|
|
|
@ -18,6 +18,7 @@ |
|
|
|
******************************************************************************/ |
|
|
|
#include "bsp_uart.h" |
|
|
|
#include "bsp_CAN.h" |
|
|
|
#include "com.h" |
|
|
|
#include "fdcan.h" |
|
|
|
/*----------------------------------------------*
|
|
|
|
* 外部变量说明 * |
|
|
|
@ -84,27 +85,39 @@ void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) |
|
|
|
|
|
|
|
static int check_RS485_1(char *_pBuffer, uint32_t _iSize) |
|
|
|
{ |
|
|
|
rd_ComSend(g_ptRS485_1, _pBuffer, _iSize); |
|
|
|
return _iSize; |
|
|
|
} |
|
|
|
|
|
|
|
static int check_RS485_2(char *_pBuffer, uint32_t _iSize) |
|
|
|
{ |
|
|
|
rd_ComSend(g_ptRS485_2, _pBuffer, _iSize); |
|
|
|
return _iSize; |
|
|
|
} |
|
|
|
|
|
|
|
static int check_Spoolend(char *_pBuffer, uint32_t _iSize) |
|
|
|
{ |
|
|
|
TCANUserData *ptCANUserData = (TCANUserData *)g_ptFDCAN1->m_pUserData; |
|
|
|
uint32_t iCANId = (uint8_t)ptCANUserData->m_canrx->Identifier; |
|
|
|
rd_ComIDSend(g_ptFDCAN1, iCANId, _pBuffer, _iSize); |
|
|
|
return _iSize; |
|
|
|
} |
|
|
|
|
|
|
|
static void decode_RS485_1(const char *_pBuffer, uint32_t _iSize) |
|
|
|
{ |
|
|
|
rd_ComSend(g_ptRS485_1, (char *)_pBuffer, _iSize); |
|
|
|
} |
|
|
|
|
|
|
|
static void decode_RS485_2(const char *_pBuffer, uint32_t _iSize) |
|
|
|
{ |
|
|
|
rd_ComSend(g_ptRS485_2, (char *)_pBuffer, _iSize); |
|
|
|
} |
|
|
|
|
|
|
|
static void decode_Spoolend(const char *_pBuffer, uint32_t _iSize) |
|
|
|
{ |
|
|
|
TCANUserData *ptCANUserData = (TCANUserData *)g_ptFDCAN1->m_pUserData; |
|
|
|
uint32_t iCANId = (uint32_t)ptCANUserData->m_canrx->Identifier; |
|
|
|
rd_ComIDWrite(g_ptFDCAN1, iCANId, (char *)_pBuffer, _iSize); |
|
|
|
} |
|
|
|
|
|
|
|
static int FDCAN1_Send(char *_pBuffer, uint32_t _iSize) |
|
|
|
{ |
|
|
|
return CAN_TX_FIFOQ(g_ptFDCAN1, _pBuffer[0], &_pBuffer[4], _iSize); |
|
|
|
return CAN_TX_FIFOQ(g_ptFDCAN1, _pBuffer, _iSize); |
|
|
|
} |
|
|
|
|
|
|
|
void HAL_FDCAN_ErrorStatusCallback(FDCAN_HandleTypeDef *hfdcan, uint32_t ErrorStatusITs) |
|
|
|
@ -154,13 +167,13 @@ int Myprint_putchar(uint8_t ch) |
|
|
|
void SpoolendInit(void) |
|
|
|
{ |
|
|
|
TUartUserData *ptUartUserData = UART_userdata_init(0, 115200, 512); |
|
|
|
g_ptRS485_1 = rd_ComCreate(check_RS485_1, NULL, RS485_1_Send, ptUartUserData->m_buf_size, ptUartUserData); |
|
|
|
g_ptRS485_1 = rd_ComCreate(check_RS485_1, decode_RS485_1, RS485_1_Send, ptUartUserData->m_buf_size, ptUartUserData); |
|
|
|
UART_IT_init(g_ptRS485_1); |
|
|
|
// TUartUserData *ptUartUserData1 = UART_userdata_init(0, 115200, 512);
|
|
|
|
// g_ptRS485_2 = rd_ComCreate(check_RS485_2, NULL, RS485_2_Send, ptUartUserData1->m_buf_size, ptUartUserData1);
|
|
|
|
// g_ptRS485_2 = rd_ComCreate(check_RS485_2, decode_RS485_2, RS485_2_Send, ptUartUserData1->m_buf_size, ptUartUserData1);
|
|
|
|
// UART_IT_init(g_ptRS485_2);
|
|
|
|
TCANUserData *ptCANUserData = CAN_userdata_init(&hfdcan1, 8, 0); |
|
|
|
g_ptFDCAN1 = rd_ComCreate(check_Spoolend, NULL, FDCAN1_Send, CONFIG_UART_BUFFER_SIZE, ptCANUserData); |
|
|
|
g_ptFDCAN1 = rd_ComCreate(check_Spoolend, decode_Spoolend, FDCAN1_Send, CONFIG_UART_BUFFER_SIZE, ptCANUserData); |
|
|
|
CAN_IT_init(g_ptFDCAN1); |
|
|
|
} |
|
|
|
|
|
|
|
@ -178,6 +191,7 @@ void SpoolendTask(void) |
|
|
|
HAL_GPIO_TogglePin(LED1_GPIO_Port, LED1_Pin); |
|
|
|
HAL_GPIO_TogglePin(LED2_GPIO_Port, LED2_Pin); |
|
|
|
HAL_GPIO_TogglePin(LED3_GPIO_Port, LED3_Pin); |
|
|
|
rd_ComSendProc(g_ptFDCAN1); |
|
|
|
HAL_Delay(500); |
|
|
|
} |
|
|
|
|
|
|
|
|