feat: 移植 lwprintf

feat: 创建 can 发送接口
feat: 添加编码器读数接口
This commit is contained in:
2024-04-19 17:16:24 +08:00
parent f0cbc9f1d3
commit 8408ab1cf3
21 changed files with 2522 additions and 94 deletions

View File

@@ -6,6 +6,9 @@
#define DRV_ENABLE() gpio_bits_set(GPIOB, GPIO_PINS_15)
#define DRV_DISABLE() gpio_bits_reset(GPIOB, GPIO_PINS_15)
int16_t speed_m1;
int16_t speed_m2;
void by_motion_pwm_m1(int32_t pwm_duty)
{
pwm_duty = clip_s32(pwm_duty, -449, 449); // 不可以拉满哦
@@ -24,10 +27,23 @@ void by_motion_pwm_m2(int32_t pwm_duty)
tmr_channel_value_set(TMR1, TMR_SELECT_CHANNEL_2, pwm_duty);
}
int16_t by_motion_get_speed_m1(void)
{
speed_m1 = (int16_t)tmr_counter_value_get(TMR2);
tmr_counter_value_set(TMR2, 0);
return speed_m1;
}
int16_t by_motion_get_speed_m2(void)
{
speed_m2 = (int16_t)tmr_counter_value_get(TMR3);
tmr_counter_value_set(TMR3, 0);
return speed_m2;
}
void by_motion_init(void)
{
DRV_ENABLE();
by_motion_pwm_m1(125);
by_motion_pwm_m1(-125);
by_motion_pwm_m2(0);
}