Esempio n. 1
0
/*********************************************************************
 * @fn      HeartRate_clockHandler
 *
 * @brief   Handler function for clock timeouts.
 *
 * @param   none
 *
 * @return  none
 */
static void HeartRate_clockHandler(UArg arg)
{ 
  // Store the event.
  events |= arg;
  
  // Wake up the application.
  Semaphore_post(sem);
}
/*********************************************************************
 * @fn      CyclingSensor_controlPointCB
 *
 * @brief   Cycling service control point was written.  Set an event
 *          to send out an indication to the client after the write
 *          response is sent.
 *
 * @param   none
 *
 * @ret     none
 */
static void CyclingSensor_controlPointCB(void)
{
  // Set the event.
  events |= CSC_CMD_SEND_IND_EVT;
  
  // Post the application's semaphore.
  Semaphore_post(sem);
}
/*
 *  ======== Adaptor_freePacket ========
 *  Function called by a service to "free" a packet.
 */
Void Adaptor_freePacket(UIAPacket_Hdr *packet)
{
    Queue_Elem *elem;
    UIAPacket_HdrType type = UIAPacket_getHdrType(packet);

    elem = (Queue_Elem *)((UInt)packet - sizeof(Queue_Elem));

    /* Determine the type of header to place on the correct queue */
    if (type == UIAPacket_HdrType_EventPkt) {
        Queue_put(Adaptor_module->freeEventQ, elem);
        Semaphore_post(Adaptor_module->freeEventSem);
    }
    else {
        Queue_put(Adaptor_module->freeMsgQ, elem);
        Semaphore_post(Adaptor_module->freeMsgSem);
    }
}
Esempio n. 4
0
/*********************************************************************
 * @fn      SimpleBLEPeripheral_clockHandler
 *
 * @brief   Handler function for clock timeouts.
 *
 * @param   arg - event type
 *
 * @return  None.
 */
static void SimpleBLEPeripheral_clockHandler(UArg arg)
{
  // Store the event.
  events |= arg;

  // Wake up the application.
  Semaphore_post(sem);
}
void SW1_IRQHandler(void){
	uint32_t status;
	status = MAP_GPIO_getEnabledInterruptStatus(GPIO_PORT_P5);
	_delay_cycles(3000000);
	MAP_GPIO_clearInterruptFlag(GPIO_PORT_P5, status);

	Semaphore_post(Button_Semaphore);
}
Esempio n. 6
0
/*********************************************************************
 * @fn      trainingTag_clockHandler
 *
 * @brief   Handler function for clock timeouts.
 *
 * @param   arg - event type
 *
 * @return  None.
 */
static void trainingTag_clockHandler(UArg arg)
{
  // Store the event.
  events |= arg;

  // Wake up the application.
  Semaphore_post(sem);
}
Esempio n. 7
0
uint8_t USBCDC_handleReceiveCompleted(uint8_t intfNum)
{
    if (intfNum == USBCDCD_INTFNUM) {
        Semaphore_post(semRxSerial);
        Log_print0(Diags_USER1, "USB: USBCDC_handleReceiveCompleted");
    }
    return (true);
}
/*********************************************************************
 * @fn      CyclingSensor_clockHandler
 *
 * @brief   Clock handle for all clock events.  This function stores an event 
 *          flag and wakes up the application's event processor.
 *
 * @param   arg - event flag.
 *
 * @return  none
 */
static void CyclingSensor_clockHandler(UArg arg)
{
  // Store the event.
  events |= arg;
  
  // Wake up the application.
  Semaphore_post(sem);
}
Esempio n. 9
0
/*
 *  ======== cbFxn ========
 *  This function was registered with Notify. It is called when any event is
 *  sent to this processor.
 */
Void cbFxn(UInt16 procId, UInt16 lineId,
           UInt32 eventId, UArg arg, UInt32 payload)
{
    /* The payload is a sequence number. */
    recvProcId = procId;
    seq = payload;
    Semaphore_post(semHandle);
}
Esempio n. 10
0
// Idle function that starts uart capture and adc capture
void start_button()
{
	if ((P1IN & BIT4) == 0) {
    P1OUT &= ~BIT0;
		P2OUT |= BIT1;
		Semaphore_post(start_data_semaphore);// unbock uart
	}

}
/*******************************************************************************
 * @fn		SensorTag_clockHandler
 *
 * @brief	Handler function for clock time-outs.
 *
 * @param	arg - event type
 *
 * @return	none
 */
static void userApp_clockHandler(UArg arg)
{
	// Store the event.
	userEvents |= arg;

	// Wake up the application.
	//Semaphore_post(userSem);
	Semaphore_post(sem);
}
Esempio n. 12
0
/*
 *  ======== DSKT2_releaseLock ========
 *  Releases the semaphore lock on a particular scratch group.
 */
Void DSKT2_releaseLock(Int scratchId)
{
    /*
     * Release the lock
     */
    if ((scratchId >= 0) && (scratchId < DSKT2_NUM_SCRATCH_GROUPS)) {
        Semaphore_post(_locks[scratchId]);
    }
}
Esempio n. 13
0
/*!
 * ======== OffloadM3_processSysM3Tasks ========
 *
 * Process the different Offload request messages on SysM3. Signal the
 * appropriate tasks for executing the functions to be offloaded.
 */
Int OffloadM3_processSysM3Tasks(UArg msg)
{
    UInt index = (UInt)msg - RP_MSG_OFFLOAD_BASE;
    if (index >= OFFLOAD_MAX_IDX)
        return 0;

    Semaphore_post(module.semaphores[index]);
    return 1;
}
Esempio n. 14
0
/*
 *  ======== IpcPower_suspend ========
 */
Void IpcPower_suspend()
{
    Assert_isTrue((curInit > 0) , NULL);

#ifndef SMP
    Semaphore_post(IpcPower_semSuspend);
#else
    Swi_post(suspendResumeSwi);
#endif
}
Esempio n. 15
0
Int32 System_unlockVip(UInt32 vipInst)
{

   if (vipInst < SYSTEM_VIP_MAX)
   {
       Semaphore_post(gSystem_objVpss.vipLock[vipInst]);
   }

   return FVID2_SOK;
}
Esempio n. 16
0
/*
 *  ======== SemProcessSupport_post ========
 */
Bool SemProcessSupport_post(SemProcessSupport_Handle sem, 
    Error_Block *eb)
{
    Semaphore_Handle bios6sem;
 
    bios6sem = SemProcessSupport_Instance_State_sem(sem);
    Semaphore_post(bios6sem);

    return (TRUE);
}
Esempio n. 17
0
/*
 *  ======== idl0Fxn ========
 */
Void idl0Fxn()
{
    Log_info0("Entering idl0Fxn.");

    Semaphore_post(sem0);

    Log_info0("Exiting idl0Fxn.");

    BIOS_exit(0);
}
Esempio n. 18
0
File: comm.c Progetto: fcovatti/iccp
int send_digital_to_ihm(int socketfd, struct sockaddr_in * server_sock_addr,unsigned int nponto, unsigned char ihm_station, unsigned char state, time_t time_stamp,unsigned short time_stamp_extended, char report){
	//struct tm * time_result;
	struct tm time_result = {0};

	t_msgsup msg_sup;
	unsigned char digital_state;

	memset(&msg_sup, 0, sizeof(t_msgsup));
	msg_sup.signature = IHM_SINGLE_POINT_SIGN;
	msg_sup.endereco = nponto;
	msg_sup.prim = ihm_station;
	
	digital_state = get_digital_state(state);

	//only send as report if timestamp is valid
	if(report && time_stamp != 0xffffffff){
		digital_w_time7_seq digital_value;
		msg_sup.causa=3; //report
		msg_sup.tipo=30;
		msg_sup.taminfo=sizeof(digital_w_time7_seq);
		digital_value.iq = digital_state;
		//time_result = (struct tm *)localtime(&time_stamp);
		//
		Semaphore_wait(localtime_mutex);	
		if(localtime_r(&time_stamp, &time_result) == 0){
			LOG_MESSAGE("error obtaining localtime nponto %d, time_stamp %d, extended %d \n", nponto, time_stamp, time_stamp_extended);
		}
		Semaphore_post(localtime_mutex);	

		digital_value.ms=(time_result.tm_sec*1000)+time_stamp_extended;
		digital_value.min=time_result.tm_min;
		digital_value.hora=time_result.tm_hour;
		digital_value.dia=time_result.tm_mday;
		digital_value.mes=time_result.tm_mon+1;
		if(time_result.tm_year >=100)
			digital_value.ano=time_result.tm_year-100;
		else
			digital_value.ano=time_result.tm_year;
		memcpy(msg_sup.info,(char *) &digital_value, sizeof(digital_w_time7_seq));
	}
	else {
		digital_seq digital_value_gi;
		msg_sup.tipo=1;
		if(report){
			msg_sup.causa=3; //report
			LOG_MESSAGE("report with invalid timestamp nponto %d, time_stamp %d, extended %d \n", nponto, time_stamp, time_stamp_extended);
		}else
			msg_sup.causa=20; //integrity
		msg_sup.taminfo=sizeof(digital_seq);
		digital_value_gi.iq = digital_state;
		memcpy(msg_sup.info,(char *) &digital_value_gi, sizeof(digital_seq));
	}
	
	return SendT(socketfd,(void *)&msg_sup, sizeof(t_msgsup), server_sock_addr);
}
Esempio n. 19
0
/*
 *  ======== GateMutex_leave ========
 *  Only releases the gate if key == FIRST_ENTER.
 */
Void GateMutex_leave(GateMutex_Object *obj, IArg key)
{
    Semaphore_Handle sem;

    /* If this is the outermost call to leave, then post the semaphore. */
    if (key == FIRST_ENTER) {
        obj->owner = NULL;
        sem = GateMutex_Instance_State_sem(obj);
        Semaphore_post(sem);
    }
}
Esempio n. 20
0
IedConnectionState
IedConnection_getState(IedConnection self)
{
    IedConnectionState state;

    Semaphore_wait(self->stateMutex);
    state = self->state;
    Semaphore_post(self->stateMutex);

    return state;
}
Esempio n. 21
0
/*******************************************************************************
 * @fn      SensorTagMultiRoleTest_scanStartHandler
 *
 * @brief   Handler function for clock time-outs.
 *
 * @param   arg - event type
 *
 * @return  none
 */
static void SensorTagMultiRoleTest_scanStartHandler(UArg arg)
{
	// Store the event.
	events |= arg;

	// we don't want to do work here, though, because of the priority problem
	// so once we've posted the event, wake up the application and let the app thread do the work

	// Wake up the application.
	Semaphore_post(sem);
}
Esempio n. 22
0
void adcIsr(UArg a0) {

  // Pop sample from FIFO to allow clearing ADC_IRQ event
  singleSample = AUXADCReadFifo();
  // Clear ADC_IRQ flag. Note: Missing driver for this.
  HWREGBITW(AUX_EVCTL_BASE + AUX_EVCTL_O_EVTOMCUFLAGSCLR, AUX_EVCTL_EVTOMCUFLAGSCLR_ADC_IRQ_BITN) = 1;

  // Post semaphore to wakeup task
  Semaphore_post(hSem);

}
Esempio n. 23
0
Int32 DupLink_putEmptyFrames(Utils_TskHndl * pTsk, UInt16 queId,
                             FVID2_FrameList * pFrameList)
{
    DupLink_Obj *pObj = (DupLink_Obj *) pTsk->appData;
    FVID2_FrameList freeFrameList;
    UInt32 frameId;
    FVID2_Frame *pFrame, *pOrgFrame;
    System_FrameInfo *pFrameInfo, *pOrgFrameInfo;
    Int32 status;

    UTILS_assert(queId < DUP_LINK_MAX_OUT_QUE);
    UTILS_assert(queId < pObj->createArgs.numOutQue);

    freeFrameList.numFrames = 0;

    Semaphore_pend(pObj->lock, BIOS_WAIT_FOREVER);

    for (frameId = 0; frameId < pFrameList->numFrames; frameId++)
    {
        pFrame = pFrameList->frames[frameId];
        if (pFrame == NULL)
            continue;

        pFrameInfo = (System_FrameInfo *) pFrame->appData;
        UTILS_assert(pFrameInfo != NULL);

        pOrgFrame = pFrameInfo->pDupOrgFrame;
        UTILS_assert(pOrgFrame != NULL);

        pOrgFrameInfo = (System_FrameInfo *) pOrgFrame->appData;
        UTILS_assert(pOrgFrameInfo != NULL);

        pOrgFrameInfo->dupCount--;

        if (pOrgFrameInfo->dupCount == 0)
        {
            freeFrameList.frames[freeFrameList.numFrames] = pOrgFrame;
            freeFrameList.numFrames++;
        }
    }

    pObj->putFrameCount += freeFrameList.numFrames;

    System_putLinksEmptyFrames(pObj->createArgs.inQueParams.prevLinkId,
                               pObj->createArgs.inQueParams.prevLinkQueId,
                               &freeFrameList);

    Semaphore_post(pObj->lock);

    status = Utils_bufPutEmpty(&pObj->outFrameQue[queId], pFrameList);
    UTILS_assert(status == FVID2_SOK);

    return FVID2_SOK;
}
Esempio n. 24
0
/*
 *  ======== Lck_post ========
 */
Void Lck_post(Lck_Object *lock)
{
    Semaphore_Handle sem;

    if (--lock->value == 0) {
        lock->owner = NULL;

        sem = Lck_Instance_State_sem(lock);
        Semaphore_post(sem);
    }
}
Esempio n. 25
0
/*
 *  ======== pthread_exit ========
 */
void pthread_exit(void *retval)
{
    pthread_Obj      *thread = (pthread_Obj *)pthread_self();

    /*
     *  This function terminates the calling thread and returns
     *  a value via retval that (if the thread is joinable) is available to
     *  another thread that calls pthread_join().
     *
     *  Any clean-up handlers that have not yet been popped, are popped
     *  (in the reverse of the order in which they were pushed) and executed.
     */
    thread->ret = retval;

    /*
     *  Don't bother disabling the Task scheduler while the thread
     *  is exiting.  It will be up to the application to not make
     *  such calls as pthread_cancel() or pthread_detach() while the
     *  thread is exiting.
     */

    /* Pop and execute the cleanup handlers */
    while (thread->cleanupList != NULL) {
        _pthread_cleanup_pop(thread->cleanupList, 1);
    }

    /* Cleanup any pthread specific data */
    _pthread_removeThreadKeys((pthread_t)thread);

    if (!thread->detached) {
        Semaphore_post(Semaphore_handle(&(thread->joinSem)));

        /* Set this task's priority to -1 to stop it from running. */
        Task_setPri(thread->task, -1);
    }
    else {
        /* Free memory */
#if ti_sysbios_posix_Settings_supportsMutexPriority__D
        Queue_destruct(&(thread->mutexList));
#endif
        Semaphore_destruct(&(thread->joinSem));

        Memory_free(Task_Object_heap(), thread, sizeof(pthread_Obj));

        /*
         *  Don't call Task_delete on the calling thread.  Task_exit()
         *  will put the task on the terminated queue, and if
         *  Task_deleteTerminatedTasks is TRUE, the task will be cleaned
         *  up automatically.
         */
        Task_exit();
    }
}
Esempio n. 26
0
/*
 *  ======== cbFxnLine0 ========
 *  This function was registered with Notify. It is called when 
 *  an event is sent to this processor.
 */
Void cbFxnLine0(UInt16 procId, UInt16 lineId,
                UInt32 eventId, UArg arg, UInt32 payload)
{
    /* Quick sanity check. This should never fail in this example */
    if ((arg != 0xFEED) ||
        (eventId != EVENTID)) {
        System_abort("Wrong values\n");
    }

    /* store in seq to show that payload made it all the way around */
    seq = payload;
    Semaphore_post(semHandle);
}
Esempio n. 27
0
void lightReadFn() {
	//Read the pin then switch the port to output and post the LightSema.
	Timer_stop(timer2);
	if (GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_1)){
		lightPtr = 1; //Dark if output of pin is high
		black_count++;
	}
	else {
		lightPtr = 0; //Light if output of pin is low
	}
	GPIOPinTypeGPIOOutput(GPIO_PORTE_BASE, GPIO_PIN_1);
	Semaphore_post(LightSema);
}
Esempio n. 28
0
/*
 *  ======== SPICC26XXDMA_transferCallback ========
 *  Callback function for when the SPI is in SPI_MODE_BLOCKING
 *
 *  @pre    Function assumes that the handle is not NULL
 */
static void SPICC26XXDMA_transferCallback(SPI_Handle handle, SPI_Transaction *msg)
{
    SPICC26XX_Object         *object;

    Log_print1(Diags_USER1, "SPI DMA:(%p) posting transferComplete semaphore",
                ((SPICC26XX_HWAttrs const *)(handle->hwAttrs))->baseAddr);

    /* Get the pointer to the object */
    object = handle->object;

    /* Post the semaphore */
    Semaphore_post(Semaphore_handle(&(object->transferComplete)));
}
Esempio n. 29
0
static void
setState(ControlObject* self, int newState)
{
#if (CONFIG_MMS_THREADLESS_STACK != 1)
    Semaphore_wait(self->stateLock);
#endif

    self->state = newState;

#if (CONFIG_MMS_THREADLESS_STACK != 1)
    Semaphore_post(self->stateLock);
#endif
}
Esempio n. 30
0
/*
 *  ======== ThreadSupport_runStub ========
 */
Void ThreadSupport_runStub(UArg input, UArg discard)
{
    ThreadSupport_Handle obj = (ThreadSupport_Handle)input;
    ti_sysbios_knl_Semaphore_Handle bios6sem;

    bios6sem = ThreadSupport_Instance_State_join_sem(obj);

    Log_write1(ThreadSupport_L_start, (IArg)obj);
    obj->startFxn(obj->startFxnArg);
    Log_write1(ThreadSupport_L_finish, (IArg)obj);

    Semaphore_post(bios6sem);
}