2022-01-20 03:30 AM
2022-01-20 07:49 AM
Welcome, @MGhob.1, to the community!
HAL is a layer of abstraction which is not available for the STM8. So sending a memory block via I2C has to be done manually there, for which you can use the SPL: I2C_Send7bitAddress(), I2C_SendData() etc.
Good luck!
Regards
/Peter
2022-02-10 08:37 AM
void I2C_sendarray_reg8(uint8_t dev_address, uint8_t reg8_register, uint8_t *data_array, uint8_t datalength)
{
uint8_t i;
i = 0;
I2C_GenerateSTART(ENABLE); //startbit
while(!I2C_CheckEvent(I2C_EVENT_MASTER_MODE_SELECT)); //master-mode?
I2C_Send7bitAddress(dev_address, I2C_DIRECTION_TX); //write-address-of reg16
while(!I2C_CheckEvent( I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED)); //transmit-mode?
I2C_SendData((uint8_t) reg8_register); //reg8 register
while(I2C_GetFlagStatus(I2C_FLAG_TRANSFERFINISHED) == RESET); //byte is sent?
while (i < datalength)
{
I2C_SendData(data_array[i++]); //send reg16 data byte
while(!I2C_CheckEvent( I2C_EVENT_MASTER_BYTE_TRANSMITTED)); //byte is sent?
}
I2C_GenerateSTOP(ENABLE); //stopbit
}
you'll have to write it yourself, above is some code as an example.