44#ifndef SOFTI2C0_DIVIDER
45#define SOFTI2C0_DIVIDER 1
47#ifndef SOFTI2C1_DIVIDER
48#define SOFTI2C1_DIVIDER 1
74#if USE_SOFTI2C0 && ( \
75 !defined(SOFTI2C0_SDA_GPIO) || !defined(SOFTI2C0_SDA_PIN) || \
76 !defined(SOFTI2C0_SCL_GPIO) || !defined(SOFTI2C0_SCL_PIN))
77#error "SDA and SCL pins must be configured for SOFTI2C0!"
80#if USE_SOFTI2C1 && ( \
81 !defined(SOFTI2C1_SDA_GPIO) || !defined(SOFTI2C1_SDA_PIN) || \
82 !defined(SOFTI2C1_SCL_GPIO) || !defined(SOFTI2C1_SCL_PIN))
83#error "SDA and SCL pins must be configured for SOFTI2C1!"
133#if PERIODIC_TELEMETRY
167#if defined(CHIBIOS_MCU_ARCH_H) || defined(STM32_MCU_ARCH_H)
197#ifdef STM32_MCU_ARCH_H
320 default:
return false;
345 default:
return false;
376 default:
return false;
407 default:
return false;
440 default:
return false;
474 default:
return false;
481#pragma GCC diagnostic push
482#pragma GCC diagnostic ignored "-Wcast-qual"
548 byte =
t->slave_addr | 0x01;
603#pragma GCC diagnostic pop
610 if (
p->trans_insert_idx !=
p->trans_extract_idx) {
651 return (
p->status ==
I2CIdle) && (
p->trans_insert_idx ==
p->trans_extract_idx);
658 p->errors->queue_full_cnt++;
664 p->trans[
p->trans_insert_idx] =
t;
void gpio_setup_input_pullup(ioportid_t port, uint16_t gpios)
Setup one or more pins of the given GPIO port as inputs with pull up resistor enabled.
void gpio_setup_output(ioportid_t port, uint16_t gpios)
Setup one or more pins of the given GPIO port as outputs.
void gpio_setup_input(ioportid_t port, uint16_t gpios)
Setup one or more pins of the given GPIO port as inputs.
static void gpio_set(ioportid_t port, uint16_t pin)
Set a gpio output to high level.
static void gpio_clear(ioportid_t port, uint16_t pin)
Clear a gpio output to low level.
ioportid_t gpio_port_t
Abstract gpio port type for hardware independent part.
static uint8_t gpio_get(ioportid_t port, uint16_t pin)
Get level of a gpio.
Some architecture independent helper functions for GPIOs.
struct i2c_errors * errors
volatile uint16_t ack_fail_cnt
#define ZEROS_ERR_COUNTER(_i2c_err)
#define I2C_TRANSACTION_QUEUE_LEN
I2C transaction queue length.
void i2c_init(struct i2c_periph *p)
Initialize I2C peripheral.
@ I2CTransRunning
transaction is currently ongoing
@ I2CTransSuccess
transaction successfully finished by I2C driver
@ I2CTransFailed
transaction failed
@ I2CTransPending
transaction is pending in queue
@ I2CTransRx
receive only transaction
@ I2CTransTxRx
transmit and receive transaction
I2C transaction structure.
static bool softi2c_write_restart(struct softi2c_device *d)
static void softi2c_device_event(struct softi2c_device *d)
static bool softi2c_submit(struct i2c_periph *periph, struct i2c_transaction *t)
static bool softi2c_idle(struct i2c_periph *periph)
static bool softi2c_read_bit(struct softi2c_device *d, bool *bit)
static void softi2c_setbitrate(struct i2c_periph *periph, int bitrate)
static void softi2c_gpio_drive_low(gpio_port_t port, uint16_t pin)
static void softi2c_gpio_highz(gpio_port_t port, uint16_t pin)
struct i2c_periph * periph
static bool softi2c_gpio_read(gpio_port_t port, uint16_t pin)
static bool softi2c_write_byte(struct softi2c_device *d, uint8_t byte, bool *ack)
static void softi2c_setup_gpio(gpio_port_t sda_port, uint16_t sda_pin, gpio_port_t scl_port, uint16_t scl_pin)
static bool softi2c_write_bit(struct softi2c_device *d, bool bit)
static bool softi2c_process_transaction(struct softi2c_device *d, struct i2c_transaction *t)
static bool softi2c_write_start(struct softi2c_device *d)
static bool softi2c_write_stop(struct softi2c_device *d)
static void softi2c_spin(struct i2c_periph *p)
static bool softi2c_read_byte(struct softi2c_device *d, uint8_t *byte, bool ack)
Platform-independent software I2C implementation.
void gpio_enable_clock(uint32_t port)
Enable the relevant clock.
static const struct usb_device_descriptor dev
Architecture independent timing functions.
Periodic telemetry system header (includes downlink utility and generated code).
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.