feat(ex00): is done
This commit is contained in:
parent
a8d64871b1
commit
dd41c1f072
17 changed files with 978 additions and 0 deletions
39
ex00/src/utils.c
Normal file
39
ex00/src/utils.c
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
#include "utils.h"
|
||||
#include "mystd.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--;
|
||||
}
|
||||
}
|
||||
|
||||
void ft_bzero(void* data, uint16_t size) {
|
||||
char* d = data;
|
||||
while (size) {
|
||||
*d = 0;
|
||||
d++;
|
||||
size--;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t ft_stridx(const char* str, char chr) {
|
||||
if (!str)
|
||||
return -1;
|
||||
for (uint8_t i = 0; str[i]; i++) {
|
||||
if (str[i] == chr)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue