0.2.1 Добавлено включение/отключение разных модулей для оптимизации размера прошивки
This commit is contained in:
@@ -61,7 +61,7 @@
|
||||
|
||||
#define RS_Set_TX_Flags(_hRS_) _hRS_->f.TX_Busy = 1; _hRS_->f.TX_Done = 0
|
||||
|
||||
#define RS_Reset_RX_Active_Flags(_hRS_) _hRS_->f.RX_Ongoing = 0
|
||||
#define RS_Reset_RX_Active_Flags(_hRS_) _hRS_->f.RX_Ongoing = 0; _hRS_->f.RX_Continue = 0;
|
||||
#define RS_Reset_RX_Flags(_hRS_) RS_Reset_RX_Active_Flags(_hRS_); _hRS_->f.RX_Busy = 0; _hRS_->f.RX_Done = 0; _hRS_->f.RX_Half = 0
|
||||
#define RS_Reset_TX_Flags(_hRS_) _hRS_->f.TX_Busy = 0; _hRS_->f.TX_Done = 0
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
******************************************************************************/
|
||||
#include "modbus_coils.h"
|
||||
|
||||
|
||||
#ifdef MODBUS_ENABLE_COILS
|
||||
|
||||
/**
|
||||
* @brief Set or Reset Coil at its global address.
|
||||
@@ -236,3 +236,12 @@ uint8_t MB_Write_Miltuple_Coils(RS_MsgTypeDef *modbus_msg)
|
||||
|
||||
return 1;
|
||||
}
|
||||
#else //MODBUS_ENABLE_COILS
|
||||
|
||||
MB_ExceptionTypeDef MB_Write_Coil_Global(uint16_t Addr, MB_CoilsOpTypeDef WriteVal) {return ILLEGAL_FUNCTION;}
|
||||
uint16_t MB_Read_Coil_Global(uint16_t Addr, MB_ExceptionTypeDef *Exception) {return 0;}
|
||||
uint8_t MB_Proccess_Read_Coils(RS_MsgTypeDef *modbus_msg) {return 0;}
|
||||
uint8_t MB_Proccess_Write_Single_Coil(RS_MsgTypeDef *modbus_msg) {return 0;}
|
||||
uint8_t MB_Write_Miltuple_Coils(RS_MsgTypeDef *modbus_msg) {return 0;}
|
||||
|
||||
#endif
|
||||
@@ -16,6 +16,8 @@
|
||||
******************************************************************************/
|
||||
#include "modbus_devid.h"
|
||||
|
||||
#ifdef MODBUS_ENABLE_DEVICE_IDENTIFICATORS
|
||||
|
||||
MB_DeviceIdentificationTypeDef MB_DEVID; ///< Device Identificatino=
|
||||
|
||||
|
||||
@@ -539,3 +541,13 @@ void MB_DeviceInentificationInit(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#else //MODBUS_ENABLE_DEVICE_IDENTIFICATORS
|
||||
|
||||
|
||||
void MB_WriteSingleObjectToMessage(char *mbdata, unsigned *ind, MB_DeviceObjectTypeDef *obj) {}
|
||||
void MB_WriteObjectsToMessage(RS_MsgTypeDef *modbus_msg, unsigned maxidofobj) {}
|
||||
uint8_t MB_Proccess_Read_Device_Identification(RS_MsgTypeDef *modbus_msg) {return 0;}
|
||||
void MB_DeviceInentificationInit(void) {}
|
||||
|
||||
#endif
|
||||
@@ -12,6 +12,7 @@
|
||||
******************************************************************************/
|
||||
#include "modbus_diag.h"
|
||||
|
||||
#ifdef MODBUS_ENABLE_DIAGNOSTICS
|
||||
// Глобальная структура диагностики
|
||||
MB_DiagnosticsInfoTypeDef MB_DIAG = {0};
|
||||
|
||||
@@ -291,3 +292,21 @@ MB_DeviceModeTypeDef MB_GetDeviceMode(void)
|
||||
{
|
||||
return MB_DIAG.DeviceMode;
|
||||
}
|
||||
|
||||
#else //MODBUS_ENABLE_DIAGNOSTICS
|
||||
|
||||
void MB_DiagnosticsInit(void) {}
|
||||
int MB_Diagnostics_WriteBit(int bit_num, int bit_state) {return 0;}
|
||||
int MB_Diagnostics_GetBit(int bit_num) {return 0;}
|
||||
uint8_t MB_Proccess_Diagnostics(RS_MsgTypeDef *modbus_msg) {return 0;}
|
||||
void MB_Diagnostics_BusMessageCnt(void) {}
|
||||
void MB_Diagnostics_CommunicationErrorCnt(void) {}
|
||||
void MB_Diagnostics_ExceptionErrorCnt(void) {}
|
||||
void MB_Diagnostics_CharacterOverrunCnt(void) {}
|
||||
void MB_Diagnostics_SlaveMessageCnt(void) {}
|
||||
void MB_Diagnostics_SlaveNoResponseCnt(void) {}
|
||||
void MB_Diagnostics_SlaveNAKCnt(void) {}
|
||||
void MB_Diagnostics_SlaveBusyCnt(void) {}
|
||||
MB_DeviceModeTypeDef MB_GetDeviceMode(void) {return MODBUS_NORMAL_MODE;}
|
||||
|
||||
#endif
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "modbus_inputregs.h"
|
||||
|
||||
|
||||
#ifdef MODBUS_ENABLE_HOLDINGS
|
||||
|
||||
|
||||
/**
|
||||
@@ -97,3 +98,12 @@ uint8_t MB_Proccess_Write_Miltuple_Regs(RS_MsgTypeDef *modbus_msg)
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
#else //MODBUS_ENABLE_HOLDINGS
|
||||
|
||||
uint8_t MB_Proccess_Read_Hold_Regs(RS_MsgTypeDef *modbus_msg) {return 0;}
|
||||
uint8_t MB_Proccess_Write_Single_Reg(RS_MsgTypeDef *modbus_msg) {return 0;}
|
||||
uint8_t MB_Proccess_Write_Miltuple_Regs(RS_MsgTypeDef *modbus_msg) {return 0;}
|
||||
|
||||
#endif
|
||||
@@ -12,6 +12,8 @@
|
||||
#include "modbus_inputregs.h"
|
||||
|
||||
|
||||
#ifdef MODBUS_ENABLE_INPUTS
|
||||
|
||||
/**
|
||||
* @brief Proccess command Read Input Registers (04 - 0x04).
|
||||
* @param modbus_msg Указатель на структуру собщения modbus.
|
||||
@@ -42,3 +44,9 @@ uint8_t MB_Proccess_Read_Input_Regs(RS_MsgTypeDef *modbus_msg)
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
#else //MODBUS_ENABLE_INPUTS
|
||||
|
||||
uint8_t MB_Proccess_Read_Input_Regs(RS_MsgTypeDef *modbus_msg) {return 0;}
|
||||
|
||||
#endif
|
||||
@@ -339,6 +339,7 @@ void RS_UART_Handler(RS_HandleTypeDef *hRS)
|
||||
__HAL_UART_CLEAR_IDLEFLAG(hRS->huart); // Важно: очистить флаг IDLE
|
||||
//-------------STANDARD UART HANDLING-------------
|
||||
HAL_UART_IRQHandler(hRS->huart);
|
||||
hRS->f.RX_Continue = 0;
|
||||
|
||||
// Если прием активен и мы получили IDLE - это конец фрейма
|
||||
if(RS_Is_RX_Busy(hRS) && hRS->f.RX_Ongoing)
|
||||
|
||||
Reference in New Issue
Block a user