![]() |
API Reference
The NEORV32 RISC-V Processor
|
Two-Wire Interface Controller (TWI) HW driver header file. More...
Go to the source code of this file.
Data Structures | |
| struct | neorv32_twi_t |
Functions | |
| static void | neorv32_twi_start_nonblocking (void) |
| static void | neorv32_twi_stop_nonblocking (void) |
| static void | neorv32_twi_tx_nonblocking (uint8_t data) |
| static void | neorv32_twi_rx_ack_nonblocking (void) |
| static void | neorv32_twi_rx_nack_nonblocking (void) |
Prototypes | |
| int | neorv32_twi_available (void) |
| void | neorv32_twi_setup (int prsc, int cdiv) |
| uint32_t | neorv32_twi_get_fifo_depth (void) |
| uint32_t | neorv32_twi_get_clock (void) |
| int | neorv32_twi_sense_scl (void) |
| int | neorv32_twi_sense_sda (void) |
| int | neorv32_twi_claimed (void) |
| int | neorv32_twi_check_nack (void) |
| void | neorv32_twi_irq_clr (void) |
| int | neorv32_twi_busy (void) |
| int | neorv32_twi_rx_avail (void) |
| int | neorv32_twi_tx_full (void) |
| uint8_t | neorv32_twi_rx_get (void) |
| void | neorv32_twi_start (void) |
| void | neorv32_twi_stop (void) |
| void | neorv32_twi_tx (uint8_t data) |
| void | neorv32_twi_rx_ack (void) |
| void | neorv32_twi_rx_nack (void) |
IO Device: Two-Wire Interface Controller (TWI) | |
| #define | NEORV32_TWI ((neorv32_twi_t*) (NEORV32_TWI_BASE)) |
| #define | TWI_DCMD_START ((uint32_t)( (1U<<8) | 0x00U )) |
| #define | TWI_DCMD_STOP ((uint32_t)( (1U<<8) | 0x01U )) |
| #define | TWI_DCMD_TX ((uint32_t)( (0U<<8) )) |
| #define | TWI_DCMD_RXACK ((uint32_t)( (1U<<8) | 0x02U )) |
| #define | TWI_DCMD_RXNACK ((uint32_t)( (1U<<8) | 0x03U )) |
| enum | NEORV32_TWI_CTRL_enum { TWI_CTRL_EN = 0 , TWI_CTRL_PRSC0 = 1 , TWI_CTRL_PRSC1 = 2 , TWI_CTRL_PRSC2 = 3 , TWI_CTRL_CDIV0 = 4 , TWI_CTRL_CDIV1 = 5 , TWI_CTRL_CDIV2 = 6 , TWI_CTRL_CDIV3 = 7 , TWI_CTRL_FIFO_LSB = 15 , TWI_CTRL_FIFO_MSB = 18 , TWI_CTRL_NACK = 23 , TWI_CTRL_NACK_CLR = 24 , TWI_CTRL_IRQ_CLR = 25 , TWI_CTRL_CLAIMED = 26 , TWI_CTRL_SENSE_SCL = 27 , TWI_CTRL_SENSE_SDA = 28 , TWI_CTRL_TX_FULL = 29 , TWI_CTRL_RX_AVAIL = 30 , TWI_CTRL_BUSY = 31 } |
Two-Wire Interface Controller (TWI) HW driver header file.
| #define NEORV32_TWI ((neorv32_twi_t*) (NEORV32_TWI_BASE)) |
TWI module hardware handle (neorv32_twi_t)
| #define TWI_DCMD_RXACK ((uint32_t)( (1U<<8) | 0x02U )) |
TWI module hardware handle (neorv32_twi_t)
| #define TWI_DCMD_RXNACK ((uint32_t)( (1U<<8) | 0x03U )) |
TWI module hardware handle (neorv32_twi_t)
| #define TWI_DCMD_START ((uint32_t)( (1U<<8) | 0x00U )) |
TWI DCMD command masks
| #define TWI_DCMD_STOP ((uint32_t)( (1U<<8) | 0x01U )) |
TWI module hardware handle (neorv32_twi_t)
| #define TWI_DCMD_TX ((uint32_t)( (0U<<8) )) |
TWI module hardware handle (neorv32_twi_t)
TWI control register bits
| int neorv32_twi_available | ( | void | ) |
Check if TWI unit was synthesized.
| int neorv32_twi_busy | ( | void | ) |
Check if TWI controller is busy (TWI bus engine busy or TX FIFO not empty).
| int neorv32_twi_check_nack | ( | void | ) |
Check if a TX transfer returned a NACK and clear NACK flag.
| int neorv32_twi_claimed | ( | void | ) |
Check if bus is (still) claimed by TWI controller.
| uint32_t neorv32_twi_get_clock | ( | void | ) |
Get programmed TWI bus clock speed.
| uint32_t neorv32_twi_get_fifo_depth | ( | void | ) |
Get TWI FIFO depth.
| void neorv32_twi_irq_clr | ( | void | ) |
Clear/acknowledge interrupt request.
| void neorv32_twi_rx_ack | ( | void | ) |
Issue RX data transmission with ACK (read from bus).
|
inlinestatic |
Issue RX data transmission with ACK (read from bus).
| int neorv32_twi_rx_avail | ( | void | ) |
Check if RX data is available.
| uint8_t neorv32_twi_rx_get | ( | void | ) |
Get RX data. Check with neorv32_twi_rx_avail before.
| void neorv32_twi_rx_nack | ( | void | ) |
Issue RX data transmission with NACK (read from bus).
|
inlinestatic |
Issue RX data transmission with NACK (read from bus).
| int neorv32_twi_sense_scl | ( | void | ) |
Get current state of SCL bus line.
| int neorv32_twi_sense_sda | ( | void | ) |
Get current state of SDA bus line.
| void neorv32_twi_setup | ( | int | prsc, |
| int | cdiv ) |
Enable and configure TWI controller. The TWI control register bits are listed in NEORV32_TWI_CTRL_enum.
| [in] | prsc | Clock prescaler select (0..7). See NEORV32_CLOCK_PRSC_enum. |
| [in] | cdiv | Clock divider (0..15). |
| void neorv32_twi_start | ( | void | ) |
Issue START (or REPEATED-START) condition.
|
inlinestatic |
Issue START (or REPEATED-START) condition.
| void neorv32_twi_stop | ( | void | ) |
Issue STOP condition.
|
inlinestatic |
Issue STOP condition.
| void neorv32_twi_tx | ( | uint8_t | data | ) |
Issue TX data transmission (send data to bus).
| [in] | data | Data byte to be send. |
| int neorv32_twi_tx_full | ( | void | ) |
Check if TX FIFO is full.
|
inlinestatic |
Issue TX data transmission (send data to bus).
| [in] | data | Data byte to be send. |