add iddle irq
This commit is contained in:
@@ -89,7 +89,7 @@ void MODBUS_FirstInit(void)
|
||||
//-----------SETUP MODBUS-------------
|
||||
// set up modbus: MB_RX_Size_NotConst and Timeout enable
|
||||
hmodbus1.ID = MODBUS_DEVICE_ID;
|
||||
hmodbus1.sRS_Timeout = MODBUS_TIMEOUT;
|
||||
hmodbus1.sRS_Timeout = MODBUS_TIMEOUT;
|
||||
hmodbus1.sRS_Mode = SLAVE_ALWAYS_WAIT;
|
||||
hmodbus1.sRS_RX_Size_Mode = RS_RX_Size_NotConst;
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
*************************************************************************/
|
||||
#ifndef __MODBUS_H_
|
||||
#define __MODBUS_H_
|
||||
#define TCP_ModBus
|
||||
//#define TCP_ModBus
|
||||
#include "modbus_config.h"
|
||||
#include "modbus_data.h"
|
||||
//#include "settings.h" // for modbus settings
|
||||
@@ -33,16 +33,16 @@
|
||||
//-------------DEFINES FOR STRUCTURE----------------
|
||||
/* defines for structure of modbus message */
|
||||
|
||||
#define ID_Transaction_size 2
|
||||
#define ID_Prot_size 2
|
||||
#define ID_Transaction_size 2
|
||||
#define ID_Prot_size 2
|
||||
#define DataLength_size 2
|
||||
#define MbAddr_SIZE 1 ///< size of (MbAddr)
|
||||
#define MbAddr_SIZE 1 ///< size of (MbAddr)
|
||||
#define Func_Code_SIZE 1 ///< size of (Func_Code)
|
||||
#define Addr_SIZE 2 ///< size of (Addr)
|
||||
#define Qnt_SIZE 2 ///< size of (Qnt)
|
||||
#define ByteCnt_SIZE 1 ///< size of (ByteCnt)
|
||||
#define DATA_SIZE 125 ///< maximum number of data: DWORD (NOT MESSAGE SIZE)
|
||||
#define CRC_SIZE 2 ///< size of (MB_CRC) in bytes
|
||||
#define Addr_SIZE 2 ///< size of (Addr)
|
||||
#define Qnt_SIZE 2 ///< size of (Qnt)
|
||||
#define ByteCnt_SIZE 1 ///< size of (ByteCnt)
|
||||
#define DATA_SIZE 125 ///< maximum number of data: DWORD (NOT MESSAGE SIZE)
|
||||
#define CRC_SIZE 2 ///< size of (MB_CRC) in bytes
|
||||
|
||||
/** @brief Size of whole message */
|
||||
#ifdef TCP_ModBus
|
||||
@@ -66,7 +66,7 @@ typedef enum //MB_ExceptionTypeDef
|
||||
ILLEGAL_DATA_ADDRESS = 0x02, ///< Адрес данных, указанный в запросе, недоступен
|
||||
ILLEGAL_DATA_VALUE = 0x03, ///< Значение, содержащееся в поле данных запроса, является недопустимой величиной
|
||||
SLAVE_DEVICE_FAILURE = 0x04, ///< Невосстанавливаемая ошибка имела место, пока ведомое устройство пыталось выполнить затребованное действие
|
||||
// ACKNOWLEDGE = 0x05, ///< idk
|
||||
// ACKNOWLEDGE = 0x05, ///< idk
|
||||
// SLAVE_DEVICE_BUSY = 0x06, ///< idk
|
||||
// MEMORY_PARITY_ERROR = 0x08, ///< idk
|
||||
}MB_ExceptionTypeDef;
|
||||
|
||||
@@ -6,11 +6,15 @@
|
||||
#ifndef _MODBUS_CONFIG_H_
|
||||
#define _MODBUS_CONFIG_H_
|
||||
#include "stm32f1xx_hal.h"
|
||||
|
||||
#include "proj_setup.h"
|
||||
// MODBUS PARAMS
|
||||
#define MODBUS_DEVICE_ID 1 ///< девайс текущего устройства
|
||||
#define MODBUS_TIMEOUT 2000 ///< максимальнйы тайтаут MB в тиках таймера
|
||||
|
||||
#define MODBUS_DEVICE_ID 1 ///< девайс текущего устройства
|
||||
#ifdef OldVer
|
||||
#define MODBUS_TIMEOUT 2000 ///< максимальнйы тайтаут MB в тиках таймера
|
||||
#else
|
||||
#define MODBUS_TIMEOUT 0
|
||||
#endif
|
||||
// STRING OBJECTS MODBUS
|
||||
#define MODBUS_VENDOR_NAME "NIO-12"
|
||||
#define MODBUS_PRODUCT_CODE ""
|
||||
|
||||
@@ -486,8 +486,19 @@ void RS_UART_Handler(RS_HandleTypeDef *hRS)
|
||||
*/
|
||||
void RS_TIM_Handler(RS_HandleTypeDef *hRS)
|
||||
{
|
||||
// if(hRS->sRS_Timeout)
|
||||
// HAL_TIM_Base_Stop_IT(hRS->htim);
|
||||
|
||||
|
||||
HAL_TIM_Base_Stop_IT(hRS->htim);
|
||||
RS_Abort(hRS, ABORT_RS);
|
||||
#ifdef OldVer
|
||||
RS_Abort(hRS, ABORT_RS);
|
||||
#else
|
||||
RS_Abort(hRS, ABORT_RX);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
RS_Handle_Receive_Start(hRS, hRS->pMessagePtr);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user