Update HAL version, board description, version number to 10.0

This commit is contained in:
Anton Mukhin
2023-11-22 10:43:10 +03:00
parent 65ca64389e
commit 89ced0fc11
65 changed files with 21574 additions and 1608 deletions

View File

@@ -6,7 +6,7 @@
#ifndef BOARD_LOGIC_H_
#define BOARD_LOGIC_H_
#define MODBUS_FIRMWARE_VERSION ( /*major*/ 1 + /*minor*/ 0 * 0x100)
#define MODBUS_FIRMWARE_VERSION ( /*major*/ 10 + /*minor*/ 0 * 0x100)
#define MODBUS_BOARD_TYPE (8) //Relay Module board ID
#define REL_MAIN_BIT (1u<<0)

View File

@@ -73,6 +73,7 @@ void Error_Handler(void);
#define RL_AUX_GPIO_Port GPIOA
#define RL_MAIN_Pin GPIO_PIN_3
#define RL_MAIN_GPIO_Port GPIOB
/* USER CODE BEGIN Private defines */
/* USER CODE END Private defines */

View File

@@ -13,7 +13,7 @@
#define BOARD_DESC_LEN (23)
extern TIM_HandleTypeDef htim3;
static const char board_description[BOARD_DESC_LEN] = "RS485 Relay Module v1";
static const char board_description[BOARD_DESC_LEN] = "RS485_Relay V1R1";
extern uint16_t tranfer_errors_count;
extern uint16_t last_rx_time;
@@ -141,22 +141,24 @@ uint8_t write_register(uint16_t address, uint16_t value)
#ifdef UART_DEBUG
printf("Write A=0x%X D=0x%X\n\r",address,value);
#endif
switch (address)
{
case 0x2001: relays = value; break;
case 0x2002: motor_pwm = value;
if(motor_pwm>MOTOR_MAX)motor_pwm=MOTOR_MAX;
if(motor_pwm<MOTOR_MIN)motor_pwm=MOTOR_MIN;
if(motor_pwm==0)
HAL_TIM_PWM_Stop(&htim3, TIM_CHANNEL_1);
else
{
HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_1);
__HAL_TIM_SetCompare(&htim3, TIM_CHANNEL_1, motor_pwm);
HAL_Delay(5);
}
break;
default: ret = 1;
switch (address) {
case 0x2001:
relays = value;
break;
case 0x2002:
motor_pwm = value;
if(motor_pwm>MOTOR_MAX)motor_pwm=MOTOR_MAX;
if(motor_pwm<MOTOR_MIN)motor_pwm=MOTOR_MIN;
if(motor_pwm==0)
HAL_TIM_PWM_Stop(&htim3, TIM_CHANNEL_1);
else {
HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_1);
__HAL_TIM_SetCompare(&htim3, TIM_CHANNEL_1, motor_pwm);
HAL_Delay(5);
}
break;
default:
ret = 1;
}
return ret;
}

View File

@@ -143,6 +143,7 @@ void SystemClock_Config(void)
{
Error_Handler();
}
/** Initializes the CPU, AHB and APB buses clocks
*/
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
@@ -230,7 +231,7 @@ static void MX_TIM3_Init(void)
htim3.Instance = TIM3;
htim3.Init.Prescaler = 239;
htim3.Init.CounterMode = TIM_COUNTERMODE_UP;
htim3.Init.Period = 256;
htim3.Init.Period = 255;
htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim3.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
if (HAL_TIM_PWM_Init(&htim3) != HAL_OK)
@@ -317,6 +318,8 @@ static void MX_DMA_Init(void)
static void MX_GPIO_Init(void)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
/* USER CODE BEGIN MX_GPIO_Init_1 */
/* USER CODE END MX_GPIO_Init_1 */
/* GPIO Ports Clock Enable */
__HAL_RCC_GPIOF_CLK_ENABLE();
@@ -343,6 +346,8 @@ static void MX_GPIO_Init(void)
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
/* USER CODE BEGIN MX_GPIO_Init_2 */
/* USER CODE END MX_GPIO_Init_2 */
}
/* USER CODE BEGIN 4 */
@@ -386,4 +391,3 @@ void assert_failed(uint8_t *file, uint32_t line)
/* USER CODE END 6 */
}
#endif /* USE_FULL_ASSERT */

View File

@@ -20,6 +20,7 @@
/* Includes ------------------------------------------------------------------*/
#include "main.h"
/* USER CODE BEGIN Includes */
/* USER CODE END Includes */
@@ -314,4 +315,3 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */

View File

@@ -203,4 +203,3 @@ void USART1_IRQHandler(void)
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */