END_TEST START_TEST (test_Event_addEventAssignment4) { Event_t *e = Event_create(2, 2); EventAssignment_t *ea = EventAssignment_create(2, 2); EventAssignment_setVariable(ea, "c"); EventAssignment_setMath(ea, SBML_parseFormula("a-n")); EventAssignment_t *ea1 = EventAssignment_create(2, 2); EventAssignment_setVariable(ea1, "c"); EventAssignment_setMath(ea1, SBML_parseFormula("a-n")); int i = Event_addEventAssignment(e, ea); fail_unless( i == LIBSBML_OPERATION_SUCCESS); fail_unless( Event_getNumEventAssignments(e) == 1); i = Event_addEventAssignment(e, ea1); fail_unless( i == LIBSBML_DUPLICATE_OBJECT_ID); fail_unless( Event_getNumEventAssignments(e) == 1); EventAssignment_free(ea); EventAssignment_free(ea1); Event_free(e); }
/** * usage: this method sets up the events needed by the queues * @method setup_Events * @author: patrik.szabo * @param arg0 - not used param for the task * @return 0, if everything succeeded */ int setup_Events() { Error_Block eb; /* Default instance configuration params */ uartReadyEvent = Event_create(NULL, &eb); if (uartReadyEvent == NULL) { System_abort("UartReadyEvent create failed"); } externalModuleReadyEvent = Event_create(NULL, &eb); if (uartReadyEvent == NULL) { System_abort("ExternalModuleReadyEvent create failed"); } return (0); }
int main(void) { /* Call board init functions */ uint32_t ui32SysClock; ui32SysClock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120E6); Board_initGeneral(ui32SysClock); Board_initEMAC(); Board_initGPIO(); // Board_initI2C(); // Board_initSDSPI(); // Board_initSPI(); // Board_initUART(); // Board_initUSB(Board_USBDEVICE); // Board_initUSBMSCHFatFs(); // Board_initWatchdog(); // Board_initWiFi(); setup_ledcube(); Mailbox_Params mbox_Params; Error_Block eb; Error_init(&eb); _sem = Semaphore_create(0, NULL, &eb); if (_sem == NULL) { System_abort("Couldn't create semaphore"); } ledEvent = Event_create(NULL,&eb); Mailbox_Params_init(&mbox_Params); mbox_Params.readerEvent=ledEvent; mbox_Params.readerEventId=Event_Id_01; mbox_led = Mailbox_create(sizeof(struct ledMatrix),1, &mbox_Params, &eb); if(mbox_led == NULL){ // Do something with errorblock, in the real world System_abort("woho!"); } create_led_task((UArg) mbox_led); //netOpenHook((UArg) mbox_led); netOpenHook(mbox_led); System_printf("Starting the example\nSystem provider is set to SysMin. " "Halt the target to view any SysMin contents in ROV.\n"); /* SysMin will only print to the console when you call flush or exit */ System_flush(); /* Start BIOS */ BIOS_start(); return (0); }
void L3EventTest_setup (void) { E = Event_create(3, 1); if (E == NULL) { fail("Event_create(3, 1) returned a NULL pointer."); } }
void EventTest1_setup (void) { E = Event_create(2, 4); if (E == NULL) { fail("Event_create() returned a NULL pointer."); } }
bool_t osCreateEvent(OsEvent *event) { //Create an event object event->handle = Event_create(NULL, NULL); //Check whether the returned handle is valid if(event->handle != NULL) return TRUE; else return FALSE; }
END_TEST START_TEST (test_Event_setUseValuesFromTriggerTime2) { Event_t *e = Event_create(2, 2); int i = Event_setUseValuesFromTriggerTime(e, 0); fail_unless( i == LIBSBML_UNEXPECTED_ATTRIBUTE); Event_free(e); }
END_TEST START_TEST (test_Event_addEventAssignment3) { Event_t *e = Event_create(2, 2); int i = Event_addEventAssignment(e, NULL); fail_unless( i == LIBSBML_OPERATION_FAILED); fail_unless( Event_getNumEventAssignments(e) == 0); Event_free(e); }
END_TEST START_TEST (test_Event_setTimeUnits4) { Event_t *e = Event_create(2, 1); int i = Event_setTimeUnits(e, NULL); fail_unless( i == LIBSBML_OPERATION_SUCCESS); fail_unless( !Event_isSetTimeUnits(e) ); Event_free(e); }
void Event::begin() { Error_Block eb; Error_init(&eb); Event_Params params; Event_Params_init(¶ms); EventHandle = Event_create(¶ms, &eb); if (EventHandle == NULL) { System_abort("Event create failed"); } }
END_TEST START_TEST (test_L3_Event_hasRequiredAttributes ) { Event_t *e = Event_create (3, 1); fail_unless ( !Event_hasRequiredAttributes(e)); Event_setUseValuesFromTriggerTime(e, 1); fail_unless ( Event_hasRequiredAttributes(e)); Event_free(e); }
END_TEST START_TEST (test_Event_createEventAssignment) { Event_t *e = Event_create(2, 2); EventAssignment_t *ea = Event_createEventAssignment(e); fail_unless( Event_getNumEventAssignments(e) == 1); fail_unless( SBase_getLevel((SBase_t *) (ea)) == 2 ); fail_unless( SBase_getVersion((SBase_t *) (ea)) == 2 ); Event_free(e); }
END_TEST START_TEST (test_L3_Event_hasRequiredElements ) { Event_t *e = Event_create (3, 1); fail_unless ( !Event_hasRequiredElements(e)); Trigger_t *t = Trigger_create(3, 1); Event_setTrigger(e, t); fail_unless ( Event_hasRequiredElements(e)); Event_free(e); }
/* * ======== main ======== */ Int main() { Clock_Params clkParams; Task_Params tskParams; Mailbox_Params mbxParams; Semaphore_Params semParams; /* Create a one-shot Clock Instance with timeout = 5 system time units */ Clock_Params_init(&clkParams); clkParams.startFlag = TRUE; clk1 = Clock_create(clk0Fxn, 5, &clkParams, NULL); /* Create an one-shot Clock Instance with timeout = 10 system time units */ Clock_Params_init(&clkParams); clkParams.startFlag = TRUE; clk2 = Clock_create(clk1Fxn, 10, &clkParams, NULL); /* create an Event Instance */ evt = Event_create(NULL, NULL); /* create a Semaphore Instance */ Semaphore_Params_init(&semParams); semParams.mode = Semaphore_Mode_BINARY; semParams.event = evt; semParams.eventId = Event_Id_01; sem = Semaphore_create(0, &semParams, NULL); /* create a Mailbox Instance */ Mailbox_Params_init(&mbxParams); mbxParams.readerEvent = evt; mbxParams.readerEventId = Event_Id_02; mbx = Mailbox_create(sizeof(MsgObj), 2, &mbxParams, NULL); /* create a writer task */ Task_Params_init(&tskParams); tskParams.priority = 1; tskParams.arg0 = (UArg) mbx; Task_create(writer, &tskParams, NULL); /* create a reader task */ Task_create(reader, &tskParams, NULL); BIOS_start(); /* does not return */ return(0); }
END_TEST START_TEST (test_Event_setUseValuesFromTriggerTime1) { Event_t *e = Event_create(2, 4); int i = Event_setUseValuesFromTriggerTime(e, 0); fail_unless( i == LIBSBML_OPERATION_SUCCESS); fail_unless( Event_getUseValuesFromTriggerTime(e) == 0 ); i = Event_setUseValuesFromTriggerTime(e, 1); fail_unless( i == LIBSBML_OPERATION_SUCCESS); fail_unless( Event_getUseValuesFromTriggerTime(e) == 1 ); Event_free(e); }
static Event_t * rsbml_build_doc_event(SEXP r_event) { Event_t * event; event = Event_create(); rsbml_build_doc_s_base((SBase_t *)event, r_event); SET_ATTR(Event, event, Id, id, STRING); SET_ATTR(Event, event, Name, name, STRING); SET_ATTR(Event, event, Trigger, trigger, EXPRESSION); SET_ATTR(Event, event, Delay, delay, EXPRESSION); SET_ATTR(Event, event, TimeUnits, timeUnits, STRING); ADD_LIST(Event, event, EventAssignment, eventAssignments, event_assignment); return event; }
END_TEST START_TEST (test_Event_addEventAssignment2) { Event_t *e = Event_create(2, 2); EventAssignment_t *ea = EventAssignment_create(2, 3); EventAssignment_setVariable(ea, "f"); EventAssignment_setMath(ea, SBML_parseFormula("a-n")); int i = Event_addEventAssignment(e, ea); fail_unless( i == LIBSBML_VERSION_MISMATCH); fail_unless( Event_getNumEventAssignments(e) == 0); EventAssignment_free(ea); Event_free(e); }
END_TEST START_TEST (test_Event_setTimeUnits3) { const char *units = "1second"; Event_t *e = Event_create(2, 1); int i = Event_setTimeUnits(e, units); fail_unless( i == LIBSBML_INVALID_ATTRIBUTE_VALUE); fail_unless( !Event_isSetTimeUnits(e) ); i = Event_unsetTimeUnits(e); fail_unless( i == LIBSBML_OPERATION_SUCCESS ); fail_unless( !Event_isSetTimeUnits(e) ); Event_free(e); }
END_TEST START_TEST (test_Event_setTimeUnits2) { const char *units = "second"; Event_t *e = Event_create(2, 1); int i = Event_setTimeUnits(e, units); fail_unless( i == LIBSBML_OPERATION_SUCCESS); fail_unless( !strcmp(Event_getTimeUnits(e), units) ); fail_unless( Event_isSetTimeUnits(e) ); i = Event_unsetTimeUnits(e); fail_unless( i == LIBSBML_OPERATION_SUCCESS ); fail_unless( !Event_isSetTimeUnits(e) ); Event_free(e); }
END_TEST START_TEST (test_L3_Event_hasRequiredElements ) { Event_t *e = Event_create (3, 1); fail_unless ( !Event_hasRequiredElements(e)); Trigger_t *t = Trigger_create(3, 1); ASTNode_t* math = SBML_parseFormula("true"); Trigger_setMath(t, math); ASTNode_free(math); Trigger_setInitialValue(t, 1); Trigger_setPersistent(t, 1); Event_setTrigger(e, t); fail_unless ( Event_hasRequiredElements(e)); Event_free(e); Trigger_free(t); }
Int main(Int argc, char* argv[]) { RcmServer_Params rcmServerParams; System_printf("%s starting..\n", MultiProc_getName(MultiProc_self())); /* * Enable use of runtime Diags_setMask per module: * * Codes: E = ENTRY, X = EXIT, L = LIFECYCLE, F = INFO, S = STATUS */ Diags_setMask("ti.ipc.rpmsg.MessageQCopy=EXLFS"); /* Setup the table of services, so clients can create and connect to * new service instances: */ ServiceMgr_init(); /* initialize RcmServer create params */ RcmServer_Params_init(&rcmServerParams); /* The first function, at index 0, is a special create function, which * gets passed a Service_Handle argument. * We set this at run time as our C compiler is not allowing named union * field initialization: */ OMXServer_fxnTab.elem[0].addr.createFxn = RPC_SKEL_GetHandle; rcmServerParams.priority = Thread_Priority_ABOVE_NORMAL; rcmServerParams.fxns.length = OMXServer_fxnTab.length; rcmServerParams.fxns.elem = OMXServer_fxnTab.elem; /* Register an OMX service to create and call new OMX components: */ ServiceMgr_register("OMX", &rcmServerParams); /* Some background ping testing tasks, used by rpmsg samples: */ //start_ping_tasks(); #if 0 /* DSP or CORE0 or IPU */ /* Run a background task to test rpmsg_resmgr service */ start_resmgr_task(); #endif #if 0 /* DSP or CORE0 or IPU */ /* Run a background task to test hwspinlock */ start_hwSpinlock_task(); #endif /* Create 1 task with priority 15 */ Error_init(&eb0); Task_Params_init(&taskParams0); //taskParams0.stackSize = 512; taskParams0.priority = 15; taskParams0.affinity = 1; taskParams0.arg0 = (xdc_UArg)(&(t1)) ; taskParams0.arg1 = 0 ; /* Create 1 task with priority 15 */ Error_init(&eb1); Task_Params_init(&taskParams1); //taskParams1.stackSize = 512; taskParams1.priority = 15; taskParams1.affinity = 0; taskParams1.arg0 = (xdc_UArg)(&(t2)) ; taskParams1.arg1 = 1 ; /* create an Event object. All events are binary */ Error_Block eb; Error_init(&eb); edgeDetectEvent = Event_create(NULL, &eb); if (edgeDetectEvent == NULL) { System_abort("Event create failed"); } local_barrier_sense = local_barrier_counter = 2 ; sem0 = Semaphore_create(1, NULL, NULL) ; /* Start the ServiceMgr services */ ServiceMgr_start(0); BIOS_start(); return (0); }
/** ============================================================================ * @n@b Setup_Rx * * @b Description * @n This API sets up all relevant data structures and configuration required * for receiving data from PASS/Ethernet. It sets up a Rx free descriptor queue * with some empty pre-allocated buffers to receive data, and an Rx queue * to which the Rxed data is streamed for the example application. This API * also sets up the QM high priority accumulation interrupts required to * receive data from the Rx queue. * * @param[in] * @n None * * @return Int32 * -1 - Error * 0 - Success * ============================================================================= */ Int32 Setup_Rx (Ethernet *pThis) { Int32 result; UInt8 isAllocated, accChannelNum; UInt16 numAccEntries, intThreshold, i; Qmss_Queue rxFreeQInfo, rxQInfo; Ptr pCppiDesc; Qmss_AccCmdCfg accCfg; Cppi_RxFlowCfg rxFlowCfg; Ptr pDataBuffer; Error_Block eb; Uint32 mySWInfo[] = {0x11112222, 0x33334444}; /* Open a Receive (Rx) queue. * * This queue will be used to hold all the packets received by PASS/CPSW * * Open the next available High Priority Accumulation queue for Rx. */ if ((gRxQHnd = Qmss_queueOpen (Qmss_QueueType_HIGH_PRIORITY_QUEUE, QMSS_PARAM_NOT_SPECIFIED, &isAllocated)) < 0) { uart_write ("Error opening a High Priority Accumulation Rx queue \n"); return -1; } rxQInfo = Qmss_getQueueNumber (gRxQHnd); uart_write ("Opened RX queue Number %d \n",rxQInfo.qNum); /* Setup high priority accumulation interrupts on the Rx queue. * * Let's configure the accumulator with the following settings: * (1) Interrupt pacing disabled. * (2) Interrupt on every received packet */ intThreshold = RX_INT_THRESHOLD; numAccEntries = (intThreshold + 1) * 2; accChannelNum = PA_ACC_CHANNEL_NUM; /* Initialize the accumulator list memory */ memset ((Void *) gHiPriAccumList, 0, numAccEntries * 4); /* Ensure that the accumulator channel we are programming is not * in use currently. */ result = Qmss_disableAccumulator (Qmss_PdspId_PDSP1, accChannelNum); if (result != QMSS_ACC_SOK && result != QMSS_ACC_CHANNEL_NOT_ACTIVE) { uart_write ("Error Disabling high priority accumulator for channel : %d error code: %d\n", accChannelNum, result); return -1; } /* Setup the accumulator settings */ accCfg.channel = accChannelNum; accCfg.command = Qmss_AccCmd_ENABLE_CHANNEL; accCfg.queueEnMask = 0; accCfg.listAddress = Convert_CoreLocal2GlobalAddr((Uint32) gHiPriAccumList); // accCfg.listAddress = gHiPriAccumList; accCfg.queMgrIndex = gRxQHnd; accCfg.maxPageEntries = (intThreshold + 1); /* Add an extra entry for holding the entry count */ accCfg.timerLoadCount = 0; accCfg.interruptPacingMode = Qmss_AccPacingMode_LAST_INTERRUPT; accCfg.listEntrySize = Qmss_AccEntrySize_REG_D; accCfg.listCountMode = Qmss_AccCountMode_ENTRY_COUNT; accCfg.multiQueueMode = Qmss_AccQueueMode_SINGLE_QUEUE; /* Program the accumulator */ if ((result = Qmss_programAccumulator (Qmss_PdspId_PDSP1, &accCfg)) != QMSS_ACC_SOK) { uart_write ("Error Programming high priority accumulator for channel : %d queue : %d error code : %d\n", accCfg.channel, accCfg.queMgrIndex, result); return -1; } Error_init(&eb); pThis->RxEventHandle = Event_create(NULL,&eb); if (pThis->RxEventHandle == NULL) { uart_write("Event create failed"); return -1; } memset(pThis->pRxDataPtr,0,sizeof(pThis->pRxDataPtr)); pThis->RxDataHead = 0; pThis->RxDataTail = 0; Intr_Init(&pThis->oEthIntr, INTR_ITEM_ETH_RX,(Intr_Handler)Cpsw_RxISR, (void*)pThis); /* Open a Rx Free Descriptor Queue (Rx FDQ). * * This queue will hold all the Rx free decriptors. These descriptors will be * used by the PASS CPDMA to hold data received via CPSW. */ if ((gRxFreeQHnd = Qmss_queueOpen (Qmss_QueueType_STARVATION_COUNTER_QUEUE, QMSS_PARAM_NOT_SPECIFIED, &isAllocated)) < 0) { uart_write ("Error opening Rx Free descriptor queue \n"); return -1; } rxFreeQInfo = Qmss_getQueueNumber (gRxFreeQHnd); uart_write("Opened RX Free queue Number %d\n",gRxFreeQHnd); /* Attach some free descriptors to the Rx free queue we just opened. */ for (i = 0; i < NUM_RX_DESC; i++) { /* Get a free descriptor from the global free queue we setup * during initialization. */ if ((pCppiDesc = Qmss_queuePop (gGlobalFreeQHnd)) == NULL) { break; } /* The descriptor address returned from the hardware has the * descriptor size appended to the address in the last 4 bits. * * To get the true descriptor size, always mask off the last * 4 bits of the address. */ pCppiDesc = (Ptr) ((UInt32) pCppiDesc & 0xFFFFFFF0); if ((pDataBuffer = (Ptr) Memory_alloc((IHeap_Handle)heap2, ETHER_MAX_SIZE, 0, NULL)) == NULL) { uart_write ("Error allocating memory for Rx data buffer \n"); break; } /* Populate the Rx free descriptor with the buffer we just allocated. */ Cppi_setData (Cppi_DescType_HOST, pCppiDesc, (UInt8 *)Convert_CoreLocal2GlobalAddr((UInt32)pDataBuffer), ETHER_MAX_SIZE); /* Save original buffer information */ Cppi_setOriginalBufInfo (Cppi_DescType_HOST, pCppiDesc, (UInt8 *)Convert_CoreLocal2GlobalAddr((UInt32)pDataBuffer), ETHER_MAX_SIZE); /* Setup the Completion queue: * * Setup the return policy for this desc to return to the free q we just * setup instead of the global free queue. */ Cppi_setReturnQueue (Cppi_DescType_HOST, pCppiDesc, rxFreeQInfo); Cppi_setSoftwareInfo (Cppi_DescType_HOST, pCppiDesc, (UInt8 *) mySWInfo); Cppi_setPacketLen (Cppi_DescType_HOST, pCppiDesc, ETHER_MAX_SIZE); /* Push descriptor to Tx free queue */ Qmss_queuePushDescSize (gRxFreeQHnd, pCppiDesc, SIZE_CPSW_HOST_DESC); } if (i != NUM_RX_DESC) { uart_write ("Error allocating Rx free descriptors \n"); return -1; } //count=Qmss_getQueueEntryCount(gRxFreeQHnd); //platform_write("Total %d entries in queue %d\n",count,gRxFreeQHnd); /* Setup a Rx Flow. * * A Rx flow encapsulates all relevant data properties that CPDMA would * have to know in order to succefully receive data. */ /* Initialize the flow configuration */ memset (&rxFlowCfg, 0, sizeof(Cppi_RxFlowCfg)); /* Let CPPI pick the next available flow */ rxFlowCfg.flowIdNum = CPPI_PARAM_NOT_SPECIFIED; rxFlowCfg.rx_dest_qmgr = rxQInfo.qMgr; rxFlowCfg.rx_dest_qnum = rxQInfo.qNum; rxFlowCfg.rx_desc_type = Cppi_DescType_HOST; rxFlowCfg.rx_ps_location = Cppi_PSLoc_PS_IN_DESC; rxFlowCfg.rx_psinfo_present = 1; /* Enable PS info */ rxFlowCfg.rx_error_handling = 0; /* Drop the packet, do not retry on starvation by default */ rxFlowCfg.rx_einfo_present = 1; /* EPIB info present */ rxFlowCfg.rx_dest_tag_lo_sel = 0; /* Disable tagging */ rxFlowCfg.rx_dest_tag_hi_sel = 0; rxFlowCfg.rx_src_tag_lo_sel = 0; rxFlowCfg.rx_src_tag_hi_sel = 0; rxFlowCfg.rx_size_thresh0_en = 0; /* By default, we disable Rx Thresholds */ rxFlowCfg.rx_size_thresh1_en = 0; /* By default, we disable Rx Thresholds */ rxFlowCfg.rx_size_thresh2_en = 0; /* By default, we disable Rx Thresholds */ rxFlowCfg.rx_size_thresh0 = 0x0; rxFlowCfg.rx_size_thresh1 = 0x0; rxFlowCfg.rx_size_thresh2 = 0x0; rxFlowCfg.rx_fdq0_sz0_qmgr = rxFreeQInfo.qMgr; /* Setup the Receive free queue for the flow */ rxFlowCfg.rx_fdq0_sz0_qnum = rxFreeQInfo.qNum; rxFlowCfg.rx_fdq0_sz1_qnum = 0x0; rxFlowCfg.rx_fdq0_sz1_qmgr = 0x0; rxFlowCfg.rx_fdq0_sz2_qnum = 0x0; rxFlowCfg.rx_fdq0_sz2_qmgr = 0x0; rxFlowCfg.rx_fdq0_sz3_qnum = 0x0; rxFlowCfg.rx_fdq0_sz3_qmgr = 0x0; rxFlowCfg.rx_fdq1_qnum = rxFreeQInfo.qNum; /* Use the Rx Queue to pick descriptors */ rxFlowCfg.rx_fdq1_qmgr = rxFreeQInfo.qMgr; rxFlowCfg.rx_fdq2_qnum = rxFreeQInfo.qNum; /* Use the Rx Queue to pick descriptors */ rxFlowCfg.rx_fdq2_qmgr = rxFreeQInfo.qMgr; rxFlowCfg.rx_fdq3_qnum = rxFreeQInfo.qNum; /* Use the Rx Queue to pick descriptors */ rxFlowCfg.rx_fdq3_qmgr = rxFreeQInfo.qMgr; /* Configure the Rx flow */ if ((gRxFlowHnd = Cppi_configureRxFlow (gCpdmaHnd, &rxFlowCfg, &isAllocated)) == NULL) { uart_write ("Error configuring Rx flow \n"); return -1; } else { //platform_write("Rx flow configured. handle %p Id %d \n",gRxFlowHnd,Cppi_getFlowId (gRxFlowHnd)); } /* All done with Rx configuration. Return success. */ return 0; }