29 #if defined(RETARGET_USART)
33 #if defined(RETARGET_LEUART)
39 static volatile int rxReadIndex = 0;
40 static volatile int rxWriteIndex = 0;
41 static volatile int rxCount = 0;
42 static volatile uint8_t rxBuffer[RXBUFSIZE];
43 static uint8_t LFtoCRLF = 0;
44 static bool initialized = false;
49 void RETARGET_IRQ_NAME(void)
51 #if defined(RETARGET_USART)
105 #if defined(RETARGET_USART)
110 RETARGET_PERIPHERAL_ENABLE();
119 #if defined( USART_ROUTEPEN_RXPEN )
120 usart->ROUTEPEN = USART_ROUTEPEN_RXPEN | USART_ROUTEPEN_TXPEN;
121 usart->ROUTELOC0 = ( usart->ROUTELOC0 &
122 ~( _USART_ROUTELOC0_TXLOC_MASK
123 | _USART_ROUTELOC0_RXLOC_MASK ) )
124 | ( RETARGET_TX_LOCATION << _USART_ROUTELOC0_TXLOC_SHIFT )
125 | ( RETARGET_RX_LOCATION << _USART_ROUTELOC0_RXLOC_SHIFT );
132 NVIC_ClearPendingIRQ(RETARGET_IRQn);
136 NVIC_EnableIRQ(RETARGET_IRQn);
146 RETARGET_PERIPHERAL_ENABLE();
151 #if defined(RETARGET_VCOM)
153 #if defined(_CMU_LFCLKSEL_LFB_HFCORECLKLEDIV2)
170 #if defined(RETARGET_VCOM)
175 #if defined( LEUART_ROUTEPEN_RXPEN )
176 leuart->ROUTEPEN = USART_ROUTEPEN_RXPEN | USART_ROUTEPEN_TXPEN;
177 leuart->ROUTELOC0 = ( leuart->ROUTELOC0 &
178 ~( _LEUART_ROUTELOC0_TXLOC_MASK
179 | _LEUART_ROUTELOC0_RXLOC_MASK ) )
180 | ( RETARGET_TX_LOCATION << _LEUART_ROUTELOC0_TXLOC_SHIFT )
181 | ( RETARGET_RX_LOCATION << _LEUART_ROUTELOC0_RXLOC_SHIFT );
188 NVIC_ClearPendingIRQ(RETARGET_IRQn);
192 NVIC_EnableIRQ(RETARGET_IRQn);
198 #if !defined(__CROSSWORKS_ARM) && defined(__GNUC__)
199 setvbuf(stdout, NULL, _IONBF, 0);
251 RETARGET_TX(RETARGET_UART,
'\r');
253 RETARGET_TX(RETARGET_UART, c);
257 RETARGET_TX(RETARGET_UART,
'\n');
Clock management unit (CMU) API.
void CMU_ClockSelectSet(CMU_Clock_TypeDef clock, CMU_Select_TypeDef ref)
Select reference clock/oscillator used for a clock branch.
int RETARGET_ReadChar(void)
Receive a byte from USART/LEUART and put into global buffer.
#define CORE_DECLARE_IRQ_STATE
__STATIC_INLINE void USART_IntClear(USART_TypeDef *usart, uint32_t flags)
Clear one or more pending USART interrupts.
CMSIS Cortex-M Peripheral Access Layer for Silicon Laboratories microcontroller devices.
Universal synchronous/asynchronous receiver/transmitter (USART/UART) peripheral API.
__STATIC_INLINE void USART_IntEnable(USART_TypeDef *usart, uint32_t flags)
Enable one or more USART interrupts.
USART_Enable_TypeDef enable
Retarget stdout to a serial port.
__STATIC_INLINE void LEUART_IntClear(LEUART_TypeDef *leuart, uint32_t flags)
Clear one or more pending LEUART interrupts.
void LEUART_Init(LEUART_TypeDef *leuart, LEUART_Init_TypeDef const *init)
Init LEUART.
#define LEUART_IF_RXDATAV
__STATIC_INLINE void LEUART_IntEnable(LEUART_TypeDef *leuart, uint32_t flags)
Enable one or more LEUART interrupts.
#define CORE_ENTER_ATOMIC()
#define USART_ROUTE_TXPEN
void GPIO_PinModeSet(GPIO_Port_TypeDef port, unsigned int pin, GPIO_Mode_TypeDef mode, unsigned int out)
Set the mode for a GPIO pin.
General Purpose IO (GPIO) peripheral API.
int RETARGET_WriteChar(char c)
Transmit single byte to USART/LEUART.
#define LEUART_ROUTE_RXPEN
Core interrupt handling API.
void CMU_ClockEnable(CMU_Clock_TypeDef clock, bool enable)
Enable/disable a clock.
void LEUART_Enable(LEUART_TypeDef *leuart, LEUART_Enable_TypeDef enable)
Enable/disable LEUART receiver and/or transmitter.
static volatile int rxCount
Low Energy Universal Asynchronous Receiver/Transmitter (LEUART) peripheral API.
static volatile int rxWriteIndex
static volatile int rxReadIndex
void RETARGET_SerialInit(void)
Intializes UART/LEUART.
#define CORE_EXIT_ATOMIC()
#define USART_STATUS_RXDATAV
static volatile uint8_t rxBuffer[RXBUFSIZE]
#define USART_INITASYNC_DEFAULT
void USART_Enable(USART_TypeDef *usart, USART_Enable_TypeDef enable)
Enable/disable USART/UART receiver and/or transmitter.
void USART_InitAsync(USART_TypeDef *usart, const USART_InitAsync_TypeDef *init)
Init USART/UART for normal asynchronous mode.
#define LEUART_ROUTE_TXPEN
#define LEUART_INIT_DEFAULT
#define USART_ROUTE_RXPEN
void RETARGET_SerialCrLf(int on)
UART/LEUART toggle LF to CRLF conversion.
void CMU_ClockDivSet(CMU_Clock_TypeDef clock, CMU_ClkDiv_TypeDef div)
Set clock divisor/prescaler.
LEUART_Enable_TypeDef enable