add trigger pwm for ultrasonic module

This commit is contained in:
tkl
2016-08-23 11:40:57 +02:00
parent 7b7c40978b
commit fdc493fcef
3 changed files with 63 additions and 143 deletions

View File

@@ -15,17 +15,6 @@
#include "pwm.h"
#include "stm32f4_pwm.h"
#pragma pack(push)
#pragma pack(1)
struct stm32f4_pwm_object {
uint8_t used_channels;
uint32_t channel_1_max_period;
uint32_t channel_2_max_period;
uint32_t channel_3_max_period;
uint32_t channel_4_max_period;
};
#pragma pack(pop)
int stm32f4_pwm_open(const void *pwm)
{
if(NULL == pwm)
@@ -35,6 +24,9 @@ int stm32f4_pwm_open(const void *pwm)
if(this->timer_handle->Instance == TIM4) {
__HAL_RCC_TIM4_CLK_ENABLE();
}
if(this->timer_handle->Instance == TIM5) {
__HAL_RCC_TIM5_CLK_ENABLE();
}
HAL_TIM_PWM_Init(this->timer_handle);
HAL_TIM_PWM_ConfigChannel(this->timer_handle, this->output_compare_cfg, this->channel);