This is an example of how to setup mbed to run on the ANNA-B112 using the EVK-NINA-B1 target for compilation
Diff: main.cpp
- Revision:
- 0:67a616264a3f
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Feb 27 21:02:19 2020 +0000 @@ -0,0 +1,51 @@ +/* mbed Microcontroller Library + * Copyright (c) 20 Point Labs, LLC. + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "mbed.h" +#include "ANNA-B112.h" +#include "platform/mbed_thread.h" + +// Blinking rate in milliseconds +#define BLINKING_RATE_MS 500 + + +DigitalOut led(LED_B); +UARTSerial radio(TX_PIN, RX_PIN, 115200); + +static Thread echoThread( osPriorityNormal, OS_STACK_SIZE / 2, NULL, "echo_thread" ); +void echoTask() +{ + while(true){ + uint8_t inbuf[64]; + int size; + if(radio.readable()){ + size = radio.read(inbuf,sizeof(inbuf)); + radio.write(inbuf,size); + } + } +} + +static Thread blinkThread( osPriorityNormal, OS_STACK_SIZE / 2, NULL, "pc_thread" ); +void blinkTask() +{ + while (true) { + led = !led; + thread_sleep_for(BLINKING_RATE_MS); + } +} + +int main() +{ + // Initialise the digital pin state + led = 1; + + // Start the threads + echoThread.start(echoTask); + blinkThread.start(blinkTask); + + while (true) { + thread_sleep_for(1000); // Just get out of the way + } +}