Paparazzi UAS  v5.4.2_stable-3-gc351a71
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
I2C Interface
+ Collaboration diagram for I2C Interface:

Data Structures

struct  i2c_transaction
 I2C transaction structure. More...
 
struct  i2c_periph
 I2C peripheral structure. More...
 
struct  i2c_errors
 I2C errors counter. More...
 

Macros

#define I2C_BUF_LEN   32
 I2C buffer length. More...
 
#define I2C_TRANSACTION_QUEUE_LEN   8
 I2C transaction queue length. More...
 
#define I2C_ZERO_EVENTS(_err)
 
#define ZEROS_ERR_COUNTER(_i2c_err)
 

Enumerations

enum  I2CTransactionType { I2CTransTx, I2CTransRx, I2CTransTxRx }
 I2C transaction type. More...
 
enum  I2CTransactionStatus {
  I2CTransPending, I2CTransRunning, I2CTransSuccess, I2CTransFailed,
  I2CTransDone
}
 I2C transaction status. More...
 
enum  I2CStatus {
  I2CIdle, I2CStartRequested, I2CAddrWrSent, I2CAddrRdSent,
  I2CSendingByte, I2CReadingByte, I2CReadingLastByte, I2CStopRequested,
  I2CRestartRequested, I2CComplete, I2CFailed
}
 I2C peripheral status. More...
 

Functions

void i2c_init (struct i2c_periph *p)
 Initialize I2C peripheral. More...
 
bool_t i2c_idle (struct i2c_periph *p)
 Check if I2C bus is idle. More...
 
bool_t i2c_submit (struct i2c_periph *p, struct i2c_transaction *t)
 Submit a I2C transaction. More...
 
void i2c_setbitrate (struct i2c_periph *p, int bitrate)
 Set I2C bitrate. More...
 
void i2c_event (void)
 
bool_t i2c_transmit (struct i2c_periph *p, struct i2c_transaction *t, uint8_t s_addr, uint8_t len)
 Submit a write only transaction. More...
 
bool_t i2c_receive (struct i2c_periph *p, struct i2c_transaction *t, uint8_t s_addr, uint16_t len)
 Submit a read only transaction. More...
 
bool_t i2c_transceive (struct i2c_periph *p, struct i2c_transaction *t, uint8_t s_addr, uint8_t len_w, uint16_t len_r)
 Submit a write/read transaction. More...
 

Detailed Description

Macro Definition Documentation

#define I2C_BUF_LEN   32

I2C buffer length.

Number of bytes a transaction can hold.

Definition at line 84 of file i2c.h.

#define I2C_TRANSACTION_QUEUE_LEN   8

I2C transaction queue length.

Number of transactions that can be queued.

Definition at line 133 of file i2c.h.

Referenced by i2c_irq(), i2c_submit(), and I2cEndOfTransaction().

#define I2C_ZERO_EVENTS (   _err)
Value:
{ \
_err.irq_cnt = 0; \
memset((void*)_err.event_chain, 0, sizeof(_err.event_chain)); \
memset((void*)_err.status_chain, 0, sizeof(_err.status_chain)); \
}

Definition at line 173 of file i2c.h.

#define ZEROS_ERR_COUNTER (   _i2c_err)
Value:
{ \
_i2c_err.queue_full_cnt = 0; \
_i2c_err.ack_fail_cnt = 0; \
_i2c_err.miss_start_stop_cnt = 0; \
_i2c_err.arb_lost_cnt = 0; \
_i2c_err.over_under_cnt = 0; \
_i2c_err.pec_recep_cnt = 0; \
_i2c_err.timeout_tlow_cnt = 0; \
_i2c_err.smbus_alert_cnt = 0; \
_i2c_err.unexpected_event_cnt = 0; \
_i2c_err.last_unexpected_event = 0; \
_i2c_err.er_irq_cnt = 0; \
}

Definition at line 179 of file i2c.h.

Enumeration Type Documentation

enum I2CStatus

I2C peripheral status.

Used by each architecture specifc implementation.

Enumerator
I2CIdle 
I2CStartRequested 
I2CAddrWrSent 
I2CAddrRdSent 
I2CSendingByte 
I2CReadingByte 
I2CReadingLastByte 
I2CStopRequested 
I2CRestartRequested 
I2CComplete 
I2CFailed 

Definition at line 65 of file i2c.h.

I2C transaction status.

Enumerator
I2CTransPending 

transaction is pending in queue

I2CTransRunning 

transaction is currently ongoing

I2CTransSuccess 

transaction successfully finished by I2C driver

I2CTransFailed 

transaction failed

I2CTransDone 

transaction set to done by user level

Definition at line 54 of file i2c.h.

I2C transaction type.

Enumerator
I2CTransTx 

transmit only transaction

I2CTransRx 

receive only transaction

I2CTransTxRx 

transmit and receive transaction

Definition at line 46 of file i2c.h.

Function Documentation

void i2c_event ( void  )

Definition at line 36 of file i2c_arch.c.

References SysTimeTimer, and SysTimeTimerStart.

Referenced by event_task_ap(), event_task_fbw(), and main_event().

+ Here is the caller graph for this function:

bool_t i2c_idle ( struct i2c_periph p)

Check if I2C bus is idle.

Parameters
pi2c peripheral to be used
Returns
TRUE if idle

Definition at line 44 of file i2c_arch.c.

References BIT_X_IS_SET_IN_REG, FALSE, I2CIdle, if(), i2c_periph::reg_addr, i2c_periph::status, and TRUE.

Referenced by baro_periodic(), event_i2c_abuse_test(), hmc5843_idle_task(), hmc5843_periodic(), and i2c_setbitrate().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void i2c_init ( struct i2c_periph p)

Initialize I2C peripheral.

Definition at line 237 of file i2c.c.

References DefaultPeriodic, I2CIdle, register_periodic_telemetry(), i2c_periph::status, i2c_periph::trans_extract_idx, and i2c_periph::trans_insert_idx.

+ Here is the call graph for this function:

bool_t i2c_receive ( struct i2c_periph p,
struct i2c_transaction t,
uint8_t  s_addr,
uint16_t  len 
)

Submit a read only transaction.

Convenience function which is usually preferred over i2c_submit, as it explicitly sets the transaction type again.

Parameters
pi2c peripheral to be used
ti2c transaction
s_addrslave address
lennumber of bytes to receive
Returns
TRUE if insertion to the transaction queue succeded

Definition at line 260 of file i2c.c.

References i2c_submit(), I2CTransRx, i2c_transaction::len_r, i2c_transaction::len_w, i2c_transaction::slave_addr, and i2c_transaction::type.

Referenced by airspeed_amsys_read_periodic(), airspeed_ets_read_periodic(), ArduIMU_periodic(), baro_amsys_read_periodic(), baro_ets_read_periodic(), baro_hca_read_periodic(), charge_sens_periodic(), dpicco_periodic(), dust_gp2y_periodic(), ezcurrent_read_periodic(), geiger_counter_periodic(), humid_htm_read(), humid_sht_p_humid(), humid_sht_p_temp(), infrared_i2c_hor_event(), infrared_i2c_update(), MPPT_periodic(), ms45xx_i2c_periodic(), srf08_read(), temod_periodic(), and wind_gfi_event().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void i2c_setbitrate ( struct i2c_periph p,
int  bitrate 
)

Set I2C bitrate.

Parameters
pi2c peripheral to be used
bitratebitrate

Definition at line 40 of file i2c_arch.c.

References __disable_irq(), __enable_irq(), i2c_idle(), if(), LED1_OFF(), LED1_ON(), LED2_OFF(), LED2_ON(), and i2c_periph::reg_addr.

Referenced by event_i2c_abuse_test().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool_t i2c_submit ( struct i2c_periph p,
struct i2c_transaction t 
)

Submit a I2C transaction.

Must be implemented by the underlying architecture

Parameters
pi2c peripheral to be used
ti2c transaction
Returns
TRUE if insertion to the transaction queue succeded

Definition at line 51 of file i2c_arch.c.

References __disable_irq(), __enable_irq(), i2c_transaction::buf, disableIRQ(), enableIRQ(), i2c_periph::errors, FALSE, I2C_SLAVE, I2C_TRANSACTION_QUEUE_LEN, I2CIdle, I2cSendStart(), I2CTransFailed, I2CTransPending, I2CTransRx, I2CTransSuccess, I2CTransTx, I2CTransTxRx, LED2_OFF(), LED2_ON(), i2c_transaction::len_r, i2c_transaction::len_w, PPRZ_I2C_SEND_START(), i2c_errors::queue_full_cnt, i2c_periph::reg_addr, i2c_transaction::slave_addr, i2c_transaction::status, i2c_periph::status, i2c_periph::trans, i2c_periph::trans_extract_idx, i2c_periph::trans_insert_idx, TRUE, and i2c_transaction::type.

Referenced by actuators_asctec_v2_set(), actuators_mkk_v2_set(), actuators_skiron_set(), adxl345_i2c_read(), adxl345_i2c_tx_reg(), ami601_read(), baro_board_read_from_current_register(), baro_board_read_from_register(), baro_board_send_reset(), baro_board_set_current_register(), baro_board_write_to_register(), config_mkk_v2_read_eeprom(), config_mkk_v2_send_eeprom(), event_i2c_abuse_test(), hmc5843_idle_task(), hmc5843_periodic(), hmc58xx_i2c_tx_reg(), hmc58xx_read(), i2c_abuse_send_transaction(), i2c_receive(), i2c_transceive(), i2c_transmit(), itg3200_i2c_tx_reg(), itg3200_read(), lsm303dlhc_i2c_tx_reg(), lsm303dlhc_read(), and send_config().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool_t i2c_transceive ( struct i2c_periph p,
struct i2c_transaction t,
uint8_t  s_addr,
uint8_t  len_w,
uint16_t  len_r 
)

Submit a write/read transaction.

Convenience function which is usually preferred over i2c_submit, as it explicitly sets the transaction type again.

Parameters
pi2c peripheral to be used
ti2c transaction
s_addrslave address
len_wnumber of bytes to transmit
len_rnumber of bytes to receive
Returns
TRUE if insertion to the transaction queue succeded

Definition at line 270 of file i2c.c.

References i2c_submit(), I2CTransTxRx, i2c_transaction::len_r, i2c_transaction::len_w, i2c_transaction::slave_addr, and i2c_transaction::type.

Referenced by actuators_bebop_commit(), ads1114_read(), ak8963_event(), ak8963_read(), atmega_i2c_cam_ctrl_send(), baro_scp_event(), baro_scp_periodic(), bmp085_periodic(), bmp085_read_eeprom_calib(), humid_sht_event_i2c(), humid_sht_periodic_i2c(), imu_periodic(), ir_mlx_event(), ir_mlx_periodic(), l3g4200_read(), lm75_periodic(), mpl3115_read(), mpu60x0_i2c_read(), mpu9250_i2c_read(), ms5611_i2c_event(), ms5611_i2c_periodic_check(), pbn_periodic(), pcap01readRegister(), readPCAP01_SRAM(), srf08_read_register(), and tmp102_periodic().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool_t i2c_transmit ( struct i2c_periph p,
struct i2c_transaction t,
uint8_t  s_addr,
uint8_t  len 
)