ChibiOS/HAL  6.1.0
PAL Driver

I/O Ports Abstraction Layer. More...

Collaboration diagram for PAL Driver:

Detailed Description

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.

Precondition
In order to use the PAL driver the HAL_USE_PAL option must be enabled in halconf.h.

Implementation Rules

In implementing a PAL Low Level Driver there are some rules/behaviors that should be respected.

Writing on input pads

The behavior is not specified but there are implementations better than others, this is the list of possible implementations, preferred options are on top:

  1. The written value is not actually output but latched, should the pads be reprogrammed as outputs the value would be in effect.
  2. The write operation is ignored.
  3. The write operation has side effects, as example disabling/enabling pull up/down resistors or changing the pad direction. This scenario is discouraged, please try to avoid this scenario.

Reading from output pads

The behavior is not specified but there are implementations better than others, this is the list of possible implementations, preferred options are on top:

  1. The actual pads states are read (not the output latch).
  2. The output latch value is read (regardless of the actual pads states).
  3. Unspecified, please try to avoid this scenario.

Writing unused or unimplemented port bits

The behavior is not specified.

Reading from unused or unimplemented port bits

The behavior is not specified.

Reading or writing on pins associated to other functionalities

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...
 

Macro Definition Documentation

#define PAL_MODE_RESET   0U

After reset state.

The state itself is not specified and is architecture dependent, it is guaranteed to be equal to the after-reset state. It is usually an input state.

Definition at line 44 of file hal_pal.h.

#define PAL_MODE_UNCONNECTED   1U

Safe state for unconnected pads.

The state itself is not specified and is architecture dependent, it may be mapped on PAL_MODE_INPUT_PULLUP, PAL_MODE_INPUT_PULLDOWN or PAL_MODE_OUTPUT_PUSHPULL for example.

Definition at line 53 of file hal_pal.h.

#define PAL_MODE_INPUT   2U

Regular input high-Z pad.

Definition at line 58 of file hal_pal.h.

#define PAL_MODE_INPUT_PULLUP   3U

Input pad with weak pull up resistor.

Definition at line 63 of file hal_pal.h.

#define PAL_MODE_INPUT_PULLDOWN   4U

Input pad with weak pull down resistor.

Definition at line 68 of file hal_pal.h.

#define PAL_MODE_INPUT_ANALOG   5U

Analog input mode.

Definition at line 73 of file hal_pal.h.

#define PAL_MODE_OUTPUT_PUSHPULL   6U

Push-pull output pad.

Definition at line 78 of file hal_pal.h.

#define PAL_MODE_OUTPUT_OPENDRAIN   7U

Open-drain output pad.

Definition at line 83 of file hal_pal.h.

#define PAL_LOW   0U

Logical low state.

Definition at line 93 of file hal_pal.h.

#define PAL_HIGH   1U

Logical high state.

Definition at line 98 of file hal_pal.h.

#define PAL_EVENT_MODE_EDGES_MASK   3U

Mask of edges field.

Definition at line 105 of file hal_pal.h.

#define PAL_EVENT_MODE_DISABLED   0U

Channel disabled.

Definition at line 106 of file hal_pal.h.

#define PAL_EVENT_MODE_RISING_EDGE   1U

Rising edge callback.

Definition at line 107 of file hal_pal.h.

#define PAL_EVENT_MODE_FALLING_EDGE   2U

Falling edge callback.

Definition at line 108 of file hal_pal.h.

#define PAL_EVENT_MODE_BOTH_EDGES   3U

Both edges callback.

Definition at line 109 of file hal_pal.h.

#define PAL_USE_CALLBACKS   TRUE

Enables synchronous APIs.

Note
Disabling this option saves both code and data space.

Definition at line 125 of file hal_pal.h.

#define PAL_USE_WAIT   TRUE

Enables synchronous APIs.

Note
Disabling this option saves both code and data space.

Definition at line 133 of file hal_pal.h.

#define PAL_PORT_BIT (   n)    ((ioportmask_t)(1U << (n)))

Port bit helper macro.

This macro calculates the mask of a bit within a port.

Parameters
[in]nbit position within the port
Returns
The bit mask.

Definition at line 212 of file hal_pal.h.

#define PAL_GROUP_MASK (   width)    ((ioportmask_t)(1U << (width)) - 1U)

Bits group mask helper.

This macro calculates the mask of a bits group.

Parameters
[in]widthgroup width
Returns
The group mask.

Definition at line 223 of file hal_pal.h.

#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.

Parameters
[in]namename of the IOBus variable
[in]portI/O port descriptor
[in]widthbus width in bits
[in]offsetbus bit offset within the port

Definition at line 236 of file hal_pal.h.

#define IOBUS_DECL (   name,
  port,
  width,
  offset 
)    IOBus name = _IOBUS_DATA(name, port, width, offset)

Static I/O bus initializer.

Parameters
[in]namename of the IOBus variable
[in]portI/O port descriptor
[in]widthbus width in bits
[in]offsetbus bit offset within the port

Definition at line 247 of file hal_pal.h.

#define _pal_init_event (   e)
Value:
do { \
osalThreadQueueObjectInit(&_pal_events[e].threads); \
_pal_events[e].cb = NULL; \
_pal_events[e].arg = NULL; \
} while (false)
static void osalThreadQueueObjectInit(threads_queue_t *tqp)
Initializes a threads queue object.
Definition: osal.h:653

Initializes a PAL event object.

Parameters
[in]eevent index
Function Class:Not an API, this function is for internal use only.

Definition at line 282 of file hal_pal.h.

#define _pal_init_event (   e)
Value:
do { \
_pal_events[e].cb = NULL; \
_pal_events[e].arg = NULL; \
} while (false)

Initializes a PAL event object.

Parameters
[in]eevent index
Function Class:Not an API, this function is for internal use only.

Definition at line 282 of file hal_pal.h.

#define _pal_init_event (   e)
Value:
do { \
osalThreadQueueObjectInit(&_pal_events[e].threads); \
} while (false)
static void osalThreadQueueObjectInit(threads_queue_t *tqp)
Initializes a threads queue object.
Definition: osal.h:653

Initializes a PAL event object.

Parameters
[in]eevent index
Function Class:Not an API, this function is for internal use only.

Definition at line 282 of file hal_pal.h.

#define _pal_clear_event (   e)
Value:
do { \
osalThreadDequeueAllI(&_pal_events[pad].threads, MSG_RESET); \
_pal_events[e].cb = NULL; \
_pal_events[e].arg = NULL; \
} while (false)
void osalThreadDequeueAllI(threads_queue_t *tqp, msg_t msg)
Dequeues and wakes up all threads from the queue.
Definition: osal.c:309

Clears a PAL event object.

Parameters
[in]eevent index
Function Class:Not an API, this function is for internal use only.

Definition at line 313 of file hal_pal.h.

#define _pal_clear_event (   e)
Value:
do { \
_pal_events[e].cb = NULL; \
_pal_events[e].arg = NULL; \
} while (false)

Clears a PAL event object.

Parameters
[in]eevent index
Function Class:Not an API, this function is for internal use only.

Definition at line 313 of file hal_pal.h.

#define _pal_clear_event (   e)
Value:
do { \
osalThreadDequeueAllI(&_pal_events[pad].threads, MSG_RESET); \
} while (false)
void osalThreadDequeueAllI(threads_queue_t *tqp, msg_t msg)
Dequeues and wakes up all threads from the queue.
Definition: osal.c:309

Clears a PAL event object.

Parameters
[in]eevent index
Function Class:Not an API, this function is for internal use only.

Definition at line 313 of file hal_pal.h.

#define _pal_isr_code (   e)
Value:
do { \
if (_pal_events[e].cb != NULL) { \
_pal_events[e].cb(_pal_events[e].arg); \
} \
osalThreadDequeueAllI(&_pal_events[e].threads, MSG_OK); \
} while (false)
void osalThreadDequeueAllI(threads_queue_t *tqp, msg_t msg)
Dequeues and wakes up all threads from the queue.
Definition: osal.c:309
static void osalSysLockFromISR(void)
Enters a critical zone from ISR context.
Definition: osal.h:550
static void osalSysUnlockFromISR(void)
Leaves a critical zone from ISR context.
Definition: osal.h:560

Common ISR code.

Note
This macro is meant to be used in the low level drivers implementation only.
Parameters
[in]eevent index
Function Class:Not an API, this function is for internal use only.

Definition at line 350 of file hal_pal.h.

#define _pal_isr_code (   e)
Value:
do { \
if (_pal_events[e].cb != NULL) { \
_pal_events[e].cb(_pal_events[e].arg); \
} \
} while (false)

Common ISR code.

Note
This macro is meant to be used in the low level drivers implementation only.
Parameters
[in]eevent index
Function Class:Not an API, this function is for internal use only.

Definition at line 350 of file hal_pal.h.

#define _pal_isr_code (   e)
Value:
do { \
osalThreadDequeueAllI(&_pal_events[e].threads, MSG_OK); \
} while (false)
void osalThreadDequeueAllI(threads_queue_t *tqp, msg_t msg)
Dequeues and wakes up all threads from the queue.
Definition: osal.c:309
static void osalSysLockFromISR(void)
Enters a critical zone from ISR context.
Definition: osal.h:550
static void osalSysUnlockFromISR(void)
Leaves a critical zone from ISR context.
Definition: osal.h:560

Common ISR code.

Note
This macro is meant to be used in the low level drivers implementation only.
Parameters
[in]eevent index
Function Class:Not an API, this function is for internal use only.

Definition at line 350 of file hal_pal.h.

#define palInit ( )    pal_lld_init()

PAL subsystem initialization.

Note
This function is implicitly invoked by halInit(), there is no need to explicitly initialize the driver.
Function Class:Initializer, this function just initializes an object and can be invoked before the kernel is initialized.

Definition at line 372 of file hal_pal.h.

Referenced by halInit().

#define palReadPort (   port)    ((void)(port), 0U)

Reads the physical I/O port states.

Note
The function can be called from any context.
Parameters
[in]portport identifier
Returns
The port logic states.
Function Class:Special function, this function has special requirements see the notes.

Definition at line 387 of file hal_pal.h.

#define palReadLatch (   port)    ((void)(port), 0U)

Reads the output latch.

The purpose of this function is to read back the latched output value.

Note
The function can be called from any context.
Parameters
[in]portport identifier
Returns
The latched logic states.
Function Class:Special function, this function has special requirements see the notes.

Definition at line 404 of file hal_pal.h.

#define palWritePort (   port,
  bits 
)    ((void)(port), (void)(bits))

Writes a bits mask on a I/O port.

Note
The function can be called from any context.
Parameters
[in]portport identifier
[in]bitsbits to be written on the specified port
Function Class:Special function, this function has special requirements see the notes.

Definition at line 419 of file hal_pal.h.

#define palSetPort (   port,
  bits 
)    palWritePort(port, palReadLatch(port) | (bits))

Sets a bits mask on a I/O port.

Note
The operation is not guaranteed to be atomic on all the architectures, for atomicity and/or portability reasons you may need to enclose port I/O operations between osalSysLock() and osalSysUnlock().
The function can be called from any context.
Parameters
[in]portport identifier
[in]bitsbits to be ORed on the specified port
Function Class:Special function, this function has special requirements see the notes.

Definition at line 438 of file hal_pal.h.

#define palClearPort (   port,
  bits 
)    palWritePort(port, palReadLatch(port) & ~(bits))

Clears a bits mask on a I/O port.

Note
The operation is not guaranteed to be atomic on all the architectures, for atomicity and/or portability reasons you may need to enclose port I/O operations between osalSysLock() and osalSysUnlock().
The function can be called from any context.
Parameters
[in]portport identifier
[in]bitsbits to be cleared on the specified port
Function Class:Special function, this function has special requirements see the notes.

Definition at line 458 of file hal_pal.h.

#define palTogglePort (   port,
  bits 
)    palWritePort(port, palReadLatch(port) ^ (bits))

Toggles a bits mask on a I/O port.

Note
The operation is not guaranteed to be atomic on all the architectures, for atomicity and/or portability reasons you may need to enclose port I/O operations between osalSysLock() and osalSysUnlock().
The function can be called from any context.
Parameters
[in]portport identifier
[in]bitsbits to be XORed on the specified port
Function Class:Special function, this function has special requirements see the notes.

Definition at line 478 of file hal_pal.h.

#define palReadGroup (   port,
  mask,
  offset 
)    ((palReadPort(port) >> (offset)) & (mask))

Reads a group of bits.

Note
The function can be called from any context.
Parameters
[in]portport identifier
[in]maskgroup mask, a logic AND is performed on the input data
[in]offsetgroup bit offset within the port
Returns
The group logic states.
Function Class:Special function, this function has special requirements see the notes.

Definition at line 497 of file hal_pal.h.

Referenced by palReadBus().

#define palWriteGroup (   port,
  mask,
  offset,
  bits 
)
Value:
palWritePort(port, (palReadLatch(port) & ~((mask) << (offset))) | \
(((bits) & (mask)) << (offset)))
#define palWritePort(port, bits)
Writes a bits mask on a I/O port.
Definition: hal_pal.h:419
#define palReadLatch(port)
Reads the output latch.
Definition: hal_pal.h:404

Writes a group of bits.

Note
The operation is not guaranteed to be atomic on all the architectures, for atomicity and/or portability reasons you may need to enclose port I/O operations between osalSysLock() and osalSysUnlock().
The function can be called from any context.
Parameters
[in]portport identifier
[in]maskgroup mask, a logic AND is performed on the output data
[in]offsetgroup bit offset within the port
[in]bitsbits to be written. Values exceeding the group width are masked.
Function Class:Special function, this function has special requirements see the notes.

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.

Note
The operation is not guaranteed to be atomic on all the architectures, for atomicity and/or portability reasons you may need to enclose port I/O operations between osalSysLock() and osalSysUnlock().
Programming an unknown or unsupported mode is silently ignored.
The function can be called from any context.
Parameters
[in]portport identifier
[in]maskgroup mask
[in]offsetgroup bit offset within the port
[in]modegroup mode
Function Class:Special function, this function has special requirements see the notes.

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.

Note
The function can be called from any context.
Parameters
[in]portport identifier
[in]padpad number within the port
Returns
The logic state.
Return values
PAL_LOWlow logic state.
PAL_HIGHhigh logic state.
Function Class:Special function, this function has special requirements see the notes.

Definition at line 567 of file hal_pal.h.

#define palWritePad (   port,
  pad,
  bit 
)
Value:
palWritePort(port, (palReadLatch(port) & ~PAL_PORT_BIT(pad)) | \
(((bit) & 1U) << pad))
#define PAL_PORT_BIT(n)
Port bit helper macro.
Definition: hal_pal.h:212
#define palWritePort(port, bits)
Writes a bits mask on a I/O port.
Definition: hal_pal.h:419
#define palReadLatch(port)
Reads the output latch.
Definition: hal_pal.h:404

Writes a logic state on an output pad.

Note
The operation is not guaranteed to be atomic on all the architectures, for atomicity and/or portability reasons you may need to enclose port I/O operations between osalSysLock() and osalSysUnlock().
The function can be called from any context.
Parameters
[in]portport identifier
[in]padpad number within the port
[in]bitlogic value, the value must be PAL_LOW or PAL_HIGH
Function Class:Special function, this function has special requirements see the notes.

Definition at line 588 of file hal_pal.h.

#define palSetPad (   port,
  pad 
)    palSetPort(port, PAL_PORT_BIT(pad))

Sets a pad logic state to PAL_HIGH.

Note
The operation is not guaranteed to be atomic on all the architectures, for atomicity and/or portability reasons you may need to enclose port I/O operations between osalSysLock() and osalSysUnlock().
The function can be called from any context.
Parameters
[in]portport identifier
[in]padpad number within the port
Function Class:Special function, this function has special requirements see the notes.

Definition at line 609 of file hal_pal.h.

#define palClearPad (   port,
  pad 
)    palClearPort(port, PAL_PORT_BIT(pad))

Clears a pad logic state to PAL_LOW.

Note
The operation is not guaranteed to be atomic on all the architectures, for atomicity and/or portability reasons you may need to enclose port I/O operations between osalSysLock() and osalSysUnlock().
The function can be called from any context.
Parameters
[in]portport identifier
[in]padpad number within the port
Function Class:Special function, this function has special requirements see the notes.

Definition at line 628 of file hal_pal.h.

#define palTogglePad (   port,
  pad 
)    palTogglePort(port, PAL_PORT_BIT(pad))

Toggles a pad logic state.

Note
The operation is not guaranteed to be atomic on all the architectures, for atomicity and/or portability reasons you may need to enclose port I/O operations between osalSysLock() and osalSysUnlock().
The function can be called from any context.
Parameters
[in]portport identifier
[in]padpad number within the port
Function Class:Special function, this function has special requirements see the notes.

Definition at line 647 of file hal_pal.h.

#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.

Note
The operation is not guaranteed to be atomic on all the architectures, for atomicity and/or portability reasons you may need to enclose port I/O operations between osalSysLock() and osalSysUnlock().
Programming an unknown or unsupported mode is silently ignored.
The function can be called from any context.
Parameters
[in]portport identifier
[in]padpad number within the port
[in]modepad mode
Function Class:Special function, this function has special requirements see the notes.

Definition at line 669 of file hal_pal.h.

#define palReadLine (   line)    palReadPad(PAL_PORT(line), PAL_PAD(line))

Reads an input line logic state.

Note
The function can be called from any context.
Parameters
[in]lineline identifier
Returns
The logic state.
Return values
PAL_LOWlow logic state.
PAL_HIGHhigh logic state.
Function Class:Special function, this function has special requirements see the notes.

Definition at line 687 of file hal_pal.h.

#define palWriteLine (   line,
  bit 
)    palWritePad(PAL_PORT(line), PAL_PAD(line), bit)

Writes a logic state on an output line.

Note
The operation is not guaranteed to be atomic on all the architectures, for atomicity and/or portability reasons you may need to enclose port I/O operations between osalSysLock() and osalSysUnlock().
The function can be called from any context.
Parameters
[in]lineline identifier
[in]bitlogic value, the value must be PAL_LOW or PAL_HIGH
Function Class:Special function, this function has special requirements see the notes.

Definition at line 707 of file hal_pal.h.

#define palSetLine (   line)    palSetPad(PAL_PORT(line), PAL_PAD(line))

Sets a line logic state to PAL_HIGH.

Note
The operation is not guaranteed to be atomic on all the architectures, for atomicity and/or portability reasons you may need to enclose port I/O operations between osalSysLock() and osalSysUnlock().
The function can be called from any context.
Parameters
[in]lineline identifier
Function Class:Special function, this function has special requirements see the notes.

Definition at line 725 of file hal_pal.h.

#define palClearLine (   line)    palClearPad(PAL_PORT(line), PAL_PAD(line))

Clears a line logic state to PAL_LOW.

Note
The operation is not guaranteed to be atomic on all the architectures, for atomicity and/or portability reasons you may need to enclose port I/O operations between osalSysLock() and osalSysUnlock().
The function can be called from any context.
Parameters
[in]lineline identifier
Function Class:Special function, this function has special requirements see the notes.

Definition at line 743 of file hal_pal.h.

#define palToggleLine (   line)    palTogglePad(PAL_PORT(line), PAL_PAD(line))

Toggles a line logic state.

Note
The operation is not guaranteed to be atomic on all the architectures, for atomicity and/or portability reasons you may need to enclose port I/O operations between osalSysLock() and osalSysUnlock().
The function can be called from any context.
Parameters
[in]lineline identifier
Function Class:Special function, this function has special requirements see the notes.

Definition at line 761 of file hal_pal.h.

#define palSetLineMode (   line,
  mode 
)    palSetPadMode(PAL_PORT(line), PAL_PAD(line), mode)

Line mode setup.

Note
The operation is not guaranteed to be atomic on all the architectures, for atomicity and/or portability reasons you may need to enclose port I/O operations between osalSysLock() and osalSysUnlock().
The function can be called from any context.
Parameters
[in]lineline identifier
[in]modepad mode
Function Class:Special function, this function has special requirements see the notes.

Definition at line 780 of file hal_pal.h.

#define palEnablePadEventI (   port,
  pad,
  mode 
)

Pad event enable.

Note
Programming an unknown or unsupported mode is silently ignored.
Parameters
[in]portport identifier
[in]padpad number within the port
[in]modepad event mode
Function Class:This is an I-Class API, this function can be invoked from within a system lock zone by both threads and interrupt handlers.

Definition at line 799 of file hal_pal.h.

#define palDisablePadEventI (   port,
  pad 
)

Pad event disable.

This function also disables previously programmed event callbacks.

Parameters
[in]portport identifier
[in]padpad number within the port
Function Class:This is an I-Class API, this function can be invoked from within a system lock zone by both threads and interrupt handlers.

Definition at line 815 of file hal_pal.h.

#define palEnablePadEvent (   port,
  pad,
  mode 
)
Value:
do { \
palEnablePadEventI(port, pad, mode); \
} while (false)
static void osalSysUnlock(void)
Leaves a critical zone from thread context.
Definition: osal.h:540
#define palEnablePadEventI(port, pad, mode)
Pad event enable.
Definition: hal_pal.h:799
static void osalSysLock(void)
Enters a critical zone from thread context.
Definition: osal.h:530

Pad event enable.

Note
Programming an unknown or unsupported mode is silently ignored.
Parameters
[in]portport identifier
[in]padpad number within the port
[in]modepad event mode
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 831 of file hal_pal.h.

#define palDisablePadEvent (   port,
  pad 
)
Value:
do { \
} while (false)
#define palDisablePadEventI(port, pad)
Pad event disable.
Definition: hal_pal.h:815
static void osalSysUnlock(void)
Leaves a critical zone from thread context.
Definition: osal.h:540
static void osalSysLock(void)
Enters a critical zone from thread context.
Definition: osal.h:530

Pad event disable.

This function also disables previously programmed event callbacks.

Parameters
[in]portport identifier
[in]padpad number within the port
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 847 of file hal_pal.h.

#define palEnableLineEventI (   line,
  mode 
)    palEnablePadEventI(PAL_PORT(line), PAL_PAD(line), mode)

Line event enable.

Note
Programming an unknown or unsupported mode is silently ignored.
Parameters
[in]lineline identifier
[in]modeline event mode
Function Class:This is an I-Class API, this function can be invoked from within a system lock zone by both threads and interrupt handlers.

Definition at line 864 of file hal_pal.h.

#define palDisableLineEventI (   line)    palDisablePadEventI(PAL_PORT(line), PAL_PAD(line))

Line event disable.

This function also disables previously programmed event callbacks.

Parameters
[in]lineline identifier
Function Class:This is an I-Class API, this function can be invoked from within a system lock zone by both threads and interrupt handlers.

Definition at line 880 of file hal_pal.h.

#define palEnableLineEvent (   line,
  mode 
)
Value:
do { \
palEnableLineEventI(line, mode); \
} while (false)
static void osalSysUnlock(void)
Leaves a critical zone from thread context.
Definition: osal.h:540
#define palEnableLineEventI(line, mode)
Line event enable.
Definition: hal_pal.h:864
static void osalSysLock(void)
Enters a critical zone from thread context.
Definition: osal.h:530

Line event enable.

Note
Programming an unknown or unsupported mode is silently ignored.
Parameters
[in]lineline identifier
[in]modeline event mode
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 895 of file hal_pal.h.

#define palDisableLineEvent (   line)
Value:
do { \
} while (false)
#define palDisableLineEventI(line)
Line event disable.
Definition: hal_pal.h:880
static void osalSysUnlock(void)
Leaves a critical zone from thread context.
Definition: osal.h:540
static void osalSysLock(void)
Enters a critical zone from thread context.
Definition: osal.h:530

Line event disable.

This function also disables previously programmed event callbacks.

Parameters
[in]lineline identifier
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 910 of file hal_pal.h.

#define palSetPadCallback (   port,
  pad,
  cb,
  arg 
)
Value:
do { \
palSetPadCallbackI(port, pad, cb, arg); \
} while (false)
static void osalSysUnlock(void)
Leaves a critical zone from thread context.
Definition: osal.h:540
void palSetPadCallbackI(ioportid_t port, iopadid_t pad, palcallback_t cb, void *arg)
Associates a callback to a port/pad.
Definition: hal_pal.c:131
static void osalSysLock(void)
Enters a critical zone from thread context.
Definition: osal.h:530

Associates a callback to a pad.

Parameters
[in]portport identifier
[in]padpad number within the port
[in]cbevent callback function
[in]argcallback argument
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 930 of file hal_pal.h.

#define palSetLineCallback (   line,
  cb,
  arg 
)
Value:
do { \
palSetLineCallbackI(line, cb, arg); \
} while (false)
static void osalSysUnlock(void)
Leaves a critical zone from thread context.
Definition: osal.h:540
void palSetLineCallbackI(ioline_t line, palcallback_t cb, void *arg)
Associates a callback to a line.
Definition: hal_pal.c:148
static void osalSysLock(void)
Enters a critical zone from thread context.
Definition: osal.h:530

Associates a callback to a line.

Parameters
[in]lineline identifier
[in]cbevent callback function
[in]argcallback argument
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 946 of file hal_pal.h.

#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.

Parameters
[in]configarchitecture-dependent ports configuration
Function Class:Not an API, this function is for internal use only.

Definition at line 148 of file hal_pal_lld.h.

#define pal_lld_readport (   port)    0U

Reads the physical I/O port states.

Parameters
[in]portport identifier
Returns
The port bits.
Function Class:Not an API, this function is for internal use only.

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.

Parameters
[in]portport identifier
Returns
The latched logical states.
Function Class:Not an API, this function is for internal use only.

Definition at line 170 of file hal_pal_lld.h.

#define pal_lld_writeport (   port,
  bits 
)
Value:
do { \
(void)port; \
(void)bits; \
} while (false)

Writes a bits mask on a I/O port.

Parameters
[in]portport identifier
[in]bitsbits to be written on the specified port
Function Class:Not an API, this function is for internal use only.

Definition at line 180 of file hal_pal_lld.h.

#define pal_lld_setport (   port,
  bits 
)
Value:
do { \
(void)port; \
(void)bits; \
} while (false)

Sets a bits mask on a I/O port.

Note
The PAL Driver provides a default software implementation of this functionality, implement this function if can optimize it by using special hardware functionalities or special coding.
Parameters
[in]portport identifier
[in]bitsbits to be ORed on the specified port
Function Class:Not an API, this function is for internal use only.

Definition at line 198 of file hal_pal_lld.h.

#define pal_lld_clearport (   port,
  bits 
)
Value:
do { \
(void)port; \
(void)bits; \
} while (false)

Clears a bits mask on a I/O port.

Note
The PAL Driver provides a default software implementation of this functionality, implement this function if can optimize it by using special hardware functionalities or special coding.
Parameters
[in]portport identifier
[in]bitsbits to be cleared on the specified port
Function Class:Not an API, this function is for internal use only.

Definition at line 216 of file hal_pal_lld.h.

#define pal_lld_toggleport (   port,
  bits 
)
Value:
do { \
(void)port; \
(void)bits; \
} while (false)

Toggles a bits mask on a I/O port.

Note
The PAL Driver provides a default software implementation of this functionality, implement this function if can optimize it by using special hardware functionalities or special coding.
Parameters
[in]portport identifier
[in]bitsbits to be XORed on the specified port
Function Class:Not an API, this function is for internal use only.

Definition at line 234 of file hal_pal_lld.h.

#define pal_lld_readgroup (   port,
  mask,
  offset 
)    0U

Reads a group of bits.

Note
The PAL Driver provides a default software implementation of this functionality, implement this function if can optimize it by using special hardware functionalities or special coding.
Parameters
[in]portport identifier
[in]maskgroup mask
[in]offsetgroup bit offset within the port
Returns
The group logical states.
Function Class:Not an API, this function is for internal use only.

Definition at line 254 of file hal_pal_lld.h.

#define pal_lld_writegroup (   port,
  mask,
  offset,
  bits 
)
Value:
do { \
(void)port; \
(void)mask; \
(void)offset; \
(void)bits; \
} while (false)

Writes a group of bits.

Note
The PAL Driver provides a default software implementation of this functionality, implement this function if can optimize it by using special hardware functionalities or special coding.
Parameters
[in]portport identifier
[in]maskgroup mask
[in]offsetgroup bit offset within the port
[in]bitsbits to be written. Values exceeding the group width are masked.
Function Class:Not an API, this function is for internal use only.

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.

Note
Programming an unknown or unsupported mode is silently ignored.
Parameters
[in]portport identifier
[in]maskgroup mask
[in]offsetgroup bit offset within the port
[in]modegroup mode
Function Class:Not an API, this function is for internal use only.

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.

Note
The PAL Driver provides a default software implementation of this functionality, implement this function if can optimize it by using special hardware functionalities or special coding.
Parameters
[in]portport identifier
[in]padpad number within the port
Returns
The logical state.
Return values
PAL_LOWlow logical state.
PAL_HIGHhigh logical state.
Function Class:Not an API, this function is for internal use only.

Definition at line 308 of file hal_pal_lld.h.

#define pal_lld_writepad (   port,
  pad,
  bit 
)
Value:
do { \
(void)port; \
(void)pad; \
(void)bit; \
} while (false)

Writes a logical state on an output pad.

Note
This function is not meant to be invoked directly by the application code.
The PAL Driver provides a default software implementation of this functionality, implement this function if can optimize it by using special hardware functionalities or special coding.
Parameters
[in]portport identifier
[in]padpad number within the port
[in]bitlogical value, the value must be PAL_LOW or PAL_HIGH
Function Class:Not an API, this function is for internal use only.

Definition at line 325 of file hal_pal_lld.h.

#define pal_lld_setpad (   port,
  pad 
)
Value:
do { \
(void)port; \
(void)pad; \
} while (false)

Sets a pad logical state to PAL_HIGH.

Note
The PAL Driver provides a default software implementation of this functionality, implement this function if can optimize it by using special hardware functionalities or special coding.
Parameters
[in]portport identifier
[in]padpad number within the port
Function Class:Not an API, this function is for internal use only.

Definition at line 343 of file hal_pal_lld.h.

#define pal_lld_clearpad (   port,
  pad 
)
Value:
do { \
(void)port; \
(void)pad; \
} while (false)

Clears a pad logical state to PAL_LOW.

Note
The PAL Driver provides a default software implementation of this functionality, implement this function if can optimize it by using special hardware functionalities or special coding.
Parameters
[in]portport identifier
[in]padpad number within the port
Function Class:Not an API, this function is for internal use only.

Definition at line 361 of file hal_pal_lld.h.

#define pal_lld_togglepad (   port,
  pad 
)
Value:
do { \
(void)port; \
(void)pad; \
} while (false)

Toggles a pad logical state.

Note
The PAL Driver provides a default software implementation of this functionality, implement this function if can optimize it by using special hardware functionalities or special coding.
Parameters
[in]portport identifier
[in]padpad number within the port
Function Class:Not an API, this function is for internal use only.

Definition at line 379 of file hal_pal_lld.h.

#define pal_lld_setpadmode (   port,
  pad,
  mode 
)
Value:
do { \
(void)port; \
(void)pad; \
(void)mode; \
} while (false)

Pad mode setup.

This function programs a pad with the specified mode.

Note
The PAL Driver provides a default software implementation of this functionality, implement this function if can optimize it by using special hardware functionalities or special coding.
Programming an unknown or unsupported mode is silently ignored.
Parameters
[in]portport identifier
[in]padpad number within the port
[in]modepad mode
Function Class:Not an API, this function is for internal use only.

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.

Parameters
[in]portport identifier
[in]padpad number within the port
Function Class:Not an API, this function is for internal use only.

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.

Parameters
[in]lineline identifier
Function Class:Not an API, this function is for internal use only.

Definition at line 425 of file hal_pal_lld.h.

Referenced by palSetLineCallbackI(), and palWaitLineTimeoutS().

Typedef Documentation

typedef void(* palcallback_t) (void *arg)

Type of a PAL event callback.

Definition at line 148 of file hal_pal.h.

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.

Function Documentation

ioportmask_t palReadBus ( const IOBus bus)

Read from an I/O bus.

Note
The operation is not guaranteed to be atomic on all the architectures, for atomicity and/or portability reasons you may need to enclose port I/O operations between osalSysLock() and osalSysUnlock().
The function internally uses the palReadGroup() macro. The use of this function is preferred when you value code size, readability and error checking over speed.
The function can be called from any context.
Parameters
[in]busthe I/O bus, pointer to a IOBus structure
Returns
The bus logical states.
Function Class:Special function, this function has special requirements see the notes.

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.

Note
The operation is not guaranteed to be atomic on all the architectures, for atomicity and/or portability reasons you may need to enclose port I/O operations between osalSysLock() and osalSysUnlock().
The default implementation is non atomic and not necessarily optimal. Low level drivers may optimize the function by using specific hardware or coding.
The function can be called from any context.
Parameters
[in]busthe I/O bus, pointer to a IOBus structure
[in]bitsthe bits to be written on the I/O bus. Values exceeding the bus width are masked so most significant bits are lost.
Function Class:Special function, this function has special requirements see the notes.

Definition at line 90 of file hal_pal.c.

References IOBus::mask, IOBus::offset, osalDbgCheck, PAL_IOPORTS_WIDTH, palWriteGroup, and IOBus::portid.

void palSetBusMode ( const IOBus bus,
iomode_t  mode 
)

Programs a bus with the specified mode.

Note
The operation is not guaranteed to be atomic on all the architectures, for atomicity and/or portability reasons you may need to enclose port I/O operations between osalSysLock() and osalSysUnlock().
The default implementation is non atomic and not necessarily optimal. Low level drivers may optimize the function by using specific hardware or coding.
The function can be called from any context.
Parameters
[in]busthe I/O bus, pointer to a IOBus structure
[in]modethe mode
Function Class:Special function, this function has special requirements see the notes.

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.

Parameters
[in]portport identifier
[in]padpad number within the port
[in]cbevent callback function
[in]argcallback argument
Function Class:This is an I-Class API, this function can be invoked from within a system lock zone by both threads and interrupt handlers.

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.

Parameters
[in]lineline identifier
[in]cbevent callback function
[in]argcallback argument
Function Class:This is an I-Class API, this function can be invoked from within a system lock zone by both threads and interrupt handlers.

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.

Parameters
[in]portport identifier
[in]padpad number within the port
[in]timeoutthe number of ticks before the operation timeouts, the following special values are allowed:
  • TIME_IMMEDIATE immediate timeout.
  • TIME_INFINITE no timeout.
Returns
The operation state.
Return values
MSG_OKif an edge has been detected.
MSG_TIMEOUTif a timeout occurred before an edge could be detected.
MSG_RESETif the event has been disabled while the thread was waiting for an edge.
Function Class:This is an S-Class API, this function can be invoked from within a system lock zone by threads only.

Definition at line 175 of file hal_pal.c.

References osalThreadEnqueueTimeoutS(), pal_lld_get_pad_event, and palevent_t::threads.

Referenced by palWaitPadTimeout().

Here is the call graph for this function:

msg_t palWaitPadTimeout ( ioportid_t  port,
iopadid_t  pad,
sysinterval_t  timeout 
)

Waits for an edge on the specified port/pad.

Parameters
[in]portport identifier
[in]padpad number within the port
[in]timeoutthe number of ticks before the operation timeouts, the following special values are allowed:
  • TIME_IMMEDIATE immediate timeout.
  • TIME_INFINITE no timeout.
Returns
The operation state.
Return values
MSG_OKif an edge has been detected.
MSG_TIMEOUTif a timeout occurred before an edge cound be detected.
MSG_RESETif the event has been disabled while the thread was waiting for an edge.
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 201 of file hal_pal.c.

References osalSysLock(), osalSysUnlock(), and palWaitPadTimeoutS().

Here is the call graph for this function:

msg_t palWaitLineTimeoutS ( ioline_t  line,
sysinterval_t  timeout 
)

Waits for an edge on the specified line.

Parameters
[in]lineline identifier
[in]timeoutoperation timeout
Returns
The operation state.
Return values
MSG_OKif an edge has been detected.
MSG_TIMEOUTif a timeout occurred before an edge could be detected.
MSG_RESETif the event has been disabled while the thread was waiting for an edge.
Function Class:This is an S-Class API, this function can be invoked from within a system lock zone by threads only.

Definition at line 225 of file hal_pal.c.

References osalThreadEnqueueTimeoutS(), pal_lld_get_line_event, and palevent_t::threads.

Referenced by palWaitLineTimeout().

Here is the call graph for this function:

msg_t palWaitLineTimeout ( ioline_t  line,
sysinterval_t  timeout 
)

Waits for an edge on the specified line.

Parameters
[in]lineline identifier
[in]timeoutoperation timeout
Returns
The operation state.
Return values
MSG_OKif an edge has been detected.
MSG_TIMEOUTif a timeout occurred before an edge cound be detected.
MSG_RESETif the event has been disabled while the thread was waiting for an edge.
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 245 of file hal_pal.c.

References osalSysLock(), osalSysUnlock(), and palWaitLineTimeoutS().

Here is the call graph for this function:

void _pal_lld_init ( const PALConfig config)

STM32 I/O ports configuration.

Ports A-D(E, F, G, H) clocks enabled.

Parameters
[in]configthe STM32 ports configuration
Function Class:Not an API, this function is for internal use only.

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.

Parameters
[in]portthe port identifier
[in]maskthe group mask
[in]modethe mode
Function Class:Not an API, this function is for internal use only.

Definition at line 78 of file hal_pal_lld.c.