ESOS32
ESOSOn32-bitProcessors
|
Files | |
file | esos_i2c.c |
Hardware independent support for ESOS32 I2C services. | |
file | esos_hwxxx_i2c.c |
Template for creating hardware-specific support for ESOS32 I2C services. | |
file | esos_hwxxx_i2c.c |
Template for creating hardware-specific support for ESOS32 I2C services. | |
file | esos_stm32l4_i2c.c |
Hardware-specific support for ESOS32 I2C services on the STM32L4xx MCUs (tested on STM32L452RE) | |
file | esos_stm32l4_i2c.c |
Hardware-specific support for ESOS32 I2C services on the STM32L4xx MCUs (tested on STM32L452RE) | |
file | esos_i2c.h |
file | esos_hwxxx_i2c.h |
This file contains template routines which define, configure and allow use of the I2C service on some specific hardware. | |
file | esos_stm32l4_i2c.h |
This file contains routines which define, configure and allow use of the I2C service on the ST Microelectronics STM32L452RE MCU. | |
Macros | |
#define | DEBUG(str) __esos_unsafe_PutString(str) |
#define | ESOS_I2C_ACK 0 |
#define | ESOS_I2C_NAK 1 |
#define | I2C_WADDR(x) (x & 0xFE) |
#define | I2C_RADDR(x) (x | 0x01) |
#define | ESOS_TASK_WAIT_ON_AVAILABLE_I2C() |
#define | ESOS_SIGNAL_AVAILABLE_I2C() |
#define | ESOS_IS_I2C_AVAILABLE() |
#define | ESOS_TASK_WAIT_ON_WRITE1I2C(u8_addr, u8_d1) |
#define | ESOS_TASK_WAIT_ON_WRITE2I2C(u8_addr, u8_d1, u8_d2) |
#define | ESOS_TASK_WAIT_ON_WRITENI2C(u8_addr, pu8_d, u8_cnt) |
#define | ESOS_TASK_WAIT_ON_READ1I2C(u8_addr, u8_d1) |
#define | ESOS_TASK_WAIT_ON_READ2I2C(u8_addr, u8_d1, u8_d2) |
#define | ESOS_TASK_WAIT_ON_READNI2C(u8_addr, pu8_d, u8_cnt) |
#define | CLEAR_REGISTER_BITS(reg, mask) reg &= (~(mask)) |
#define | SET_REGISTER_BITS(reg, mask) reg |= (mask) |
#define | MAKE_I2C_WR_ADDR(bits) bits &= 0xFFE |
#define | MAKE_I2C_RD_ADDR(bits) bits &= 0x001 |
#define | CLEAR_REGISTER_BITS(reg, mask) reg &= (~(mask)) |
#define | SET_REGISTER_BITS(reg, mask) reg |= (mask) |
#define | MAKE_I2C_WR_ADDR(bits) bits &= 0xFFF |
#define | MAKE_I2C_RD_ADDR(bits) bits &= 0x001 |
#define | __ESOS_I2C_STM32L4_SET_WRITE_DIR() I2C1_CR2 &= (~I2C_CR2_RD_WRN) |
#define | __ESOS_I2C_STM32L4_SET_READ_DIR() I2C1_CR2 |= I2C_CR2_RD_WRN |
#define | __ESOS_I2C_STM32L4_SET_NUM_BYTES(x) I2C1_CR2 = (I2C1_CR2 & ~I2C_CR2_NBYTES_MASK) | (x << I2C_CR2_NBYTES_SHIFT) |
#define | __ESOS_I2C_STM32L4_SET_ADDR7_MODE() I2C1_CR2 &= (~I2C_CR2_ADD10) |
#define | __ESOS_I2C_STM32L4_SET_ADDR10_MODE() I2C1_CR2 |= I2C_CR2_ADD10 |
#define | __ESOS_I2C_STM32L4_SET_ADDR7(x) I2C1_CR2 = (I2C1_CR2 & ~I2C_CR2_SADD_7BIT_MASK) | ((x & 0x7F) << I2C_CR2_SADD_7BIT_SHIFT) |
#define | __ESOS_I2C_STM32L4_SET_AUTOEND() I2C1_CR2 |= I2C_CR2_AUTOEND |
#define | __ESOS_I2C_STM32L4_CLEAR_AUTOEND() I2C1_CR2 &= (~I2C_CR2_AUTOEND) |
#define | __ESOS_I2C_STM32L4_SET_RELOAD() I2C1_CR2 |= I2C_CR2_RELOAD |
#define | __ESOS_I2C_STM32L4_CLEAR_RELOAD() I2C1_CR2 &= (~I2C_CR2_RELOAD) |
#define | __ESOS_I2C_STM32L4_IS_NACK_RECEIVED() (I2C1_ISR & I2C_ISR_NACKF) |
#define | __ESOS_I2C_STM32L4_CLEAR_STOP_FLAG() I2C1_ICR |= I2C_ICR_STOPCF |
#define | __ESOS_I2C_STM32L4_RESET_CR2() I2C1_CR2 &= (uint32_t)~((uint32_t)(I2C_CR2_SADD_7BIT_MASK | I2C_CR2_HEAD10R | I2C_CR2_NBYTES_MASK | I2C_CR2_RELOAD | I2C_CR2_RD_WRN)) |
#define | __ESOS_I2C_STM32L4_IS_BUSY() (I2C1_ISR & I2C_ISR_BUSY) |
#define | __ESOS_I2C_STM32L4_IS_TX_EMPTY() (I2C1_ISR & I2C_ISR_TXIS) |
#define | __ESOS_I2C_STM32L4_IS_RX_NOT_EMPTY() (I2C1_ISR & I2C_ISR_RXNE) |
#define | __ESOS_I2C_HW_START() |
#define | __ESOS_I2C_HW_RSTART() |
#define | __ESOS_I2C_HW_STOP() |
#define | __ESOS_I2C_HW_PUT(byte) |
Functions | |
void | __esos_i2c_config (uint32_t u32_i2cbps) |
void | __esos_i2c_hw_config (uint32_t u32_i2cbps) |
ESOS_CHILD_TASK (__esos_i2c_hw_writeN, uint8_t u8_addr, uint8_t *pu8_d, uint8_t u8_cnt) | |
ESOS_CHILD_TASK (__esos_i2c_hw_readN, uint8_t u8_addr, uint8_t *pu8_d, uint8_t u8_cnt) | |
ESOS_CHILD_TASK (__esos_i2c_hw_writeNReadM, uint8_t u8_addr, uint8_t *pu8_wd, uint8_t u8_wcnt, uint8_t *pu8_rd, uint8_t u8_rcnt) | |
ESOS_CHILD_TASK (__esos_hw_getI2C, uint8_t *pu8_x, uint8_t u8_ack2Send) | |
ESOS_CHILD_TASK (__esos_i2c_hw_writeN, uint8_t u8_addr, uint8_t *pu8_d, uint_t u8_cnt) | |
ESOS_CHILD_TASK (__esos_hw_getI2C1, uint8_t *pu8_x, uint8_t u8_ack2Send) | |
ESOS_CHILD_TASK (__esos_hw_writeNI2C1, uint8_t u8_addr, uint8_t *pu8_d, uint16_t u16_cnt) | |
ESOS_CHILD_TASK (__esos_hw_readNI2C1, uint8_t u8_addr, uint8_t *pu8_d, uint16_t u16_cnt) | |
Variables | |
struct stTask | __stChildTaskI2C |
uint8_t | __esos_i2c_dataBytes [2] |
struct stTask __stChildTaskI2C | __stGrandChildTaskI2C |
uint8_t | __esos_i2c_dataBytes [2] |
struct stTask __stChildTaskI2C | __stGrandChildTaskI2C |
uint8_t | __esos_i2c_dataBytes [2] |
struct stTask __stChildTaskI2C | __stGrandChildTaskI2C |
uint8_t | __esos_i2c_dataBytes [2] |
struct stTask __stChildTaskI2C | __stGrandChildTaskI2C |
uint8_t | __esos_i2c_dataBytes [2] |
#define __ESOS_I2C_HW_PUT | ( | byte | ) |
Definition at line 112 of file esos_stm32l4_i2c.h.
#define __ESOS_I2C_HW_RSTART | ( | ) |
Definition at line 100 of file esos_stm32l4_i2c.h.
#define __ESOS_I2C_HW_START | ( | ) |
Definition at line 94 of file esos_stm32l4_i2c.h.
#define __ESOS_I2C_HW_STOP | ( | ) |
Definition at line 106 of file esos_stm32l4_i2c.h.
#define ESOS_IS_I2C_AVAILABLE | ( | ) |
Returns TRUE if the ESOS I2C resource is available, else returns FALSE.
TRUE | ESOS I2C is not in use; available |
Definition at line 95 of file esos_i2c.h.
#define ESOS_SIGNAL_AVAILABLE_I2C | ( | ) |
Release ESOS I2C resource for use by other task.
Definition at line 83 of file esos_i2c.h.
#define ESOS_TASK_WAIT_ON_AVAILABLE_I2C | ( | ) |
Current task waits until the ESOS I2C resource becomes available for use.
Definition at line 67 of file esos_i2c.h.
#define ESOS_TASK_WAIT_ON_READ1I2C | ( | u8_addr, | |
u8_d1 | |||
) |
Transaction: Read 1 (ONE) byte from I2C slave at address u8_addr, and save to variable u8_d1 As per the I2C standard, a NAK is returned for the last byte read from the slave, ACKs are returned for the other bytes.
u8_addr | Slave I2C address |
u8_d1 | variable to hold the read byte |
Definition at line 177 of file esos_i2c.h.
#define ESOS_TASK_WAIT_ON_READ2I2C | ( | u8_addr, | |
u8_d1, | |||
u8_d2 | |||
) |
Transaction: Read 2 (TWO) bytes from I2C slave at address u8_addr, save to variables u8_d1 and u8_d2 As per the I2C standard, a NAK is returned for the last byte read from the slave, ACKs are returned for the other bytes.
u8_addr | Slave I2C address |
u8_d1 | variable to hold first read byte |
u8_d2 | variable to hold second read byte |
Definition at line 198 of file esos_i2c.h.
#define ESOS_TASK_WAIT_ON_READNI2C | ( | u8_addr, | |
pu8_d, | |||
u8_cnt | |||
) |
Transaction: Read u16_cnt bytes from I2C slave at address u8_addr, save to buffer *pu8_d. As per the I2C standard, a NAK is returned for the last byte read from the slave, ACKs are returned for the other bytes.
u8_addr | Slave I2C address |
pu8_d | Pointer to buffer for storing bytes read from slave |
u16_cnt | Number of bytes read from slave. |
Definition at line 218 of file esos_i2c.h.
#define ESOS_TASK_WAIT_ON_WRITE1I2C | ( | u8_addr, | |
u8_d1 | |||
) |
Transaction: Write 1 (ONE) byte stored in variable u8_d1 to I2C slave at address u8_addr.
u8_addr | Slave I2C address |
u8_d1 | Variable containing first byte to write |
Definition at line 116 of file esos_i2c.h.
#define ESOS_TASK_WAIT_ON_WRITE2I2C | ( | u8_addr, | |
u8_d1, | |||
u8_d2 | |||
) |
Transaction: Write 2 (TWO) bytes stored in variables u8_d1 and u8_d2 to I2C slave at address u8_addr.
u8_addr | Slave I2C address |
u8_d1 | Variable containing first byte to write |
u8_d2 | Variable containing second byte to write |
Definition at line 139 of file esos_i2c.h.
#define ESOS_TASK_WAIT_ON_WRITENI2C | ( | u8_addr, | |
pu8_d, | |||
u8_cnt | |||
) |
Transaction: Write u16_cnt bytes stored in buffer *pu8_d to I2C slave at address u8_addr.
u8_addr | Slave I2C address |
pu8_d | Pointer to buffer containing bytes to send |
u16_cnt | Number of bytes to send |
Definition at line 159 of file esos_i2c.h.
void __esos_i2c_config | ( | uint32_t | u32_i2cbps | ) |
Configure and enable the ESOS I2C service for operation at u32_i2cbbps bits per second clock speed.
u32_i2cbps | specifies clock speed in bits per second |
Definition at line 65 of file esos_i2c.c.
void __esos_i2c_hw_config | ( | uint32_t | u32_i2cbps | ) |
Configure and enable the I2C1 module for operation at u32_i2cbps.
u32_i2cbps | specifies clock speed in bits per second |
Configure and enable the I2C1 module for operation at u16_fKHz KHz clock speed.
u16_fKHz | specifies clock speed in KHz |
Definition at line 74 of file esos_hwxxx_i2c.c.
ESOS_CHILD_TASK | ( | __esos_i2c_hw_readN | , |
uint8_t | u8_addr, | ||
uint8_t * | pu8_d, | ||
uint8_t | u8_cnt | ||
) |
Transaction: Read u8_cnt bytes from I2C slave at address u8_addr, save to buffer *pu8_d. As per the I2C standard, a NAK is returned for the last byte read from the slave, ACKs are returned for the other bytes.
u8_addr | Slave I2C address |
pu8_d | Pointer to buffer for storing bytes read from slave |
u8_cnt | Number of bytes read from slave. |
Definition at line 108 of file esos_hwxxx_i2c.c.
ESOS_CHILD_TASK | ( | __esos_i2c_hw_writeN | , |
uint8_t | u8_addr, | ||
uint8_t * | pu8_d, | ||
uint8_t | u8_cnt | ||
) |
Transaction: Write u8_cnt bytes stored in buffer *pu8_d to I2C slave, I2C slave is located at I2C address u8_addr.
u8_addr | Slave I2C address |
pu8_d | Pointer to buffer containing bytes to send |
u8_cnt | Number of bytes to send |
Transaction: Write u8_wcnt bytes stored in buffer *pu8_wd to I2C slave, then read u8_rcnt bytes into buffer *pu8_rd from I2C slave. I2C slave is located at I2C address u8_addr.
u8_addr | Slave I2C address |
pu8_d | Pointer to buffer containing bytes to send |
u16_cnt | Number of bytes to send |
/note Once written, the writeN() and readN() routines can call this routine to do their dirty work Transaction: Write u16_cnt bytes stored in buffer *pu8_d to I2C slave at address u8_addr.
u8_addr | Slave I2C address |
pu8_d | Pointer to buffer containing bytes to send |
u16_cnt | Number of bytes to send |
Definition at line 90 of file esos_hwxxx_i2c.c.
ESOS_CHILD_TASK | ( | __esos_i2c_hw_writeNReadM | , |
uint8_t | u8_addr, | ||
uint8_t * | pu8_wd, | ||
uint8_t | u8_wcnt, | ||
uint8_t * | pu8_rd, | ||
uint8_t | u8_rcnt | ||
) |
Transaction: Write u8_wcnt bytes stored in buffer *pu8_wd to I2C slave, then read u8_rcnt bytes into buffer *pu8_rd from I2C slave. I2C slave is located at I2C address u8_addr.
u8_addr | Slave I2C address |
pu8_d | Pointer to buffer containing bytes to send |
u16_cnt | Number of bytes to send |
\TODO WRITE THIS CHILD TASK __esos_i2c_hw_WriteMReadN
Transaction: Write u8_wcnt bytes stored in buffer *pu8_wd to I2C slave, then read u8_rcnt bytes into buffer *pu8_rd from I2C slave. I2C slave is located at I2C address u8_addr.
u8_addr | Slave I2C address |
pu8_d | Pointer to buffer containing bytes to send |
u16_cnt | Number of bytes to send |
/note Once written, the writeN() and readN() routines can call this routine to do their dirty work Transaction: Write u8_wcnt bytes stored in buffer *pu8_wd to I2C slave at address u8_addr, followed by a read of u8_rcnt bytes into the buffer *pu8_rd
u8_addr | Slave I2C address |
pu8_wd | Pointer to buffer containing bytes to send |
u8_wcnt | Number of bytes to send |
pu8_rd | Pointer to buffer to "catch" bytes read from device |
u8_rcnt | Number of bytes to read |
Definition at line 128 of file esos_hwxxx_i2c.c.