примерная примерная такая же по размеру структура данных модбас которая будет в итоге, все помещается
hardfault при отключении датчика
This commit is contained in:
@@ -133,8 +133,6 @@ HAL_StatusTypeDef PCHSens_ReadTemperature(PCHSens_ModuleTypeDef *module)
|
||||
if(module == NULL)
|
||||
return HAL_ERROR;
|
||||
|
||||
result = Dallas_StartConvertTAll(module->hdallas, DALLAS_WAIT_BUS, 0);
|
||||
|
||||
result = PCHSens_SensorHandleActions(module->hdallas, &module->sens1);
|
||||
result = PCHSens_SensorHandleActions(module->hdallas, &module->sens2);
|
||||
result = PCHSens_SensorHandleActions(module->hdallas, &module->sens3);
|
||||
@@ -143,7 +141,10 @@ HAL_StatusTypeDef PCHSens_ReadTemperature(PCHSens_ModuleTypeDef *module)
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
HAL_StatusTypeDef PCHSens_Covert(PCHSens_DallasBusHandle *hbus)
|
||||
{
|
||||
return Dallas_StartConvertTAll(hbus->hdallas, DALLAS_WAIT_BUS, 0);
|
||||
}
|
||||
HAL_StatusTypeDef PCHSens_CheckSensor(DALLAS_HandleTypeDef *hdallas, PCHSens_SensorTypeDef* sensor)
|
||||
{
|
||||
HAL_StatusTypeDef result;
|
||||
@@ -272,7 +273,8 @@ void PCHSens_FirstInit(void)
|
||||
OneWire_Init(&OW);
|
||||
DS18B20_Search(&DS, &OW);
|
||||
|
||||
hdallas1.onewire = &OW;
|
||||
DallasBus.hdallas = &hdallas1;
|
||||
DallasBus.hdallas->onewire = &OW;
|
||||
PCHSens_InitModule(&hdallas1, &module1, REG_PCH_NUMB_11|REG_PCH_DIODE_NUMB_1);
|
||||
|
||||
PCHSens_FindUnknownSensors(&DallasBus);
|
||||
|
||||
@@ -164,6 +164,7 @@ HAL_StatusTypeDef PCHSens_InitNewSensor(DALLAS_HandleTypeDef *hdallas, PCHSens_S
|
||||
HAL_StatusTypeDef PCHSens_AddSensor(DALLAS_HandleTypeDef *hdallas, PCHSens_SensorTypeDef* sensor);
|
||||
HAL_StatusTypeDef PCHSens_InitModule(DALLAS_HandleTypeDef *hdallas, PCHSens_ModuleTypeDef* module, uint16_t param);
|
||||
HAL_StatusTypeDef PCHSens_ReadTemperature(PCHSens_ModuleTypeDef *module);
|
||||
HAL_StatusTypeDef PCHSens_Covert(PCHSens_DallasBusHandle *hbus);
|
||||
HAL_StatusTypeDef PCHSens_CheckSensor(DALLAS_HandleTypeDef *hdallas, PCHSens_SensorTypeDef* sensor);
|
||||
HAL_StatusTypeDef PCHSens_FindUnknownSensors(PCHSens_DallasBusHandle *hbus);
|
||||
HAL_StatusTypeDef PCHSens_DefineUnknownSensor(PCHSens_DallasBusHandle *hbus, PCHSens_SensorTypeDef *sensor);
|
||||
|
||||
@@ -31,7 +31,7 @@ extern "C" {
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "py32f0xx_hal.h"
|
||||
|
||||
#include "interface_config.h"
|
||||
/* Private includes ----------------------------------------------------------*/
|
||||
/* Private defines -----------------------------------------------------------*/
|
||||
#define GPIO_LED_2 GPIO_PIN_1
|
||||
|
||||
@@ -21,23 +21,16 @@
|
||||
#define MODBUS_VENDOR_NAME "NIO-12"
|
||||
#define MODBUS_PRODUCT_CODE "12345"
|
||||
#define MODBUS_REVISION "Ver. 1.0"
|
||||
#define MODBUS_VENDOR_URL "https://git.arktika.cyou/Andrey/Diod_Test"
|
||||
#define MODBUS_PRODUCT_NAME "Diode Tester"
|
||||
#define MODBUS_MODEL_NAME "STM32F103"
|
||||
#define MODBUS_USER_APPLICATION_NAME "diode_tester"
|
||||
#define MODBUS_VENDOR_URL "https://git.arktika.cyou/set506/DS18B20_Library/src/branch/py32f002b_dallas"
|
||||
#define MODBUS_PRODUCT_NAME "Dallas Driver"
|
||||
#define MODBUS_MODEL_NAME "PY32F002B"
|
||||
#define MODBUS_USER_APPLICATION_NAME "PY32Dallas"
|
||||
|
||||
//#define MODBUS_UART_NUMB 1 ///< Номер используемого UART, по нему выставляется дефайн USED_MB_UART = USARTx
|
||||
#define MODBUS_SPEED 115200 ///< Скорость UART для модбас
|
||||
//#define MODBUS_GPIOX GPIOA ///< Порт для UART RX/TX
|
||||
//#define MODBUS_GPIO_PIN_RX GPIO_PIN_9 ///< Пин для UART RX
|
||||
//#define MODBUS_GPIO_PIN_TX GPIO_PIN_10 ///< Пин для UART TX
|
||||
|
||||
//#define MODBUS_TIM_NUMB 2 ///< number of used tim, accord to this define sets define USED_MB_TIM = TIMx
|
||||
//#define MODBUS_TIM_AHB_FREQ 72 ///< TIM AHB Bus Freq
|
||||
|
||||
// defines for modbus behaviour
|
||||
#define MODBUS_DEVICE_ID 1 ///< девайс текущего устройства
|
||||
//#define MODBUS_MAX_TIMEOUT 500 ///< максимальнйы тайтаут MB is ms
|
||||
|
||||
#define MODBUS_DATA_SIZE 27 ///< maximum number of data: DWORD (NOT MESSAGE SIZE)
|
||||
|
||||
|
||||
#define RS_UART_Init MX_USART1_UART_Init
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
#define Addr_SIZE 2 ///< size of (Addr)
|
||||
#define Qnt_SIZE 2 ///< size of (Qnt)
|
||||
#define ByteCnt_SIZE 1 ///< size of (ByteCnt)
|
||||
#define DATA_SIZE 27 ///< maximum number of data: DWORD (NOT MESSAGE SIZE)
|
||||
#define DATA_SIZE MODBUS_DATA_SIZE ///< maximum number of data: DWORD (NOT MESSAGE SIZE)
|
||||
#define CRC_SIZE 2 ///< size of (MB_CRC) in bytes
|
||||
|
||||
/** @brief Size of whole message */
|
||||
|
||||
@@ -13,8 +13,9 @@
|
||||
|
||||
#ifndef _MODBUS_DATA_H_
|
||||
#define _MODBUS_DATA_H_
|
||||
|
||||
|
||||
#include "stdint.h"
|
||||
#include "ds18b20_driver.h"
|
||||
//--------------DEFINES FOR REGISTERS---------------
|
||||
// DEFINES FOR ARRAYS
|
||||
/**
|
||||
@@ -37,8 +38,8 @@
|
||||
*/
|
||||
typedef struct //MB_DataInRegsTypeDef
|
||||
{
|
||||
uint16_t ForwardVoltage;
|
||||
uint16_t ReversePeakVoltage;
|
||||
uint16_t SensTemperature[DS18B20_DEVICE_AMOUNT];
|
||||
uint16_t Resolution;
|
||||
}MB_DataInRegsTypeDef;
|
||||
|
||||
|
||||
|
||||
@@ -58,17 +58,20 @@ int main(void)
|
||||
RS_Receive_IT(&hmodbus1, &MODBUS_MSG);
|
||||
|
||||
|
||||
// PCHSens_FirstInit();
|
||||
PCHSens_FirstInit();
|
||||
/* infinite loop */
|
||||
while (1)
|
||||
{
|
||||
GPIOA->ODR ^= GPIO_LED_2;
|
||||
|
||||
PCHSens_Covert(&DallasBus);
|
||||
|
||||
PCHSens_ReadTemperature(&module1);
|
||||
PCHSens_ReadTemperature(&module2);
|
||||
PCHSens_ReadTemperature(&module3);
|
||||
PCHSens_ReadTemperature(&module4);
|
||||
PCHSens_ReadTemperature(&module5);
|
||||
PCHSens_ReadTemperature(&module6);
|
||||
// PCHSens_ReadTemperature(&module2);
|
||||
// PCHSens_ReadTemperature(&module3);
|
||||
// PCHSens_ReadTemperature(&module4);
|
||||
// PCHSens_ReadTemperature(&module5);
|
||||
// PCHSens_ReadTemperature(&module6);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
/* USER CODE END Header */
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "usart.h"
|
||||
|
||||
/* USER CODE BEGIN 0 */
|
||||
|
||||
/* USER CODE END 0 */
|
||||
@@ -39,7 +38,7 @@ void MX_USART1_UART_Init(void)
|
||||
|
||||
/* USER CODE END USART1_Init 1 */
|
||||
huart1.Instance = USART1;
|
||||
huart1.Init.BaudRate = 115200;
|
||||
huart1.Init.BaudRate = MODBUS_SPEED;
|
||||
huart1.Init.WordLength = UART_WORDLENGTH_8B;
|
||||
huart1.Init.StopBits = UART_STOPBITS_1;
|
||||
huart1.Init.Parity = UART_PARITY_NONE;
|
||||
|
||||
Reference in New Issue
Block a user