55#define CC26XX_UART_RX_INTERRUPT_TRIGGERS (UART_INT_RX | UART_INT_RT)
58#define CC26XX_UART_INTERRUPT_ALL (UART_INT_OE | UART_INT_BE | UART_INT_PE | \
59 UART_INT_FE | UART_INT_RT | UART_INT_TX | \
60 UART_INT_RX | UART_INT_CTS)
62#define cc26xx_uart_isr UART0IntHandler
64static int (*input_handler)(
unsigned char c);
79 ti_lib_prcm_power_domain_on(PRCM_DOMAIN_SERIAL);
80 while(ti_lib_prcm_power_domain_status(PRCM_DOMAIN_SERIAL)
81 != PRCM_DOMAIN_POWER_ON);
84 ti_lib_prcm_peripheral_run_enable(PRCM_PERIPH_UART0);
85 ti_lib_prcm_load_set();
86 while(!ti_lib_prcm_load_get());
102 if(ti_lib_prcm_power_domain_status(PRCM_DOMAIN_SERIAL)
103 != PRCM_DOMAIN_POWER_ON) {
108 if(!(HWREG(PRCM_BASE + PRCM_O_UARTCLKGR) & PRCM_UARTCLKGR_CLK_EN)) {
116disable_interrupts(
void)
119 ti_lib_int_disable(INT_UART0_COMB);
122 ti_lib_uart_int_disable(UART0_BASE, CC26XX_UART_INTERRUPT_ALL);
125 ti_lib_uart_int_clear(UART0_BASE, CC26XX_UART_INTERRUPT_ALL);
129enable_interrupts(
void)
132 ti_lib_uart_int_clear(UART0_BASE, CC26XX_UART_INTERRUPT_ALL);
137 ti_lib_uart_int_enable(UART0_BASE, CC26XX_UART_RX_INTERRUPT_TRIGGERS);
140 ti_lib_int_enable(INT_UART0_COMB);
152 ti_lib_ioc_pin_type_gpio_output(BOARD_IOID_UART_TX);
153 ti_lib_gpio_set_dio(BOARD_IOID_UART_TX);
159 ti_lib_ioc_pin_type_uart(UART0_BASE, BOARD_IOID_UART_RX, BOARD_IOID_UART_TX,
160 BOARD_IOID_UART_CTS, BOARD_IOID_UART_RTS);
163 ti_lib_uart_config_set_exp_clk(UART0_BASE, ti_lib_sys_ctrl_clock_get(),
165 (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
166 UART_CONFIG_PAR_NONE));
172 ti_lib_uart_fifo_level_set(UART0_BASE, UART_FIFO_TX7_8, UART_FIFO_RX4_8);
182 HWREG(UART0_BASE + UART_O_CTL) = ctl_val;
186lpm_drop_handler(uint8_t mode)
198 while(ti_lib_uart_busy(UART0_BASE));
206 if((mode != LPM_MODE_SHUTDOWN) && (input_handler != NULL)) {
218 ti_lib_uart_disable(UART0_BASE);
221 disable_interrupts();
228 ti_lib_prcm_peripheral_run_disable(PRCM_PERIPH_UART0);
229 if(mode == LPM_MODE_SHUTDOWN) {
230 ti_lib_prcm_peripheral_sleep_disable(PRCM_PERIPH_UART0);
231 ti_lib_prcm_peripheral_deep_sleep_disable(PRCM_PERIPH_UART0);
233 ti_lib_prcm_load_set();
234 while(!ti_lib_prcm_load_get());
244LPM_MODULE(uart_module, NULL, lpm_drop_handler, NULL, LPM_DOMAIN_NONE);
252 ti_lib_uart_disable(UART0_BASE);
255 disable_interrupts();
267 bool interrupts_disabled;
270 if(!usable(BOARD_IOID_UART_TX) && !usable(BOARD_IOID_UART_RX)) {
275 interrupts_disabled = ti_lib_int_master_disable();
281 input_handler = NULL;
289 if(!interrupts_disabled) {
290 ti_lib_int_master_enable();
298 if(!usable(BOARD_IOID_UART_TX)) {
306 ti_lib_uart_char_put(UART0_BASE, c);
312 input_handler =
input;
315 if(!usable(BOARD_IOID_UART_RX)) {
321 uart_module.domain_lock = LPM_DOMAIN_NONE;
324 ti_lib_prcm_peripheral_sleep_disable(PRCM_PERIPH_UART0);
325 ti_lib_prcm_peripheral_deep_sleep_disable(PRCM_PERIPH_UART0);
328 uart_module.domain_lock = LPM_DOMAIN_SERIAL;
331 ti_lib_prcm_peripheral_sleep_enable(PRCM_PERIPH_UART0);
332 ti_lib_prcm_peripheral_deep_sleep_enable(PRCM_PERIPH_UART0);
335 ti_lib_prcm_load_set();
336 while(!ti_lib_prcm_load_get());
347 if(!usable(BOARD_IOID_UART_TX)) {
356 return ti_lib_uart_busy(UART0_BASE);
368 flags = ti_lib_uart_int_status(UART0_BASE,
true);
371 ti_lib_uart_int_clear(UART0_BASE, CC26XX_UART_INTERRUPT_ALL);
373 if((flags & CC26XX_UART_RX_INTERRUPT_TRIGGERS) != 0) {
378 while(ti_lib_uart_chars_avail(UART0_BASE)) {
379 the_char = ti_lib_uart_char_get_non_blocking(UART0_BASE);
381 if(input_handler != NULL) {
382 input_handler((
unsigned char)the_char);
Header file for the CC13xx/CC26xx UART driver.
#define UART_CTL_UARTEN
UART enable.
#define UART_CTL_RXE
UART receive enable.
#define UART_LCRH_FEN
UART enable FIFOs.
#define UART_CTL_TXE
UART transmit enable.
void lpm_pin_set_default_state(uint32_t ioid)
Sets an IOID to a default state.
#define LPM_MODULE(n, m, s, w, l)
Declare a variable to be used in order to get notifications from LPM.
void lpm_register_module(lpm_registered_module_t *module)
Register a module for LPM notifications.
void cc26xx_uart_init()
Initialises the UART controller, configures I/O control and interrupts.
void cc26xx_uart_set_input(int(*input)(unsigned char c))
Assigns a callback to be called when the UART receives a byte.
void cc26xx_uart_write_byte(uint8_t c)
Sends a single character down the UART.
uint8_t cc26xx_uart_busy(void)
Returns the UART busy status.
#define TI_UART_CONF_BAUD_RATE
Default UART0 baud rate.
#define TI_UART_CONF_ENABLE
Enable/Disable UART I/O.
static void input(void)
Process a received 6lowpan packet.
Header file with declarations for the I/O Control module.
Header file with macros which rename TI CC26xxware functions.
Header file for the cc2538 UART driver.