stm32l5: add pwm

This commit is contained in:
Kenneth Bell
2021-05-08 09:39:29 -07:00
committed by Ron Evans
parent ee167f15de
commit 2c4b507d34
5 changed files with 259 additions and 16 deletions
+4 -2
View File
@@ -1,4 +1,4 @@
// +build stm32f4
// +build stm32f4 stm32l5
package machine
@@ -8,6 +8,8 @@ import (
"runtime/volatile"
)
const PWM_MODE1 = 0x6
type TimerCallback func()
type ChannelCallback func(channel uint8)
@@ -94,7 +96,7 @@ func (t *TIM) SetMatchInterrupt(channel uint8, callback ChannelCallback) error {
t.OCInterrupt = t.registerOCInterrupt()
// Clear the interrupt flag
t.Device.SR.ClearBits(stm32.TIM_SR_CC1IF_Match << channel)
t.Device.SR.ClearBits(stm32.TIM_SR_CC1IF << channel)
// Enable the interrupt
t.OCInterrupt.SetPriority(0xc1)