Improve UART power-cycling logic:
* Only enable TX by default. * Add some magic for RX handling. When an input handler is registered: * Automatically enable RX-related and interrupts * Automatically lock the SERIAL PD on under all power modes * Automatically enable the UART clock under sleep and deep sleep * Automatically undo all of the above when the input handler becomes NULL * As a result, modules / examples that need UART RX no longer need to clock the UART and manipulate the SERIAL PD. They simply have to specify an input handler * Don't automatically power on the UART whenever the CM3 is active * Before accessing the UART, make sure it is powered and clocked * Avoid falling edge glitches * Fix garbage characters / Explicitly wait for UART TX to complete
This commit is contained in:
parent
34f52ed08e
commit
07272b7cd6
3 changed files with 271 additions and 95 deletions
|
@ -29,6 +29,7 @@
|
|||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "cc26xx-uart.h"
|
||||
#include "ti-lib.h"
|
||||
|
||||
#include <string.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
@ -47,9 +48,16 @@ puts(const char *str)
|
|||
return 0;
|
||||
}
|
||||
for(i = 0; i < strlen(str); i++) {
|
||||
putchar(str[i]);
|
||||
cc26xx_uart_write_byte(str[i]);
|
||||
}
|
||||
putchar('\n');
|
||||
cc26xx_uart_write_byte('\n');
|
||||
|
||||
/*
|
||||
* Wait for the line to go out. This is to prevent garbage when used between
|
||||
* UART on/off cycles
|
||||
*/
|
||||
while(cc26xx_uart_busy() == UART_BUSY);
|
||||
|
||||
return i;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
@ -62,9 +70,16 @@ dbg_send_bytes(const unsigned char *s, unsigned int len)
|
|||
if(i >= len) {
|
||||
break;
|
||||
}
|
||||
putchar(*s++);
|
||||
cc26xx_uart_write_byte(*s++);
|
||||
i++;
|
||||
}
|
||||
|
||||
/*
|
||||
* Wait for the buffer to go out. This is to prevent garbage when used
|
||||
* between UART on/off cycles
|
||||
*/
|
||||
while(cc26xx_uart_busy() == UART_BUSY);
|
||||
|
||||
return i;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue