Unofficial update by Zhironkin

This commit is contained in:
Pavel Volkov
2022-05-25 00:00:06 +03:00
parent e226faa454
commit fe0b46c130
8 changed files with 86 additions and 46 deletions

View File

@@ -12,6 +12,7 @@
#define BOARD_DESC_LEN (23)
extern TIM_HandleTypeDef htim3;
static const char board_description[BOARD_DESC_LEN] = "RS485 Relay Module v1";
extern uint16_t tranfer_errors_count;
extern uint16_t last_rx_time;
@@ -56,17 +57,9 @@ void loop_iterate()
REL_AUX_OFF;
LED_AUX_OFF;
}
/*
if(motor_pwm>MOTOR_MAX)motor_pwm=MOTOR_MAX;
if(motor_pwm<MOTOR_MIN)motor_pwm=MOTOR_MIN;
if(motor_pwm==0)
//TCCR1A&=~(1<<COM1B1);
else
{
//MOTOR_PWM = motor_pwm;
//TCCR1A|=(1<<COM1B1);
}
*/
/* */
modbus_loop_iterate();
HAL_Delay(1);
}
@@ -151,7 +144,18 @@ uint8_t write_register(uint16_t address, uint16_t value)
switch (address)
{
case 0x2001: relays = value; break;
case 0x2002: motor_pwm = 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;