From e3f3171a33f12064b876b98b537f2c6347761f42 Mon Sep 17 00:00:00 2001 From: Gareth McMullin Date: Sat, 27 Apr 2013 13:14:22 -0700 Subject: usbuart: Fix build error and clean up whitespace. --- src/platforms/stm32/usbuart.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'src/platforms/stm32') diff --git a/src/platforms/stm32/usbuart.c b/src/platforms/stm32/usbuart.c index 6694d90..7f5ebde 100644 --- a/src/platforms/stm32/usbuart.c +++ b/src/platforms/stm32/usbuart.c @@ -75,9 +75,12 @@ void usbuart_init(void) /* Setup timer for running deferred FIFO processing */ USBUSART_TIM_CLK_EN(); timer_reset(USBUSART_TIM); - timer_set_mode(USBUSART_TIM, TIM_CR1_CKD_CK_INT, TIM_CR1_CMS_EDGE, TIM_CR1_DIR_UP); - timer_set_prescaler(USBUSART_TIM, rcc_ppre2_frequency/TIMER_FREQ_HZ*2 - 1); - timer_set_period(USBUSART_TIM, TIMER_FREQ_HZ/USBUART_RUN_FREQ_HZ - 1); + timer_set_mode(USBUSART_TIM, TIM_CR1_CKD_CK_INT, + TIM_CR1_CMS_EDGE, TIM_CR1_DIR_UP); + timer_set_prescaler(USBUSART_TIM, + rcc_ppre2_frequency / USBUART_TIMER_FREQ_HZ * 2 - 1); + timer_set_period(USBUSART_TIM, + USBUART_TIMER_FREQ_HZ / USBUART_RUN_FREQ_HZ - 1); /* Setup update interrupt in NVIC */ nvic_set_priority(USBUSART_TIM_IRQ, IRQ_PRI_USBUSART_TIM); @@ -88,8 +91,9 @@ void usbuart_init(void) } /* - * Runs deferred processing for usb uart rx, draining RX FIFO by sending characters to host PC via CDCACM. - * Allowed to read from FIFO in pointer, but not write to it. Allowed to write to FIFO out pointer. + * Runs deferred processing for usb uart rx, draining RX FIFO by sending + * characters to host PC via CDCACM. Allowed to read from FIFO in pointer, + * but not write to it. Allowed to write to FIFO out pointer. */ static void usbuart_run(void) { @@ -125,7 +129,9 @@ static void usbuart_run(void) } /* advance fifo out pointer by amount written */ - buf_rx_out = (buf_rx_out + usbd_ep_write_packet(usbdev, CDCACM_UART_ENDPOINT, packet_buf, packet_size)) % FIFO_SIZE; + buf_rx_out += usbd_ep_write_packet(usbdev, + CDCACM_UART_ENDPOINT, packet_buf, packet_size); + buf_rx_out %= FIFO_SIZE; } } @@ -188,7 +194,8 @@ void usbuart_usb_in_cb(usbd_device *dev, uint8_t ep) /* * Read a character from the UART RX and stuff it in a software FIFO. - * Allowed to read from FIFO out pointer, but not write to it. Allowed to write to FIFO in pointer. + * Allowed to read from FIFO out pointer, but not write to it. + * Allowed to write to FIFO in pointer. */ void USBUSART_ISR(void) { @@ -224,3 +231,4 @@ void USBUSART_TIM_ISR(void) /* process FIFO */ usbuart_run(); } + -- cgit v1.2.3