-
Notifications
You must be signed in to change notification settings - Fork 0
Important Library Features
This document contains crucial information in the use of the library.
When using the library, it is extremely important that structures are initialized to zero. When declaring structure variables, please use the following convention:
Timer_Config timer_configuration = {0};This will ensure that all variables within the structure are initialized to 0. If structures are not initialized the zero, the library may work improperly. An example of this occurs if the callback function is not declared as NULL and does not point to an actual function. If this is the case, then the program will link to a function that does not exist and normal C execution will break as a result of a dangling reference.
The Callback function is used within almost every structure created by SUBLIBinal. The callback function is what drives interrupt driven designs. A callback function is simply a pointer to a function that will execute when an interrupt occurs. To supply a callback function, simply declare a function and hand a reference to it. Please see the following example:
#include "Sublibinal.h" //include the library header file
void foo() {
//implement functionality that will run when the timer interrupt occurs
}
void main() {
Timer_Config t_con = {0};
//... Fill out portions of the structure
t_con.callback = &foo; //supply a pointer to the function foo
initialize_Timer(t_con);
//...Complete other initialization
while (1) {
//Embedded system loop, implement what you would like in here!
}
}SUBLIBinal was created by the Palouse Robosub Club.