Commit 9b8472e 1 parent 8f0add9 commit 9b8472e Copy full SHA for 9b8472e
File tree 1 file changed +14
-3
lines changed
1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -117,10 +117,11 @@ uint32_t timeout = 0;
117
117
uint32_t current_index = 0 ;
118
118
119
119
#define STATE_GOOD 0
120
- #define STATE_FAULT_CHECKSUM 1
120
+ #define STATE_FAULT_BAD_CHECKSUM 1
121
121
#define STATE_FAULT_SEND 2
122
122
#define STATE_FAULT_SCE 3
123
- uint8_t state = STATE_NONE ;
123
+ #define STATE_FAULT_STARTUP 4
124
+ uint8_t state = STATE_FAULT_STARTUP ;
124
125
125
126
void CAN1_RX0_IRQHandler () {
126
127
while (CAN -> RF0R & CAN_RF0R_FMP0 ) {
@@ -157,7 +158,7 @@ void CAN1_RX0_IRQHandler() {
157
158
current_index = index ;
158
159
} else {
159
160
// wrong checksum = fault
160
- state = STATE_FAULT_CHECKSUM ;
161
+ state = STATE_FAULT_BAD_CHECKSUM ;
161
162
}
162
163
}
163
164
// next
@@ -234,6 +235,9 @@ void pedal() {
234
235
dac_set (0 , pdl0 );
235
236
dac_set (1 , pdl1 );
236
237
}
238
+
239
+ // feed the watchdog
240
+ IWDG -> KR = 0xAAAA ;
237
241
}
238
242
239
243
int main () {
@@ -267,6 +271,13 @@ int main() {
267
271
268
272
NVIC_EnableIRQ (TIM3_IRQn );
269
273
274
+ // setup watchdog
275
+ IWDG -> KR = 0x5555 ;
276
+ IWDG -> PR = 0 ; // divider /4
277
+ // 0 = 0.125 ms, let's have a 50ms watchdog
278
+ IWDG -> RLR = 400 - 1 ;
279
+ IWDG -> KR = 0xCCCC ;
280
+
270
281
puts ("**** INTERRUPTS ON ****\n" );
271
282
__enable_irq ();
272
283
You can’t perform that action at this time.
0 commit comments