You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
97 lines
3.2 KiB
97 lines
3.2 KiB
|
3 days ago
|
/******************************************************************************
|
||
|
|
|
||
|
|
版权所有 (C), 2018-2099, Radkil
|
||
|
|
|
||
|
|
******************************************************************************
|
||
|
|
文 件 名 : Spoolend.c
|
||
|
|
版 本 号 : 初稿
|
||
|
|
作 者 : radkil
|
||
|
|
生成日期 : 2026年6月10日
|
||
|
|
最近修改 :
|
||
|
|
功能描述 : 线轴端控制板
|
||
|
|
|
||
|
|
修改历史 :
|
||
|
|
1.日 期 : 2026年6月10日
|
||
|
|
作 者 : radkil
|
||
|
|
修改内容 : 创建文件
|
||
|
|
|
||
|
|
******************************************************************************/
|
||
|
|
|
||
|
|
/*----------------------------------------------*
|
||
|
|
* 外部变量说明 *
|
||
|
|
*----------------------------------------------*/
|
||
|
|
|
||
|
|
/*----------------------------------------------*
|
||
|
|
* 外部函数原型说明 *
|
||
|
|
*----------------------------------------------*/
|
||
|
|
|
||
|
|
/*----------------------------------------------*
|
||
|
|
* 内部函数原型说明 *
|
||
|
|
*----------------------------------------------*/
|
||
|
|
|
||
|
|
/*----------------------------------------------*
|
||
|
|
* 全局变量 *
|
||
|
|
*----------------------------------------------*/
|
||
|
|
TComCtrl *g_ptRS485_1;
|
||
|
|
TComCtrl *g_ptRS485_2;
|
||
|
|
|
||
|
|
/*----------------------------------------------*
|
||
|
|
* 模块级变量 *
|
||
|
|
*----------------------------------------------*/
|
||
|
|
|
||
|
|
/*----------------------------------------------*
|
||
|
|
* 常量定义 *
|
||
|
|
*----------------------------------------------*/
|
||
|
|
|
||
|
|
/*----------------------------------------------*
|
||
|
|
* 宏定义 *
|
||
|
|
*----------------------------------------------*/
|
||
|
|
|
||
|
|
int RS485_1_Send(char *_pBuffer, uint32_t _iSize)
|
||
|
|
{
|
||
|
|
HAL_GPIO_WritePin(RS485_1_DIR_GPIO_Port, RS485_1_DIR_Pin, GPIO_PIN_SET);
|
||
|
|
TUartUserData *ptUartUserData = (TUartUserData *)g_ptRS485_1->m_pUserData;
|
||
|
|
int iRet = HAL_UART_Transmit(ptUartUserData->m_uart, (uint8_t *)_pBuffer, _iSize, 100);
|
||
|
|
HAL_GPIO_WritePin(RS485_1_DIR_GPIO_Port, RS485_1_DIR_Pin, GPIO_PIN_RESET);
|
||
|
|
return iRet;
|
||
|
|
}
|
||
|
|
|
||
|
|
int RS485_2_Send(char *_pBuffer, uint32_t _iSize)
|
||
|
|
{
|
||
|
|
HAL_GPIO_WritePin(RS485_2_DIR_GPIO_Port, RS485_2_DIR_Pin, GPIO_PIN_SET);
|
||
|
|
TUartUserData *ptUartUserData = (TUartUserData *)g_ptRS485_2->m_pUserData;
|
||
|
|
int iRet = HAL_UART_Transmit(ptUartUserData->m_uart, (uint8_t *)_pBuffer, _iSize, 100);
|
||
|
|
HAL_GPIO_WritePin(RS485_2_DIR_GPIO_Port, RS485_2_DIR_Pin, GPIO_PIN_RESET);
|
||
|
|
return iRet;
|
||
|
|
}
|
||
|
|
|
||
|
|
#ifndef CONFIG_UART_IT_IDLEDMA
|
||
|
|
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
|
||
|
|
{
|
||
|
|
if (huart->Instance == LPUART1)
|
||
|
|
{
|
||
|
|
UART_RX_IRQHandler(g_ptRS485_1);
|
||
|
|
}
|
||
|
|
else if (huart->Instance == USART1)
|
||
|
|
{
|
||
|
|
UART_RX_IRQHandler(g_ptRS485_2);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
|
void SpoolendInit(void)
|
||
|
|
{
|
||
|
|
TUartUserData *ptUartUserData = UART_userdata_init(0, -1, 512);
|
||
|
|
g_ptRS485_1 = rd_ComCreate(check_MK32Data, decode_MK32Data, E28_SBUS_Send, ptUartUserData->m_buf_size, ptUartUserData);
|
||
|
|
UART_IT_init(g_ptRS485_1);
|
||
|
|
TUartUserData *ptUartUserData1 = UART_userdata_init(0, -1, 512);
|
||
|
|
g_ptRS485_1 = rd_ComCreate(check_MK32Data, decode_MK32Data, E28_SBUS_Send, ptUartUserData1->m_buf_size, ptUartUserData1);
|
||
|
|
UART_IT_init(g_ptRS485_1);
|
||
|
|
}
|
||
|
|
|
||
|
|
void SpoolendTask(void)
|
||
|
|
{
|
||
|
|
|
||
|
|
}
|
||
|
|
|