Loading...
 
Skip to main content

System Workbench for STM32


GPIO Toggle Question

I feel like I'm asking the wrong question. Here's the psuedo code of what I'm trying to accomplish:

  • Start Condition
  • Send A Byte The value is 0x86 (134). The seven most significant bits instruct the STA013 to listen (because there may be other chips connected to SDA and SCL). The LSB is clear, telling the STA013 that will will be writing an address.
  • Send A Byte The value is the address where we need to read data. The main program will pass the address to our sta013_read function.
  • Stop Condition
  • Start Condition
  • Send A Byte The value is 0x87 (135). Again, the upper bits select the STA013, and the LSB sets up the next access to read.
  • Receive A Byte Read the byte from the STA013. This will be returned to the main program.
  • Stop Condition


My code looks like this:

uint8_t sta013ReadReg(uint8_t reg)
{
uint8_t data;

// STA_I2C_DEV = 0x86
sta013WriteReg(STA_I2C_DEV, data);
sta013WriteReg((STA_I2C_DEV+1), data);

/* Not sure which of these two is correct verstion */
//HAL_I2C_Mem_Read(&hi2c3, STA_I2C_DEV, reg, I2C_MEMADD_SIZE_8BIT, &data, 1, 10);
//HAL_I2C_Master_Receive(&hi2c3, reg, &data, 1, 100);

return data;
}

I feel like I'm missing this step:

  • Send A Byte The value is the address where we need to read data. The main program will pass the address to our sta013_read function.


Not really sure what it means or how to implement it.