Sample code to trigger GPIO
#include “NDP.h”
//const bool lowestPower = true;
const bool lowestPower = false;
void checkmatch(char* label)
{
if(strcmp((char *)label,“NN0:go”) == 0)
{
ledGreenOn();
digitalWrite(4,HIGH);
}
else if(strcmp((char *)label,“NN0:stop”) == 0)
{
ledBlueOn();
digitalWrite(4,LOW);
}
if (!lowestPower) {
Serial.println(label);
}
}
void ledMagentaOn() {
nicla::leds.begin();
nicla::leds.setColor(magenta);
delay(200);
nicla::leds.setColor(off);
nicla::leds.end();
}
void ledYellowOn() {
nicla::leds.begin();
nicla::leds.setColor(yellow);
delay(200);
nicla::leds.setColor(off);
nicla::leds.end();
}
void ledCyanOn() {
nicla::leds.begin();
nicla::leds.setColor(cyan);
delay(200);
nicla::leds.setColor(off);
nicla::leds.end();
}
void ledWhiteOn() {
nicla::leds.begin();
nicla::leds.setColor(white);
delay(200);
nicla::leds.setColor(off);
nicla::leds.end();
}
void ledBlueOn() {
nicla::leds.begin();
nicla::leds.setColor(blue);
delay(200);
nicla::leds.setColor(off);
nicla::leds.end();
}
void ledGreenOn() {
nicla::leds.begin();
nicla::leds.setColor(green);
delay(200);
nicla::leds.setColor(off);
nicla::leds.end();
}
void ledRedBlink() {
while (1) {
nicla::leds.begin();
nicla::leds.setColor(red);
delay(200);
nicla::leds.setColor(off);
delay(200);
nicla::leds.end();
}
}
void setup() {
pinMode(4,OUTPUT);
Serial.begin(115200);
nicla::begin();
nicla::disableLDO();
nicla::leds.begin();
NDP.onError(ledRedBlink);
NDP.onMatch(checkmatch);
NDP.onEvent(ledGreenOn);
Serial.println(“Loading synpackages”);
NDP.begin(“mcu_fw_120_v91.synpkg”);
NDP.load(“dsp_firmware_v91.synpkg”);
NDP.load(“ei_model.synpkg”);
Serial.println(“packages loaded”);
NDP.getInfo();
Serial.println(“Configure mic”);
NDP.turnOnMicrophone();
NDP.interrupts();
// For maximum low power; please note that it’s impossible to print after calling these functions
nicla::leds.end();
if (lowestPower) {
NRF_UART0->ENABLE = 0;
}
//NDP.turnOffMicrophone();
}
void loop() {
uint8_t command = 0xFF;
while (Serial.available()) {
command = Serial.read();
if (command == ‘f’) {
Serial.println(“Interrupts disabled”);
NDP.noInterrupts();
} else if (command == ‘o’) {
Serial.println(“Interrupts enabled”);
NDP.interrupts();
}
}
//Serial.println(“in the loop”);
delay(100);
}