Added PWM
This commit is contained in:
parent
e375586804
commit
afaa87daec
21
pwm.c
Normal file
21
pwm.c
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#include <hardware/pwm.h>
|
||||||
|
#include <pico/types.h>
|
||||||
|
|
||||||
|
#include "const.h"
|
||||||
|
|
||||||
|
#include "pwm.h"
|
||||||
|
|
||||||
|
void pwm_isr(void) {
|
||||||
|
static uint slice = -1, chan = -1;
|
||||||
|
if (slice == -1) slice = pwm_gpio_to_slice_num(AUDIO_OUT);
|
||||||
|
if (chan == -1) chan = pwm_gpio_to_channel(AUDIO_OUT);
|
||||||
|
|
||||||
|
pwm_clear_irq(slice);
|
||||||
|
|
||||||
|
// TODO:
|
||||||
|
float sample = 0.0f;
|
||||||
|
|
||||||
|
uint16_t level = (uint16_t)((sample + 1.0f) * 0.5f * 3400.0f);
|
||||||
|
pwm_set_chan_level(slice, chan, level);
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user