NEORV32 Software Framework Documentation
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, int irq_rx_avail, int irq_rx_full, int irq_tx_empty)
 
int neorv32_twd_get_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_sense_scl (void)
 
int neorv32_twd_sense_sda (void)
 
int neorv32_twd_busy (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.

Note
These functions should only be used if the TWD unit was synthesized (IO_TWD_EN = true).
See also
https://stnolting.github.io/neorv32/sw/files.html

Function Documentation

◆ neorv32_twd_available()

int neorv32_twd_available ( void )

Check if TWD unit was synthesized.

Returns
0 if TWD was not synthesized, 1 if TWD is available.

◆ neorv32_twd_busy()

int neorv32_twd_busy ( void )

Check if there is a TWD bus operation in progress.

Returns
0 if idle, 1 if busy.

◆ 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_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_fifo_depth()

int neorv32_twd_get_fifo_depth ( void )

Get TWD FIFO depth.

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

◆ 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
0 if no data available, 1 if data is available.

◆ neorv32_twd_rx_full()

int neorv32_twd_rx_full ( void )

Check if RX FIFO is full.

Returns
0 if no RX FIFO is not full, 1 if RX FIFO is full.

◆ neorv32_twd_sense_scl()

int neorv32_twd_sense_scl ( void )

Get current state of SCL bus line.

Returns
1 if SCL is high, 0 if SCL is low.

◆ neorv32_twd_sense_sda()

int neorv32_twd_sense_sda ( void )

Get current state of SDA bus line.

Returns
1 if SDA is high, 0 if SDA is low.

◆ neorv32_twd_setup()

void neorv32_twd_setup ( int device_addr,
int fsel,
int irq_rx_avail,
int irq_rx_full,
int irq_tx_empty )

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_rx_availIRQ if RX FIFO data available.
[in]irq_rx_fullIRQ if RX FIFO full.
[in]irq_tx_emptyIRQ if TX FIFO empty.

◆ neorv32_twd_tx_empty()

int neorv32_twd_tx_empty ( void )

Check if TX FIFO is empty.

Returns
0 if no TX FIFO is not empty, 1 if TX FIFO is empty.

◆ neorv32_twd_tx_full()

int neorv32_twd_tx_full ( void )

Check if TX FIFO is full.

Returns
0 if no TX FIFO is not full, 1 if TX FIFO is full.