SP1 vers 3
Dependents: SoufflerieSP1-vers2
pwm.cpp@0:63a2685bf4f0, 2021-06-08 (annotated)
- Committer:
- petit
- Date:
- Tue Jun 08 10:37:05 2021 +0000
- Revision:
- 0:63a2685bf4f0
SP1-3
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
petit | 0:63a2685bf4f0 | 1 | #include "mbed.h" |
petit | 0:63a2685bf4f0 | 2 | #include "pwm.h" |
petit | 0:63a2685bf4f0 | 3 | PwmOut PwmMot(PA_15); |
petit | 0:63a2685bf4f0 | 4 | |
petit | 0:63a2685bf4f0 | 5 | void InitPwmMot(void) |
petit | 0:63a2685bf4f0 | 6 | { |
petit | 0:63a2685bf4f0 | 7 | PwmMot.period_ms(20); |
petit | 0:63a2685bf4f0 | 8 | PwmMot.pulsewidth_us(875); |
petit | 0:63a2685bf4f0 | 9 | } |
petit | 0:63a2685bf4f0 | 10 | |
petit | 0:63a2685bf4f0 | 11 | void SetPwmMot(unsigned char Pourcent) |
petit | 0:63a2685bf4f0 | 12 | { |
petit | 0:63a2685bf4f0 | 13 | int th = 875 + (float)Pourcent * 11.25; |
petit | 0:63a2685bf4f0 | 14 | PwmMot.pulsewidth_us(th); |
petit | 0:63a2685bf4f0 | 15 | } |