API Reference
The NEORV32 RISC-V Processor
Loading...
Searching...
No Matches
neorv32_twd.c File Reference

Two-Wire Device Controller (TWD) HW driver source file. More...

#include <neorv32.h>

Functions

int neorv32_twd_available (void)
 
void neorv32_twd_setup (int device_addr, int fsel, uint32_t irq_mask)
 
void neorv32_twd_irq_config (int enable, uint32_t irq_mask)
 
int neorv32_twd_get_rx_fifo_depth (void)
 
int neorv32_twd_get_tx_fifo_depth (void)
 
void neorv32_twd_disable (void)
 
void neorv32_twd_enable (void)
 
void neorv32_twd_clear_rx (void)
 
void neorv32_twd_clear_tx (void)
 
int neorv32_twd_com_state (void)
 
int neorv32_twd_com_started (void)
 
int neorv32_twd_com_ended (void)
 
int neorv32_twd_rx_available (void)
 
int neorv32_twd_rx_full (void)
 
int neorv32_twd_tx_empty (void)
 
int neorv32_twd_tx_full (void)
 
void neorv32_twd_put (uint8_t data)
 
uint8_t neorv32_twd_get (void)
 

Detailed Description

Two-Wire Device Controller (TWD) HW driver source file.

Function Documentation

◆ neorv32_twd_available()

int neorv32_twd_available ( void )

Check if TWD unit was synthesized.

Returns
zero if TWD was not synthesized, non-zero if TWD is available.

◆ neorv32_twd_clear_rx()

void neorv32_twd_clear_rx ( void )

Clear TWD RX FIFO.

◆ neorv32_twd_clear_tx()

void neorv32_twd_clear_tx ( void )

Clear TWD TX FIFO.

◆ neorv32_twd_com_ended()

int neorv32_twd_com_ended ( void )

Check if the TWD communication has ended. This function also clears the "communication ended" flag it it was set.

Returns
Non-zero if a communication-end has been observed, zero otherwise.

◆ neorv32_twd_com_started()

int neorv32_twd_com_started ( void )

Check if the TWD communication has started. This function also clears the "communication started" flag it it was set.

Returns
Non-zero if a communication-start has been observed, zero otherwise.

◆ neorv32_twd_com_state()

int neorv32_twd_com_state ( void )

Check if a TWD communication is active.

Returns
zero if no communication, non-zero if active communication.

◆ neorv32_twd_disable()

void neorv32_twd_disable ( void )

Disable TWD controller.

◆ neorv32_twd_enable()

void neorv32_twd_enable ( void )

Enable TWD controller.

◆ neorv32_twd_get()

uint8_t neorv32_twd_get ( void )

Get data byte from RX FIFO.

Warning
This function is non-blocking. Check FIFO status before.
Returns
Data byte read from RX FIFO.

◆ neorv32_twd_get_rx_fifo_depth()

int neorv32_twd_get_rx_fifo_depth ( void )

Get TWD RX FIFO depth.

Returns
RX FIFO depth (number of entries), zero if no RX FIFO implemented

◆ neorv32_twd_get_tx_fifo_depth()

int neorv32_twd_get_tx_fifo_depth ( void )

Get TWD TX FIFO depth.

Returns
TX FIFO depth (number of entries), zero if no TX FIFO implemented

◆ neorv32_twd_irq_config()

void neorv32_twd_irq_config ( int enable,
uint32_t irq_mask )

Enable/disable IRQ TWD source(s).

Parameters
[in]enableEnable IRQ source(s) when non-zero, disable when zero.
[in]irq_maskInterrupt configuration bit mask (TWD_CTRL_IRQ_* bits).

◆ neorv32_twd_put()

void neorv32_twd_put ( uint8_t data)

Put data byte into TX FIFO.

Warning
This function is non-blocking. Check FIFO status before.
Parameters
[in]dataData byte to be stored in TX FIFO.

◆ neorv32_twd_rx_available()

int neorv32_twd_rx_available ( void )

Check if RX data available.

Returns
zero if no data available, non-zero if data is available.

◆ neorv32_twd_rx_full()

int neorv32_twd_rx_full ( void )

Check if RX FIFO is full.

Returns
zero if no RX FIFO is not full, non-zero if RX FIFO is full.

◆ neorv32_twd_setup()

void neorv32_twd_setup ( int device_addr,
int fsel,
uint32_t irq_mask )

Enable and configure TWD controller. The TWD control register bits are listed in NEORV32_TWD_CTRL_enum.

Parameters
[in]device_addr7-bit device address.
[in]fselBus sample clock / filter select.
[in]irq_maskInterrupt configuration bit mask (TWD_CTRL_IRQ_* bits).

◆ neorv32_twd_tx_empty()

int neorv32_twd_tx_empty ( void )

Check if TX FIFO is empty.

Returns
zero if no TX FIFO is not empty, non-zero if TX FIFO is empty.

◆ neorv32_twd_tx_full()

int neorv32_twd_tx_full ( void )

Check if TX FIFO is full.

Returns
zero if no TX FIFO is not full, non-zero if TX FIFO is full.