TMPM4G9  V1.0.0.0
bsp_i2c.c File Reference

This file provides API functions for BSP I2C driver. More...

#include "bsp_i2c.h"

Data Structures

struct  i2c_irq_t
 For IRQn_Type number definition. More...
 

Macros

#define I2CxSR_AL   ((uint32_t)0x00000008)
 
#define I2C_CH0   (0)
 
#define I2C_CH1   (1)
 
#define I2C_CH2   (2)
 
#define I2C_CH3   (3)
 
#define I2C_CH4   (4)
 
#define I2C_CH_NUM   (5)
 
Parameter Result

Whether the parameter is specified or not.

#define I2C_PARAM_OK   ((int32_t)1)
 
#define I2C_PARAM_NG   ((int32_t)0)
 
timeout

This timeouts are not based on accurate values, this just guarantee that the application will not remain stuck if the I2C communication is corrupted.

#define I2C_TIMEOUT   (100000) /*>! fail safe. */
 

Enumerations

enum  { I2C_TRANSFER_STATE_IDLE = 0U, I2C_TRANSFER_STATE_BUSY }
 Transfer State. More...
 

Functions

__STATIC_INLINE void enable_irq (uint32_t irqn)
 Enable I2C IRQ. More...
 
__STATIC_INLINE void disable_irq (uint32_t irqn)
 Disable I2C IRQ. More...
 
__STATIC_INLINE void clear_irq (uint32_t irqn)
 ClearPending I2C IRQ. More...
 
__STATIC_INLINE void set_port_ch0 (i2c_port_t sda, i2c_port_t scl)
 I2C Port Setting (PG2, PG3) More...
 
__STATIC_INLINE void set_port_ch1 (i2c_port_t sda, i2c_port_t scl)
 I2C Port Setting (PF2, PF3) More...
 
__STATIC_INLINE void set_port_ch2 (i2c_port_t sda, i2c_port_t scl)
 I2C Port Setting (PG4, PG5) More...
 
__STATIC_INLINE uint32_t set_i2c (uint8_t ch, uint32_t *p_irqn)
 I2C Setting. More...
 
__STATIC_INLINE void reset_asynch (i2c_t *p_obj)
 Reset Asynch Transfer. More...
 
__STATIC_INLINE int32_t wait_status (i2c_t *p_obj)
 Waiting i2c status. More...
 
__STATIC_INLINE int32_t I2C_status_arbitration (I2C_t *p_obj)
 
void i2c_enable_irq (i2c_t *p_obj)
 Enable I2C IRQ. More...
 
void i2c_disable_irq (i2c_t *p_obj)
 Disable I2C IRQ. More...
 
TXZ_Result i2c_init (i2c_t *p_obj, i2c_port_t sda, i2c_port_t scl)
 Initialize the I2C Driver. More...
 
void i2c_reset (i2c_t *p_obj)
 Reset I2C peripheral. More...
 
TXZ_Result i2c_frequency (i2c_t *p_obj, int32_t hz)
 Configure the I2C frequency. More...
 
TXZ_Result i2c_check_bus_free (i2c_t *p_obj)
 Check bus free on the I2C bus. More...
 
TXZ_Result i2c_start (i2c_t *p_obj)
 Creates a start condition on the I2C bus. More...
 
TXZ_Result i2c_stop (i2c_t *p_obj)
 Creates a stop condition on the I2C bus. More...
 
int32_t i2c_read (i2c_t *p_obj, int32_t address, uint8_t *p_data, int32_t length, int32_t stop)
 Blocking reading data. More...
 
int32_t i2c_write (i2c_t *p_obj, int32_t address, uint8_t *p_data, int32_t length, int32_t stop)
 Blocking sending data. More...
 
int32_t i2c_byte_read (i2c_t *p_obj, int32_t last)
 Read one byte. More...
 
int32_t i2c_byte_write (i2c_t *p_obj, int32_t data)
 Write one byte. More...
 
uint8_t i2c_active (i2c_t *p_obj)
 Attempts to determine if the I2C bus is already in use. More...
 
TXZ_Result i2c_transfer_asynch (i2c_t *p_obj, uint8_t *p_tx, int32_t tx_length, uint8_t *p_rx, int32_t rx_length, int32_t address, int32_t stop)
 Start I2C asynchronous transfer. More...
 
uint32_t i2c_irq_handler_asynch (i2c_t *p_obj)
 The asynchronous IRQ handler. More...
 
void i2c_abort_asynch (i2c_t *p_obj)
 Abort asynchronous transfer. More...
 
void i2c_slave_mode (i2c_t *p_obj, int32_t enable_slave)
 Configure I2C as slave or master. More...
 
int32_t i2c_slave_receive (i2c_t *p_obj)
 Check to see if the I2C slave has been addressed. More...
 
int32_t i2c_slave_read (i2c_t *p_obj, uint8_t *p_data, int32_t length)
 Blocking reading data. More...
 
int32_t i2c_slave_write (i2c_t *p_obj, uint8_t *p_data, int32_t length)
 Blocking sending data. More...
 
void i2c_slave_address (i2c_t *p_obj, uint32_t address)
 Configure I2C slave address. More...
 
TXZ_Result i2c_slave_transfer_asynch (i2c_t *p_obj, uint8_t *p_tx, int32_t tx_length, uint8_t *p_rx, int32_t rx_length)
 Start I2C asynchronous transfer. More...
 
uint32_t i2c_slave_irq_handler_asynch (i2c_t *p_obj)
 The asynchronous IRQ handler. More...
 
void i2c_slave_abort_asynch (i2c_t *p_obj)
 Abort asynchronous transfer. More...
 

Variables

enum { ... }  TransferState
 Transfer State. More...
 

Detailed Description

This file provides API functions for BSP I2C driver.

Version
V1.0.0.2
Date
2018-04-04

DO NOT USE THIS SOFTWARE WITHOUT THE SOFTWARE LISENSE AGREEMENT.

Copyright(C) Toshiba Electronic Device Solutions Corporation 2019