Other Parts Discussed in Thread: SYSBIOS
We are working on a Sensor driver for J7 using the TI-RTOS Imaging SDK component.
Currently we have a sensor driver working for our target camera, but we are adding a feature to enable and control an external train pulse signal which will allow the camera to stream in slave mode. Basically we would like to enable a periodic function to constantly switch from HIGH to LOW using a specific duty cycle and we want to collect the timestamps for every positive level switch.
For that we want to use a Timers API to enable and configure the period for a GPIO signal which will be reached by the camera.
I did some research on the documentation about it, but I couldn't find good information about how to use Timers on TI-RTOS, so I was analyzing files on the SDK and I found some interesting APIs.
- crete-j7-rtos/bios_6_82_01_19/packages/ti/sysbios/knl/Clock.c
- crete-j7-rtos/bios_6_82_01_19/packages/ti/posix/tirtos/timer.c
- crete-j7-rtos/pdk_jacinto_07_00_00/packages/ti/osal/src/tirtos/TimerP_tirtos.c
I found an example which uses the "TimerP" API:
- crete-j7-rtos/pdk_jacinto_07_00_00/packages/ti/diag/sdr/test/sdtf-test/src/sdtf_main.c
I did a quick implementation, adding code to the sensor driver trying to print a message every 1 ms. However, I didn't see the message being printed. I attached the code here:
... TimerP_Params periodicTimerParams; TimerP_Handle periodicTimerHandle; /* TimerP_Status timerStatus; */ appLogPrintf("*************** PROBE ***************** \n"); /* Initialize timer parameters */ TimerP_Params_init(&periodicTimerParams); /* Configure periodic timer for 1 ms*/ periodicTimerParams.period = 1000; /* 1 ms */ periodicTimerParams.periodType = TimerP_PeriodType_MICROSECS; periodicTimerParams.arg = &periodicTimerHandle; periodicTimerParams.startMode = TimerP_StartMode_USER; periodicTimerParams.startMode = TimerP_StartMode_AUTO; periodicTimerParams.runMode = TimerP_RunMode_CONTINUOUS; /* Create Periodic Timer */ appLogPrintf("*************** PROBE: Create Timer ***************** \n"); periodicTimerHandle = TimerP_create( TIMER_ID, (TimerP_Fxn)&GW5300_PeriodicTests, &periodicTimerParams); if (periodicTimerHandle == NULL) { appLogPrintf("ERR: Timer create failed\n"); return -1; } /* Start the Timer */ appLogPrintf("*************** PROBE: Start Timer ***************** \n"); timerStatus = TimerP_start(periodicTimerHandle); if (timerStatus != TimerP_OK) { appLogPrintf("ERR: Could not start the timer %d \n", TIMER_ID); return -1; } appLogWaitMsecs(1000); /* Stop the Timer */ appLogPrintf("*************** PROBE: Stop Timer ***************** \n"); timerStatus = TimerP_stop(periodicTimerHandle); if (timerStatus != TimerP_OK) { appLogPrintf("ERR: Could not stop the timer %d \n", TIMER_ID); return -1; } /* Delete the Timer */ appLogPrintf("*************** PROBE: Delete Timer ***************** \n"); timerStatus = TimerP_delete(periodicTimerHandle); if (timerStatus != TimerP_OK) { appLogPrintf("ERR: Could not delete the timer %d \n", TIMER_ID); return -1; } appLogPrintf("*************** PROBE END ***************** \n"); ...
I have some questions:
- Do you have information about Timer APIs that you can share or tell me where to find it?
- What is the best way to implement Timers? Do you have examples?
- How can I compile and run the example found on the SDK?
- What do you think about my test? Is there something missing? Should I use a different API?
Thanks.
-Enrique