Initial commit

This commit is contained in:
Paul Mathieu
2021-02-17 13:20:30 -08:00
commit 363944d417
35 changed files with 3318 additions and 0 deletions

31
first/cc/blinky.c Normal file
View File

@@ -0,0 +1,31 @@
// let's write blinky.c
#define LED_ADDR ((volatile char*)0xC000)
#define led_write(x) (*LED_ADDR = (x))
#define CYCLES_PER_MS 6666 // ish
void busy_sleep_1ms() {
for (int i = 0; i < CYCLES_PER_MS; ++i) {
// nothing
}
}
/** waits a general amount of time */
void busy_sleep(int ms) {
for (int i = 0; i < ms; ++i) {
busy_sleep_1ms();
}
}
int main() {
int onoff = 0;
while (1) {
led_write(onoff);
busy_sleep(100);
onoff++;
}
return 0; // actually unreachable
}