Two-Wire Device Controller (TWD) HW driver source file.
More...
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
◆ 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 | | ) |
|
◆ neorv32_twd_clear_tx()
void neorv32_twd_clear_tx |
( |
void | | ) |
|
◆ neorv32_twd_disable()
void neorv32_twd_disable |
( |
void | | ) |
|
◆ neorv32_twd_disable_tx_dummy()
void neorv32_twd_disable_tx_dummy |
( |
void | | ) |
|
Disable TWD tx_dummy byte.
◆ neorv32_twd_enable()
void neorv32_twd_enable |
( |
void | | ) |
|
◆ neorv32_twd_enable_tx_dummy()
void neorv32_twd_enable_tx_dummy |
( |
void | | ) |
|
Enable TWD tx_dummy byte.
◆ 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_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] | data | Data 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_set_tx_dummy()
void neorv32_twd_set_tx_dummy |
( |
uint8_t | data | ) |
|
Clear TX Fifo and put data byte into TX FIFO to get stored into dummy.abs
- Warning
- This function expects enabled dummy byte
- Parameters
-
[in] | data | Data byte to be stored in TX FIFO/dummy. |
◆ neorv32_twd_setup()
void neorv32_twd_setup |
( |
int | device_addr, |
|
|
int | fsel, |
|
|
int | irq_rx_avail, |
|
|
int | irq_rx_full, |
|
|
int | irq_tx_empty, |
|
|
int | tx_dummy_en, |
|
|
int | hide_read ) |
Enable and configure TWD controller. The TWD control register bits are listed in NEORV32_TWD_CTRL_enum.
- Parameters
-
[in] | device_addr | 7-bit device address. |
[in] | fsel | Bus sample clock / filter select. |
[in] | irq_rx_avail | IRQ if RX FIFO data available. |
[in] | irq_rx_full | IRQ if RX FIFO full. |
[in] | irq_tx_empty | IRQ if TX FIFO empty. |
[in] | tx_dummy_en | enable sending tx_dummy (last sent byte) when fifo is empty |
[in] | hide_read | generate NACK ony READ-access when TX FIFO is 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.