| | |
| | | l_astUartInfo[_eUartID].m_mutexLock = osMutexCreate(HIDO_NULL); |
| | | #endif |
| | | |
| | | struct UART_CFG_T uart_cfg = |
| | | struct UART_CFG_T uart_cfg = |
| | | { |
| | | .parity = UART_PARITY_NONE, |
| | | .stop = UART_STOP_BITS_1, |
| | |
| | | .rx_level = UART_RXFIFO_CHAR_1, |
| | | .tx_level = UART_TXFIFO_EMPTY, |
| | | .baud = get_baud(_pstInit->m_u32BaudRate), |
| | | .dma_en = false, |
| | | .int_rx = true, |
| | | .dma_en = true, |
| | | .int_rx = false, |
| | | .int_tx = false, |
| | | }; |
| | | |
| | |
| | | l_astUartInfo[_eUartID].m_u32RxBufSize = _pstInit->m_u32RxBufSize; |
| | | if(UART_RX_MODE_DMA == _pstInit->m_eRxMode) |
| | | { |
| | | l_astUartInfo[_eUartID].m_pu8RxLastPos= l_astUartInfo[_eUartID].m_pu8RxBuf; |
| | | l_astUartInfo[_eUartID].m_pu8RxBufEnd = l_astUartInfo[_eUartID].m_pu8RxBuf + l_astUartInfo[_eUartID].m_u32RxBufSize - 1; |
| | | HIDO_ArraryQueueInit( |
| | | &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) |
| | | { |
| | |
| | | *******************************************************************************/ |
| | | static void uart_receive_callback(void *dev, uint32_t err_code) |
| | | { |
| | | E_UartID eUartID = (E_UartID) 0; |
| | | E_UartID eUartID = UART_ID_4G; |
| | | |
| | | HIDO_UINT8 u8RecvByte = l_astUartInfo[eUartID].m_u8RxValue; |
| | | |
| | | for (eUartID = (E_UartID) 0; eUartID < UART_ID_LAST; eUartID++) |
| | | { |
| | | if (l_astUartInfo[eUartID].m_eUartPort == *(enum UART_DEV_T *)dev) |
| | | { |
| | | if(UART_RX_MODE_INT == l_astUartInfo[eUartID].m_eRxMode) |
| | | { |
| | | HIDO_UINT8 u8RecvByte = l_astUartInfo[eUartID].m_u8RxValue; |
| | | HIDO_ArraryQueueIn(&l_astUartInfo[eUartID].m_stRxArraryQueue, &u8RecvByte); |
| | | |
| | | HIDO_ArraryQueueIn(&l_astUartInfo[eUartID].m_stRxArraryQueue, &u8RecvByte); |
| | | |
| | | /* 启动INT接收 */ |
| | | uart_receive(l_astUartInfo[eUartID].m_eUartPort, &l_astUartInfo[eUartID].m_u8RxValue, 1, uart_receive_callback); |
| | | } |
| | | |
| | | break; |
| | | } |
| | | } |
| | | /* 启动INT接收 */ |
| | | uart_receive(l_astUartInfo[eUartID].m_eUartPort, &l_astUartInfo[eUartID].m_u8RxValue, 1, uart_receive_callback); |
| | | } |
| | | |
| | | /******************************************************************************* |
| | |
| | | osMutexWait(l_astUartInfo[_eUartID].m_mutexLock, osWaitForever); |
| | | #endif |
| | | |
| | | if (UART_RX_MODE_INT == l_astUartInfo[_eUartID].m_eRxMode) |
| | | switch(l_astUartInfo[_eUartID].m_eRxMode) |
| | | { |
| | | if (HIDO_ArraryQueueOut(&l_astUartInfo[_eUartID].m_stRxArraryQueue, _pu8Char) == HIDO_OK) |
| | | case UART_RX_MODE_INT: |
| | | case UART_RX_MODE_DMA: |
| | | { |
| | | i32Result = HIDO_OK; |
| | | if (HIDO_ArraryQueueOut(&l_astUartInfo[_eUartID].m_stRxArraryQueue, _pu8Char) == HIDO_OK) |
| | | { |
| | | i32Result = HIDO_OK; |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | |
| | |
| | | #endif |
| | | |
| | | return i32Result; |
| | | } |
| | | |
| | | /******************************************************************************* |
| | | * Function Name : Uart_SetChar |
| | | * Description : |
| | | * Input : |
| | | * Output : |
| | | * Return : |
| | | * Author : 杜键 |
| | | * Modified Date: : 2018年4月24日 |
| | | *******************************************************************************/ |
| | | HIDO_VOID Uart_SetChar(E_UartID _eUartID, HIDO_UINT8 _u8Data) |
| | | { |
| | | HIDO_ArraryQueueIn(&l_astUartInfo[_eUartID].m_stRxArraryQueue, &_u8Data); |
| | | } |
| | | |
| | | /******************************************************************************* |
| | |
| | | |
| | | return i32Result; |
| | | } |
| | | HIDO_VOID HIDO_Lock(void) |
| | | { |
| | | int_lock(); |
| | | } |
| | | HIDO_VOID HIDO_UnLock(void) |
| | | { |
| | | uint32_t lock = int_lock(); |
| | | int_unlock(lock); |
| | | } |