synth/arm/main.cc

33 lines
515 B
C++
Raw Normal View History

#include "gpio.h"
2022-05-08 06:00:22 +00:00
2022-05-09 03:55:58 +00:00
namespace {
2022-05-08 06:00:22 +00:00
2022-05-09 03:55:58 +00:00
[[maybe_unused]]
void sleep(int ms) {
for (int i = 0; i < ms; i++) {
// sleep for 1 ms
for (int j = 0; j < 22000; j++) {
2022-05-09 03:55:58 +00:00
asm("");
}
}
2022-05-08 06:00:22 +00:00
}
2022-05-09 03:55:58 +00:00
} // namespace
extern "C" int main() {
uint8_t cnt = 0;
2022-05-09 03:55:58 +00:00
for (int i = 0; i < 256; i++) {
gpio0->data = cnt;
cnt++;
2022-05-09 03:55:58 +00:00
sleep(125);
2022-05-09 03:55:58 +00:00
}
auto* airc = reinterpret_cast<volatile uint32_t*>(0xe000ed0c);
uint32_t a = *airc;
*airc = a | 0x04;
while (1) {}
}