Esempio n. 1
0
osaStatus_t HostInterface_RxInit(void)
{
    osa_status_t status;
    
    LPUART_DRV_InstallRxCallback(gHostInterface_instance, HostInterface_RxCallback, (uint8_t *)&hostInterface_rxPacket, 0, true);
    
    // Create Rx Message Queue
    hostInterface_rxQueueHnd = OSA_MsgQCreate(hostInterface_rxQueue, gHostInterface_msgNum, sizeof(hostInterface_packet_t) / 4);
    if(hostInterface_rxQueueHnd == 0)
    {
        panic(0,0,0,0);
        return osaStatus_Error;
    }
    
    // Create Rx Handler Task
    status = OSA_TaskCreate(HostInterface_RxHandlerTask, "HostInterface_RxHandlerTask", gHostInterfaceRxTaskStackSize_c, 0,
                            gHostInterfaceRxHandlerPriority_c, (task_param_t)NULL, FALSE, &gHostInterface_RxHandlerTaskId); 
    if( kStatus_OSA_Success != status )
    {
        panic(0,0,0,0);
        return (osaStatus_t)status;
    }
  
    return (osaStatus_t)status;
}
/*
 * NOTE: The msg_size here is counted by words, not bytes!
 */
os_msgq_handle OS_MsgQ_create(uint32_t max_msg_number, uint32_t msg_size)
{
    os_msgq_handle ret;
#if defined (FSL_RTOS_UCOSII)
    uint8_t *p_tmp;
    uint32_t size = sizeof(msg_queue_t)
    + (msg_size*sizeof(int32_t)+sizeof(void*))*max_msg_number;
#elif defined (FSL_RTOS_UCOSIII)
    uint8_t *p_tmp;
    uint32_t size = sizeof(msg_queue_t) + (msg_size*sizeof(int32_t))*max_msg_number;
#elif defined (FSL_RTOS_MQX)
    uint32_t size = (SIZE_IN_MMT_UNITS(sizeof(LWMSGQ_STRUCT))
    + SIZE_IN_MMT_UNITS((msg_size*sizeof(int32_t))*(max_msg_number)))
    * sizeof(_mqx_max_type);
#elif defined (FSL_RTOS_FREE_RTOS)
#else /* Bare metal by default. */
    uint8_t *p_tmp;
    uint32_t size = sizeof(msg_queue_t) + sizeof(uint32_t) * max_msg_number * msg_size;
#endif

#if defined (FSL_RTOS_FREE_RTOS)
    msg_queue_t* msgq = NULL;
#else
    msg_queue_t* msgq = (msg_queue_t*) OSA_MemAllocZero(size);

    if (!msgq)
    {
        return (msg_queue_handler_t) 0;
    }
#endif
    /* initialize the msg_queue_t */
#if defined (FSL_RTOS_UCOSII)
    p_tmp = (uint8_t*)msgq;
    p_tmp += sizeof(msg_queue_t);
    msgq->msgTbl = (void**)p_tmp;
    p_tmp += max_msg_number*sizeof(void*);
    msgq->msgs = (uint32_t*)p_tmp;
#elif defined (FSL_RTOS_UCOSIII)
    p_tmp = (uint8_t*)msgq;
    p_tmp += sizeof(msg_queue_t);
    msgq->msgs = (void*)p_tmp;
#elif defined (FSL_RTOS_MQX)
#elif defined (FSL_RTOS_FREE_RTOS)
#else /* Bare metal by default. */
    p_tmp = (uint8_t*) msgq;
    p_tmp += sizeof(msg_queue_t);
    msgq->queueMem = (uint32_t*) p_tmp;
#endif
    ret = OSA_MsgQCreate(msgq, max_msg_number, msg_size);
#if !defined (FSL_RTOS_FREE_RTOS)
    if (!ret)
    {
        OSA_MemFree(msgq);
    }
#endif
    return ret;
}
Esempio n. 3
0
/**
 * initialize sensor tag mode structures and tasks
 * @param param optional parameter
 */
void gui_sensorTag_Init( void* param )
{
    // create pedometer packet queue
    gui_sensorTag_queueHnd = OSA_MsgQCreate (
                                                gui_sensorTag_queue,
                                                1,
                                                sizeof(uint32_t) / sizeof(uint32_t)
                                            );
#if defined( HEXIWEAR_DEBUG )
  vQueueAddToRegistry( gui_sensorTag_queueHnd, (char*)"SensorTag Queue" );
#endif

    GuiDriver_ImageAddToScr( &gui_sensorTag_icon );

    screen_labelEnter.textProperties.fontColor = GUI_COLOR_WHITE;
    GuiDriver_RegisterForNavigation( GUI_NAVIGATION_RIGHT );

    GuiDriver_LabelAddToScr(&screen_labelEnter);
}
Esempio n. 4
0
/**
 * initialize RX tasks and queues
 * @return  task initialization status
 */
osa_status_t HostInterface_RxInit()
{
  osa_status_t
    status;

  // install the callback
  UART_DRV_InstallRxCallback( gHostInterface_instance, HostInterface_RxCallback, (uint8_t*)&hostInterface_rxPacket, NULL, true );

  // Create Rx Message Queue
  hostInterface_rxQueueHnd = OSA_MsgQCreate (
                                              hostInterface_rxQueue,
                                              gHostInterface_msgNum,
                                              sizeof(hostInterface_packet_t) / sizeof(uint32_t)
                                            );

  if ( NULL == hostInterface_rxQueueHnd )
  {
    catch(3);
  }

#if defined( HEXIWEAR_DEBUG )
  vQueueAddToRegistry( hostInterface_rxQueueHnd, (const char*)"RxQueue" );
#endif

  // Create Rx Task
  status = OSA_TaskCreate (
                            HostInterface_RxTask,
                            (uint8_t*)"HostInterface_RxTask",
                            gHostInterfaceRxTaskStackSize_c,
                            NULL,
                            gHostInterfaceRxPriority_c,
                            (task_param_t)NULL,
                            false,
                            &hexiwear_intf_RX_handler
                          );

  if  ( kStatus_OSA_Success != status )
  {
    catch(3);
  }

  return (osa_status_t)status;
}
Esempio n. 5
0
 /**
  * [gui_pedometer_Init description]
  * @param param [description]
  */
void gui_pedometer_Init( void* param )
{
    // create pedometer packet queue
    gui_pedometer_queueHnd = OSA_MsgQCreate (
                                                gui_pedometer_queue,
                                                1,
                                                sizeof(uint32_t) / sizeof(uint32_t)
                                            );
#if defined( HEXIWEAR_DEBUG )
  vQueueAddToRegistry( gui_pedometer_queueHnd, (char*)"GUI Pedometer Queue" );
#endif

    GuiDriver_ImageAddToScr( &screen_buttonStart );

    GuiDriver_LabelCreate( &gui_pedometer_stepCounter_label );
    snprintf( (char*)gui_pedometer_stepCounter_label.caption, 4, "%03u", 000 );

    GuiDriver_LabelCreate( &gui_pedometer_stepText_label );
    GuiDriver_LabelSetCaption( &gui_pedometer_stepText_label, (uint8_t*)"steps" );

    GuiDriver_LabelCreate( &gui_pedometer_calCounter_label );
    snprintf( (char*)gui_pedometer_calCounter_label.caption, 4, "%03u", 000 );

    GuiDriver_LabelCreate( &gui_pedometer_calText_label );
    GuiDriver_LabelSetCaption( &gui_pedometer_calText_label, (uint8_t*)"Cal" );

    GuiDriver_ImageAddToScr( &gui_pedometer_icon );

    // listen if the user wants to use the pedometer
    GuiDriver_RegisterForNavigation( GUI_NAVIGATION_RIGHT );

    // initiate the pedometer process structures
    oldStepVal = newStepVal = 0;
    pedometer_Init();

    GuiDriver_NotifyKW40( GUI_CURRENT_APP_PEDOMETER );
}
/**
 * create RTOS structures for sending data via communication interface
 */
osa_status_t HostInterface_TxInit()
{
  osa_status_t
    status = OSA_MutexCreate(&uartTxAccessMutex);

  if( kStatus_OSA_Success != status )
  {
    catch(3);
  }

  // Create Tx Message Queue
  hostInterface_txQueueHnd = OSA_MsgQCreate (
                                              hostInterface_txQueue,
                                              gHostInterface_msgNum,
                                              sizeof(hostInterface_packet_t) / sizeof(uint32_t)
                                            );
  if ( NULL == hostInterface_txQueueHnd )
  {
    return kStatus_OSA_Error;
  }

#if defined( HEXIWEAR_DEBUG )
  vQueueAddToRegistry( hostInterface_txQueueHnd, (signed char*)"TxQueue" );
#endif

  // Create Tx-Data Task
  status = OSA_TaskCreate (
                            HostInterface_TxTask,
                            (uint8_t*)"HostInterface_TxTask",
                            gHostInterfaceTxTaskStackSize_c,
                            HostInterface_TxTask_stack,
                            gHostInterfaceTxPriority_c,
                            (task_param_t)NULL,
                            false,
                            &HostInterface_TxTask_task_handler
                          );

  if ( kStatus_OSA_Success != status )
  {
    catch(3);
  }

  // create Tx-OK Task
  status = OSA_TaskCreate (
                            HostInterface_OkTask,
                            (uint8_t*)"HostInterface_OkTask",
                            gHostInterfaceOkTaskStackSize_c,
                            HostInterface_OkTask_stack,
                            gHostInterfaceOkPriority_c,
                            (task_param_t)NULL,
                            false,
                            &HostInterface_OkTask_task_handler
                          );

  if ( kStatus_OSA_Success != status )
  {
    catch(3);
  }

  return (osa_status_t)status;
}