@@ -143,7 +143,9 @@ int usb_cb_ep1_in(uint8_t *usbdata, int len, bool hardwired) {
143
143
UNUSED (hardwired );
144
144
CAN_FIFOMailBox_TypeDef * reply = (CAN_FIFOMailBox_TypeDef * )usbdata ;
145
145
int ilen = 0 ;
146
- while (ilen < MIN (len /0x10 , 4 ) && can_pop (& can_rx_q , & reply [ilen ])) ilen ++ ;
146
+ while (ilen < MIN (len /0x10 , 4 ) && can_pop (& can_rx_q , & reply [ilen ])) {
147
+ ilen ++ ;
148
+ }
147
149
return ilen * 0x10 ;
148
150
}
149
151
@@ -153,7 +155,11 @@ void usb_cb_ep2_out(uint8_t *usbdata, int len, bool hardwired) {
153
155
uart_ring * ur = get_ring_by_number (usbdata [0 ]);
154
156
if ((len != 0 ) && (ur != NULL )) {
155
157
if ((usbdata [0 ] < 2 ) || safety_tx_lin_hook (usbdata [0 ]- 2 , usbdata + 1 , len - 1 )) {
156
- for (int i = 1 ; i < len ; i ++ ) while (!putc (ur , usbdata [i ]));
158
+ for (int i = 1 ; i < len ; i ++ ) {
159
+ while (!putc (ur , usbdata [i ])) {
160
+ // wait
161
+ }
162
+ }
157
163
}
158
164
}
159
165
}
@@ -340,8 +346,12 @@ int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp, bool hardwired)
340
346
// **** 0xe0: uart read
341
347
case 0xe0 :
342
348
ur = get_ring_by_number (setup -> b .wValue .w );
343
- if (!ur ) break ;
344
- if (ur == & esp_ring ) uart_dma_drain ();
349
+ if (!ur ) {
350
+ break ;
351
+ }
352
+ if (ur == & esp_ring ) {
353
+ uart_dma_drain ();
354
+ }
345
355
// read
346
356
while ((resp_len < MIN (setup -> b .wLength .w , MAX_RESP_LEN )) &&
347
357
getc (ur , (char * )& resp [resp_len ])) {
@@ -351,13 +361,17 @@ int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp, bool hardwired)
351
361
// **** 0xe1: uart set baud rate
352
362
case 0xe1 :
353
363
ur = get_ring_by_number (setup -> b .wValue .w );
354
- if (!ur ) break ;
364
+ if (!ur ) {
365
+ break ;
366
+ }
355
367
uart_set_baud (ur -> uart , setup -> b .wIndex .w );
356
368
break ;
357
369
// **** 0xe2: uart set parity
358
370
case 0xe2 :
359
371
ur = get_ring_by_number (setup -> b .wValue .w );
360
- if (!ur ) break ;
372
+ if (!ur ) {
373
+ break ;
374
+ }
361
375
switch (setup -> b .wIndex .w ) {
362
376
case 0 :
363
377
// disable parity, 8-bit
@@ -380,7 +394,9 @@ int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp, bool hardwired)
380
394
// **** 0xe4: uart set baud rate extended
381
395
case 0xe4 :
382
396
ur = get_ring_by_number (setup -> b .wValue .w );
383
- if (!ur ) break ;
397
+ if (!ur ) {
398
+ break ;
399
+ }
384
400
uart_set_baud (ur -> uart , (int )setup -> b .wIndex .w * 300 );
385
401
break ;
386
402
// **** 0xe5: set CAN loopback (for testing)
@@ -578,8 +594,9 @@ void TIM3_IRQHandler(void) {
578
594
puts("\n");*/
579
595
580
596
// reset this every 16th pass
581
- if ((tcnt & 0xF ) == 0 ) pending_can_live = 0 ;
582
-
597
+ if ((tcnt & 0xF ) == 0 ) {
598
+ pending_can_live = 0 ;
599
+ }
583
600
#ifdef DEBUG
584
601
puts ("** blink " );
585
602
puth (can_rx_q .r_ptr ); puts (" " ); puth (can_rx_q .w_ptr ); puts (" " );
@@ -621,7 +638,9 @@ int main(void) {
621
638
puts (is_entering_bootmode ? " ESP wants bootmode\n" : " no bootmode\n" );
622
639
623
640
// non rev c panda are no longer supported
624
- while (revision != PANDA_REV_C );
641
+ while (revision != PANDA_REV_C ) {
642
+ // hang
643
+ }
625
644
626
645
gpio_init ();
627
646
0 commit comments