Fork for Get Started Demo

Dependencies:   DebouncedInterrupt dash7-alp mbed-rtos mbed wizzi-utils

Fork of D7A_Demo_full by WizziLab

main.cpp

Committer:
Jeej
Date:
2015-11-19
Revision:
1:49da0144dd4c
Parent:
0:aa25c4c8ddbf
Child:
2:c3cfaa7d5bb8

File content as of revision 1:49da0144dd4c:

#include "mbed.h"
#include "rtos.h"
#include "dbg.h"
#include "shield.h"
#include "alp_serial.h"
#include "alp_device.h"

int main()
{
    // ----- Debug session over USB Serial ----- //
    DBG_OPEN();
        
    // Clear some lines on the terminal
    DPRINT("\r\n\nBOOT\r\n");
    
    // Declare Shield NRST pin
    DigitalOut shield_nrst(PB_0);
    
    // Reset shield
    shield_nrst = 0;
    
    // Open ALP port over serial
    // This is the physical ALP serial port
    AlpSerial serial_shield;

    // Initialize ALP device
    // This creates an AlpDevice object abstracting the shield1001
    // The parameters describe how to access it
    AlpDevice shield(&serial_shield, 0, ACCESS_CLASS_EP, ALP_FILE_BLOCK_ISFB, true);

    // Release reset
    shield_nrst = 1;
    
    // Check the shield boot packets
    shield_check_boot(&shield);
    
    // Wait for Shield to notify its files if there is any
    Thread::wait(1000);
    
    // Set main task to lowest priority
    osThreadSetPriority(osThreadGetId(), osPriorityIdle);
    while(true)
    {
        // Wait to avoid beeing stuck in loop
        Thread::wait(osWaitForever);
    }
}