72 lines
2.6 KiB
C
72 lines
2.6 KiB
C
/****************************************************************************
|
|
|
|
Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
|
|
|
|
This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
|
|
be copied by any method or incorporated into another program without
|
|
the express written consent of Aerospace C.Power. This Information or any portion
|
|
thereof remains the property of Aerospace C.Power. The Information contained herein
|
|
is believed to be accurate and Aerospace C.Power assumes no responsibility or
|
|
liability for its use in any way and conveys no license or title under
|
|
any patent or copyright and makes no representation or warranty that this
|
|
Information is free from patent or copyright infringement.
|
|
|
|
****************************************************************************/
|
|
|
|
#ifndef _OSIF_DMA_UART_H_
|
|
#define _OSIF_DMA_UART_H_
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/* Descriptors for DMA-operation, RX/TX */
|
|
#define IOT_UART_DMA_DESC_NUM 8
|
|
#define IOT_UART_DMA_DESC_SIZE 128
|
|
#define IOT_UART_DMA_BACKUP_DMA_NUM 0x3
|
|
|
|
typedef void* iot_dma_uart_h;
|
|
/* If return of iot_uart_dma_rcv_func is OK/ZERO, means pkt is free() by
|
|
iot_uart_dma_rcv_func. Else mean pkt should be re-used by dma module. */
|
|
typedef int (*iot_uart_dma_rcv_func)(int pt, iot_pkt_t* pkt);
|
|
|
|
/* For recieving call back function "iot_uart_dma_rcv_func func" , return ZERO
|
|
if the pkg-data is freed by it, NO-ZERO if the pkg-data is not freed.*/
|
|
iot_dma_uart_h iot_uart_dma_open(uint32_t uart_port, iot_uart_dma_rcv_func func);
|
|
|
|
typedef enum iot_dma_signal {
|
|
/* A single buffer recieved, uplayer should get-use-of & FREE the buffer
|
|
that from GET-function */
|
|
IDMA_SIG_DATA_IN = (1<<0),
|
|
/* No enough buffer for rx-descriptor , uplayer should malloc one or more
|
|
buffer for recieving. */
|
|
IDMA_SIG_RX_RUNOUT = (1<<1),
|
|
/* A single buffer sent , uplayer should free the buffer that get from
|
|
GET-function */
|
|
IDMA_SIG_DATA_OUT = (1<<2),
|
|
/* All buffer sent. */
|
|
IDMA_SIG_TX_RUNOUT = (1<<3),
|
|
IDMA_SIG_MASK = (0x0F)
|
|
} idma_sig;
|
|
|
|
#define DMA_SIGNAL(pt, vl) (((vl)&IDMA_SIG_MASK)<<((pt)<<2))
|
|
#define DMA_SIGNAL_VALUE(sig, pt) (((sig)>>((pt)<<2))&IDMA_SIG_MASK)
|
|
|
|
typedef void (*iot_uart_dma_sig_func)(int pt);
|
|
|
|
bool_t iot_uart_dma_set_signal_callback
|
|
(iot_dma_uart_h uart_h, idma_sig sig, iot_uart_dma_sig_func cb);
|
|
|
|
bool_t iot_uart_dma_set_config(iot_dma_uart_h uart_h, int baud,
|
|
int data, int stop, int parity);
|
|
|
|
uint32_t iot_uart_dma_send(iot_dma_uart_h uart_h, iot_pkt_t *pkt);
|
|
|
|
void iot_uart_dma_init(void);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|