/*
 *  ======== main ========
 */
int main()
{
  PIN_init(BoardGpioInitTable);

#ifndef POWER_SAVING
    /* Set constraints for Standby, powerdown and idle mode */
    Power_setConstraint(Power_SB_DISALLOW);
    Power_setConstraint(Power_IDLE_PD_DISALLOW);
#endif // POWER_SAVING

    /* Initialize ICall module */
    ICall_init();

    /* Start tasks of external images - Priority 5 */
    ICall_createRemoteTasks();

#ifdef PRINTF_ENABLED
    // Enable System_printf(..) UART output
    UART_Params uartParams;
    UART_Params_init(&uartParams);
    uartParams.baudRate = 921600;
    UartPrintf_init(UART_open(Board_UART, &uartParams));
#endif
    /* Kick off profile - Priority 3 */
    GAPRole_createTask();
    
    SimpleBLEPeripheral_createTask();

#ifdef FEATURE_OAD
    {
      uint8_t counter;
      uint32_t *vectorTable =  (uint32_t*) 0x20000000;
#if defined(__IAR_SYSTEMS_ICC__)
      uint32_t *flashVectors = &__vector_table;
#elif defined(__TI_COMPILER_VERSION__)
      uint32_t *flashVectors = &ti_sysbios_family_arm_m3_Hwi_resetVectors;
#endif //Compiler.
      
      // Write image specific interrupt vectors into RAM vector table.
      for(counter = 0; counter < 15; ++counter)
      {
        *vectorTable++ = *flashVectors++;
      }
    }
#endif //FEATURE_OAD
    
    /* enable interrupts and start SYS/BIOS */
    BIOS_start();
    
    return 0;
}
/*
 *  ======== main ========
 */
Void main()
{
  PIN_init(BoardGpioInitTable);


  //enable iCache prefetching
   VIMSConfigure(VIMS_BASE, TRUE, TRUE);
   
   // Enable cache
   VIMSModeSet(VIMS_BASE, VIMS_MODE_ENABLED);

#ifndef POWER_SAVING
    /* Set constraints for Standby, powerdown and idle mode */
    Power_setConstraint(Power_SB_DISALLOW);
    Power_setConstraint(Power_IDLE_PD_DISALLOW);
#endif // POWER_SAVING
    

    //Initialize task
    Task_Params params;
    Task_Params_init(&params);
    params.priority = TASK_PRI;
    params.stackSize = TASK_STACK_SIZE;
    params.stack = taskStack;

    //semaphore init
    Semaphore_Params sParams;
    Semaphore_Params_init(&sParams);
    sParams.mode = Semaphore_Mode_BINARY;


    /* Initialize ICall module */
    ICall_init();

    /* Start tasks of external images - Priority 5 */
    ICall_createRemoteTasks();
    
    /* Kick off profile - Priority 3 */
    GAPRole_createTask();
    
    SimpleBLEPeripheral_createTask();

    //Contruct task
    Task_construct(&taskStruct, taskFxn, &params, NULL);

    // Construct semaphore used for pending in task ADC
    Semaphore_construct(&sem, 0, &sParams);
    hSem = Semaphore_handle(&sem);

#ifdef FEATURE_OAD_BIM
    {
      uint8_t counter;
      uint32_t *vectorTable =  (uint32_t*) 0x20000000;
      uint32_t *flashVectors = &__vector_table;
      
      // Write image specific interrupt vectors into RAM vector table.
      for(counter = 0; counter < 15; ++counter)
      {
        *vectorTable++ = *flashVectors++;
      }
    }
#endif //FEATURE_OAD_BIM
    
    /* enable interrupts and start SYS/BIOS */
    BIOS_start();
}