mirror of
https://gitea.ecohim.ru:3000/RS485_Relay/RS485_Relay2_fw.git
synced 2025-08-06 16:07:17 +03:00
Merge branch 'V2R1-board'
This commit is contained in:
2
.project
2
.project
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<projectDescription>
|
<projectDescription>
|
||||||
<name>Relay_RS485</name>
|
<name>Relay_RS485_V2</name>
|
||||||
<comment></comment>
|
<comment></comment>
|
||||||
<projects>
|
<projects>
|
||||||
</projects>
|
</projects>
|
||||||
|
@@ -6,17 +6,24 @@
|
|||||||
#ifndef BOARD_LOGIC_H_
|
#ifndef BOARD_LOGIC_H_
|
||||||
#define BOARD_LOGIC_H_
|
#define BOARD_LOGIC_H_
|
||||||
|
|
||||||
#define MODBUS_FIRMWARE_VERSION ( /*major*/ 10 + /*minor*/ 1 * 0x100)
|
#define MODBUS_FIRMWARE_VERSION ( /*major*/ 11 + /*minor*/ 0 * 0x100)
|
||||||
#define MODBUS_BOARD_TYPE (8) //Relay Module board ID
|
#define MODBUS_BOARD_TYPE (8) //Relay Module board ID
|
||||||
|
|
||||||
#define REL_MAIN_BIT (1u<<0)
|
#define REL_MAIN_BIT (1u<<0)
|
||||||
#define REL_AUX_BIT (1u<<1)
|
#define REL_AUX_BIT (1u<<1)
|
||||||
|
|
||||||
#define MOTOR_MIN 0
|
#define PWM_DUTY_MIN 0
|
||||||
#define MOTOR_MAX 255
|
#define PWM_DUTY_MAX 255
|
||||||
|
#define PWM_LIGHTS_STEP 20 // Time step in ms between LED light PWM updates
|
||||||
|
#define LIGHTS_TIME 600 // Time in ms to spend for smooth lights level change
|
||||||
|
|
||||||
|
|
||||||
|
void estop_reset(void);
|
||||||
|
void board_init(void);
|
||||||
|
uint16_t clamp_duty(uint16_t duty);
|
||||||
|
void set_pwm(uint8_t unit, uint16_t duty);
|
||||||
|
void set_light(uint16_t duty);
|
||||||
void loop_iterate();
|
void loop_iterate();
|
||||||
void timer1_ovf_isr(void);
|
void update_service_indication(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -59,6 +59,16 @@ void Error_Handler(void);
|
|||||||
/* USER CODE END EFP */
|
/* USER CODE END EFP */
|
||||||
|
|
||||||
/* Private defines -----------------------------------------------------------*/
|
/* Private defines -----------------------------------------------------------*/
|
||||||
|
#define WATER_Pin GPIO_PIN_0
|
||||||
|
#define WATER_GPIO_Port GPIOA
|
||||||
|
#define WATER_EXTI_IRQn EXTI0_1_IRQn
|
||||||
|
#define ESTOP_Pin GPIO_PIN_1
|
||||||
|
#define ESTOP_GPIO_Port GPIOA
|
||||||
|
#define ESTOP_EXTI_IRQn EXTI0_1_IRQn
|
||||||
|
#define LIGHTS_Pin GPIO_PIN_4
|
||||||
|
#define LIGHTS_GPIO_Port GPIOA
|
||||||
|
#define RL_EN_Pin GPIO_PIN_5
|
||||||
|
#define RL_EN_GPIO_Port GPIOA
|
||||||
#define LED_AUX_Pin GPIO_PIN_6
|
#define LED_AUX_Pin GPIO_PIN_6
|
||||||
#define LED_AUX_GPIO_Port GPIOA
|
#define LED_AUX_GPIO_Port GPIOA
|
||||||
#define LED_MAIN_Pin GPIO_PIN_7
|
#define LED_MAIN_Pin GPIO_PIN_7
|
||||||
@@ -67,6 +77,9 @@ void Error_Handler(void);
|
|||||||
#define LED_ERR_GPIO_Port GPIOB
|
#define LED_ERR_GPIO_Port GPIOB
|
||||||
#define LED_ACT_Pin GPIO_PIN_1
|
#define LED_ACT_Pin GPIO_PIN_1
|
||||||
#define LED_ACT_GPIO_Port GPIOB
|
#define LED_ACT_GPIO_Port GPIOB
|
||||||
|
#define LIGHTS_SW_Pin GPIO_PIN_8
|
||||||
|
#define LIGHTS_SW_GPIO_Port GPIOA
|
||||||
|
#define LIGHTS_SW_EXTI_IRQn EXTI4_15_IRQn
|
||||||
#define TXEN_Pin GPIO_PIN_11
|
#define TXEN_Pin GPIO_PIN_11
|
||||||
#define TXEN_GPIO_Port GPIOA
|
#define TXEN_GPIO_Port GPIOA
|
||||||
#define RL_AUX_Pin GPIO_PIN_15
|
#define RL_AUX_Pin GPIO_PIN_15
|
||||||
|
@@ -51,6 +51,8 @@ void HardFault_Handler(void);
|
|||||||
void SVC_Handler(void);
|
void SVC_Handler(void);
|
||||||
void PendSV_Handler(void);
|
void PendSV_Handler(void);
|
||||||
void SysTick_Handler(void);
|
void SysTick_Handler(void);
|
||||||
|
void EXTI0_1_IRQHandler(void);
|
||||||
|
void EXTI4_15_IRQHandler(void);
|
||||||
void DMA1_Channel2_3_IRQHandler(void);
|
void DMA1_Channel2_3_IRQHandler(void);
|
||||||
void TIM1_BRK_UP_TRG_COM_IRQHandler(void);
|
void TIM1_BRK_UP_TRG_COM_IRQHandler(void);
|
||||||
void TIM1_CC_IRQHandler(void);
|
void TIM1_CC_IRQHandler(void);
|
||||||
|
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "modbus_logic.h"
|
#include "modbus_logic.h"
|
||||||
@@ -12,10 +13,11 @@
|
|||||||
|
|
||||||
#define BOARD_DESC_LEN (16)
|
#define BOARD_DESC_LEN (16)
|
||||||
|
|
||||||
|
extern TIM_HandleTypeDef htim1;
|
||||||
extern TIM_HandleTypeDef htim3;
|
extern TIM_HandleTypeDef htim3;
|
||||||
static const char board_description[BOARD_DESC_LEN] = "RS485_Relay V1R1";
|
extern TIM_HandleTypeDef htim14;
|
||||||
|
static const char board_description[BOARD_DESC_LEN] = "RS485_Relay V2R1";
|
||||||
extern uint16_t tranfer_errors_count;
|
extern uint16_t tranfer_errors_count;
|
||||||
extern uint16_t last_rx_time;
|
|
||||||
|
|
||||||
#define REL_MAIN_ON HAL_GPIO_WritePin(RL_MAIN_GPIO_Port, RL_MAIN_Pin, GPIO_PIN_SET)
|
#define REL_MAIN_ON HAL_GPIO_WritePin(RL_MAIN_GPIO_Port, RL_MAIN_Pin, GPIO_PIN_SET)
|
||||||
#define REL_MAIN_OFF HAL_GPIO_WritePin(RL_MAIN_GPIO_Port, RL_MAIN_Pin, GPIO_PIN_RESET)
|
#define REL_MAIN_OFF HAL_GPIO_WritePin(RL_MAIN_GPIO_Port, RL_MAIN_Pin, GPIO_PIN_RESET)
|
||||||
@@ -28,11 +30,82 @@ extern uint16_t last_rx_time;
|
|||||||
#define LED_ACT_ON HAL_GPIO_WritePin(LED_ACT_GPIO_Port, LED_ACT_Pin, GPIO_PIN_SET)
|
#define LED_ACT_ON HAL_GPIO_WritePin(LED_ACT_GPIO_Port, LED_ACT_Pin, GPIO_PIN_SET)
|
||||||
#define LED_ACT_OFF HAL_GPIO_WritePin(LED_ACT_GPIO_Port, LED_ACT_Pin, GPIO_PIN_RESET)
|
#define LED_ACT_OFF HAL_GPIO_WritePin(LED_ACT_GPIO_Port, LED_ACT_Pin, GPIO_PIN_RESET)
|
||||||
|
|
||||||
uint16_t relays=0;
|
|
||||||
uint16_t motor_pwm=0;
|
|
||||||
uint16_t led_time_act=0;
|
|
||||||
|
|
||||||
void update_service_indication(void);
|
uint16_t relays = 0;
|
||||||
|
uint16_t status = 0;
|
||||||
|
uint16_t motor1_pwm = 0;
|
||||||
|
uint16_t motor2_pwm = 0;
|
||||||
|
uint16_t lights_pwm = 0;
|
||||||
|
uint16_t lights_pwm_target = 0;
|
||||||
|
int16_t lights_pwm_delta = 0;
|
||||||
|
uint16_t led_time_act = 0;
|
||||||
|
|
||||||
|
void estop_reset(void) {
|
||||||
|
HAL_GPIO_WritePin(RL_EN_GPIO_Port, RL_EN_Pin, GPIO_PIN_RESET);
|
||||||
|
HAL_Delay(1);
|
||||||
|
HAL_GPIO_WritePin(RL_EN_GPIO_Port, RL_EN_Pin, GPIO_PIN_SET);
|
||||||
|
}
|
||||||
|
|
||||||
|
void board_init(void) {
|
||||||
|
// Activate (normalize) E-STOP trigger
|
||||||
|
estop_reset();
|
||||||
|
|
||||||
|
// Check if E-STOP is not shorted
|
||||||
|
if (HAL_GPIO_ReadPin(ESTOP_GPIO_Port, ESTOP_Pin) == GPIO_PIN_RESET)
|
||||||
|
status = status | 0b010;
|
||||||
|
|
||||||
|
// 1ms timer start
|
||||||
|
HAL_TIM_Base_Start_IT(&htim1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint16_t clamp_duty(uint16_t duty) {
|
||||||
|
if (duty > PWM_DUTY_MAX) return PWM_DUTY_MAX;
|
||||||
|
if (duty < PWM_DUTY_MIN) return PWM_DUTY_MIN;
|
||||||
|
return duty;
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_pwm(uint8_t unit, uint16_t duty) {
|
||||||
|
uint32_t channel;
|
||||||
|
TIM_HandleTypeDef* tim;
|
||||||
|
|
||||||
|
switch (unit) {
|
||||||
|
case 1: // motor 1
|
||||||
|
tim = &htim3;
|
||||||
|
channel = TIM_CHANNEL_1;
|
||||||
|
break;
|
||||||
|
case 2: // motor 2
|
||||||
|
tim = &htim3;
|
||||||
|
channel = TIM_CHANNEL_2;
|
||||||
|
break;
|
||||||
|
case 3: // lights
|
||||||
|
tim = &htim14;
|
||||||
|
channel = TIM_CHANNEL_1;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
duty = clamp_duty(duty);
|
||||||
|
if (duty == 0)
|
||||||
|
HAL_TIM_PWM_Stop(tim, channel);
|
||||||
|
else {
|
||||||
|
HAL_TIM_PWM_Start(tim, channel);
|
||||||
|
__HAL_TIM_SetCompare(tim, channel, duty);
|
||||||
|
HAL_Delay(5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_light(uint16_t duty) {
|
||||||
|
lights_pwm_target = clamp_duty(duty);
|
||||||
|
if (lights_pwm_target != lights_pwm) {
|
||||||
|
lights_pwm_delta = (lights_pwm_target - lights_pwm) / (LIGHTS_TIME / PWM_LIGHTS_STEP);
|
||||||
|
if (lights_pwm_delta == 0) {
|
||||||
|
if (lights_pwm_target - lights_pwm > 0) lights_pwm_delta = 1;
|
||||||
|
else lights_pwm_delta = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void loop_iterate()
|
void loop_iterate()
|
||||||
{
|
{
|
||||||
@@ -64,40 +137,15 @@ void loop_iterate()
|
|||||||
HAL_Delay(1);
|
HAL_Delay(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Timer1 overflow interrupt service routine
|
|
||||||
void timer1_ovf_isr(void) //1 ms
|
|
||||||
{
|
|
||||||
static uint32_t count_1sec=0;
|
|
||||||
if(last_rx_time<0xFFFF)last_rx_time++;
|
|
||||||
|
|
||||||
update_service_indication();
|
|
||||||
|
|
||||||
if(++count_1sec==1000)
|
|
||||||
{
|
|
||||||
count_1sec = 0;
|
|
||||||
//led_time_g += 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void update_service_indication(void)
|
void update_service_indication(void)
|
||||||
{
|
{
|
||||||
if(led_time_act)
|
if (led_time_act) {
|
||||||
{
|
|
||||||
LED_ACT_ON;
|
LED_ACT_ON;
|
||||||
led_time_act--;
|
led_time_act--;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
LED_ACT_OFF;
|
LED_ACT_OFF;
|
||||||
/*
|
|
||||||
if(led_time_g)
|
|
||||||
{
|
|
||||||
LED_G_ON;
|
|
||||||
led_time_g--;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
LED_G_OFF;
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -125,9 +173,22 @@ uint8_t read_register(uint16_t address, uint16_t* value)
|
|||||||
{
|
{
|
||||||
*value = relays;
|
*value = relays;
|
||||||
}
|
}
|
||||||
else if (address == 0x2002) //Read motor pwm
|
else if (address == 0x2002) //Read motor 1 pwm
|
||||||
{
|
{
|
||||||
*value = motor_pwm;
|
*value = motor1_pwm;
|
||||||
|
}
|
||||||
|
else if (address == 0x2003) //Read motor 2 pwm
|
||||||
|
{
|
||||||
|
*value = motor2_pwm;
|
||||||
|
}
|
||||||
|
else if (address == 0x2004) //Read Lights pwm
|
||||||
|
{
|
||||||
|
*value = lights_pwm;
|
||||||
|
}
|
||||||
|
else if (address == 0x2010) //Read status
|
||||||
|
{
|
||||||
|
*value = status;
|
||||||
|
status &= 0b011; // Reset light button press event status
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return 1;
|
return 1;
|
||||||
@@ -137,24 +198,30 @@ uint8_t read_register(uint16_t address, uint16_t* value)
|
|||||||
uint8_t write_register(uint16_t address, uint16_t value)
|
uint8_t write_register(uint16_t address, uint16_t value)
|
||||||
{
|
{
|
||||||
uint8_t ret;
|
uint8_t ret;
|
||||||
ret=0;
|
ret = 0;
|
||||||
#ifdef UART_DEBUG
|
#ifdef UART_DEBUG
|
||||||
printf("Write A=0x%X D=0x%X\n\r",address,value);
|
printf("Write A=0x%X D=0x%X\n\r",address,value);
|
||||||
#endif
|
#endif
|
||||||
switch (address) {
|
switch (address) {
|
||||||
case 0x2001:
|
case 0x2001:
|
||||||
|
if (status & 0b010) break; // Check if we are in emergency stop mode
|
||||||
relays = value;
|
relays = value;
|
||||||
break;
|
break;
|
||||||
case 0x2002:
|
case 0x2002:
|
||||||
motor_pwm = value;
|
motor1_pwm = value;
|
||||||
if(motor_pwm>MOTOR_MAX)motor_pwm=MOTOR_MAX;
|
set_pwm(1, motor1_pwm);
|
||||||
if(motor_pwm<MOTOR_MIN)motor_pwm=MOTOR_MIN;
|
break;
|
||||||
if(motor_pwm==0)
|
case 0x2003:
|
||||||
HAL_TIM_PWM_Stop(&htim3, TIM_CHANNEL_1);
|
motor2_pwm = value;
|
||||||
else {
|
set_pwm(2, motor2_pwm);
|
||||||
HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_1);
|
break;
|
||||||
__HAL_TIM_SetCompare(&htim3, TIM_CHANNEL_1, motor_pwm);
|
case 0x2004:
|
||||||
HAL_Delay(5);
|
set_light(value);
|
||||||
|
break;
|
||||||
|
case 0x2020:
|
||||||
|
if (value == 1) {
|
||||||
|
estop_reset();
|
||||||
|
status &= 0b101;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -163,3 +230,47 @@ uint8_t write_register(uint16_t address, uint16_t value)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Pin external interrupts handler
|
||||||
|
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
|
||||||
|
{
|
||||||
|
if(GPIO_Pin == ESTOP_Pin) {
|
||||||
|
status = status | 0b010;
|
||||||
|
relays = 0;
|
||||||
|
}
|
||||||
|
if(GPIO_Pin == LIGHTS_SW_Pin) {
|
||||||
|
// Set "lights switch pressed" status bit
|
||||||
|
status |= 0b100;
|
||||||
|
if (lights_pwm_target > 0) set_light(0);
|
||||||
|
else set_light(255);
|
||||||
|
}
|
||||||
|
if(GPIO_Pin == WATER_Pin) {
|
||||||
|
// Set or reset "water" status bit
|
||||||
|
status |= HAL_GPIO_ReadPin(WATER_GPIO_Port, WATER_Pin);
|
||||||
|
if (HAL_GPIO_ReadPin(WATER_GPIO_Port, WATER_Pin)) status |= 1;
|
||||||
|
else status &= ~1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Timers overflow interrupt
|
||||||
|
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) {
|
||||||
|
// check if the interrupt comes from TIM1
|
||||||
|
if(htim->Instance == TIM1) {
|
||||||
|
static uint32_t count_ms = 0;
|
||||||
|
|
||||||
|
update_service_indication();
|
||||||
|
|
||||||
|
// Check if we should change lights pwm for smooth transition
|
||||||
|
if (lights_pwm != lights_pwm_target) {
|
||||||
|
// Change pwm only every 20ms (PWM_LIGHTS_STEP)
|
||||||
|
if(++count_ms == PWM_LIGHTS_STEP) {
|
||||||
|
count_ms = 0;
|
||||||
|
|
||||||
|
lights_pwm += lights_pwm_delta;
|
||||||
|
// Set lights pwm to target if the difference is less than the delta
|
||||||
|
if (abs(lights_pwm_target - lights_pwm) < abs(lights_pwm_delta))
|
||||||
|
lights_pwm = lights_pwm_target;
|
||||||
|
set_pwm(3, lights_pwm);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -45,6 +45,7 @@
|
|||||||
/* Private variables ---------------------------------------------------------*/
|
/* Private variables ---------------------------------------------------------*/
|
||||||
TIM_HandleTypeDef htim1;
|
TIM_HandleTypeDef htim1;
|
||||||
TIM_HandleTypeDef htim3;
|
TIM_HandleTypeDef htim3;
|
||||||
|
TIM_HandleTypeDef htim14;
|
||||||
|
|
||||||
UART_HandleTypeDef huart1;
|
UART_HandleTypeDef huart1;
|
||||||
DMA_HandleTypeDef hdma_usart1_rx;
|
DMA_HandleTypeDef hdma_usart1_rx;
|
||||||
@@ -61,6 +62,7 @@ static void MX_DMA_Init(void);
|
|||||||
static void MX_TIM3_Init(void);
|
static void MX_TIM3_Init(void);
|
||||||
static void MX_USART1_UART_Init(void);
|
static void MX_USART1_UART_Init(void);
|
||||||
static void MX_TIM1_Init(void);
|
static void MX_TIM1_Init(void);
|
||||||
|
static void MX_TIM14_Init(void);
|
||||||
/* USER CODE BEGIN PFP */
|
/* USER CODE BEGIN PFP */
|
||||||
|
|
||||||
/* USER CODE END PFP */
|
/* USER CODE END PFP */
|
||||||
@@ -102,8 +104,9 @@ int main(void)
|
|||||||
MX_TIM3_Init();
|
MX_TIM3_Init();
|
||||||
MX_USART1_UART_Init();
|
MX_USART1_UART_Init();
|
||||||
MX_TIM1_Init();
|
MX_TIM1_Init();
|
||||||
|
MX_TIM14_Init();
|
||||||
/* USER CODE BEGIN 2 */
|
/* USER CODE BEGIN 2 */
|
||||||
HAL_TIM_Base_Start_IT(&htim1);
|
board_init();
|
||||||
|
|
||||||
/* USER CODE END 2 */
|
/* USER CODE END 2 */
|
||||||
|
|
||||||
@@ -183,9 +186,9 @@ static void MX_TIM1_Init(void)
|
|||||||
|
|
||||||
/* USER CODE END TIM1_Init 1 */
|
/* USER CODE END TIM1_Init 1 */
|
||||||
htim1.Instance = TIM1;
|
htim1.Instance = TIM1;
|
||||||
htim1.Init.Prescaler = 479;
|
htim1.Init.Prescaler = 480-1;
|
||||||
htim1.Init.CounterMode = TIM_COUNTERMODE_UP;
|
htim1.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||||
htim1.Init.Period = 100;
|
htim1.Init.Period = 100-1;
|
||||||
htim1.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
htim1.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||||
htim1.Init.RepetitionCounter = 0;
|
htim1.Init.RepetitionCounter = 0;
|
||||||
htim1.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
|
htim1.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
|
||||||
@@ -229,7 +232,7 @@ static void MX_TIM3_Init(void)
|
|||||||
|
|
||||||
/* USER CODE END TIM3_Init 1 */
|
/* USER CODE END TIM3_Init 1 */
|
||||||
htim3.Instance = TIM3;
|
htim3.Instance = TIM3;
|
||||||
htim3.Init.Prescaler = 239;
|
htim3.Init.Prescaler = 240-1;
|
||||||
htim3.Init.CounterMode = TIM_COUNTERMODE_UP;
|
htim3.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||||
htim3.Init.Period = 255;
|
htim3.Init.Period = 255;
|
||||||
htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||||
@@ -252,6 +255,10 @@ static void MX_TIM3_Init(void)
|
|||||||
{
|
{
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
}
|
}
|
||||||
|
if (HAL_TIM_PWM_ConfigChannel(&htim3, &sConfigOC, TIM_CHANNEL_2) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
/* USER CODE BEGIN TIM3_Init 2 */
|
/* USER CODE BEGIN TIM3_Init 2 */
|
||||||
|
|
||||||
/* USER CODE END TIM3_Init 2 */
|
/* USER CODE END TIM3_Init 2 */
|
||||||
@@ -259,6 +266,52 @@ static void MX_TIM3_Init(void)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TIM14 Initialization Function
|
||||||
|
* @param None
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
static void MX_TIM14_Init(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
/* USER CODE BEGIN TIM14_Init 0 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM14_Init 0 */
|
||||||
|
|
||||||
|
TIM_OC_InitTypeDef sConfigOC = {0};
|
||||||
|
|
||||||
|
/* USER CODE BEGIN TIM14_Init 1 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM14_Init 1 */
|
||||||
|
htim14.Instance = TIM14;
|
||||||
|
htim14.Init.Prescaler = 6-1;
|
||||||
|
htim14.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||||
|
htim14.Init.Period = 255;
|
||||||
|
htim14.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||||
|
htim14.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
|
||||||
|
if (HAL_TIM_Base_Init(&htim14) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
if (HAL_TIM_PWM_Init(&htim14) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
sConfigOC.OCMode = TIM_OCMODE_PWM1;
|
||||||
|
sConfigOC.Pulse = 0;
|
||||||
|
sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
|
||||||
|
sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
|
||||||
|
if (HAL_TIM_PWM_ConfigChannel(&htim14, &sConfigOC, TIM_CHANNEL_1) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
/* USER CODE BEGIN TIM14_Init 2 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM14_Init 2 */
|
||||||
|
HAL_TIM_MspPostInit(&htim14);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USART1 Initialization Function
|
* @brief USART1 Initialization Function
|
||||||
* @param None
|
* @param None
|
||||||
@@ -326,14 +379,31 @@ static void MX_GPIO_Init(void)
|
|||||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||||
|
|
||||||
|
/*Configure GPIO pin Output Level */
|
||||||
|
HAL_GPIO_WritePin(RL_EN_GPIO_Port, RL_EN_Pin, GPIO_PIN_SET);
|
||||||
|
|
||||||
/*Configure GPIO pin Output Level */
|
/*Configure GPIO pin Output Level */
|
||||||
HAL_GPIO_WritePin(GPIOA, LED_AUX_Pin|LED_MAIN_Pin|TXEN_Pin|RL_AUX_Pin, GPIO_PIN_RESET);
|
HAL_GPIO_WritePin(GPIOA, LED_AUX_Pin|LED_MAIN_Pin|TXEN_Pin|RL_AUX_Pin, GPIO_PIN_RESET);
|
||||||
|
|
||||||
/*Configure GPIO pin Output Level */
|
/*Configure GPIO pin Output Level */
|
||||||
HAL_GPIO_WritePin(GPIOB, LED_ERR_Pin|LED_ACT_Pin|RL_MAIN_Pin, GPIO_PIN_RESET);
|
HAL_GPIO_WritePin(GPIOB, LED_ERR_Pin|LED_ACT_Pin|RL_MAIN_Pin, GPIO_PIN_RESET);
|
||||||
|
|
||||||
/*Configure GPIO pins : LED_AUX_Pin LED_MAIN_Pin TXEN_Pin RL_AUX_Pin */
|
/*Configure GPIO pin : WATER_Pin */
|
||||||
GPIO_InitStruct.Pin = LED_AUX_Pin|LED_MAIN_Pin|TXEN_Pin|RL_AUX_Pin;
|
GPIO_InitStruct.Pin = WATER_Pin;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
HAL_GPIO_Init(WATER_GPIO_Port, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
/*Configure GPIO pins : ESTOP_Pin LIGHTS_SW_Pin */
|
||||||
|
GPIO_InitStruct.Pin = ESTOP_Pin|LIGHTS_SW_Pin;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
/*Configure GPIO pins : RL_EN_Pin LED_AUX_Pin LED_MAIN_Pin TXEN_Pin
|
||||||
|
RL_AUX_Pin */
|
||||||
|
GPIO_InitStruct.Pin = RL_EN_Pin|LED_AUX_Pin|LED_MAIN_Pin|TXEN_Pin
|
||||||
|
|RL_AUX_Pin;
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||||
@@ -346,18 +416,19 @@ static void MX_GPIO_Init(void)
|
|||||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
/* EXTI interrupt init*/
|
||||||
|
HAL_NVIC_SetPriority(EXTI0_1_IRQn, 0, 0);
|
||||||
|
HAL_NVIC_EnableIRQ(EXTI0_1_IRQn);
|
||||||
|
|
||||||
|
HAL_NVIC_SetPriority(EXTI4_15_IRQn, 0, 0);
|
||||||
|
HAL_NVIC_EnableIRQ(EXTI4_15_IRQn);
|
||||||
|
|
||||||
/* USER CODE BEGIN MX_GPIO_Init_2 */
|
/* USER CODE BEGIN MX_GPIO_Init_2 */
|
||||||
/* USER CODE END MX_GPIO_Init_2 */
|
/* USER CODE END MX_GPIO_Init_2 */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* USER CODE BEGIN 4 */
|
/* USER CODE BEGIN 4 */
|
||||||
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
|
|
||||||
{
|
|
||||||
if(htim->Instance == TIM1) //check if the interrupt comes from TIM1
|
|
||||||
{
|
|
||||||
timer1_ovf_isr();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* USER CODE END 4 */
|
/* USER CODE END 4 */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -15,7 +15,7 @@ uint8_t recv_buffer[BUFFERS_SIZE];
|
|||||||
uint8_t send_buffer[BUFFERS_SIZE];
|
uint8_t send_buffer[BUFFERS_SIZE];
|
||||||
|
|
||||||
uint16_t bytes_to_send = 0;
|
uint16_t bytes_to_send = 0;
|
||||||
uint16_t last_rx_time = 0xFFFF;
|
//uint16_t last_rx_time = 0xFFFF;
|
||||||
enum recv_state cmd_receiving = RECV_IDLE;
|
enum recv_state cmd_receiving = RECV_IDLE;
|
||||||
enum send_state cmd_sending = SEND_IDLE;
|
enum send_state cmd_sending = SEND_IDLE;
|
||||||
uint16_t tranfer_errors_count;
|
uint16_t tranfer_errors_count;
|
||||||
@@ -79,14 +79,7 @@ void modbus_loop_iterate()
|
|||||||
{
|
{
|
||||||
if (cmd_receiving == RECV_ERROR)
|
if (cmd_receiving == RECV_ERROR)
|
||||||
{
|
{
|
||||||
// poor man's way to synchronize packets
|
cmd_receiving = RECV_IDLE;
|
||||||
//if(last_rx_time>=BUS_IDLE_TIME)
|
|
||||||
//{
|
|
||||||
cmd_receiving = RECV_IDLE;
|
|
||||||
//TXEN_485 = 1;
|
|
||||||
//delay_us(10);
|
|
||||||
//TXEN_485 = 0;
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
if (cmd_receiving == RECV_IDLE)
|
if (cmd_receiving == RECV_IDLE)
|
||||||
{
|
{
|
||||||
|
@@ -63,7 +63,7 @@ extern DMA_HandleTypeDef hdma_usart1_tx;
|
|||||||
/* USER CODE END 0 */
|
/* USER CODE END 0 */
|
||||||
|
|
||||||
void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim);
|
void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim);
|
||||||
/**
|
/**
|
||||||
* Initializes the Global MSP.
|
* Initializes the Global MSP.
|
||||||
*/
|
*/
|
||||||
void HAL_MspInit(void)
|
void HAL_MspInit(void)
|
||||||
@@ -106,6 +106,17 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base)
|
|||||||
|
|
||||||
/* USER CODE END TIM1_MspInit 1 */
|
/* USER CODE END TIM1_MspInit 1 */
|
||||||
}
|
}
|
||||||
|
else if(htim_base->Instance==TIM14)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN TIM14_MspInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM14_MspInit 0 */
|
||||||
|
/* Peripheral clock enable */
|
||||||
|
__HAL_RCC_TIM14_CLK_ENABLE();
|
||||||
|
/* USER CODE BEGIN TIM14_MspInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM14_MspInit 1 */
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,12 +150,12 @@ void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim)
|
|||||||
/* USER CODE BEGIN TIM3_MspPostInit 0 */
|
/* USER CODE BEGIN TIM3_MspPostInit 0 */
|
||||||
|
|
||||||
/* USER CODE END TIM3_MspPostInit 0 */
|
/* USER CODE END TIM3_MspPostInit 0 */
|
||||||
|
|
||||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||||
/**TIM3 GPIO Configuration
|
/**TIM3 GPIO Configuration
|
||||||
PB4 ------> TIM3_CH1
|
PB4 ------> TIM3_CH1
|
||||||
|
PB5 ------> TIM3_CH2
|
||||||
*/
|
*/
|
||||||
GPIO_InitStruct.Pin = GPIO_PIN_4;
|
GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5;
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||||
@@ -155,6 +166,27 @@ void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim)
|
|||||||
|
|
||||||
/* USER CODE END TIM3_MspPostInit 1 */
|
/* USER CODE END TIM3_MspPostInit 1 */
|
||||||
}
|
}
|
||||||
|
else if(htim->Instance==TIM14)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN TIM14_MspPostInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM14_MspPostInit 0 */
|
||||||
|
|
||||||
|
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||||
|
/**TIM14 GPIO Configuration
|
||||||
|
PA4 ------> TIM14_CH1
|
||||||
|
*/
|
||||||
|
GPIO_InitStruct.Pin = LIGHTS_Pin;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||||
|
GPIO_InitStruct.Alternate = GPIO_AF4_TIM14;
|
||||||
|
HAL_GPIO_Init(LIGHTS_GPIO_Port, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
/* USER CODE BEGIN TIM14_MspPostInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM14_MspPostInit 1 */
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -180,6 +212,17 @@ void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base)
|
|||||||
|
|
||||||
/* USER CODE END TIM1_MspDeInit 1 */
|
/* USER CODE END TIM1_MspDeInit 1 */
|
||||||
}
|
}
|
||||||
|
else if(htim_base->Instance==TIM14)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN TIM14_MspDeInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM14_MspDeInit 0 */
|
||||||
|
/* Peripheral clock disable */
|
||||||
|
__HAL_RCC_TIM14_CLK_DISABLE();
|
||||||
|
/* USER CODE BEGIN TIM14_MspDeInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM14_MspDeInit 1 */
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -143,6 +143,35 @@ void SysTick_Handler(void)
|
|||||||
/* please refer to the startup file (startup_stm32f0xx.s). */
|
/* please refer to the startup file (startup_stm32f0xx.s). */
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function handles EXTI line 0 and 1 interrupts.
|
||||||
|
*/
|
||||||
|
void EXTI0_1_IRQHandler(void)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN EXTI0_1_IRQn 0 */
|
||||||
|
|
||||||
|
/* USER CODE END EXTI0_1_IRQn 0 */
|
||||||
|
HAL_GPIO_EXTI_IRQHandler(WATER_Pin);
|
||||||
|
HAL_GPIO_EXTI_IRQHandler(ESTOP_Pin);
|
||||||
|
/* USER CODE BEGIN EXTI0_1_IRQn 1 */
|
||||||
|
|
||||||
|
/* USER CODE END EXTI0_1_IRQn 1 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function handles EXTI line 4 to 15 interrupts.
|
||||||
|
*/
|
||||||
|
void EXTI4_15_IRQHandler(void)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN EXTI4_15_IRQn 0 */
|
||||||
|
|
||||||
|
/* USER CODE END EXTI4_15_IRQn 0 */
|
||||||
|
HAL_GPIO_EXTI_IRQHandler(LIGHTS_SW_Pin);
|
||||||
|
/* USER CODE BEGIN EXTI4_15_IRQn 1 */
|
||||||
|
|
||||||
|
/* USER CODE END EXTI4_15_IRQn 1 */
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles DMA1 channel 2 and 3 interrupts.
|
* @brief This function handles DMA1 channel 2 and 3 interrupts.
|
||||||
*/
|
*/
|
||||||
|
82
Relay_RS485_V2 Debug.launch
Normal file
82
Relay_RS485_V2 Debug.launch
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<launchConfiguration type="com.st.stm32cube.ide.mcu.debug.launch.launchConfigurationType">
|
||||||
|
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.access_port_id" value="0"/>
|
||||||
|
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.cubeprog_external_loaders" value="[]"/>
|
||||||
|
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.debug_auth_certif_path" value=""/>
|
||||||
|
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.debug_auth_check_enable" value="false"/>
|
||||||
|
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.debug_auth_key_path" value=""/>
|
||||||
|
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.debug_auth_permission" value=""/>
|
||||||
|
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.enable_live_expr" value="true"/>
|
||||||
|
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.enable_swv" value="false"/>
|
||||||
|
<intAttribute key="com.st.stm32cube.ide.mcu.debug.launch.formatVersion" value="2"/>
|
||||||
|
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.ip_address_local" value="localhost"/>
|
||||||
|
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.limit_swo_clock.enabled" value="false"/>
|
||||||
|
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.limit_swo_clock.value" value=""/>
|
||||||
|
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.loadList" value="{"fItems":[{"fIsFromMainTab":true,"fPath":"Debug/Relay_RS485_V2.elf","fProjectName":"Relay_RS485_V2","fPerformBuild":true,"fDownload":true,"fLoadSymbols":true}]}"/>
|
||||||
|
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.override_start_address_mode" value="default"/>
|
||||||
|
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.remoteCommand" value="target remote"/>
|
||||||
|
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.startServer" value="true"/>
|
||||||
|
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.startuptab.exception.divby0" value="true"/>
|
||||||
|
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.startuptab.exception.unaligned" value="false"/>
|
||||||
|
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.startuptab.haltonexception" value="true"/>
|
||||||
|
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.swd_mode" value="true"/>
|
||||||
|
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.swv_port" value="61235"/>
|
||||||
|
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.swv_trace_hclk" value="48000000"/>
|
||||||
|
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.useRemoteTarget" value="true"/>
|
||||||
|
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.vector_table" value=""/>
|
||||||
|
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.verify_flash_download" value="true"/>
|
||||||
|
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.cti_allow_halt" value="false"/>
|
||||||
|
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.cti_signal_halt" value="false"/>
|
||||||
|
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.enable_logging" value="false"/>
|
||||||
|
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.enable_max_halt_delay" value="false"/>
|
||||||
|
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.enable_shared_stlink" value="false"/>
|
||||||
|
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.frequency" value="0"/>
|
||||||
|
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.halt_all_on_reset" value="false"/>
|
||||||
|
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.log_file" value="D:\bitbucket\RS485_Relay\RS485_Relay2_fw\Debug\st-link_gdbserver_log.txt"/>
|
||||||
|
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.low_power_debug" value="enable"/>
|
||||||
|
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.max_halt_delay" value="2"/>
|
||||||
|
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.reset_strategy" value="connect_under_reset"/>
|
||||||
|
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.stlink_check_serial_number" value="false"/>
|
||||||
|
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.stlink_txt_serial_number" value=""/>
|
||||||
|
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.watchdog_config" value="none"/>
|
||||||
|
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlinkenable_rtos" value="false"/>
|
||||||
|
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlinkrestart_configurations" value="{"fVersion":1,"fItems":[{"fDisplayName":"Reset","fIsSuppressible":false,"fResetAttribute":"Software system reset","fResetStrategies":[{"fDisplayName":"Software system reset","fLaunchAttribute":"system_reset","fGdbCommands":["monitor reset\r\n"],"fCmdOptions":["-g"]},{"fDisplayName":"Hardware reset","fLaunchAttribute":"hardware_reset","fGdbCommands":["monitor reset hardware\r\n"],"fCmdOptions":["-g"]},{"fDisplayName":"Core reset","fLaunchAttribute":"core_reset","fGdbCommands":["monitor reset core\r\n"],"fCmdOptions":["-g"]},{"fDisplayName":"None","fLaunchAttribute":"no_reset","fGdbCommands":[],"fCmdOptions":["-g"]}],"fGdbCommandGroup":{"name":"Additional commands","commands":[]},"fStartApplication":true}]}"/>
|
||||||
|
<booleanAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.enableRtosProxy" value="false"/>
|
||||||
|
<stringAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyCustomProperties" value=""/>
|
||||||
|
<stringAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyDriver" value="threadx"/>
|
||||||
|
<booleanAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyDriverAuto" value="false"/>
|
||||||
|
<stringAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyDriverPort" value="cortex_m0"/>
|
||||||
|
<intAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyPort" value="60000"/>
|
||||||
|
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.doHalt" value="false"/>
|
||||||
|
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.doReset" value="false"/>
|
||||||
|
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.initCommands" value=""/>
|
||||||
|
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.ipAddress" value="localhost"/>
|
||||||
|
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.jtagDeviceId" value="com.st.stm32cube.ide.mcu.debug.stlink"/>
|
||||||
|
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.pcRegister" value=""/>
|
||||||
|
<intAttribute key="org.eclipse.cdt.debug.gdbjtag.core.portNumber" value="61234"/>
|
||||||
|
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.runCommands" value=""/>
|
||||||
|
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setPcRegister" value="false"/>
|
||||||
|
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setResume" value="true"/>
|
||||||
|
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setStopAt" value="true"/>
|
||||||
|
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.stopAt" value="main"/>
|
||||||
|
<stringAttribute key="org.eclipse.cdt.dsf.gdb.DEBUG_NAME" value="arm-none-eabi-gdb"/>
|
||||||
|
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.NON_STOP" value="false"/>
|
||||||
|
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.UPDATE_THREADLIST_ON_SUSPEND" value="false"/>
|
||||||
|
<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/>
|
||||||
|
<stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/>
|
||||||
|
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_START_MODE" value="remote"/>
|
||||||
|
<booleanAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN" value="true"/>
|
||||||
|
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN_SYMBOL" value="main"/>
|
||||||
|
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="Debug/Relay_RS485_V2.elf"/>
|
||||||
|
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="Relay_RS485_V2"/>
|
||||||
|
<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="true"/>
|
||||||
|
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.107351323"/>
|
||||||
|
<booleanAttribute key="org.eclipse.debug.core.ATTR_FORCE_SYSTEM_CONSOLE_ENCODING" value="false"/>
|
||||||
|
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||||
|
<listEntry value="/Relay_RS485_V2"/>
|
||||||
|
</listAttribute>
|
||||||
|
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||||
|
<listEntry value="4"/>
|
||||||
|
</listAttribute>
|
||||||
|
<stringAttribute key="process_factory_id" value="com.st.stm32cube.ide.mcu.debug.launch.HardwareDebugProcessFactory"/>
|
||||||
|
</launchConfiguration>
|
@@ -24,7 +24,7 @@ Dma.USART1_TX.1.PeriphInc=DMA_PINC_DISABLE
|
|||||||
Dma.USART1_TX.1.Priority=DMA_PRIORITY_LOW
|
Dma.USART1_TX.1.Priority=DMA_PRIORITY_LOW
|
||||||
Dma.USART1_TX.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority
|
Dma.USART1_TX.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority
|
||||||
File.Version=6
|
File.Version=6
|
||||||
GPIO.groupedBy=
|
GPIO.groupedBy=Group By Peripherals
|
||||||
KeepUserPlacement=false
|
KeepUserPlacement=false
|
||||||
Mcu.CPN=STM32F030K6T6
|
Mcu.CPN=STM32F030K6T6
|
||||||
Mcu.Family=STM32F0
|
Mcu.Family=STM32F0
|
||||||
@@ -34,33 +34,43 @@ Mcu.IP2=RCC
|
|||||||
Mcu.IP3=SYS
|
Mcu.IP3=SYS
|
||||||
Mcu.IP4=TIM1
|
Mcu.IP4=TIM1
|
||||||
Mcu.IP5=TIM3
|
Mcu.IP5=TIM3
|
||||||
Mcu.IP6=USART1
|
Mcu.IP6=TIM14
|
||||||
Mcu.IPNb=7
|
Mcu.IP7=USART1
|
||||||
|
Mcu.IPNb=8
|
||||||
Mcu.Name=STM32F030K6Tx
|
Mcu.Name=STM32F030K6Tx
|
||||||
Mcu.Package=LQFP32
|
Mcu.Package=LQFP32
|
||||||
Mcu.Pin0=PF0-OSC_IN
|
Mcu.Pin0=PF0-OSC_IN
|
||||||
Mcu.Pin1=PF1-OSC_OUT
|
Mcu.Pin1=PF1-OSC_OUT
|
||||||
Mcu.Pin10=PA14
|
Mcu.Pin10=PA8
|
||||||
Mcu.Pin11=PA15
|
Mcu.Pin11=PA9
|
||||||
Mcu.Pin12=PB3
|
Mcu.Pin12=PA10
|
||||||
Mcu.Pin13=PB4
|
Mcu.Pin13=PA11
|
||||||
Mcu.Pin14=VP_SYS_VS_Systick
|
Mcu.Pin14=PA13
|
||||||
Mcu.Pin15=VP_TIM1_VS_ClockSourceINT
|
Mcu.Pin15=PA14
|
||||||
Mcu.Pin2=PA6
|
Mcu.Pin16=PA15
|
||||||
Mcu.Pin3=PA7
|
Mcu.Pin17=PB3
|
||||||
Mcu.Pin4=PB0
|
Mcu.Pin18=PB4
|
||||||
Mcu.Pin5=PB1
|
Mcu.Pin19=PB5
|
||||||
Mcu.Pin6=PA9
|
Mcu.Pin2=PA0
|
||||||
Mcu.Pin7=PA10
|
Mcu.Pin20=VP_SYS_VS_Systick
|
||||||
Mcu.Pin8=PA11
|
Mcu.Pin21=VP_TIM1_VS_ClockSourceINT
|
||||||
Mcu.Pin9=PA13
|
Mcu.Pin22=VP_TIM14_VS_ClockSourceINT
|
||||||
Mcu.PinsNb=16
|
Mcu.Pin3=PA1
|
||||||
|
Mcu.Pin4=PA4
|
||||||
|
Mcu.Pin5=PA5
|
||||||
|
Mcu.Pin6=PA6
|
||||||
|
Mcu.Pin7=PA7
|
||||||
|
Mcu.Pin8=PB0
|
||||||
|
Mcu.Pin9=PB1
|
||||||
|
Mcu.PinsNb=23
|
||||||
Mcu.ThirdPartyNb=0
|
Mcu.ThirdPartyNb=0
|
||||||
Mcu.UserConstants=
|
Mcu.UserConstants=
|
||||||
Mcu.UserName=STM32F030K6Tx
|
Mcu.UserName=STM32F030K6Tx
|
||||||
MxCube.Version=6.9.2
|
MxCube.Version=6.10.0
|
||||||
MxDb.Version=DB.6.0.92
|
MxDb.Version=DB.6.0.100
|
||||||
NVIC.DMA1_Channel2_3_IRQn=true\:2\:0\:true\:false\:true\:false\:true\:true
|
NVIC.DMA1_Channel2_3_IRQn=true\:2\:0\:true\:false\:true\:false\:true\:true
|
||||||
|
NVIC.EXTI0_1_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
|
||||||
|
NVIC.EXTI4_15_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
|
||||||
NVIC.ForceEnableDMAVector=true
|
NVIC.ForceEnableDMAVector=true
|
||||||
NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||||
NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||||
@@ -70,6 +80,16 @@ NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:false
|
|||||||
NVIC.TIM1_BRK_UP_TRG_COM_IRQn=true\:3\:0\:true\:false\:true\:true\:true\:true
|
NVIC.TIM1_BRK_UP_TRG_COM_IRQn=true\:3\:0\:true\:false\:true\:true\:true\:true
|
||||||
NVIC.TIM1_CC_IRQn=true\:3\:0\:true\:false\:true\:true\:true\:true
|
NVIC.TIM1_CC_IRQn=true\:3\:0\:true\:false\:true\:true\:true\:true
|
||||||
NVIC.USART1_IRQn=true\:1\:0\:true\:false\:true\:true\:true\:true
|
NVIC.USART1_IRQn=true\:1\:0\:true\:false\:true\:true\:true\:true
|
||||||
|
PA0.GPIOParameters=GPIO_Label,GPIO_ModeDefaultEXTI
|
||||||
|
PA0.GPIO_Label=WATER
|
||||||
|
PA0.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING
|
||||||
|
PA0.Locked=true
|
||||||
|
PA0.Signal=GPXTI0
|
||||||
|
PA1.GPIOParameters=GPIO_Label,GPIO_ModeDefaultEXTI
|
||||||
|
PA1.GPIO_Label=ESTOP
|
||||||
|
PA1.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_FALLING
|
||||||
|
PA1.Locked=true
|
||||||
|
PA1.Signal=GPXTI1
|
||||||
PA10.Locked=true
|
PA10.Locked=true
|
||||||
PA10.Mode=Asynchronous
|
PA10.Mode=Asynchronous
|
||||||
PA10.Signal=USART1_RX
|
PA10.Signal=USART1_RX
|
||||||
@@ -85,6 +105,14 @@ PA15.GPIOParameters=GPIO_Label
|
|||||||
PA15.GPIO_Label=RL_AUX
|
PA15.GPIO_Label=RL_AUX
|
||||||
PA15.Locked=true
|
PA15.Locked=true
|
||||||
PA15.Signal=GPIO_Output
|
PA15.Signal=GPIO_Output
|
||||||
|
PA4.GPIOParameters=GPIO_Label
|
||||||
|
PA4.GPIO_Label=LIGHTS
|
||||||
|
PA4.Signal=S_TIM14_CH1
|
||||||
|
PA5.GPIOParameters=PinState,GPIO_Label
|
||||||
|
PA5.GPIO_Label=RL_EN
|
||||||
|
PA5.Locked=true
|
||||||
|
PA5.PinState=GPIO_PIN_SET
|
||||||
|
PA5.Signal=GPIO_Output
|
||||||
PA6.GPIOParameters=GPIO_Label
|
PA6.GPIOParameters=GPIO_Label
|
||||||
PA6.GPIO_Label=LED_AUX
|
PA6.GPIO_Label=LED_AUX
|
||||||
PA6.Locked=true
|
PA6.Locked=true
|
||||||
@@ -93,6 +121,11 @@ PA7.GPIOParameters=GPIO_Label
|
|||||||
PA7.GPIO_Label=LED_MAIN
|
PA7.GPIO_Label=LED_MAIN
|
||||||
PA7.Locked=true
|
PA7.Locked=true
|
||||||
PA7.Signal=GPIO_Output
|
PA7.Signal=GPIO_Output
|
||||||
|
PA8.GPIOParameters=GPIO_Label,GPIO_ModeDefaultEXTI
|
||||||
|
PA8.GPIO_Label=LIGHTS_SW
|
||||||
|
PA8.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_FALLING
|
||||||
|
PA8.Locked=true
|
||||||
|
PA8.Signal=GPXTI8
|
||||||
PA9.Locked=true
|
PA9.Locked=true
|
||||||
PA9.Mode=Asynchronous
|
PA9.Mode=Asynchronous
|
||||||
PA9.Signal=USART1_TX
|
PA9.Signal=USART1_TX
|
||||||
@@ -110,6 +143,7 @@ PB3.Locked=true
|
|||||||
PB3.Signal=GPIO_Output
|
PB3.Signal=GPIO_Output
|
||||||
PB4.Locked=true
|
PB4.Locked=true
|
||||||
PB4.Signal=S_TIM3_CH1
|
PB4.Signal=S_TIM3_CH1
|
||||||
|
PB5.Signal=S_TIM3_CH2
|
||||||
PF0-OSC_IN.Mode=HSE-External-Oscillator
|
PF0-OSC_IN.Mode=HSE-External-Oscillator
|
||||||
PF0-OSC_IN.Signal=RCC_OSC_IN
|
PF0-OSC_IN.Signal=RCC_OSC_IN
|
||||||
PF1-OSC_OUT.Mode=HSE-External-Oscillator
|
PF1-OSC_OUT.Mode=HSE-External-Oscillator
|
||||||
@@ -135,8 +169,8 @@ ProjectManager.MainLocation=Core/Src
|
|||||||
ProjectManager.NoMain=false
|
ProjectManager.NoMain=false
|
||||||
ProjectManager.PreviousToolchain=STM32CubeIDE
|
ProjectManager.PreviousToolchain=STM32CubeIDE
|
||||||
ProjectManager.ProjectBuild=false
|
ProjectManager.ProjectBuild=false
|
||||||
ProjectManager.ProjectFileName=Relay_RS485.ioc
|
ProjectManager.ProjectFileName=Relay_RS485_V2.ioc
|
||||||
ProjectManager.ProjectName=Relay_RS485
|
ProjectManager.ProjectName=Relay_RS485_V2
|
||||||
ProjectManager.ProjectStructure=
|
ProjectManager.ProjectStructure=
|
||||||
ProjectManager.RegisterCallBack=
|
ProjectManager.RegisterCallBack=
|
||||||
ProjectManager.StackSize=0x400
|
ProjectManager.StackSize=0x400
|
||||||
@@ -145,7 +179,7 @@ ProjectManager.ToolChainLocation=
|
|||||||
ProjectManager.UAScriptAfterPath=
|
ProjectManager.UAScriptAfterPath=
|
||||||
ProjectManager.UAScriptBeforePath=
|
ProjectManager.UAScriptBeforePath=
|
||||||
ProjectManager.UnderRoot=true
|
ProjectManager.UnderRoot=true
|
||||||
ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-false,3-MX_DMA_Init-DMA-false-HAL-true,4-MX_TIM3_Init-TIM3-false-HAL-true,5-MX_USART1_UART_Init-USART1-false-HAL-true,6-MX_TIM1_Init-TIM1-false-HAL-true
|
ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-false,3-MX_DMA_Init-DMA-false-HAL-true,4-MX_TIM3_Init-TIM3-false-HAL-true,5-MX_USART1_UART_Init-USART1-false-HAL-true,6-MX_TIM1_Init-TIM1-false-HAL-true,7-MX_TIM14_Init-TIM14-false-HAL-true
|
||||||
RCC.AHBFreq_Value=48000000
|
RCC.AHBFreq_Value=48000000
|
||||||
RCC.APB1Freq_Value=48000000
|
RCC.APB1Freq_Value=48000000
|
||||||
RCC.APB1TimFreq_Value=48000000
|
RCC.APB1TimFreq_Value=48000000
|
||||||
@@ -163,20 +197,38 @@ RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK
|
|||||||
RCC.TimSysFreq_Value=48000000
|
RCC.TimSysFreq_Value=48000000
|
||||||
RCC.USART1Freq_Value=48000000
|
RCC.USART1Freq_Value=48000000
|
||||||
RCC.VCOOutput2Freq_Value=8000000
|
RCC.VCOOutput2Freq_Value=8000000
|
||||||
|
SH.GPXTI0.0=GPIO_EXTI0
|
||||||
|
SH.GPXTI0.ConfNb=1
|
||||||
|
SH.GPXTI1.0=GPIO_EXTI1
|
||||||
|
SH.GPXTI1.ConfNb=1
|
||||||
|
SH.GPXTI8.0=GPIO_EXTI8
|
||||||
|
SH.GPXTI8.ConfNb=1
|
||||||
|
SH.S_TIM14_CH1.0=TIM14_CH1,PWM Generation1 CH1
|
||||||
|
SH.S_TIM14_CH1.ConfNb=1
|
||||||
SH.S_TIM3_CH1.0=TIM3_CH1,PWM Generation1 CH1
|
SH.S_TIM3_CH1.0=TIM3_CH1,PWM Generation1 CH1
|
||||||
SH.S_TIM3_CH1.ConfNb=1
|
SH.S_TIM3_CH1.ConfNb=1
|
||||||
|
SH.S_TIM3_CH2.0=TIM3_CH2,PWM Generation2 CH2
|
||||||
|
SH.S_TIM3_CH2.ConfNb=1
|
||||||
TIM1.IPParameters=Prescaler,Period
|
TIM1.IPParameters=Prescaler,Period
|
||||||
TIM1.Period=100
|
TIM1.Period=100-1
|
||||||
TIM1.Prescaler=479
|
TIM1.Prescaler=480-1
|
||||||
|
TIM14.Channel=TIM_CHANNEL_1
|
||||||
|
TIM14.IPParameters=Channel,Prescaler,Period,OCMode_PWM
|
||||||
|
TIM14.OCMode_PWM=TIM_OCMODE_PWM1
|
||||||
|
TIM14.Period=255
|
||||||
|
TIM14.Prescaler=6-1
|
||||||
TIM3.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1
|
TIM3.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1
|
||||||
TIM3.IPParameters=Channel-PWM Generation1 CH1,Prescaler,Period
|
TIM3.Channel-PWM\ Generation2\ CH2=TIM_CHANNEL_2
|
||||||
|
TIM3.IPParameters=Channel-PWM Generation1 CH1,Prescaler,Period,Channel-PWM Generation2 CH2
|
||||||
TIM3.Period=255
|
TIM3.Period=255
|
||||||
TIM3.Prescaler=239
|
TIM3.Prescaler=240-1
|
||||||
USART1.BaudRate=9600
|
USART1.BaudRate=9600
|
||||||
USART1.IPParameters=VirtualMode-Asynchronous,BaudRate
|
USART1.IPParameters=VirtualMode-Asynchronous,BaudRate
|
||||||
USART1.VirtualMode-Asynchronous=VM_ASYNC
|
USART1.VirtualMode-Asynchronous=VM_ASYNC
|
||||||
VP_SYS_VS_Systick.Mode=SysTick
|
VP_SYS_VS_Systick.Mode=SysTick
|
||||||
VP_SYS_VS_Systick.Signal=SYS_VS_Systick
|
VP_SYS_VS_Systick.Signal=SYS_VS_Systick
|
||||||
|
VP_TIM14_VS_ClockSourceINT.Mode=Enable_Timer
|
||||||
|
VP_TIM14_VS_ClockSourceINT.Signal=TIM14_VS_ClockSourceINT
|
||||||
VP_TIM1_VS_ClockSourceINT.Mode=Internal
|
VP_TIM1_VS_ClockSourceINT.Mode=Internal
|
||||||
VP_TIM1_VS_ClockSourceINT.Signal=TIM1_VS_ClockSourceINT
|
VP_TIM1_VS_ClockSourceINT.Signal=TIM1_VS_ClockSourceINT
|
||||||
board=custom
|
board=custom
|
12
V1-V2_HW_changes.txt
Normal file
12
V1-V2_HW_changes.txt
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
New in Relay_V2 MCU:
|
||||||
|
|
||||||
|
PA0 - INPUT - Water level (HIGH - we have water)
|
||||||
|
PA1 - INPUT - E-STOP button (HIGH - normal state. should be interrupt-driven on falling edge detection)
|
||||||
|
PA2 \
|
||||||
|
PA3 ---------- Test points TP4, TP5 (ADC / USART1 / GPIO)
|
||||||
|
PA4 - OUTPUT - LED Lights TIM14 CH1 PWM output
|
||||||
|
PA5 - OUTPUT - RL_EN. Sets E-STOP trigger to controllable state (resets to normal state). LOW to activate. Should be HIGH by default.
|
||||||
|
PA8 - INPUT - LED Lights switch
|
||||||
|
PB5 - OUTPUT - Second DC motor channel. TIM3 CH2 PWM
|
||||||
|
PB6 \
|
||||||
|
PB7 ---------- Test points TP1, TP2 (USART1, I2C1, GPIO)
|
Reference in New Issue
Block a user