未验证 提交 fea12e09 编写于 作者: B Bernard Xiong 提交者: GitHub

Merge pull request #4929 from greedyhao/ab32

[bsp][bluetrum] 优化串口驱动和对接新的RTC框架
......@@ -29,6 +29,7 @@ CONFIG_RT_TIMER_THREAD_STACK_SIZE=256
#
# CONFIG_RT_KSERVICE_USING_STDLIB is not set
# CONFIG_RT_KSERVICE_USING_TINY_SIZE is not set
# CONFIG_RT_USING_ASM_MEMCPY is not set
CONFIG_RT_DEBUG=y
# CONFIG_RT_DEBUG_COLOR is not set
# CONFIG_RT_DEBUG_INIT_CONFIG is not set
......@@ -74,6 +75,7 @@ CONFIG_RT_USING_DEVICE_OPS=y
CONFIG_RT_USING_CONSOLE=y
CONFIG_RT_CONSOLEBUF_SIZE=128
CONFIG_RT_CONSOLE_DEVICE_NAME="uart0"
# CONFIG_RT_PRINTF_LONGLONG is not set
CONFIG_RT_VER_NUM=0x40004
# CONFIG_RT_USING_CPU_FFS is not set
# CONFIG_ARCH_CPU_STACK_GROWS_UPWARD is not set
......@@ -162,7 +164,7 @@ CONFIG_RT_USING_PIN=y
CONFIG_RT_USING_LIBC=y
# CONFIG_RT_USING_PTHREADS is not set
# CONFIG_RT_USING_MODULE is not set
CONFIG_RT_LIBC_FIXED_TIMEZONE=8
CONFIG_RT_LIBC_DEFAULT_TIMEZONE=8
#
# Network
......@@ -568,6 +570,7 @@ CONFIG_RT_LIBC_FIXED_TIMEZONE=8
#
CONFIG_BSP_USING_UART=y
CONFIG_BSP_USING_UART0=y
CONFIG_BSP_UART0_FIFO_SIZE=10
# CONFIG_BSP_USING_UART1 is not set
# CONFIG_BSP_USING_UART2 is not set
# CONFIG_BSP_USING_SDIO is not set
......
menu "Hardware Drivers Config"
config SOC_AB32VG1
bool
select PKG_USING_BLUETRUM_SDK
default y
menu "Onboard Peripheral Drivers"
menuconfig BSP_USING_AUDIO
......@@ -29,20 +34,40 @@ endmenu
menu "On-chip Peripheral Drivers"
menuconfig BSP_USING_UART
bool "Enable UART"
bool "Enable UART"
if BSP_USING_UART
config BSP_USING_UART0
bool "Enable UART0"
select RT_USING_SERIAL
default y
if BSP_USING_UART0
config BSP_UART0_FIFO_SIZE
int "BSP_UART0_FIFO_SIZE"
range 5 255
default 10
endif
config BSP_USING_UART1
bool "Enable UART1"
select RT_USING_SERIAL
default n
if BSP_USING_UART1
config BSP_UART1_FIFO_SIZE
int "BSP_UART1_FIFO_SIZE"
range 5 255
default 10
endif
config BSP_USING_UART2
bool "Enable UART2"
select RT_USING_SERIAL
default n
if BSP_USING_UART2
config BSP_UART2_FIFO_SIZE
int "BSP_UART2_FIFO_SIZE"
range 5 255
default 10
endif
endif
config BSP_USING_SDIO
......@@ -174,12 +199,12 @@ menu "On-chip Peripheral Drivers"
default n
if BSP_USING_ONCHIP_RTC
config RTC_USING_INTERNAL_CLK
bool "Using internal clock RTC"
default y
bool "Using internal clock RTC"
default y
config RTC_USING_1S_INT
bool "Using 1 second interrupt"
depends on RT_USING_ALARM
default n
bool "Using 1 second interrupt"
depends on RT_USING_ALARM
default n
endif
menuconfig BSP_USING_ADC
......
......@@ -21,6 +21,7 @@ void set_cpu_irq_comm(void (*irq_hook)(void));
void load_cache();
void os_cache_init(void);
void sys_error_hook(uint8_t err_no);
void huart_timer_isr(void);
typedef void (*spiflash_init_func)(uint8_t sf_read, uint8_t dummy);
......@@ -29,6 +30,7 @@ static struct rt_mutex mutex_cache = {0};
extern volatile rt_uint8_t rt_interrupt_nest;
extern uint32_t __heap_start, __heap_end;
#ifdef RT_USING_CONSOLE
void hal_printf(const char *fmt, ...)
{
rt_device_t console = rt_console_get_device();
......@@ -64,6 +66,7 @@ void hal_printf(const char *fmt, ...)
#endif
va_end(args);
}
#endif
RT_SECTION(".irq.timer")
void timer0_isr(int vector, void *param)
......@@ -71,6 +74,9 @@ void timer0_isr(int vector, void *param)
rt_interrupt_enter();
TMR0CPND = BIT(9);
rt_tick_increase();
#ifdef RT_USING_SERIAL
huart_timer_isr();
#endif
rt_interrupt_leave();
}
......@@ -206,8 +212,10 @@ void exception_isr(void)
extern long list_thread(void);
sys_error_hook(1);
#ifdef RT_USING_CONSOLE
rt_console_set_device(RT_NULL);
rt_kprintf(stack_info, rt_thread_self()->sp, rt_thread_self()->name);
#endif
while(1);
}
......@@ -91,7 +91,7 @@
/* POSIX layer and C standard library */
#define RT_USING_LIBC
#define RT_LIBC_FIXED_TIMEZONE 8
#define RT_LIBC_DEFAULT_TIMEZONE 8
/* Network */
......@@ -176,6 +176,7 @@
#define BSP_USING_UART
#define BSP_USING_UART0
#define BSP_UART0_FIFO_SIZE 10
/* Board extended module Drivers */
......
......@@ -4,6 +4,7 @@ from building import *
cwd = GetCurrentDir()
src = []
src += ['drv_common.c']
path = [cwd]
path += [cwd + '/config']
......
#include "drv_common.h"
#define DRV_THREAD_PRIORITY 18
#define DRV_THREAD_STACK_SIZE 512
#define DRV_THREAD_TIMESLICE 5
enum {
MSG_UART0_IRQ,
MSG_UART1_IRQ,
MSG_UART2_IRQ,
};
static rt_thread_t drv_tid = RT_NULL;
static rt_mq_t drv_mq = RT_NULL;
void uart0_irq_process(void);
void uart1_irq_process(void);
RT_SECTION(".irq.uart")
void uart0_irq_post(void)
{
uint8_t mq_msg = MSG_UART0_IRQ;
rt_mq_send(drv_mq, &mq_msg, 1);
}
RT_SECTION(".irq.uart")
void uart1_irq_post(void)
{
uint8_t mq_msg = MSG_UART1_IRQ;
rt_mq_send(drv_mq, &mq_msg, 1);
}
RT_SECTION(".irq.uart")
void uart2_irq_post(void)
{
uint8_t mq_msg = MSG_UART2_IRQ;
rt_mq_send(drv_mq, &mq_msg, 1);
}
static void drv_thread_entry(void *parameter)
{
uint8_t mq_msg = 0;
while (1) {
rt_mq_recv(drv_mq, &mq_msg, 1, RT_WAITING_FOREVER);
switch (mq_msg) {
#ifdef BSP_USING_UART0
case MSG_UART0_IRQ:
uart0_irq_process();
break;
#endif
#ifdef BSP_USING_UART1
case MSG_UART1_IRQ:
uart1_irq_process();
break;
#endif
#ifdef BSP_USING_UART2
case MSG_UART2_IRQ:
uart2_irq_process();
break;
#endif
default:
break;
}
}
}
static int drv_thread_init(void)
{
drv_mq = rt_mq_create("drv", 1, 128, RT_IPC_FLAG_FIFO);
drv_tid = rt_thread_create("drv",
drv_thread_entry,
RT_NULL,
DRV_THREAD_STACK_SIZE,
DRV_THREAD_PRIORITY,
DRV_THREAD_TIMESLICE);
if (drv_tid != RT_NULL)
rt_thread_startup(drv_tid);
}
INIT_PREV_EXPORT(drv_thread_init);
......@@ -17,4 +17,8 @@
#define GET_PIN(PORTx,PIN) (uint8_t)__AB32_GET_PIN_##PORTx(PIN)
void uart0_irq_post(void);
void uart1_irq_post(void);
void uart2_irq_post(void);
#endif // DRV_COMMON_H__
......@@ -144,151 +144,68 @@ void hal_rtc_init(void)
}
/************** HAL End *******************/
static time_t get_rtc_time_stamp(void)
static rt_err_t ab32_rtc_get_secs(void *args)
{
time_t sec = 0;
sec = irtc_time_read(RTCCNT_CMD);
LOG_D("get rtc time.");
*(rt_uint32_t *)args = irtc_time_read(RTCCNT_CMD);
LOG_D("RTC: get rtc_time %x\n", *(rt_uint32_t *)args);
return sec;
return RT_EOK;
}
static rt_err_t set_rtc_time_stamp(time_t time_stamp)
static rt_err_t ab32_rtc_set_secs(void *args)
{
irtc_time_write(RTCCNT_CMD, time_stamp);
irtc_time_write(RTCCNT_CMD, *(rt_uint32_t *)args);
return RT_EOK;
}
static rt_err_t set_rtc_alarm_stamp(time_t alarm_stamp)
static rt_err_t ab32_rtc_get_alarm(void *args)
{
irtc_time_write(RTCALM_CMD, alarm_stamp);
*(rt_uint32_t *)args = irtc_time_read(RTCALM_CMD);
return RT_EOK;
}
static time_t get_rtc_alarm_stamp(void)
static rt_err_t ab32_rtc_set_alarm(void *args)
{
time_t sec = 0;
sec = irtc_time_read(RTCALM_CMD);
irtc_time_write(RTCALM_CMD, *(rt_uint32_t *)args);
return sec;
return RT_EOK;
}
static void rt_rtc_init(void)
static rt_err_t ab32_rtc_init(void)
{
hal_rtc_init();
}
static rt_err_t ab32_rtc_control(rt_device_t dev, int cmd, void *args)
{
rt_err_t result = RT_EOK;
RT_ASSERT(dev != RT_NULL);
switch (cmd)
{
case RT_DEVICE_CTRL_RTC_GET_TIME:
*(time_t *)args = get_rtc_time_stamp();
LOG_D("RTC: get rtc_time %x", *(time_t *)args);
break;
case RT_DEVICE_CTRL_RTC_SET_TIME:
if (set_rtc_time_stamp(*(time_t *)args))
{
result = -RT_ERROR;
}
LOG_D("RTC: set rtc_time %x", *(time_t *)args);
break;
case RT_DEVICE_CTRL_RTC_SET_ALARM:
if (set_rtc_alarm_stamp(*(time_t *)args))
{
result = -RT_ERROR;
}
LOG_D("RTC: set alarm_stamp %x", *(time_t *)args);
break;
case RT_DEVICE_CTRL_RTC_GET_ALARM:
*(time_t *)args = get_rtc_alarm_stamp();
LOG_D("RTC: get alarm_stamp %x", *(time_t *)args);
break;
}
return result;
return RT_EOK;
}
#ifdef RT_USING_DEVICE_OPS
const static struct rt_device_ops rtc_ops =
static const struct rt_rtc_ops ab32_rtc_ops =
{
ab32_rtc_init,
ab32_rtc_get_secs,
ab32_rtc_set_secs,
ab32_rtc_get_alarm,
ab32_rtc_set_alarm,
RT_NULL,
RT_NULL,
RT_NULL,
RT_NULL,
RT_NULL,
ab32_rtc_control
};
#endif
static rt_err_t rt_hw_rtc_register(rt_device_t device, const char *name, rt_uint32_t flag)
{
RT_ASSERT(device != RT_NULL);
rt_rtc_init();
#ifdef RT_USING_DEVICE_OPS
device->ops = &rtc_ops;
#else
device->init = RT_NULL;
device->open = RT_NULL;
device->close = RT_NULL;
device->read = RT_NULL;
device->write = RT_NULL;
device->control = ab32_rtc_control;
#endif
device->type = RT_Device_Class_RTC;
device->rx_indicate = RT_NULL;
device->tx_complete = RT_NULL;
device->user_data = RT_NULL;
/* register a character device */
return rt_device_register(device, name, flag);
}
#ifdef RT_USING_ALARM
RT_SECTION(".irq.rtc")
static void rtc_isr(int vector, void *param)
{
rt_interrupt_enter();
if (RTCCON & RTC_CON_ALM_PEND)
{
RTCCPND |= RTC_CPND_ALM;
}
#ifdef RTC_USING_1S_INT
if (RTCCON & RTC_CON_1S_PEND)
{
RTCCPND |= RTC_CPND_1S;
}
#endif
rt_interrupt_leave();
}
#endif
static rt_rtc_dev_t ab32_rtc_dev;
int rt_hw_rtc_init(void)
static int rt_hw_rtc_init(void)
{
rt_err_t result;
result = rt_hw_rtc_register(&rtc, "rtc", RT_DEVICE_FLAG_RDWR);
ab32_rtc_dev.ops = &ab32_rtc_ops;
result = rt_hw_rtc_register(&ab32_rtc_dev, "rtc", RT_DEVICE_FLAG_RDWR, RT_NULL);
if (result != RT_EOK)
{
LOG_E("rtc register err code: %d", result);
return result;
}
#ifdef RT_USING_ALARM
rt_hw_interrupt_install(IRQ_RTC_VECTOR, rtc_isr, RT_NULL, "rtc_isr");
#endif
LOG_D("rtc init success");
return RT_EOK;
}
INIT_DEVICE_EXPORT(rt_hw_rtc_init);
......
......@@ -10,7 +10,7 @@
#include "board.h"
#include "drv_usart.h"
#include <shell.h>
#include "api_huart.h"
#ifdef RT_USING_SERIAL
......@@ -40,6 +40,7 @@ static struct ab32_uart_config uart_config[] =
.name = "uart0",
.instance = UART0_BASE,
.mode = UART_MODE_TX_RX | UART_MODE_1LINE,
.fifo_size = BSP_UART0_FIFO_SIZE,
},
#endif
#ifdef BSP_USING_UART1
......@@ -47,6 +48,7 @@ static struct ab32_uart_config uart_config[] =
.name = "uart1",
.instance = UART1_BASE,
.mode = UART_MODE_TX_RX,
.fifo_size = BSP_UART1_FIFO_SIZE,
},
#endif
#ifdef BSP_USING_UART2
......@@ -54,12 +56,17 @@ static struct ab32_uart_config uart_config[] =
.name = "uart2",
.instance = UART2_BASE,
.mode = UART_MODE_TX_RX,
.fifo_size = BSP_UART2_FIFO_SIZE,
}
#endif
};
static struct ab32_uart uart_obj[sizeof(uart_config) / sizeof(uart_config[0])] = {0};
#ifdef HUART_ENABLE
static uint8_t huart_dma[512];
#endif
static rt_err_t ab32_configure(struct rt_serial_device *serial, struct serial_configure *cfg)
{
struct ab32_uart *uart;
......@@ -101,7 +108,14 @@ static rt_err_t ab32_configure(struct rt_serial_device *serial, struct serial_co
uart->dma_rx.last_index = 0;
#endif
hal_uart_init(&uart->handle);
if (!uart->uart_dma_flag) {
hal_uart_init(&uart->handle);
}
#ifdef HUART_ENABLE
else {
huart_init_do(HUART_TR_PB3, HUART_TR_PB4, uart->handle.init.baud, huart_dma, 512);
}
#endif
return RT_EOK;
}
......@@ -141,25 +155,55 @@ static int ab32_putc(struct rt_serial_device *serial, char ch)
RT_ASSERT(serial != RT_NULL);
uart = rt_container_of(serial, struct ab32_uart, serial);
hal_uart_clrflag(uart->handle.instance, UART_FLAG_TXPND);
hal_uart_write(uart->handle.instance, ch);
while(hal_uart_getflag(uart->handle.instance, UART_FLAG_TXPND) == 0);
if (!uart->uart_dma_flag) {
hal_uart_clrflag(uart->handle.instance, UART_FLAG_TXPND);
hal_uart_write(uart->handle.instance, ch);
while(hal_uart_getflag(uart->handle.instance, UART_FLAG_TXPND) == 0);
}
#ifdef HUART_ENABLE
else {
huart_putchar(ch);
}
#endif
return 1;
}
RT_SECTION(".irq.usart")
static int ab32_getc(struct rt_serial_device *serial)
{
int ch;
struct ab32_uart *uart;
RT_ASSERT(serial != RT_NULL);
uart = rt_container_of(serial, struct ab32_uart, serial);
ch = -1;
if(hal_uart_getflag(uart->handle.instance, UART_FLAG_RXPND) != HAL_RESET) {
ch = hal_uart_read(uart->handle.instance);
hal_uart_clrflag(uart->handle.instance, UART_FLAG_RXPND);
switch ((uint32_t)(uart->handle.instance)) {
case (uint32_t)UART0_BASE:
if (uart->rx_idx != uart->rx_idx_prev) {
ch = (int)(uart->rx_buf[uart->rx_idx_prev++ % 10]);
}
break;
case (uint32_t)UART1_BASE:
#ifdef HUART_ENABLE
if ((uart->uart_dma_flag) && (huart_get_rxcnt())) {
ch = huart_getchar();
} else
#endif
{
if (uart->rx_idx != uart->rx_idx_prev) {
ch = (int)(uart->rx_buf[uart->rx_idx_prev++ % 10]);
}
}
break;
case (uint32_t)UART2_BASE:
if (uart->rx_idx != uart->rx_idx_prev) {
ch = (int)(uart->rx_buf[uart->rx_idx_prev++ % 10]);
}
break;
default:
break;
}
return ch;
......@@ -170,78 +214,24 @@ static rt_size_t ab32_dma_transmit(struct rt_serial_device *serial, rt_uint8_t *
return -1;
}
extern struct finsh_shell *shell;
RT_SECTION(".irq.usart")
static rt_err_t shell_rx_ind(void)
void uart0_irq_process(void)
{
RT_ASSERT(shell != RT_NULL);
/* release semaphore to let finsh thread rx data */
rt_sem_release(&shell->rx_sem);
return RT_EOK;
rt_hw_serial_isr(&(uart_obj[UART0_INDEX].serial), RT_SERIAL_EVENT_RX_IND);
}
RT_SECTION(".irq.usart")
void uart_irq_process(struct rt_serial_device *serial)
#ifdef BSP_USING_UART1
void uart1_irq_process(void)
{
int ch = -1;
rt_base_t level;
struct rt_serial_rx_fifo* rx_fifo;
/* interrupt mode receive */
rx_fifo = (struct rt_serial_rx_fifo*)serial->serial_rx;
RT_ASSERT(rx_fifo != RT_NULL);
while (1)
{
ch = serial->ops->getc(serial);
if (ch == -1) break;
/* disable interrupt */
level = rt_hw_interrupt_disable();
rx_fifo->buffer[rx_fifo->put_index] = ch;
rx_fifo->put_index += 1;
if (rx_fifo->put_index >= serial->config.bufsz) rx_fifo->put_index = 0;
/* if the next position is read index, discard this 'read char' */
if (rx_fifo->put_index == rx_fifo->get_index)
{
rx_fifo->get_index += 1;
rx_fifo->is_full = RT_TRUE;
if (rx_fifo->get_index >= serial->config.bufsz) rx_fifo->get_index = 0;
// _serial_check_buffer_size();
}
/* enable interrupt */
rt_hw_interrupt_enable(level);
}
rt_size_t rx_length;
/* get rx length */
level = rt_hw_interrupt_disable();
rx_length = (rx_fifo->put_index >= rx_fifo->get_index)? (rx_fifo->put_index - rx_fifo->get_index):
(serial->config.bufsz - (rx_fifo->get_index - rx_fifo->put_index));
rt_hw_interrupt_enable(level);
if ((serial->parent.rx_indicate != RT_NULL) && (rx_length != 0)) {
#ifdef RT_CONSOLE_DEVICE_NAME
if (serial == &uart_obj[*(RT_CONSOLE_DEVICE_NAME + 4) - '0'].serial) {
shell_rx_ind();
} else
#endif
{
rt_kprintf("rx_indicate must loacted in the .comm section!\n");
//serial->parent.rx_indicate(&serial->parent, rx_length);
}
}
rt_hw_serial_isr(&(uart_obj[UART1_INDEX].serial), RT_SERIAL_EVENT_RX_IND);
}
#endif
#ifdef BSP_USING_UART2
void uart2_irq_process(void)
{
rt_hw_serial_isr(&(uart_obj[UART2_INDEX].serial), RT_SERIAL_EVENT_RX_IND);
}
#endif
RT_SECTION(".irq.usart")
static void uart_isr(int vector, void *param)
......@@ -251,25 +241,50 @@ static void uart_isr(int vector, void *param)
#ifdef BSP_USING_UART0
if(hal_uart_getflag(UART0_BASE, UART_FLAG_RXPND)) //RX one byte finish
{
uart_irq_process(&(uart_obj[UART0_INDEX].serial));
uart_obj[0].rx_buf[uart_obj[0].rx_idx++ % 10] = hal_uart_read(UART0_BASE);
hal_uart_clrflag(UART0_BASE, UART_FLAG_RXPND);
uart0_irq_post();
}
#endif
#ifdef BSP_USING_UART1
if(hal_uart_getflag(UART1_BASE, UART_FLAG_RXPND)) //RX one byte finish
{
uart_irq_process(&(uart_obj[UART1_INDEX].serial));
uart_obj[1].rx_buf[uart_obj[1].rx_idx++ % 10] = hal_uart_read(UART1_BASE);
hal_uart_clrflag(UART1_BASE, UART_FLAG_RXPND);
uart1_irq_post();
}
#endif
#ifdef BSP_USING_UART2
if(hal_uart_getflag(UART2_BASE, UART_FLAG_RXPND)) //RX one byte finish
{
uart_irq_process(&(uart_obj[UART2_INDEX].serial));
uart_obj[2].rx_buf[uart_obj[2].rx_idx++ % 10] = hal_uart_read(UART2_BASE);
hal_uart_clrflag(UART2_BASE, UART_FLAG_RXPND);
uart2_irq_post();
}
#endif
rt_interrupt_leave();
}
#ifdef HUART_ENABLE
RT_SECTION(".irq.huart")
void huart_timer_isr(void)
{
huart_if_rx_ovflow();
if (0 == huart_get_rxcnt()) {
return;
}
uart1_irq_post();
}
#else
RT_SECTION(".irq.huart")
void huart_timer_isr(void)
{
}
#endif
static const struct rt_uart_ops ab32_uart_ops =
{
.configure = ab32_configure,
......@@ -291,9 +306,17 @@ int rt_hw_usart_init(void)
{
/* init UART object */
uart_obj[i].config = &uart_config[i];
uart_obj[i].rx_idx = 0;
uart_obj[i].rx_idx_prev = 0;
uart_obj[i].serial.ops = &ab32_uart_ops;
uart_obj[i].serial.config = config;
uart_obj[i].serial.config.baud_rate = 1500000;
uart_obj[i].rx_buf = rt_malloc(uart_config[i].fifo_size);
if (uart_obj[i].rx_buf == RT_NULL) {
LOG_E("uart%d malloc failed!", i);
continue;
}
/* register UART device */
result = rt_hw_serial_register(&uart_obj[i].serial, uart_obj[i].config->name,
......@@ -305,7 +328,7 @@ int rt_hw_usart_init(void)
RT_ASSERT(result == RT_EOK);
}
return result;
return result;
}
#endif
......@@ -19,9 +19,10 @@
struct ab32_uart_config
{
const char *name;
hal_sfr_t instance;
uint8_t mode;
uint8_t reserve[3];
hal_sfr_t instance;
uint8_t mode;
uint16_t fifo_size;
uint8_t reserve[1];
// struct dma_config *dma_rx;
// struct dma_config *dma_tx;
};
......@@ -45,6 +46,9 @@ struct ab32_uart
#endif
rt_uint16_t uart_dma_flag;
struct rt_serial_device serial;
rt_uint8_t *rx_buf;
rt_uint8_t rx_idx;
rt_uint8_t rx_idx_prev;
};
#endif
......
......@@ -48,8 +48,8 @@ ASFLAGS = ""
CPPDEFINES = []
LOCAL_CPPDEFINES = []
LIBS = ['hal']
LIBPATH = [CWD]
LIBS = []
LIBPATH = []
LINKFLAGS = ""
......
#ifndef API_HUART_H__
#define API_HUART_H__
enum {
HUART_TR_PA7 = 0,
HUART_TR_PB2,
HUART_TR_PB3,
HUART_TR_PE7,
HUART_TR_PA1,
HUART_TR_PA6,
HUART_TR_PB1,
HUART_TR_PB4,
HUART_TR_PE6,
HUART_TR_PA0,
};
void huart_init_do(uint8_t tx_port, uint8_t rx_port, uint32_t baud_rate, uint8_t *buf, uint16_t buf_size);
void huart_setbaudrate(unsigned int baudrate);
void huart_putchar(const char ch);
void huart_tx(const void *buf, unsigned int len);
unsigned int huart_get_rxcnt(void);
void huart_rxfifo_clear(void);
char huart_getchar(void);
void huart_exit(void);
void huart_if_rx_ovflow(void);
#endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册