Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
i2c_arch.c File Reference

Interface from Paparazzi I2C to ChibiOS I2C driver. More...

#include "mcu_periph/i2c_arch.h"
#include "mcu_periph/i2c.h"
#include <BOARD_CONFIG>
#include <ch.h>
#include <hal.h>
#include "mcu_periph/ram_arch.h"
#include "string.h"
+ Include dependency graph for i2c_arch.c:

Go to the source code of this file.

Macros

#define I2C_THREAD_STACK_SIZE   512
 

Functions

static bool i2c_chibios_idle (struct i2c_periph *p)
 i2c_idle() function More...
 
static bool i2c_chibios_submit (struct i2c_periph *p, struct i2c_transaction *t)
 i2c_submit() function More...
 
static void i2c_chibios_setbitrate (struct i2c_periph *p, int bitrate)
 i2c_setbitrate() function More...
 
void i2c_event (void)
 i2c_event() function More...
 

Detailed Description

Interface from Paparazzi I2C to ChibiOS I2C driver.

I2C configuration files are defined in the board file, so the maximal architecture independence is ensured.

Definition in file i2c_arch.c.

Macro Definition Documentation

◆ I2C_THREAD_STACK_SIZE

#define I2C_THREAD_STACK_SIZE   512

Definition at line 46 of file i2c_arch.c.

Function Documentation

◆ i2c_chibios_idle()

static bool i2c_chibios_idle ( struct i2c_periph p)
static

i2c_idle() function

Empty, for paparazzi compatibility only

Definition at line 459 of file i2c_arch.c.

References FALSE.

◆ i2c_chibios_setbitrate()

static void i2c_chibios_setbitrate ( struct i2c_periph p,
int  bitrate 
)
static

i2c_setbitrate() function

Empty, for paparazzi compatibility only. Bitrate is already set in i2cX_hw_init()

Definition at line 401 of file i2c_arch.c.

◆ i2c_chibios_submit()

static bool i2c_chibios_submit ( struct i2c_periph p,
struct i2c_transaction t 
)
static

i2c_submit() function

Provides interface between high-level paparazzi i2c functions (such as i2c_transmit(), i2c_transcieve()) and ChibiOS i2c transmit function i2cMasterTransmitTimeout()

Note that we are using the same buffer for transmit and recevive. It is OK because in i2c transaction is Tx always before Rx.

I2C calls are synchronous, timeout is set to 1/PERIODIC_FREQUENCY seconds TODO: Note that on STM32F1xx such as Lia board I2C bus can easily hang in an interrupt (see issue #531). Use I2C bus with care and caution.

Parameters
[in]ppointer to a i2c_periph struct
[in]tpointer to a i2c_transaction struct

Definition at line 420 of file i2c_arch.c.

References FALSE, i2c_init(), I2C_TRANSACTION_QUEUE_LEN, I2CTransFailed, I2CTransPending, p, i2c_transaction::status, and TRUE.

+ Here is the call graph for this function: