sipeed / bl602-hal

Hardware Abstract Layer for BL602 RISC-V WiFi + BLE SoC in embedded Rust
Other
75 stars 14 forks source link

Add LED timer interrupt example #35

Closed kiyoshigawa closed 3 years ago

kiyoshigawa commented 3 years ago

This is example code showing the use of the timer interrupts to control LED blinking. It makes use of all three match interrupts on TimerCh0, and uses Mutex<RefCell<>> to allow access to peripherals inside the interrupt function.

This code only works once this pull request fixing the memory.x file has been applied: https://github.com/sipeed/bl602-hal/pull/34

Note: I couldn't figure out how to copy a file from my test repo into this one and preserve version history, so I just manually copied and pasted it without the history. I want to note in this pull request that 9names and bjoernQ assisted me in getting the RefCell code to work correctly, and to link to the test repo here to show their contributions: https://github.com/kiyoshigawa/bl602-irq-example