wip
This commit is contained in:
@@ -17,6 +17,8 @@
|
||||
#include "shell.h"
|
||||
|
||||
#include "stm32f4xx.h"
|
||||
|
||||
#include "pwm.h"
|
||||
#include "stm32f4_pwm.h"
|
||||
|
||||
/* apb1 clock = 84MHz */
|
||||
@@ -59,6 +61,10 @@ static struct stm32f4_pwm str32f4_pwm = {
|
||||
.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];
|
||||
@@ -66,8 +72,9 @@ struct thread_context th_ctx;
|
||||
static void th_func(void *arg)
|
||||
{
|
||||
unsigned int duty = 0;
|
||||
pwm_open(&pwm_ch4);
|
||||
while(1) {
|
||||
stm32f4_pwm_set_duty_cycle(&str32f4_pwm, duty);
|
||||
pwm_set_duty_cycle(&pwm_ch4, duty);
|
||||
sleep_ms(100);
|
||||
duty++;
|
||||
if(duty > 100)
|
||||
@@ -77,7 +84,6 @@ static void th_func(void *arg)
|
||||
|
||||
int main(void)
|
||||
{
|
||||
stm32f4_pwm_open(&str32f4_pwm);
|
||||
thread_create(&th_ctx, th_stack, TH_STACK_SIZE, th_func, NULL, THREAD_PRIO_LOW);
|
||||
|
||||
schedule_start();
|
||||
|
Reference in New Issue
Block a user