|
uMIDI
The swiss army knife for quick and easy developement of MIDI applications.
|
PWM configuration and service functions. More...
#include <stdbool.h>#include <stdint.h>#include <avr/io.h>#include <avr/interrupt.h>#include "gpio.h"#include "lookup_tables.h"#include "math.h"#include "midi.h"#include "pwm.h"
Functions | |
| void | init_pwm_module (uint16_t(*const conversion_function)(midi_value_t value)) |
| Initializes the PWM. More... | |
| void | set_pwm_duty_cycle (midi_value_t duty) |
| Updates the PWM duty cycle. More... | |
Variables | |
| static uint16_t(* | convert_pwm_range )(midi_value_t value) |
PWM configuration and service functions.
| void init_pwm_module | ( | uint16_t(*)(midi_value_t value) | conversion_function | ) |
Initializes the PWM.
CPU timer 1 is clocked with the system clock (32 MHz) and the compare output A is set up to output a dual slope PWM. Additionally, a conversion function which is used in set_pwm_duty_cycle() to compute the duty cycle compare values is registered.
| conversion_function | pointer to a function converting midi values to pwm compare register values |
| void set_pwm_duty_cycle | ( | midi_value_t | duty | ) |
Updates the PWM duty cycle.
Computes a suitable duty cycle compare value and writes the PWM counter compare register. This procedure can be used to manually control the modulation.
| duty | the desired duty cycle [0..MIDI_MAX_VALUE] |
|
static |
1.8.13