//
// Included Files
//
#include "driverlib_cm.h"
#include "cm.h"

#include "cm_board.h"


IPC_MessageQueue_t messageQueue1;
IPC_Message_t TxMsg1, RxMsg1;

//#define IPC_SYNC 		IPC_FLAG31

uint32_t EntryAddr = 0x0210000;
#define jumpEntryAddr 	(void (*)(void))0x0210000

void exit(uint32_t address){
    //
    // Jump to entry address
    //
    __asm("   bx r0");
}

//
// Main
//
void main(void)
{
    //
    // Initialize device clock and peripherals
    //
    CM_init();

//    DEVICE_DELAY_US(2000000);

    GPIO_writePin(mGPIO_PIN_LED5, 0);

    IPC_sync(IPC_CM_L_CPU1_R, IPC_SYNC);

    IPC_clearFlagLtoR(IPC_CM_L_CPU1_R, IPC_FLAG_ALL);

    // jump to CM_APP
    __asm(" mov r0, #0x00210000");
    __asm(" mov pc, r0");


//    IPC_initMessageQueue(IPC_CM_L_CPU1_R, &messageQueue1, IPC_INT1, IPC_INT1);

//    asm("    LB 0x00210000");

//    exit(EntryAddr); // EntryAddr = 0x0210000;

    for(;;)
    {
    	GPIO_togglePin(mGPIO_PIN_LED5);
		DEVICE_DELAY_US(500000);

//	    __asm(" mov r0, #0x00210000");
//	    __asm(" mov pc, r0");
    }
}

//
// End of File
//
