File tree 4 files changed +29
-27
lines changed
4 files changed +29
-27
lines changed Original file line number Diff line number Diff line change 19
19
20
20
#include "board_driver_led.h"
21
21
22
+ volatile uint8_t ledKeepValue = 0 ;
23
+ volatile uint8_t ledTargetValue = 20 ;
24
+ volatile int8_t ledDirection = 1 ;
22
25
26
+ inline void LED_pulse ()
27
+ {
28
+ if (ledKeepValue == 0 ) {
29
+ ledTargetValue += ledDirection ;
30
+ LED_toggle ();
31
+ }
32
+ ledKeepValue ++ ;
33
+
34
+ if (ledTargetValue > 240 || ledTargetValue < 10 ) {
35
+ ledDirection = - ledDirection ;
36
+ ledTargetValue += ledDirection ;
37
+ }
38
+
39
+ if (ledKeepValue == ledTargetValue ) {
40
+ LED_toggle ();
41
+ }
42
+ }
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ inline void LED_init(void) { PORT->Group[BOARD_LED_PORT].DIRSET.reg = (1<<BOARD_
27
27
inline void LED_on (void ) { PORT -> Group [BOARD_LED_PORT ].OUTSET .reg = (1 <<BOARD_LED_PIN ); }
28
28
inline void LED_off (void ) { PORT -> Group [BOARD_LED_PORT ].OUTCLR .reg = (1 <<BOARD_LED_PIN ); }
29
29
inline void LED_toggle (void ) { PORT -> Group [BOARD_LED_PORT ].OUTTGL .reg = (1 <<BOARD_LED_PIN ); }
30
+ void LED_pulse ();
30
31
31
32
inline void LEDRX_init (void ) { PORT -> Group [BOARD_LEDRX_PORT ].DIRSET .reg = (1 <<BOARD_LEDRX_PIN ); }
32
33
inline void LEDRX_on (void ) { PORT -> Group [BOARD_LEDRX_PORT ].OUTCLR .reg = (1 <<BOARD_LEDRX_PIN ); }
@@ -38,6 +39,4 @@ inline void LEDTX_on(void) { PORT->Group[BOARD_LEDTX_PORT].OUTCLR.reg = (1<<BOAR
38
39
inline void LEDTX_off (void ) { PORT -> Group [BOARD_LEDTX_PORT ].OUTSET .reg = (1 <<BOARD_LEDTX_PIN ); }
39
40
inline void LEDTX_toggle (void ) { PORT -> Group [BOARD_LEDTX_PORT ].OUTTGL .reg = (1 <<BOARD_LEDTX_PIN ); }
40
41
41
- inline void LED_configure (uint32_t sampleRate ) { SysTick_Config (sampleRate ); }
42
-
43
42
#endif // _BOARD_DRIVER_LED_
Original file line number Diff line number Diff line change 18
18
*/
19
19
20
20
#include <sam.h>
21
- #include "board_driver_led.h"
22
21
23
22
struct ConstVectors
24
23
{
@@ -140,26 +139,3 @@ void PendSV_Handler(void)
140
139
__BKPT (2 );
141
140
while (1 );
142
141
}
143
-
144
- volatile uint8_t keepValue = 0 ;
145
- volatile uint8_t targetValue = 20 ;
146
- volatile int8_t direction = 1 ;
147
-
148
- void SysTick_Handler (void )
149
- {
150
- if (keepValue == 0 ) {
151
- targetValue += direction ;
152
- LED_toggle ();
153
- }
154
- keepValue ++ ;
155
-
156
- if (targetValue > 240 || targetValue < 10 ) {
157
- direction = - direction ;
158
- targetValue += direction ;
159
- }
160
-
161
- if (keepValue == targetValue ) {
162
- LED_toggle ();
163
- }
164
- //TC5->COUNT16.INTFLAG.bit.MC0 = 1; // Clear interrupt
165
- }
Original file line number Diff line number Diff line change @@ -181,12 +181,14 @@ int main(void)
181
181
182
182
/* Initialize LEDs */
183
183
LED_init ();
184
- LED_configure (1000 );
185
184
LEDRX_init ();
186
185
LEDRX_off ();
187
186
LEDTX_init ();
188
187
LEDTX_off ();
189
188
189
+ /* Start the sys tick (1 ms) */
190
+ SysTick_Config (1000 );
191
+
190
192
/* Wait for a complete enum on usb or a '#' char on serial line */
191
193
while (1 )
192
194
{
@@ -222,3 +224,8 @@ int main(void)
222
224
#endif
223
225
}
224
226
}
227
+
228
+ void SysTick_Handler (void )
229
+ {
230
+ LED_pulse ();
231
+ }
You can’t perform that action at this time.
0 commit comments