Skip to content

Instantly share code, notes, and snippets.

@nanase
Created April 29, 2020 13:35
Show Gist options
  • Save nanase/c9c3f48da9fa895e476addf0db512a5e to your computer and use it in GitHub Desktop.
Save nanase/c9c3f48da9fa895e476addf0db512a5e to your computer and use it in GitHub Desktop.
Manipulating PA30 and PA31 pins on Seeeduino XIAO
void setup() {
// instead of pinMode(30, OUTPUT);
(&(PORT->Group[PORTA]))->PINCFG[30].reg = (uint8_t)(PORT_PINCFG_INEN);
(&(PORT->Group[PORTA]))->PINCFG[31].reg = (uint8_t)(PORT_PINCFG_INEN);
(&(PORT->Group[PORTA]))->DIRSET.reg = (1 << 30);
(&(PORT->Group[PORTA]))->DIRSET.reg = (1 << 31);
}
void loop() {
// instead of digitalWrite(30, HIGH);
(&(PORT->Group[PORTA]))->OUTSET.reg = (1 << 30);
(&(PORT->Group[PORTA]))->OUTSET.reg = (1 << 31);
delay(1000);
// instead of digitalWrite(30, LOW);
(&(PORT->Group[PORTA]))->OUTCLR.reg = (1 << 30);
(&(PORT->Group[PORTA]))->OUTCLR.reg = (1 << 31);
delay(1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment