wip
This commit is contained in:
parent
461f219b08
commit
2f13f30b3d
@ -13,15 +13,18 @@
|
||||
|
||||
#include "driver.h"
|
||||
#include "gpio.h"
|
||||
#include "pwm.h"
|
||||
#include "timer.h"
|
||||
#include "uart.h"
|
||||
#include "ringbuffer.h"
|
||||
#include "sys_tick.h"
|
||||
#include "stm32f4xx.h"
|
||||
#include "stm32f4_gpio.h"
|
||||
#include "stm32f4_pwm.h"
|
||||
#include "stm32f4_uart.h"
|
||||
#include "stm32_sys_tick.h"
|
||||
|
||||
|
||||
// SYSTEM TICK
|
||||
static const enum stm32_sys_tick_time_base stm23_sys_tick_time_base =
|
||||
STM32_SYS_TICK_TIME_BASE_MS;
|
||||
@ -36,6 +39,53 @@ static const struct loki_timer timer_1 = {
|
||||
&timer_fp
|
||||
};
|
||||
|
||||
// PWM CHANNEL 4
|
||||
/* apb1 clock = 84MHz */
|
||||
/* period_reg = src_clk / presc / cnt_clk */
|
||||
/* 4199 = 84MHZ / (0 + 1) / 20kHz - 1 */
|
||||
static const TIM_TimeBaseInitTypeDef timer_4_cfg = {
|
||||
.TIM_RepetitionCounter = 0x0000,
|
||||
.TIM_Prescaler = 0,
|
||||
.TIM_ClockDivision = TIM_CKD_DIV1,
|
||||
.TIM_CounterMode = TIM_CounterMode_Up,
|
||||
.TIM_Period = 4199
|
||||
};
|
||||
|
||||
static const TIM_OCInitTypeDef t4_output_compare_cfg = {
|
||||
.TIM_OutputNState = TIM_OutputNState_Disable,
|
||||
.TIM_OCNPolarity = TIM_OCPolarity_High,
|
||||
.TIM_OCIdleState = TIM_OCIdleState_Reset,
|
||||
.TIM_OCNIdleState = TIM_OCNIdleState_Set,
|
||||
.TIM_OCMode = TIM_OCMode_PWM1,
|
||||
.TIM_OCPolarity = TIM_OCPolarity_High,
|
||||
.TIM_OutputState = TIM_OutputState_Enable,
|
||||
.TIM_Pulse = 0 // Initiale Pulsweite in Millisekunden
|
||||
};
|
||||
|
||||
static const GPIO_InitTypeDef port_cfg = {
|
||||
.GPIO_Pin = GPIO_Pin_15,
|
||||
.GPIO_Mode = GPIO_Mode_AF,
|
||||
.GPIO_OType = GPIO_OType_PP,
|
||||
.GPIO_PuPd = GPIO_PuPd_UP,
|
||||
.GPIO_Speed = GPIO_Speed_100MHz,
|
||||
};
|
||||
|
||||
static struct stm32f4_pwm str32f4_pwm = {
|
||||
.timer = TIM4,
|
||||
.timer_cfg = &timer_4_cfg,
|
||||
.output_compare_cfg = &t4_output_compare_cfg,
|
||||
.port = GPIOD,
|
||||
.pin_src = GPIO_PinSource15,
|
||||
.port_cfg = &port_cfg,
|
||||
.channel = channel_4,
|
||||
};
|
||||
|
||||
static const struct pwm pwm_ch4 = {
|
||||
.arch_dep_device = &str32f4_pwm,
|
||||
.fp = &stm32f4_pwm_fp,
|
||||
};
|
||||
|
||||
// UART 1
|
||||
static char console_linear_buffer[80];
|
||||
static struct ringbuffer console_buffer = {
|
||||
console_linear_buffer,
|
||||
|
@ -16,55 +16,6 @@
|
||||
#include "list.h"
|
||||
#include "shell.h"
|
||||
|
||||
#include "stm32f4xx.h"
|
||||
|
||||
#include "pwm.h"
|
||||
#include "stm32f4_pwm.h"
|
||||
|
||||
/* apb1 clock = 84MHz */
|
||||
/* period_reg = src_clk / presc / cnt_clk */
|
||||
/* 4199 = 84MHZ / (0 + 1) / 20kHz - 1 */
|
||||
static const TIM_TimeBaseInitTypeDef timer_4_cfg = {
|
||||
.TIM_RepetitionCounter = 0x0000,
|
||||
.TIM_Prescaler = 0,
|
||||
.TIM_ClockDivision = TIM_CKD_DIV1,
|
||||
.TIM_CounterMode = TIM_CounterMode_Up,
|
||||
.TIM_Period = 4199
|
||||
};
|
||||
|
||||
static const TIM_OCInitTypeDef t4_output_compare_cfg = {
|
||||
.TIM_OutputNState = TIM_OutputNState_Disable,
|
||||
.TIM_OCNPolarity = TIM_OCPolarity_High,
|
||||
.TIM_OCIdleState = TIM_OCIdleState_Reset,
|
||||
.TIM_OCNIdleState = TIM_OCNIdleState_Set,
|
||||
.TIM_OCMode = TIM_OCMode_PWM1,
|
||||
.TIM_OCPolarity = TIM_OCPolarity_High,
|
||||
.TIM_OutputState = TIM_OutputState_Enable,
|
||||
.TIM_Pulse = 0 // Initiale Pulsweite in Millisekunden
|
||||
};
|
||||
|
||||
static const GPIO_InitTypeDef port_cfg = {
|
||||
.GPIO_Pin = GPIO_Pin_15,
|
||||
.GPIO_Mode = GPIO_Mode_AF,
|
||||
.GPIO_OType = GPIO_OType_PP,
|
||||
.GPIO_PuPd = GPIO_PuPd_UP,
|
||||
.GPIO_Speed = GPIO_Speed_100MHz,
|
||||
};
|
||||
|
||||
static struct stm32f4_pwm str32f4_pwm = {
|
||||
.timer = TIM4,
|
||||
.timer_cfg = &timer_4_cfg,
|
||||
.output_compare_cfg = &t4_output_compare_cfg,
|
||||
.port = GPIOD,
|
||||
.pin_src = GPIO_PinSource15,
|
||||
.port_cfg = &port_cfg,
|
||||
.channel = channel_4,
|
||||
};
|
||||
|
||||
static const struct pwm pwm_ch4 = {
|
||||
.arch_dep_device = &str32f4_pwm,
|
||||
.fp = &stm32f4_pwm_fp,
|
||||
};
|
||||
|
||||
#define TH_STACK_SIZE 256
|
||||
stack_t th_stack[TH_STACK_SIZE];
|
||||
@ -90,7 +41,6 @@ static void th_func(void *arg)
|
||||
int main(void)
|
||||
{
|
||||
thread_create(&th_ctx, th_stack, TH_STACK_SIZE, th_func, NULL, THREAD_PRIO_LOW);
|
||||
|
||||
schedule_start();
|
||||
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user