Quantcast
Channel: Forums - Recent Threads
Viewing all articles
Browse latest Browse all 262198

CC1310: Using an additional timer in the stack

$
0
0

Part Number:CC1310

Hi,

I tried to add an additional timer to the 15.4 Stack example FH mode in order to add some custom functions. At the moment I have used a LED toggle as the custom function.

-----------------------------------------------------------------
ssf.c
-----------------------------------------------------------------

#define SAVING_INIT_TIMEOUT_VALUE 1000

static Clock_Struct savingClkStruct;
static Clock_Handle savingClkHandle;

void Ssf_initializeSavingClock(void)
{
/* Initialize the timers needed for this application */
savingClkHandle = Timer_construct(&savingClkStruct,
processSavingTimeoutCallback,
SAVING_INIT_TIMEOUT_VALUE,
0,
false,
0);
}

void Ssf_setSavingClock(uint32_t readingTime)
{
/* Stop the Reading timer */
if(Timer_isActive(&savingClkStruct) == true)
{
Timer_stop(&savingClkStruct);
}
/* Setup timer */
if ( readingTime )
{
Timer_setTimeout(savingClkHandle, readingTime);
Timer_start(&savingClkStruct);
}
}

static void processSavingTimeoutCallback(UArg a0)
{
(void)a0; /* Parameter is not used */

Util_setEvent(&Sensor_events, SENSOR_SAVING_TIMEOUT_EVT);

/* Wake up the application thread when it waits for clock event */
Semaphore_post(sensorSem);
}

-----------------------------------------------------------------
sensor.c
-----------------------------------------------------------------

void Tag_init(void)

{
Ssf_initializeSavingClock();
Util_setEvent(&Sensor_events, SENSOR_SAVING_TIMEOUT_EVT);
}


void Sensor_save(void)
{
if(Sensor_events & SENSOR_SAVING_TIMEOUT_EVT)
{
Board_Led_toggle(board_led_type_LED2);
Ssf_setSavingClock(1000);
Util_clearEvent(&Sensor_events, SENSOR_SAVING_TIMEOUT_EVT);
}
}

-----------------------------------------------------------------
main.c
-----------------------------------------------------------------

Void taskFxn(UArg a0, UArg a1)
{
Tag_init();

while(1)
{
Sensor_save();
}

// /* Initialize the application */
// Sensor_init();
//
// /* Kick off application - Forever loop */
// while(1)
// {
// Sensor_process();
// }
}

Above are all the changes I have done to the stack example.

The LED only toggles once

I also tried implementing the functions inside the Sensor_init(); and Sensor_process(); functions. 

Then the LED blinks as expected.

I must be missing some piece of code in this. Can someone help me identify the mistake I am doing.

Or any other solution I can use for this. 

Thanks in advance.

-Abrar


Viewing all articles
Browse latest Browse all 262198

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>