U16 is the declaration of the return variable. In this case I think it is a 16 bit unsigned int (not familiar with the compiler). If there is no return value, the function should be declared "void My_Function(void)"
What I can understand from your code is, "read_zero_push_state" this is the function name which is going to return U16 data type this should be declared in the any one of your .h file and the function argument is void.
That depends on where it is declared, static can have diffirent meanings...
Code:
void Foo(void)
{
static int i = 5;
//Some code here
}
In this case, static means the integer i is created only once, and assigned the initial value 5. It will not be destroyed when function Foo exits and recreated when Foo is entered again like a normal automatic variable but it will keep its value at all times troughout the program.
Code:
static int Global_i = 5;
Here, Global_i is declared as global variable (outside of a function). This means it can be accessed anywhere within that file.
Here, static means Global_i will have internal linkage. Wich means it will only be visible within the module where it is created.
Say you are creating a LCD library for others to use. Your code uses a global variable called i.
Code:
int i;
Now someone else uses your LCD.c and LCD.h files in his project (or even the already compiled object file if it is closed source). His own code contains
a I²C library wich happens to also declare a global variable i in the same way. During linking you will get an error, because i is declared twice.
By making i static, it will only be seen within its own module, solving the problem.
Ofcourse you can only make the variable static if you don't intend to use it within another module, meaning that if you want to use it somewhere else (with extern) then you can't make it static.
By module i mean object file , wich are the input files for the linker.
So yes, in C that will typically mean the file it was declared in. But weird constructions where multiple source files compile into a single object file are possible.
I know you hate me for this post, but it is important to use the correct terms. Especially when asking for advice on a forum like this. (and yes, I teach embedded programming. That's why I'm being 'pedantic').
No, the U16 tells you that the function returns an unsigned 16 bit integer. The memory location where the return value is placed depends on how you call the function.
This places the return value in a variable called "var":
Code:
U16 var;
var = read_zero_push_state();
This discards the return variable completely. You can do this if you don't need the return value for anything.