cancel
Showing results for 
Search instead for 
Did you mean: 

BLUENRG232 i2c communication with eeprom

Pshar.1
Associate II

How can i assign addresses in EEPROM code of BlueNRG 232 for different vaiables location.

As in the sample code bluenrg232 only device address is used not the register address where we will save varaible values memory.

function taken from sample i2c code of bluenrg232.

/**

 * @brief I2C Master communication.

 * @param uint8_t dev_address: I2C device address

 * @param uint8_t send_val: value to send

 * @param uint8_t get_val: value to get

 * @retval I2C_OpStatus: I2C operation sattus

 */

I2C_AppOpStatus I2C_Read_Reg(uint8_t dev_address, uint8_t send_val, uint8_t* get_val)

{

 I2C_TransactionType t;

  

 /* Write I2C device address address */

 t.Operation = I2C_Operation_Write;

 t.Address = dev_address;

 t.StartByte = I2C_StartByte_Disable;

 t.AddressType = I2C_AddressType_7Bit;

 t.StopCondition = I2C_StopCondition_Disable;

 t.Length = 1;  

  

 I2C_FlushTx((I2C_Type*)SDK_EVAL_I2C);

  

 /* wait until Flush finished */

 while (I2C_WaitFlushTx((I2C_Type*)SDK_EVAL_I2C) == I2C_OP_ONGOING);

  

 /* Write I2C device address address and put the send_val in TX FIFO */

 I2C_BeginTransaction((I2C_Type*)SDK_EVAL_I2C, &t);

 I2C_FillTxFIFO((I2C_Type*)SDK_EVAL_I2C, send_val);

  

 /* Check write */

 do

 {

  if(I2C_OP_ABORTED == I2C_GetStatus((I2C_Type*)SDK_EVAL_I2C))

   return I2C_OP_FAILED;

   

 } while (I2C_GetITStatus((I2C_Type*)SDK_EVAL_I2C, I2C_IT_MTDWS) == RESET);

 I2C_ClearITPendingBit((I2C_Type*)SDK_EVAL_I2C, I2C_IT_MTDWS);

  

  

  

  

  

 /* Prepare to read data */

 t.Operation = I2C_Operation_Read;

 t.Address = dev_address;

 t.StartByte = I2C_StartByte_Disable;

 t.AddressType = I2C_AddressType_7Bit;

 t.StopCondition = I2C_StopCondition_Enable;

 t.Length = 1;

  

 I2C_BeginTransaction((I2C_Type*)SDK_EVAL_I2C, &t);

  

 /* Check read */

 do

 {

  if(I2C_OP_ABORTED == I2C_GetStatus((I2C_Type*)SDK_EVAL_I2C))

   return I2C_OP_FAILED;

   

 } while (RESET == I2C_GetITStatus((I2C_Type*)SDK_EVAL_I2C, I2C_IT_MTD));

  

 I2C_ClearITPendingBit((I2C_Type*)SDK_EVAL_I2C, I2C_IT_MTD | I2C_IT_MTDWS);

  

 /* Get data */

 *get_val = I2C_ReceiveData((I2C_Type*)SDK_EVAL_I2C);

  

 return I2C_OP_SUCCEED;

}

can you please share a sample code of EEPROM to Bluenrg232 i2c communication where at different locations in side the eeprom we can write and read 6 vaiables .

1 REPLY 1
Terrance Parker
Associate III

I think you have an offset address issue. But you can download code from ST from various apps to make sure sure your I2C registers are set up correctly.

Terry - ST Sales Guy