This is an example of how to setup mbed to run on the ANNA-B112 using the EVK-NINA-B1 target for compilation

main.cpp

Committer:
rlanders73
Date:
2020-03-01
Revision:
1:2bd5f1894796
Parent:
0:67a616264a3f

File content as of revision 1:2bd5f1894796:

/* 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
    }
}