Read one and multiple bytes in function
Hello
I need help in my embedded project. assume array is loaded with five bytes so we know the location of each byte and data stored in the location.
byte 1 = location for byte1 6422296 = 00
byte 2 = location for byte2 6422300 = 01
byte 3 = location for byte3 6422304 = 02
byte 4 = location for byte4 6422308 = 03
byte 5 = location for byte5 6422312 = 04
I need to design two function
*read one byte
*read five bytes
In the read one byte function, function would take the memory location of one byte and save result
in read multiple byte function, read five bytes by calling read one byte function
I made my attempt
Code:
#include<stdio.h>
// Function to read one byte
void ReadByte (int *N)
{
//loop to read 8 bits
for ( n = 0; n <8; n++ )
{
/*read each bit of one byte */
}
}
// Function to read five byte
void ReadMultipleByte (int *P )
{
//loop to read 5 bytes
for ( n = 0; n <5; n++ )
{
// call the function to read one byte and it will run five time in loop
}
}
void main ()
{
int n;
int Data[]= {0,1,2,3,4}; //five bytes are stored into array
ReadMultipleByte (&Data)
return 0;
}