usbuart: Moved usbuart_set_led_state() into aux_serial.c
This commit is contained in:
parent
9cb9cda62f
commit
3d707b4497
|
@ -22,6 +22,7 @@
|
||||||
#include <libopencm3/stm32/rcc.h>
|
#include <libopencm3/stm32/rcc.h>
|
||||||
#include <libopencm3/stm32/usart.h>
|
#include <libopencm3/stm32/usart.h>
|
||||||
#include <libopencm3/stm32/dma.h>
|
#include <libopencm3/stm32/dma.h>
|
||||||
|
#include <libopencm3/cm3/cortex.h>
|
||||||
#elif defined(LM4F)
|
#elif defined(LM4F)
|
||||||
#include <libopencm3/lm4f/rcc.h>
|
#include <libopencm3/lm4f/rcc.h>
|
||||||
#include <libopencm3/lm4f/uart.h>
|
#include <libopencm3/lm4f/uart.h>
|
||||||
|
@ -233,6 +234,28 @@ void aux_serial_set_encoding(struct usb_cdc_line_coding *coding)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(STM32F0) || defined(STM32F1) || defined(STM32F3) || defined(STM32F4)
|
#if defined(STM32F0) || defined(STM32F1) || defined(STM32F3) || defined(STM32F4)
|
||||||
|
/*
|
||||||
|
* Update led state atomically respecting RX anb TX states.
|
||||||
|
*/
|
||||||
|
void usbuart_set_led_state(uint8_t ledn, bool state)
|
||||||
|
{
|
||||||
|
CM_ATOMIC_CONTEXT();
|
||||||
|
|
||||||
|
static uint8_t led_state = 0;
|
||||||
|
|
||||||
|
if (state)
|
||||||
|
{
|
||||||
|
led_state |= ledn;
|
||||||
|
gpio_set(LED_PORT_UART, LED_UART);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
led_state &= ~ledn;
|
||||||
|
if (!led_state)
|
||||||
|
gpio_clear(LED_PORT_UART, LED_UART);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
char *aux_serial_current_transmit_buffer(void)
|
char *aux_serial_current_transmit_buffer(void)
|
||||||
{
|
{
|
||||||
return aux_serial_transmit_buffer[aux_serial_transmit_buffer_index];
|
return aux_serial_transmit_buffer[aux_serial_transmit_buffer_index];
|
||||||
|
|
|
@ -28,6 +28,8 @@ void aux_serial_init(void);
|
||||||
void aux_serial_set_encoding(struct usb_cdc_line_coding *coding);
|
void aux_serial_set_encoding(struct usb_cdc_line_coding *coding);
|
||||||
|
|
||||||
#if defined(STM32F0) || defined(STM32F1) || defined(STM32F3) || defined(STM32F4)
|
#if defined(STM32F0) || defined(STM32F1) || defined(STM32F3) || defined(STM32F4)
|
||||||
|
void usbuart_set_led_state(uint8_t ledn, bool state);
|
||||||
|
|
||||||
void aux_serial_switch_transmit_buffers(void);
|
void aux_serial_switch_transmit_buffers(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -38,6 +40,7 @@ size_t aux_serial_transmit_buffer_fullness(void);
|
||||||
/* Send a number of bytes staged into the current transmit bufer */
|
/* Send a number of bytes staged into the current transmit bufer */
|
||||||
void aux_serial_send(size_t len);
|
void aux_serial_send(size_t len);
|
||||||
|
|
||||||
|
#if defined(STM32F0) || defined(STM32F1) || defined(STM32F3) || defined(STM32F4)
|
||||||
void aux_serial_update_receive_buffer_fullness(void);
|
void aux_serial_update_receive_buffer_fullness(void);
|
||||||
bool aux_serial_receive_has_data(void);
|
bool aux_serial_receive_has_data(void);
|
||||||
void aux_serial_drain_receive_buffer(void);
|
void aux_serial_drain_receive_buffer(void);
|
||||||
|
@ -45,5 +48,6 @@ void aux_serial_drain_receive_buffer(void);
|
||||||
void aux_serial_stage_debug_buffer(void);
|
void aux_serial_stage_debug_buffer(void);
|
||||||
#endif
|
#endif
|
||||||
void aux_serial_stage_receive_buffer(void);
|
void aux_serial_stage_receive_buffer(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /*AUX_SERIAL_H*/
|
#endif /*AUX_SERIAL_H*/
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
|
|
||||||
#include "general.h"
|
#include "general.h"
|
||||||
|
|
||||||
void usbuart_set_led_state(uint8_t ledn, bool state);
|
|
||||||
void debug_uart_run(void);
|
void debug_uart_run(void);
|
||||||
|
|
||||||
#define TX_LED_ACT (1 << 0)
|
#define TX_LED_ACT (1 << 0)
|
||||||
|
|
|
@ -46,25 +46,3 @@ uint8_t usb_dbg_in;
|
||||||
/* Debug Fifo out pointer */
|
/* Debug Fifo out pointer */
|
||||||
uint8_t usb_dbg_out;
|
uint8_t usb_dbg_out;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
|
||||||
* Update led state atomically respecting RX anb TX states.
|
|
||||||
*/
|
|
||||||
void usbuart_set_led_state(uint8_t ledn, bool state)
|
|
||||||
{
|
|
||||||
CM_ATOMIC_CONTEXT();
|
|
||||||
|
|
||||||
static uint8_t led_state = 0;
|
|
||||||
|
|
||||||
if (state)
|
|
||||||
{
|
|
||||||
led_state |= ledn;
|
|
||||||
gpio_set(LED_PORT_UART, LED_UART);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
led_state &= ~ledn;
|
|
||||||
if (!led_state)
|
|
||||||
gpio_clear(LED_PORT_UART, LED_UART);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue