AnsweredAssumed Answered

Adding a 2nd I2C peripheral to STM8L development system.

Question asked by pietroforte.angelo on Dec 20, 2014

</p>

I am trying to add a 2nd I2C peripheral with an address of 0x42 to my STM8L development system, and I’m having a hard time understanding how to go about it.  The first I2C peripheral with address of 0x90 is working good and the I2C address is defined like this:

Line 65  #define LM75_ADDR    0x90          (this LM75 is a carryover from the temp sensor that was on the eval board)  (found in stm8_eval_i2c_tsensor.h) 

</p>

Line 183 I2C_Send7bitAddress(LM75_I2C, LM75_ADDR, I2C_Direction_Transmitter);                                                  (found in stm8_eval_i2c_tsensor.c)

 

 Line 715  void I@C_Send7bitAddress (I2C_TypeDef* I2Cx,  unint8_t Address, I2C_Direction_TypeDef I2C_Direction)    (found in stm8l15x_i2c.c)

</span></span>

The STM8L1526-EVAL I’m using also has an I2C EEPROM which I removed when we removed the LM75.  We removed the LM75 because it had an address 0x90 which was the same as the peripheral we were putting in.  And since the soldering iron was hot we removed the EEPROM too.  The reason I mention this is because when I look in stm8l1526_eval.h I see defines dedicated to the EEPROM.  I’m thinking I can use these sEE defines for my new peripheral and then use the EEPROM device driver?</span>

#define sEE_I2C                         I2C1

#define sEE _I2C_CLK                     CLK_Peripheral_I2C1

#define sEE _I2C_SCL_PIN                 GPIO_Pin_1                  /* PC.01 */

#define sEE _I2C_SCL_GPIO_PORT           GPIOC                       /* GPIOC */

#define sEE _I2C_SDA_PIN                 GPIO_Pin_0                  /* PC.00 */

#define sEE _I2C_SDA_GPIO_PORT           GPIOC                       /* GPIOC */

I tried to write a device driver as done for the I2C temperature sensor in file stm_eval_I2C_tsensor.c by copying almost the entire file, pasting at the bottom of the same file, and then changing LM75 to LM33, but that didn’t work.  I started to get compile errors:  missing )  and misc.  Just a very long list of compile errors.  It seemed a very laborious approach even though I did use the find LM75 and replace LM33 feature in the IDE.  I thought maybe the stm8_eval_i2c_ee.c could be insert as shown in the attached jpeg.

I've been told to to create similar defines , then write your device driver as done for the I2Ctemperature sensor in file stm_eval_I2C_tsensor.c 

#define LM75_I2C                         I2C1

 

#define LM75_I2C_CLK                     CLK_Peripheral_I2C1

 

#define LM75_I2C_SCL_PIN                 GPIO_Pin_1                  /* PC.01 */

 

#define LM75_I2C_SCL_GPIO_PORT           GPIOC                       /* GPIOC */

 

#define LM75_I2C_SDA_PIN                 GPIO_Pin_0                  /* PC.00 */

 

#define LM75_I2C_SDA_GPIO_PORT           GPIOC                       /* GPIOC */

 

 

 


</span>

Outcomes