1:
9:
10:
14:
15:
#ifndef _UARTMGR_H_
16:
#define _UARTMGR_H_
17:
18:
19:
#include <stdint.h>
20:
#include "lib_common/AG903_common.h"
21:
22:
#ifdef __cplusplus
23:
extern "C" {
24:
#endif
25:
26:
27:
#define AG903_UART_CLK (100000000)
28:
29:
30:
#define AG903_UART_BUFSIZE (512)
31:
32:
105:
typedef uint32_t
AG903_UARTMgrHandle;
106:
107:
126:
typedef void (*
AG903_UARTMgrClbk)(
AG903_UARTMgrHandle* handle, uint32_t event);
127:
128:
133:
typedef struct _AG903_UARTMgrParam {
134: uint32_t baud;
135: uint8_t parity;
136: uint8_t stopbit;
137: uint8_t databit;
138: uint8_t flow;
139: }
AG903_UARTMgrParam;
140:
141:
148:
typedef struct _AG903_UARTMgrRs485Param {
149: uint32_t setuptime;
150: uint32_t holdtime;
151: uint32_t rcvtime;
152: uint32_t interval;
153: uint32_t timeout;
154: uint32_t event;
155: }
AG903_UARTMgrRs485Param;
156:
157:
158: int32_t
AG903_UARTMgrInit(uint8_t ch);
159: int32_t
AG903_UARTMgrGetHandle(uint8_t ch,
AG903_UARTMgrHandle** handle);
160: int32_t
AG903_UARTMgrReleaseHandle(
AG903_UARTMgrHandle* handle);
161: int32_t
AG903_UARTMgrSetCallback(
AG903_UARTMgrHandle* handle,
AG903_UARTMgrClbk clbk);
162: int32_t
AG903_UARTMgrSetParam(
AG903_UARTMgrHandle*handle,
AG903_UARTMgrParam* param);
163: int32_t
AG903_UARTMgrSetRs485Param(
AG903_UARTMgrHandle*handle,
AG903_UARTMgrRs485Param *param);
164: int32_t
AG903_UARTMgrSend(
AG903_UARTMgrHandle* handle, uint8_t* buf, uint32_t size, _Bool dma);
165: int32_t
AG903_UARTMgrReceive(
AG903_UARTMgrHandle* handle, _Bool dma);
166: int32_t
AG903_UARTMgrGetReceiveData(
AG903_UARTMgrHandle* handle, uint8_t* buf, uint32_t size);
167: int32_t
AG903_UARTMgrStopSend(
AG903_UARTMgrHandle* handle);
168: int32_t
AG903_UARTMgrStopReceive(
AG903_UARTMgrHandle* handle);
169: int32_t
AG903_UARTMgrResetFifo(
AG903_UARTMgrHandle* handle, uint8_t rstbit);
170: int32_t
AG903_UARTMgrSetBreak(
AG903_UARTMgrHandle* handle, _Bool enable);
171:
172:
#ifdef __cplusplus
173: }
174:
#endif
175:
#endif