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

fix(wire): support only 7 bits addressing mode #2493

Merged
merged 2 commits into from
Aug 22, 2024
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
2 changes: 1 addition & 1 deletion libraries/Wire/src/Wire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ void TwoWire::begin(uint8_t address, bool generalCall, bool NoStretchMode)

recoverBus(); // in case I2C bus (device) is stuck after a reset for example

i2c_custom_init(&_i2c, 100000, I2C_ADDRESSINGMODE_7BIT, ownAddress);
i2c_init(&_i2c, 100000, ownAddress);

if (_i2c.isMaster == 0) {
// i2c_attachSlaveTxEvent(&_i2c, reinterpret_cast<void(*)(i2c_t*)>(&TwoWire::onRequestService));
Expand Down
15 changes: 2 additions & 13 deletions libraries/Wire/src/utility/twi.c
Original file line number Diff line number Diff line change
Expand Up @@ -637,25 +637,14 @@ static uint32_t i2c_getTiming(i2c_t *obj, uint32_t frequency)
return ret;
}

/**
* @brief Default init and setup GPIO and I2C peripheral
* @param obj : pointer to i2c_t structure
* @retval none
*/
void i2c_init(i2c_t *obj)
{
i2c_custom_init(obj, 100000, I2C_ADDRESSINGMODE_7BIT, 0x33);
}

/**
* @brief Initialize and setup GPIO and I2C peripheral
* @param obj : pointer to i2c_t structure
* @param timing : one of the i2c_timing_e
* @param addressingMode : I2C_ADDRESSINGMODE_7BIT or I2C_ADDRESSINGMODE_10BIT
* @param ownAddress : device address
* @retval none
*/
void i2c_custom_init(i2c_t *obj, uint32_t timing, uint32_t addressingMode, uint32_t ownAddress)
void i2c_init(i2c_t *obj, uint32_t timing, uint32_t ownAddress)
{
if (obj != NULL) {

Expand Down Expand Up @@ -771,7 +760,7 @@ void i2c_custom_init(i2c_t *obj, uint32_t timing, uint32_t addressingMode, uint3
#endif
handle->Init.OwnAddress1 = ownAddress;
handle->Init.OwnAddress2 = 0;
handle->Init.AddressingMode = addressingMode;
handle->Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
handle->Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
handle->Init.GeneralCallMode = (obj->generalCall == 0) ? I2C_GENERALCALL_DISABLE : I2C_GENERALCALL_ENABLE;
handle->Init.NoStretchMode = (obj->NoStretchMode == 0) ? I2C_NOSTRETCH_DISABLE : I2C_NOSTRETCH_ENABLE;
Expand Down
4 changes: 1 addition & 3 deletions libraries/Wire/src/utility/twi.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,7 @@ typedef enum {
} i2c_status_e;

/* Exported functions ------------------------------------------------------- */
void i2c_init(i2c_t *obj);
void i2c_custom_init(i2c_t *obj, uint32_t timing, uint32_t addressingMode,
uint32_t ownAddress);
void i2c_init(i2c_t *obj, uint32_t timing, uint32_t ownAddress);
void i2c_deinit(i2c_t *obj);
void i2c_setTiming(i2c_t *obj, uint32_t frequency);
i2c_status_e i2c_master_write(i2c_t *obj, uint8_t dev_address, uint8_t *data, uint16_t size);
Expand Down
Loading