Input / Output Driver APIs

ADC Interface

static void adc_enable(struct device *dev)

Enable ADC hardware.

This routine enables the ADC hardware block for data sampling for the specified device.

Return
N/A
Parameters
  • dev -

    Pointer to the device structure for the driver instance.

static void adc_disable(struct device *dev)

Disable ADC hardware.

This routine disables the ADC hardware block for data sampling for the specified device.

Return
N/A
Parameters
  • dev -

    Pointer to the device structure for the driver instance.

static int adc_read(struct device *dev, struct adc_seq_table *seq_table)

Set a read request.

This routine sends a read or sampling request to the ADC hardware block. A sequence table describes the read request. The routine returns once the ADC completes the read sequence. The sample data can be retrieved from the memory buffers in the sequence table structure.

Parameters
  • dev -

    Pointer to the device structure for the driver instance.

  • seq_table -

    Pointer to the structure representing the sequence table.

Return Value
  • DEV_OK -

    On success

  • else -

    Otherwise.

struct adc_seq_entry
#include <adc.h>

ADC driver Sequence entry.

This structure defines a sequence entry used to define a sample from a specific channel.

struct adc_seq_table
#include <adc.h>

ADC driver Sequence table.

This structure defines a list of sequence entries used to execute a sequence of samplings.

struct adc_driver_api
#include <adc.h>

ADC driver API.

This structure holds all API function pointers.

GPIO Interface

typedef void(* gpio_callback_t)(struct device *port, uint32_t pin)

Define the application callback function signature.

Parameters
  • port -

    Device struct for the GPIO device.

  • pin -

    The pin that triggers the callback.

static int gpio_pin_configure(struct device *port, uint8_t pin, int flags)

Configure a single pin.

Parameters
  • port -

    Pointer to device structure for the driver instance.

  • pin -

    Pin number to configure.

  • flags -

    Flags for pin configuration. IN/OUT, interrupt ...

static int gpio_pin_write(struct device *port, uint32_t pin, uint32_t value)

Write the data value to a single pin.

Parameters
  • port -

    Pointer to the device structure for the driver instance.

  • pin -

    Pin number where the data is written.

  • value -

    Value set on the pin.

static int gpio_pin_read(struct device *port, uint32_t pin, uint32_t *value)

Read the data value of a single pin.

Parameters
  • port -

    Pointer to the device structure for the driver instance.

  • pin -

    Pin number where data is read.

  • value -

    Integer pointer to receive the data vales from the pin.

static int gpio_set_callback(struct device *port, gpio_callback_t callback)

Set the application’s callback function.

Parameters
  • port -

    Pointer to the device structure for the driver instance.

  • callback -

    Application’s callback function.

static int gpio_pin_enable_callback(struct device *port, uint32_t pin)

Enable the callback function for a single pin.

Parameters
  • port -

    Pointer to the device structure for the driver instance.

  • pin -

    Pin number where the callback function is enabled.

static int gpio_pin_disable_callback(struct device *port, uint32_t pin)

Disable the callback function for a single pin.

Parameters
  • port -

    Pointer to the device structure for the driver instance.

  • pin -

    Pin number where the callback function is disabled.

static int gpio_port_configure(struct device *port, int flags)

Configure all the pins in the port. List out all flags on the detailed description.

Parameters
  • port -

    Pointer to the device structure for the driver instance.

  • flags -

    Flags for the port configuration. IN/OUT, interrupt ...

static int gpio_port_write(struct device *port, uint32_t value)

Write a data value to the port.

Parameters
  • port -

    Pointer to the device structure for the driver instance.

  • value -

    Value to set on the port.

static int gpio_port_read(struct device *port, uint32_t *value)

Read data value from the port.

Parameters
  • port -

    Pointer to the device structure for the driver instance.

  • value -

    Integer pointer to receive the data value from the port.

static int gpio_port_enable_callback(struct device *port)

Enable port callback.

Parameters
  • port -

    Pointer to the device structure for the driver instance.

static int gpio_port_disable_callback(struct device *port)

Disable the callback function for the port.

Parameters
  • port -

    Pointer to the device structure for the driver instance.

static int gpio_suspend(struct device *port)

Save the state of the device and make it go to the low power state.

Parameters
  • port -

    Pointer to the device structure for the driver instance.

static int gpio_resume(struct device *port)

Restore the state stored during suspend and resume operation.

Parameters
  • port -

    Pointer to the device structure for the driver instance.

GPIO_DIR_IN

GPIO pin to be input.

GPIO_DIR_OUT

GPIO pin to be output.

GPIO_DIR_MASK

For internal use.

GPIO_INT

GPIO pin to trigger interrupt.

GPIO_INT_ACTIVE_LOW

GPIO pin trigger on level low or falling edge.

GPIO_INT_ACTIVE_HIGH

GPIO pin trigger on level high or rising edge.

GPIO_INT_CLOCK_SYNC

GPIO pin trggier to be synchronized to clock pulses.

GPIO_INT_DEBOUNCE

Enable GPIO pin debounce.

GPIO_INT_LEVEL

Do Level trigger.

GPIO_INT_EDGE

Do Edge trigger.

GPIO_INT_DOUBLE_EDGE

Interrupt triggers on both rising and falling edge.

GPIO_POL_POS

For internal use.

GPIO_POL_NORMAL

GPIO pin polarity is normal.

GPIO_POL_INV

GPIO pin polarity is inverted.

GPIO_POL_MASK

For internal use.

GPIO_PUD_POS

For internal use.

GPIO_PUD_NORMAL

GPIO pin to have no pull-up or pull-down.

GPIO_PUD_PULL_UP

Enable GPIO pin pull-up.

GPIO_PUD_PULL_DOWN

Enable GPIO pin pull-down.

GPIO_PUD_MASK

For internal use.

GPIO_PIN_ENABLE

Enable GPIO pin.

GPIO_PIN_DISABLE

Disable GPIO pin.

I2C Interface

static int i2c_configure(struct device *dev, uint32_t dev_config)

Configure operation of a host controller.

Parameters
  • dev -

    Pointer to the device structure for the driver instance.

  • dev_config -

    Bit-packed 32-bit value to the device runtime configuration for the I2C controller.

Return Value
  • DEV_OK -

    If successful.

  • DEV_* -

    code otherwise.

static int i2c_write(struct device *dev, uint8_t *buf, uint32_t len, uint16_t addr)

Write a set amount of data to an I2C device.

This routine writes a set amount of data synchronously.

Parameters
  • dev -

    Pointer to the device structure for the driver instance.

  • buf -

    Memory pool from which the data is transferred.

  • len -

    Size of the memory pool available for reading.

  • addr -

    Address to the target I2C device for writing.

Return Value
  • DEV_OK -

    If successful.

  • DEV_* -

    code otherwise.

static int i2c_read(struct device *dev, uint8_t *buf, uint32_t len, uint16_t addr)

Read a set amount of data from an I2C device.

This routine reads a set amount of data synchronously.

Parameters
  • dev -

    Pointer to the device structure for the driver instance.

  • buf -

    Memory pool that stores the retrieved data.

  • len -

    Size of the memory pool available for writing.

  • addr -

    Address of the I2C device being read.

Return Value
  • DEV_OK -

    If successful.

  • DEV_* -

    code otherwise.

static int i2c_transfer(struct device *dev, struct i2c_msg *msgs, uint8_t num_msgs, uint16_t addr)

Perform data transfer to another I2C device.

This routine provides a generic interface to perform data transfer to another I2C device synchronously. Use i2c_read()/i2c_write() for simple read or write.

Parameters
  • dev -

    Pointer to the device structure for the driver instance.

  • msgs -

    Array of messages to transfer.

  • num_msgs -

    Number of messages to transfer.

  • addr -

    Address of the I2C target device.

Return Value
  • DEV_OK -

    If successful.

  • DEV_* -

    code otherwise.

static int i2c_suspend(struct device *dev)

Suspend an I2C driver.

Parameters
  • dev -

    Pointer to the device structure for the driver instance.

Return Value
  • DEV_OK -

    If successful.

static int i2c_resume(struct device *dev)

Resume an I2C driver.

Parameters
  • dev -

    Pointer to the device structure for the driver instance.

Return Value
  • DEV_OK -

    If successful.

I2C_SPEED_STANDARD

I2C Standard Speed

I2C_SPEED_FAST

I2C Fast Speed

I2C_SPEED_FAST_PLUS

I2C Fast Plus Speed

I2C_SPEED_HIGH

I2C High Speed

I2C_SPEED_ULTRA

I2C Ultra Fast Speed

I2C_SPEED_MASK

For internal use.

I2C_ADDR_10_BITS

Use 10-bit addressing.

I2C_MODE_MASTER

Controller to act as Master.

I2C_MODE_SLAVE_READ

Controller to act as Slave.

I2C_MSG_WRITE

Write message to I2C bus.

I2C_MSG_READ

Read message from I2C bus.

I2C_MSG_RW_MASK

For internal use.

I2C_MSG_STOP

Send STOP after this message.

I2C_MSG_RESTART

RESTART I2C transaction for this message.

struct i2c_msg
#include <i2c.h>

One I2C Message.

This defines one I2C message to transact on the I2C bus.

union dev_config
#include <i2c.h>

Public Members

uint32_t raw
struct dev_config::@59 dev_config::bits

IPM Interface

typedef void(* ipm_callback_t)(void *context, uint32_t id, volatile void *data)

Callback API for incoming IPM messages.

These callbacks execute in interrupt context. Therefore, use only interrupt-safe APIS. Registration of callbacks is done via ipm_register_callback

Parameters
  • context -

    Arbitrary context pointer provided at registration time.

  • id -

    Message type identifier.

  • data -

    Message data pointer. The correct amount of data to read out must be inferred using the message id/upper level protocol.

typedef int(* ipm_send_t)(struct device *ipmdev, int wait, uint32_t id, const void *data, int size)
typedef int(* ipm_max_data_size_get_t)(struct device *ipmdev)
typedef uint32_t(* ipm_max_id_val_get_t)(struct device *ipmdev)
typedef void(* ipm_register_callback_t)(struct device *port, ipm_callback_t cb, void *cb_context)
typedef int(* ipm_set_enabled_t)(struct device *ipmdev, int enable)
static int ipm_send(struct device *ipmdev, int wait, uint32_t id, void *data, int size)

Try to send a message over the IPM device.

A message is considered consumed once the remote interrupt handler finishes. If there is deferred processing on the remote side, or if outgoing messages must be queued and wait on an event/semaphore, a high-level driver can implement that.

There are constraints on how much data can be sent or the maximum value of id. Use the ipm_max_data_size_get and ipm_max_id_val_get routines to determine them.

The size parameter is used only on the sending side to determine the amount of data to put in the message registers. It is not passed along to the receiving side. The upper-level protocol dictates the amount of data read back.

Parameters
  • ipmdev -

    Driver instance

  • wait -

    Time to busy-wait for remote to consume the message.

  • id -

    Message identifier. Values are constrained by ipm_max_data_size_get since many platforms only allow for a subset of bits in a 32-bit register to store the ID.

  • data -

    Pointer to the data sent in the message.

  • size -

    Size of the data.

Return Value
  • EBUSY -

    If the remote hasn’t yet read the last data sent.

  • EMSGSIZE -

    If the supplied data size is unsupported by the driver.

  • EINVAL -

    If there was a bad parameter, such as: too-large id value. or the device isn’t an outbound IPM channel.

  • 0 -

    On success.

static void ipm_register_callback(struct device *ipmdev, ipm_callback_t cb, void *context)

Register a callback function for incoming messages.

Parameters
  • ipmdev -

    Driver instance pointer.

  • cb -

    Callback function to execute on incoming message interrupts.

  • context -

    Application-specific context pointer which will be passed to the callback function when executed.

static int ipm_max_data_size_get(struct device *ipmdev)

Return the maximum number of bytes possible in an outbound message.

IPM implementations vary on the amount of data that can be sent in a single message since the data payload is typically stored in registers.

Return
Maximum possible size of a message in bytes.
Parameters
  • ipmdev -

    Driver instance pointer.

static uint32_t ipm_max_id_val_get(struct device *ipmdev)

Return the maximum id value possible in an outbound message.

Many IPM implementations store the message’s ID in a register with some bits reserved for other uses.

Return
Maximum possible value of a message ID.
Parameters
  • ipmdev -

    Driver instance pointer.

static int ipm_set_enabled(struct device *ipmdev, int enable)

Enable interrupts and callbacks for inbound channels.

Parameters
  • ipmdev -

    Driver instance pointer.

  • enable -

    Set to 0 to disable and to nonzero to enable.

Return Value
  • 0 -

    On success.

  • EINVAL -

    If it isn’t an inbound channel.

PWM Interface

typedef int(* pwm_config_t)(struct device *dev, int access_op, uint32_t pwm, int flags)
typedef int(* pwm_set_values_t)(struct device *dev, int access_op, uint32_t pwm, uint32_t on, uint32_t off)
typedef int(* pwm_set_duty_cycle_t)(struct device *dev, int access_op, uint32_t pwm, uint8_t duty)
typedef int(* pwm_suspend_dev_t)(struct device *dev)
typedef int(* pwm_resume_dev_t)(struct device *dev)
static int pwm_pin_configure(struct device *dev, uint8_t pwm, int flags)

Configure a single PWM output.

Parameters
  • dev -

    Pointer to the device structure for the driver instance.

  • pwm -

    PWM output.

  • flags -

    PWM configuration flags.

Return Value
  • DEV_OK -

    If successful,

  • failed -

    Otherwise.

static int pwm_pin_set_values(struct device *dev, uint32_t pwm, uint32_t on, uint32_t off)

Set the ON/OFF values for a single PWM output.

Parameters
  • dev -

    Pointer to the device structure for the driver instance.

  • pwm -

    PWM output.

  • on -

    ON value set to the PWM.

  • off -

    OFF value set to the PWM.

Return Value
  • DEV_OK -

    If successful.

  • failed -

    Otherwise.

static int pwm_pin_set_duty_cycle(struct device *dev, uint32_t pwm, uint8_t duty)

Set the duty cycle of a single PWM output.

This routine overrides any ON/OFF values set before.

Parameters
  • dev -

    Pointer to the device structure for the driver instance.

  • pwm -

    PWM output.

  • duty -

    Duty cycle to set to the PWM in %, for example, 50 sets to 50%.

Return Value
  • DEV_OK -

    If successful.

  • failed -

    Otherwise.

static int pwm_all_configure(struct device *dev, int flags)

Configure all the PWM outputs.

Parameters
  • dev -

    Pointer to the device structure for the driver instance.

  • flags -

    PWM configuration flags.

Return Value
  • DEV_OK -

    If successful.

  • failed -

    Otherwise.

static int pwm_all_set_values(struct device *dev, uint32_t on, uint32_t off)

Set the ON/OFF values for all PWM outputs.

Parameters
  • dev -

    Pointer to the device structure for the driver instance.

  • on -

    ON value set to the PWM.

  • off -

    OFF value set to the PWM.

Return Value
  • DEV_OK -

    If successful.

  • failed -

    Otherwise.

static int pwm_all_set_duty_cycle(struct device *dev, uint8_t duty)

Set the duty cycle of all PWM outputs.

This overrides any ON/OFF values being set before.

Parameters
  • dev -

    Pointer to the device structure for the driver instance.

  • duty -

    Duty cycle to set to the PWM in %, for example, 50 sets to 50%.

Return Value
  • DEV_OK -

    If successful.

  • failed -

    Otherwise.

static int pwm_suspend(struct device *dev)

Save the state of the device and makes it go to the low power state.

Parameters
  • dev -

    Pointer to the device structure for the driver instance.

Return Value
  • DEV_OK -

    If successful.

  • failed -

    Otherwise.

static int pwm_resume(struct device *dev)

Restore state stored during suspend and resumes operation.

Parameters
  • dev -

    Pointer to the device structure for the driver instance.

Return Value
  • DEV_OK -

    If successful.

  • failed -

    Otherwise.

PWM_ACCESS_BY_PIN
PWM_ACCESS_ALL
struct pwm_driver_api
#include <pwm.h>

PWM driver API definition.

Pinmux Interface

typedef uint32_t(* pmux_set)(struct device *dev, uint32_t pin, uint8_t func)
typedef uint32_t(* pmux_get)(struct device *dev, uint32_t pin, uint8_t *func)
typedef uint32_t(* pmux_pullup)(struct device *dev, uint32_t pin, uint8_t func)
typedef uint32_t(* pmux_input)(struct device *dev, uint32_t pin, uint8_t func)
static uint32_t pinmux_pin_set(struct device *dev, uint32_t pin, uint8_t func)
static uint32_t pinmux_pin_get(struct device *dev, uint32_t pin, uint8_t *func)
static uint32_t pinmux_pin_pullup(struct device *dev, uint32_t pin, uint8_t func)
static uint32_t pinmux_pin_input_enable(struct device *dev, uint32_t pin, uint8_t func)
PINMUX_NAME
PINMUX_FUNC_A
PINMUX_FUNC_B
PINMUX_FUNC_C
PINMUX_FUNC_D
PINMUX_PULLUP_ENABLE
PINMUX_PULLUP_DISABLE
PINMUX_INPUT_ENABLED
PINMUX_OUTPUT_ENABLED

SPI Interface

typedef int(* spi_api_configure)(struct device *dev, struct spi_config *config)
typedef int(* spi_api_slave_select)(struct device *dev, uint32_t slave)
typedef int(* spi_api_io)(struct device *dev, uint8_t *tx_buf, uint32_t tx_buf_len, uint8_t *rx_buf, uint32_t rx_buf_len)
typedef int(* spi_api_control)(struct device *dev)
static int spi_configure(struct device *dev, struct spi_config *config)

Configure a host controller for operating against slaves.

Parameters
  • dev -

    Pointer to the device structure for the driver instance.

  • config -

    Pointer to the configuration provided by the application.

Return Value
  • DEV_OK -

    If successful.

  • DEV_* -

    Code otherwise.

static int spi_slave_select(struct device *dev, uint32_t slave)

Select a slave to deal with.

This routine is meaningful only if the controller supports per-slave addressing: One SS line per-slave. If not, this routine has no effect and daisy-chaining should be considered to deal with multiple slaves on the same line.

Parameters
  • dev -

    Pointer to the device structure for the driver instance

  • slave -

    An integer identifying the slave

Return Value
  • DEV_OK -

    If successful.

  • DEV_* -

    Code otherwise.

static int spi_read(struct device *dev, uint8_t *buf, uint32_t len)

Read the specified amount of data from the SPI driver.

Parameters
  • dev -

    Pointer to the device structure for the driver instance.

  • buf -

    Memory buffer where data will be transferred.

  • len -

    Size of the memory buffer available for writing.

Return Value
  • DEV_OK -

    If successful.

  • DEV_* -

    Code otherwise.

static int spi_write(struct device *dev, uint8_t *buf, uint32_t len)

Write the specified amount of data from the SPI driver.

Parameters
  • dev -

    Pointer to the device structure for the driver instance.

  • buf -

    Memory buffer from where data is transferred.

  • len -

    Size of the memory buffer available for reading.

Return Value
  • DEV_OK -

    If successful.

  • DEV_* -

    Code otherwise.

static int spi_transceive(struct device *dev, uint8_t *tx_buf, uint32_t tx_buf_len, uint8_t *rx_buf, uint32_t rx_buf_len)

Read and write the specified amount of data from the SPI driver.

This routine is meant for full-duplex transmission.

Parameters
  • dev -

    Pointer to the device structure for the driver instance.

  • tx_buf -

    Memory buffer where data originates

  • tx_buf_len -

    Size of the memory buffer available for reading.

  • rx_buf -

    Memory buffer where data is transferred.

  • rx_buf_len -

    Size of the memory buffer available for writing.

Return Value
  • DEV_OK -

    If successful.

  • DEV_* -

    Code otherwise.

static int spi_suspend(struct device *dev)

Suspend the SPI host controller operations.

Parameters
  • dev -

    Pointer to the device structure for the driver instance.

Return Value
  • DEV_OK -

    If successful.

  • DEV_* -

    Code otherwise.

static int spi_resume(struct device *dev)

Resume the SPI host controller operations.

Parameters
  • dev -

    Pointer to the device structure for the driver instance.

Return Value
  • DEV_OK -

    If successful.

  • DEV_* -

    Code otherwise.

SPI_MODE_CPOL

SPI Polarity & Phase Modes.

SPI_MODE_CPHA
SPI_MODE_LOOP
SPI_MODE_MASK
SPI_MODE(_in_)
SPI_TRANSFER_MSB

SPI Transfer modes (host controller dependent)

SPI_TRANSFER_LSB
SPI_TRANSFER_MASK
SPI_WORD_SIZE_MASK
SPI_WORD_SIZE_GET(_in_)
SPI_WORD(_in_)
struct spi_config
#include <spi.h>

SPI configuration structure.

config is a bit field with the following parts: mode [ 0 : 2 ] - Polarity, phase and loop mode. transfer_mode [ 3 ] - LSB or MSB first transfer mode. word_size [ 4 : 11 ] - Size of a data frame in bits. RESERVED [ 12 : 31 ] - undefined usage.

max_sys_freq is the maximum frequency supported by the slave it will deal with. This value depends on the host controller. The driver can present a specific format for setting it.

UART Interface

static int uart_err_check(struct device *dev)

Check whether an error was detected.

Parameters
  • dev -

    UART device structure.

Return Value
  • UART_ERROR_OVERRUN -

    if an overrun error was detected.

  • UART_ERROR_PARITY -

    if a parity error was detected.

  • UART_ERROR_FRAMING -

    if a framing error was detected.

  • UART_ERROR_BREAK -

    if a break error was detected.

  • 0 -

    Otherwise.

static int uart_poll_in(struct device * dev, unsigned char * p_char)

Poll the device for input.

Parameters
  • dev -

    UART device structure.

  • p_char -

    Pointer to character.

Return Value
  • 0 -

    If a character arrived.

  • -1 -

    If the input buffer if empty.

  • DEV_INVALID_OP -

    If the operation is not supported.

static unsigned char uart_poll_out(struct device * dev, unsigned char out_char)

Output a character in polled mode.

This routine checks if the transmitter is empty. When the transmitter is empty, it writes a character to the data register.

To send a character when hardware flow control is enabled, the handshake signal CTS must be asserted.

Parameters
  • dev -

    UART device structure.

  • out_char -

    Character to send.

Return Value
  • char -

    Sent character.

static int uart_fifo_fill(struct device *dev, const uint8_t *tx_data, int size)

Fill FIFO with data.

Return
Number of bytes sent.
Parameters
  • dev -

    UART device structure.

  • tx_data -

    Data to transmit.

  • size -

    Number of bytes to send.

static int uart_fifo_read(struct device *dev, uint8_t *rx_data, const int size)

Read data from FIFO.

Return
Number of bytes read.
Parameters
  • dev -

    UART device structure.

  • rx_data -

    Data container.

  • size -

    Container size.

static void uart_irq_tx_enable(struct device *dev)

Enable TX interrupt in IER.

Return
N/A
Parameters
  • dev -

    UART device structure.

static void uart_irq_tx_disable(struct device *dev)

Disable TX interrupt in IER.

Return
N/A
Parameters
  • dev -

    UART device structure.

static int uart_irq_tx_ready(struct device *dev)

Check if Tx IRQ has been raised.

Parameters
  • dev -

    UART device structure.

Return Value
  • 1 -

    If an IRQ is ready.

  • 0 -

    Otherwise.

static void uart_irq_rx_enable(struct device *dev)

Enable RX interrupt in IER.

Return
N/A
Parameters
  • dev -

    UART device structure.

static void uart_irq_rx_disable(struct device *dev)

Disable RX interrupt in IER.

Return
N/A
Parameters
  • dev -

    UART device structure.

static int uart_irq_tx_empty(struct device *dev)

Check if nothing remains to be transmitted.

Parameters
  • dev -

    UART device structure.

Return Value
  • 1 -

    If nothing remains to be transmitted.

  • 0 -

    Otherwise.

static int uart_irq_rx_ready(struct device *dev)

Check if Rx IRQ has been raised.

Parameters
  • dev -

    UART device structure.

Return Value
  • 1 -

    If an IRQ is ready.

  • 0 -

    Otherwise.

static void uart_irq_err_enable(struct device *dev)

Enable error interrupt in IER.

Return
N/A
Parameters
  • dev -

    UART device structure.

static void uart_irq_err_disable(struct device *dev)

Disable error interrupt in IER.

Parameters
  • dev -

    UART device structure.

Return Value
  • 1 -

    If an IRQ is ready.

  • 0 -

    Otherwise.

static int uart_irq_is_pending(struct device *dev)

Check if any IRQs is pending.

Parameters
  • dev -

    UART device structure.

Return Value
  • 1 -

    If an IRQ is pending.

  • 0 -

    Otherwise.

static int uart_irq_update(struct device *dev)

Update cached contents of IIR.

Parameters
  • dev -

    UART device structure.

Return Value
  • 1 -

    Always.

static int uart_irq_input_hook(struct device *dev, uint8_t byte)

Invoke the UART input hook routine if it is installed.

The input hook is a custom handler invoked by the ISR on each received character. It allows the detection of a character escape sequence that can be used to override the behavior of the ISR handler.

Parameters
  • dev -

    UART device structure.

  • byte -

    Byte to process.

Return Value
  • 1 -

    If character processing must stop.

  • 0 -

    If it should continue.

static void uart_irq_input_hook_set(struct device *dev, int (*hook)(struct device *, uint8_t))

Set the UART input hook routine.

Return
N/A
Parameters
  • dev -

    UART device structure.

  • hook -

    Routine to use as UART input hook.

static int uart_drv_cmd(struct device *dev, uint32_t cmd, uint32_t p)

Send extra command to driver.

Implementation and accepted commands are driver specific. Refer to the drivers for more information.

Parameters
  • dev -

    UART device structure.

  • cmd -

    Command to driver.

  • p -

    Parameter to the command.

Return Value
  • DEV_OK -

    If successful.

  • failed -

    Otherwise.

UART_OPTION_AFCE

Options for UART initialization.

LINE_CTRL_BAUD_RATE

Common line controls for UART.

LINE_CTRL_RTS
LINE_CTRL_DTR
UART_ERROR_OVERRUN

Overrun error.

UART_ERROR_PARITY

Parity error.

UART_ERROR_FRAMING

Framing error.

UART_ERROR_BREAK

Break interrupt error:

A break interrupt was received. This happens when the serial input is held at a logic ‘0’ state for longer than the sum of start time + data bits

  • parity + stop bits.

struct uart_device_config
#include <uart.h>

UART device configuration.

union

Base port number or memory mapped base address or register address

Public Members

struct uart_driver_api
#include <uart.h>

Driver API structure.