Browse Source

update,重新封装了编码器开启,停止函数

external_Interrupt
tianjialong 2 years ago
parent
commit
d1f82efec5
  1. 21
      MDK-ARM/LWIP.uvguix.29643
  2. 16
      usersrc/encoder.c
  3. 4
      usersrc/encoder.h
  4. 2
      usersrc/usermain.c

21
MDK-ARM/LWIP.uvguix.29643
File diff suppressed because it is too large
View File

16
usersrc/encoder.c

@ -10,16 +10,20 @@ static encoder_t m_uarts[] = {
{&driven_encoder_gear, TIM_CHANNEL_1 | TIM_CHANNEL_2} //
};
void encoder_start(void)
void encoder_all_start(void)
{
/* 不开启会导致程序无法启动,原因未知 */
HAL_TIM_Encoder_Start(&camera_encoder, TIM_CHANNEL_1 | TIM_CHANNEL_2);
HAL_TIM_Encoder_Start(&driven_encoder_gear, TIM_CHANNEL_1 | TIM_CHANNEL_2);
for (uint8_t i = 0; i < (sizeof(m_uarts) / sizeof(encoder_t)); i++)
{
HAL_TIM_Encoder_Start(m_uarts[i].tim_handler, m_uarts[i].tim_channel);
}
}
void encoder_stop(void)
void encoder_all_stop(void)
{
HAL_TIM_Encoder_Stop(&camera_encoder, TIM_CHANNEL_1 | TIM_CHANNEL_2);
HAL_TIM_Encoder_Stop(&driven_encoder_gear, TIM_CHANNEL_1 | TIM_CHANNEL_2);
for (uint8_t i = 0; i < (sizeof(m_uarts) / sizeof(encoder_t)); i++)
{
HAL_TIM_Encoder_Stop(m_uarts[i].tim_handler, m_uarts[i].tim_channel);
}
}
void encoder_read_printf(void)

4
usersrc/encoder.h

@ -7,6 +7,6 @@ typedef struct
uint32_t tim_channel;
} encoder_t;
void encoder_start(void);
void encoder_stop(void);
void encoder_all_start(void);
void encoder_all_stop(void);
void encoder_read_printf(void);

2
usersrc/usermain.c

@ -19,7 +19,7 @@ void user_main()
printf("==============ethernet_sound_acquisition_card=============\r\n");
printf("version %d.%d", VERSION_MAIN_ID, VERSION_SUB_ID);
encoder_start();
encoder_all_start();
udp_client_init();
config_init();

Loading…
Cancel
Save