| | |
| | | { |
| | | enum UART_BAUD_T baud; |
| | | HIDO_UINT32 u32Baud; |
| | | } baud_map[] = |
| | | } baud_map[] = |
| | | { |
| | | {BAUD_1200, 1200}, |
| | | {BAUD_2400, 2400}, |
| | |
| | | return baud_map[i].baud; |
| | | } |
| | | } |
| | | |
| | | |
| | | return BAUD_115200; |
| | | } |
| | | |
| | |
| | | *******************************************************************************/ |
| | | |
| | | /******************************************************************************* |
| | | * Function Name : |
| | | * Description : |
| | | * Input : |
| | | * Output : |
| | | * Return : |
| | | * Function Name : |
| | | * Description : |
| | | * Input : |
| | | * Output : |
| | | * Return : |
| | | * Author : 杜键 |
| | | * Modified Date: : 2018年4月24日 |
| | | *******************************************************************************/ |
| | |
| | | { |
| | | /* 初始化参数 */ |
| | | HIDO_UtilBzero(&l_astUartInfo[_eUartID], sizeof(ST_UartInfo)); |
| | | |
| | | |
| | | l_astUartInfo[_eUartID].m_eUartPort = _ePort; |
| | | |
| | | return HIDO_OK; |
| | |
| | | #ifdef _USE_OS_ |
| | | l_astUartInfo[_eUartID].m_mutexLock = osMutexCreate(HIDO_NULL); |
| | | #endif |
| | | |
| | | |
| | | struct UART_CFG_T uart_cfg = |
| | | { |
| | | .parity = UART_PARITY_NONE, |
| | |
| | | if(UART_RX_MODE_DMA == _pstInit->m_eRxMode) |
| | | { |
| | | HIDO_ArraryQueueInit( |
| | | &l_astUartInfo[_eUartID].m_stRxArraryQueue, |
| | | _pstInit->m_pu8RxBuf, |
| | | _pstInit->m_u32RxBufSize, |
| | | sizeof(HIDO_UINT8)); |
| | | return HIDO_OK; |
| | | &l_astUartInfo[_eUartID].m_stRxArraryQueue, |
| | | _pstInit->m_pu8RxBuf, |
| | | _pstInit->m_u32RxBufSize, |
| | | sizeof(HIDO_UINT8)); |
| | | return HIDO_OK; |
| | | } |
| | | else if(UART_RX_MODE_INT == _pstInit->m_eRxMode) |
| | | { |
| | | HIDO_ArraryQueueInit( |
| | | &l_astUartInfo[_eUartID].m_stRxArraryQueue, |
| | | _pstInit->m_pu8RxBuf, |
| | | _pstInit->m_u32RxBufSize, |
| | | sizeof(HIDO_UINT8)); |
| | | &l_astUartInfo[_eUartID].m_stRxArraryQueue, |
| | | _pstInit->m_pu8RxBuf, |
| | | _pstInit->m_u32RxBufSize, |
| | | sizeof(HIDO_UINT8)); |
| | | } |
| | | |
| | | l_astUartInfo[_eUartID].m_pu8TxBuf = _pstInit->m_pu8TxBuf; |
| | | l_astUartInfo[_eUartID].m_u32TxBufSize = _pstInit->m_u32TxBufSize; |
| | | l_astUartInfo[_eUartID].m_fnRxISR = _pstInit->m_fnRxISR; |
| | | l_astUartInfo[_eUartID].m_u32TxQueueMemberCnt = _pstInit->m_u32TxQueueMemberCnt; |
| | | |
| | | |
| | | uart_open(l_astUartInfo[_eUartID].m_eUartPort, &uart_cfg); |
| | | |
| | | if((UART_TX_MODE_DMA == _pstInit->m_eTxMode) || (UART_TX_MODE_INT == _pstInit->m_eTxMode)) |
| | | { |
| | | HIDO_VLQInit( |
| | | &(l_astUartInfo[_eUartID].m_stTxVLQueue), |
| | | _pstInit->m_pu8TxBuf, |
| | | _pstInit->m_u32TxBufSize, |
| | | _pstInit->m_u32TxQueueMemberCnt); |
| | | &(l_astUartInfo[_eUartID].m_stTxVLQueue), |
| | | _pstInit->m_pu8TxBuf, |
| | | _pstInit->m_u32TxBufSize, |
| | | _pstInit->m_u32TxQueueMemberCnt); |
| | | } |
| | | |
| | | if (UART_RX_MODE_INT == _pstInit->m_eRxMode) |
| | |
| | | else if(UART_RX_MODE_INT == l_astUartInfo[_eUartID].m_eRxMode) |
| | | { |
| | | HIDO_ArraryQueueInit( |
| | | &l_astUartInfo[_eUartID].m_stRxArraryQueue, |
| | | l_astUartInfo[_eUartID].m_pu8RxBuf, |
| | | l_astUartInfo[_eUartID].m_u32RxBufSize, |
| | | sizeof(HIDO_UINT8)); |
| | | &l_astUartInfo[_eUartID].m_stRxArraryQueue, |
| | | l_astUartInfo[_eUartID].m_pu8RxBuf, |
| | | l_astUartInfo[_eUartID].m_u32RxBufSize, |
| | | sizeof(HIDO_UINT8)); |
| | | } |
| | | |
| | | if((UART_TX_MODE_DMA == l_astUartInfo[_eUartID].m_eTxMode) || (UART_TX_MODE_INT == l_astUartInfo[_eUartID].m_eTxMode)) |
| | | { |
| | | HIDO_VLQInit( |
| | | &(l_astUartInfo[_eUartID].m_stTxVLQueue), |
| | | l_astUartInfo[_eUartID].m_pu8TxBuf, |
| | | l_astUartInfo[_eUartID].m_u32TxBufSize, |
| | | l_astUartInfo[_eUartID].m_u32TxQueueMemberCnt); |
| | | &(l_astUartInfo[_eUartID].m_stTxVLQueue), |
| | | l_astUartInfo[_eUartID].m_pu8TxBuf, |
| | | l_astUartInfo[_eUartID].m_u32TxBufSize, |
| | | l_astUartInfo[_eUartID].m_u32TxQueueMemberCnt); |
| | | } |
| | | |
| | | uart_receive(l_astUartInfo[_eUartID].m_eUartPort, &l_astUartInfo[_eUartID].m_u8RxValue, 1, uart_receive_callback); |
| | |
| | | .int_rx = true, |
| | | .int_tx = false, |
| | | }; |
| | | |
| | | |
| | | uart_open(l_astUartInfo[_eUartID].m_eUartPort, &uart_cfg); |
| | | |
| | | return HIDO_OK; |
| | |
| | | static void uart_receive_callback(void *dev, uint32_t err_code) |
| | | { |
| | | E_UartID eUartID = UART_ID_4G; |
| | | |
| | | |
| | | HIDO_UINT8 u8RecvByte = l_astUartInfo[eUartID].m_u8RxValue; |
| | | |
| | | HIDO_ArraryQueueIn(&l_astUartInfo[eUartID].m_stRxArraryQueue, &u8RecvByte); |
| | |
| | | |
| | | switch(l_astUartInfo[_eUartID].m_eRxMode) |
| | | { |
| | | case UART_RX_MODE_INT: |
| | | case UART_RX_MODE_DMA: |
| | | case UART_RX_MODE_INT: |
| | | case UART_RX_MODE_DMA: |
| | | { |
| | | if (HIDO_ArraryQueueOut(&l_astUartInfo[_eUartID].m_stRxArraryQueue, _pu8Char) == HIDO_OK) |
| | | { |
| | | if (HIDO_ArraryQueueOut(&l_astUartInfo[_eUartID].m_stRxArraryQueue, _pu8Char) == HIDO_OK) |
| | | { |
| | | i32Result = HIDO_OK; |
| | | } |
| | | break; |
| | | i32Result = HIDO_OK; |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | |
| | | #ifdef _USE_OS_ |
| | |
| | | memcpy(pstMember->m_pDataAddr, _pu8Data, _u32Len); |
| | | pstMember = HIDO_VLQGetDequeueMember(&(l_astUartInfo[_eUartID].m_stTxVLQueue)); |
| | | HIDO_UnLock(); |
| | | |
| | | |
| | | uart_send(l_astUartInfo[_eUartID].m_eUartPort, pstMember->m_pDataAddr, pstMember->m_u32DataLen, uart_send_callback); |
| | | } |
| | | } |