// 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
}
