feat(ex01): ex01 is complete
This commit is contained in:
parent
49164a0c18
commit
7eb2daf73f
5 changed files with 129 additions and 0 deletions
19
ex01/utils.c
Normal file
19
ex01/utils.c
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#include "utils.h"
|
||||
|
||||
// this just burns cycles.
|
||||
// the volatile is important, it means that the cpu can't optimize any
|
||||
// read/writes for the value
|
||||
static inline void spin_loop(volatile uint16_t counts) {
|
||||
while (counts)
|
||||
counts--;
|
||||
}
|
||||
|
||||
void delay_ms(uint16_t ms) {
|
||||
while (ms) {
|
||||
// this value was taken using a delay of 500ms, and just recording the led
|
||||
// blinking. it seems to be high enough such that each loop of delay_loop
|
||||
// takes 1ms :D
|
||||
spin_loop((F_CPU) / 5000);
|
||||
ms--;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue