Page 1 of 1

I2C compilation errors

Posted: Sun Feb 19, 2017 1:50 pm
by becafuel
Hello,

I am quite new to ChibiOS, so please forgive what could be an obvious mistake on my side.

As soon as I add I2C support for F42x boards (F427 & F429 so far), I get compilation errors about many missing declarations (e.g. I2C_CR2_ADD10) :

Code: Select all

C:\dev\nf-interpreter\build\ChibiOS_Source\os\hal\ports\STM32\LLD\I2Cv2\i2c_lld.c: In function 'i2c_lld_set_address':
C:\dev\nf-interpreter\build\ChibiOS_Source\os\hal\ports\STM32\LLD\I2Cv2\i2c_lld.c:137:28: error: 'I2C_CR2_ADD10' undeclared (first use in this function)
if ((i2cp->config->cr2 & I2C_CR2_ADD10) == 0U)


Such declarations are available for many other MCUs but not F42x ones as far as I can tell.

I did try to use i2cv1 but I get other errors as well.
FYI, I do not have any problem when adding SPI, PWM or ADC support (among others).

So my question is : how can I avoid those compile time errors or what am I doing wrong here ?



Best regards,
___________
Christophe

Re: I2C compilation errors

Posted: Sun Feb 19, 2017 2:17 pm
by steved
IIRC the F429 uses I2CV1 - but if you set everything up right that bit's done automatically.
There's a demo project for the F429-Discovery which should be a good basis for your setup.
I2C needs to be enabled in two separate places:
a) In halconf.h, enable it in general

Code: Select all

#define HAL_USE_I2C                         TRUE

b) In mcuconf.h, enable the specific port you're using:

Code: Select all

#define STM32_I2C_USE_I2C1                  TRUE

Re: I2C compilation errors

Posted: Sun Feb 19, 2017 3:39 pm
by becafuel
Steved, thank you for your reply.

Unfortunately, those are the settings I already have.

When I try to use I2CV1, I get the following errors (excerpt) :

Code: Select all

C:\dev\nf-interpreter\build\ChibiOS_Source\os\hal\ports\STM32\LLD\I2Cv1\i2c_lld.c: In function 'i2c_lld_set_clock':
C:\dev\nf-interpreter\build\ChibiOS_Source\os\hal\ports\STM32\LLD\I2Cv1\i2c_lld.c:146:37: error: 'I2CConfig {aka const struct <anonymous>}' has no member named 'clock_speed'
   int32_t clock_speed = i2cp->config->clock_speed;
                                     ^
C:\dev\nf-interpreter\build\ChibiOS_Source\os\hal\ports\STM32\LLD\I2Cv1\i2c_lld.c:147:3: error: unknown type name 'i2cdutycycle_t'
   i2cdutycycle_t duty = i2cp->config->duty_cycle;
   ^


This is what is puzzling me : whichever version of I2C I choose, both give compilation error :(

I presume I am missing some .h files somewhere ?

Re: I2C compilation errors

Posted: Sun Feb 19, 2017 4:07 pm
by becafuel
Please forget my post :(

As soon as I wrote the previous reply, I have checked again (at least for the 5th time...) my include files and this time I have noticed that I had kept a reference to I2CV2 :?
How silly.

This does not mean that my I2C will work but I will not have any compilation errors regarding its inclusion.

Thank you for spending some time on this.


Regards,
_______
Christophe