@@ -49,25 +49,6 @@ volatile uint32_t dma_stream_complete = 0;
49
49
uint8_t dmaStream = DMA_STREAM1 ;
50
50
uint32_t dmaChannel = DMA_SxCR_CHSEL_6 ;
51
51
uint32_t dmaUnit = DMA2 ;
52
-
53
- /*
54
- volatile uint32_t timer2Ticks = 0;
55
- volatile uint16_t tim1_dier= 0;
56
- volatile uint16_t tim1_dcr= 0;
57
- volatile uint16_t tim1_cr1= 0;
58
- volatile uint16_t tim1_cr2= 0;
59
- volatile uint16_t tim1_sr = 0;
60
- volatile uint16_t tim1_egr = 0;
61
- volatile uint32_t tim1_ccr1 = 0;
62
- volatile uint32_t tim1_ccr2 = 0;
63
- volatile uint32_t tim1_ccr3 = 0;
64
- volatile uint32_t tim1_ccr4 = 0;
65
- volatile uint32_t dma2_stream1_spar = 0;
66
- volatile uint32_t dma2_stream1_moar = 0;
67
- volatile uint32_t dma2_stream1_ndtr = 0;
68
- */
69
-
70
- //const uint16_t dma_buffer[] = { 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1400, 1300, 1200, 1100, 1000, 900, 800, 700, 600, 500, 400, 300, 200 }; // Initial duty cycle
71
52
//
72
53
// sequence of values easily recognizable on a scope
73
54
const uint16_t dma_buffer [] = { 100 , 350 , 500 , 350 };
@@ -236,21 +217,29 @@ int main(void) {
236
217
nvic_enable_irq (NVIC_DMA2_STREAM1_IRQ );
237
218
238
219
while (1 ) {
220
+ //
221
+ // report back that dma is working by generating 5 flashes
239
222
flashes = dma_stream_complete > 0 ? 5 :1 ;
240
223
offTime = 3000 - (flashes * (onTime + shortOffTime ));
241
224
if (systicks > ticks ) {
242
225
//
243
226
// period elapsed
244
227
if (duration == shortOffTime && ++ flashCount == flashes ) {
228
+ //
229
+ // number of short flashes reached, start over with long time off
245
230
duration = offTime ;
246
231
gpio_set (GPIOC , GPIO13 );
247
232
flashCount = 0 ;
248
233
}
249
234
else if (duration == onTime ) {
235
+ //
236
+ // end of short flash reached, start over with short time off
250
237
duration = shortOffTime ;
251
238
gpio_set (GPIOC , GPIO13 );
252
239
}
253
240
else if (duration == shortOffTime ) {
241
+ //
242
+ // end of short time off reached, tart over with short time on
254
243
duration = onTime ;
255
244
gpio_clear (GPIOC , GPIO13 );
256
245
}
0 commit comments