ChibiOS  21.6.0
SIO Driver

Generic SIO Driver. More...

Collaboration diagram for SIO Driver:

Detailed Description

Generic SIO Driver.

This driver abstracts a generic serial communication channel, usually an UART, this driver is similar to Serial and UART drivers but follows a different concept:

Precondition
In order to use the SIO driver the HAL_USE_SIO option must be enabled in halconf.h.

Driver State Machine

The driver implements a state machine internally, not all the driver functionalities can be used in any moment, any transition not explicitly shown in the following diagram has to be considered an error and shall be captured by an assertion (if enabled).

dot_inline_dotgraph_17.png

Macros

#define _sio_driver_methods   _base_channel_methods
 SIODriver specific methods. More...
 
#define sioGetFlagsX(siop)   sio_lld_get_flags(siop)
 Returns the current set of flags and clears it. More...
 
#define sioIsRXEmptyX(siop)   sio_lld_is_rx_empty(siop)
 Determines the state of the RX FIFO. More...
 
#define sioIsTXFullX(siop)   sio_lld_is_tx_full(siop)
 Determines the state of the TX FIFO. More...
 
#define sioGetAndClearEventsI(siop)   sio_lld_get_and_clear_events(siop)
 Return the pending SIO events flags. More...
 
#define sioGetX(siop)   sio_lld_get(siop)
 Returns one frame from the RX FIFO. More...
 
#define sioPutX(siop, data)   sio_lld_put(siop, data)
 Pushes one frame into the TX FIFO. More...
 
#define sioAsyncReadI(siop, size, buffer)   sio_lld_read(siop, size, buffer)
 Reads data from the RX FIFO. More...
 
#define sioAsyncWriteI(siop, size, buffer)   sio_lld_write(siop, size, buffer)
 Writes data into the TX FIFO. More...
 
#define sioControlX(siop, operation, arg)   sio_lld_control(siop, operation, arg)
 Control operation on a serial port. More...
 
#define sio_lld_driver_fields   uint32_t dummy
 Low level fields of the SIO driver structure. More...
 
#define sio_lld_config_fields   uint32_t dummy
 Low level fields of the SIO configuration structure. More...
 
#define sio_lld_is_rx_empty(siop)   false
 Determines the state of the RX FIFO. More...
 
#define sio_lld_is_tx_full(siop)   false
 Determines the state of the TX FIFO. More...
 
#define sio_lld_is_tx_ongoing(siop)   false
 Determines the transmission state. More...
 

SIO status flags

#define SIO_NO_ERROR   0
 No pending conditions.
More...
 
#define SIO_PARITY_ERROR   4
 Parity error happened.
More...
 
#define SIO_FRAMING_ERROR   8
 Framing error happened.
More...
 
#define SIO_OVERRUN_ERROR   16
 Overflow happened.
More...
 
#define SIO_NOISE_ERROR   32
 Noise on the line.
More...
 
#define SIO_BREAK_DETECTED   64
 Break detected.
More...
 

SIO additional messages

#define SIO_MSG_IDLE   1
 
#define SIO_MSG_ERRORS   2
 

SIO configuration options

#define SIO_DEFAULT_BITRATE   38400
 Default bit rate. More...
 
#define SIO_USE_SYNCHRONIZATION   TRUE
 Support for thread synchronization API. More...
 

Low level driver helper macros

#define __sio_callback_rx(siop)
 RX callback. More...
 
#define __sio_callback_rx_idle(siop)
 RX idle callback. More...
 
#define __sio_callback_tx(siop)
 TX callback. More...
 
#define __sio_callback_tx_end(siop)
 TX end callback. More...
 
#define __sio_callback_rx_evt(siop)
 RX event callback. More...
 
#define __sio_wakeup_rx(siop, msg)
 Wakes up the RX-waiting thread. More...
 
#define __sio_wakeup_tx(siop, msg)
 Wakes up the TX-waiting thread. More...
 
#define __sio_wakeup_txend(siop, msg)
 Wakes up the TXend-waiting thread. More...
 

PLATFORM configuration options

#define PLATFORM_SIO_USE_SIO1   FALSE
 SIO driver enable switch. More...
 

Typedefs

typedef uint_fast8_t sioflags_t
 SIO driver condition flags type. More...
 
typedef struct hal_sio_driver SIODriver
 Type of structure representing a SIO driver. More...
 
typedef struct hal_sio_config SIOConfig
 Type of structure representing a SIO configuration. More...
 
typedef struct hal_sio_operation SIOOperation
 Type of structure representing a SIO operation. More...
 
typedef void(* siocb_t) (SIODriver *siop)
 Generic SIO notification callback type. More...
 
typedef uint32_t sio_events_mask_t
 Type of a SIO events mask. More...
 

Data Structures

struct  hal_sio_config
 Driver configuration structure. More...
 
struct  sio_driver_vmt
 SIODriver virtual methods table. More...
 
struct  hal_sio_driver
 Structure representing a SIO driver. More...
 
struct  hal_sio_operation
 Structure representing a SIO operation. More...
 

Functions

void sioInit (void)
 SIO Driver initialization. More...
 
void sioObjectInit (SIODriver *siop)
 Initializes the standard part of a SIODriver structure. More...
 
bool sioStart (SIODriver *siop, const SIOConfig *config)
 Configures and activates the SIO peripheral. More...
 
void sioStop (SIODriver *siop)
 Deactivates the SIO peripheral. More...
 
void sioStartOperation (SIODriver *siop, const SIOOperation *operation)
 Starts a SIO operation. More...
 
void sioStopOperation (SIODriver *siop)
 Stops an ongoing SIO operation, if any. More...
 
sio_events_mask_t sioGetAndClearEvents (SIODriver *siop)
 Return the pending SIO events flags. More...
 
size_t sioAsyncRead (SIODriver *siop, uint8_t *buffer, size_t n)
 Reads data from the RX FIFO. More...
 
size_t sioAsyncWrite (SIODriver *siop, const uint8_t *buffer, size_t n)
 Writes data into the TX FIFO. More...
 
msg_t sioSynchronizeRX (SIODriver *siop, sysinterval_t timeout)
 Synchronizes with RX FIFO data availability. More...
 
msg_t sioSynchronizeTX (SIODriver *siop, sysinterval_t timeout)
 Synchronizes with TX FIFO space availability. More...
 
msg_t sioSynchronizeTXEnd (SIODriver *siop, sysinterval_t timeout)
 Synchronizes with TX completion. More...
 
void sio_lld_init (void)
 Low level SIO driver initialization. More...
 
bool sio_lld_start (SIODriver *siop)
 Configures and activates the SIO peripheral. More...
 
void sio_lld_stop (SIODriver *siop)
 Deactivates the SIO peripheral. More...
 
void sio_lld_start_operation (SIODriver *siop)
 Starts a SIO operation. More...
 
void sio_lld_stop_operation (SIODriver *siop)
 Stops an ongoing SIO operation, if any. More...
 
sio_events_mask_t sio_lld_get_and_clear_events (SIODriver *siop)
 Return the pending SIO events flags. More...
 
size_t sio_lld_read (SIODriver *siop, uint8_t *buffer, size_t n)
 Reads data from the RX FIFO. More...
 
size_t sio_lld_write (SIODriver *siop, const uint8_t *buffer, size_t n)
 Writes data into the TX FIFO. More...
 
msg_t sio_lld_get (SIODriver *siop)
 Returns one frame from the RX FIFO. More...
 
void sio_lld_put (SIODriver *siop, uint_fast16_t data)
 Pushes one frame into the TX FIFO. More...
 
msg_t sio_lld_control (SIODriver *siop, unsigned int operation, void *arg)
 Control operation on a serial port. More...
 

Enumerations

enum  siostate_t { SIO_UNINIT = 0, SIO_STOP = 1, SIO_READY = 2, SIO_ACTIVE = 3 }
 Driver state machine possible states. More...
 

Variables

SIODriver SIOD1
 SIO1 driver identifier. More...
 

Macro Definition Documentation

◆ SIO_NO_ERROR

#define SIO_NO_ERROR   0

No pending conditions.

Definition at line 38 of file hal_sio.h.

◆ SIO_PARITY_ERROR

#define SIO_PARITY_ERROR   4

Parity error happened.

Definition at line 39 of file hal_sio.h.

◆ SIO_FRAMING_ERROR

#define SIO_FRAMING_ERROR   8

Framing error happened.

Definition at line 40 of file hal_sio.h.

◆ SIO_OVERRUN_ERROR

#define SIO_OVERRUN_ERROR   16

Overflow happened.

Definition at line 41 of file hal_sio.h.

◆ SIO_NOISE_ERROR

#define SIO_NOISE_ERROR   32

Noise on the line.

Definition at line 42 of file hal_sio.h.

◆ SIO_BREAK_DETECTED

#define SIO_BREAK_DETECTED   64

Break detected.

Definition at line 43 of file hal_sio.h.

◆ SIO_DEFAULT_BITRATE

#define SIO_DEFAULT_BITRATE   38400

Default bit rate.

Configuration parameter, this is the baud rate selected for the default configuration.

Definition at line 68 of file hal_sio.h.

◆ SIO_USE_SYNCHRONIZATION

#define SIO_USE_SYNCHRONIZATION   TRUE

Support for thread synchronization API.

Definition at line 75 of file hal_sio.h.

◆ _sio_driver_methods

#define _sio_driver_methods   _base_channel_methods

SIODriver specific methods.

Definition at line 139 of file hal_sio.h.

◆ sioGetFlagsX

#define sioGetFlagsX (   siop)    sio_lld_get_flags(siop)

Returns the current set of flags and clears it.

Definition at line 234 of file hal_sio.h.

◆ sioIsRXEmptyX

#define sioIsRXEmptyX (   siop)    sio_lld_is_rx_empty(siop)

Determines the state of the RX FIFO.

Parameters
[in]sioppointer to the SIODriver object
Returns
The RX FIFO state.
Return values
falseif RX FIFO is not empty
trueif RX FIFO is empty
Function Class:
This is an X-Class API, this function can be invoked from any context.

Definition at line 246 of file hal_sio.h.

◆ sioIsTXFullX

#define sioIsTXFullX (   siop)    sio_lld_is_tx_full(siop)

Determines the state of the TX FIFO.

Parameters
[in]sioppointer to the SIODriver object
Returns
The TX FIFO state.
Return values
falseif TX FIFO is not full
trueif TX FIFO is full
Function Class:
This is an X-Class API, this function can be invoked from any context.

Definition at line 258 of file hal_sio.h.

◆ sioGetAndClearEventsI

#define sioGetAndClearEventsI (   siop)    sio_lld_get_and_clear_events(siop)

Return the pending SIO events flags.

Parameters
[in]sioppointer to the SIODriver object
Returns
The pending event flags.
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 268 of file hal_sio.h.

◆ sioGetX

#define sioGetX (   siop)    sio_lld_get(siop)

Returns one frame from the RX FIFO.

Note
If the FIFO is empty then the returned value is unpredictable.
Parameters
[in]sioppointer to the SIODriver object
Returns
The frame from RX FIFO.
Function Class:
This is an X-Class API, this function can be invoked from any context.

Definition at line 279 of file hal_sio.h.

◆ sioPutX

#define sioPutX (   siop,
  data 
)    sio_lld_put(siop, data)

Pushes one frame into the TX FIFO.

Note
If the FIFO is full then the behavior is unpredictable.
Parameters
[in]sioppointer to the SIODriver object
[in]dataframe to be written
Function Class:
This is an X-Class API, this function can be invoked from any context.

Definition at line 290 of file hal_sio.h.

◆ sioAsyncReadI

#define sioAsyncReadI (   siop,
  size,
  buffer 
)    sio_lld_read(siop, size, buffer)

Reads data from the RX FIFO.

This function is non-blocking, data is read if present and the effective amount is returned.

Note
This function can be called from any context but it is meant to be called from the rxne_cb callback handler.
Parameters
[in]sioppointer to the SIODriver object
[in]sizemaximum number of frames to read
[in]bufferbuffer for the received data
Returns
The number of received frames.
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 306 of file hal_sio.h.

◆ sioAsyncWriteI

#define sioAsyncWriteI (   siop,
  size,
  buffer 
)    sio_lld_write(siop, size, buffer)

Writes data into the TX FIFO.

This function is non-blocking, data is written if there is space in the FIFO and the effective amount is returned.

Note
This function can be called from any context but it is meant to be called from the txnf_cb callback handler.
Parameters
[in]sioppointer to the SIODriver object
[in]sizemaximum number of frames to read
[out]bufferbuffer containing the data to be transmitted
Returns
The number of transmitted frames.
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 322 of file hal_sio.h.

◆ sioControlX

#define sioControlX (   siop,
  operation,
  arg 
)    sio_lld_control(siop, operation, arg)

Control operation on a serial port.

Parameters
[in]sioppointer to the SIODriver object
[in]operationcontrol operation code
[in,out]argoperation argument
Returns
The control operation status.
Return values
MSG_OKin case of success.
MSG_TIMEOUTin case of operation timeout.
MSG_RESETin case of operation reset.
Function Class:
This is an X-Class API, this function can be invoked from any context.

Definition at line 338 of file hal_sio.h.

◆ __sio_callback_rx

#define __sio_callback_rx (   siop)
Value:
{ \
if ((siop)->operation->rx_cb != NULL) { \
(siop)->operation->rx_cb(siop); \
} \
}

RX callback.

Parameters
[in]sioppointer to the SIODriver object
Function Class:
Not an API, this function is for internal use only.

Definition at line 351 of file hal_sio.h.

◆ __sio_callback_rx_idle

#define __sio_callback_rx_idle (   siop)
Value:
{ \
if ((siop)->operation->rx_idle_cb != NULL) { \
(siop)->operation->rx_idle_cb(siop); \
} \
}

RX idle callback.

Parameters
[in]sioppointer to the SIODriver object
Function Class:
Not an API, this function is for internal use only.

Definition at line 364 of file hal_sio.h.

◆ __sio_callback_tx

#define __sio_callback_tx (   siop)
Value:
{ \
if ((siop)->operation->tx_cb != NULL) { \
(siop)->operation->tx_cb(siop); \
} \
}

TX callback.

Parameters
[in]sioppointer to the SIODriver object
Function Class:
Not an API, this function is for internal use only.

Definition at line 377 of file hal_sio.h.

◆ __sio_callback_tx_end

#define __sio_callback_tx_end (   siop)
Value:
{ \
if ((siop)->operation->tx_end_cb != NULL) { \
(siop)->operation->tx_end_cb(siop); \
} \
}

TX end callback.

Parameters
[in]sioppointer to the SIODriver object
Function Class:
Not an API, this function is for internal use only.

Definition at line 390 of file hal_sio.h.

◆ __sio_callback_rx_evt

#define __sio_callback_rx_evt (   siop)
Value:
{ \
if ((siop)->operation->rx_evt_cb != NULL) { \
(siop)->operation->rx_evt_cb(siop); \
} \
}

RX event callback.

Parameters
[in]sioppointer to the SIODriver object
Function Class:
Not an API, this function is for internal use only.

Definition at line 403 of file hal_sio.h.

◆ __sio_wakeup_rx

#define __sio_wakeup_rx (   siop,
  msg 
)
Value:
{ \
osalSysLockFromISR(); \
osalThreadResumeI(&(siop)->sync_rx, msg); \
osalSysUnlockFromISR(); \
}

Wakes up the RX-waiting thread.

Parameters
[in]sioppointer to the SIODriver object
[in]msgthe wake up message
Function Class:
Not an API, this function is for internal use only.

Definition at line 418 of file hal_sio.h.

◆ __sio_wakeup_tx

#define __sio_wakeup_tx (   siop,
  msg 
)
Value:
{ \
osalSysLockFromISR(); \
osalThreadResumeI(&(siop)->sync_tx, msg); \
osalSysUnlockFromISR(); \
}

Wakes up the TX-waiting thread.

Parameters
[in]sioppointer to the SIODriver object
[in]msgthe wake up message
Function Class:
Not an API, this function is for internal use only.

Definition at line 432 of file hal_sio.h.

◆ __sio_wakeup_txend

#define __sio_wakeup_txend (   siop,
  msg 
)
Value:
{ \
osalSysLockFromISR(); \
osalThreadResumeI(&(siop)->sync_txend, msg); \
osalSysUnlockFromISR(); \
}

Wakes up the TXend-waiting thread.

Parameters
[in]sioppointer to the SIODriver object
[in]msgthe wake up message
Function Class:
Not an API, this function is for internal use only.

Definition at line 446 of file hal_sio.h.

◆ PLATFORM_SIO_USE_SIO1

#define PLATFORM_SIO_USE_SIO1   FALSE

SIO driver enable switch.

If set to TRUE the support for SIO1 is included.

Note
The default is FALSE.

Definition at line 48 of file hal_sio_lld.h.

◆ sio_lld_driver_fields

#define sio_lld_driver_fields   uint32_t dummy

Low level fields of the SIO driver structure.

Definition at line 72 of file hal_sio_lld.h.

◆ sio_lld_config_fields

#define sio_lld_config_fields   uint32_t dummy

Low level fields of the SIO configuration structure.

Definition at line 78 of file hal_sio_lld.h.

◆ sio_lld_is_rx_empty

#define sio_lld_is_rx_empty (   siop)    false

Determines the state of the RX FIFO.

Parameters
[in]sioppointer to the SIODriver object
Returns
The RX FIFO state.
Return values
falseif RX FIFO is not empty
trueif RX FIFO is empty
Function Class:
Not an API, this function is for internal use only.

Definition at line 91 of file hal_sio_lld.h.

◆ sio_lld_is_tx_full

#define sio_lld_is_tx_full (   siop)    false

Determines the state of the TX FIFO.

Parameters
[in]sioppointer to the SIODriver object
Returns
The TX FIFO state.
Return values
falseif TX FIFO is not full
trueif TX FIFO is full
Function Class:
Not an API, this function is for internal use only.

Definition at line 103 of file hal_sio_lld.h.

◆ sio_lld_is_tx_ongoing

#define sio_lld_is_tx_ongoing (   siop)    false

Determines the transmission state.

Parameters
[in]sioppointer to the SIODriver object
Returns
The TX FIFO state.
Return values
falseif transmission is idle
trueif transmission is ongoing
Function Class:
Not an API, this function is for internal use only.

Definition at line 115 of file hal_sio_lld.h.

Typedef Documentation

◆ sioflags_t

typedef uint_fast8_t sioflags_t

SIO driver condition flags type.

Definition at line 90 of file hal_sio.h.

◆ SIODriver

typedef struct hal_sio_driver SIODriver

Type of structure representing a SIO driver.

Definition at line 95 of file hal_sio.h.

◆ SIOConfig

typedef struct hal_sio_config SIOConfig

Type of structure representing a SIO configuration.

Definition at line 100 of file hal_sio.h.

◆ SIOOperation

Type of structure representing a SIO operation.

Definition at line 105 of file hal_sio.h.

◆ siocb_t

typedef void(* siocb_t) (SIODriver *siop)

Generic SIO notification callback type.

Parameters
[in]sioppointer to the SIODriver object

Definition at line 112 of file hal_sio.h.

◆ sio_events_mask_t

typedef uint32_t sio_events_mask_t

Type of a SIO events mask.

Definition at line 63 of file hal_sio_lld.h.

Enumeration Type Documentation

◆ siostate_t

enum siostate_t

Driver state machine possible states.

Enumerator
SIO_UNINIT 

Not initialized.

SIO_STOP 

Stopped.

SIO_READY 

Ready.

SIO_ACTIVE 

Operation ongoing.

Definition at line 117 of file hal_sio.h.

Function Documentation

◆ sioInit()

void sioInit ( void  )

SIO Driver 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 213 of file hal_sio.c.

References sio_lld_init().

Referenced by halInit().

Here is the call graph for this function:

◆ sioObjectInit()

void sioObjectInit ( SIODriver siop)

Initializes the standard part of a SIODriver structure.

Parameters
[out]sioppointer to the SIODriver object
Function Class:
Initializer, this function just initializes an object and can be invoked before the kernel is initialized.

Definition at line 225 of file hal_sio.c.

References hal_sio_driver::vmt.

Referenced by sio_lld_init().

◆ sioStart()

bool sioStart ( SIODriver siop,
const SIOConfig config 
)

Configures and activates the SIO peripheral.

Parameters
[in]sioppointer to the SIODriver object
[in]configpointer to the SIOConfig object, can be NULL if the default configuration is desired
Returns
The operation status.
Return values
falseif the driver has been correctly started.
trueif an error occurred.
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 251 of file hal_sio.c.

References hal_sio_driver::config, osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), sio_lld_start(), SIO_READY, SIO_STOP, and hal_sio_driver::state.

Here is the call graph for this function:

◆ sioStop()

void sioStop ( SIODriver siop)

Deactivates the SIO peripheral.

Parameters
[in]sioppointer to the SIODriver object
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 277 of file hal_sio.c.

References hal_sio_driver::config, osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), sio_lld_stop(), SIO_READY, SIO_STOP, and hal_sio_driver::state.

Here is the call graph for this function:

◆ sioStartOperation()

void sioStartOperation ( SIODriver siop,
const SIOOperation operation 
)

Starts a SIO operation.

Parameters
[in]sioppointer to an SIODriver structure
[in]operationpointer to an SIOOperation structure, can be NULL if callbacks are not required encoding the operation to be performed
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 303 of file hal_sio.c.

References hal_sio_driver::operation, osalDbgAssert, osalDbgCheck, osalSysLock(), SIO_READY, and hal_sio_driver::state.

Here is the call graph for this function:

◆ sioStopOperation()

void sioStopOperation ( SIODriver siop)

Stops an ongoing SIO operation, if any.

Parameters
[in]sioppointer to an SIODriver structure
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 333 of file hal_sio.c.

References MSG_RESET, hal_sio_driver::operation, osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), osalThreadResumeI(), SIO_ACTIVE, sio_lld_stop_operation(), SIO_READY, hal_sio_driver::state, hal_sio_driver::sync_rx, hal_sio_driver::sync_tx, and hal_sio_driver::sync_txend.

Here is the call graph for this function:

◆ sioGetAndClearEvents()

sio_events_mask_t sioGetAndClearEvents ( SIODriver siop)

Return the pending SIO events flags.

Parameters
[in]sioppointer to the SIODriver object
Returns
The pending event flags.
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 364 of file hal_sio.c.

References osalDbgCheck, osalSysLock(), osalSysUnlock(), and sioGetAndClearEventsI.

Here is the call graph for this function:

◆ sioAsyncRead()

size_t sioAsyncRead ( SIODriver siop,
uint8_t *  buffer,
size_t  n 
)

Reads data from the RX FIFO.

This function is non-blocking, data is read if present and the effective amount is returned.

Note
This function can be called from any context but it is meant to be called from the rxne_cb callback handler.
Parameters
[in]sioppointer to the SIODriver object
[in]bufferbuffer for the received data
[in]nmaximum number of frames to read
Returns
The number of received frames.
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 392 of file hal_sio.c.

References osalDbgCheck, osalSysLock(), osalSysUnlock(), and sioAsyncReadI.

Here is the call graph for this function:

◆ sioAsyncWrite()

size_t sioAsyncWrite ( SIODriver siop,
const uint8_t *  buffer,
size_t  n 
)

Writes data into the TX FIFO.

This function is non-blocking, data is written if there is space in the FIFO and the effective amount is returned.

Note
This function can be called from any context but it is meant to be called from the txnf_cb callback handler.
Parameters
[in]sioppointer to the SIODriver object
[out]bufferbuffer containing the data to be transmitted
[in]nmaximum number of frames to read
Returns
The number of transmitted frames.
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 419 of file hal_sio.c.

References osalDbgCheck, osalSysLock(), osalSysUnlock(), and sioAsyncWriteI.

Here is the call graph for this function:

◆ sioSynchronizeRX()

msg_t sioSynchronizeRX ( SIODriver siop,
sysinterval_t  timeout 
)

Synchronizes with RX FIFO data availability.

Note
The exact behavior depends on low level FIFO settings such as thresholds, etc.
This function can only be called by a single thread at time.
Parameters
[in]sioppointer to an SIODriver structure
[in]timeoutsynchronization timeout
Returns
The synchronization result.
Return values
MSG_OKif there is data in the RX FIFO.
MSG_TIMEOUTif synchronization timed out.
MSG_RESEToperation has been stopped while waiting.
SIO_MSG_IDLEif RX line went idle.
SIO_MSG_ERRORSif RX errors occurred during wait.

Definition at line 448 of file hal_sio.c.

References MSG_OK, osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), osalThreadSuspendTimeoutS(), SIO_ACTIVE, sio_lld_is_rx_empty, hal_sio_driver::state, and hal_sio_driver::sync_rx.

Here is the call graph for this function:

◆ sioSynchronizeTX()

msg_t sioSynchronizeTX ( SIODriver siop,
sysinterval_t  timeout 
)

Synchronizes with TX FIFO space availability.

Note
The exact behavior depends on low level FIFO settings such as thresholds, etc.
This function can only be called by a single thread at time.
Parameters
[in]sioppointer to an SIODriver structure
[in]timeoutsynchronization timeout
Returns
The synchronization result.
Return values
MSG_OKif there is space in the TX FIFO.
MSG_TIMEOUTif synchronization timed out.
MSG_RESEToperation has been stopped while waiting.

Definition at line 483 of file hal_sio.c.

References MSG_OK, osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), osalThreadSuspendTimeoutS(), SIO_ACTIVE, sio_lld_is_tx_full, hal_sio_driver::state, and hal_sio_driver::sync_tx.

Here is the call graph for this function:

◆ sioSynchronizeTXEnd()

msg_t sioSynchronizeTXEnd ( SIODriver siop,
sysinterval_t  timeout 
)

Synchronizes with TX completion.

Note
This function can only be called by a single thread at time.
Parameters
[in]sioppointer to an SIODriver structure
[in]timeoutsynchronization timeout
Returns
The synchronization result.
Return values
MSG_OKif TX operation finished.
MSG_TIMEOUTif synchronization timed out.

Definition at line 515 of file hal_sio.c.

References MSG_OK, osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), osalThreadSuspendTimeoutS(), SIO_ACTIVE, sio_lld_is_tx_ongoing, hal_sio_driver::state, and hal_sio_driver::sync_txend.

Here is the call graph for this function:

◆ sio_lld_init()

void sio_lld_init ( void  )

Low level SIO driver initialization.

Function Class:
Not an API, this function is for internal use only.

Definition at line 65 of file hal_sio_lld.c.

References SIOD1, and sioObjectInit().

Referenced by sioInit().

Here is the call graph for this function:

◆ sio_lld_start()

bool sio_lld_start ( SIODriver siop)

Configures and activates the SIO peripheral.

Parameters
[in]sioppointer to the SIODriver object
Returns
The operation status.
Return values
falseif the driver has been correctly started.
trueif an error occurred.
Function Class:
Not an API, this function is for internal use only.

Definition at line 83 of file hal_sio_lld.c.

References SIO_STOP, SIOD1, and hal_sio_driver::state.

Referenced by sioStart().

◆ sio_lld_stop()

void sio_lld_stop ( SIODriver siop)

Deactivates the SIO peripheral.

Parameters
[in]sioppointer to the SIODriver object
Function Class:
Not an API, this function is for internal use only.

Definition at line 105 of file hal_sio_lld.c.

References SIO_READY, SIOD1, and hal_sio_driver::state.

Referenced by sioStop().

◆ sio_lld_start_operation()

void sio_lld_start_operation ( SIODriver siop)

Starts a SIO operation.

Parameters
[in]sioppointer to an SIODriver structure
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 126 of file hal_sio_lld.c.

◆ sio_lld_stop_operation()

void sio_lld_stop_operation ( SIODriver siop)

Stops an ongoing SIO operation, if any.

Parameters
[in]sioppointer to an SIODriver structure
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 138 of file hal_sio_lld.c.

Referenced by sioStopOperation().

◆ sio_lld_get_and_clear_events()

sio_events_mask_t sio_lld_get_and_clear_events ( SIODriver siop)

Return the pending SIO events flags.

Parameters
[in]sioppointer to the SIODriver object
Returns
The pending event flags.
Function Class:
Not an API, this function is for internal use only.

Definition at line 151 of file hal_sio_lld.c.

◆ sio_lld_read()

size_t sio_lld_read ( SIODriver siop,
uint8_t *  buffer,
size_t  n 
)

Reads data from the RX FIFO.

The function is not blocking, it writes frames until there is space available without waiting.

Parameters
[in]sioppointer to an SIODriver structure
[in]bufferpointer to the buffer for read frames
[in]nmaximum number of frames to be read
Returns
The number of frames copied from the buffer.
Return values
0if the TX FIFO is full.

Definition at line 170 of file hal_sio_lld.c.

◆ sio_lld_write()

size_t sio_lld_write ( SIODriver siop,
const uint8_t *  buffer,
size_t  n 
)

Writes data into the TX FIFO.

The function is not blocking, it writes frames until there is space available without waiting.

Parameters
[in]sioppointer to an SIODriver structure
[in]bufferpointer to the buffer for read frames
[in]nmaximum number of frames to be written
Returns
The number of frames copied from the buffer.
Return values
0if the TX FIFO is full.

Definition at line 189 of file hal_sio_lld.c.

◆ sio_lld_get()

msg_t sio_lld_get ( SIODriver siop)

Returns one frame from the RX FIFO.

Note
If the FIFO is empty then the returned value is unpredictable.
Parameters
[in]sioppointer to the SIODriver object
Returns
The frame from RX FIFO.
Function Class:
Not an API, this function is for internal use only.

Definition at line 206 of file hal_sio_lld.c.

◆ sio_lld_put()

void sio_lld_put ( SIODriver siop,
uint_fast16_t  data 
)

Pushes one frame into the TX FIFO.

Note
If the FIFO is full then the behavior is unpredictable.
Parameters
[in]sioppointer to the SIODriver object
[in]dataframe to be written
Function Class:
Not an API, this function is for internal use only.

Definition at line 223 of file hal_sio_lld.c.

◆ sio_lld_control()

msg_t sio_lld_control ( SIODriver siop,
unsigned int  operation,
void *  arg 
)

Control operation on a serial port.

Parameters
[in]sioppointer to the SIODriver object
[in]operationcontrol operation code
[in,out]argoperation argument
Returns
The control operation status.
Return values
MSG_OKin case of success.
MSG_TIMEOUTin case of operation timeout.
MSG_RESETin case of operation reset.
Function Class:
Not an API, this function is for internal use only.

Definition at line 243 of file hal_sio_lld.c.

References MSG_OK.

Variable Documentation

◆ SIOD1

SIODriver SIOD1

SIO1 driver identifier.

Definition at line 41 of file hal_sio_lld.c.

Referenced by sio_lld_init(), sio_lld_start(), and sio_lld_stop().