Skip to content

File syn_defs.h

FileList > common > syn_defs.h

Go to the source code of this file

Common type definitions and status codes for SyntropicOS. More...

  • #include <stddef.h>
  • #include <stdint.h>

Public Types

Type Name
enum SYN_GPIO_Mode
GPIO pin mode / direction.
typedef uint16_t SYN_GPIO_Pin
Abstract GPIO pin identifier.
enum SYN_GPIO_State
Logical state of a GPIO pin.
enum SYN_Status
Return status used by all SyntropicOS functions.
typedef uint8_t SYN_UARTInstance
Identifies a UART peripheral instance (0, 1, 2, …).
enum bool
C99 bool fallback for pre-C99 compilers.

Macros

Type Name
define SYN_ABS (x) (((x) &lt; 0) ? -(x) : (x))
define SYN_ARRAY_SIZE (arr) (sizeof(arr) / sizeof((arr)[0]))
define SYN_CLAMP (val, lo, hi) (((val) &lt; (lo)) ? (lo) : (((val) &gt; (hi)) ? (hi) : (val)))
define SYN_MAX (a, b) (((a) &gt; (b)) ? (a) : (b))
Maximum of two values.
define SYN_MIN (a, b) (((a) &lt; (b)) ? (a) : (b))
Minimum of two values.
define SYN_SIGN (x) (((x) &gt; 0) - ((x) &lt; 0))
define SYN_UNUSED_VAR (x) ((void)(x))

Detailed Description

This header is included by virtually every other SyntropicOS file. It provides the fundamental types, enumerations, and constants used throughout the library.

Public Types Documentation

enum SYN_GPIO_Mode

GPIO pin mode / direction.

enum SYN_GPIO_Mode {
    SYN_GPIO_INPUT = 0,
    SYN_GPIO_OUTPUT = 1,
    SYN_GPIO_INPUT_PULLUP = 2,
    SYN_GPIO_INPUT_PULLDOWN = 3,
    SYN_GPIO_OUTPUT_OD = 4
};


typedef SYN_GPIO_Pin

Abstract GPIO pin identifier.

typedef uint16_t SYN_GPIO_Pin;

The meaning of this value is platform-specific. It may encode a port+pin pair, a flat pin number, or any scheme the port layer defines.


enum SYN_GPIO_State

Logical state of a GPIO pin.

enum SYN_GPIO_State {
    SYN_GPIO_LOW = 0,
    SYN_GPIO_HIGH = 1
};


enum SYN_Status

Return status used by all SyntropicOS functions.

enum SYN_Status {
    SYN_OK = 0,
    SYN_ERROR = -1,
    SYN_BUSY = -2,
    SYN_TIMEOUT = -3,
    SYN_INVALID_PARAM = -4,
    SYN_NOT_IMPLEMENTED = -5
};


typedef SYN_UARTInstance

Identifies a UART peripheral instance (0, 1, 2, …).

typedef uint8_t SYN_UARTInstance;


enum bool

C99 bool fallback for pre-C99 compilers.

enum bool {
    false = 0,
    true = 1
};


Macro Definition Documentation

define SYN_ABS

#define SYN_ABS (
    x
) `(((x) < 0) ? -(x) : (x))`

Absolute value


define SYN_ARRAY_SIZE

#define SYN_ARRAY_SIZE (
    arr
) `(sizeof(arr) / sizeof((arr)[0]))`

Number of elements in a statically-allocated array.


define SYN_CLAMP

#define SYN_CLAMP (
    val,
    lo,
    hi
) `(((val) < (lo)) ? (lo) : (((val) > (hi)) ? (hi) : (val)))`

Clamp value to [lo, hi]


define SYN_MAX

Maximum of two values.

#define SYN_MAX (
    a,
    b
) `(((a) > (b)) ? (a) : (b))`


define SYN_MIN

Minimum of two values.

#define SYN_MIN (
    a,
    b
) `(((a) < (b)) ? (a) : (b))`


define SYN_SIGN

#define SYN_SIGN (
    x
) `(((x) > 0) - ((x) < 0))`

Sign: returns -1, 0, or +1


define SYN_UNUSED_VAR

#define SYN_UNUSED_VAR (
    x
) `((void)(x))`

Suppress unused-variable warnings.



The documentation for this class was generated from the following file src/syntropic/common/syn_defs.h