picofuse

app.h
Go to the documentation of this file.
1 
29 #pragma once
30 #include "hid.h"
31 #include "hw.h"
32 #include "sys.h"
33 
35 // TYPES
36 
41 typedef enum {
43  app_flag_multicore = (1 << 0),
44  app_flag_signal = (1 << 1),
45  app_flag_user_button = (1 << 2),
49  app_flag_temperature = (1 << 3),
55  app_flag_stdio_rtt = (1 << 5),
62  app_flag_led = (1 << 6),
65  app_flag_watchdog = (1 << 7),
69  app_flag_usb = (1 << 8),
75 } app_flag_t;
86 
91 typedef struct app_t app_t;
92 
103 typedef void (*app_callback_start_t)(app_t *app, void *userdata);
104 
113 typedef void (*app_callback_event_t)(app_t *app, sys_event_t event,
114  void *userdata);
115 
117 // LIFECYCLE
118 
157 int app_main(int argc, char *argv[], app_flag_t flags,
158  app_callback_start_t on_start, app_callback_event_t on_event,
159  void *userdata);
160 
163 // PROPERTIES
165 
176 hid_t *app_hid(const app_t *app);
177 
188 hw_led_t *app_led(const app_t *app);
189 
202 hw_watchdog_t *app_watchdog(const app_t *app);
203 
216 hw_usb_t *app_usb(const app_t *app);
217 
220 // METHODS
222 
236 void app_shutdown(int exit_code);
237 
hid_t * app_hid(const app_t *app)
Get the HID instance initialized for this app.
struct hw_led_t hw_led_t
Opaque LED handle.
Definition: led.h:109
Initialize the on-board LED if available (see app_led).
Definition: app.h:64
Run the event loop across all cores.
Definition: app.h:43
struct hw_watchdog_t hw_watchdog_t
Watchdog adapter handle.
Definition: watchdog.h:57
Aggregates HID component interfaces.
Enable the watchdog (see app_watchdog) - hw_poll(), called every run loop tick, feeds it from there...
Definition: app.h:68
int app_main(int argc, char *argv[], app_flag_t flags, app_callback_start_t on_start, app_callback_event_t on_event, void *userdata)
Initialize the sys subsystem, run the event loop, then tear it down.
System abstraction headers and process lifecycle hooks.
Default behavior.
Definition: app.h:42
Register the board&#39;s user button (if any) as a HID event with keycode KEYCODE_BUTTON_USER (see app_hi...
Definition: app.h:48
hw_usb_t * app_usb(const app_t *app)
Get the USB host handle initialized for this app.
void(* app_callback_start_t)(app_t *app, void *userdata)
Called once, on the main worker, before the run loop starts dispatching events.
Definition: app.h:103
hw_watchdog_t * app_watchdog(const app_t *app)
Get the watchdog handle initialized for this app.
Hardware abstraction headers for on-board peripherals.
Initialize standard I/O via SEGGER RTT (sys_stdio_rtt) instead of the platform default.
Definition: app.h:61
hw_led_t * app_led(const app_t *app)
Get the on-board LED handle initialized for this app.
Register environment signals (TERM, INT, QUIT) as HID events (see app_hid).
Definition: app.h:44
app_flag_t
Feature flags controlling how app_main() runs.
Definition: app.h:41
void * sys_event_t
Event payload stored in a queue.
Definition: event.h:68
struct hw_usb_t hw_usb_t
Opaque USB host handle.
Definition: usb.h:280
Initialize the USB host subsystem and register it with HID (see app_usb and app_hid) - hotplug activi...
Definition: app.h:74
Register the internal temperature-sensor channel as a polling HID metric source (see hid_register_tem...
Definition: app.h:54
struct hid_t hid_t
Opaque HID instance handle.
Definition: device.h:40
struct app_t app_t
Opaque application instance passed to app callbacks.
Definition: app.h:91
void app_shutdown(int exit_code)
Request that the running app&#39;s event loop stop.
void(* app_callback_event_t)(app_t *app, sys_event_t event, void *userdata)
Called on a worker for each event the run loop dispatches.
Definition: app.h:113