weAutSys utility / library functions to be used also by application / user software
This file contains the definitions for weAutSys' (weAut_01) utility / library functions to be used also by application / user software. This is system software and must not be modified for user or application programs.
This file is part of weAutSys <weinert-automation.de>
Copyright © 2011 Albrecht Weinert, Bochum
Defines | |
#define | clearBitMask(bitNum) |
Get the 8 bit "Clear bit mask" for the given bit. | |
#define | INDEX_OFFSET_LIST2 125 |
Offset for token found in second list by searchTokenIn. | |
#define | setBitMask(bitNum) |
Get the 8 bit "Set bit mask" for the given bit. | |
Optimised Divide functions | |
#define | mod2pow(div, po2) |
Modulo by power of 2. | |
u8div_t | divByVal10 (uint8_t div) __attribute__((pure)) |
Divide an unsigned byte by the constant 10. | |
u8div_t | divWByVal10toByte (uint16_t div) __attribute__((pure)) |
Divide an unsigned word by by the constant 10 for a byte quotient. | |
u16div_t | divWByVal1000 (uint16_t div) __attribute__((pure)) |
Divide an unsigned word by by the constant 1000. | |
uint8_t | mod16byVal7 (uint16_t val) __attribute__((pure)) |
Modulo 7 of an unsigned 16 bit value. | |
uint8_t | mod8byVal7 (uint8_t val) __attribute__((pure)) |
Modulo 7 of an unsigned 8 bit value. | |
uint32_t | div32byVal512 (const uint32_t div) __attribute__((pure)) |
Divide unsigned 32 bit by the constant 512. | |
uint16_t | div16byVal512 (const uint16_t div) __attribute__((pure)) |
Divide unsigned 16 bit by the constant 512. | |
uint32_t | div32byVal1024 (const uint32_t div) __attribute__((pure)) |
Divide unsigned 32 bit by the constant 1024. | |
uint32_t | div32byVal2048 (const uint32_t div) __attribute__((pure)) |
Divide unsigned 32 bit by the constant 2048. | |
uint32_t | div32byVal256 (const uint32_t div) __attribute__((pure)) |
Divide unsigned 32 bit by 256. | |
uint32_t | div32byVal128 (const uint32_t div) __attribute__((pure)) |
Divide unsigned 32 bit by the constant 128. | |
Functions | |
uint8_t | asDigit (uint8_t c) __attribute__((always_inline)) |
Recognise one digit. | |
void | eightHexs (char *begin, uint32_t value) |
Set an eight digit hexadecimal number with leading zeroes into a string. | |
void | eightHexsBE (char *begin, uint32_t value) |
Set an eight digit big endian hexadecimal number with into a string. | |
char * | form16BytSeq (char *s, uint8_t *seq) |
Format a sequence of 16 bytes in four hex groups and as characters. | |
char * | formModTelegr (char *s, struct modTelegr_t *modTeleg) |
Format a Modbus telegram. | |
char * | formN20BytSeq (char *s, uint8_t *seq, uint8_t n) |
Format a sequence of 0..20 bytes in five hex groups and as characters. | |
void | fourDigs (char *begin, uint16_t value) |
Set a four decimal digit number into a string. | |
void | fourHexs (char *begin, uint16_t value) |
Set a four digit hexadecimal number with leading zeroes into a string. | |
void | fourHexsBE (char *begin, uint16_t value) |
Set an four digit big endian hexadecimal big endian number into a string. | |
char * | getFirstSVNtokenP (char *dest, char const *src, uint8_t mxLen) |
Copy the first SVN token or a full string from program space. | |
uint8_t | isContainedIn (char s[], const uint8_t c) |
Check if a character is contained in a RAM string. | |
uint8_t | isContainedIn_P (char s[], const uint8_t c) |
Check if a character is contained in a flash string. | |
uint8_t | parse2hex (uint8_t *res, char s[], uint8_t si) |
Parse a two digit hexadecimal number. | |
uint8_t | parseByteNum (uint8_t *res, char s[], uint8_t si) |
Parse a one byte number. | |
uint8_t | parseDWordNum (uint32_t *res, char s[], uint8_t si) |
Parse a four byte number. | |
uint8_t | parseWordNum (uint16_t *res, char s[], uint8_t si) |
Parse a two byte number. | |
uint8_t | searchFirstToken (char s[], uint8_t si, uint8_t len) |
Search the first token in a short (RAM) string. | |
uint8_t | searchTokenEnd (char s[], uint8_t si, uint8_t len) |
Search the the end of a token in a short (RAM) string. | |
uint8_t | searchTokenIn (char s[], uint8_t si, uint8_t se, char const *const *list, char const *const *list2) |
Match a (short) token in a (RAM) string to a list of flash strings. | |
uint8_t | searchTokenStart (char s[], uint8_t si, uint8_t len) |
Search the next token in a short (RAM) string. | |
void | threeDigs (char *begin, uint16_t value) |
Set a three decimal digit number with leading zeroes into a string. | |
void | threeDigsB (char *begin, uint8_t value) |
Set a three decimal digit number with leading zeroes into a string. | |
void | twoDigs (char *begin, uint8_t value) |
Set a two decimal digit number with leading zeroes into a string. | |
void | twoHexs (char *s, uint8_t value) __attribute__((always_inline)) |
Set a two hexadecimal digit number with leading zeroes into a string. | |
Optimised Multiplication functions | |
uint32_t | mul16with8 (const uint16_t f16, const uint8_t f8) __attribute__((pure)) |
Multiply unsigned 16 bit with 8 bit. | |
uint32_t | mul16 (const uint16_t ab, const uint16_t cd) __attribute__((pure)) |
Multiply unsigned 16 bit with 16 bit. | |
uint32_t | mul16with17 (const uint16_t ab, const uint16_t cd) __attribute__((pure)) |
Multiply unsigned 16 bit with 17 bit. | |
uint32_t | mul32withVal512 (const uint32_t fac) __attribute__((pure)) |
Multiply unsigned 32 bit with the constant 512. | |
uint16_t | mul16withVal512 (const uint16_t fac) __attribute__((pure)) |
Optimised Compare functions | |
uint8_t | geU32ModAr (uint32_t a, uint32_t b) __attribute__((always_inline)) |
A 32 bit unsigned greater equal (ge) comparison for modulo arithmetic. | |
uint8_t | leU32ModAr (uint32_t a, uint32_t b) __attribute__((always_inline)) |
A 32 bit unsigned less or equal (le) comparison for modulo arithmetic. | |
Endianess Handling functions | |
void | toggle32endian (ucnt32_t *value) |
Toggle the endianess of a 32 bit value. | |
void | toggle16endian (ucnt16_t *value) |
Toggle the endianess of a 16 bit value. | |
uint16_t | convert16endian (uint16_t value) |
Convert the endianess of a 16 bit value. | |
uint32_t | convert32endian (uint32_t value) |
Convert the endianess of a 32 bit value. | |
void | add16littleTo32bigEndian (ucnt32_t *opRes, uint16_t op2) |
Add a normal (little endian) 16 bit value to 32 bit big endian. | |
Variables | |
uint8_t const | clearBitMasks [8] |
Clear bit masks (table in flash memory) | |
uint8_t const | setBitMasks [8] |
Set bit masks (table in flash memory) |