RKH
Miscellaneous

Files

file  rkhplat.h
 RKH platform abstraction layer.
 
file  rkhtype.h
 Defines the data types that uses RKH.
 

Functions

void rkh_fwk_init (void)
 Initializes the RKH framework. More...
 
void rkh_fwk_enter (void)
 RKH framework is started. More...
 
void rkh_fwk_exit (void)
 Exit the RKH framework. More...
 

Detailed Description

Function Documentation

◆ rkh_fwk_init()

void rkh_fwk_init ( void  )

Initializes the RKH framework.

A requirement of RKH is that must be called rkh_fwk_init() before call any of its other services. This function initializes all of RKH's variables and data structures.

Note
Platform-dependent function. All RKH ports must be define it in the RKH port file to a particular platform. However, only the ports to the external OS/RTOS usually need some code to bolt the framework to the external OS/RTOS.
Usage
Implementation example for x86, linux emulator of simple cooperative scheduler non-preemptive.
void
{
sem_init(&sma_is_rdy, 0, 0);
}
void rkh_fwk_init(void)
Initializes the RKH framework.

◆ rkh_fwk_enter()

void rkh_fwk_enter ( void  )

RKH framework is started.

This entry function turns over control to RKH (and does not return!). This function runs the highest priority state machine application (SMA) that is ready to run in run-to-completation model.

Note
The call to this function does not return. Hence, any code after it will never be executed.
Platform-dependent function. All RKH ports must be define it in the RKH port file to a particular platform. However, only the ports to the external OS/RTOS usually need some code to bolt the framework to the external OS/RTOS.
Usage
Implementation example for x86, linux emulator of simple cooperative scheduler non-preemptive.
void
{
rui8_t prio;
RKH_SMA_T *sma;
RKH_HOOK_START();
running = 1;
while (running)
{
if (RKH_RDY_ISNOT_EMPTY(rkhrg))
{
RKH_RDY_FIND_HIGHEST(rkhrg, prio);
sma = rkh_sptbl[prio];
e = rkh_sma_get(sma);
RKH_FWK_GC(e, sma);
}
else
{
}
}
sem_destroy(&sma_is_rdy);
pthread_mutex_destroy(&csection);
}
void rkh_hook_exit(void)
This hook function is called just before the RKH returns to the underlying OS/RTOS....
void rkh_hook_idle(void)
An idle hook function will only get executed (with interrupts LOCKED) when there are no SMAs of highe...
#define RKH_FWK_GC(e, sender_)
Recycle a dynamic event.
RKH_EVT_T * rkh_sma_get(RKH_SMA_T *me)
Get an event from the event queue of an state machine application (SMA) as known as active object....
void rkh_fwk_enter(void)
RKH framework is started.
ruint rkh_sm_dispatch(RKH_SM_T *me, RKH_EVT_T *e)
Executes a state machine in a run-to-completation (RTC) model.
RKH_SMA_T * rkh_sptbl[RKH_CFG_FWK_MAX_SMA]
Priority arranged table of registered SMA.
#define RKH_TR_FWK_EN()
Initializes the RKH framework.
#define RKH_SR_ALLOC()
RKH need to disable interrupts in order to access critical sections of code, and re-enable interrupts...
Definition: rkhitl.h:2051
#define RKH_EXIT_CRITICAL(dummy)
RKH need to disable interrupts in order to access critical sections of code, and re-enable interrupts...
Definition: rkhitl.h:2054
#define RKH_ENTER_CRITICAL(dummy)
RKH need to disable interrupts in order to access critical sections of code, and re-enable interrupts...
Definition: rkhitl.h:2053
Represents events without parameters.
Definition: rkhevt.h:170
Describes the state machine.
Definition: rkhsm.h:1905
Describes the SMA (active object in UML).
Definition: rkhsma.h:772
Here is the basic algorithm for interpreting the listing shown above. A pseudocode description of the procedure is:
infinite loop
{
disable interrupts;
if( is_active_object_ready_to_run )
{
find the active object with highest priority;
enable interrupts;
e = get the event from the active object's queue;
dispatch the 'e' event to the active object's state machine;
}
else
execute the idle processing;
}

◆ rkh_fwk_exit()

void rkh_fwk_exit ( void  )

Exit the RKH framework.

Function invoked by the application layer to exit the RKH application and return control to the underlying OS/Kernel.

Note
This function is strongly platform-dependent. All RKH ports and must be defined in the RKH port to a particular platform. Some RKH ports might not require implementing this function at all, because many embedded applications don't have anything to exit to.
Platform-dependent function. All RKH ports must be defined in the RKH port file to a particular platform. However, only the ports to the external OS/RTOS usually need some code to bolt the framework to the external OS/RTOS.
Usage
Implementation example for x86, linux emulator of simple cooperative scheduler non-preemptive.
void
{
}
void rkh_fwk_exit(void)
Exit the RKH framework.
#define RKH_TR_FWK_EX()
Exit the RKH framework.