ChibiOS/HAL
6.1.0
|
I/O Ports Abstraction Layer. More...
I/O Ports Abstraction Layer.
This module defines an abstract interface for digital I/O ports. Note that most I/O ports functions are just macros. The macros have default software implementations that can be redefined in a PAL Low Level Driver if the target hardware supports special features like, for example, atomic bit set/reset/masking. Please refer to the ports specific documentation for details.
The PAL Driver driver has the advantage to make the access to the I/O ports platform independent and still be optimized for the specific architectures.
Note that the PAL Low Level Driver may also offer non standard macro and functions in order to support specific features but, of course, the use of such interfaces would not be portable. Such interfaces shall be marked with the architecture name inside the function names.
HAL_USE_PAL
option must be enabled in halconf.h
.In implementing a PAL Low Level Driver there are some rules/behaviors that should be respected.
The behavior is not specified but there are implementations better than others, this is the list of possible implementations, preferred options are on top:
The behavior is not specified but there are implementations better than others, this is the list of possible implementations, preferred options are on top:
The behavior is not specified.
The behavior is not specified.
The behavior is not specified.
Macros | |
#define | PAL_PORT_BIT(n) ((ioportmask_t)(1U << (n))) |
Port bit helper macro. More... | |
#define | PAL_GROUP_MASK(width) ((ioportmask_t)(1U << (width)) - 1U) |
Bits group mask helper. More... | |
#define | _IOBUS_DATA(name, port, width, offset) {port, PAL_GROUP_MASK(width), offset} |
Data part of a static I/O bus initializer. More... | |
#define | IOBUS_DECL(name, port, width, offset) IOBus name = _IOBUS_DATA(name, port, width, offset) |
Static I/O bus initializer. More... | |
#define | IOPORT1 0 |
First I/O port identifier. More... | |
#define | pal_lld_init(config) _pal_lld_init(config) |
Low level PAL subsystem initialization. More... | |
#define | pal_lld_readport(port) 0U |
Reads the physical I/O port states. More... | |
#define | pal_lld_readlatch(port) 0U |
Reads the output latch. More... | |
#define | pal_lld_writeport(port, bits) |
Writes a bits mask on a I/O port. More... | |
#define | pal_lld_setport(port, bits) |
Sets a bits mask on a I/O port. More... | |
#define | pal_lld_clearport(port, bits) |
Clears a bits mask on a I/O port. More... | |
#define | pal_lld_toggleport(port, bits) |
Toggles a bits mask on a I/O port. More... | |
#define | pal_lld_readgroup(port, mask, offset) 0U |
Reads a group of bits. More... | |
#define | pal_lld_writegroup(port, mask, offset, bits) |
Writes a group of bits. More... | |
#define | pal_lld_setgroupmode(port, mask, offset, mode) _pal_lld_setgroupmode(port, mask << offset, mode) |
Pads group mode setup. More... | |
#define | pal_lld_readpad(port, pad) PAL_LOW |
Reads a logical state from an I/O pad. More... | |
#define | pal_lld_writepad(port, pad, bit) |
Writes a logical state on an output pad. More... | |
#define | pal_lld_setpad(port, pad) |
Sets a pad logical state to PAL_HIGH . More... | |
#define | pal_lld_clearpad(port, pad) |
Clears a pad logical state to PAL_LOW . More... | |
#define | pal_lld_togglepad(port, pad) |
Toggles a pad logical state. More... | |
#define | pal_lld_setpadmode(port, pad, mode) |
Pad mode setup. More... | |
#define | pal_lld_get_pad_event(port, pad) &_pal_events[0]; (void)(port); (void)pad |
Returns a PAL event structure associated to a pad. More... | |
#define | pal_lld_get_line_event(line) &_pal_events[0]; (void)line |
Returns a PAL event structure associated to a line. More... | |
Pads mode constants | |
#define | PAL_MODE_RESET 0U |
After reset state. More... | |
#define | PAL_MODE_UNCONNECTED 1U |
Safe state for unconnected pads. More... | |
#define | PAL_MODE_INPUT 2U |
Regular input high-Z pad. More... | |
#define | PAL_MODE_INPUT_PULLUP 3U |
Input pad with weak pull up resistor. More... | |
#define | PAL_MODE_INPUT_PULLDOWN 4U |
Input pad with weak pull down resistor. More... | |
#define | PAL_MODE_INPUT_ANALOG 5U |
Analog input mode. More... | |
#define | PAL_MODE_OUTPUT_PUSHPULL 6U |
Push-pull output pad. More... | |
#define | PAL_MODE_OUTPUT_OPENDRAIN 7U |
Open-drain output pad. More... | |
Logic level constants | |
#define | PAL_LOW 0U |
Logical low state. More... | |
#define | PAL_HIGH 1U |
Logical high state. More... | |
PAL event modes | |
#define | PAL_EVENT_MODE_EDGES_MASK 3U |
Mask of edges field. More... | |
#define | PAL_EVENT_MODE_DISABLED 0U |
Channel disabled. More... | |
#define | PAL_EVENT_MODE_RISING_EDGE 1U |
Rising edge callback. More... | |
#define | PAL_EVENT_MODE_FALLING_EDGE 2U |
Falling edge callback. More... | |
#define | PAL_EVENT_MODE_BOTH_EDGES 3U |
Both edges callback. More... | |
PAL configuration options | |
#define | PAL_USE_CALLBACKS TRUE |
Enables synchronous APIs. More... | |
#define | PAL_USE_WAIT TRUE |
Enables synchronous APIs. More... | |
Low level driver helper macros | |
#define | _pal_init_event(e) |
Initializes a PAL event object. More... | |
#define | _pal_init_event(e) |
Initializes a PAL event object. More... | |
#define | _pal_init_event(e) |
Initializes a PAL event object. More... | |
#define | _pal_clear_event(e) |
Clears a PAL event object. More... | |
#define | _pal_clear_event(e) |
Clears a PAL event object. More... | |
#define | _pal_clear_event(e) |
Clears a PAL event object. More... | |
#define | _pal_isr_code(e) |
Common ISR code. More... | |
#define | _pal_isr_code(e) |
Common ISR code. More... | |
#define | _pal_isr_code(e) |
Common ISR code. More... | |
Macro Functions | |
#define | palInit() pal_lld_init() |
PAL subsystem initialization. More... | |
#define | palReadPort(port) ((void)(port), 0U) |
Reads the physical I/O port states. More... | |
#define | palReadLatch(port) ((void)(port), 0U) |
Reads the output latch. More... | |
#define | palWritePort(port, bits) ((void)(port), (void)(bits)) |
Writes a bits mask on a I/O port. More... | |
#define | palSetPort(port, bits) palWritePort(port, palReadLatch(port) | (bits)) |
Sets a bits mask on a I/O port. More... | |
#define | palClearPort(port, bits) palWritePort(port, palReadLatch(port) & ~(bits)) |
Clears a bits mask on a I/O port. More... | |
#define | palTogglePort(port, bits) palWritePort(port, palReadLatch(port) ^ (bits)) |
Toggles a bits mask on a I/O port. More... | |
#define | palReadGroup(port, mask, offset) ((palReadPort(port) >> (offset)) & (mask)) |
Reads a group of bits. More... | |
#define | palWriteGroup(port, mask, offset, bits) |
Writes a group of bits. More... | |
#define | palSetGroupMode(port, mask, offset, mode) |
Pads group mode setup. More... | |
#define | palReadPad(port, pad) ((palReadPort(port) >> (pad)) & 1U) |
Reads an input pad logic state. More... | |
#define | palWritePad(port, pad, bit) |
Writes a logic state on an output pad. More... | |
#define | palSetPad(port, pad) palSetPort(port, PAL_PORT_BIT(pad)) |
Sets a pad logic state to PAL_HIGH . More... | |
#define | palClearPad(port, pad) palClearPort(port, PAL_PORT_BIT(pad)) |
Clears a pad logic state to PAL_LOW . More... | |
#define | palTogglePad(port, pad) palTogglePort(port, PAL_PORT_BIT(pad)) |
Toggles a pad logic state. More... | |
#define | palSetPadMode(port, pad, mode) palSetGroupMode(port, PAL_PORT_BIT(pad), 0U, mode) |
Pad mode setup. More... | |
#define | palReadLine(line) palReadPad(PAL_PORT(line), PAL_PAD(line)) |
Reads an input line logic state. More... | |
#define | palWriteLine(line, bit) palWritePad(PAL_PORT(line), PAL_PAD(line), bit) |
Writes a logic state on an output line. More... | |
#define | palSetLine(line) palSetPad(PAL_PORT(line), PAL_PAD(line)) |
Sets a line logic state to PAL_HIGH . More... | |
#define | palClearLine(line) palClearPad(PAL_PORT(line), PAL_PAD(line)) |
Clears a line logic state to PAL_LOW . More... | |
#define | palToggleLine(line) palTogglePad(PAL_PORT(line), PAL_PAD(line)) |
Toggles a line logic state. More... | |
#define | palSetLineMode(line, mode) palSetPadMode(PAL_PORT(line), PAL_PAD(line), mode) |
Line mode setup. More... | |
#define | palEnablePadEventI(port, pad, mode) |
Pad event enable. More... | |
#define | palDisablePadEventI(port, pad) |
Pad event disable. More... | |
#define | palEnablePadEvent(port, pad, mode) |
Pad event enable. More... | |
#define | palDisablePadEvent(port, pad) |
Pad event disable. More... | |
#define | palEnableLineEventI(line, mode) palEnablePadEventI(PAL_PORT(line), PAL_PAD(line), mode) |
Line event enable. More... | |
#define | palDisableLineEventI(line) palDisablePadEventI(PAL_PORT(line), PAL_PAD(line)) |
Line event disable. More... | |
#define | palEnableLineEvent(line, mode) |
Line event enable. More... | |
#define | palDisableLineEvent(line) |
Line event disable. More... | |
#define | palSetPadCallback(port, pad, cb, arg) |
Associates a callback to a pad. More... | |
#define | palSetLineCallback(line, cb, arg) |
Associates a callback to a line. More... | |
Port related definitions | |
#define | PAL_IOPORTS_WIDTH 16U |
Width, in bits, of an I/O port. More... | |
#define | PAL_WHOLE_PORT ((ioportmask_t)0xFFFFU) |
Whole port mask. More... | |
Line handling macros | |
#define | PAL_LINE(port, pad) ((ioline_t)((uint32_t)(port)) | ((uint32_t)(pad))) |
Forms a line identifier. More... | |
#define | PAL_PORT(line) ((stm32_gpio_t *)(((uint32_t)(line)) & 0xFFFFFFF0U)) |
Decodes a port identifier from a line identifier. More... | |
#define | PAL_PAD(line) ((uint32_t)((uint32_t)(line) & 0x0000000FU)) |
Decodes a pad identifier from a line identifier. More... | |
#define | PAL_NOLINE 0U |
Value identifying an invalid line. More... | |
Typedefs | |
typedef void(* | palcallback_t) (void *arg) |
Type of a PAL event callback. More... | |
typedef uint32_t | ioportmask_t |
Digital I/O port sized unsigned type. More... | |
typedef uint32_t | iomode_t |
Digital I/O modes. More... | |
typedef uint32_t | ioline_t |
Type of an I/O line. More... | |
typedef uint32_t | ioportid_t |
Port Identifier. More... | |
typedef uint32_t | iopadid_t |
Type of an pad identifier. More... | |
Data Structures | |
struct | palevent_t |
Type of a PAL event record. More... | |
struct | IOBus |
I/O bus descriptor. More... | |
struct | PALConfig |
Generic I/O ports static initializer. More... | |
Functions | |
ioportmask_t | palReadBus (const IOBus *bus) |
Read from an I/O bus. More... | |
void | palWriteBus (const IOBus *bus, ioportmask_t bits) |
Write to an I/O bus. More... | |
void | palSetBusMode (const IOBus *bus, iomode_t mode) |
Programs a bus with the specified mode. More... | |
void | palSetPadCallbackI (ioportid_t port, iopadid_t pad, palcallback_t cb, void *arg) |
Associates a callback to a port/pad. More... | |
void | palSetLineCallbackI (ioline_t line, palcallback_t cb, void *arg) |
Associates a callback to a line. More... | |
msg_t | palWaitPadTimeoutS (ioportid_t port, iopadid_t pad, sysinterval_t timeout) |
Waits for an edge on the specified port/pad. More... | |
msg_t | palWaitPadTimeout (ioportid_t port, iopadid_t pad, sysinterval_t timeout) |
Waits for an edge on the specified port/pad. More... | |
msg_t | palWaitLineTimeoutS (ioline_t line, sysinterval_t timeout) |
Waits for an edge on the specified line. More... | |
msg_t | palWaitLineTimeout (ioline_t line, sysinterval_t timeout) |
Waits for an edge on the specified line. More... | |
void | _pal_lld_init (const PALConfig *config) |
STM32 I/O ports configuration. More... | |
void | _pal_lld_setgroupmode (ioportid_t port, ioportmask_t mask, iomode_t mode) |
Pads mode setup. More... | |
#define PAL_MODE_RESET 0U |
#define PAL_MODE_UNCONNECTED 1U |
#define PAL_MODE_INPUT_PULLUP 3U |
#define PAL_MODE_INPUT_PULLDOWN 4U |
#define PAL_MODE_OUTPUT_OPENDRAIN 7U |
#define PAL_EVENT_MODE_RISING_EDGE 1U |
#define PAL_EVENT_MODE_FALLING_EDGE 2U |
#define PAL_USE_CALLBACKS TRUE |
#define PAL_USE_WAIT TRUE |
#define PAL_PORT_BIT | ( | n | ) | ((ioportmask_t)(1U << (n))) |
#define PAL_GROUP_MASK | ( | width | ) | ((ioportmask_t)(1U << (width)) - 1U) |
#define _IOBUS_DATA | ( | name, | |
port, | |||
width, | |||
offset | |||
) | {port, PAL_GROUP_MASK(width), offset} |
Data part of a static I/O bus initializer.
This macro should be used when statically initializing an I/O bus that is part of a bigger structure.
[in] | name | name of the IOBus variable |
[in] | port | I/O port descriptor |
[in] | width | bus width in bits |
[in] | offset | bus bit offset within the port |
#define IOBUS_DECL | ( | name, | |
port, | |||
width, | |||
offset | |||
) | IOBus name = _IOBUS_DATA(name, port, width, offset) |
#define _pal_init_event | ( | e | ) |
Initializes a PAL event object.
[in] | e | event index |
#define _pal_init_event | ( | e | ) |
#define _pal_init_event | ( | e | ) |
Initializes a PAL event object.
[in] | e | event index |
#define _pal_clear_event | ( | e | ) |
Clears a PAL event object.
[in] | e | event index |
#define _pal_clear_event | ( | e | ) |
#define _pal_clear_event | ( | e | ) |
Clears a PAL event object.
[in] | e | event index |
#define _pal_isr_code | ( | e | ) |
Common ISR code.
[in] | e | event index |
#define _pal_isr_code | ( | e | ) |
Common ISR code.
[in] | e | event index |
#define _pal_isr_code | ( | e | ) |
Common ISR code.
[in] | e | event index |
#define palInit | ( | ) | pal_lld_init() |
PAL subsystem initialization.
halInit()
, there is no need to explicitly initialize the driver.Definition at line 372 of file hal_pal.h.
Referenced by halInit().
#define palReadPort | ( | port | ) | ((void)(port), 0U) |
#define palReadLatch | ( | port | ) | ((void)(port), 0U) |
Reads the output latch.
The purpose of this function is to read back the latched output value.
[in] | port | port identifier |
#define palWritePort | ( | port, | |
bits | |||
) | ((void)(port), (void)(bits)) |
#define palSetPort | ( | port, | |
bits | |||
) | palWritePort(port, palReadLatch(port) | (bits)) |
Sets a bits mask on a I/O port.
osalSysLock()
and osalSysUnlock()
. [in] | port | port identifier |
[in] | bits | bits to be ORed on the specified port |
#define palClearPort | ( | port, | |
bits | |||
) | palWritePort(port, palReadLatch(port) & ~(bits)) |
Clears a bits mask on a I/O port.
osalSysLock()
and osalSysUnlock()
. [in] | port | port identifier |
[in] | bits | bits to be cleared on the specified port |
#define palTogglePort | ( | port, | |
bits | |||
) | palWritePort(port, palReadLatch(port) ^ (bits)) |
Toggles a bits mask on a I/O port.
osalSysLock()
and osalSysUnlock()
. [in] | port | port identifier |
[in] | bits | bits to be XORed on the specified port |
#define palReadGroup | ( | port, | |
mask, | |||
offset | |||
) | ((palReadPort(port) >> (offset)) & (mask)) |
Reads a group of bits.
[in] | port | port identifier |
[in] | mask | group mask, a logic AND is performed on the input data |
[in] | offset | group bit offset within the port |
Definition at line 497 of file hal_pal.h.
Referenced by palReadBus().
#define palWriteGroup | ( | port, | |
mask, | |||
offset, | |||
bits | |||
) |
Writes a group of bits.
osalSysLock()
and osalSysUnlock()
. [in] | port | port identifier |
[in] | mask | group mask, a logic AND is performed on the output data |
[in] | offset | group bit offset within the port |
[in] | bits | bits to be written. Values exceeding the group width are masked. |
Definition at line 521 of file hal_pal.h.
Referenced by palWriteBus().
#define palSetGroupMode | ( | port, | |
mask, | |||
offset, | |||
mode | |||
) |
Pads group mode setup.
This function programs a pads group belonging to the same port with the specified mode.
osalSysLock()
and osalSysUnlock()
. [in] | port | port identifier |
[in] | mask | group mask |
[in] | offset | group bit offset within the port |
[in] | mode | group mode |
Definition at line 548 of file hal_pal.h.
Referenced by palSetBusMode().
#define palReadPad | ( | port, | |
pad | |||
) | ((palReadPort(port) >> (pad)) & 1U) |
Reads an input pad logic state.
[in] | port | port identifier |
[in] | pad | pad number within the port |
PAL_LOW | low logic state. |
PAL_HIGH | high logic state. |
#define palWritePad | ( | port, | |
pad, | |||
bit | |||
) |
Writes a logic state on an output pad.
osalSysLock()
and osalSysUnlock()
. [in] | port | port identifier |
[in] | pad | pad number within the port |
[in] | bit | logic value, the value must be PAL_LOW or PAL_HIGH |
#define palSetPad | ( | port, | |
pad | |||
) | palSetPort(port, PAL_PORT_BIT(pad)) |
Sets a pad logic state to PAL_HIGH
.
osalSysLock()
and osalSysUnlock()
. [in] | port | port identifier |
[in] | pad | pad number within the port |
#define palClearPad | ( | port, | |
pad | |||
) | palClearPort(port, PAL_PORT_BIT(pad)) |
Clears a pad logic state to PAL_LOW
.
osalSysLock()
and osalSysUnlock()
. [in] | port | port identifier |
[in] | pad | pad number within the port |
#define palTogglePad | ( | port, | |
pad | |||
) | palTogglePort(port, PAL_PORT_BIT(pad)) |
Toggles a pad logic state.
osalSysLock()
and osalSysUnlock()
. [in] | port | port identifier |
[in] | pad | pad number within the port |
#define palSetPadMode | ( | port, | |
pad, | |||
mode | |||
) | palSetGroupMode(port, PAL_PORT_BIT(pad), 0U, mode) |
Pad mode setup.
This function programs a pad with the specified mode.
osalSysLock()
and osalSysUnlock()
. [in] | port | port identifier |
[in] | pad | pad number within the port |
[in] | mode | pad mode |
#define palReadLine | ( | line | ) | palReadPad(PAL_PORT(line), PAL_PAD(line)) |
Reads an input line logic state.
[in] | line | line identifier |
PAL_LOW | low logic state. |
PAL_HIGH | high logic state. |
#define palWriteLine | ( | line, | |
bit | |||
) | palWritePad(PAL_PORT(line), PAL_PAD(line), bit) |
Writes a logic state on an output line.
osalSysLock()
and osalSysUnlock()
. [in] | line | line identifier |
[in] | bit | logic value, the value must be PAL_LOW or PAL_HIGH |
Sets a line logic state to PAL_HIGH
.
osalSysLock()
and osalSysUnlock()
. [in] | line | line identifier |
#define palClearLine | ( | line | ) | palClearPad(PAL_PORT(line), PAL_PAD(line)) |
Clears a line logic state to PAL_LOW
.
osalSysLock()
and osalSysUnlock()
. [in] | line | line identifier |
#define palToggleLine | ( | line | ) | palTogglePad(PAL_PORT(line), PAL_PAD(line)) |
Toggles a line logic state.
osalSysLock()
and osalSysUnlock()
. [in] | line | line identifier |
#define palSetLineMode | ( | line, | |
mode | |||
) | palSetPadMode(PAL_PORT(line), PAL_PAD(line), mode) |
Line mode setup.
osalSysLock()
and osalSysUnlock()
. [in] | line | line identifier |
[in] | mode | pad mode |
#define palEnablePadEventI | ( | port, | |
pad, | |||
mode | |||
) |
Pad event enable.
[in] | port | port identifier |
[in] | pad | pad number within the port |
[in] | mode | pad event mode |
#define palDisablePadEventI | ( | port, | |
pad | |||
) |
Pad event disable.
This function also disables previously programmed event callbacks.
[in] | port | port identifier |
[in] | pad | pad number within the port |
#define palEnablePadEvent | ( | port, | |
pad, | |||
mode | |||
) |
Pad event enable.
[in] | port | port identifier |
[in] | pad | pad number within the port |
[in] | mode | pad event mode |
#define palDisablePadEvent | ( | port, | |
pad | |||
) |
Pad event disable.
This function also disables previously programmed event callbacks.
[in] | port | port identifier |
[in] | pad | pad number within the port |
#define palEnableLineEventI | ( | line, | |
mode | |||
) | palEnablePadEventI(PAL_PORT(line), PAL_PAD(line), mode) |
Line event enable.
[in] | line | line identifier |
[in] | mode | line event mode |
#define palDisableLineEventI | ( | line | ) | palDisablePadEventI(PAL_PORT(line), PAL_PAD(line)) |
Line event disable.
This function also disables previously programmed event callbacks.
[in] | line | line identifier |
#define palEnableLineEvent | ( | line, | |
mode | |||
) |
Line event enable.
[in] | line | line identifier |
[in] | mode | line event mode |
#define palDisableLineEvent | ( | line | ) |
Line event disable.
This function also disables previously programmed event callbacks.
[in] | line | line identifier |
#define palSetPadCallback | ( | port, | |
pad, | |||
cb, | |||
arg | |||
) |
Associates a callback to a pad.
[in] | port | port identifier |
[in] | pad | pad number within the port |
[in] | cb | event callback function |
[in] | arg | callback argument |
#define palSetLineCallback | ( | line, | |
cb, | |||
arg | |||
) |
Associates a callback to a line.
[in] | line | line identifier |
[in] | cb | event callback function |
[in] | arg | callback argument |
#define PAL_IOPORTS_WIDTH 16U |
Width, in bits, of an I/O port.
Definition at line 45 of file hal_pal_lld.h.
Referenced by palReadBus(), palSetBusMode(), and palWriteBus().
#define PAL_WHOLE_PORT ((ioportmask_t)0xFFFFU) |
Whole port mask.
This macro specifies all the valid bits into a port.
Definition at line 51 of file hal_pal_lld.h.
#define PAL_LINE | ( | port, | |
pad | |||
) | ((ioline_t)((uint32_t)(port)) | ((uint32_t)(pad))) |
Forms a line identifier.
A port/pad pair are encoded into an ioline_t
type. The encoding of this type is platform-dependent.
Definition at line 63 of file hal_pal_lld.h.
#define PAL_PORT | ( | line | ) | ((stm32_gpio_t *)(((uint32_t)(line)) & 0xFFFFFFF0U)) |
Decodes a port identifier from a line identifier.
Definition at line 69 of file hal_pal_lld.h.
#define PAL_PAD | ( | line | ) | ((uint32_t)((uint32_t)(line) & 0x0000000FU)) |
Decodes a pad identifier from a line identifier.
Definition at line 75 of file hal_pal_lld.h.
#define PAL_NOLINE 0U |
Value identifying an invalid line.
Definition at line 81 of file hal_pal_lld.h.
#define IOPORT1 0 |
First I/O port identifier.
Low level drivers can define multiple ports, it is suggested to use this naming convention.
Definition at line 134 of file hal_pal_lld.h.
#define pal_lld_init | ( | config | ) | _pal_lld_init(config) |
Low level PAL subsystem initialization.
[in] | config | architecture-dependent ports configuration |
Definition at line 148 of file hal_pal_lld.h.
#define pal_lld_readport | ( | port | ) | 0U |
Reads the physical I/O port states.
[in] | port | port identifier |
Definition at line 158 of file hal_pal_lld.h.
#define pal_lld_readlatch | ( | port | ) | 0U |
Reads the output latch.
The purpose of this function is to read back the latched output value.
[in] | port | port identifier |
Definition at line 170 of file hal_pal_lld.h.
#define pal_lld_writeport | ( | port, | |
bits | |||
) |
Writes a bits mask on a I/O port.
[in] | port | port identifier |
[in] | bits | bits to be written on the specified port |
Definition at line 180 of file hal_pal_lld.h.
#define pal_lld_setport | ( | port, | |
bits | |||
) |
Sets a bits mask on a I/O port.
[in] | port | port identifier |
[in] | bits | bits to be ORed on the specified port |
Definition at line 198 of file hal_pal_lld.h.
#define pal_lld_clearport | ( | port, | |
bits | |||
) |
Clears a bits mask on a I/O port.
[in] | port | port identifier |
[in] | bits | bits to be cleared on the specified port |
Definition at line 216 of file hal_pal_lld.h.
#define pal_lld_toggleport | ( | port, | |
bits | |||
) |
Toggles a bits mask on a I/O port.
[in] | port | port identifier |
[in] | bits | bits to be XORed on the specified port |
Definition at line 234 of file hal_pal_lld.h.
#define pal_lld_readgroup | ( | port, | |
mask, | |||
offset | |||
) | 0U |
Reads a group of bits.
[in] | port | port identifier |
[in] | mask | group mask |
[in] | offset | group bit offset within the port |
Definition at line 254 of file hal_pal_lld.h.
#define pal_lld_writegroup | ( | port, | |
mask, | |||
offset, | |||
bits | |||
) |
Writes a group of bits.
[in] | port | port identifier |
[in] | mask | group mask |
[in] | offset | group bit offset within the port |
[in] | bits | bits to be written. Values exceeding the group width are masked. |
Definition at line 270 of file hal_pal_lld.h.
#define pal_lld_setgroupmode | ( | port, | |
mask, | |||
offset, | |||
mode | |||
) | _pal_lld_setgroupmode(port, mask << offset, mode) |
Pads group mode setup.
This function programs a pads group belonging to the same port with the specified mode.
[in] | port | port identifier |
[in] | mask | group mask |
[in] | offset | group bit offset within the port |
[in] | mode | group mode |
Definition at line 291 of file hal_pal_lld.h.
#define pal_lld_readpad | ( | port, | |
pad | |||
) | PAL_LOW |
Reads a logical state from an I/O pad.
[in] | port | port identifier |
[in] | pad | pad number within the port |
PAL_LOW | low logical state. |
PAL_HIGH | high logical state. |
Definition at line 308 of file hal_pal_lld.h.
#define pal_lld_writepad | ( | port, | |
pad, | |||
bit | |||
) |
Writes a logical state on an output pad.
[in] | port | port identifier |
[in] | pad | pad number within the port |
[in] | bit | logical value, the value must be PAL_LOW or PAL_HIGH |
Definition at line 325 of file hal_pal_lld.h.
#define pal_lld_setpad | ( | port, | |
pad | |||
) |
Sets a pad logical state to PAL_HIGH
.
[in] | port | port identifier |
[in] | pad | pad number within the port |
Definition at line 343 of file hal_pal_lld.h.
#define pal_lld_clearpad | ( | port, | |
pad | |||
) |
Clears a pad logical state to PAL_LOW
.
[in] | port | port identifier |
[in] | pad | pad number within the port |
Definition at line 361 of file hal_pal_lld.h.
#define pal_lld_togglepad | ( | port, | |
pad | |||
) |
Toggles a pad logical state.
[in] | port | port identifier |
[in] | pad | pad number within the port |
Definition at line 379 of file hal_pal_lld.h.
#define pal_lld_setpadmode | ( | port, | |
pad, | |||
mode | |||
) |
Pad mode setup.
This function programs a pad with the specified mode.
[in] | port | port identifier |
[in] | pad | pad number within the port |
[in] | mode | pad mode |
Definition at line 400 of file hal_pal_lld.h.
#define pal_lld_get_pad_event | ( | port, | |
pad | |||
) | &_pal_events[0]; (void)(port); (void)pad |
Returns a PAL event structure associated to a pad.
[in] | port | port identifier |
[in] | pad | pad number within the port |
Definition at line 415 of file hal_pal_lld.h.
Referenced by palSetPadCallbackI(), and palWaitPadTimeoutS().
#define pal_lld_get_line_event | ( | line | ) | &_pal_events[0]; (void)line |
Returns a PAL event structure associated to a line.
[in] | line | line identifier |
Definition at line 425 of file hal_pal_lld.h.
Referenced by palSetLineCallbackI(), and palWaitLineTimeoutS().
typedef void(* palcallback_t) (void *arg) |
typedef uint32_t ioportmask_t |
Digital I/O port sized unsigned type.
Definition at line 100 of file hal_pal_lld.h.
typedef uint32_t iomode_t |
Digital I/O modes.
Definition at line 105 of file hal_pal_lld.h.
typedef uint32_t ioline_t |
Type of an I/O line.
Definition at line 110 of file hal_pal_lld.h.
typedef uint32_t ioportid_t |
Port Identifier.
This type can be a scalar or some kind of pointer, do not make any assumption about it, use the provided macros when populating variables of this type.
Definition at line 118 of file hal_pal_lld.h.
typedef uint32_t iopadid_t |
Type of an pad identifier.
Definition at line 123 of file hal_pal_lld.h.
ioportmask_t palReadBus | ( | const IOBus * | bus | ) |
Read from an I/O bus.
osalSysLock()
and osalSysUnlock()
. palReadGroup()
macro. The use of this function is preferred when you value code size, readability and error checking over speed. [in] | bus | the I/O bus, pointer to a IOBus structure |
Definition at line 65 of file hal_pal.c.
References IOBus::mask, IOBus::offset, osalDbgCheck, PAL_IOPORTS_WIDTH, palReadGroup, and IOBus::portid.
void palWriteBus | ( | const IOBus * | bus, |
ioportmask_t | bits | ||
) |
Write to an I/O bus.
osalSysLock()
and osalSysUnlock()
. [in] | bus | the I/O bus, pointer to a IOBus structure |
[in] | bits | the bits to be written on the I/O bus. Values exceeding the bus width are masked so most significant bits are lost. |
Definition at line 90 of file hal_pal.c.
References IOBus::mask, IOBus::offset, osalDbgCheck, PAL_IOPORTS_WIDTH, palWriteGroup, and IOBus::portid.
Programs a bus with the specified mode.
osalSysLock()
and osalSysUnlock()
. [in] | bus | the I/O bus, pointer to a IOBus structure |
[in] | mode | the mode |
Definition at line 113 of file hal_pal.c.
References IOBus::mask, IOBus::offset, osalDbgCheck, PAL_IOPORTS_WIDTH, palSetGroupMode, and IOBus::portid.
void palSetPadCallbackI | ( | ioportid_t | port, |
iopadid_t | pad, | ||
palcallback_t | cb, | ||
void * | arg | ||
) |
Associates a callback to a port/pad.
[in] | port | port identifier |
[in] | pad | pad number within the port |
[in] | cb | event callback function |
[in] | arg | callback argument |
Definition at line 131 of file hal_pal.c.
References palevent_t::arg, palevent_t::cb, and pal_lld_get_pad_event.
void palSetLineCallbackI | ( | ioline_t | line, |
palcallback_t | cb, | ||
void * | arg | ||
) |
Associates a callback to a line.
[in] | line | line identifier |
[in] | cb | event callback function |
[in] | arg | callback argument |
Definition at line 148 of file hal_pal.c.
References palevent_t::arg, palevent_t::cb, and pal_lld_get_line_event.
msg_t palWaitPadTimeoutS | ( | ioportid_t | port, |
iopadid_t | pad, | ||
sysinterval_t | timeout | ||
) |
Waits for an edge on the specified port/pad.
[in] | port | port identifier |
[in] | pad | pad number within the port |
[in] | timeout | the number of ticks before the operation timeouts, the following special values are allowed:
|
MSG_OK | if an edge has been detected. |
MSG_TIMEOUT | if a timeout occurred before an edge could be detected. |
MSG_RESET | if the event has been disabled while the thread was waiting for an edge. |
Definition at line 175 of file hal_pal.c.
References osalThreadEnqueueTimeoutS(), pal_lld_get_pad_event, and palevent_t::threads.
Referenced by palWaitPadTimeout().
msg_t palWaitPadTimeout | ( | ioportid_t | port, |
iopadid_t | pad, | ||
sysinterval_t | timeout | ||
) |
Waits for an edge on the specified port/pad.
[in] | port | port identifier |
[in] | pad | pad number within the port |
[in] | timeout | the number of ticks before the operation timeouts, the following special values are allowed:
|
MSG_OK | if an edge has been detected. |
MSG_TIMEOUT | if a timeout occurred before an edge cound be detected. |
MSG_RESET | if the event has been disabled while the thread was waiting for an edge. |
Definition at line 201 of file hal_pal.c.
References osalSysLock(), osalSysUnlock(), and palWaitPadTimeoutS().
msg_t palWaitLineTimeoutS | ( | ioline_t | line, |
sysinterval_t | timeout | ||
) |
Waits for an edge on the specified line.
[in] | line | line identifier |
[in] | timeout | operation timeout |
MSG_OK | if an edge has been detected. |
MSG_TIMEOUT | if a timeout occurred before an edge could be detected. |
MSG_RESET | if the event has been disabled while the thread was waiting for an edge. |
Definition at line 225 of file hal_pal.c.
References osalThreadEnqueueTimeoutS(), pal_lld_get_line_event, and palevent_t::threads.
Referenced by palWaitLineTimeout().
msg_t palWaitLineTimeout | ( | ioline_t | line, |
sysinterval_t | timeout | ||
) |
Waits for an edge on the specified line.
[in] | line | line identifier |
[in] | timeout | operation timeout |
MSG_OK | if an edge has been detected. |
MSG_TIMEOUT | if a timeout occurred before an edge cound be detected. |
MSG_RESET | if the event has been disabled while the thread was waiting for an edge. |
Definition at line 245 of file hal_pal.c.
References osalSysLock(), osalSysUnlock(), and palWaitLineTimeoutS().
void _pal_lld_init | ( | const PALConfig * | config | ) |
STM32 I/O ports configuration.
Ports A-D(E, F, G, H) clocks enabled.
[in] | config | the STM32 ports configuration |
Definition at line 61 of file hal_pal_lld.c.
void _pal_lld_setgroupmode | ( | ioportid_t | port, |
ioportmask_t | mask, | ||
iomode_t | mode | ||
) |
Pads mode setup.
This function programs a pads group belonging to the same port with the specified mode.
[in] | port | the port identifier |
[in] | mask | the group mask |
[in] | mode | the mode |
Definition at line 78 of file hal_pal_lld.c.