FD32M0P Microcontroller SDK
|
Data Structures | |
struct | i2c_counter_cfg_t |
I2C Counter Configuration struct. More... | |
struct | i2c_slv_cfg_t |
I2C Configuration in Slave Mode. More... | |
struct | i2c_slv_sts_t |
I2C Slave status register struct. More... |
Macros | |
#define | I2C_COUNTER_CFG_DEFAULT_100Khz |
Default Values for I2C Counter Configurations. | |
#define | I2C_SLAVE_CFG_DEFAULT |
Default Values for I2C Slave Configurations. |
Functions | |
void | i2c_clk_cfg_set (I2C_REGS_s *regs, I2C_CLK_CTRL_CLKSEL_E clksel, uint8_t clkdiv) |
This function updates the clock settings used in I2C. | |
void | i2c_mst_enable (I2C_REGS_s *regs) |
This function enables I2C master. | |
void | i2c_slv_enable (I2C_REGS_s *regs) |
This function enables I2C slave. | |
void | i2c_mst_disable (I2C_REGS_s *regs) |
This function disables I2C master. | |
void | i2c_slv_disable (I2C_REGS_s *regs) |
This function disables I2C slave. | |
void | i2c_counter_cfg_set (I2C_REGS_s *regs, i2c_counter_cfg_t *i2c_counter_cfg) |
This function configures the counter config register required for I2C Master/Slave. | |
void | i2c_slv_cfg_set (I2C_REGS_s *regs, i2c_slv_cfg_t *i2c_slv_cfg) |
This function configures I2C slave. | |
void | i2c_glitch_width_cfg_set (I2C_REGS_s *regs, uint8_t glitch_width) |
This function sets the glitch width for the glitch filter. | |
uint8_t | i2c_txfifo_fill_nonblocking (I2C_REGS_s *regs, const uint8_t *buffer, uint8_t num_bytes) |
This function pushes bytes into TX FIFO (Non-blocking) | |
void | i2c_txfifo_fill_blocking (I2C_REGS_s *regs, const uint8_t *buffer, uint8_t num_bytes) |
This function pushes bytes into TX FIFO (Blocking) | |
uint8_t | i2c_rxfifo_drain_nonblocking (I2C_REGS_s *regs, uint8_t *buffer, uint8_t num_bytes) |
This function pops bytes from the RX FIFO (Non-blocking) | |
void | i2c_rxfifo_drain_blocking (I2C_REGS_s *regs, uint8_t *buffer, uint8_t num_bytes) |
This function pops bytes from the RX FIFO (Blocking) | |
bool | i2c_slv_rd_wr_sts_get (I2C_REGS_s *regs) |
This function reads the status register which contains wheather the slave is in read or write mode. | |
void | i2c_slv_sts_get (I2C_REGS_s *regs, i2c_slv_sts_t *i2c_slv_sts) |
This function reads all the status registers related to I2C Slave. | |
void | i2c_wait_for_slv_start (I2C_REGS_s *regs) |
This function is blocking. It waits until I2C slave recieves a start from the Master. | |
void | i2c_wait_for_rx_done (I2C_REGS_s *regs) |
This function is blocking. It waits until I2C slave recieves a byte from the Master. | |
void | i2c_wait_for_tx_done (I2C_REGS_s *regs) |
This function is blocking. It waits until I2C slave sends a byte to the Master. | |
void | i2c_wait_for_slv_stop (I2C_REGS_s *regs) |
This function polls stop bit sent by the master. | |
void | i2c_slv_ackval (I2C_REGS_s *regs, I2C_SLAVE_BYTE_ACK_SLV_ACKVAL_E ackval) |
This function controls whether the slave sends a ACK or a NACK. |
struct i2c_counter_cfg_t |
I2C Counter Configuration struct.
struct i2c_slv_cfg_t |
I2C Configuration in Slave Mode.
Data Fields | ||
---|---|---|
I2C_SLAVE_CTRL_SLV_ADDR_MODE_E | slv_addr_mode | |
bool | slv_low_pwr_wakeup_en | |
bool | slv_def_dev_addr_en | |
bool | slv_alres_addr_en | |
bool | slv_def_host_addr_en | |
bool | slv_txtrig_at_txmode | |
bool | slv_clkstretch_en | |
bool | slv_gencall_en | |
bool | slv_addr2_en | |
uint8_t | slv_addr2_mask | |
I2C_SLAVE_CTRL_SLV_TXWAIT_STALE_FIFO_E | slv_txwait_stale_fifo | |
I2C_SLAVE_CTRL_SLV_TXEMPTY_INTR_ON_TX_REQ_E | slv_txempty_intr_on_tx_req | |
uint16_t | slv_addr1 | |
uint16_t | slv_addr2 | |
bool | slv_auto_ack_en | |
bool | slv_addr_auto_ack_en | |
bool | i2c_pec_en | |
bool | rxfifo_en | |
bool | txfifo_en |
struct i2c_slv_sts_t |
#define I2C_COUNTER_CFG_DEFAULT_100Khz |
Default Values for I2C Counter Configurations.
#define I2C_SLAVE_CFG_DEFAULT |
Default Values for I2C Slave Configurations.
void i2c_clk_cfg_set | ( | I2C_REGS_s * | regs, |
I2C_CLK_CTRL_CLKSEL_E | clksel, | ||
uint8_t | clkdiv ) |
This function updates the clock settings used in I2C.
regs | : pointer to the i2c register space |
clksel | : Enum for i2c clock select |
clkdiv | : Value for the clock divider |
void |
References I2C_REGS_s::CLK_CTRL.
void i2c_mst_enable | ( | I2C_REGS_s * | regs | ) |
This function enables I2C master.
regs | : pointer to the i2c register space |
void |
References I2C_REGS_s::MASTER_CFG.
void i2c_slv_enable | ( | I2C_REGS_s * | regs | ) |
This function enables I2C slave.
regs | : pointer to the i2c register space |
void |
References I2C_REGS_s::SLAVE_CTRL.
void i2c_mst_disable | ( | I2C_REGS_s * | regs | ) |
This function disables I2C master.
regs | : pointer to the i2c register space |
void |
References I2C_REGS_s::MASTER_CFG.
void i2c_slv_disable | ( | I2C_REGS_s * | regs | ) |
This function disables I2C slave.
regs | : pointer to the i2c register space |
void |
References I2C_REGS_s::SLAVE_CTRL.
void i2c_counter_cfg_set | ( | I2C_REGS_s * | regs, |
i2c_counter_cfg_t * | i2c_counter_cfg ) |
This function configures the counter config register required for I2C Master/Slave.
regs | : pointer to the i2c register space |
i2c_counter_cfg | : pointer to the struct containing i2c counter config |
void |
References I2C_REGS_s::CLK_CTRL, I2C_REGS_s::MASTER_CLKSTRETCH_CNT, I2C_REGS_s::MASTER_SCL_GEN, I2C_REGS_s::MASTER_TIMING_CONSTRAINT, i2c_counter_cfg_t::mst_max_clkstretch_cnt, i2c_counter_cfg_t::mst_restart_setup_cnt, i2c_counter_cfg_t::mst_scl_cnt_high_val, i2c_counter_cfg_t::mst_scl_cnt_low_val, i2c_counter_cfg_t::mst_scl_start_cnt, i2c_counter_cfg_t::mst_sda_stop_cnt, i2c_counter_cfg_t::mst_stop_start_buffer_cnt, i2c_counter_cfg_t::setup_cnt, I2C_REGS_s::SLAVE_CLKSTRETCH_CNT, i2c_counter_cfg_t::slv_max_clkstretch_cnt, I2C_REGS_s::SMBUS_TIMEOUT_CNT, and i2c_counter_cfg_t::smbus_timeout_cnt.
void i2c_slv_cfg_set | ( | I2C_REGS_s * | regs, |
i2c_slv_cfg_t * | i2c_slv_cfg ) |
This function configures I2C slave.
regs | : pointer to the i2c register space |
i2c_slv_cfg | : pointer to the struct containing i2c slave config |
void |
References I2C_REGS_s::FIFO_CTRL, i2c_slv_cfg_t::i2c_pec_en, I2C_REGS_s::PEC_CTRL, i2c_slv_cfg_t::rxfifo_en, I2C_REGS_s::SLAVE_ACK_CFG, I2C_REGS_s::SLAVE_ADDR, I2C_REGS_s::SLAVE_CTRL, i2c_slv_cfg_t::slv_addr1, i2c_slv_cfg_t::slv_addr2, i2c_slv_cfg_t::slv_addr2_en, i2c_slv_cfg_t::slv_addr2_mask, i2c_slv_cfg_t::slv_addr_auto_ack_en, i2c_slv_cfg_t::slv_addr_mode, i2c_slv_cfg_t::slv_alres_addr_en, i2c_slv_cfg_t::slv_auto_ack_en, i2c_slv_cfg_t::slv_clkstretch_en, i2c_slv_cfg_t::slv_def_dev_addr_en, i2c_slv_cfg_t::slv_def_host_addr_en, i2c_slv_cfg_t::slv_gencall_en, i2c_slv_cfg_t::slv_low_pwr_wakeup_en, i2c_slv_cfg_t::slv_txempty_intr_on_tx_req, i2c_slv_cfg_t::slv_txtrig_at_txmode, i2c_slv_cfg_t::slv_txwait_stale_fifo, and i2c_slv_cfg_t::txfifo_en.
void i2c_glitch_width_cfg_set | ( | I2C_REGS_s * | regs, |
uint8_t | glitch_width ) |
This function sets the glitch width for the glitch filter.
regs | : pointer to the i2c register space |
glitch_width | : glitch width value to be programmed |
void |
References I2C_REGS_s::GLITCH_FILTER_CFG.
uint8_t i2c_txfifo_fill_nonblocking | ( | I2C_REGS_s * | regs, |
const uint8_t * | buffer, | ||
uint8_t | num_bytes ) |
This function pushes bytes into TX FIFO (Non-blocking)
regs | : pointer to the i2c register space |
buffer | : pointer to the buffer space containing the data to pushed into the tx fifo |
num_bytes | : number of bytes to be written into the tx fifo |
The | number of bytes written into the TX FIFO |
References I2C_REGS_s::FIFO_STS, I2C_TXDATA_u::packed_byte, and I2C_REGS_s::TXDATA.
void i2c_txfifo_fill_blocking | ( | I2C_REGS_s * | regs, |
const uint8_t * | buffer, | ||
uint8_t | num_bytes ) |
This function pushes bytes into TX FIFO (Blocking)
regs | : pointer to the i2c register space |
buffer | : pointer to the buffer space containing the data to pushed into the tx fifo |
num_bytes | : number of bytes to be written into the tx fifo |
void |
References I2C_REGS_s::FIFO_STS, I2C_TXDATA_u::packed_byte, and I2C_REGS_s::TXDATA.
uint8_t i2c_rxfifo_drain_nonblocking | ( | I2C_REGS_s * | regs, |
uint8_t * | buffer, | ||
uint8_t | num_bytes ) |
This function pops bytes from the RX FIFO (Non-blocking)
regs | : pointer to the i2c register space |
buffer | : pointer to the buffer space containing the data to be copied to from the RX FIFO |
num_bytes | : number of bytes to be written into the tx fifo |
The | number of bytes read from the RX FIFO |
References I2C_REGS_s::FIFO_STS, I2C_RXDATA_u::packed_byte, and I2C_REGS_s::RXDATA.
void i2c_rxfifo_drain_blocking | ( | I2C_REGS_s * | regs, |
uint8_t * | buffer, | ||
uint8_t | num_bytes ) |
This function pops bytes from the RX FIFO (Blocking)
regs | : pointer to the i2c register space |
buffer | : pointer to the buffer space containing the data to be copied to from the RX FIFO |
num_bytes | : number of bytes to be written into the tx fifo |
void |
References I2C_REGS_s::FIFO_STS, I2C_RXDATA_u::packed_byte, and I2C_REGS_s::RXDATA.
bool i2c_slv_rd_wr_sts_get | ( | I2C_REGS_s * | regs | ) |
This function reads the status register which contains wheather the slave is in read or write mode.
regs | : pointer to the i2c register space |
Returns | 0 for write transaction and 1 for read transaction |
References I2C_REGS_s::SPARE_STS.
void i2c_slv_sts_get | ( | I2C_REGS_s * | regs, |
i2c_slv_sts_t * | i2c_slv_sts ) |
This function reads all the status registers related to I2C Slave.
regs | : pointer to the i2c register space |
i2c_slv_sts | : pointer to the struct which will contain the register values read |
void |
References i2c_slv_sts_t::quick_cmd_rw, i2c_slv_sts_t::quick_cmd_sts, I2C_REGS_s::SLAVE_STS, i2c_slv_sts_t::slv_addr2_sel, i2c_slv_sts_t::slv_addr_match, i2c_slv_sts_t::slv_busbsy, i2c_slv_sts_t::slv_rx_req, i2c_slv_sts_t::slv_rxmode, i2c_slv_sts_t::slv_stale_txfifo, i2c_slv_sts_t::slv_tx_req, and i2c_slv_sts_t::slv_txmode.
void i2c_wait_for_slv_start | ( | I2C_REGS_s * | regs | ) |
This function is blocking. It waits until I2C slave recieves a start from the Master.
regs | : pointer to the i2c register space |
void |
References I2C_INTR_EVENT_CLEAR(), I2C_INTR_EVENT_SLV_START_IDX, and I2C_REGS_s::INTR_EVENT.
void i2c_wait_for_rx_done | ( | I2C_REGS_s * | regs | ) |
This function is blocking. It waits until I2C slave recieves a byte from the Master.
regs | : pointer to the i2c register space |
void |
References I2C_INTR_EVENT_CLEAR(), I2C_INTR_EVENT_RX_DONE_IDX, and I2C_REGS_s::INTR_EVENT.
void i2c_wait_for_tx_done | ( | I2C_REGS_s * | regs | ) |
This function is blocking. It waits until I2C slave sends a byte to the Master.
regs | : pointer to the i2c register space |
void |
References I2C_INTR_EVENT_CLEAR(), I2C_INTR_EVENT_TX_DONE_IDX, and I2C_REGS_s::INTR_EVENT.
void i2c_wait_for_slv_stop | ( | I2C_REGS_s * | regs | ) |
This function polls stop bit sent by the master.
regs | : pointer to the i2c register space |
void |
References I2C_INTR_EVENT_CLEAR(), I2C_INTR_EVENT_SLV_STOP_IDX, and I2C_REGS_s::INTR_EVENT.
void i2c_slv_ackval | ( | I2C_REGS_s * | regs, |
I2C_SLAVE_BYTE_ACK_SLV_ACKVAL_E | ackval ) |
This function controls whether the slave sends a ACK or a NACK.
regs | : pointer to the i2c register space |
void |
References I2C_REGS_s::SLAVE_BYTE_ACK.