mirror of
https://github.com/Fishwaldo/bl_mcu_sdk.git
synced 2025-07-24 05:39:27 +00:00
[update][lhal] update lhal and demos
This commit is contained in:
parent
251da8c488
commit
703fb5d8c2
105 changed files with 3765 additions and 558 deletions
|
@ -5,28 +5,25 @@
|
|||
|
||||
struct bflb_device_s *uart1;
|
||||
|
||||
static uint32_t uart_txbuf[3];
|
||||
|
||||
void uart_isr(int irq, void *arg)
|
||||
{
|
||||
uint32_t intstatus = bflb_uart_get_intstatus(uart1);
|
||||
int ret;
|
||||
uint32_t baudrate;
|
||||
|
||||
if (intstatus & UART_INTSTS_RX_AD5) {
|
||||
uart_txbuf[0] = UART_AUTO_BAUD_0X55;
|
||||
bflb_uart_feature_control(uart1, UART_CMD_GET_AUTO_BAUD, (uint32_t)uart_txbuf);
|
||||
uint32_t baudrate = 40000000 / (uart_txbuf[1] + 1);
|
||||
ret = bflb_uart_feature_control(uart1, UART_CMD_GET_AUTO_BAUD, UART_AUTO_BAUD_0X55);
|
||||
baudrate = 40000000 / (ret + 1);
|
||||
printf("Detected baudrate by 0x55 is %d\r\n", baudrate);
|
||||
}
|
||||
bflb_uart_int_clear(uart1, UART_INTCLR_RX_AD5);
|
||||
|
||||
if (intstatus & UART_INTSTS_RX_ADS) {
|
||||
uart_txbuf[0] = UART_AUTO_BAUD_START;
|
||||
bflb_uart_feature_control(uart1, UART_CMD_GET_AUTO_BAUD, (uint32_t)uart_txbuf);
|
||||
uint32_t baudrate = 40000000 / (uart_txbuf[1] + 1);
|
||||
ret = bflb_uart_feature_control(uart1, UART_CMD_GET_AUTO_BAUD, UART_AUTO_BAUD_START);
|
||||
baudrate = 40000000 / (ret + 1);
|
||||
printf("Detected baudrate by startbit is %d\r\n", baudrate);
|
||||
}
|
||||
bflb_uart_int_clear(uart1, UART_INTCLR_RX_ADS);
|
||||
|
||||
}
|
||||
|
||||
int main(void)
|
||||
|
@ -48,9 +45,11 @@ int main(void)
|
|||
bflb_uart_init(uart1, &cfg);
|
||||
|
||||
bflb_uart_feature_control(uart1, UART_CMD_SET_AUTO_BAUD, 1);
|
||||
bflb_uart_feature_control(uart1, UART_CMD_SET_ABR_PW_VALUE, 3);
|
||||
bflb_uart_feature_control(uart1, UART_CMD_SET_ABR_ALLOWABLE_ERROR, 3);
|
||||
|
||||
bflb_irq_attach(uart1->irq_num, uart_isr, uart1);
|
||||
bflb_irq_enable(uart1->irq_num);
|
||||
|
||||
while (1) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ int main(void)
|
|||
cfg.data_bits = UART_DATA_BITS_8;
|
||||
cfg.stop_bits = UART_STOP_BITS_1;
|
||||
cfg.parity = UART_PARITY_NONE;
|
||||
cfg.flow_ctrl = UART_FLOWCTRL_RTS;
|
||||
cfg.flow_ctrl = 0;
|
||||
cfg.tx_fifo_threshold = 7;
|
||||
cfg.rx_fifo_threshold = 7;
|
||||
bflb_uart_init(uart1, &cfg);
|
||||
|
@ -46,8 +46,9 @@ int main(void)
|
|||
bflb_irq_attach(uart1->irq_num, uart_isr, uart1);
|
||||
bflb_irq_enable(uart1->irq_num);
|
||||
|
||||
bflb_uart_feature_control(uart1, UART_CMD_SET_SW_RTS_CONTROL, true);
|
||||
bflb_uart_feature_control(uart1, UART_CMD_SET_RTS_VALUE, 0);
|
||||
while (1) {
|
||||
printf("helloworld\r\n");
|
||||
bflb_mtimer_delay_ms(2000);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -130,7 +130,6 @@ int main(void)
|
|||
printf("receive data:%02x\r\n", receive_buffer[i]);
|
||||
}
|
||||
while (1) {
|
||||
printf("helloworld\r\n");
|
||||
bflb_mtimer_delay_ms(2000);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,7 +62,6 @@ int main(void)
|
|||
bflb_irq_enable(uart1->irq_num);
|
||||
|
||||
while (1) {
|
||||
printf("helloworld\r\n");
|
||||
bflb_mtimer_delay_ms(2000);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ int main(void)
|
|||
bflb_uart_init(uart1, &cfg);
|
||||
|
||||
bflb_uart_feature_control(uart1, UART_CMD_SET_TX_RS485_EN, 1);
|
||||
bflb_uart_feature_control(uart1, UART_CMD_SET_TX_RS485_POL, 1);
|
||||
bflb_uart_feature_control(uart1, UART_CMD_SET_TX_RS485_POLARITY, 1);
|
||||
|
||||
for (uint8_t i = 0; i < 128; i++) {
|
||||
bflb_uart_putchar(uart1, uart_txbuf[i]);
|
||||
|
@ -58,7 +58,6 @@ int main(void)
|
|||
bflb_irq_enable(uart1->irq_num);
|
||||
|
||||
while (1) {
|
||||
printf("helloworld\r\n");
|
||||
bflb_mtimer_delay_ms(2000);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue