Skip to content

Commit ed020a4

Browse files
committed
Initial commit
0 parents  commit ed020a4

File tree

510 files changed

+461326
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

510 files changed

+461326
-0
lines changed

.clang-format

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
---
2+
Language: Cpp
3+
BasedOnStyle: Google
4+
AccessModifierOffset: -1
5+
AlignAfterOpenBracket: Align
6+
AlignConsecutiveAssignments: true
7+
AlignConsecutiveDeclarations: true
8+
AlignEscapedNewlinesLeft: true
9+
AlignOperands: true
10+
AlignTrailingComments: true
11+
AllowAllParametersOfDeclarationOnNextLine: true
12+
AllowShortBlocksOnASingleLine: false
13+
AllowShortCaseLabelsOnASingleLine: false
14+
AllowShortFunctionsOnASingleLine: All
15+
AllowShortIfStatementsOnASingleLine: true
16+
AllowShortLoopsOnASingleLine: true
17+
AlwaysBreakAfterDefinitionReturnType: None
18+
AlwaysBreakAfterReturnType: None
19+
AlwaysBreakBeforeMultilineStrings: true
20+
AlwaysBreakTemplateDeclarations: true
21+
BinPackArguments: true
22+
BinPackParameters: true
23+
BreakBeforeBraces: Custom
24+
BraceWrapping:
25+
AfterCaseLabel: true
26+
AfterClass: true
27+
AfterControlStatement: true
28+
AfterEnum: true
29+
AfterFunction: true
30+
AfterNamespace: true
31+
AfterObjCDeclaration: true
32+
AfterStruct: true
33+
AfterUnion: true
34+
BeforeElse: true
35+
IndentBraces: false
36+
BreakBeforeBinaryOperators: None
37+
BreakBeforeTernaryOperators: true
38+
BreakConstructorInitializersBeforeComma: false
39+
ColumnLimit: 120
40+
CommentPragmas: "^ IWYU pragma:"
41+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
42+
ConstructorInitializerIndentWidth: 4
43+
ContinuationIndentWidth: 4
44+
Cpp11BracedListStyle: false
45+
DerivePointerAlignment: false
46+
DisableFormat: false
47+
ExperimentalAutoDetectBinPacking: false
48+
ForEachMacros: [foreach, Q_FOREACH, BOOST_FOREACH]
49+
IncludeCategories:
50+
- Regex: '^<.*\.h>'
51+
Priority: 1
52+
- Regex: "^<.*"
53+
Priority: 2
54+
- Regex: ".*"
55+
Priority: 3
56+
IndentCaseLabels: false
57+
IndentWidth: 4
58+
IndentWrappedFunctionNames: false
59+
KeepEmptyLinesAtTheStartOfBlocks: false
60+
MacroBlockBegin: ""
61+
MacroBlockEnd: ""
62+
MaxEmptyLinesToKeep: 1
63+
NamespaceIndentation: None
64+
ObjCBlockIndentWidth: 2
65+
ObjCSpaceAfterProperty: false
66+
ObjCSpaceBeforeProtocolList: false
67+
PenaltyBreakBeforeFirstCallParameter: 1
68+
PenaltyBreakComment: 300
69+
PenaltyBreakFirstLessLess: 120
70+
PenaltyBreakString: 1000
71+
PenaltyExcessCharacter: 1000000
72+
PenaltyReturnTypeOnItsOwnLine: 200
73+
PointerAlignment: Left
74+
ReflowComments: true
75+
SortIncludes: false
76+
SpaceAfterCStyleCast: true
77+
SpaceBeforeAssignmentOperators: true
78+
SpaceBeforeParens: Never
79+
SpaceInEmptyParentheses: true
80+
SpacesBeforeTrailingComments: 2
81+
SpacesInAngles: true
82+
SpacesInContainerLiterals: true
83+
SpacesInCStyleCastParentheses: true
84+
SpacesInParentheses: true
85+
SpacesInSquareBrackets: false
86+
Standard: Auto
87+
TabWidth: 4
88+
UseTab: Never

Drivers/BSP/Components/Leds/leds.c

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
/*!
2+
* \file leds.c
3+
*
4+
* \brief leds driver implementation.
5+
*
6+
* Revised BSD License
7+
* Copyright Semtech Corporation 2020. All rights reserved.
8+
*
9+
* Redistribution and use in source and binary forms, with or without
10+
* modification, are permitted provided that the following conditions are met:
11+
* * Redistributions of source code must retain the above copyright
12+
* notice, this list of conditions and the following disclaimer.
13+
* * Redistributions in binary form must reproduce the above copyright
14+
* notice, this list of conditions and the following disclaimer in the
15+
* documentation and/or other materials provided with the distribution.
16+
* * Neither the name of the Semtech corporation nor the
17+
* names of its contributors may be used to endorse or promote products
18+
* derived from this software without specific prior written permission.
19+
*
20+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23+
* ARE DISCLAIMED. IN NO EVENT SHALL SEMTECH CORPORATION BE LIABLE FOR ANY
24+
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
27+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30+
*/
31+
32+
/*
33+
* -----------------------------------------------------------------------------
34+
* --- DEPENDENCIES ------------------------------------------------------------
35+
*/
36+
37+
#include "smtc_hal.h"
38+
#include "leds.h"
39+
40+
/*
41+
* -----------------------------------------------------------------------------
42+
* --- PRIVATE MACROS-----------------------------------------------------------
43+
*/
44+
45+
/*
46+
* -----------------------------------------------------------------------------
47+
* --- PRIVATE CONSTANTS -------------------------------------------------------
48+
*/
49+
50+
/*
51+
* -----------------------------------------------------------------------------
52+
* --- PRIVATE TYPES -----------------------------------------------------------
53+
*/
54+
55+
/*
56+
* -----------------------------------------------------------------------------
57+
* --- PRIVATE VARIABLES -------------------------------------------------------
58+
*/
59+
60+
/*
61+
* -----------------------------------------------------------------------------
62+
* --- PRIVATE FUNCTIONS DECLARATION -------------------------------------------
63+
*/
64+
65+
/*
66+
* -----------------------------------------------------------------------------
67+
* --- PUBLIC FUNCTIONS DEFINITION ---------------------------------------------
68+
*/
69+
70+
void leds_init( void ){
71+
hal_gpio_init_out( LED_TX, 1 );
72+
hal_gpio_init_out( LED_RX, 1 );
73+
}
74+
75+
void leds_deinit( void ){
76+
hal_gpio_deinit( LED_TX );
77+
hal_gpio_deinit( LED_RX );
78+
}
79+
80+
void leds_on( uint8_t leds ){
81+
82+
if( leds & LED_TX_MASK )
83+
{
84+
// LED1
85+
hal_gpio_set_value( LED_TX, GPIO_PIN_RESET );
86+
}
87+
if( leds & LED_RX_MASK )
88+
{
89+
// LED2
90+
hal_gpio_set_value( LED_RX, GPIO_PIN_RESET );
91+
}
92+
}
93+
94+
void leds_off( uint8_t leds ){
95+
96+
if( leds & LED_TX_MASK )
97+
{
98+
// LED1
99+
hal_gpio_set_value( LED_TX, GPIO_PIN_SET );
100+
}
101+
if( leds & LED_RX_MASK )
102+
{
103+
// LED2
104+
hal_gpio_set_value( LED_RX, GPIO_PIN_SET );
105+
}
106+
}
107+
108+
void leds_toggle( uint8_t leds ){
109+
110+
if( leds & LED_TX_MASK )
111+
{
112+
// LED1
113+
hal_gpio_toggle( LED_TX );
114+
}
115+
if( leds & LED_RX_MASK )
116+
{
117+
// LED2
118+
hal_gpio_toggle( LED_RX );
119+
}
120+
}
121+
122+
void leds_blink( uint8_t leds, uint32_t delay, uint8_t nb_blink, bool reset_leds )
123+
{
124+
uint8_t i=0;
125+
126+
if(reset_leds == true)
127+
{
128+
leds_off( LED_ALL_MASK );
129+
}
130+
131+
while( i < nb_blink )
132+
{
133+
i++;
134+
leds_on( leds );
135+
HAL_Delay( delay / 2 );
136+
leds_off( leds );
137+
HAL_Delay( delay / 2 );
138+
}
139+
}
140+
141+
/*
142+
* -----------------------------------------------------------------------------
143+
* --- PRIVATE FUNCTIONS DEFINITION --------------------------------------------
144+
*/
145+
146+
/* --- EOF ------------------------------------------------------------------ */

Drivers/BSP/Components/Leds/leds.h

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
/**
2+
* @file leds.h
3+
*
4+
* @brief Leds driver definition.
5+
*
6+
* Revised BSD License
7+
* Copyright Semtech Corporation 2020. All rights reserved.
8+
*
9+
* Redistribution and use in source and binary forms, with or without
10+
* modification, are permitted provided that the following conditions are met:
11+
* * Redistributions of source code must retain the above copyright
12+
* notice, this list of conditions and the following disclaimer.
13+
* * Redistributions in binary form must reproduce the above copyright
14+
* notice, this list of conditions and the following disclaimer in the
15+
* documentation and/or other materials provided with the distribution.
16+
* * Neither the name of the Semtech corporation nor the
17+
* names of its contributors may be used to endorse or promote products
18+
* derived from this software without specific prior written permission.
19+
*
20+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23+
* ARE DISCLAIMED. IN NO EVENT SHALL SEMTECH CORPORATION BE LIABLE FOR ANY
24+
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
27+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30+
*/
31+
32+
#ifndef __LEDS_H__
33+
#define __LEDS_H__
34+
35+
#ifdef __cplusplus
36+
extern "C" {
37+
#endif
38+
39+
/*
40+
* -----------------------------------------------------------------------------
41+
* --- DEPENDENCIES ------------------------------------------------------------
42+
*/
43+
44+
#include <stdint.h>
45+
#include <stdbool.h>
46+
47+
/*
48+
* -----------------------------------------------------------------------------
49+
* --- PUBLIC MACROS -----------------------------------------------------------
50+
*/
51+
52+
/*
53+
* -----------------------------------------------------------------------------
54+
* --- PUBLIC CONSTANTS --------------------------------------------------------
55+
*/
56+
57+
/*!
58+
* \brief LED TX MASK
59+
*/
60+
#define LED_TX_MASK 0x01
61+
62+
/*!
63+
* \brief LED RX MASK
64+
*/
65+
#define LED_RX_MASK 0x02
66+
67+
/*!
68+
* \brief LED ALL MASK
69+
*/
70+
#define LED_ALL_MASK 0x03
71+
72+
/*
73+
* -----------------------------------------------------------------------------
74+
* --- PUBLIC TYPES ------------------------------------------------------------
75+
*/
76+
77+
/*
78+
* -----------------------------------------------------------------------------
79+
* --- PUBLIC FUNCTIONS PROTOTYPES ---------------------------------------------
80+
*/
81+
82+
/*!
83+
* \brief Init Leds
84+
*/
85+
void leds_init( void );
86+
87+
/*!
88+
* \brief Deinit Leds
89+
*/
90+
void leds_deinit( void );
91+
/*!
92+
* \brief Select and turn on Leds
93+
*
94+
* \param [in] leds Leds MASK to turn on leds
95+
*/
96+
void leds_on( uint8_t leds );
97+
98+
/*!
99+
* \brief Select and turn off Leds
100+
*
101+
* \param [in] leds Leds MASK to turn off leds
102+
*/
103+
void leds_off( uint8_t leds );
104+
105+
/*!
106+
* \brief Select and toggle Leds
107+
*
108+
* \param [in] leds Leds MASK to turn off leds
109+
*/
110+
void leds_toggle( uint8_t leds );
111+
112+
/*!
113+
* \brief Select and toggle Leds
114+
*
115+
* \param [in] leds Leds MASK to turn off leds
116+
* \param [in] delay Blink delay
117+
* \param [in] nb_blink Number of blink
118+
* \param [in] reset_leds Reset leds at the beginning
119+
*/
120+
void leds_blink( uint8_t leds, uint32_t delay, uint8_t nb_blink, bool reset_leds );
121+
122+
#ifdef __cplusplus
123+
}
124+
#endif
125+
126+
#endif //__LEDS_H__

0 commit comments

Comments
 (0)