Problem accessing structure members

I am using Espressif’s ESP32 i2c library which contains the following structure:

typedef struct{
   i2c_mode_t mode;       /*!< I2C mode */
   gpio_num_t sda_io_num;        /*!< GPIO number for I2C sda signal */
   gpio_pullup_t sda_pullup_en;  /*!< Internal GPIO pull mode for I2C sda signal*/
   gpio_num_t scl_io_num;        /*!< GPIO number for I2C scl signal */
   gpio_pullup_t scl_pullup_en;  /*!< Internal GPIO pull mode for I2C scl signal*/

   union {
       struct {
           uint32_t clk_speed;     /*!< I2C clock frequency for master mode, (no higher than 1MHz for now) */
       } master;
       struct {
           uint8_t addr_10bit_en;  /*!< I2C 10bit address mode enable for slave mode */
           uint16_t slave_addr;    /*!< I2C address for slave mode */
       } slave;


But I get a compile time error when I try to reference the member clk_speed. This is my code:

bool Start_I2C () {
 i2c_Config.mode = I2C_MODE_MASTER;
 i2c_Config.sda_io_num = GPIO21SDA;
 i2c_Config.sda_pullup_en = GPIO_PULLUP_ENABLE;
 i2c_Config.scl_io_num = GPIO22SCL;
 i2c_Config.scl_pullup_en = GPIO_PULLUP_ENABLE;
 i2c_Config.clk_speed = i2C_clk_speed;

 i2c_Err = i2c_driver_install(I2C_NUM_0, I2C_MODE_MASTER, 0, 0, 1);

What am I doing wrong? How do I reference the member?

I have attached a screen shot of the error. Probably simple when you know how, but not when you don’t…

i think

i2c_Config.master.clk_speed = i2C_clk_speed;

Thank you Greg, so easy when you know how. That is the first struct I have come across that use what is essentially a redefinition.

i wouldn’t describe the use of a union as a redefinition, it allows memory to be used for different purposes. I’ve often defined structure members as (void*) and used casts to use that member for several different purposes. another struct member might indicate the purpose