synth/arm/gpio.h

28 lines
477 B
C++

#pragma once
#include <cstdint>
struct Gpio {
volatile uint32_t data;
};
#define gpio0 ((Gpio*)0x40000000)
inline void ToggleLed(int which) {
uint8_t data = gpio0->data;
data ^= (0x1 << which);
gpio0->data = data;
}
inline void SetLed(int which) {
uint8_t data = gpio0->data;
data |= (0x1 << which);
gpio0->data = data;
}
inline void ClearLed(int which) {
uint8_t data = gpio0->data;
data &= ~(0x1 << which);
gpio0->data = data;
}