ESOS32
ESOSOn32-bitProcessors
Data Structures | Macros | Typedefs | Enumerations
all_generic.h File Reference

Embedded Systems Operating System 32 bit (ESOS32) definitions to make ESOS32 code more generic and portable. More...

#include <stdint.h>
Include dependency graph for all_generic.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

union  _UINT8
 
union  _UINT16
 
union  _UINT32
 

Macros

#define HELLO_MSG   "\n" __FILE__ ", built on " __DATE__ " at " __TIME__ "\n"
 
#define LSB(a)
 
#define MSB(a)
 
#define LOWER_WORD(a)
 
#define UPPER_WORD(a)
 
#define LOWER_LSB(a)
 
#define LOWER_MSB(a)
 
#define UPPER_LSB(a)
 
#define UPPER_MSB(a)
 
#define OK   TRUE
 
#define FAIL   FALSE
 
#define ON   TRUE
 
#define OFF   FALSE
 
#define HIGH   TRUE
 
#define LOW   FALSE
 
#define ENABLE   TRUE
 
#define DISABLE   FALSE
 
#define NULLPTR   0
 
#define NULLIDX   0xFF
 
#define ESOS_BIT0   0x0001
 
#define ESOS_BIT1   0x0002
 
#define ESOS_BIT2   0x0004
 
#define ESOS_BIT3   0x0008
 
#define ESOS_BIT4   0x0010
 
#define ESOS_BIT5   0x0020
 
#define ESOS_BIT6   0x0040
 
#define ESOS_BIT7   0x0080
 
#define ESOS_BIT8   0x0100
 
#define ESOS_BIT9   0x0200
 
#define ESOS_BIT10   0x0400
 
#define ESOS_BIT11   0x0800
 
#define ESOS_BIT12   0x1000
 
#define ESOS_BIT13   0x2000
 
#define ESOS_BIT14   0x4000
 
#define ESOS_BIT15   0x8000
 
#define ESOS_BIT16   0x00010000
 
#define ESOS_BIT17   0x00020000
 
#define ESOS_BIT18   0x00040000
 
#define ESOS_BIT19   0x00080000
 
#define ESOS_BIT20   0x00100000
 
#define ESOS_BIT21   0x00200000
 
#define ESOS_BIT22   0x00400000
 
#define ESOS_BIT23   0x00800000
 
#define ESOS_BIT24   0x01000000
 
#define ESOS_BIT25   0x02000000
 
#define ESOS_BIT26   0x04000000
 
#define ESOS_BIT27   0x08000000
 
#define ESOS_BIT28   0x10000000
 
#define ESOS_BIT29   0x20000000
 
#define ESOS_BIT30   0x40000000
 
#define ESOS_BIT31   0x80000000
 
#define BIT_SET_MASK(var, mask)
 
#define BIT_CLEAR_MASK(var, mask)
 
#define BIT_TOGGLE_MASK(var, mask)
 
#define IS_BIT_SET_MASK(var, mask)
 
#define IS_BIT_CLEAR_MASK(var, mask)
 
#define BIT_SET(var, bitnum)
 
#define BIT_CLEAR(var, bitnum)
 
#define BIT_TOGGLE(var, bitnum)
 
#define IS_BIT_SET(var, bitnum)
 
#define IS_BIT_CLEAR(var, bitnum)
 

Typedefs

typedef union _UINT8 UINT8
 
typedef union _UINT16 UINT16
 
typedef union _UINT32 UINT32
 
typedef enum _BOOL BOOL
 

Enumerations

enum  _BOOL { FALSE = 0, TRUE }
 

Detailed Description

Embedded Systems Operating System 32 bit (ESOS32) definitions to make ESOS32 code more generic and portable.

Note
This file is to be included in ESOS32 builds on all platforms.

Definition in file all_generic.h.

Macro Definition Documentation

◆ BIT_CLEAR

#define BIT_CLEAR (   var,
  bitnum 
)

Clears a single bit in a variable

Parameters
varvariable
bitnumNumber (0-?) of the bit that should be cleared

Definition at line 628 of file all_generic.h.

◆ BIT_CLEAR_MASK

#define BIT_CLEAR_MASK (   var,
  mask 
)

Clear the bits of a variable according to a mask

Parameters
varvariable containing the bits to "clear"
maskvarable with ONEs in the locations where you want to clear bits

Definition at line 586 of file all_generic.h.

◆ BIT_SET

#define BIT_SET (   var,
  bitnum 
)

Sets a single bit in a variable

Parameters
varvariable
bitnumNumber (0-?) of the bit that should be set

Definition at line 621 of file all_generic.h.

◆ BIT_SET_MASK

#define BIT_SET_MASK (   var,
  mask 
)

Sets the bits of a variable according to a mask

Parameters
varvariable containing the bits to "set"
maskvarable with ONEs in the locations where you want to set bits

Definition at line 579 of file all_generic.h.

◆ BIT_TOGGLE

#define BIT_TOGGLE (   var,
  bitnum 
)

Toggle a single bit in a variable

Parameters
varvariable
bitnumNumber (0-?) of the bit that should be toggleed

Definition at line 635 of file all_generic.h.

◆ BIT_TOGGLE_MASK

#define BIT_TOGGLE_MASK (   var,
  mask 
)

Toggle the bits of a variable according to a mask

Parameters
varvariable containing the bits to "toggle"
maskvarable with ONEs in the locations where you want to toggle bits

Definition at line 593 of file all_generic.h.

◆ ESOS_BIT0

#define ESOS_BIT0   0x0001

Mask to represent bit 0 (the LSb)

Definition at line 446 of file all_generic.h.

◆ ESOS_BIT1

#define ESOS_BIT1   0x0002

Mask to represent bit 1

Definition at line 450 of file all_generic.h.

◆ ESOS_BIT10

#define ESOS_BIT10   0x0400

Mask to represent bit 10

Definition at line 486 of file all_generic.h.

◆ ESOS_BIT11

#define ESOS_BIT11   0x0800

Mask to represent bit 11

Definition at line 490 of file all_generic.h.

◆ ESOS_BIT12

#define ESOS_BIT12   0x1000

Mask to represent bit 12

Definition at line 494 of file all_generic.h.

◆ ESOS_BIT13

#define ESOS_BIT13   0x2000

Mask to represent bit 13

Definition at line 498 of file all_generic.h.

◆ ESOS_BIT14

#define ESOS_BIT14   0x4000

Mask to represent bit 14

Definition at line 502 of file all_generic.h.

◆ ESOS_BIT15

#define ESOS_BIT15   0x8000

Mask to represent bit 15 (the MSb of an uint16)

Definition at line 506 of file all_generic.h.

◆ ESOS_BIT16

#define ESOS_BIT16   0x00010000

Mask to represent bit 16

Definition at line 510 of file all_generic.h.

◆ ESOS_BIT17

#define ESOS_BIT17   0x00020000

Mask to represent bit 17

Definition at line 514 of file all_generic.h.

◆ ESOS_BIT18

#define ESOS_BIT18   0x00040000

Mask to represent bit 18

Definition at line 518 of file all_generic.h.

◆ ESOS_BIT19

#define ESOS_BIT19   0x00080000

Mask to represent bit 19

Definition at line 522 of file all_generic.h.

◆ ESOS_BIT2

#define ESOS_BIT2   0x0004

Mask to represent bit 2

Definition at line 454 of file all_generic.h.

◆ ESOS_BIT20

#define ESOS_BIT20   0x00100000

Mask to represent bit 20

Definition at line 526 of file all_generic.h.

◆ ESOS_BIT21

#define ESOS_BIT21   0x00200000

Mask to represent bit 21

Definition at line 530 of file all_generic.h.

◆ ESOS_BIT22

#define ESOS_BIT22   0x00400000

Mask to represent bit 22

Definition at line 534 of file all_generic.h.

◆ ESOS_BIT23

#define ESOS_BIT23   0x00800000

Mask to represent bit 23

Definition at line 538 of file all_generic.h.

◆ ESOS_BIT24

#define ESOS_BIT24   0x01000000

Mask to represent bit 24

Definition at line 542 of file all_generic.h.

◆ ESOS_BIT25

#define ESOS_BIT25   0x02000000

Mask to represent bit 25

Definition at line 546 of file all_generic.h.

◆ ESOS_BIT26

#define ESOS_BIT26   0x04000000

Mask to represent bit 26

Definition at line 550 of file all_generic.h.

◆ ESOS_BIT27

#define ESOS_BIT27   0x08000000

Mask to represent bit 27

Definition at line 554 of file all_generic.h.

◆ ESOS_BIT28

#define ESOS_BIT28   0x10000000

Mask to represent bit 28

Definition at line 558 of file all_generic.h.

◆ ESOS_BIT29

#define ESOS_BIT29   0x20000000

Mask to represent bit 29

Definition at line 562 of file all_generic.h.

◆ ESOS_BIT3

#define ESOS_BIT3   0x0008

Mask to represent bit 3

Definition at line 458 of file all_generic.h.

◆ ESOS_BIT30

#define ESOS_BIT30   0x40000000

Mask to represent bit 30

Definition at line 566 of file all_generic.h.

◆ ESOS_BIT31

#define ESOS_BIT31   0x80000000

Mask to represent bit 31 (the MSb of an uint32)

Definition at line 570 of file all_generic.h.

◆ ESOS_BIT4

#define ESOS_BIT4   0x0010

Mask to represent bit 4

Definition at line 462 of file all_generic.h.

◆ ESOS_BIT5

#define ESOS_BIT5   0x0020

Mask to represent bit 5

Definition at line 466 of file all_generic.h.

◆ ESOS_BIT6

#define ESOS_BIT6   0x0040

Mask to represent bit 6

Definition at line 470 of file all_generic.h.

◆ ESOS_BIT7

#define ESOS_BIT7   0x0080

Mask to represent bit 7 (the MSb of a uint8)

Definition at line 474 of file all_generic.h.

◆ ESOS_BIT8

#define ESOS_BIT8   0x0100

Mask to represent bit 8 (the LSb of the most-significant byte in an uint8)

Definition at line 478 of file all_generic.h.

◆ ESOS_BIT9

#define ESOS_BIT9   0x0200

Mask to represent bit 9

Definition at line 482 of file all_generic.h.

◆ FAIL

#define FAIL   FALSE

another way to say FALSE

Definition at line 416 of file all_generic.h.

◆ IS_BIT_CLEAR

#define IS_BIT_CLEAR (   var,
  bitnum 
)

Determine if a bit is cleared in a variable

Parameters
varvariable containing the bits to test
bitnumNumber (0-?) of the bit to test for being cleared
Return values
TRUEif the bit is clear
FALSEotherwise

Definition at line 653 of file all_generic.h.

◆ IS_BIT_CLEAR_MASK

#define IS_BIT_CLEAR_MASK (   var,
  mask 
)

Determine if one or more bits are cleared in a variable

Parameters
varvariable containing the bits to test
maskvarable with ONEs in the locations where you want to check for cleared bits
Return values
TRUEif one or more of the mask bits are cleared in the variable
FALSEif none of the mask bits are cleared
Note
Does NOT test to see if you variable has ALL mask bits cleared

Definition at line 613 of file all_generic.h.

◆ IS_BIT_SET

#define IS_BIT_SET (   var,
  bitnum 
)

Determine if a bit is set in a variable

Parameters
varvariable containing the bits to test
bitnumNumber (0-?) of the bit to test for being set
Return values
TRUEif the bit is set
FALSEotherwise

Definition at line 644 of file all_generic.h.

◆ IS_BIT_SET_MASK

#define IS_BIT_SET_MASK (   var,
  mask 
)

Determine if one or more bits are set in a variable

Parameters
varvariable containing the bits to test
maskvarable with ONEs in the locations where you want to check for set bits
Return values
TRUEif one or more of the mask bits are set in the variable
FALSEif none of the mask bits are set
Note
Does NOT test to see if you variable has ALL mask bits set

Definition at line 603 of file all_generic.h.

◆ LOWER_LSB

#define LOWER_LSB (   a)

Returns the Least-Significant-BYTE (uint8) of a UINT32 structure

Parameters
aUINT32 structure holding a 32-bit value
Returns
Byte 0 (LSB) of the 32-bit value in the UINT32 struct

Definition at line 378 of file all_generic.h.

◆ LOWER_MSB

#define LOWER_MSB (   a)

Returns the 2nd most least-Significant-BYTE (uint8) of a UINT32 structure

Parameters
aUINT32 structure holding a 32-bit value
Returns
Byte 1 of the 32-bit value in the UINT32 struct

Definition at line 385 of file all_generic.h.

◆ LOWER_WORD

#define LOWER_WORD (   a)

Returns the Least-Significant-WORD (uint16) of a UINT32 structure

Parameters
aUINT32 structure holding a 32-bit value
Returns
LSW of the 32-bit value in the UINT32 struct

Definition at line 364 of file all_generic.h.

◆ LSB

#define LSB (   a)

Returns the Least-Significant-Byte (LSB)

Parameters
aUINT16 structure holding a 16-bit value
Returns
LSB of the 16-bit value in the UINT16 struct

Definition at line 198 of file all_generic.h.

◆ MSB

#define MSB (   a)

Returns the Most-Significant-Byte (MSB)

Parameters
aUINT16 structure holding a 16-bit value
Returns
MSB of the 16-bit value in the UINT16 struct

Definition at line 205 of file all_generic.h.

◆ NULLIDX

#define NULLIDX   0xFF

An unitialized index value

Definition at line 437 of file all_generic.h.

◆ NULLPTR

#define NULLPTR   0

An uninitialized pointer

Definition at line 435 of file all_generic.h.

◆ OK

#define OK   TRUE

another way to say TRUE

Definition at line 414 of file all_generic.h.

◆ UPPER_LSB

#define UPPER_LSB (   a)

Returns the 3nd most least-Significant-BYTE (uint8) of a UINT32 structure

Parameters
aUINT32 structure holding a 32-bit value
Returns
Byte 2 of the 32-bit value in the UINT32 struct

Definition at line 392 of file all_generic.h.

◆ UPPER_MSB

#define UPPER_MSB (   a)

Returns the Most-Significant-BYTE (uint8) of a UINT32 structure

Parameters
aUINT32 structure holding a 32-bit value
Returns
Byte 3 (MSB) of the 32-bit value in the UINT32 struct

Definition at line 399 of file all_generic.h.

◆ UPPER_WORD

#define UPPER_WORD (   a)

Returns the Most-Significant-WORD (uint16) of a UINT32 structure

Parameters
aUINT32 structure holding a 32-bit value
Returns
MSW of the 32-bit value in the UINT32 struct

Definition at line 371 of file all_generic.h.

Typedef Documentation

◆ BOOL

typedef enum _BOOL BOOL

A single bit quantity. Takes on the value TRUE or FALSE.

◆ UINT16

typedef union _UINT16 UINT16

Union structure to hold uint16s to provide access to 16-bit data with different "viewpoints" (or casts, if you will).

Note
Works on machines that store their data little-endian. If you use big-endian, the members will have to be reordered!
Prefix for all UINT16 structs is U16_
uint8_t u8_a, u8_b;
UINT16 U16_y;
U16_y._uint16 = 0xF00D;
u8_b = U16_y.u8Bytes[0]; // u8_b equals 0x0D
u8_a = U16_y.u8MSb; // u8_a equals 0xF0
while (U16_y.b7); // falls through since bit 7 is 0 (FALSE)

◆ UINT32

typedef union _UINT32 UINT32

Union structure to hold an uint32 to provide access to 32-bit data with different "viewpoints" (or casts, if you will).

Note
Works on machines that store their data little-endian. If you use big-endian, the members will have to be reordered!
Prefix for all UINT32 structs is U32_
UINT32 U32_x;
uint16 u16_a;
uint8 u8_b;
UINT16 U16_y;
U32_x._uint32 = 0xDEADBEEF;
u16_a = U32_x.u16LoWord; // u16_a equals 0xBEEF
u8_b = U32_x.u8Bytes[0]; // u8_b equals 0xEF
u16_a = U32_x.u16Words[1]; // u16_a equals 0xDEAD
U16_y._uint16 = U32_x.u16LoWord; // where's the "BEEF"?
u8_b = U16_y.uMSb; // u8_b equals 0xBE
while (U32_x.b31); // infinite loop

◆ UINT8

typedef union _UINT8 UINT8

Union structure to hold an uint8 (byte) to provide access to 8-bit data with different "viewpoints" (or casts, if you will).

Note
Works on machines that store their data little-endian. If you use big-endian, the members will have to be reordered!
Prefix for all UINT8 structs is U8_

Enumeration Type Documentation

◆ _BOOL

enum _BOOL

A single bit quantity. Takes on the value TRUE or FALSE.

Enumerator
FALSE 

False, not true, off, zero

TRUE 

True, not false, on, one

Definition at line 406 of file all_generic.h.

_UINT32
Definition: all_generic.h:229
_UINT16::b7
unsigned b7
Definition: all_generic.h:164
_UINT32::b31
unsigned b31
Definition: all_generic.h:353
_UINT32::u16Words
uint16_t u16Words[2]
Definition: all_generic.h:252
_UINT16::u8Bytes
uint8_t u8Bytes[2]
Definition: all_generic.h:138
_UINT16::_uint16
uint16_t _uint16
Definition: all_generic.h:117
_UINT32::u16LoWord
uint16_t u16LoWord
Definition: all_generic.h:246
_UINT16
Definition: all_generic.h:115
_UINT32::u8Bytes
uint8_t u8Bytes[4]
Definition: all_generic.h:256
_UINT32::_uint32
uint32_t _uint32
Definition: all_generic.h:231