Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Just don't use it. It's not really needed and may be considered by some to be bad practice.
Get a grip. THat is not me.
void ReadFromFlash( int FlashAddress, int Len, void* Local_Ram_Variable){
*Local_Ram_Variable=ReadFlash(FlashAddress);
if(Len==2)
*(Local_Ram_Variable+1)=ReadFlash(FlashAddress+1);
}
Now that I read what you said, why would you that its not really needed?
I want to write a function that reads Len bytes from flash memory, and will store it in an local RAM variable.
The thing is that the function dont know what Len it will receive, If Len = 1, then the type of the Local Ram Variable will be char, but if Len = 2, then it would be int.
So i wanted to write a function like that:
void ReadFromFlash( int FlashAddress, int Len, void* Local_Ram_Variable);
The problem is that when I read the value from Flash, I cant perform:
*Local_Ram_Variable = value.
I cant also do casting to value because I dont know if its type is char or int or something else.
So how can i execute this function?
void ReadFromFlash( int FlashAddress, int Len, void* Local_Ram_Variable)
{
switch (Len)
{
case 1:
*(char*)Local_Ram_Variable = someChar;
break;
case 2:
*(int*)Local_Ram_Variable = someInt;
break;
default:
error...
}
}