weAutSys provides a bundle of system function and variables mainly for internal use, that may well be used by application threads.
Compared to the system services the "low level" means that even more care must be taken on the usage conditions. And the implementation is in many cases directly dependent on target hardware and controller type.
Modules | |
Software instrumentation | |
Debugging aids | |
System initialisation | |
Basic I/O drivers (SPI) | |
Basic serial communication drivers | |
Basic Ethernet communications drivers | |
Files | |
file | ll_system.h |
weAutSys'/weAut_01' low level system calls and services | |
Defines | |
#define | abortBoot |
Abort command: go to bootloader (by human command) | |
#define | abortHMI |
Abort command: abort by human command entry. | |
#define | andAP(mask) |
Unset (boolean and operation) port bits. | |
#define | andBP(mask) |
Unset (boolean and operation) port bits. | |
#define | andCP(mask) |
Unset (boolean and operation) port bits. | |
#define | andDP(mask) |
Unset (boolean and operation) port bits. | |
#define | andOrBP(andMask, orMask) |
Unset and set port B bits. | |
#define | andOrCP(andMask, orMask) |
Unset and set port C bits. | |
#define | andPort(port, mask) |
Unset (boolean and operation) port-bits. | |
#define | dirPort(port) |
Direction port (by letter) | |
#define | fromPort(port) |
Re-read output from a port (by letter) | |
#define | inPort(port) |
Input port (by letter) | |
#define | inpPins(port, mask) |
Set port pins as input. | |
#define | orAP(mask) |
Set (boolean or operation) port-bits. | |
#define | orBP(mask) |
Set (boolean or operation) port-bits. | |
#define | orCP(mask) |
Set (boolean or operation) port-bits. | |
#define | orDP(mask) |
Set (boolean or operation) port-bits. | |
#define | orPort(port, mask) |
Set (boolean or operation) port-bits. | |
#define | outPins(port, mask) |
Set port pins as output. | |
#define | PLCinRUN |
Status check: PLC is in Run. | |
#define | PLCinSTOP |
Status check: PLC is in Stop. | |
#define | PLCrun |
Abort command: run (i.e. no abort command at all) | |
#define | PLCstop |
Abort command: stop. | |
#define | setPort(port, value) |
Set all port-bits. | |
#define | TOKENPASTE(x, y) |
Concatenation helper macro x ## y. | |
#define | toPort(port, mask) |
Output to a port (by letter) | |
#define | WDtiOut |
Abort cause: (unexpected) watchdog timeout. | |
#define | xorPort(port, mask) |
Toggle (boolean xor operation) port-bits. | |
Functions | |
void | initPorts (void) |
low level reset type initialisation of ports | |
void | initProcIO (void) |
low level reset type initialisation of process I/O | |
void | initStatusLeds (uint8_t LEDgnStart, uint8_t LEDrdStart) |
Initialisation of status / test LEDs (if any) | |
void | initSystemRes (void) |
Initialise system resources after reset or restart. | |
void | initSystTiming (void) |
low level clock / timer / tick initialisation | |
int | main (void) __attribute__((OS_main)) |
The system start. | |
void | setAbortCommand (uint8_t command) __attribute__((always_inline)) |
Set the abort cause respectively command. | |
Variables | |
uint8_t | abortCommand |
The abort command respectively cause. | |
uint8_t | resetCauses |
The last reset cause(s) | |
char const * | resetCauseText |
The last main cause as text. |
#define orAP | ( | mask | ) |
Set (boolean or operation) port-bits.
These low level helpers would / should hardly be called directly by user / application software.
#define andAP | ( | mask | ) |
Unset (boolean and operation) port bits.
These low level helpers would / should hardly be called directly by user / application software.
#define orBP | ( | mask | ) |
Set (boolean or operation) port-bits.
These low level helpers would / should hardly be called directly by user / application software.
#define andBP | ( | mask | ) |
Unset (boolean and operation) port bits.
These low level helpers would / should hardly be called directly by user / application software.
#define orCP | ( | mask | ) |
Set (boolean or operation) port-bits.
These low level helpers would / should hardly be called directly by user / application software.
#define andCP | ( | mask | ) |
Unset (boolean and operation) port bits.
These low level helpers would / should hardly be called directly by user / application software.
#define orDP | ( | mask | ) |
Set (boolean or operation) port-bits.
These low level helpers would / should hardly be called directly by user / application software.
#define andDP | ( | mask | ) |
Unset (boolean and operation) port bits.
These low level helpers would / should hardly be called directly by user / application software.
#define orPort | ( | port, | |
mask | |||
) |
Set (boolean or operation) port-bits.
This low level helper would / should hardly be called directly by user / application software.
port | The port's letter (A, B, C ...) |
mask | The value to be ORed to PORTx |
#define setPort | ( | port, | |
value | |||
) |
Set all port-bits.
This low level helper would / should hardly be called directly by user / application software.
port | The port's letter (A, B, C ...) |
value | The value to be assigned to PORTx |
#define andPort | ( | port, | |
mask | |||
) |
Unset (boolean and operation) port-bits.
This low level helper would / should hardly be called directly by user / application software.
port | The port's letter (A, B, C ...) |
mask | The value to be ANDed to PORTx |
#define xorPort | ( | port, | |
mask | |||
) |
Toggle (boolean xor operation) port-bits.
This low level helper would / should hardly be called directly by user / application software.
port | The port's letter (A, B, C ...) |
mask | The value to be XORed to PORTx (by using the PINx trick) |
#define toPort | ( | port, | |
mask | |||
) |
Output to a port (by letter)
This low level helper would / should hardly be called directly by user / application software.
port | The port's letter (A, B, C ...) |
mask | The value to be set resp. output to PORTx |
#define fromPort | ( | port | ) |
Re-read output from a port (by letter)
This low level helper would / should hardly be called directly by user / application software.
port | The port's letter (A, B, C ...) |
#define inPort | ( | port | ) |
Input port (by letter)
This low level helper would / should hardly be called directly by user / application software.
port | The port's letter (A, B, C ...) |
#define inpPins | ( | port, | |
mask | |||
) |
Set port pins as input.
This is a low level configuration function. It should hardly be called directly by user / application software (except with good knowledge and care).
port | The port's letter (A, B, C ...) |
mask | Bit values of 1 mark the bits reps. pins to be set to input |
#define outPins | ( | port, | |
mask | |||
) |
Set port pins as output.
This is a low level configuration function. It should hardly be called directly by user / application software (except with good knowledge and care).
port | The port's letter (A, B, C ...) |
mask | Bit values of 1 mark the bits reps. pins to be set to input |
#define dirPort | ( | port | ) |
Direction port (by letter)
This low level helper would / should hardly be called directly by user / application software.
port | The port's letter (A, B, C ...) |
void initSystemRes | ( | void | ) |
Initialise system resources after reset or restart.
This function essentially calls all other initialisation functions in appropriate order (while interrupts are disabled). At return interrupts are enabled.
This function shall never be called directly by user software. To cause a software restart use systemAbort(uint8_t cause).
void initStatusLeds | ( | uint8_t | LEDgnStart, |
uint8_t | LEDrdStart | ||
) |
Initialisation of status / test LEDs (if any)
LEDgnStart | start value for the green LED (ON or OFF) |
LEDrdStart | start value for the red LED (ON or OFF) |
int main | ( | void | ) |
The system start.
This is the reset entry point (where it all begins). This function is weAutSys' system software. It must not be supplied by user / application software.
User / application software is written by supplying one or more cyclic or event driven threads.
The system start.
This function is the bootloader's program entry. It contains the full (protocol AVR109) state machine.
void setAbortCommand | ( | uint8_t | command | ) |
Set the abort cause respectively command.
This function will set the the abort command or cause to the parameter value as long as the current state is PLCstop
or PLCrun
.
In other words: From state run or stop any state can be set including an abort / fault state. But an abort / fault state will not be left or changed by this function.
command | the new run stop fault abort state / command |
uint8_t resetCauses |
The last reset cause(s)
This is the state of the MCU Status Register read very early at system restart.
The register will be reset after setting this variable.
This variable must not be modified elsewhere.
char const* resetCauseText |
The last main cause as text.
This is a text describing the main reset cause according to resetCauses
. It will be set at system start.
Not to be modified elsewhere.
The text will be at least 11 characters long including at least one trailing blank. It is in flash memory (program space). In case of full bootloader integration it will be a 32 bit address value.
uint8_t abortCommand |
The abort command respectively cause.
Values (in Hex) assigned are:
00 : 0perate, run n0rmally
B0 : Block 0peration, stop (no application threads scheduled, PLCstop) ED : unExpected watchDog timeout
EC : Exit by abort Command
Any value not 0x00 and not 0xB0 will drive the system through a complete reset / restart procedure.
If 0x00 or 0xB0 this variable is set by system software if the corresponding abort conditions are diagnosed. The same can be done by user / application software if adequate.