Now also outputting SDK logs to UART1 pins, corrected an issue raising an error when using the nano_shell and added a workaround to be able to really stop the BT modem. Probably a bug in the SDK or in the chip ?

This commit is contained in:
Anatole SCHRAMM 2023-03-08 14:04:01 +01:00
parent 1aff87185a
commit cc468797b3
5 changed files with 46 additions and 6 deletions

View File

@ -60,6 +60,8 @@ void wifi_scan_result_cb(void)
}
tls_mem_free(buf);
tls_wifi_scan_result_cb_register(NULL);
}
void tls_wifi_data_ext_recv_cb(u8* data, u32 data_len, struct tls_wifi_ext_t *ext)
@ -508,12 +510,12 @@ int _bluetooth(const shell_cmd_t *pcmd, int argc, char *const argv[])
if(strcmp(argv[1], "enable") == 0)
{
shell_printf("Enabling bluetooth : %d"NEW_LINE, demo_bt_enable());
//shell_printf("Enabling bluetooth test"NEW_LINE);
}
else if(strcmp(argv[1], "disable") == 0)
{
shell_printf("Disabling bluetooth : %d"NEW_LINE, demo_bt_destroy());
//shell_printf("Disabling bluetooth test"NEW_LINE);
//Starting a wifi scan really stops the BT modem ?? Why ? I don't know
tls_wifi_scan();
}
else if(strcmp(argv[1], "start_demo") == 0)
{

View File

@ -77,9 +77,13 @@ int shell_printf(const char *format, ...)
length = vsnprintf(shell_printf_buffer, CONFIG_SHELL_PRINTF_BUFFER_SIZE, format, ap);
va_end(ap);
//No need to write anything in this case
if(!length) return 0;
(void)tls_uart_write(TLS_UART_0, shell_printf_buffer, length);
(void)tls_uart_write(TLS_UART_1, shell_printf_buffer, length);
(void)network_write_string(shell_printf_buffer, length);
return length;
}

View File

@ -49,6 +49,25 @@ static void uart0Init (int bandrate)
tls_reg_write32(HR_UART0_FIFO_CTRL, 0x00); /* one byte TX/RX */
// tls_reg_write32(HR_UART0_INT_MASK, 0x00); /* Disable INT */
}
/*Not present in official SDK, added to spit the traces on the UART1 on startup */
static void uart1Init (int bandrate)
{
unsigned int bd;
NVIC_DisableIRQ(UART1_IRQn);
NVIC_ClearPendingIRQ(UART1_IRQn);
bd = (APB_CLK/(16*bandrate) - 1)|(((APB_CLK%(bandrate*16))*16/(bandrate*16))<<16);
tls_reg_write32(HR_UART1_BAUD_RATE_CTRL, bd);
tls_reg_write32(HR_UART1_LINE_CTRL, UART_BITSTOP_VAL | UART_TXEN_BIT | UART_RXEN_BIT);
tls_reg_write32(HR_UART1_FLOW_CTRL, 0x00); /* Disable afc */
tls_reg_write32(HR_UART1_DMA_CTRL, 0x00); /* Disable DMA */
tls_reg_write32(HR_UART1_FIFO_CTRL, 0x00); /* one byte TX/RX */
// tls_reg_write32(HR_UART1_INT_MASK, 0x00); /* Disable INT */
}
#if 0
static void uart1_io_init(void)
@ -96,8 +115,9 @@ void board_init(void)
{
#if USE_UART0_PRINT
/* use uart0 as log output io */
uart0Init(115200);
/* use uart1 as log output io */
//uart0Init(115200);
uart1Init(115200);
set_printf_port(0);
#else
uart1_io_init();

View File

@ -78,14 +78,27 @@ int sendchar(int ch)
while(tls_reg_read32(HR_UART1_FIFO_STATUS) & 0x3F);
tls_reg_write32(HR_UART1_TX_WIN, (char)ch);
}
//tls_reg_write32(HR_UART0_INT_MASK, 0x0);
return ch;
//tls_reg_write32(HR_UART0_INT_MASK, 0x0);
return ch;
}
int sendchar_debug_uart(int ch)
{
if (ch == '\n')
{
while (tls_reg_read32(HR_UART1_FIFO_STATUS) & 0x3F);
tls_reg_write32(HR_UART1_TX_WIN, '\r');
}
while (tls_reg_read32(HR_UART1_FIFO_STATUS) & 0x3F);
tls_reg_write32(HR_UART1_TX_WIN, (char)ch);
return ch;
}
int fputc(int ch, FILE *stream)
{
(void)stream;
sendchar(ch);
sendchar_debug_uart(ch);
return 0;
}

View File

@ -35,6 +35,7 @@ char * strdup(const char *s);
char * strndup(const char *s, size_t len);
int sendchar(int ch);
int sendchar_debug_uart(int ch);
void dumpBuffer(char *name, char* buffer, int len);
void dumpUint32(char *name, u32* buffer, int len);