first commit
This commit is contained in:
100
application/ws63/hsf/hfuart.h
Executable file
100
application/ws63/hsf/hfuart.h
Executable file
@ -0,0 +1,100 @@
|
||||
|
||||
|
||||
#ifndef _HF_UART_H_
|
||||
#define _HF_UART_H_
|
||||
|
||||
#include "hsf.h"
|
||||
#include "ringbuf.h"
|
||||
#include "hfthread.h"
|
||||
|
||||
|
||||
#define DEBUG_LEVEL_CLOSE 0
|
||||
|
||||
#define DEBUG_LEVEL_NON -1
|
||||
#define DEBUG_LEVEL_CLOSE 0
|
||||
#define DEBUG_LEVEL_LOW 3
|
||||
#define DEBUG_LEVEL_MID 4
|
||||
#define DEBUG_LEVEL_HI 5
|
||||
#define DEBUG_LEVEL DEBUG_LEVEL_HI
|
||||
|
||||
|
||||
|
||||
#define DEBUG_SMTLK DEBUG_LEVEL_MID
|
||||
#define DEBUG_UPGRADE DEBUG_LEVEL_MID
|
||||
#define DEBUG_ASSIS DEBUG_LEVEL_LOW //DEBUG_LEVEL_CLOSE
|
||||
#define DEBUG_FLASH DEBUG_LEVEL_LOW
|
||||
#define DEBUG_BOOTUP DEBUG_LEVEL_LOW
|
||||
#define DEBUG_ATCMD DEBUG_LEVEL_LOW
|
||||
#define DEBUG_CONFIG DEBUG_LEVEL_LOW
|
||||
|
||||
|
||||
#define DEBUG_LEVEL_USER 10
|
||||
#define DEBUG_WARN (DEBUG_LEVEL_USER-2)
|
||||
#define DEBUG_ERROR (DEBUG_LEVEL_USER-2)
|
||||
|
||||
typedef void * hfuart_handle_t;
|
||||
|
||||
typedef struct _HFUART_THREAD
|
||||
{
|
||||
int uart_id;
|
||||
hfuart_handle_t uart_handle;
|
||||
char *uart_buf;
|
||||
int uart_buf_size;
|
||||
}HFUART_THREAD,*PHFUART_THREAD;
|
||||
|
||||
typedef struct _HFUART
|
||||
{
|
||||
unsigned char port; //端口 HF_UART0 0;HF_UART1 1;
|
||||
char tx_enable;
|
||||
char rx_enable;
|
||||
char *rxbuf; //环形buff数据缓冲区
|
||||
struct ringbuf uart_rx_buf; //串口环形buff句柄
|
||||
volatile int b_wait_rx;
|
||||
hfthread_sem_t rx_wait_event; //信号量
|
||||
char fc_enable;
|
||||
char fc_full;
|
||||
char valid;
|
||||
}HFUART,*PHFUART;
|
||||
|
||||
|
||||
void HSF_API HF_Debug(int debug_level, const char *format , ... );
|
||||
|
||||
#define hfdbg_error(...) HF_Debug(DEBUG_ERROR,"[ %d error %s %d]",hfsys_get_time(),__FUNCTION__,__LINE__); \
|
||||
HF_Debug(DEBUG_ERROR,__VA_ARGS__)
|
||||
#define hfdbg_warn(...) HF_Debug(DEBUG_WARN,"[warnning %d %s %d]",hfsys_get_time(),__FUNCTION__,__LINE__); \
|
||||
HF_Debug(DEBUG_WARN,__VA_ARGS__)
|
||||
#define u_printf(...) HF_Debug(DEBUG_LEVEL_USER,__VA_ARGS__)
|
||||
|
||||
|
||||
int hfuart_config(hfuart_handle_t huart, int baudrate, ENCOMPARITY_E parity, ENCOMBITS_E databits, ENCOMSTOPBITS_E stopbits, ENCOMUARTCTL_E fc);
|
||||
|
||||
hfuart_handle_t HSF_API hfuart_open(int uart_id);
|
||||
|
||||
int HSF_API hfuart_recv(hfuart_handle_t huart,char *recv,uint32_t bytes,uint32_t timeouts);
|
||||
|
||||
int HSF_API hfuart_send(hfuart_handle_t huart, char *data, uint32_t bytes, uint32_t timeouts);
|
||||
int HSF_API hfuart_close(hfuart_handle_t huart);
|
||||
|
||||
|
||||
int HSF_API hfdbg_get_level(void);
|
||||
void HSF_API hfdbg_set_level(int level);
|
||||
|
||||
/**
|
||||
* @brief set uart parameters.
|
||||
*
|
||||
* @param[in]
|
||||
* baud: 串口波特率
|
||||
* data_bits:数据位 参考ENCOMBITS_E
|
||||
* stop_bits:停止位 参考ENCOMSTOPBITS_E
|
||||
* parity :校验位 参考ENCOMPARITY_E
|
||||
* len: the length, in bytes, of the data pointed to write
|
||||
* @return[out] HF_SUCCESS-successfully, other value is failed
|
||||
* @see None.
|
||||
* @note 立即生效需在hfnet_start_uart前设置,默认不保存flash,如需参数保存调用hfconfig_file_save();.
|
||||
*/
|
||||
int HSF_API hfset_uart_parameters(int baud,ENCOMBITS_E data_bits,ENCOMSTOPBITS_E stop_bits,ENCOMPARITY_E parity);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user