Compare commits

...

2 Commits

7 changed files with 112 additions and 53 deletions

View File

@ -60,7 +60,7 @@ uint8_t ralay_5v_on_var=0;
float temperature;
extern uint8_t roms[MAX_DEVICES][8];
//extern uint8_t devices_found ;
uint8_t _debug_init=1;
uint8_t _debug_init=0;
//TEMP temp_sense[30];
float set_temp_old[30];
char rx_buffer[64];

View File

@ -726,6 +726,7 @@ __weak void HAL_UART_MspInit(UART_HandleTypeDef *huart)
/**
* @brief UART MSP DeInit.
* @param huart Pointer to a UART_HandleTypeDef structure that contains
* the configuration information for the specified UART module.
* @retval None

View File

@ -148,7 +148,24 @@
<Name>-U37FF71064E57343625581443 -O2254 -SF10000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP (ARM Core") -D00(1BA01477) -L00(0) -TO131090 -TC10000000 -TT10000000 -TP21 -TDS8000 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO15 -FD20000000 -FC800 -FN1 -FF0STM32F10x_128.FLM -FS08000000 -FL08000 -FP0($$Device:STM32F103C6$Flash\STM32F10x_128.FLM) -WA0 -WE0 -WVCE4 -WS2710 -WM0 -WP2</Name>
</SetRegEntry>
</TargetDriverDllRegistry>
<Breakpoint/>
<Breakpoint>
<Bp>
<Number>0</Number>
<Type>0</Type>
<LineNumber>302</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>0</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>0</BreakIfRCount>
<Filename>..\Modbus\modbus.c</Filename>
<ExecCommand></ExecCommand>
<Expression></Expression>
</Bp>
</Breakpoint>
<WatchWindow1>
<Ww>
<count>0</count>
@ -225,6 +242,21 @@
<WinNumber>1</WinNumber>
<ItemText>MB_DATA.Coils.coils[1].state_val_bit.state_val_01,0x0A</ItemText>
</Ww>
<Ww>
<count>15</count>
<WinNumber>1</WinNumber>
<ItemText>RS_Buffer</ItemText>
</Ww>
<Ww>
<count>16</count>
<WinNumber>1</WinNumber>
<ItemText>MODBUS_MSG</ItemText>
</Ww>
<Ww>
<count>17</count>
<WinNumber>1</WinNumber>
<ItemText>modbus_uart_buff</ItemText>
</Ww>
</WatchWindow1>
<WatchWindow2>
<Ww>
@ -233,6 +265,14 @@
<ItemText>resolution</ItemText>
</Ww>
</WatchWindow2>
<MemoryWindow1>
<Mm>
<WinNumber>1</WinNumber>
<SubType>0</SubType>
<ItemText>0x2000058c</ItemText>
<AccSizeX>0</AccSizeX>
</Mm>
</MemoryWindow1>
<Tracepoint>
<THDelay>0</THDelay>
</Tracepoint>
@ -433,7 +473,7 @@
<GroupNumber>2</GroupNumber>
<FileNumber>8</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\Modbus\modbus.c</PathWithFileName>

View File

@ -807,6 +807,17 @@ RS_StatusTypeDef RS_Parse_Message(RS_HandleTypeDef *hmodbus, RS_MsgTypeDef *modb
uint32_t check_empty_buff;
int ind = 0; // ind for modbus-uart buffer
//-----INFO ABOUT DATA/MESSAGE-------
#ifdef TCP_ModBus
modbus_msg->ID_Transaction=modbus_uart_buff[ind++]<<8;
modbus_msg->ID_Transaction|=modbus_uart_buff[ind++];
modbus_msg->ID_Prot=modbus_uart_buff[ind++]<<8;
modbus_msg->ID_Prot|=modbus_uart_buff[ind++];
modbus_msg->PDU_Length=modbus_uart_buff[ind++]<<8;
modbus_msg->PDU_Length|=modbus_uart_buff[ind++];
#else
#endif
//-----------[first bits]------------
// get ID of message/user
modbus_msg->MbAddr = modbus_uart_buff[ind++];

View File

@ -11,7 +11,7 @@
*************************************************************************/
#ifndef __MODBUS_H_
#define __MODBUS_H_
#define TCP_ModBus
#include "modbus_config.h"
#include "modbus_data.h"
//#include "settings.h" // for modbus settings
@ -32,6 +32,10 @@
/////////////////////---USER MESSAGE DEFINES---//////////////////////
//-------------DEFINES FOR STRUCTURE----------------
/* defines for structure of modbus message */
#define ID_Transaction_size 2
#define ID_Prot_size 2
#define DataLength_size 2
#define MbAddr_SIZE 1 ///< size of (MbAddr)
#define Func_Code_SIZE 1 ///< size of (Func_Code)
#define Addr_SIZE 2 ///< size of (Addr)
@ -41,8 +45,11 @@
#define CRC_SIZE 2 ///< size of (MB_CRC) in bytes
/** @brief Size of whole message */
#ifdef TCP_ModBus
#define INFO_SIZE_MAX (ID_Transaction_size+ID_Prot_size+DataLength_size+MbAddr_SIZE+Func_Code_SIZE+Addr_SIZE+Qnt_SIZE)
#else
#define INFO_SIZE_MAX (MbAddr_SIZE+Func_Code_SIZE+Addr_SIZE+Qnt_SIZE+ByteCnt_SIZE)
#endif
/** @brief Size of first part of message that will be received
first receive info part of message, than defines size of rest message*/
#define RX_FIRST_PART_SIZE INFO_SIZE_MAX
@ -134,6 +141,10 @@ typedef struct
/** @brief Structure for modbus messsage */
typedef struct // RS_MsgTypeDef
{
uint16_t ID_Transaction;
uint16_t ID_Prot;
uint16_t PDU_Length;
uint8_t MbAddr; ///< Modbus Slave Address
MB_FunctonTypeDef Func_Code; ///< Modbus Function Code
MB_DevIdMsgTypeDef DevId; ///< Read Device Identification Header struct

View File

@ -168,6 +168,8 @@ typedef struct
typedef struct // RS_HandleTypeDef
{
/* MESSAGE */
uint8_t ID; ///< ID of RS "channel"
RS_MsgTypeDef *pMessagePtr; ///< pointer to message struct
uint8_t *pBufferPtr; ///< pointer to message buffer

View File

@ -33,50 +33,48 @@ Mcu.IPNb=11
Mcu.Name=STM32F103C(4-6)Tx
Mcu.Package=LQFP48
Mcu.Pin0=PC13-TAMPER-RTC
Mcu.Pin1=PC14-OSC32_IN
Mcu.Pin10=PA5
Mcu.Pin11=PA6
Mcu.Pin12=PA7
Mcu.Pin13=PB0
Mcu.Pin14=PB1
Mcu.Pin15=PB2
Mcu.Pin16=PB10
Mcu.Pin17=PB11
Mcu.Pin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35=VP_ADC1_TempSens_Input
Mcu.Pin36=VP_ADC1_Vref_Input
Mcu.Pin37=VP_RTC_VS_RTC_Activate
Mcu.Pin38=VP_RTC_VS_RTC_Calendar
Mcu.Pin39=VP_SYS_VS_tim3
Mcu.Pin4=PA1
Mcu.Pin40=VP_TIM1_VS_ClockSourceINT
Mcu.Pin41=VP_TIM2_VS_ClockSourceINT
Mcu.Pin5=PA2
Mcu.Pin6=PA3
Mcu.Pin7=PA4
Mcu.Pin8=PA5
Mcu.Pin9=PA6
Mcu.PinsNb=42
Mcu.ThirdPartyNb=0
Mcu.UserConstants=
Mcu.UserName=STM32F103C6Tx
@ -173,10 +171,6 @@ PB9.Mode=I2C
PB9.Signal=I2C1_SDA
PC13-TAMPER-RTC.Mode=RTC OUT
PC13-TAMPER-RTC.Signal=RTC_OUT
PC14-OSC32_IN.Mode=LSE-External-Oscillator
PC14-OSC32_IN.Signal=RCC_OSC32_IN
PC15-OSC32_OUT.Mode=LSE-External-Oscillator
PC15-OSC32_OUT.Signal=RCC_OSC32_OUT
PD0-OSC_IN.Mode=HSE-External-Oscillator
PD0-OSC_IN.Signal=RCC_OSC_IN
PD1-OSC_OUT.Mode=HSE-External-Oscillator