gossamer 0.0.1
a very lightweight app framework for SAMD and SAML chips
Loading...
Searching...
No Matches
Gossamer application framework

This section describes the application framework that you will use to write your firmware. More...

Functions

void app_init (void)
 A function you will implement to initialize your application's low- level setup. The app_init function is called after system clocks are initialized, and before anything else.
 
void app_wake_from_backup (void)
 OPTIONAL: A function you may implement to restore state after waking up from BACKUP mode on the SAM L21 or L22. This function is called after system_init, but before app_setup. You can stash a bit of your application state in the RTC's BKUP and GPn registers, and use this function as an opportinity to restore it before app_setup is called.
 
void app_setup (void)
 A function you will implement to set up your app. The app_setup function is like setup() in Arduino. It is called once when the program begins, after app_init and app_wake_from_backup, if it exists. You should use this function to set up your application state and configure any peripherals you need to use.
 
bool app_loop (void)
 A function you will implement to serve as the app's main run loop. This method will be called repeatedly, or if you enter STANDBY mode, as soon as the device wakes from that mode.
 
void yield (void)
 OPTIONAL: A function to yield control of the CPU to other tasks. This function is called in the delay function to allow other tasks to run while the CPU is busy waiting. By default, this function does nothing, but if you are using the USB peripheral, you should implement this function and call tud_task at minumum, along with any other USB-related tasks you need to run.
 

Detailed Description

This section describes the application framework that you will use to write your firmware.

All Gossamer applications are built by implementing the three functions described in this section. There is an optional fourth function that relates to the SAM L21 and L22's BACKUP mode, but you do not need to implement it unless you are using the BACKUP mode functionality.

Function Documentation

◆ app_init()

void app_init ( void  )

A function you will implement to initialize your application's low- level setup. The app_init function is called after system clocks are initialized, and before anything else.

You may be wondering why there is an app_init function as well as an app_setup function. The main difference is that app_init is only meant to be callec once, at boot, whereas you might want to call app_setup multiple times, for example if you want to disable some peripherals before entering STANDBY mode, and re-enable them after waking up. In essence, you should set up anything that will run forever in app_init, whereas anything that could get turned off in the course of execution should be set up in app_setup. If your application plans to use the real-time clock perhiperal, you probably want to call the rtc_init function here.

◆ app_loop()

bool app_loop ( void  )

A function you will implement to serve as the app's main run loop. This method will be called repeatedly, or if you enter STANDBY mode, as soon as the device wakes from that mode.

Note
In order to wake from STANDBY mode, you must set up an interrupt or wake source. Otherwise your app will remain in STANDBY indefinitely.
Returns
true if your app is prepared to enter STANDBY mode. If you return false, your app's app_loop method will be called again immediately.

◆ app_wake_from_backup()

void app_wake_from_backup ( void  )

OPTIONAL: A function you may implement to restore state after waking up from BACKUP mode on the SAM L21 or L22. This function is called after system_init, but before app_setup. You can stash a bit of your application state in the RTC's BKUP and GPn registers, and use this function as an opportinity to restore it before app_setup is called.

Note
You do not need to implement this function unless you are using the SAM L21 or L22 and you want to restore state from BACKUP mode.