- struct dev *address - It reads the addresses from a structure of registers.
- unsigned int bytes- number of bytes of data being read from the register address.
- For example - (0x2, 1). 0x2 - register address and 1 - number of bytes.
i2c_read(struct dev *address, unsigned int bytes)
{
char buff[256];
char *p1 = buff; // Contains a pointer to a buffer of 256 bytes
p1 = func(address, bytes); //values to be stored to the "pointer of a buffer of 256 bytes".
}
- The buffer contains values to be stored from func(address, bytes).
int push() //to push the buffer into the stack.
{
//push the buffer to stack here?.
}
I tried doing something like this -
void push(unsigned int *result_buffer)
{
unsigned int *tos, *p1, arr_stack[MAX_SIZE];
//MAX_SIZE is the size of the stack.
tos = arr_stack; /* tos points to the top of stack */
p1 = arr_stack; /* initialize p1 */
printf("\n Simple Stack Example - Pointers");
if (p1 == (tos + MAX_SIZE)) {
printf("\nStatus : Stack Overflow.\n");
} else {
*p1 = *result_buffer;
printf("\nPush Value : %d ", *(p1));
p1++;
}
}