コード例 #1
0
/*
 * Handle the received message and implement the action.
 * 
 * receivedMsgType  the msgType, extracted from the
 *                  received mesage.
 * pReceivedMsgBody pointer to the body part of the
 *                  received message.
 * pSendMsg         pointer to a message that we
 *                  can fill in with the response.
 * 
 * @return          SERVER_SUCCESS_KEEP_RUNNING unless
 *                  exitting in which case SERVER_EXIT_NORMALLY.
 */
static ServerReturnCode doAction (TaskHandlerMsgType receivedMsgType, UInt8 * pReceivedMsgBody, Msg *pSendMsg)
{
    ServerReturnCode returnCode = SERVER_SUCCESS_KEEP_RUNNING;
    Bool success = false;
        
    ASSERT_PARAM (pReceivedMsgBody != PNULL, (unsigned long) pReceivedMsgBody);
    ASSERT_PARAM (pSendMsg != PNULL, (unsigned long) pSendMsg);
    
    /* We always respond with the same message type */
    pSendMsg->msgType = (MsgType) receivedMsgType;
    /* Fill in the length so far */
    pSendMsg->msgLength += sizeof (pSendMsg->msgType);
    
    /* Now handle each message specifically */
    switch (receivedMsgType)
    {
        /*
         * Messages to do with the server itself
         */
        case TASK_HANDLER_SERVER_START:
        {
            success = initTaskList();
        }
        break;
        case TASK_HANDLER_SERVER_STOP:
        {
            success = clearTaskList();
            returnCode = SERVER_EXIT_NORMALLY;
        }
        break;
        /*
         * Messages to do with tasks
         */
        case TASK_HANDLER_NEW_TASK:
        {
            success = handleNewTaskReq ((RoboOneTaskReq *) pReceivedMsgBody);
        }
        break;
        case TASK_HANDLER_TICK:
        {
            success = tickTaskHandler();
        }
        break;
        default:
        {
            ASSERT_ALWAYS_PARAM (receivedMsgType);   
        }
        break;
    }

    /* Note: the following code assumes packing of 1 and that the start of a Cnf message contains the Bool 'success' */
    pSendMsg->msgBody[0] = success;
    pSendMsg->msgLength += sizeof (Bool);
    
    return returnCode;
}
コード例 #2
0
/*
 * Handle a motion oriented task.
 * 
 * pMTaskReq  pointer to the Motion task
 *            to be handled.
 * pMTaskInd  pointer a place to put the response.
 * 
 * @return    result code from RoboOneMotionResult.
 */
RoboOneMotionResult handleMotionTaskReq (RoboOneMotionTaskReq *pMotionTaskReq, RoboOneMotionTaskInd *pMotionTaskInd)
{
    RoboOneMotionResult result = MOTION_RESULT_GENERAL_FAILURE;

    ASSERT_PARAM (pMotionTaskReq != PNULL, (unsigned long) pMotionTaskReq);
    ASSERT_PARAM (pMotionTaskInd != PNULL, (unsigned long) pMotionTaskInd);
     
    printDebug ("Task Handler: Motion Protocol Task received command %d.\n", pMotionTaskReq->command);
    
    return result;
}
コード例 #3
0
/*
 * Handle a message that does a battery swap.
 * 
 * msgType          the msgType, extracted from the
 *                  received mesage.
 * pReceivedMsgBody a pointer to the data to be
 *                  passed to the battery swap
 *                  function.
 * pSendMsgBody     pointer to the relevant message
 *                  type to fill in with a response,
 *                  which will be overlaid over the
 *                  body of the response message.
 * 
 * @return          the length of the message body
 *                  to send back.
 */
static UInt16 actionSwapBattery (HardwareMsgType msgType, UInt8 *pReceivedMsgBody, UInt8 *pSendMsgBody)
{
    Bool success;
    UInt16 sendMsgBodyLength = 0;
    HardwareBatterySwapData *pBatterySwapData = PNULL;
    
    ASSERT_PARAM (pReceivedMsgBody != PNULL, (unsigned long) pReceivedMsgBody);
    ASSERT_PARAM (pSendMsgBody != PNULL, (unsigned long) pSendMsgBody);

    switch (msgType)
    {
        case HARDWARE_SWAP_RIO_BATTERY:
        {
            pBatterySwapData = &(((HardwareSwapRioBatteryReq *) pReceivedMsgBody)->batterySwapData);
            success = swapRioBattery (pBatterySwapData->systemTime, pBatterySwapData->remainingCapacity);
            ((HardwareSwapRioBatteryCnf *) pSendMsgBody)->success = success;
            sendMsgBodyLength += sizeof (((HardwareSwapRioBatteryCnf *) pSendMsgBody)->success);
        }
        break;
        case HARDWARE_SWAP_O1_BATTERY:
        {
            pBatterySwapData = &(((HardwareSwapO1BatteryReq *) pReceivedMsgBody)->batterySwapData);
            success = swapO1Battery (pBatterySwapData->systemTime, pBatterySwapData->remainingCapacity);
            ((HardwareSwapO1BatteryCnf *) pSendMsgBody)->success = success;
            sendMsgBodyLength += sizeof (((HardwareSwapO1BatteryCnf *) pSendMsgBody)->success);
        }
        break;
        case HARDWARE_SWAP_O2_BATTERY:
        {
            pBatterySwapData = &(((HardwareSwapO2BatteryReq *) pReceivedMsgBody)->batterySwapData);
            success = swapO2Battery (pBatterySwapData->systemTime, pBatterySwapData->remainingCapacity);
            ((HardwareSwapO2BatteryCnf *) pSendMsgBody)->success = success;
            sendMsgBodyLength += sizeof (((HardwareSwapO2BatteryCnf *) pSendMsgBody)->success);
        }
        break;
        case HARDWARE_SWAP_O3_BATTERY:
        {
            pBatterySwapData = &(((HardwareSwapO3BatteryReq *) pReceivedMsgBody)->batterySwapData);
            success = swapO3Battery (pBatterySwapData->systemTime, pBatterySwapData->remainingCapacity);
            ((HardwareSwapO3BatteryCnf *) pSendMsgBody)->success = success;
            sendMsgBodyLength += sizeof (((HardwareSwapO3BatteryCnf *) pSendMsgBody)->success);
        }
        break;
        default:
        {
            ASSERT_ALWAYS_PARAM (msgType);
        }
        break;
    }
    
    return sendMsgBodyLength;
}
コード例 #4
0
ファイル: ccs811.c プロジェクト: A-Paul/RIOT
int ccs811_set_int_mode(ccs811_t *dev, ccs811_int_mode_t mode)
{
    ASSERT_PARAM(dev != NULL);

    if (dev->params.int_pin == GPIO_UNDEF) {
        DEBUG_DEV("nINT pin not configured", dev);
        return CCS811_ERROR_NO_INT_PIN;
    }

    ccs811_meas_mode_reg_t reg;

    /* read measurement mode register value */
    if (_reg_read(dev, CCS811_REG_MEAS_MODE, (uint8_t *)&reg, 1) != CCS811_OK) {
        DEBUG_DEV("could not set interrupt mode, could not read register "
                  "CCS811_REG_MEAS_MODE", dev);
        return CCS811_ERROR_I2C;
    }

    reg.int_datardy = mode != CCS811_INT_NONE;
    reg.int_thresh  = mode == CCS811_INT_THRESHOLD;

    /* write back measurement mode register */
    if (_reg_write(dev, CCS811_REG_MEAS_MODE, (uint8_t *)&reg, 1) != CCS811_OK) {
        DEBUG_DEV("could not set interrupt mode, could not write register "
                  "CCS811_REG_MEAS_MODE", dev);
        return CCS811_ERROR_I2C;
    }

    dev->params.int_mode = mode;

    return CCS811_OK;
}
コード例 #5
0
ファイル: local_server.c プロジェクト: RobMeades/PiSoftware
/*
 * Handle a response from the Hindbrain.
 * 
 * pTaskInd  pointer to the Hindbrain Direct
 *           progress indication message.
 */
static void handleHDTaskInd (RoboOneHDTaskInd *pHDTaskInd)
{
    ASSERT_PARAM (pHDTaskInd != PNULL, (unsigned long) pHDTaskInd);
    
    /* Strictly speaking should semaphore access to this global data but in practice
     * it is for information only and would only occur if the user performed actions
     * inhumanly fast so is very unlikely ever to cause overlapping access */
    gRoboOneGlobals.roboOneTaskInfo.lastResultReceived = pHDTaskInd->result;
    gRoboOneGlobals.roboOneTaskInfo.lastResultReceivedIsValid = true;
    gRoboOneGlobals.roboOneTaskInfo.lastIndString[0] = 0;
    switch (pHDTaskInd->result)
    {
        case HD_RESULT_SUCCESS:
        {
            removeCtrlCharacters (&(pHDTaskInd->string[0]), &(gRoboOneGlobals.roboOneTaskInfo.lastIndString[0]));
            printDebug ("RO Server, HD Protocol: response '%s'.\n", &(gRoboOneGlobals.roboOneTaskInfo.lastIndString[0]));
        }
        break;
        case HD_RESULT_SEND_FAILURE:
        {
            printDebug ("RO Server, HD Protocol: failure to send task to Hindbrain.\n");
        }
        break;
        case HD_RESULT_GENERAL_FAILURE:
        {
            printDebug ("RO Server, HD Protocol: general failure.\n");
        }
        break;
        default:
        {
            ASSERT_ALWAYS_PARAM (pHDTaskInd->result);            
        }
        break;
    }
}
コード例 #6
0
ファイル: mobile_state.c プロジェクト: RobMeades/PiSoftware
/*
 * Handle the arrival of a task.
 * 
 * pState    pointer to the state structure.
 * pTaskReq  pointer to the new task.
 */
static void eventTasksAvailable (RoboOneState *pState, RoboOneTaskReq *pTaskReq)
{
    Bool success;
    
    ASSERT_PARAM (pState != PNULL, (unsigned long) pState);
    ASSERT_PARAM (pTaskReq != PNULL, (unsigned long) pTaskReq);

    /* Forward the task to the task handler */
    success = taskHandlerServerSendReceive (TASK_HANDLER_NEW_TASK, pTaskReq, sizeof (*pTaskReq));
    
    /* TODO: something more sensible than this */
    if (!success)
    {
        printDebug ("!!!Task handler failed to accept command!!!.\n");
    }
}
コード例 #7
0
/*
 * Handle a message that will cause us to start.
 * 
 * batteriesOnly if true, only start up the battery
 *               related items on the OneWire bus
 *               (useful when just synchronising
 *               remaining battery capacity values),
 *               otherwise setup the PIOs as well.
 * pSendMsgBody  pointer to the relevant message
 *               type to fill in with a response,
 *               which will be overlaid over the
 *               body of the response message.
 * 
 * @return       the length of the message body
 *               to send back.
 */
static UInt16 actionHardwareServerStart (Bool batteriesOnly, HardwareServerStartCnf *pSendMsgBody)
{
    Bool success;
    UInt16 sendMsgBodyLength = 0;

    ASSERT_PARAM (pSendMsgBody != PNULL, (unsigned long) pSendMsgBody);
    
   /* First of all, start up the OneWire bus */
    success = startOneWireBus();      
    if (success)
    {
        /* Find and setup the devices on the OneWire bus */
        success = setupDevices (batteriesOnly);
        if (!success)
        {
            /* If the setup fails, print out what devices we can find */
            findAllDevices();
        }
    }
    
    pSendMsgBody->success = success;
    sendMsgBodyLength += sizeof (pSendMsgBody->success);
    
    return sendMsgBodyLength;
}
コード例 #8
0
/*
 * Send a message to a client of the task handler.
 * 
 * pHeader            the header containing details
 *                    of the destination for the
 *                    response.
 * msgType            the message type to send.
 * pSendMsgBody       pointer to the body of the
 *                    REquest message to send.
 *                    May be PNULL.
 * sendMsgBodyLength  the length of the data that
 *                    pSendMsg points to.
 * 
 * @return            true if the message send is
 *                    successful otherwise false.
 */
Bool taskHandlerResponder (RoboOneTaskReqHeader *pHeader, TaskHandlerMsgType msgType, void *pSendMsgBody, UInt16 sendMsgBodyLength)
{
    ClientReturnCode returnCode;
    Bool success = false;
    Msg *pSendMsg;
    Char *pIpAddress = "127.0.0.1";

    ASSERT_PARAM (pHeader != PNULL, (unsigned long) pHeader);
    ASSERT_PARAM (msgType < MAX_NUM_TASK_HANDLER_MSGS, msgType);
    ASSERT_PARAM (sendMsgBodyLength <= MAX_MSG_BODY_LENGTH, sendMsgBodyLength);

    pSendMsg = malloc (sizeof (*pSendMsg));
    
    if (pSendMsg != PNULL)
    {
        if (pHeader->sourceServerIpAddressStringPresent)
        {
            pIpAddress = &(pHeader->sourceServerIpAddressString[0]);
        }

        /* Put in the bit before the body */
        pSendMsg->msgLength = 0;
        pSendMsg->msgType = msgType;
        pSendMsg->msgLength += sizeof (pSendMsg->msgType);
                    
        /* Put in any body to send */
        if (pSendMsgBody != PNULL)
        {
            memcpy (&pSendMsg->msgBody[0], pSendMsgBody, sendMsgBodyLength);
        }
        pSendMsg->msgLength += sendMsgBodyLength;
        
        printDebug ("TH Responder: sending message %s, length %d, to port %d, IP address %s, hex dump:\n", pgTaskHandlerMessageNames[pSendMsg->msgType], pSendMsg->msgLength, pHeader->sourceServerPort, pIpAddress);
        printHexDump (pSendMsg, pSendMsg->msgLength + 1);
        returnCode = runMessagingClient (pHeader->sourceServerPort, pIpAddress, pSendMsg, PNULL);                
        printDebug ("TH Responder: message system returnCode: %d\n", returnCode);
        if (returnCode == CLIENT_SUCCESS)
        {
            success = true;
        }

        free (pSendMsg);
    }

    return success;
}
コード例 #9
0
/**
  * @brief: USE UART2 to output debug message
  *
  */
void app_traceInfo_output(const char* fmt, ...)
{
    va_list     ap;
    _mqx_uint   err;

    err = _mutex_lock(&g_trace_mutex);
    ASSERT_PARAM(MQX_EOK == err);

    va_start(ap, fmt);
    vsnprintf((char*)output_msg, sizeof(output_msg), fmt, ap);
    va_end(ap);

    //uart0_send_string(output_msg);
		uart_send_string(UART1_BASE_PTR, output_msg);
    err = _mutex_unlock(&g_trace_mutex);
    ASSERT_PARAM(MQX_EOK == err);
}
コード例 #10
0
/*
 * Handle a whole message received from the client
 * and send back a response.
 * 
 * pReceivedMsg   a pointer to the buffer containing the
 *                incoming message.
 * pSendMsg       a pointer to a message buffer to put
 *                the response into. Not touched if return
 *                code is a failure one.
 * 
 * @return        whatever doAction() returns.
 */
ServerReturnCode serverHandleMsg (Msg *pReceivedMsg, Msg *pSendMsg)
{
    ServerReturnCode returnCode;
    
    ASSERT_PARAM (pReceivedMsg != PNULL, (unsigned long) pReceivedMsg);
    ASSERT_PARAM (pSendMsg != PNULL, (unsigned long) pSendMsg);

    /* Check the type */
    ASSERT_PARAM (pReceivedMsg->msgType < MAX_NUM_HARDWARE_MSGS, pReceivedMsg->msgType);
    
    printDebug ("HW Server received message %s, length %d.\n", pgHardwareMessageNames[pReceivedMsg->msgType], pReceivedMsg->msgLength);
    printHexDump (pReceivedMsg, pReceivedMsg->msgLength + 1);
    /* Do the thang */
    returnCode = doAction ((HardwareMsgType) pReceivedMsg->msgType, pReceivedMsg->msgBody, pSendMsg);
    printDebug ("HW Server responding with message %s, length %d.\n", pgHardwareMessageNames[pSendMsg->msgType], pSendMsg->msgLength);
        
    return returnCode;
}
コード例 #11
0
/*
 * Handle a message that reads lifetime
 * charge/discharge.
 * 
 * msgType       the msgType, extracted from the
 *               received mesage.
 * pSendMsgBody  pointer to the relevant message
 *               type to fill in with a response,
 *               which will be overlaid over the
 *               body of the response message.
 * 
 * @return       the length of the message body
 *               to send back.
 */
static UInt16 actionReadChargeDischarge (HardwareMsgType msgType, UInt8 *pSendMsgBody)
{
    Bool success;
    UInt16 sendMsgBodyLength = 0;
    HardwareChargeDischarge chargeDischarge;
    
    ASSERT_PARAM (pSendMsgBody != PNULL, (unsigned long) pSendMsgBody);

    chargeDischarge.charge = 0;
    chargeDischarge.discharge = 0;
    switch (msgType)
    {
        case HARDWARE_READ_RIO_BATT_LIFETIME_CHARGE_DISCHARGE:
        {
            success = readRioBattLifetimeChargeDischarge (&chargeDischarge.charge, &chargeDischarge.discharge);
            ((HardwareReadRioBattLifetimeChargeDischargeCnf *) pSendMsgBody)->success = success;
            sendMsgBodyLength += sizeof (((HardwareReadRioBattLifetimeChargeDischargeCnf *) pSendMsgBody)->success);
            memcpy ((&((HardwareReadRioBattLifetimeChargeDischargeCnf *) pSendMsgBody)->chargeDischarge), &chargeDischarge, sizeof (((HardwareReadRioBattLifetimeChargeDischargeCnf *) pSendMsgBody)->chargeDischarge));
            sendMsgBodyLength += sizeof (((HardwareReadRioBattLifetimeChargeDischargeCnf *) pSendMsgBody)->chargeDischarge);            
        }
        break;
        case HARDWARE_READ_O1_BATT_LIFETIME_CHARGE_DISCHARGE:
        {
            success = readO1BattLifetimeChargeDischarge (&chargeDischarge.charge, &chargeDischarge.discharge);
            ((HardwareReadO1BattLifetimeChargeDischargeCnf *) pSendMsgBody)->success = success;
            sendMsgBodyLength += sizeof (((HardwareReadO1BattLifetimeChargeDischargeCnf *) pSendMsgBody)->success);
            memcpy ((&((HardwareReadO1BattLifetimeChargeDischargeCnf *) pSendMsgBody)->chargeDischarge), &chargeDischarge, sizeof (((HardwareReadO1BattLifetimeChargeDischargeCnf *) pSendMsgBody)->chargeDischarge));
            sendMsgBodyLength += sizeof (((HardwareReadO1BattLifetimeChargeDischargeCnf *) pSendMsgBody)->chargeDischarge);            
        }
        break;
        case HARDWARE_READ_O2_BATT_LIFETIME_CHARGE_DISCHARGE:
        {
            success = readO2BattLifetimeChargeDischarge (&chargeDischarge.charge, &chargeDischarge.discharge);
            ((HardwareReadO2BattLifetimeChargeDischargeCnf *) pSendMsgBody)->success = success;
            sendMsgBodyLength += sizeof (((HardwareReadO2BattLifetimeChargeDischargeCnf *) pSendMsgBody)->success);
            memcpy ((&((HardwareReadO2BattLifetimeChargeDischargeCnf *) pSendMsgBody)->chargeDischarge), &chargeDischarge, sizeof (((HardwareReadO2BattLifetimeChargeDischargeCnf *) pSendMsgBody)->chargeDischarge));
            sendMsgBodyLength += sizeof (((HardwareReadO2BattLifetimeChargeDischargeCnf *) pSendMsgBody)->chargeDischarge);            
        }
        break;
        case HARDWARE_READ_O3_BATT_LIFETIME_CHARGE_DISCHARGE:
        {
            success = readO3BattLifetimeChargeDischarge (&chargeDischarge.charge, &chargeDischarge.discharge);
            ((HardwareReadO3BattLifetimeChargeDischargeCnf *) pSendMsgBody)->success = success;
            sendMsgBodyLength += sizeof (((HardwareReadO3BattLifetimeChargeDischargeCnf *) pSendMsgBody)->success);
            memcpy ((&((HardwareReadO3BattLifetimeChargeDischargeCnf *) pSendMsgBody)->chargeDischarge), &chargeDischarge, sizeof (((HardwareReadO3BattLifetimeChargeDischargeCnf *) pSendMsgBody)->chargeDischarge));
            sendMsgBodyLength += sizeof (((HardwareReadO3BattLifetimeChargeDischargeCnf *) pSendMsgBody)->chargeDischarge);            
        }
        break;
        default:
        {
            ASSERT_ALWAYS_PARAM (msgType);
        }
        break;
    }
    
    return sendMsgBodyLength;
}
コード例 #12
0
/*
 * Handle a message that sends a string to the 
 * Orangutan, AKA Hindbrain.
 * 
 * pString          the null terminated string to send.
 * waitForResponse  true if a response is required.
 * pSendMsgBody     pointer to the relevant message
 *                  type to fill in with a response,
 *                  which will be overlaid over the
 *                  body of the response message.
 * 
 * @return          the length of the message body
 *                  to send back.
 */
static UInt16 actionSendOString (Char *pInputString, Bool waitForResponse, HardwareSendOStringCnf *pSendMsgBody)
{
    Bool success;
    UInt16 sendMsgBodyLength = 0;
    Char *pResponseString = PNULL;
    UInt32 *pResponseStringLength = PNULL;
    Char displayBuffer[MAX_O_STRING_LENGTH];
    
    ASSERT_PARAM (pSendMsgBody != PNULL, (unsigned long) pSendMsgBody);
    ASSERT_PARAM (pInputString != PNULL, (unsigned long) pInputString);

    printDebug ("HW Server: received '%s', sending to Orangutan.\n", removeCtrlCharacters (pInputString, &(displayBuffer[0])));
    pResponseStringLength = &(pSendMsgBody->string.stringLength); 
    *pResponseStringLength = 0;
    
    if (waitForResponse)
    {
        pResponseString = &(pSendMsgBody->string.string[0]);
        *pResponseStringLength = sizeof (pSendMsgBody->string.string);
    }
    
    success = sendStringToOrangutan (pInputString, pResponseString, pResponseStringLength);
    pSendMsgBody->success = success;
    sendMsgBodyLength += sizeof (pSendMsgBody->success);
    sendMsgBodyLength += *pResponseStringLength + sizeof (*pResponseStringLength); /* Assumes packing of 1 */
    if (success)
    {
        if (pResponseString != PNULL)
        {
            printDebug ("HW Server: received '%s', back from Orangutan.\n", removeCtrlCharacters (pResponseString, &(displayBuffer[0])));
        }
        else
        {
            printDebug ("HW Server: send successful, not waiting for a response.\n");
        }
    }
    else
    {
        printDebug ("HW Server: send failed.\n");        
    }
    
    return sendMsgBodyLength;
}
コード例 #13
0
/**
  * @brief: UART2 must be init before call this function
  *
  */
void trace_init(void)
{
    _mqx_uint err;

    err = _mutex_init(&g_trace_mutex, NULL);
    ASSERT_PARAM(err == MQX_EOK);

   // init_uart0(uart0_irq_handler);
	init_uart1(uart1_irq_handler);
}
コード例 #14
0
/*
 * Handle a message that reads current.
 * 
 * msgType       the msgType, extracted from the
 *               received mesage.
 * pSendMsgBody  pointer to the relevant message
 *               type to fill in with a response,
 *               which will be overlaid over the
 *               body of the response message.
 * 
 * @return       the length of the message body
 *               to send back.
 */
static UInt16 actionReadCurrent (HardwareMsgType msgType, UInt8 *pSendMsgBody)
{
    Bool success;
    UInt16 sendMsgBodyLength = 0;
    SInt16 current = 0;
    
    ASSERT_PARAM (pSendMsgBody != PNULL, (unsigned long) pSendMsgBody);

    switch (msgType)
    {
        case HARDWARE_READ_RIO_BATT_CURRENT:
        {
            success = readRioBattCurrent (&current);
            ((HardwareReadRioBattCurrentCnf *) pSendMsgBody)->success = success;
            sendMsgBodyLength += sizeof (((HardwareReadRioBattCurrentCnf *) pSendMsgBody)->success);
            ((HardwareReadRioBattCurrentCnf *) pSendMsgBody)->current = current;
            sendMsgBodyLength += sizeof (((HardwareReadRioBattCurrentCnf *) pSendMsgBody)->current);            
        }
        break;
        case HARDWARE_READ_O1_BATT_CURRENT:
        {
            success = readO1BattCurrent (&current);
            ((HardwareReadO1BattCurrentCnf *) pSendMsgBody)->success = success;
            sendMsgBodyLength += sizeof (((HardwareReadO1BattCurrentCnf *) pSendMsgBody)->success);
            ((HardwareReadO1BattCurrentCnf *) pSendMsgBody)->current = current;
            sendMsgBodyLength += sizeof (((HardwareReadO1BattCurrentCnf *) pSendMsgBody)->current);            
        }
        break;
        case HARDWARE_READ_O2_BATT_CURRENT:
        {
            success = readO2BattCurrent (&current);
            ((HardwareReadO2BattCurrentCnf *) pSendMsgBody)->success = success;
            sendMsgBodyLength += sizeof (((HardwareReadO2BattCurrentCnf *) pSendMsgBody)->success);
            ((HardwareReadO2BattCurrentCnf *) pSendMsgBody)->current = current;
            sendMsgBodyLength += sizeof (((HardwareReadO2BattCurrentCnf *) pSendMsgBody)->current);            
        }
        break;
        case HARDWARE_READ_O3_BATT_CURRENT:
        {
            success = readO3BattCurrent (&current);
            ((HardwareReadO3BattCurrentCnf *) pSendMsgBody)->success = success;
            sendMsgBodyLength += sizeof (((HardwareReadO3BattCurrentCnf *) pSendMsgBody)->success);
            ((HardwareReadO3BattCurrentCnf *) pSendMsgBody)->current = current;
            sendMsgBodyLength += sizeof (((HardwareReadO3BattCurrentCnf *) pSendMsgBody)->current);            
        }
        break;
        default:
        {
            ASSERT_ALWAYS_PARAM (msgType);
        }
        break;
    }
    
    return sendMsgBodyLength;
}
コード例 #15
0
/*
 * Handle a message that reads remaining capacity.
 * 
 * msgType       the msgType, extracted from the
 *               received mesage.
 * pSendMsgBody  pointer to the relevant message
 *               type to fill in with a response,
 *               which will be overlaid over the
 *               body of the response message.
 * 
 * @return       the length of the message body
 *               to send back.
 */
static UInt16 actionReadRemainingCapacity (HardwareMsgType msgType, UInt8 *pSendMsgBody)
{
    Bool success;
    UInt16 sendMsgBodyLength = 0;
    UInt16 remainingCapacity = 0;
    
    ASSERT_PARAM (pSendMsgBody != PNULL, (unsigned long) pSendMsgBody);

    switch (msgType)
    {
        case HARDWARE_READ_RIO_REMAINING_CAPACITY:
        {
            success = readRioRemainingCapacity (&remainingCapacity);
            ((HardwareReadRioRemainingCapacityCnf *) pSendMsgBody)->success = success;
            sendMsgBodyLength += sizeof (((HardwareReadRioRemainingCapacityCnf *) pSendMsgBody)->success);
            ((HardwareReadRioRemainingCapacityCnf *) pSendMsgBody)->remainingCapacity = remainingCapacity;
            sendMsgBodyLength += sizeof (((HardwareReadRioRemainingCapacityCnf *) pSendMsgBody)->remainingCapacity);            
        }
        break;
        case HARDWARE_READ_O1_REMAINING_CAPACITY:
        {
            success = readO1RemainingCapacity (&remainingCapacity);
            ((HardwareReadO1RemainingCapacityCnf *) pSendMsgBody)->success = success;
            sendMsgBodyLength += sizeof (((HardwareReadO1RemainingCapacityCnf *) pSendMsgBody)->success);
            ((HardwareReadO1RemainingCapacityCnf *) pSendMsgBody)->remainingCapacity = remainingCapacity;
            sendMsgBodyLength += sizeof (((HardwareReadO1RemainingCapacityCnf *) pSendMsgBody)->remainingCapacity);            
        }
        break;
        case HARDWARE_READ_O2_REMAINING_CAPACITY:
        {
            success = readO2RemainingCapacity (&remainingCapacity);
            ((HardwareReadO2RemainingCapacityCnf *) pSendMsgBody)->success = success;
            sendMsgBodyLength += sizeof (((HardwareReadO2RemainingCapacityCnf *) pSendMsgBody)->success);
            ((HardwareReadO2RemainingCapacityCnf *) pSendMsgBody)->remainingCapacity = remainingCapacity;
            sendMsgBodyLength += sizeof (((HardwareReadO2RemainingCapacityCnf *) pSendMsgBody)->remainingCapacity);            
        }
        break;
        case HARDWARE_READ_O3_REMAINING_CAPACITY:
        {
            success = readO3RemainingCapacity (&remainingCapacity);
            ((HardwareReadO3RemainingCapacityCnf *) pSendMsgBody)->success = success;
            sendMsgBodyLength += sizeof (((HardwareReadO3RemainingCapacityCnf *) pSendMsgBody)->success);
            ((HardwareReadO3RemainingCapacityCnf *) pSendMsgBody)->remainingCapacity = remainingCapacity;
            sendMsgBodyLength += sizeof (((HardwareReadO3RemainingCapacityCnf *) pSendMsgBody)->remainingCapacity);            
        }
        break;
        default:
        {
            ASSERT_ALWAYS_PARAM (msgType);
        }
        break;
    }
    
    return sendMsgBodyLength;
}
コード例 #16
0
/*
 * Handle a message that reads temperature.
 * 
 * msgType       the msgType, extracted from the
 *               received mesage.
 * pSendMsgBody  pointer to the relevant message
 *               type to fill in with a response,
 *               which will be overlaid over the
 *               body of the response message.
 * 
 * @return       the length of the message body
 *               to send back.
 */
static UInt16 actionReadTemperature (HardwareMsgType msgType, UInt8 *pSendMsgBody)
{
    Bool success;
    UInt16 sendMsgBodyLength = 0;
    double temperature = 0;
    
    ASSERT_PARAM (pSendMsgBody != PNULL, (unsigned long) pSendMsgBody);

    switch (msgType)
    {
        case HARDWARE_READ_RIO_BATT_TEMPERATURE:
        {
            success = readRioBattTemperature (&temperature);
            ((HardwareReadRioBattTemperatureCnf *) pSendMsgBody)->success = success;
            sendMsgBodyLength += sizeof (((HardwareReadRioBattTemperatureCnf *) pSendMsgBody)->success);
            ((HardwareReadRioBattTemperatureCnf *) pSendMsgBody)->temperature = temperature;
            sendMsgBodyLength += sizeof (((HardwareReadRioBattTemperatureCnf *) pSendMsgBody)->temperature);            
        }
        break;
        case HARDWARE_READ_O1_BATT_TEMPERATURE:
        {
            success = readO1BattTemperature (&temperature);
            ((HardwareReadO1BattTemperatureCnf *) pSendMsgBody)->success = success;
            sendMsgBodyLength += sizeof (((HardwareReadO1BattTemperatureCnf *) pSendMsgBody)->success);
            ((HardwareReadO1BattTemperatureCnf *) pSendMsgBody)->temperature = temperature;
            sendMsgBodyLength += sizeof (((HardwareReadO1BattTemperatureCnf *) pSendMsgBody)->temperature);            
        }
        break;
        case HARDWARE_READ_O2_BATT_TEMPERATURE:
        {
            success = readO2BattTemperature (&temperature);
            ((HardwareReadO2BattTemperatureCnf *) pSendMsgBody)->success = success;
            sendMsgBodyLength += sizeof (((HardwareReadO2BattTemperatureCnf *) pSendMsgBody)->success);
            ((HardwareReadO2BattTemperatureCnf *) pSendMsgBody)->temperature = temperature;
            sendMsgBodyLength += sizeof (((HardwareReadO2BattTemperatureCnf *) pSendMsgBody)->temperature);            
        }
        break;
        case HARDWARE_READ_O3_BATT_TEMPERATURE:
        {
            success = readO3BattTemperature (&temperature);
            ((HardwareReadO3BattTemperatureCnf *) pSendMsgBody)->success = success;
            sendMsgBodyLength += sizeof (((HardwareReadO3BattTemperatureCnf *) pSendMsgBody)->success);
            ((HardwareReadO3BattTemperatureCnf *) pSendMsgBody)->temperature = temperature;
            sendMsgBodyLength += sizeof (((HardwareReadO3BattTemperatureCnf *) pSendMsgBody)->temperature);            
        }
        break;
        default:
        {
            ASSERT_ALWAYS_PARAM (msgType);
        }
        break;
    }
    
    return sendMsgBodyLength;
}
コード例 #17
0
/*
 * Handle a message that reads voltage.
 * 
 * msgType       the msgType, extracted from the
 *               received mesage.
 * pSendMsgBody  pointer to the relevant message
 *               type to fill in with a response,
 *               which will be overlaid over the
 *               body of the response message.
 * 
 * @return       the length of the message body
 *               to send back.
 */
static UInt16 actionReadVoltage (HardwareMsgType msgType, UInt8 *pSendMsgBody)
{
    Bool success;
    UInt16 sendMsgBodyLength = 0;
    UInt16 voltage = 0;
    
    ASSERT_PARAM (pSendMsgBody != PNULL, (unsigned long) pSendMsgBody);

    switch (msgType)
    {
        case HARDWARE_READ_RIO_BATT_VOLTAGE:
        {
            success = readRioBattVoltage (&voltage);
            ((HardwareReadRioBattVoltageCnf *) pSendMsgBody)->success = success;
            sendMsgBodyLength += sizeof (((HardwareReadRioBattVoltageCnf *) pSendMsgBody)->success);
            ((HardwareReadRioBattVoltageCnf *) pSendMsgBody)->voltage = voltage;
            sendMsgBodyLength += sizeof (((HardwareReadRioBattVoltageCnf *) pSendMsgBody)->voltage);            
        }
        break;
        case HARDWARE_READ_O1_BATT_VOLTAGE:
        {
            success = readO1BattVoltage (&voltage);
            ((HardwareReadO1BattVoltageCnf *) pSendMsgBody)->success = success;
            sendMsgBodyLength += sizeof (((HardwareReadO1BattVoltageCnf *) pSendMsgBody)->success);
            ((HardwareReadO1BattVoltageCnf *) pSendMsgBody)->voltage = voltage;
            sendMsgBodyLength += sizeof (((HardwareReadO1BattVoltageCnf *) pSendMsgBody)->voltage);            
        }
        break;
        case HARDWARE_READ_O2_BATT_VOLTAGE:
        {
            success = readO2BattVoltage (&voltage);
            ((HardwareReadO2BattVoltageCnf *) pSendMsgBody)->success = success;
            sendMsgBodyLength += sizeof (((HardwareReadO2BattVoltageCnf *) pSendMsgBody)->success);
            ((HardwareReadO2BattVoltageCnf *) pSendMsgBody)->voltage = voltage;
            sendMsgBodyLength += sizeof (((HardwareReadO2BattVoltageCnf *) pSendMsgBody)->voltage);            
        }
        break;
        case HARDWARE_READ_O3_BATT_VOLTAGE:
        {
            success = readO3BattVoltage (&voltage);
            ((HardwareReadO3BattVoltageCnf *) pSendMsgBody)->success = success;
            sendMsgBodyLength += sizeof (((HardwareReadO3BattVoltageCnf *) pSendMsgBody)->success);
            ((HardwareReadO3BattVoltageCnf *) pSendMsgBody)->voltage = voltage;
            sendMsgBodyLength += sizeof (((HardwareReadO3BattVoltageCnf *) pSendMsgBody)->voltage);            
        }
        break;
        default:
        {
            ASSERT_ALWAYS_PARAM (msgType);
        }
        break;
    }
    
    return sendMsgBodyLength;
}
コード例 #18
0
ファイル: ccs811.c プロジェクト: A-Paul/RIOT
int ccs811_power_up (ccs811_t *dev)
{
    ASSERT_PARAM(dev != NULL);

    if (dev->params.wake_pin != GPIO_UNDEF) {
        DEBUG_DEV("Setting nWAKE pin low", dev);
        gpio_clear(dev->params.wake_pin);
    }

    return ccs811_set_mode(dev, dev->params.mode);
}
コード例 #19
0
ファイル: ccs811.c プロジェクト: A-Paul/RIOT
int ccs811_read_ntc(const ccs811_t *dev, uint32_t r_ref, uint32_t *r_ntc)
{
    ASSERT_PARAM(dev != NULL);
    ASSERT_PARAM(r_ntc != NULL);

    uint8_t data[4];

    /* read baseline register */
    if (_reg_read(dev, CCS811_REG_NTC, data, 4) != CCS811_OK) {
        DEBUG_DEV("could not read the V_REF and V_NTC "
                  "from register CCS811_REG_NTC", dev);
        return -CCS811_ERROR_I2C;
    }

    /* calculation from application note ams AN000372 */
    uint32_t v_ref = (uint16_t)(data[0]) << 8 | data[1];
    uint32_t v_ntc = (uint16_t)(data[2]) << 8 | data[3];

    *r_ntc = v_ntc * r_ref / v_ref;
    return CCS811_OK;
}
コード例 #20
0
/*
 * Handle a whole message received from the client
 * and send back a response.
 * 
 * pReceivedMsg   a pointer to the buffer containing the
 *                incoming message.
 * pSendMsg       a pointer to a message buffer to put
 *                the response into. Not touched if return
 *                code is a failure one.
 * 
 * @return        whatever doAction() returns.
 */
ServerReturnCode serverHandleMsg (Msg *pReceivedMsg, Msg *pSendMsg)
{
    ServerReturnCode returnCode;
    
    ASSERT_PARAM (pReceivedMsg != PNULL, (unsigned long) pReceivedMsg);
    ASSERT_PARAM (pSendMsg != PNULL, (unsigned long) pSendMsg);

    /* Check the type */
    ASSERT_PARAM (pReceivedMsg->msgType < MAX_NUM_TASK_HANDLER_MSGS, pReceivedMsg->msgType);
    
    printDebug ("TH Server received message %s, length %d.\n", pgTaskHandlerMessageNames[pReceivedMsg->msgType], pReceivedMsg->msgLength);
    printHexDump (pReceivedMsg, pReceivedMsg->msgLength + 1);
    /* Do the thang */
    returnCode = doAction ((TaskHandlerMsgType) pReceivedMsg->msgType, pReceivedMsg->msgBody, pSendMsg);
    if (pSendMsg->msgLength > 0)
    {
        printDebug ("TH Server responding with message %s, length %d.\n", pgTaskHandlerMessageNames[pSendMsg->msgType], pSendMsg->msgLength);
    }
        
    return returnCode;
}
コード例 #21
0
ファイル: timer_server.c プロジェクト: RobMeades/PiSoftware
/*
 * Handle a whole message received from the client.
 * 
 * pReceivedMsg   a pointer to the buffer containing the
 *                incoming message.
 * pSendMsg       a pointer to a message buffer to put
 *                the response into, may be PNULL as
 *                this server never sends responses.
 * 
 * @return        whatever doAction() returns.
 */
ServerReturnCode serverHandleMsg (Msg *pReceivedMsg, Msg *pSendMsg)
{
    ServerReturnCode returnCode;
    
    ASSERT_PARAM (pReceivedMsg != PNULL, (unsigned long) pReceivedMsg);

    /* Never return any confirmations so set this length to zero */ 
    if (pSendMsg != PNULL)
    {
        pSendMsg->msgLength = 0;
    }
    
    /* Check the type */
    ASSERT_PARAM (pReceivedMsg->msgType < MAX_NUM_TIMER_MSGS, pReceivedMsg->msgType);
    
    printDebug ("T  Server received message %s, length %d.\n", pgTimerMessageNames[pReceivedMsg->msgType], pReceivedMsg->msgLength);
    printHexDump (pReceivedMsg, pReceivedMsg->msgLength + 1);
    /* Do the thang */
    returnCode = doAction ((TimerMsgType) pReceivedMsg->msgType, pReceivedMsg->msgBody);
        
    return returnCode;
}
コード例 #22
0
ファイル: lptmr.c プロジェクト: ethan-jiang-1/hello_starfish
void Lptmr_Init(int count, int clock_source)
{
	 _mqx_uint       mqx_ret;
    SIM_SCGC5 |= SIM_SCGC5_LPTMR_MASK;
	
	SIM_SOPT1 &= ~SIM_SOPT1_OSC32KSEL_MASK;
    SIM_SOPT1 |= SIM_SOPT1_OSC32KSEL(2); // ERCLK32 is RTC OSC CLOCK
	
	PORTC_PCR1 &= ~PORT_PCR_MUX_MASK;
	PORTC_PCR1 |= PORT_PCR_MUX(1);//enable ptc1 alt1 functions to select RTC_CLKIN function
	
	/********************************************************************************* 
	*	On L2K tower board, we use external 32kHz clock instead of 32kHz crystal, so please
	*	don't enable the 32kHz crystal oscillator 
	**********************************************************************************/
	/*
	RTC_CR |= RTC_CR_OSCE_MASK |
              RTC_CR_CLKO_MASK |
              RTC_CR_SC8P_MASK  ;	*/

	LPTMR0_PSR &= ~LPTMR_PSR_PRESCALE_MASK;
    LPTMR0_PSR |=  LPTMR_PSR_PRESCALE(0); // 0000 is div 2
    LPTMR0_PSR |= LPTMR_PSR_PBYP_MASK;  // LPO feeds directly to LPT
    LPTMR0_PSR &= ~LPTMR_PSR_PCS_MASK;
	LPTMR0_PSR |= LPTMR_PSR_PCS(clock_source); // use the choice of clock
	
    if (clock_source== 0)
      APP_TRACE("\n LPTMR Clock source is the MCGIRCLK \n\r");
    if (clock_source== 1)
      APP_TRACE("\n LPTMR Clock source is the LPOCLK \n\r");
    if (clock_source== 2)
      APP_TRACE("\n LPTMR Clock source is the ERCLK32 \n\r");
    if (clock_source== 3)
      APP_TRACE("\n LPTMR Clock source is the OSCERCLK \n\r");
             
    LPTMR0_CMR = LPTMR_CMR_COMPARE(count);  //Set compare value

    LPTMR0_CSR |=(  LPTMR_CSR_TCF_MASK   // Clear any pending interrupt
                 | LPTMR_CSR_TIE_MASK   // LPT interrupt enabled
                 |!LPTMR_CSR_TPP_MASK   //TMR Pin polarity
                 |!LPTMR_CSR_TFC_MASK   // Timer Free running counter is reset whenever TMR counter equals compare
                 |!LPTMR_CSR_TMS_MASK   //LPTMR0 as Timer
                );
		enable_irq(28) ;
		_int_install_isr(LDD_ivIndex_INT_LPTimer, lptmr_isr, NULL);
		    mqx_ret = _lwsem_create(&g_lptmr_int_sem, 0);
    ASSERT_PARAM(MQX_OK == mqx_ret);
//				   // ready for this interrupt.  
//		set_irq_priority(28, 2);
	
}
コード例 #23
0
ファイル: ccs811.c プロジェクト: A-Paul/RIOT
int ccs811_power_down (ccs811_t *dev)
{
    ASSERT_PARAM(dev != NULL);

    ccs811_mode_t tmp_mode = dev->params.mode;
    int res = ccs811_set_mode(dev, CCS811_MODE_IDLE);
    dev->params.mode = tmp_mode;

    if (dev->params.wake_pin != GPIO_UNDEF) {
        DEBUG_DEV("Setting nWAKE pin high", dev);
        gpio_set(dev->params.wake_pin);
    }

    return res;
}
コード例 #24
0
/*
 * Handle a message that reads the general
 * purpose IO pins
 * 
 * pSendMsgBody  pointer to the relevant message
 *               type to fill in with a response,
 *               which will be overlaid over the
 *               body of the response message.
 * 
 * @return       the length of the message body
 *               to send back.
 */
static UInt16 actionReadGeneralPurposeIOs (HardwareReadGeneralPurposeIOsCnf *pSendMsgBody)
{
    Bool success;
    UInt16 sendMsgBodyLength = 0;
    UInt8 pinsState = 0;
    
    ASSERT_PARAM (pSendMsgBody != PNULL, (unsigned long) pSendMsgBody);

    success = readGeneralPurposeIOs (&pinsState);
    pSendMsgBody->success = success;
    sendMsgBodyLength += sizeof (pSendMsgBody->success);
    pSendMsgBody->pinsState = pinsState;
    sendMsgBodyLength += sizeof (pSendMsgBody->pinsState);            
    
    return sendMsgBodyLength;
}
コード例 #25
0
/*
 * Handle a message that will cause us to stop.
 * 
 * pSendMsgBody  pointer to the relevant message
 *               type to fill in with a response,
 *               which will be overlaid over the
 *               body of the response message.
 * 
 * @return       the length of the message body
 *               to send back.
 */
static UInt16 actionHardwareServerStop (HardwareServerStopCnf *pSendMsgBody)
{
    UInt16 sendMsgBodyLength = 0;

    ASSERT_PARAM (pSendMsgBody != PNULL, (unsigned long) pSendMsgBody);
    
    /* Shut the OneWire stuff down gracefully */
    stopOneWireBus ();
    
    /* Shut the Orangutan down in case it was up */
    closeOrangutan();
    
    pSendMsgBody->success = true;
    sendMsgBodyLength += sizeof (pSendMsgBody->success);
    
    return sendMsgBodyLength;
}
コード例 #26
0
ファイル: local_server.c プロジェクト: RobMeades/PiSoftware
/*
 * Handle an indication of task progress.
 * 
 * pTaskInd  pointer to the task indication
 *           to be handled.
 */
static void handleTaskInd (RoboOneTaskInd *pTaskInd)
{
    ASSERT_PARAM (pTaskInd != PNULL, (unsigned long) pTaskInd);

    switch (pTaskInd->body.protocol)
    {
        /* Only the Hindbrain Direct protocol is used by this program */
        case TASK_PROTOCOL_HD:
        {
            handleHDTaskInd ((RoboOneHDTaskInd *) &(pTaskInd->body.detail.hdInd));
        }
        break;
        default:
        {
            ASSERT_ALWAYS_PARAM (pTaskInd->body.protocol);   
        }
        break;
    }
}
コード例 #27
0
ファイル: timer_server.c プロジェクト: RobMeades/PiSoftware
/*
 * Send a timer expiry message.
 * 
 * pTimer   the timer related to the
 *          expiry message to send.
 * 
 * @return  true if the message send is
 *          is successful, otherwise false.
 */
static Bool sendTimerExpiryMsg (Timer *pTimer)
{
    ClientReturnCode returnCode;
    Bool success = false;

    ASSERT_PARAM (pTimer != PNULL, (unsigned long) pTimer); 

    printDebug ("Timer Server: sending expiry message to port %d, msgType 0x%08x, length %d, hex dump:\n", pTimer->sourcePort, pTimer->expiryMsg.msgType, pTimer->expiryMsg.msgLength);
    printHexDump (&(pTimer->expiryMsg), pTimer->expiryMsg.msgLength + 1);
    returnCode = runMessagingClient (pTimer->sourcePort, PNULL, &(pTimer->expiryMsg), PNULL);
                
    printDebug ("Timer Server: message system returnCode: %d\n", returnCode);
    if (returnCode == CLIENT_SUCCESS)
    { 
        success = true;
    }

    return success;
}
コード例 #28
0
/*
 * Handle a message that reads the charge state.
 * 
 * pSendMsgBody  pointer to the relevant message
 *               type to fill in with a response,
 *               which will be overlaid over the
 *               body of the response message.
 * 
 * @return       the length of the message body
 *               to send back.
 */
static UInt16 actionReadChargerState (HardwareReadChargerStateCnf *pSendMsgBody)
{
    Bool success;
    UInt16 sendMsgBodyLength = 0;
    HardwareChargeState chargeState;
    
    chargeState.flashDetectPossible = false;
    memset (&chargeState.state, 0, sizeof (chargeState.state));
    
    ASSERT_PARAM (pSendMsgBody != PNULL, (unsigned long) pSendMsgBody);
    
    success = readChargerState (&(chargeState.state[0]), &chargeState.flashDetectPossible);
    pSendMsgBody->success = success;
    sendMsgBodyLength += sizeof (pSendMsgBody->success);
    memcpy (&(pSendMsgBody->chargeState), &chargeState, sizeof (pSendMsgBody->chargeState));
    sendMsgBodyLength += sizeof (pSendMsgBody->chargeState);
    
    return sendMsgBodyLength;
}
コード例 #29
0
/**
  * @brief: init MMA8451 INT1 interrupt pin
  * @note:  PTA14
  *         PULL UP
  *         Interrupt on falling edge
  *
  */
void    init_MMA8451_interrupt(void)
{
    INT_ISR_FPTR isr;

    // PTA14 -- MMA8451 INT1
    // ALT1
    /* PORTA_PCR14: ISF=0, MUX=1, IQRC=0x0A(1010), PE=1, PS=1 */
		/*zga: in kl25, this pin is connected from chip to mcu*/
		/*But in our cup design, pta5 is used as interrupt pin*/
   // PORTA_PCR14 = 0x000A0103;
    //GPIOA_PDDR &= ~(1<<14);
	  PORTA_PCR5  = 0x000A0103;                                
		GPIOA_PDDR &= ~(1<<5);
    isr = _int_install_isr(LDD_ivIndex_INT_PORTA, MMA8451_INT1_isr_service, NULL);
    ASSERT_PARAM(isr != NULL);

    // ENABLE PTE5 Falling interrupt
    enable_irq(30);
    set_irq_priority(30, 2);
}
コード例 #30
0
ファイル: local_server.c プロジェクト: RobMeades/PiSoftware
/*
 * Handle the received message and implement the action.
 * 
 * receivedMsgType  the msgType, extracted from the
 *                  received mesage.
 * pReceivedMsgBody pointer to the body part of the
 *                  received message.
 * 
 * @return          Always SERVER_SUCCESS_KEEP_RUNNING.
 */
static ServerReturnCode doAction (TaskHandlerMsgType receivedMsgType, UInt8 * pReceivedMsgBody)
{
    ASSERT_PARAM (pReceivedMsgBody != PNULL, (unsigned long) pReceivedMsgBody);
    
    /* Now handle each message specifically */
    switch (receivedMsgType)
    {
        case TASK_HANDLER_TASK_IND:
        {
            handleTaskInd ((RoboOneTaskInd *) pReceivedMsgBody);
        }
        break;
        default:
        {
            ASSERT_ALWAYS_PARAM (receivedMsgType);   
        }
        break;
    }

    return SERVER_SUCCESS_KEEP_RUNNING;
}