Skip to content

Instantly share code, notes, and snippets.

@pingswept
Created October 26, 2020 21:27
Show Gist options
  • Save pingswept/c4a8e9aae4df17f11bd23ed20d30f7c3 to your computer and use it in GitHub Desktop.
Save pingswept/c4a8e9aae4df17f11bd23ed20d30f7c3 to your computer and use it in GitHub Desktop.
Fixing the drive strength mode on the Arduino MKR Wifi 1010
void setup() {
pinMode(4, OUTPUT);
setHighStrengthOutputPinMode(4);
}
void loop() {
digitalWrite(4, HIGH);
}
bool setHighStrengthOutputPinMode( uint32_t ulPin)
{
// Handle the case the pin isn't usable as PIO
if ( g_APinDescription[ulPin].ulPinType == PIO_NOT_A_PIN ) return false;
EPortType port = g_APinDescription[ulPin].ulPort;
uint32_t pin = g_APinDescription[ulPin].ulPin;
uint32_t pinMask = (1ul << pin);
// enable input, to support reading back values, with pullups disabled and DRVSTR set
PORT->Group[port].PINCFG[pin].reg=(uint8_t)(PORT_PINCFG_INEN | PORT_PINCFG_DRVSTR) ;
// Set pin to output mode
PORT->Group[port].DIRSET.reg = pinMask;
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment