Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpu/stm32/periph/i2c: export PERIPH_I2C_MAX_BYTES_PER_FRAME #19279

Merged
merged 1 commit into from
Feb 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions cpu/stm32/include/periph/cpu_i2c.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,19 @@ static const i2c_timing_param_t timing_params[] = {
CPU_FAM_STM32G0 || CPU_FAM_STM32G4 || CPU_FAM_STM32U5 ||
CPU_FAM_STM32WB || CPU_FAM_STM32WL */

#if defined(CPU_FAM_STM32F0) || defined(CPU_FAM_STM32F3) || \
defined(CPU_FAM_STM32F7) || defined(CPU_FAM_STM32G0) || \
defined(CPU_FAM_STM32G4) || defined(CPU_FAM_STM32L0) || \
defined(CPU_FAM_STM32L4) || defined(CPU_FAM_STM32L5) || \
defined(CPU_FAM_STM32U5) || defined(CPU_FAM_STM32WB) || \
defined(CPU_FAM_STM32WL)
/**
* @brief The I2C implementation supports only a limited frame size.
* See i2c_1.c
*/
#define PERIPH_I2C_MAX_BYTES_PER_FRAME (256U)
#endif

#ifdef __cplusplus
}
#endif
Expand Down
5 changes: 2 additions & 3 deletions cpu/stm32/periph/i2c_1.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
#include "debug.h"

#define TICK_TIMEOUT (0xFFFF)
#define MAX_BYTES_PER_FRAME (256)

#define I2C_IRQ_PRIO (1)
#define I2C_FLAG_READ (I2C_READ << I2C_CR2_RD_WRN_Pos)
Expand Down Expand Up @@ -217,7 +216,7 @@ int i2c_write_regs(i2c_t dev, uint16_t addr, uint16_t reg,
int i2c_read_bytes(i2c_t dev, uint16_t address, void *data,
size_t length, uint8_t flags)
{
assert(dev < I2C_NUMOF && length < MAX_BYTES_PER_FRAME);
assert(dev < I2C_NUMOF && length < PERIPH_I2C_MAX_BYTES_PER_FRAME);

I2C_TypeDef *i2c = i2c_config[dev].dev;
assert(i2c != NULL);
Expand Down Expand Up @@ -275,7 +274,7 @@ int i2c_write_bytes(i2c_t dev, uint16_t address, const void *data,
static int _write(I2C_TypeDef *i2c, uint16_t addr, const void *data,
size_t length, uint8_t flags, uint32_t cr2_flags)
{
assert(i2c != NULL && length < MAX_BYTES_PER_FRAME);
assert(i2c != NULL && length < PERIPH_I2C_MAX_BYTES_PER_FRAME);

/* If reload was NOT set, must either stop or start */
if ((i2c->ISR & I2C_ISR_TC) && (flags & I2C_NOSTART)) {
Expand Down