Hi Mark,
I suppose you are working with KW01 connectivity software (KSDK based), it's correct?
I recommend you to do all your described implementation in application layer (App.c file).
For SW pressing: You can create a callback function for the SW pressing, here an example:
/*Add the keyboard drivers in App.c*/
#include "Keyboard.h"
/*Declaration of push buttons callback function in App.c file*/
static void App_HandleKeys( key_event_t events );
/*Register push buttons callback function in App_init function in App.c*/
KBD_Init(App_HandleKeys);
/*Definition of push buttons callback function in App.c file*/
static void App_HandleKeys
(
key_event_t events /*IN: Events from keyboard module */
)
{
if (events == gKBD_EventPB4_c) //
{
//code
}
events = 0;
}
For timers: Connectivity framework includes functions to work with KW01 timers, here an example:
/*Add the timers file in App.c*/
#include "TimersManager.h"
/*Add ID declaration of your timer in App.c*/
tmrTimerID_t MyFirstTimerID = gTmrInvalidTimerID_c;
/*Allocate your timer in App_init function in App.c*/
MyFirstTimerID = TMR_AllocateTimer();
/*Declaration of your timer callback in App.c*/
static void MyFirstTimerCallback (uint8_t MyParameter);
/*Definition of your timer callback in App.c*/
static void MyFirstTimerCallback (uint8_t MyParameter)
{
MyParameter=0;
/*code*/
}
/*Start the single shot timer in App.c*/
TMR_StartSingleShotTimer(MyFirstTimerID , 1000, (pfTmrCallBack_t)MyFirstTimerCallback , (void*)MyParameter);
Note: This example is using the single shot timer, but there are other types of timers that you can check in TimersManager.h... example: TMR_StartIntervalTimer, TMR_StartSecondTimer, TMR_StartTimer, TMR_StopTimer, etc.
Please let me know if this is useful for you.
Best regards,
Luis Burgos.