/*
 *  ======== Adaptor_getFreePacket ========
 *  Function called by a service to "allocate" a msg packet.
 */
UIAPacket_Hdr *Adaptor_getFreePacket(UIAPacket_HdrType type, UInt timeout)
{
    Adaptor_Entry *entry;

    /* Get the free packet off the correct queue */
    if (type == UIAPacket_HdrType_EventPkt) {
        Semaphore_pend(Adaptor_module->freeEventSem, timeout);
        entry = Queue_get(Adaptor_module->freeEventQ);
        if ((Queue_Elem *)entry == (Queue_Elem *)Adaptor_module->freeEventQ) {
            return (NULL);
        }

    }
    else {
        Semaphore_pend(Adaptor_module->freeMsgSem, timeout);
        entry = Queue_get(Adaptor_module->freeMsgQ);
        if ((Queue_Elem *)entry == (Queue_Elem *)Adaptor_module->freeMsgQ) {
            return (NULL);
        }
    }

    /*
     *  Make sure the HdrType is set. This allows this module to
     *  place the packet back on the correct free queue when done processing.
     */
    UIAPacket_setHdrType(&(entry->packet), type);

    return (&(entry->packet));
}
Example #2
0
/*
 *  ======== tsk0_func ========
 *  Wait to be released then send an interrupt to the ARM processor
 */
Void tsk0_func(UArg arg0, UArg arg1)
{
    Int status;

    while (seq < NUMLOOPS) {
        /* Wait to be released by callback function */
        Semaphore_pend(semHandle, BIOS_WAIT_FOREVER);

        System_printf("Received request #%d from ARM (lineId = 0)\n",
                      seq);

        status = Notify_sendEvent(armProcId, LINE_1, EVENTID, seq, TRUE);
        if (status < 0) {
            System_abort("sendEvent failed\n");
        }

        System_printf("Sent request #%d to ARM (lineId = 1)\n", seq);

        /* Wait to be released by the cbFxn posting the semaphore */
        Semaphore_pend(semHandle, BIOS_WAIT_FOREVER);
        
        System_printf("Received request #%d from ARM (lineId = 1)\n");

        /* Send an event to the ARM */
        status = Notify_sendEvent(armProcId, LINE_0, EVENTID, seq, TRUE);
        if (status < 0) {
            System_abort("sendEvent failed\n");
        }

        System_printf("Sent request #%d to ARM (lineId = 0)\n", seq);
    }

    System_printf("Test completed\n");
    BIOS_exit(0);
}
/*
 *  ======== clockTask ========
 *  Wrapper function for TSK objects calling
 *  Clock::tick()
 */
void clockTask(UArg arg)
{   
    Clock *clock = (Clock *)arg;
    int count = 0;
   
    if (clock->getId() == 3) {
        for(;;) {             // task id = 3
            Semaphore_pend(sem0, BIOS_WAIT_FOREVER);
            clock->tick();
            if(count == 50) {
                Task_sleep(25);
                count = 0;
            } 
            count++;
            Semaphore_post(sem1);
        }
    }
    else {
        for(;;) {             // task id = 4
            Semaphore_pend(sem1, BIOS_WAIT_FOREVER);
            if(count == 50) {
                Task_sleep(25);
                count = 0;
            }   
            clock->tick();
            count++;
            Semaphore_post(sem0);
        }
    }
}
Example #4
0
/*
 *  ======== tsk0_func ========
 *  Sends an event to the remote processor then pends on a semaphore.
 *  The semaphore is posted by the callback function.
 */
Void tsk0_func(UArg arg0, UArg arg1)
{
    Int i = 1;
    Int status;
    
    if (MultiProc_self() == 0) {
        while (i <= NUMLOOPS) {
            /* Send an event to the remote processor */
            status = Notify_sendEvent(dstProc, INTERRUPT_LINE, EVENTID, i, 
                    TRUE);

            /* Continue until remote side is up */
            if (status < 0) {
                continue;
            }

            System_printf("tsk1_func: Sent request #%d to %s\n", seq,
                MultiProc_getName(dstProc));

            /* Wait to be released by the cbFxn posting the semaphore */
            Semaphore_pend(semHandle, BIOS_WAIT_FOREVER);

            System_printf("tsk1_func: Received request #%d from %s\n", seq,
                MultiProc_getName(recvProcId));

            /* increment for remote iteration */
            i++;
        }
    }
    else {
        while (seq < NUMLOOPS) {
            /* wait forever on a semaphore, semaphore is posted in callback */
            Semaphore_pend(semHandle, BIOS_WAIT_FOREVER);

            System_printf("tsk1_func: Received request #%d from %s\n", seq,
                MultiProc_getName(recvProcId));

            /* Send an event to the remote processor */
            status = Notify_sendEvent(dstProc, INTERRUPT_LINE, EVENTID, seq, 
                    TRUE);
            if (status < 0) {
                System_abort("sendEvent failed\n");
            }

            System_printf("tsk1_func: Sent request #%d to %s\n", seq,
                MultiProc_getName(dstProc));
        }
    }

    System_printf("Test completed\n");
    
    BIOS_exit(0);
}
/*****************************************************************************
** Function name:  Signal_Pend      
**
** Descriptions: 
**     			   Wait for Signal from external entity forever..
** parameters:     Mutex *pThis, Name

** Returned value: None   
**
** Dependencies/Limitations/Side Effects/Design Notes:
**		
*****************************************************************************/
VOID Signal_Pend( Signal *pThis)
{
    // SEM_reset(pThis->Handle, 0);
	Semaphore_reset(pThis->Handle, 0);
	 //SEM_pendBinary(pThis->Handle, SYS_FOREVER);
     Semaphore_pend(pThis->Handle, BIOS_WAIT_FOREVER);
}
Example #6
0
/*
 *  ======== SemProcessSupport_pend ========
 */
Int SemProcessSupport_pend(SemProcessSupport_Handle sem, UInt timeout, Error_Block *eb)
{
    UInt bios6_timeout;
    Semaphore_Handle bios6sem;
    Int status;
 
    bios6sem = SemProcessSupport_Instance_State_sem(sem);

    if (SemProcessSupport_FOREVER == timeout) {
        bios6_timeout = BIOS_WAIT_FOREVER;
    }
    else {
        bios6_timeout = timeout / Clock_tickPeriod;
        /*
         *  Don't let nonzero timeout round to 0 - semantically very
         *  different
         */
        if (timeout && (!bios6_timeout)) {
            bios6_timeout = 1;
        }
    }

    status = Semaphore_pend(bios6sem, bios6_timeout);

    if (status == 1) {
        return (ISemaphore_PendStatus_SUCCESS);
    }
    else if (status == 0) {
        return (ISemaphore_PendStatus_TIMEOUT);
    }
    else {
        return (ISemaphore_PendStatus_ERROR);
    }
}
Example #7
0
/*
 *  ======== taskLoad ========
 */
Void task(UArg arg1, UArg arg2)
{   
    UInt count = 1;
    Int status = Ipc_S_SUCCESS;
    UInt16 remoteProcId = MultiProc_getId("HOST");
    
    do {
        status = Ipc_attach(remoteProcId);
    } while (status < 0);
    
    Notify_registerEvent(remoteProcId, 0, SHUTDOWN,
                         (Notify_FnNotifyCbck)notifyCallbackFxn, 0);

    
    while (shutdownFlag == FALSE) {        
        Semaphore_pend(sem, BIOS_WAIT_FOREVER);
        
        /* Benchmark how long it takes to flip all the bits */
        Log_write1(UIABenchmark_start, (xdc_IArg)"Reverse");
        reverseBits(buffer, sizeof(buffer));
        Log_write1(UIABenchmark_stop, (xdc_IArg)"Reverse");
        
        Log_print1(Diags_USER1, "count = %d", count++);        
    }
    
    /* Start shutdown process */
    Notify_unregisterEvent(remoteProcId, 0, SHUTDOWN,
                           (Notify_FnNotifyCbck)notifyCallbackFxn, 0);
    
    do {
        status = Ipc_detach(remoteProcId);
    } while (status < 0);

    Ipc_stop();
}
TIMM_OSAL_ERRORTYPE TIMM_OSAL_SemaphoreObtain(TIMM_OSAL_PTR pSemaphore, TIMM_OSAL_U32 uTimeOut)
{
    TIMM_OSAL_SEMAPHORE *pHandle = (TIMM_OSAL_SEMAPHORE *)pSemaphore;
    TIMM_OSAL_ERRORTYPE bReturnStatus = TIMM_OSAL_ERR_NONE;
    TIMM_OSAL_U32 timeout;
    Bool status;

    if(pHandle == NULL)
    {
        bReturnStatus = TIMM_OSAL_ERR_PARAMETER;
        goto EXIT;
    }

    if (TIMM_OSAL_SUSPEND == uTimeOut) {
        timeout = BIOS_WAIT_FOREVER;
    }
    else
    {
        timeout = _TIMM_OSAL_GetTicks(uTimeOut);
    }

    status = Semaphore_pend(pHandle->sem, timeout);

    if(status == FALSE)
    {
        bReturnStatus = TIMM_OSAL_ERR_CREATE(TIMM_OSAL_ERR, TIMM_OSAL_COMP_SEMAPHORES, status);
    }
EXIT:
    return bReturnStatus;
}
Example #9
0
// 获取一次数据以供发送
void GetData()
{
	Uint8 *data;
	while(TRUE)
	{
		/* Wait 10 sets of data from ADS1298_ISR(). */
		Semaphore_pend(semDRDY, BIOS_WAIT_FOREVER);

		// 获取缓冲区地址
		data = dataPool;

		// 切换数据池
		if(dataPool == *DataPool1)
		{
			dataPool = *DataPool2;
		}
		else
		{
			dataPool = *DataPool2;
		}

		retrieve_data(data);

		Data2Send = AllData[8-Channel_No];

		signal_process();

		//发送单通道数据,触发发送事件
		Event_post(eventServer, Event_Id_01);
	}
}
Example #10
0
/*******************************************************************************
 * @fn          bspI2cSelect
 *
 * @brief       Select an I2C interface and slave
 *
 * @param       newInterface - selected interface
 * @param       address - slave address
  *
 * @return      true if success
 */
bool bspI2cSelect(uint8_t newInterface, uint8_t address)
{
  // Acquire I2C resource
  if (!Semaphore_pend(Semaphore_handle(&mutex),MS_2_TICKS(I2C_TIMEOUT)))
  {
    return false;
  }

  // Store new slave address
  slaveAddr = address;

  // Interface changed ?
  if (newInterface != interface)
  {
    // Store new interface
    interface = newInterface;

    // Shut down RTOS driver
    I2C_close(i2cHandle);

    // Sets custom to NULL, selects I2C interface 0
    I2C_Params_init(&i2cParams);

    // Assign I2C data/clock pins according to selected I2C interface 1
    if (interface == BSP_I2C_INTERFACE_1)
    {
      i2cParams.custom = (void*)&pinCfg1;
    }

    // Re-open RTOS driver with new bus pin assignment
    i2cHandle = I2C_open(Board_I2C, &i2cParams);
  }

  return true;
}
Example #11
0
/*
 *  ======== tsk0Fxn =======
 */
Void tsk0Fxn(UArg arg0, UArg arg1)
{
    UInt key;

    /* wait for swis to be posted from Clock function */
    Semaphore_pend(sem0, BIOS_WAIT_FOREVER);

    System_printf("Running tsk0Fxn\n");
         
    key = Swi_disable();        /* swis are disabled */
    Swi_inc(swi0);              /* swi0 trigger = 1 */
    Swi_inc(swi0);              /* swi0 trigger = 2 */
    Swi_restore(key);           /* swi0 runs */

    Swi_or(swi1, 0x100);        /* swi1 runs with trigger = 0x111 */

    Swi_andn(swi1, 0x1);        /* swi1 trigger = 0x10 */
    Swi_andn(swi1, 0x2);        /* swi1 runs with trigger = 0x00 */
        
    Swi_dec(swi1);              /* swi1 trigger = 2 */     
    Swi_dec(swi1);              /* swi1 trigger = 1 */
    Swi_dec(swi1);              /* swi1 runs with trigger = 0 */
        
    System_printf("Calling BIOS_exit\n");
    BIOS_exit(0);
}
void button_task(void) {
	Bool button_press = FALSE;

	Semaphore_pend(Button_Semaphore, BIOS_WAIT_FOREVER);

	if (button_press == FALSE)
	{
		// change status of LED from red to green or vice versa
		MAP_GPIO_toggleOutputOnPin(GPIO_PORT_P2, GPIO_PIN6);	// toggle Red
		MAP_GPIO_toggleOutputOnPin(GPIO_PORT_P2, GPIO_PIN4);	// toggle Green

		Timer32_startTimer((uint32_t)TIMER32_0_BASE,0);
		UART_transmitData(EUSCI_A0_BASE, 'g');

		button_press = TRUE;
	}
	else
	{
		// change status of LED from red to green or vice versa
		MAP_GPIO_toggleOutputOnPin(GPIO_PORT_P2, GPIO_PIN6);	// toggle Red
		MAP_GPIO_toggleOutputOnPin(GPIO_PORT_P2, GPIO_PIN4);	// toggle Green

		Timer32_haltTimer((uint32_t)TIMER32_0_BASE);

		button_press = FALSE;
	}
}
Void SystemCfg_waitForEvent(SystemCfg_Object *obj, UInt32 event)
{
    IArg    key;
    Bool    waitForEvent = TRUE;


    Log_print1(Diags_ENTRY|Diags_INFO,
        "--> "FXNN": waiting for event 0x%x ...", event);

    key = GateH_enter(Mod_gate);

    /* check if event already received */
    if (obj->event & event) {
        obj->event &= ~(event);
        waitForEvent = FALSE;
    }

    GateH_leave(Mod_gate, key);

    while (waitForEvent) {
        Semaphore_pend(obj->semH, BIOS_WAIT_FOREVER);

        /* check if event received */
        if (obj->event & event) {
            obj->event &= ~(event);
            waitForEvent = FALSE;
        }
    }

    Log_print1(Diags_EXIT|Diags_INFO,
        "<-- "FXNN": ...received event 0x%x", event);
}
Example #14
0
/*
 *  ======== SyncSem_wait ========
 */
Int SyncSem_wait(SyncSem_Object *obj, UInt timeout, Error_Block *eb)
{
    UInt bios6_timeout;
    Int status;

    if (timeout == ISync_WAIT_FOREVER) {
        bios6_timeout = BIOS_WAIT_FOREVER;
    }
    else {
        bios6_timeout = timeout / Clock_tickPeriod;
        /*
         *  Don't let nonzero timeout round to 0 - semantically very
         *  different
         */
        if (timeout && (!bios6_timeout)) {
            bios6_timeout = 1;
        }
    }

    status = Semaphore_pend(obj->sem, bios6_timeout);

    if (status == 1) {
        return (ISync_WaitStatus_SUCCESS);
    }
    else if (status == 0) {
        return (ISync_WaitStatus_TIMEOUT);
    }
    else {
        return (ISync_WaitStatus_ERROR);
    }
}
Example #15
0
xdc_Void A110x2500Radio::serviceInterrupt(xdc_UArg arg0, xdc_UArg arg1) {
  while(1) {
    Semaphore_pend(sem, BIOS_WAIT_FOREVER);

    GateMutex_enter(GateMutex_handle(&mygate));

    // Note: It is assumed that interrupts are disabled.

    // The GDO0 ISR will only look for the EOP edge. Therefore, if the radio
    // is not transmitting the EOP, it must be receiving an EOP signal.
    if (gDataTransmitting)
    {
      /**
       *  Note: GDO0 is issued prior to the transmitter being completely
       *  finished. The state machine will remain in TX_END until transmission
       *  completes. The following waits for TX_END to correct the hardware
       *  behavior.
       */ 
      while (CC1101GetMarcState(&gPhyInfo.cc1101) == eCC1101MarcStateTx_end);
      gDataTransmitting = false;
    }
    else
    {
      gDataReceived = true;
      readDataStream();
    }

    // Always go back to sleep.
    sleep();
    GateMutex_leave(GateMutex_handle(&mygate), 0);
  }
}
/*******************************************************************************
 * @fn          devpkLcdText
 *
 * @brief       Write a text string to a specific line/column of the display
 *
 * @param       str - text to apply
 * @param       line - line index (0 .. 11)
 * @param       col - column index (0 .. 15)
 *
 * @return      true if success
 */
bool devpkLcdText(const char *str, uint8_t line, uint8_t col)
{
  if (hLcdPin != NULL)
  {
    uint8_t xp, yp;

    Semaphore_pend(hSemLCD, BIOS_WAIT_FOREVER);

    xp = col * CHAR_WIDTH + 1;
    yp = line * CHAR_HEIGHT + 0;

    // Draw a text on the display
    GrStringDraw(&g_sContext,
                 str,
                 AUTO_STRING_LENGTH,
                 xp,
                 yp,
                 OPAQUE_TEXT);

    GrFlush(&g_sContext);

    Semaphore_post(hSemLCD);
  }

  return hLcdPin != NULL;
}
Example #17
0
/*
 * Write a specified value into a register on the IMU. This one can be done with the same setup about
 * all of its 16 SPICLK cycles, because nothing has to be read back for the Rx Stream.
 * @param reg Register to write into the IMU.
 * @param value That's the value that will be written into the IMU-register.
 */
void imu_write_byte(char reg, char value) {
	// TODO: Check des Registers ob Wert zwischen 0x00 und 0x5F
	read = false;

	/*
	 * The transmit part (the write command, which register to overwrite and the value to do so)
	 * needs to happen with active phase shifting. Because no setup change is neccessary during this
	 * operation, all th 16 (1 + 7 + 8) SPICLK cycles are done with this setup.
	 */
	SpiaRegs.SPICTL.bit.CLK_PHASE = 1;
	SpiaRegs.SPICCR.bit.SPICHAR = 0xF;

	/*
	 * To write a value into a register of the IMU the command has to have the following structure:
	 * Bit15 (MSB):		0				--> Write a Register. (Do not reply to something!)
	 * Bit14 - 8:		0x00 - 0x5F 	--> Registeraddress
	 * Bit7 - 0:		0xYZ			--> Value to register above has to be written to.
	 */
	data_tx = (reg << 8) + value;

	// Start communication by pulling SPIASTE down to 0 (Communication Enable)
	GpioDataRegs.GPBCLEAR.bit.GPIO61 = 1;

	// Fire SPIA by loading the transmit buffer.
	SpiaRegs.SPITXBUF = data_tx;

	// Wait now for the ISR signals back, that the communication is done.
	Semaphore_pend(semaphore_spia_done, BIOS_WAIT_FOREVER);

	//Finish the communication by pushing the SPIASTE back up to 1 (TRUE).
	GpioDataRegs.GPBSET.bit.GPIO61 = 1;

	// End - SPI Magic
}
Example #18
0
static Void OffloadM3_deleteTask(UArg sem, UArg arg1)
{
    Semaphore_Handle semHandle = (Semaphore_Handle)sem;
    Int i;

    while (1) {
        Semaphore_pend(semHandle, BIOS_WAIT_FOREVER);

        Mutex_enter();
        if (module.created) {
            /*
             * Since this task is higher priority than any of the subtasks,
             * they won't be in running state, so we can call Task_delete on
             * them
             */
            for (i = OFFLOAD_AC_IDX; i < OFFLOAD_MAX_IDX; i++) {
                Task_delete(&module.tasks[i]);
                Semaphore_delete(&module.semaphores[i]);
                module.tasks[i] = NULL;
                module.semaphores[i] = NULL;
            }
            module.created = FALSE;
        }
        Mutex_leave();
    }
}
Example #19
0
Int32 System_lockVip(UInt32 vipInst)
{
   if (vipInst < SYSTEM_VIP_MAX)
   {
       Semaphore_pend(gSystem_objVpss.vipLock[vipInst], BIOS_WAIT_FOREVER);
   }

   return FVID2_SOK;
}
/*****************************************************************************
** Function name:  Signal_Poll      
**
** Descriptions: 
**     			   To test if any body sent a signal.
** parameters:     Mutex *pThis, Name, Initial state

** Returned value: TRUE/FALSE   
**
** Dependencies/Limitations/Side Effects/Design Notes:
**		
*****************************************************************************/
BOOL Signal_Poll( Signal *pThis, UINT16 nTimeout)
{
	BOOL bStatus;

	//bStatus = SEM_pendBinary(pThis->Handle, 0);
	bStatus = Semaphore_pend(pThis->Handle, 0);
	return bStatus; // TRUE if available
	                // FALSE if timeout.
}
Example #21
0
/*
 *  ======== DSKT2_acquireLock ========
 *  Acquires a semaphore lock for a particular scratch group
 */
Void DSKT2_acquireLock(Int scratchId)
{
    /*
     * Try and acquire it if it is a valid scratch Id
     */
    if ((scratchId >= 0) && (scratchId < DSKT2_NUM_SCRATCH_GROUPS)) {
        Semaphore_pend(_locks[scratchId], BIOS_WAIT_FOREVER);
    }
}
Example #22
0
/*
 *  ======== ThreadSupport_join ========
 */
Bool ThreadSupport_join(ThreadSupport_Handle obj, Error_Block* eb)
{
    ti_sysbios_knl_Semaphore_Handle bios6sem;
 
    bios6sem = ThreadSupport_Instance_State_join_sem(obj);
    Semaphore_pend(bios6sem, BIOS_WAIT_FOREVER);
    Log_write1(ThreadSupport_L_join, (IArg)obj);

    return (TRUE);
}
Example #23
0
/******************************************************************************
* compute - An alternate computation function
*
*     arg0 is assumed to be a pointer to a Semaphore_Handle.
*     arg1 is unused.
*
*   Forever: wait on semaphore then increment counter
******************************************************************************/
void compute(UArg arg0, UArg arg1)
{
    Semaphore_Handle *sem = (Semaphore_Handle*) arg0;

    while (1)
    {
        Semaphore_pend(*sem, BIOS_WAIT_FOREVER);
        counter++;
    }
}
/*****************************************************************************
** Function name:  Mutex_Lock_Timeout      
**
** Descriptions: 
**     			   Tries to acquire lock, but will not pend if not available.
** parameters:     Mutex *pThis

** Returned value: TRUE/FALSE   
**
** Dependencies/Limitations/Side Effects/Design Notes:
**			User has to check whether it acquired lock or not by retval.
*****************************************************************************/
BOOL Mutex_Lock_Timeout( Mutex *pThis)
{
	BOOL bStatus;

	//bStatus = SEM_pendBinary(pThis->Handle, 0);
	bStatus = Semaphore_pend(pThis->Handle, 0);

	return bStatus; // TRUE if available
	                // FALSE if timeout.
}
/****************************************************************************
 * Test task
 ***************************************************************************/
void task_led_toggle(void)
{
	while (1)
	{
		Semaphore_pend(sem_led_blink, BIOS_WAIT_FOREVER);// wait for LEDSem to be posted by ISR
		HAL_toggleGpio(halHandle, GPIO_Number_34);
		i16ToggleCount += 1;						// keep track of #toggles
		Log_info1("LED TOGGLED [%u] TIMES",i16ToggleCount);	// store #toggles to Log display
	}
}
Example #26
0
/*
 *  ======== tsk0_func ========
 *  Send an interrupt to the DSP processor and wait on semaphore.
 */
Void tsk0_func(UArg arg0, UArg arg1)
{   
    Int   i = 1;
    Int status;    
    Int16 remoteProcId = MultiProc_getId("DSP");
    
    while (i <= NUMLOOPS) {
        /* Send an event to the DSP */
        status = Notify_sendEvent(dspProcId, LINE_0, EVENTID, i, TRUE);
        
        /* Continue until remote side is up */      
        if (status < 0) {
            continue;
        }
        
        System_printf("Sent request #%d to DSP (lineId = 0)\n", i);

        /* Wait to be released by the cbFxn posting the semaphore */
        Semaphore_pend(semHandle, BIOS_WAIT_FOREVER);
        
        System_printf("Received request #%d from DSP (lineId = 1)\n", seq);        
        
        /* Send an event to the DSP */
        status = Notify_sendEvent(dspProcId, LINE_1, EVENTID, i, TRUE);
        
        /* Continue until remote side is up */      
        if (status < 0) {
            continue;
        }

        System_printf("Sent request #%d to DSP (lineId = 1)\n", i);
        
        /* Wait to be released by the cbFxn posting the semaphore */
        Semaphore_pend(semHandle, BIOS_WAIT_FOREVER);
        System_printf("Received request #%d from DSP (lineId = 0)\n", seq);        
        
        /* increment for next iteration */
        i++;
    }
    System_printf("Test completed\n");
    BIOS_exit(0);
}
Example #27
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;
}
Example #28
0
static Void OffloadM3_workerTask(UArg sem, UArg fxn)
{
    Semaphore_Handle semHandle = (Semaphore_Handle)sem;
    MSP_PAYLOAD_TYPE *payload = (MSP_PAYLOAD_TYPE *)fxn;

    while(1) {
        Semaphore_pend(semHandle, BIOS_WAIT_FOREVER);
        payload->fxn(payload->data);
        payload->status = 0;
    }
}
Example #29
0
/*
 *  ======== tsk1Fxn ========
 */
Void tsk1Fxn(UArg arg0, UArg arg1)
{
    Log_info2("tsk1 Entering. arg0,1 = %d %d", 
        (Int)arg0, (Int)arg1);

    Log_error2("tsk1 demonstrating error event. arg0,1 = %d %d",
        (Int)arg0, (Int)arg1);
        
    Log_info0("tsk1 Calling Semaphore_pend");
    Semaphore_pend(sem0, BIOS_WAIT_FOREVER);
    
    Log_info0("tsk1 Exiting");
}
Example #30
0
uint8_t show_BH1750_Bright(struct bhl1750 *bright){


	if ( Semaphore_getCount(brightDataHandle) == 0 )   {
		//putstr("\r\nRead Brightness Data blocked!\r\n");
	}else{
		Semaphore_pend(brightDataHandle, BIOS_WAIT_FOREVER);
		putstr("\r\nBrightness: ");
		putdata(bright->SensBrightness);
		putstr(" Lux                            ");
		Semaphore_post(brightDataHandle);
	}

		return 0;
}