My forked repository. DISCO_F407VG, DISCO_F303VC, DISCO_F051R8 and DISCO_F100RB maybe added.
Dependents: FastPWM-DISCO-test
Fork of FastPWM by
Diff: Device/FastPWM_KLXX.cpp
- Revision:
- 8:a7745c791b0c
- Parent:
- 6:0f57969697b6
- Child:
- 9:c50f688cad07
diff -r 1b5df740bcd7 -r a7745c791b0c Device/FastPWM_KLXX.cpp --- a/Device/FastPWM_KLXX.cpp Thu May 01 16:54:00 2014 +0000 +++ b/Device/FastPWM_KLXX.cpp Fri Jun 27 05:48:25 2014 +0000 @@ -2,13 +2,8 @@ #include "FastPWM.h" -volatile uint32_t *TPM_SC; - void FastPWM::initFastPWM( void ) { bits = 16; - - //Yes this is ugly, yes I should feel bad about it - TPM_SC = _pwm.MOD - 2; } void FastPWM::pulsewidth_ticks( uint32_t ticks ) { @@ -24,6 +19,10 @@ } uint32_t FastPWM::setPrescaler(uint32_t reqScale) { + + //Yes this is ugly, yes I should feel bad about it + volatile uint32_t *TPM_SC = _pwm.MOD - 2; + const char prescalers[] = {1, 2, 4, 8, 16, 32, 64, 128}; //If prescaler is 0, return current one