Firmware SDK
twr_pwm.h
1 #ifndef _TWR_PWM_H
2 #define _TWR_PWM_H
3 
4 #include <twr_system.h>
5 #include <twr_gpio.h>
6 #include <stm32l0xx.h>
7 
11 
13 
14 typedef enum
15 {
16  TWR_PWM_P0 = TWR_GPIO_P0,
17  TWR_PWM_P1 = TWR_GPIO_P1,
18  TWR_PWM_P2 = TWR_GPIO_P2,
19  TWR_PWM_P3 = TWR_GPIO_P3,
20 
21  TWR_PWM_P6 = TWR_GPIO_P6,
22  TWR_PWM_P7 = TWR_GPIO_P7,
23  TWR_PWM_P8 = TWR_GPIO_P8,
24 
25  TWR_PWM_P12 = TWR_GPIO_P12,
26  TWR_PWM_P14 = TWR_GPIO_P14,
27 
29 
32 
33 typedef enum
34 {
35  TWR_PWM_TIM2_P0_P1_P2_P3,
36  TWR_PWM_TIM3_P6_P7_P8,
37  TWR_PWM_TIM21_P12_P14
38 
40 
43 
44 void twr_pwm_init(twr_pwm_channel_t channel);
45 
48 
49 void twr_pwm_enable(twr_pwm_channel_t channel);
50 
53 
55 
59 
60 void twr_pwm_set(twr_pwm_channel_t channel, uint16_t pwm_value);
61 
65 
66 void twr_pwm_tim_configure(twr_pwm_tim_t tim, uint32_t resolution_us, uint32_t period_cycles);
67 
69 
70 #endif // _TWR_PWM_H
@ TWR_GPIO_P12
GPIO channel P12, MISO.
Definition: twr_gpio.h:51
@ TWR_GPIO_P1
GPIO channel P1, A1, RXD0.
Definition: twr_gpio.h:18
@ TWR_GPIO_P8
GPIO channel P8.
Definition: twr_gpio.h:39
@ TWR_GPIO_P3
GPIO channel P3, A3, RXD1.
Definition: twr_gpio.h:24
@ TWR_GPIO_P6
GPIO channel P6.
Definition: twr_gpio.h:33
@ TWR_GPIO_P2
GPIO channel P2, A2, TXD1.
Definition: twr_gpio.h:21
@ TWR_GPIO_P0
GPIO channel P0, A0, TXD0.
Definition: twr_gpio.h:15
@ TWR_GPIO_P14
GPIO channel P14, SCLK.
Definition: twr_gpio.h:57
@ TWR_GPIO_P7
GPIO channel P7, A6.
Definition: twr_gpio.h:36
void twr_pwm_enable(twr_pwm_channel_t channel)
Enable PWM output on GPIO pin.
Definition: twr_pwm.c:174
void twr_pwm_set(twr_pwm_channel_t channel, uint16_t pwm_value)
Set PWM value for GPIO pin.
Definition: twr_pwm.c:193
void twr_pwm_tim_configure(twr_pwm_tim_t tim, uint32_t resolution_us, uint32_t period_cycles)
Reconfigure TIM3.
Definition: twr_pwm.c:115
void twr_pwm_init(twr_pwm_channel_t channel)
Initialize PWM timers based on GPIO pin.
Definition: twr_pwm.c:141
twr_pwm_tim_t
PWM timers.
Definition: twr_pwm.h:34
twr_pwm_channel_t
PWM channels.
Definition: twr_pwm.h:15
void twr_pwm_disable(twr_pwm_channel_t channel)
Disable PWM output on GPIO pin.
Definition: twr_pwm.c:188