|
|
@@ -21,7 +21,11 @@
|
|
|
* @version
|
|
|
* - 1_01_221231 > ATY
|
|
|
* -# Preliminary version, first Release
|
|
|
-* -Undone: over with "\r\n" type
|
|
|
+* - 1_02_240410 > ATY
|
|
|
+* -# add multy addr and channel
|
|
|
+* -# add lock
|
|
|
+* - Undone: over with "\r\n" type
|
|
|
+* - todo: printf in multi platform
|
|
|
********************************************************************************
|
|
|
*/
|
|
|
|
|
|
@@ -30,11 +34,160 @@
|
|
|
|
|
|
#include "HW_UART_ATY.h"
|
|
|
|
|
|
-struct _uartMsgStruct uartMsgStruct_t = {0};
|
|
|
+/******************************* For user *************************************/
|
|
|
+
|
|
|
+/******************************************************************************/
|
|
|
+
|
|
|
+/**
|
|
|
+ * @brief uart send byte and init uart if not initialized
|
|
|
+ * @param byte byte to send
|
|
|
+ * @param dev
|
|
|
+ * @return uint8_t
|
|
|
+ */
|
|
|
+uint8_t UartSendByte(uint8_t byte, struct HW_UART_ATY_Dev* dev)
|
|
|
+{
|
|
|
+ __ATY_LOCK(dev);
|
|
|
+
|
|
|
+ if(dev->uartInitFlag == 0){
|
|
|
+ dev->uartInitFlag = 1;
|
|
|
+ dev->uartInit(dev->rx);
|
|
|
+ }
|
|
|
+
|
|
|
+ while(dev->rxCount--)
|
|
|
+ dev->rx[dev->rxCount] = 0;
|
|
|
+
|
|
|
+ dev->uartSendByte(byte);
|
|
|
+
|
|
|
+ __ATY_UNLOCK(dev);
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * @brief uart send bytes
|
|
|
+ * @param bytes bytes to send
|
|
|
+ * @param len bytes to send
|
|
|
+ * @param dev
|
|
|
+ */
|
|
|
+void UartSendBytes(uint8_t* bytes, uint16_t len, struct HW_UART_ATY_Dev* dev)
|
|
|
+{
|
|
|
+ while(len--)
|
|
|
+ UartSendByte(*bytes++, dev);
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * @brief uart send string
|
|
|
+ * @param str data to send
|
|
|
+ * @param dev
|
|
|
+ */
|
|
|
+void UartSendStr(uint8_t* str, struct HW_UART_ATY_Dev* dev)
|
|
|
+{
|
|
|
+ while(*str)
|
|
|
+ UartSendByte(*str++, dev);
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * @brief uart send float data in specified endian
|
|
|
+ * @param dataFloat float number
|
|
|
+ * @param endian
|
|
|
+ * @param dev
|
|
|
+ */
|
|
|
+void UartSendFloat(float dataFloat, uint8_t endian, struct HW_UART_ATY_Dev* dev)
|
|
|
+{
|
|
|
+ union result
|
|
|
+ {
|
|
|
+ float temp_f;
|
|
|
+ uint8_t temp_uint8[4];
|
|
|
+ }resultA, resultB;
|
|
|
+
|
|
|
+ resultA.temp_f = dataFloat;
|
|
|
+ if(endian == 'B'){
|
|
|
+ resultB.temp_uint8[0] = resultA.temp_uint8[3];
|
|
|
+ resultB.temp_uint8[1] = resultA.temp_uint8[2];
|
|
|
+ resultB.temp_uint8[2] = resultA.temp_uint8[1];
|
|
|
+ resultB.temp_uint8[3] = resultA.temp_uint8[0];
|
|
|
+ }
|
|
|
+ else if(endian == 'L'){
|
|
|
+ resultB.temp_uint8[0] = resultA.temp_uint8[0];
|
|
|
+ resultB.temp_uint8[1] = resultA.temp_uint8[1];
|
|
|
+ resultB.temp_uint8[2] = resultA.temp_uint8[2];
|
|
|
+ resultB.temp_uint8[3] = resultA.temp_uint8[3];
|
|
|
+ }
|
|
|
+ UartSendBytes(resultB.temp_uint8, 4, dev);
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * @brief uart send float data in ASCII character type
|
|
|
+ * @param dataFloat number to send, use double to get better
|
|
|
+ * @param DECIMALS_NUM
|
|
|
+ * @param dev
|
|
|
+ * @note float and double is the same in C51
|
|
|
+ */
|
|
|
+void UartSendFloatStr(float dataFloat, uint8_t DECIMALS_NUM, struct HW_UART_ATY_Dev* dev)
|
|
|
+// void UartSendFloatStr(double dataFloat)
|
|
|
+{
|
|
|
+ uint8_t i = 0;
|
|
|
+ uint8_t dataStr[10]; // ulongint 4294967295, 6.4f
|
|
|
+ unsigned long int tempSaveData = 0;
|
|
|
+
|
|
|
+ for(i = 0; i < 10; i++)
|
|
|
+ dataStr[i] = 0;
|
|
|
+
|
|
|
+ if(dataFloat < 0)
|
|
|
+ {
|
|
|
+ dataFloat = -dataFloat;
|
|
|
+ UartSendByte('-', dev);
|
|
|
+ }
|
|
|
+ tempSaveData = (dataFloat * 10000) + 0.5;
|
|
|
+ for(i = 0; tempSaveData != 0; i++)
|
|
|
+ {
|
|
|
+ dataStr[10 - 1 - i] = tempSaveData % 10;
|
|
|
+ tempSaveData /= 10;
|
|
|
+ }
|
|
|
+ // UartSendByte(i + 48);
|
|
|
+ if(i < 5)
|
|
|
+ i = 5;
|
|
|
+ while(i--)
|
|
|
+ {
|
|
|
+ UartSendByte(dataStr[10 - 1 - i] + 48, dev);
|
|
|
+ if(i == DECIMALS_NUM)
|
|
|
+ UartSendByte('.', dev);
|
|
|
+ }
|
|
|
+ UartSendByte(' ', dev);
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * @brief uart receive data process
|
|
|
+ * @note put at main while
|
|
|
+ * @param dev
|
|
|
+ */
|
|
|
+void UartReceiveProcess(struct HW_UART_ATY_Dev* dev)
|
|
|
+{
|
|
|
+ if(dev->uartInitFlag == 0){
|
|
|
+ dev->uartInitFlag = 1;
|
|
|
+ dev->uartInit(dev->rx);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(dev->rcvOverTimeOutCount > dev->rcvOverTimeOutCountNum)
|
|
|
+ {
|
|
|
+ dev->rcvOverTimeOutCount = 0;
|
|
|
+ if(dev->rxCount != 0)
|
|
|
+ {
|
|
|
+ dev->rcvOverFlag = 0;
|
|
|
+ dev->uartReceiveProcess_User();
|
|
|
+ while(dev->rxCount){
|
|
|
+ dev->rx[dev->rxCount--] = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ dev->rcvOverTimeOutCount++;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
|
|
|
/******************************* For user *************************************/
|
|
|
#if defined (__STC51_ATY)
|
|
|
-
|
|
|
#define BRT (uint32_t)(65536 - (uint32_t)FOSC / BAUD_RATE / 4)
|
|
|
// #define FOSC 5529600UL // 5.5296MHz MCU frequency
|
|
|
#define FOSC 24000000UL // 24MHz MCU frequency
|
|
|
@@ -104,23 +257,6 @@ void UartSendByte(uint8_t byte)
|
|
|
|
|
|
#elif defined(__STM32_HAL_ATY)
|
|
|
#include "usart.h"
|
|
|
-void UartSendByte(uint8_t byte)
|
|
|
-{
|
|
|
- uint8_t i = 0;
|
|
|
- for(i = 0; i < uartMsgStruct_t.rxCount; i++)
|
|
|
- uartMsgStruct_t.rx[i] = 0;
|
|
|
- uartMsgStruct_t.rxCount = 0;
|
|
|
-#ifdef LL
|
|
|
- LL_USART_TransmitData8(PRINTF_UART, byte);
|
|
|
- while(!LL_USART_IsActiveFlag_TC(PRINTF_UART)){}
|
|
|
-#else
|
|
|
- HAL_UART_Transmit(&PRINTF_UART, (uint8_t*)&byte, 1, 0xFFFF);
|
|
|
-#endif
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
#ifndef __MICROLIB
|
|
|
// for standart lib(not use MicroLIB)
|
|
|
#pragma import(__use_no_semihosting)
|
|
|
@@ -170,234 +306,163 @@ GETCHAR_PROTOTYPE \
|
|
|
HAL_UART_Receive(&PRINTF_UART, &ch, 1, 0xFFFF);
|
|
|
return ch;
|
|
|
}
|
|
|
-
|
|
|
-#ifdef DEBUG_PRINTF_RECEIVE
|
|
|
-uint8_t uartPrintfRxBuf[PRINTF_RX_MAX_LEN];
|
|
|
-
|
|
|
-
|
|
|
-/**
|
|
|
- * @brief uart hardware init
|
|
|
- * @note put at main init
|
|
|
- * use DMA IDEL type, open uart IT and add rx dma, mode in Normal(not Circular!), data with byte
|
|
|
- */
|
|
|
-void UartInit(void)
|
|
|
-{
|
|
|
- // __HAL_UART_ENABLE_IT(&PRINTF_UART, UART_IT_IDLE);
|
|
|
- HAL_UARTEx_ReceiveToIdle_DMA(&PRINTF_UART, uartMsgStruct_t.rx, UART_RX_MAX_LEN);
|
|
|
- __HAL_DMA_DISABLE_IT(&PRINTF_DMA, DMA_IT_HT);
|
|
|
-
|
|
|
- *(uartMsgStruct_t.rx) = *uartPrintfRxBuf;
|
|
|
- uartMsgStruct_t.rxCount = 0x00;
|
|
|
- uartMsgStruct_t.txCount = 0x00;
|
|
|
- uartMsgStruct_t.busyFlag = 0;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef* huart, uint16_t Size)
|
|
|
-{
|
|
|
- if(huart == &PRINTF_UART){
|
|
|
- HAL_UART_DMAStop(&PRINTF_UART);
|
|
|
- uartMsgStruct_t.overCount = 0;
|
|
|
- uartMsgStruct_t.rxCount = UART_RX_MAX_LEN - __HAL_DMA_GET_COUNTER(&PRINTF_DMA);
|
|
|
- uartMsgStruct_t.rcvOverFlag = 1;
|
|
|
-
|
|
|
- // HAL_UARTEx_ReceiveToIdle_DMA(&PRINTF_UART, uartMsgStruct_t.rx, UART_RX_MAX_LEN);
|
|
|
- // __HAL_DMA_DISABLE_IT(&PRINTF_DMA, DMA_IT_HT);
|
|
|
- }
|
|
|
-
|
|
|
- /* if process is not too long, process function can be used at this call back;
|
|
|
- otherwise put process at other cycle like while or timer cycle */
|
|
|
- // PrintfReceiveProcess();
|
|
|
-}
|
|
|
-
|
|
|
-/**
|
|
|
- * @brief init uart IT and DMA etc.
|
|
|
- */
|
|
|
-void PrintfReceiveInit(void)
|
|
|
-{
|
|
|
- HAL_UARTEx_ReceiveToIdle_DMA(&PRINTF_UART, uartMsgStruct_t.rx, PRINTF_RX_MAX_LEN);
|
|
|
- __HAL_DMA_DISABLE_IT(&PRINTF_DMA, DMA_IT_HT);
|
|
|
-}
|
|
|
-
|
|
|
-/**
|
|
|
- * @brief uart receive data analysis
|
|
|
- * @note put at main while
|
|
|
- */
|
|
|
-__WEAK_ATY void PrintfReceiveProcess(void)
|
|
|
-{
|
|
|
- struct _uartMsgStruct* ptr = &uartMsgStruct_t;
|
|
|
-
|
|
|
- if(ptr->rcvOverFlag)
|
|
|
- {
|
|
|
- ptr->rcvOverFlag = 0;
|
|
|
- // ptr->rxCount = 0;
|
|
|
-
|
|
|
- UartReceiveProcess_User(ptr);
|
|
|
-
|
|
|
- PrintfReceiveInit();
|
|
|
- }
|
|
|
-}
|
|
|
-#endif /* DEBUG_PRINTF_RECEIVE */
|
|
|
-
|
|
|
#endif /* PLATFORM */
|
|
|
/******************************************************************************/
|
|
|
|
|
|
+#endif /* __HW_UART_ATY_C */
|
|
|
|
|
|
+/************************************ etc *************************************/
|
|
|
+/* init */
|
|
|
+/* STM32 (Open uart global IT, open rx DMA(Mode Normal, Width Byte) and default DMA IT) */
|
|
|
+// // uart2
|
|
|
+// extern DMA_HandleTypeDef hdma_usart2_rx;
|
|
|
+// void UartReceiveProcess_User_2(void);
|
|
|
+// void UartInit_2(uint8_t* rx)
|
|
|
+// {
|
|
|
+// // __HAL_UART_ENABLE_IT(&huart2, UART_IT_IDLE);
|
|
|
+// HAL_UARTEx_ReceiveToIdle_DMA(&huart2, rx, UART_RX_MAX_LEN);
|
|
|
+// __HAL_DMA_DISABLE_IT(&hdma_usart2_rx, DMA_IT_HT);
|
|
|
+// }
|
|
|
+// void UartSendByte_2(uint8_t byte)
|
|
|
+// {
|
|
|
+// // LL
|
|
|
+// // LL_USART_TransmitData8(huart2, byte);
|
|
|
+// // while(!LL_USART_IsActiveFlag_TC(huart2)){}
|
|
|
+// // HAL
|
|
|
+// HAL_UART_Transmit(&huart2, (uint8_t*)&byte, 1, 0xFFFF);
|
|
|
+// }
|
|
|
+// struct HW_UART_ATY_Dev HW_UART_ATY_Dev_2 = {
|
|
|
+// // .rx = uartRx1,
|
|
|
+// .rx = {0},
|
|
|
+// .rxCount = 0,
|
|
|
+// .txCount = 0,
|
|
|
+// .rcvOverTimeOutCountNum = 2000,
|
|
|
+// .rcvOverTimeOutCount = 0,
|
|
|
+// .rcvOverFlag = 0,
|
|
|
+
|
|
|
+// .uartInitFlag = 0,
|
|
|
+// .uartInit = UartInit_2,
|
|
|
+// .uartSendByte = UartSendByte_2,
|
|
|
+
|
|
|
+// .uartReceiveProcess_User = UartReceiveProcess_User_2,
|
|
|
+
|
|
|
+// .lock = _ATY_UNLOCKED,
|
|
|
+// .debugEnable = 0,
|
|
|
+// // .LOG = printf
|
|
|
+// };
|
|
|
+// // uart3
|
|
|
+// extern DMA_HandleTypeDef hdma_usart3_rx;
|
|
|
+// void UartReceiveProcess_User_3(void);
|
|
|
+// void UartInit_3(uint8_t* rx)
|
|
|
+// {
|
|
|
+// // __HAL_UART_ENABLE_IT(&huart3, UART_IT_IDLE);
|
|
|
+// HAL_UARTEx_ReceiveToIdle_DMA(&huart3, rx, UART_RX_MAX_LEN);
|
|
|
+// __HAL_DMA_DISABLE_IT(&hdma_usart3_rx, DMA_IT_HT);
|
|
|
+// }
|
|
|
+// void UartSendByte_3(uint8_t byte)
|
|
|
+// {
|
|
|
+// // LL
|
|
|
+// // LL_USART_TransmitData8(huart3, byte);
|
|
|
+// // while(!LL_USART_IsActiveFlag_TC(huart3)){}
|
|
|
+// // HAL
|
|
|
+// HAL_UART_Transmit(&huart3, (uint8_t*)&byte, 1, 0xFFFF);
|
|
|
+// }
|
|
|
+// struct HW_UART_ATY_Dev HW_UART_ATY_Dev_3 = {
|
|
|
+// // .rx = uartRx1,
|
|
|
+// .rx = {0},
|
|
|
+// .rxCount = 0,
|
|
|
+// .txCount = 0,
|
|
|
+// .rcvOverTimeOutCountNum = 2000,
|
|
|
+// .rcvOverTimeOutCount = 0,
|
|
|
+// .rcvOverFlag = 0,
|
|
|
+
|
|
|
+// .uartInitFlag = 0,
|
|
|
+// .uartInit = UartInit_3,
|
|
|
+// .uartSendByte = UartSendByte_3,
|
|
|
+
|
|
|
+// .uartReceiveProcess_User = UartReceiveProcess_User_3,
|
|
|
+
|
|
|
+// .lock = _ATY_UNLOCKED,
|
|
|
+// .debugEnable = 0,
|
|
|
+// // .LOG = printf
|
|
|
+// };
|
|
|
+// void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef* huart, uint16_t Size)
|
|
|
+// {
|
|
|
+// if(huart == &huart2){
|
|
|
+// HAL_UART_DMAStop(&huart2);
|
|
|
+// HW_UART_ATY_Dev_2.rcvOverTimeOutCount = 0;
|
|
|
+// HW_UART_ATY_Dev_2.rxCount = UART_RX_MAX_LEN - __HAL_DMA_GET_COUNTER(&hdma_usart2_rx);
|
|
|
+// HW_UART_ATY_Dev_2.rcvOverFlag = 0;
|
|
|
+
|
|
|
+// HAL_UARTEx_ReceiveToIdle_DMA(&huart2, HW_UART_ATY_Dev_2.rx, UART_RX_MAX_LEN);
|
|
|
+// __HAL_DMA_DISABLE_IT(&hdma_usart2_rx, DMA_IT_HT);
|
|
|
+// }
|
|
|
+// else if(huart == &huart3){
|
|
|
+// HAL_UART_DMAStop(&huart3);
|
|
|
+// HW_UART_ATY_Dev_3.rcvOverTimeOutCount = 0;
|
|
|
+// HW_UART_ATY_Dev_3.rxCount = UART_RX_MAX_LEN - __HAL_DMA_GET_COUNTER(&hdma_usart3_rx);
|
|
|
+// HW_UART_ATY_Dev_3.rcvOverFlag = 0;
|
|
|
+
|
|
|
+// HAL_UARTEx_ReceiveToIdle_DMA(&huart3, HW_UART_ATY_Dev_3.rx, UART_RX_MAX_LEN);
|
|
|
+// __HAL_DMA_DISABLE_IT(&hdma_usart3_rx, DMA_IT_HT);
|
|
|
+// }
|
|
|
|
|
|
-/**
|
|
|
- * @brief uart send bytes
|
|
|
- * @param bytes bytes to send
|
|
|
- * @param len bytes to send
|
|
|
- */
|
|
|
-void UartSendBytes(uint8_t* bytes, uint16_t len)
|
|
|
-{
|
|
|
- while(len--)
|
|
|
- UartSendByte(*bytes++);
|
|
|
-}
|
|
|
-
|
|
|
-/**
|
|
|
- * @brief uart send string
|
|
|
- * @param str data to send
|
|
|
- */
|
|
|
-void UartSendStr(uint8_t* str)
|
|
|
-{
|
|
|
- while(*str)
|
|
|
- UartSendByte(*str++);
|
|
|
-}
|
|
|
-
|
|
|
-/**
|
|
|
- * @brief uart send float data in little endian
|
|
|
- * @param dataFloat float number
|
|
|
- */
|
|
|
-void UartSendFloat(float dataFloat)
|
|
|
-{
|
|
|
- union result
|
|
|
- {
|
|
|
- float temp_f;
|
|
|
- uint8_t temp_uint8[4];
|
|
|
- }resultA, resultB;
|
|
|
-
|
|
|
- resultA.temp_f = dataFloat;
|
|
|
- resultB.temp_uint8[0] = resultA.temp_uint8[0];
|
|
|
- resultB.temp_uint8[1] = resultA.temp_uint8[1];
|
|
|
- resultB.temp_uint8[2] = resultA.temp_uint8[2];
|
|
|
- resultB.temp_uint8[3] = resultA.temp_uint8[3];
|
|
|
- UartSendByte(resultB.temp_uint8[3]);
|
|
|
- UartSendByte(resultB.temp_uint8[2]);
|
|
|
- UartSendByte(resultB.temp_uint8[1]);
|
|
|
- UartSendByte(resultB.temp_uint8[0]);
|
|
|
-}
|
|
|
-
|
|
|
-/**
|
|
|
- * @brief uart send float data in ASCII character type
|
|
|
- * @param dataFloat number to send, use double to get better
|
|
|
- * @note float and double is the same in C51
|
|
|
- */
|
|
|
-// void UartSendFloatStr(double dataFloat)
|
|
|
-void UartSendFloatStr(float dataFloat)
|
|
|
-{
|
|
|
-#define DECIMALS_NUM 4
|
|
|
- uint8_t i = 0;
|
|
|
- uint8_t dataStr[10]; // ulongint 4294967295, 6.4f
|
|
|
- unsigned long int tempSaveData = 0;
|
|
|
+// /* if process is not too long, process function can be used at this call back;
|
|
|
+// otherwise put process at other cycle like while or timer cycle */
|
|
|
+// // UartReceiveProcess_User_2();
|
|
|
+// // UartReceiveProcess_User_3();
|
|
|
+// }
|
|
|
|
|
|
- for(i = 0; i < 10; i++)
|
|
|
- dataStr[i] = 0;
|
|
|
+/* 51 */
|
|
|
|
|
|
- if(dataFloat < 0)
|
|
|
- {
|
|
|
- dataFloat = -dataFloat;
|
|
|
- UartSendByte('-');
|
|
|
- }
|
|
|
- tempSaveData = (dataFloat * 10000) + 0.5;
|
|
|
- for(i = 0; tempSaveData != 0; i++)
|
|
|
- {
|
|
|
- dataStr[10 - 1 - i] = tempSaveData % 10;
|
|
|
- tempSaveData /= 10;
|
|
|
- }
|
|
|
- // UartSendByte(i + 48);
|
|
|
- if(i < 5)
|
|
|
- i = 5;
|
|
|
- while(i--)
|
|
|
- {
|
|
|
- UartSendByte(dataStr[10 - 1 - i] + 48);
|
|
|
- if(i == DECIMALS_NUM)
|
|
|
- UartSendByte('.');
|
|
|
- }
|
|
|
- UartSendByte(' ');
|
|
|
-}
|
|
|
|
|
|
|
|
|
+/* use */
|
|
|
+// void main()
|
|
|
+// {
|
|
|
+// UartSendStr("Hello word!", &HW_UART_ATY_Dev_2);
|
|
|
+// UartSendStr("Hello word!", &HW_UART_ATY_Dev_3);
|
|
|
+// while (1)
|
|
|
+// {
|
|
|
+// UartReceiveProcess(&HW_UART_ATY_Dev_2);
|
|
|
+// UartReceiveProcess(&HW_UART_ATY_Dev_3);
|
|
|
+// }
|
|
|
+// }
|
|
|
|
|
|
-/**
|
|
|
- * @brief uart receive data process
|
|
|
- * @note put at main while
|
|
|
- */
|
|
|
-__WEAK_ATY void UartReceiveProcess(void)
|
|
|
-{
|
|
|
-#ifdef DEBUG_PRINTF_RECEIVE
|
|
|
- PrintfReceiveProcess();
|
|
|
-#else
|
|
|
- // if(uartMsgStruct_t.overCount >= 10000)
|
|
|
- if(uartMsgStruct_t.overCount > 2000)
|
|
|
- {
|
|
|
- uartMsgStruct_t.overCount = 0;
|
|
|
- if(uartMsgStruct_t.rxCount != 0)
|
|
|
- {
|
|
|
- // UartSendStr(&uartMsgStruct_t.rxCount);
|
|
|
- UartReceiveProcess_User(&uartMsgStruct_t);
|
|
|
- while(uartMsgStruct_t.rxCount){
|
|
|
- uartMsgStruct_t.rx[uartMsgStruct_t.rxCount--] = 0;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- uartMsgStruct_t.overCount++;
|
|
|
-#endif
|
|
|
-}
|
|
|
|
|
|
// /**
|
|
|
// * @brief uart receive data analysis in user define self
|
|
|
// */
|
|
|
-// void UartReceiveProcess_User(struct _uartMsgStruct* ptr)
|
|
|
+// void UartReceiveProcess_User_2(void)
|
|
|
// {
|
|
|
-// if(ptr->rx[0] == 'O' && ptr->rx[1] == 'K')
|
|
|
-// UartSendStr("\r\nRC OK!\r\n");
|
|
|
-// // UartSendStr(ptr->rx);
|
|
|
-
|
|
|
-// if(memcmp("DSTART", (char*)ptr->rx, strlen("DSTART")) == 0)
|
|
|
+// if((HW_UART_ATY_Dev_2.rx[0] == 'O'
|
|
|
+// && HW_UART_ATY_Dev_2.rx[1] == 'K'
|
|
|
+// && HW_UART_ATY_Dev_2.rx[2] == '?'))
|
|
|
+// UartSendStr("OK!", &HW_UART_ATY_Dev_2);
|
|
|
+// }
|
|
|
+// void UartReceiveProcess_User_3(void)
|
|
|
+// {
|
|
|
+// if((HW_UART_ATY_Dev_3.rx[0] == 'O'
|
|
|
+// && HW_UART_ATY_Dev_3.rx[1] == 'K'
|
|
|
+// && HW_UART_ATY_Dev_3.rx[2] == '?'))
|
|
|
+// UartSendStr("OK!", &HW_UART_ATY_Dev_3);
|
|
|
+//
|
|
|
+// Modbus_Process(HW_UART_ATY_Dev_3.rx, HW_UART_ATY_Dev_3.rxCount, &MODBUS_S_LOW_ATY_Dev_1);
|
|
|
+//
|
|
|
+//
|
|
|
+// // UartSendStr(HW_UART_ATY_Dev_1.rx, &HW_UART_ATY_Dev_3);
|
|
|
+// if(memcmp("DSTART", (char*)HW_UART_ATY_Dev_1.rx, strlen("DSTART")) == 0)
|
|
|
// {
|
|
|
// printf("\r\nDebug START!");
|
|
|
// }
|
|
|
-// else if(memcmp("temp", (char*)ptr->rx, strlen("temp")) == 0)
|
|
|
+// else if(memcmp("temp", (char*)HW_UART_ATY_Dev_1.rx, strlen("temp")) == 0)
|
|
|
// {
|
|
|
// printf("\r\ntemp %c%c%c",
|
|
|
-// ptr->rx[strlen("temp_")],
|
|
|
-// ptr->rx[strlen("temp_") + 1],
|
|
|
-// ptr->rx[strlen("temp_") + 2]);
|
|
|
-// }
|
|
|
-
|
|
|
-// if((ptr->rx[0] == 'O'
|
|
|
-// && ptr->rx[1] == 'K'
|
|
|
-// && ptr->rx[2] == '?'))
|
|
|
-// UartSendStr("OK!");
|
|
|
-
|
|
|
-// Modbus_Process(ptr->rx, ptr->rxCount);
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
-// void main()
|
|
|
-// {
|
|
|
-// UartInit();
|
|
|
-// UartSendStr("Uart Test !\r\n");
|
|
|
-
|
|
|
-// while (1)
|
|
|
-// {
|
|
|
-// UartReceiveProcess();
|
|
|
+// HW_UART_ATY_Dev_1.rx[strlen("temp_")],
|
|
|
+// HW_UART_ATY_Dev_1.rx[strlen("temp_") + 1],
|
|
|
+// HW_UART_ATY_Dev_1.rx[strlen("temp_") + 2]);
|
|
|
// }
|
|
|
// }
|
|
|
-
|
|
|
-
|
|
|
-#endif /* __HW_UART_ATY_C */
|
|
|
+/******************************************************************************/
|
|
|
|
|
|
/******************************** End Of File *********************************/
|