diff options
author | Marti Bolivar <mbolivar@leaflabs.com> | 2011-10-12 09:22:15 -0400 |
---|---|---|
committer | Marti Bolivar <mbolivar@leaflabs.com> | 2011-10-12 09:22:15 -0400 |
commit | c023d179fa613f979d50a0d105f08b9b58c7ce6b (patch) | |
tree | 03b26cec10ca92e5a791ff7b8c9783ee0588fbd1 /libmaple | |
parent | bf29f8223c9f9b63a11d60dbadab837589e7f3b2 (diff) | |
download | librambutan-c023d179fa613f979d50a0d105f08b9b58c7ce6b.tar.gz librambutan-c023d179fa613f979d50a0d105f08b9b58c7ce6b.zip |
timer.h: fix timer_oc_set_mode().
timer_oc_set_mode() incorrectly writes to CCMR1 when channel is 2; fix
this.
Thanks to ala42 for the fix.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
Diffstat (limited to 'libmaple')
-rw-r--r-- | libmaple/timer.h | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/libmaple/timer.h b/libmaple/timer.h index dfc8a4f..53e2547 100644 --- a/libmaple/timer.h +++ b/libmaple/timer.h @@ -994,12 +994,10 @@ static inline void timer_oc_set_mode(timer_dev *dev, uint8 channel, timer_oc_mode mode, uint8 flags) { - uint8 bit0 = channel & 1; - uint8 bit1 = (channel >> 1) & 1; /* channel == 1,2 -> CCMR1; channel == 3,4 -> CCMR2 */ - __io uint32 *ccmr = &(dev->regs).gen->CCMR1 + bit1; + __io uint32 *ccmr = &(dev->regs).gen->CCMR1 + (((channel - 1) >> 1) & 1); /* channel == 1,3 -> shift = 0, channel == 2,4 -> shift = 8 */ - uint8 shift = 8 * (1 - bit0); + uint8 shift = 8 * (1 - (channel & 1)); uint32 tmp = *ccmr; tmp &= ~(0xFF << shift); |