   spi_transfer((uint8_t)((D & 0xff00L) >> 8L));  // D[15:8]
   spi_transfer((uint8_t)(D & 0xffL));  // D[7:0]
   spi_transfer(0);
-  digitalWrite(CPLD_SS_PIN, HIGH);
+  CPLD_SS_SET();
 #ifdef SHOW_ALL_FLASH_ACCESS
   Serial.print("Flash write *0x");
   Serial.print(A, HEX);

// Tell the CPLD to return control of the flash to the host machine
void flash_unlock() {
  // Reset allowing_arm_access to 1 in the CPLD
  digitalWrite(CPLD_SS_PIN, LOW);
  spi_transfer(0xff);
  digitalWrite(CPLD_SS_PIN, HIGH);
}

// Pulse NRESET on the flash chips


  // Set up fast SPI comms on SERCOM2 with CPLD
  pinMode(CPLD_SS_PIN, OUTPUT);
  CPLD_SS_SET();
  cpld_spi.begin();
  pinPeripheral(CPLD_MOSI_PIN, PIO_SERCOM_ALT);
  pinPeripheral(CPLD_SCK_PIN, PIO_SERCOM_ALT);
