Help for I2C
Hello,
can someone help me with a sample code for STM32F12G-Disco?
I am controlling the SSD1306 via I2C, so an oled display 0x78.
I just want to output a text on the dsiplay.
This is a code excerpt. Most of it was done by code generation:
#define ssd1306_I2C_Port hi2c2
#define ssd1306_I2C_ADDR 0x78
I2C_HandleTypeDef hi2c2;
QSPI_HandleTypeDef hqspi;
UART_HandleTypeDef huart2;
SRAM_HandleTypeDef hsram1;
HAL_StatusTypeDef ret;
uint8_t buf[12];
int16_t val;
float temp_c;
ret = HAL_I2C_Master_Transmit(&hi2c2, ssd1306_I2C_ADDR, buf, 1, HAL_MAX_DELAY);
if ( ret == HAL_OK ) {
strcpy((char*)buf, "Error Tx\r\n");
}
}
Is that roughly how you do it or how would you do it? I hope you can help me
