5 years, 5 months ago.

I2C write functions - variable types for function arguments are non-sensical...

I am using a STM32 Nucleo F302R8 board I am using the online compiler

My code keeps generating an error: Error: No instance of overloaded function "mbed::I2C::write" matches the argument list in "main.cpp", Line: 419, Col: 19

Basically, I developed the rest of the application without I2C enabled (I had some peripheral parts on order) then when I added the write functions into the code, I get the above error.

Looking at the I2C API reference https://os.mbed.com/docs/v5.10/apis/i2c.html

int write ( int address, const char * data, int length, bool repeated = false )

I understand the STM32 - is by nature a 32bit processor...

Looking elsewhere on the MBED website https://os.mbed.com/handbook/C-Data-Types

You will find that an "int" is a 32 bit signed variable

1. Why is the argument "address" of type int? The actual I2C port, which is an inherently 8bit device Another device on the I2C bus cannot have an address of -30 and it cannot have an address of 2345678 Shouldn't it be of type char

2. The same argument holds for the "length" argument

Seems like such a trivial thing, (I can re-cast things, change the rest of my code) It just concerns me about the reliability of the MBED system as a whole...

2. length does not need to be an 8 bit variable

posted by Sam Manning 13 Nov 2018
Be the first to answer this question.