byte execCheckIntegrity(byte WhatToCheck);
Parameters: WhatToCheck checks as defined below
Returns: sum of failed checks as below (0 = passed).
The following checks can be performed:
- Do all the (global) events belong to a valid state machine? (1)
- Do all the (global) events correspond to a valid local event within its state machine? (2)
- Do all the events have valid default priorities? (4)
- Do all the state transitions in the state machines call up valid states for that state machine (0 is invalid)? (8)
- Are all the queues contiguous? (16)
- Are all the queue counts and tails within the bounds of the queue sizes? (32)
- Are the current states of the state machines within the bounds of the number of states in each state machine (0 is valid, state machine disabled)? (64)
- Are all the active timers part of the active timer queue? (128)
When specifying what to check, pass 0 for all the checks to be performed, or add together the figures in brackets after the questions above for the tests that are required to be performed.
For each test, if it fails, the number in brackets after the questions above are added to the return value to give a failure category bitmap.
Normally this function is called during the initialisation function to verify that the application and its data tables have been built correctly, although the last two checks verify the state of data in RAM and can be called at any time.
Returns: the current priority level. If the system is idling, then 0 is returned. Note that 0 is also the lowest priority.
This function is designed to be called from within execAppIdle. It puts the CPU in idle mode, checking first that there is no processing outstanding. It does this in a single uninterruptable instruction sequence, so that it is impossible for an interrupt routine to trigger off processing between deciding that idling is appropriate and actually going into idle. If this were to happen, the system may stall with pending events, possibly ending in a watchdog reset.
One means of monitoring the level of CPU usage is to set a port pin just prior to calling this and to reset it afterwards. Monitoring this pin on an oscilloscope will then show the periods of time that the CPU is in idle.
boolean execTraceEvent(boolean Enable, word or byte Event);
Parameters: Enable true to enable, false to disable
Event event number to trace (0 = global)
Returns: true if it succeeded or false if it failed. It will fail if the event is not a valid event number.
This function is used to enable/disable event tracing on a particular event or all events.
Event 0 is used to globally enable/disable event tracing.
word execUpdateChecksum(byte Value, word Checksum);
Parameters: Value byte to update checksum with
Checksum checksum to be updated
Returns: the updated checksum.
This function implements a CRC-16 algorithm using a lookup table. It is used principally by the asynchronous communications functions, but is available for general usage.
To calculate a CRC-16 checksum, call this routine repeatedly, iterating over the buffer to be checksummed. Start the process with a checksum value of zero.