PRSEV library

It provides a way to store several differently behaving applications in a single binary, and a way to define a function for each event state.

The App_Tag end device combines the handling of several sensors into a single application and switches the behaviour depending on the configuration.

Each vProcessEv_? .c file contains the definition of the application and the procedures for its individual behaviour.

Defining a callback function

Callback functions are defined statically, which is not a good way to combine multiple application behaviours into one. Here, they are defined static in the source file.

/**
 * Hardware interrupt
 * @param u32DeviceId
 * @param u32ItemBitmap
 * @return
 */
static uint8 cbAppToCoNet_u8HwInt(uint32 u32DeviceId, uint32 u32ItemBitmap) {
	uint8 u8handled = FALSE;
	switch (u32DeviceId) {
	default:
		break;
	}
	return u8handled;
}

/**
 * Hardware events (delayed execution)
 * @param u32DeviceId
 * @param u32ItemBitmap
 */
static void cbAppToCoNet_vHwEvent(uint32 u32DeviceId, uint32 u32ItemBitmap) {
}

/**
 * Main processing
 */
static void cbAppToCoNet_vMain() {
	/* handle serial input */
	vHandleSerialInput();
}

/**
 * Network events
 * @param eEvent
 * @param u32arg
 */
static void cbAppToCoNet_vNwkEvent(teEvent eEvent, uint32 u32arg) {
}

/**
 * RX events
 * @param pRx
 */
static void cbAppToCoNet_vRxEvent(tsRxDataApp *pRx) {
}

/**
 * TX events
 * @param u8CbId
 * @param bStatus
 */
static void cbAppToCoNet_vTxEvent(uint8 u8CbId, uint8 bStatus) {
	// tx complete
	ToCoNet_Event_Process(E_ORDER_KICK, 0, vProcessEvCore);
}

Finally, we have the tsCbHandler structure in the list.

State definitions

You can define as many events as you wish to use.

An entity is defined as follows:

Event handling functions

The event handling function is defined as follows. The event processing is done according to asStateFuncTbl prepared in the previous state definition.

Initialisation process

We will prepare an initialization function to store values in psCbHandler and pvProcessEv1, which are prepared as global variables as follows.

Running the application

This section describes the main file which contains the callback functions. The main file handles the calling of the functions for the individual processes defined above.

The user-defined event processing function and the TWELITE NET callback function should be defined as follows Call the application's own callback function, specified by the function pointer, to execute the application's own user-defined event processing.

最終更新