NEORV32 Software Framework Documentation
The NEORV32 RISC-V Processor
|
Two-Wire Interface Controller (TWI) HW driver header file. More...
#include <stdint.h>
Go to the source code of this file.
Data Structures | |
struct | neorv32_twi_t |
Macros | |
TWI commands | |
#define | TWI_CMD_NOP (0b00) |
#define | TWI_CMD_START (0b01) |
#define | TWI_CMD_STOP (0b10) |
#define | TWI_CMD_RTX (0b11) |
Functions | |
Prototypes | |
int | neorv32_twi_available (void) |
void | neorv32_twi_setup (int prsc, int cdiv, int clkstr) |
int | neorv32_twi_get_fifo_depth (void) |
void | neorv32_twi_disable (void) |
void | neorv32_twi_enable (void) |
int | neorv32_twi_busy (void) |
int | neorv32_twi_get (uint8_t *data) |
int | neorv32_twi_trans (uint8_t *data, int mack) |
void | neorv32_twi_generate_stop (void) |
void | neorv32_twi_generate_start (void) |
void | neorv32_twi_send_nonblocking (uint8_t data, int mack) |
void | neorv32_twi_generate_stop_nonblocking (void) |
void | neorv32_twi_generate_start_nonblocking (void) |
IO Device: Two-Wire Interface Controller (TWI) | |
#define | NEORV32_TWI ((neorv32_twi_t*) (NEORV32_TWI_BASE)) |
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_CLKSTR = 8 , TWI_CTRL_FIFO_LSB = 15 , TWI_CTRL_FIFO_MSB = 18 , TWI_CTRL_TX_FULL = 29 , TWI_CTRL_RX_AVAIL = 30 , TWI_CTRL_BUSY = 31 } |
enum | NEORV32_TWI_DCMD_enum { TWI_DCMD_LSB = 0 , TWI_DCMD_MSB = 7 , TWI_DCMD_ACK = 8 , TWI_DCMD_CMD_LO = 9 , TWI_DCMD_CMD_HI = 10 } |
Two-Wire Interface Controller (TWI) HW driver header file.
#define NEORV32_TWI ((neorv32_twi_t*) (NEORV32_TWI_BASE)) |
TWI module hardware access (neorv32_twi_t)
TWI control register bits
TWI command/data register bits
int neorv32_twi_available | ( | void | ) |
Check if TWI unit was synthesized.
int neorv32_twi_busy | ( | void | ) |
Check if TWI is busy (TWI bus engine busy or TX FIFO not empty).
void neorv32_twi_disable | ( | void | ) |
Disable TWI controller.
void neorv32_twi_enable | ( | void | ) |
Enable TWI controller.
void neorv32_twi_generate_start | ( | void | ) |
Generate START (or REPEATED-START) condition.
void neorv32_twi_generate_start_nonblocking | ( | void | ) |
Generate START (or REPEATED-START) condition.
void neorv32_twi_generate_stop | ( | void | ) |
Generate STOP condition.
void neorv32_twi_generate_stop_nonblocking | ( | void | ) |
Generate STOP condition.
int neorv32_twi_get | ( | uint8_t * | data | ) |
Get received data + ACK/NACH from RX FIFO.
[in,out] | data | Pointer for returned data (uint8_t). |
int neorv32_twi_get_fifo_depth | ( | void | ) |
Get TWI FIFO depth.
void neorv32_twi_send_nonblocking | ( | uint8_t | data, |
int | mack ) |
Send data byte (RX can be read via neorv32_twi_get()).
[in] | data | Data byte to be send. |
[in] | mack | Generate ACK by host controller when set. |
void neorv32_twi_setup | ( | int | prsc, |
int | cdiv, | ||
int | clkstr ) |
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). |
[in] | clkstr | Enable (allow) clock stretching. |
int neorv32_twi_trans | ( | uint8_t * | data, |
int | mack ) |
TWI transfer: send data byte and also receive data byte.
[in,out] | data | Pointer for TX/RX data (uint8_t). |
[in] | mack | Generate ACK by host controller when set. |