Morse Micro IoT SDK  2.10.4
mmhal_app.h
1/*
2 * Copyright 2025 Morse Micro
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
17#pragma once
18
19#include <stdbool.h>
20#include <stddef.h>
21#include <stdint.h>
22#include <time.h>
23
24#ifdef __cplusplus
25extern "C"
26{
27#endif
28
36{
37 LED_RED,
38 LED_GREEN,
39 LED_BLUE,
40 LED_WHITE
41};
42
44#define LED_OFF 0
45
53#define LED_ON 255
54
63void mmhal_set_led(uint8_t led, uint8_t level);
64
75void mmhal_set_error_led(bool state);
76
83{
84 BUTTON_ID_USER0
85};
86
91{
92 BUTTON_RELEASED,
93 BUTTON_PRESSED
94};
95
97typedef void (*mmhal_button_state_cb_t)(enum mmhal_button_id button_id,
98 enum mmhal_button_state button_state);
99
110 mmhal_button_state_cb_t button_state_cb);
111
119
127
142bool mmhal_get_hardware_version(char *version_buffer, size_t version_buffer_length);
143
153#define MMHAL_DEBUG_PIN(_pin_num) (1ul << (_pin_num))
154
156#define MMHAL_ALL_DEBUG_PINS (UINT32_MAX)
157
174void mmhal_set_debug_pins(uint32_t mask, uint32_t values);
175
182time_t mmhal_get_time(void);
183
197void mmhal_set_time(time_t epoch);
198
199#ifdef __cplusplus
200}
201#endif
202
bool mmhal_get_hardware_version(char *version_buffer, size_t version_buffer_length)
Reads information that can be used to identify the hardware platform, such as hardware ID and version...
void(* mmhal_button_state_cb_t)(enum mmhal_button_id button_id, enum mmhal_button_state button_state)
Button state callback function prototype.
Definition: mmhal_app.h:97
mmhal_led_id
Enumeration for different LEDs on the board.
Definition: mmhal_app.h:36
mmhal_button_state
Enumeration for button states.
Definition: mmhal_app.h:91
bool mmhal_set_button_callback(enum mmhal_button_id button_id, mmhal_button_state_cb_t button_state_cb)
Registers a callback handler for button state changes.
void mmhal_set_time(time_t epoch)
Sets the RTC to the specified time in UTC.
mmhal_button_id
Enumeration for buttons on the board.
Definition: mmhal_app.h:83
mmhal_button_state_cb_t mmhal_get_button_callback(enum mmhal_button_id button_id)
Returns the registered callback handler for button state changes.
void mmhal_set_error_led(bool state)
Set the error LED to the requested state.
void mmhal_set_led(uint8_t led, uint8_t level)
Set the specified LED to the requested level.
time_t mmhal_get_time(void)
Returns the time of day as set in the RTC.
enum mmhal_button_state mmhal_get_button(enum mmhal_button_id button_id)
Reads the state of the specified button.
void mmhal_set_debug_pins(uint32_t mask, uint32_t values)
Set the value one or more debug pins.