test prog implementation moved to real driver/board implementations

This commit is contained in:
Thomas Klaehn
2016-08-29 16:12:51 +02:00
parent 1407b35ce8
commit 13c416a2ba
8 changed files with 522 additions and 130 deletions

View File

@@ -193,6 +193,7 @@ static const struct stm32f4_gpio t4c4_gpio = {
static struct stm32f4_pwm str32f4_pwm_4 = {
.pwm_gpio = &t4c4_gpio,
.timer_handle = &tim4_handle,
.timer_src_frequency_MHz = 84,
.output_compare_cfg = &t4_output_compare_cfg,
.master_cfg = &t4_master_cfg,
.channel = TIM_CHANNEL_4,
@@ -228,6 +229,7 @@ static const struct stm32f4_gpio stm32f4_pwm_t4c3_gpio = {
static struct stm32f4_pwm str32f4_pwm_3 = {
.pwm_gpio = &stm32f4_pwm_t4c3_gpio,
.timer_handle = &tim4_handle,
.timer_src_frequency_MHz = 84,
.output_compare_cfg = &t4_output_compare_cfg,
.master_cfg = &t4_master_cfg,
.channel = TIM_CHANNEL_3,
@@ -263,6 +265,7 @@ static const struct stm32f4_gpio stm32f4_pwm_t4c2_gpio = {
static struct stm32f4_pwm str32f4_pwm_2 = {
.pwm_gpio = &stm32f4_pwm_t4c2_gpio,
.timer_handle = &tim4_handle,
.timer_src_frequency_MHz = 84,
.output_compare_cfg = &t4_output_compare_cfg,
.master_cfg = &t4_master_cfg,
.channel = TIM_CHANNEL_2,
@@ -298,6 +301,7 @@ static const struct stm32f4_gpio stm32f4_pwm_t4c1_gpio = {
static struct stm32f4_pwm str32f4_pwm_1 = {
.pwm_gpio = &stm32f4_pwm_t4c1_gpio,
.timer_handle = &tim4_handle,
.timer_src_frequency_MHz = 84,
.output_compare_cfg = &t4_output_compare_cfg,
.master_cfg = &t4_master_cfg,
.channel = TIM_CHANNEL_1,
@@ -361,6 +365,7 @@ static const struct stm32f4_gpio t5c2_gpio = {
static struct stm32f4_pwm str32f4_pwm5_c2 = {
.pwm_gpio = &t5c2_gpio,
.timer_handle = &tim5_handle,
.timer_src_frequency_MHz = 84,
.output_compare_cfg = &t5_output_compare_cfg,
.master_cfg = &t5_master_cfg,
.channel = TIM_CHANNEL_2,
@@ -380,6 +385,69 @@ const struct driver pwm5_c2 = {
&pwm5_ch2,
};
// PWM2 CHANNEL 4
/* apb1 clock = 84MHz */
/* period_reg = src_clk / presc / cnt_clk */
/* 1679 = 84MHZ / 1000 / 50Hz - 1 */
static TIM_HandleTypeDef t2_handle = {
.Instance = TIM2,
.Init.Prescaler = 1000,
.Init.CounterMode = TIM_COUNTERMODE_UP,
.Init.Period = 0xffff,
.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1,
.Init.RepetitionCounter = 0,
};
static TIM_IC_InitTypeDef t2_input_capture_init = {
.ICPrescaler = TIM_ICPSC_DIV1,
.ICFilter = 0,
.ICPolarity = TIM_ICPOLARITY_BOTHEDGE,
.ICSelection = TIM_ICSELECTION_INDIRECTTI,
};
static TIM_SlaveConfigTypeDef t2_slave_config = {
.SlaveMode = TIM_SLAVEMODE_RESET,
.InputTrigger = TIM_TS_TI1FP1,
.TriggerPolarity = TIM_INPUTCHANNELPOLARITY_BOTHEDGE,
.TriggerFilter = 0,
};
static GPIO_InitTypeDef port_cfg_b10 = {
.Pin = GPIO_PIN_10,
.Mode = GPIO_MODE_AF_OD,
.Speed = GPIO_SPEED_FREQ_HIGH,
.Pull = GPIO_NOPULL,
.Alternate = GPIO_AF1_TIM2,
};
static const struct stm32f4_gpio b10_gpio = {
.port = GPIOB,
.pin = &port_cfg_b10,
};
static struct stm32f4_pwm stm32f4_pwm2_c4 = {
.pwm_gpio = &b10_gpio,
.timer_handle = &t2_handle,
.timer_src_frequency_MHz = 84,
.input_capture_init = &t2_input_capture_init,
.slave_config = &t2_slave_config,
.channel = TIM_CHANNEL_4,
};
static const struct pwm pwm2_ch4 = {
.arch_dep_device = &stm32f4_pwm2_c4,
.fp = &stm32f4_pwm_fp,
};
#ifdef TEST_APP
static const struct driver pwm2_c4 = {
#else
const struct driver pwm2_c4 = {
#endif
DRIVER_TYPE_PWM,
&pwm2_ch4,
};
// UART 1
static const GPIO_InitTypeDef port_cfg_uart1 = {
.Pin = GPIO_PIN_6 | GPIO_PIN_7,