Hi @Nibesh
Sorry for the delay. I have some observations about your code.
If we refer to the code used as a reference for your project, we can see that two addresses were defined for the slave.
#define MPL3115A2_W 0xC0
#define MPL3115A2_R 0xC1
In these, a 1-bit shift to the left was made, and the bit that identifies whether you want to do a read or writing was added (we go from a 7-bit to an 8-bit address). Therefore, when you are calling the read or write functions, the same direction is taken as if a write were being done all the time.
Additionally, I could see that in your write function, you are sending an array, but when you call it in the function, you are only sending the address of the array, not a pointer to it.
use &uartRxBuff instead of uartRxBuff
Additionally, in this function, when sending data, you would not be traveling through the array, because you always send the same data.
uint8_t LPI2C0_write(uint8_t s_w_address, uint8_t * byte, uint8_t size)
{
if(bus_busy()) return (error |= (1 << BUSY));
generate_start_ACK(s_w_address);
for(int i=0;i<size;i++)
transmit_data(byte[i]);
if(generate_stop()) return error;
else return OK;
}
Please let me know if I misunderstood any of the above observations.