m5unified-sys 0.1.0

Raw Rust bindings for M5Unified via a C ABI shim.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(non_upper_case_globals)]
#![allow(clippy::missing_safety_doc)]

//! Raw bindings for a small C ABI shim over M5Unified.
//!
//! This crate intentionally does not bind M5Unified's C++ classes directly.
//! Instead, `native/m5u_shim.cpp` exposes stable `extern "C"` functions that
//! Rust can call from the higher-level `m5unified` crate. On non-ESP-IDF host
//! targets these functions are stubbed so the safe wrapper and translated
//! samples can be checked in CI without hardware.
//!
//! Firmware projects targeting ESP-IDF must provide the native shim component
//! from this crate's `native/` directory in their ESP-IDF component graph. The
//! host stubs are compile-time conveniences only and do not simulate M5Stack
//! hardware behavior.

use core::ffi::{c_char, c_float, c_int};

#[repr(C)]
#[derive(Debug, Copy, Clone, Default, PartialEq, Eq)]
pub struct m5u_touch_detail_t {
    pub x: c_int,
    pub y: c_int,
    pub prev_x: c_int,
    pub prev_y: c_int,
    pub is_pressed: bool,
    pub was_pressed: bool,
    pub was_released: bool,
    pub was_clicked: bool,
    pub was_hold: bool,
    pub is_holding: bool,
    pub click_count: c_int,
}

#[cfg(target_os = "espidf")]
extern "C" {
    pub fn m5u_begin() -> bool;
    pub fn m5u_update();
    pub fn m5u_delay_ms(ms: u32);

    pub fn m5u_display_width() -> c_int;
    pub fn m5u_display_height() -> c_int;
    pub fn m5u_display_fill_screen(color: u16);
    pub fn m5u_display_set_cursor(x: c_int, y: c_int);
    pub fn m5u_display_set_text_size(size: c_int);
    pub fn m5u_display_set_text_color(fg: u16, bg: u16);
    pub fn m5u_display_print(text: *const c_char);
    pub fn m5u_display_println(text: *const c_char);
    pub fn m5u_display_draw_line(x0: c_int, y0: c_int, x1: c_int, y1: c_int, color: u16);
    pub fn m5u_display_draw_rect(x: c_int, y: c_int, w: c_int, h: c_int, color: u16);
    pub fn m5u_display_fill_rect(x: c_int, y: c_int, w: c_int, h: c_int, color: u16);
    pub fn m5u_display_draw_circle(x: c_int, y: c_int, r: c_int, color: u16);
    pub fn m5u_display_fill_circle(x: c_int, y: c_int, r: c_int, color: u16);
    pub fn m5u_display_set_rotation(rotation: c_int);

    pub fn m5u_btn_a_is_pressed() -> bool;
    pub fn m5u_btn_a_was_pressed() -> bool;
    pub fn m5u_btn_a_was_released() -> bool;
    pub fn m5u_btn_b_is_pressed() -> bool;
    pub fn m5u_btn_b_was_pressed() -> bool;
    pub fn m5u_btn_b_was_released() -> bool;
    pub fn m5u_btn_c_is_pressed() -> bool;
    pub fn m5u_btn_c_was_pressed() -> bool;
    pub fn m5u_btn_c_was_released() -> bool;

    pub fn m5u_mic_begin() -> bool;
    pub fn m5u_mic_record_i16(buffer: *mut i16, samples: usize) -> bool;
    pub fn m5u_speaker_begin() -> bool;
    pub fn m5u_speaker_set_volume(volume: u8);
    pub fn m5u_speaker_tone(frequency_hz: u32, duration_ms: u32) -> bool;
    pub fn m5u_speaker_play_i16(samples: *const i16, len: usize, sample_rate_hz: u32) -> bool;

    pub fn m5u_imu_begin() -> bool;
    pub fn m5u_imu_get_accel(x: *mut f32, y: *mut f32, z: *mut f32) -> bool;
    pub fn m5u_imu_get_gyro(x: *mut f32, y: *mut f32, z: *mut f32) -> bool;
    pub fn m5u_imu_get_temp_c(temp: *mut f32) -> bool;

    pub fn m5u_touch_count() -> c_int;
    pub fn m5u_touch_get(index: c_int, x: *mut c_int, y: *mut c_int) -> bool;

    pub fn m5u_rtc_get_datetime(
        year: *mut c_int,
        month: *mut c_int,
        day: *mut c_int,
        hour: *mut c_int,
        minute: *mut c_int,
        second: *mut c_int,
    ) -> bool;
    pub fn m5u_rtc_set_datetime(
        year: c_int,
        month: c_int,
        day: c_int,
        hour: c_int,
        minute: c_int,
        second: c_int,
    ) -> bool;

    pub fn m5u_battery_level() -> c_int;
    pub fn m5u_battery_voltage_mv() -> c_int;
    pub fn m5u_power_is_charging() -> bool;

    pub fn m5u_display_get_rotation() -> c_int;
    pub fn m5u_display_set_brightness(brightness: u8);
    pub fn m5u_display_set_epd_fastest();
    pub fn m5u_display_start_write();
    pub fn m5u_display_end_write();
    pub fn m5u_display_display();
    pub fn m5u_display_display_busy() -> bool;
    pub fn m5u_display_wait_display();
    pub fn m5u_display_get_cursor_y() -> c_int;
    pub fn m5u_display_font_height() -> c_int;
    pub fn m5u_display_get_base_color() -> u16;
    pub fn m5u_display_set_color(color: u16);
    pub fn m5u_display_set_text_wrap(wrap_x: bool, wrap_y: bool);
    pub fn m5u_display_set_text_datum(datum: c_int);
    pub fn m5u_display_draw_string(text: *const c_char, x: c_int, y: c_int) -> c_int;
    pub fn m5u_display_write_pixel(x: c_int, y: c_int, color: u16);
    pub fn m5u_display_write_fast_vline(x: c_int, y: c_int, h: c_int, color: u16);
    pub fn m5u_display_set_clip_rect(x: c_int, y: c_int, w: c_int, h: c_int);
    pub fn m5u_display_clear_clip_rect();
    pub fn m5u_display_color888(r: u8, g: u8, b: u8) -> u16;
    pub fn m5u_display_count() -> c_int;
    pub fn m5u_display_index_for_kind(kind: c_int) -> c_int;
    pub fn m5u_display_width_at(index: c_int) -> c_int;
    pub fn m5u_display_height_at(index: c_int) -> c_int;
    pub fn m5u_display_print_at(index: c_int, text: *const c_char);
    pub fn m5u_display_fill_circle_at(index: c_int, x: c_int, y: c_int, r: c_int, color: u16);

    pub fn m5u_button_is_pressed(button: c_int) -> bool;
    pub fn m5u_button_was_pressed(button: c_int) -> bool;
    pub fn m5u_button_was_released(button: c_int) -> bool;
    pub fn m5u_button_was_clicked(button: c_int) -> bool;
    pub fn m5u_button_was_hold(button: c_int) -> bool;
    pub fn m5u_button_is_holding(button: c_int) -> bool;
    pub fn m5u_button_was_decide_click_count(button: c_int) -> bool;
    pub fn m5u_button_get_click_count(button: c_int) -> c_int;

    pub fn m5u_mic_is_enabled() -> bool;
    pub fn m5u_mic_is_recording() -> bool;
    pub fn m5u_mic_end();
    pub fn m5u_mic_record_i16_at(buffer: *mut i16, samples: usize, sample_rate_hz: u32) -> bool;
    pub fn m5u_mic_get_noise_filter_level() -> c_int;
    pub fn m5u_mic_set_noise_filter_level(level: c_int) -> bool;

    pub fn m5u_speaker_is_enabled() -> bool;
    pub fn m5u_speaker_end();
    pub fn m5u_speaker_get_volume() -> u8;
    pub fn m5u_speaker_tone_ex(frequency_hz: c_float, duration_ms: u32, channel: c_int) -> bool;
    pub fn m5u_speaker_play_u8(samples: *const u8, len: usize, sample_rate_hz: u32) -> bool;
    pub fn m5u_speaker_play_wav(data: *const u8, len: usize) -> bool;
    pub fn m5u_speaker_is_playing(channel: c_int) -> bool;
    pub fn m5u_speaker_stop(channel: c_int);
    pub fn m5u_speaker_get_channel_volume(channel: c_int) -> u8;
    pub fn m5u_speaker_set_channel_volume(channel: c_int, volume: u8);
    pub fn m5u_speaker_set_all_channel_volume(volume: u8);

    pub fn m5u_imu_is_enabled() -> bool;
    pub fn m5u_imu_get_type() -> c_int;
    pub fn m5u_imu_update() -> bool;
    pub fn m5u_imu_load_offset_from_nvs() -> bool;
    pub fn m5u_imu_save_offset_to_nvs() -> bool;
    pub fn m5u_imu_get_offset_data(index: c_int) -> c_float;
    pub fn m5u_imu_set_calibration(x: c_float, y: c_float, z: c_float);

    pub fn m5u_touch_get_detail(index: c_int, out: *mut m5u_touch_detail_t) -> bool;
    pub fn m5u_rtc_is_enabled() -> bool;

    pub fn m5u_power_axp2101_disable_irq(mask: u64) -> bool;
    pub fn m5u_power_axp2101_enable_irq(mask: u64) -> bool;
    pub fn m5u_power_axp2101_clear_irq_statuses() -> bool;
    pub fn m5u_power_axp2101_get_irq_statuses() -> u64;
    pub fn m5u_power_axp2101_is_bat_charger_under_temperature_irq() -> bool;
    pub fn m5u_power_axp2101_is_bat_charger_over_temperature_irq() -> bool;
    pub fn m5u_power_axp2101_is_vbus_insert_irq() -> bool;
    pub fn m5u_power_axp2101_is_vbus_remove_irq() -> bool;

    pub fn m5u_log_print(text: *const c_char);
    pub fn m5u_log_println(text: *const c_char);
    pub fn m5u_log_level(level: c_int, text: *const c_char);
    pub fn m5u_sd_begin() -> bool;
}

#[cfg(not(target_os = "espidf"))]
mod host_stubs {
    use super::*;
    use core::ptr;

    pub unsafe fn m5u_begin() -> bool {
        true
    }
    pub unsafe fn m5u_update() {}
    pub unsafe fn m5u_delay_ms(_ms: u32) {}

    pub unsafe fn m5u_display_width() -> c_int {
        320
    }
    pub unsafe fn m5u_display_height() -> c_int {
        240
    }
    pub unsafe fn m5u_display_fill_screen(_color: u16) {}
    pub unsafe fn m5u_display_set_cursor(_x: c_int, _y: c_int) {}
    pub unsafe fn m5u_display_set_text_size(_size: c_int) {}
    pub unsafe fn m5u_display_set_text_color(_fg: u16, _bg: u16) {}
    pub unsafe fn m5u_display_print(_text: *const c_char) {}
    pub unsafe fn m5u_display_println(_text: *const c_char) {}
    pub unsafe fn m5u_display_draw_line(
        _x0: c_int,
        _y0: c_int,
        _x1: c_int,
        _y1: c_int,
        _color: u16,
    ) {
    }
    pub unsafe fn m5u_display_draw_rect(_x: c_int, _y: c_int, _w: c_int, _h: c_int, _color: u16) {}
    pub unsafe fn m5u_display_fill_rect(_x: c_int, _y: c_int, _w: c_int, _h: c_int, _color: u16) {}
    pub unsafe fn m5u_display_draw_circle(_x: c_int, _y: c_int, _r: c_int, _color: u16) {}
    pub unsafe fn m5u_display_fill_circle(_x: c_int, _y: c_int, _r: c_int, _color: u16) {}
    pub unsafe fn m5u_display_set_rotation(_rotation: c_int) {}

    pub unsafe fn m5u_btn_a_is_pressed() -> bool {
        false
    }
    pub unsafe fn m5u_btn_a_was_pressed() -> bool {
        false
    }
    pub unsafe fn m5u_btn_a_was_released() -> bool {
        false
    }
    pub unsafe fn m5u_btn_b_is_pressed() -> bool {
        false
    }
    pub unsafe fn m5u_btn_b_was_pressed() -> bool {
        false
    }
    pub unsafe fn m5u_btn_b_was_released() -> bool {
        false
    }
    pub unsafe fn m5u_btn_c_is_pressed() -> bool {
        false
    }
    pub unsafe fn m5u_btn_c_was_pressed() -> bool {
        false
    }
    pub unsafe fn m5u_btn_c_was_released() -> bool {
        false
    }

    pub unsafe fn m5u_mic_begin() -> bool {
        true
    }
    pub unsafe fn m5u_mic_record_i16(buffer: *mut i16, samples: usize) -> bool {
        if !buffer.is_null() {
            for i in 0..samples {
                ptr::write(buffer.add(i), 0);
            }
        }
        true
    }
    pub unsafe fn m5u_speaker_begin() -> bool {
        true
    }
    pub unsafe fn m5u_speaker_set_volume(_volume: u8) {}
    pub unsafe fn m5u_speaker_tone(_frequency_hz: u32, _duration_ms: u32) -> bool {
        true
    }
    pub unsafe fn m5u_speaker_play_i16(
        _samples: *const i16,
        _len: usize,
        _sample_rate_hz: u32,
    ) -> bool {
        true
    }

    pub unsafe fn m5u_imu_begin() -> bool {
        true
    }
    pub unsafe fn m5u_imu_get_accel(x: *mut f32, y: *mut f32, z: *mut f32) -> bool {
        if !x.is_null() {
            *x = 0.0;
        }
        if !y.is_null() {
            *y = 0.0;
        }
        if !z.is_null() {
            *z = 1.0;
        }
        true
    }
    pub unsafe fn m5u_imu_get_gyro(x: *mut f32, y: *mut f32, z: *mut f32) -> bool {
        if !x.is_null() {
            *x = 0.0;
        }
        if !y.is_null() {
            *y = 0.0;
        }
        if !z.is_null() {
            *z = 0.0;
        }
        true
    }
    pub unsafe fn m5u_imu_get_temp_c(temp: *mut f32) -> bool {
        if !temp.is_null() {
            *temp = 25.0;
        }
        true
    }

    pub unsafe fn m5u_touch_count() -> c_int {
        0
    }
    pub unsafe fn m5u_touch_get(_index: c_int, _x: *mut c_int, _y: *mut c_int) -> bool {
        false
    }

    pub unsafe fn m5u_rtc_get_datetime(
        year: *mut c_int,
        month: *mut c_int,
        day: *mut c_int,
        hour: *mut c_int,
        minute: *mut c_int,
        second: *mut c_int,
    ) -> bool {
        if !year.is_null() {
            *year = 2026;
        }
        if !month.is_null() {
            *month = 1;
        }
        if !day.is_null() {
            *day = 1;
        }
        if !hour.is_null() {
            *hour = 0;
        }
        if !minute.is_null() {
            *minute = 0;
        }
        if !second.is_null() {
            *second = 0;
        }
        true
    }
    pub unsafe fn m5u_rtc_set_datetime(
        _year: c_int,
        _month: c_int,
        _day: c_int,
        _hour: c_int,
        _minute: c_int,
        _second: c_int,
    ) -> bool {
        true
    }

    pub unsafe fn m5u_battery_level() -> c_int {
        100
    }
    pub unsafe fn m5u_battery_voltage_mv() -> c_int {
        4200
    }
    pub unsafe fn m5u_power_is_charging() -> bool {
        false
    }

    pub unsafe fn m5u_display_get_rotation() -> c_int {
        0
    }
    pub unsafe fn m5u_display_set_brightness(_brightness: u8) {}
    pub unsafe fn m5u_display_set_epd_fastest() {}
    pub unsafe fn m5u_display_start_write() {}
    pub unsafe fn m5u_display_end_write() {}
    pub unsafe fn m5u_display_display() {}
    pub unsafe fn m5u_display_display_busy() -> bool {
        false
    }
    pub unsafe fn m5u_display_wait_display() {}
    pub unsafe fn m5u_display_get_cursor_y() -> c_int {
        0
    }
    pub unsafe fn m5u_display_font_height() -> c_int {
        16
    }
    pub unsafe fn m5u_display_get_base_color() -> u16 {
        0
    }
    pub unsafe fn m5u_display_set_color(_color: u16) {}
    pub unsafe fn m5u_display_set_text_wrap(_wrap_x: bool, _wrap_y: bool) {}
    pub unsafe fn m5u_display_set_text_datum(_datum: c_int) {}
    pub unsafe fn m5u_display_draw_string(_text: *const c_char, _x: c_int, _y: c_int) -> c_int {
        0
    }
    pub unsafe fn m5u_display_write_pixel(_x: c_int, _y: c_int, _color: u16) {}
    pub unsafe fn m5u_display_write_fast_vline(_x: c_int, _y: c_int, _h: c_int, _color: u16) {}
    pub unsafe fn m5u_display_set_clip_rect(_x: c_int, _y: c_int, _w: c_int, _h: c_int) {}
    pub unsafe fn m5u_display_clear_clip_rect() {}
    pub unsafe fn m5u_display_color888(r: u8, g: u8, b: u8) -> u16 {
        ((u16::from(r & 0xF8)) << 8) | ((u16::from(g & 0xFC)) << 3) | u16::from(b >> 3)
    }
    pub unsafe fn m5u_display_count() -> c_int {
        1
    }
    pub unsafe fn m5u_display_index_for_kind(_kind: c_int) -> c_int {
        -1
    }
    pub unsafe fn m5u_display_width_at(_index: c_int) -> c_int {
        320
    }
    pub unsafe fn m5u_display_height_at(_index: c_int) -> c_int {
        240
    }
    pub unsafe fn m5u_display_print_at(_index: c_int, _text: *const c_char) {}
    pub unsafe fn m5u_display_fill_circle_at(
        _index: c_int,
        _x: c_int,
        _y: c_int,
        _r: c_int,
        _color: u16,
    ) {
    }

    pub unsafe fn m5u_button_is_pressed(_button: c_int) -> bool {
        false
    }
    pub unsafe fn m5u_button_was_pressed(_button: c_int) -> bool {
        false
    }
    pub unsafe fn m5u_button_was_released(_button: c_int) -> bool {
        false
    }
    pub unsafe fn m5u_button_was_clicked(_button: c_int) -> bool {
        false
    }
    pub unsafe fn m5u_button_was_hold(_button: c_int) -> bool {
        false
    }
    pub unsafe fn m5u_button_is_holding(_button: c_int) -> bool {
        false
    }
    pub unsafe fn m5u_button_was_decide_click_count(_button: c_int) -> bool {
        false
    }
    pub unsafe fn m5u_button_get_click_count(_button: c_int) -> c_int {
        0
    }

    pub unsafe fn m5u_mic_is_enabled() -> bool {
        true
    }
    pub unsafe fn m5u_mic_is_recording() -> bool {
        false
    }
    pub unsafe fn m5u_mic_end() {}
    pub unsafe fn m5u_mic_record_i16_at(
        buffer: *mut i16,
        samples: usize,
        _sample_rate_hz: u32,
    ) -> bool {
        m5u_mic_record_i16(buffer, samples)
    }
    pub unsafe fn m5u_mic_get_noise_filter_level() -> c_int {
        0
    }
    pub unsafe fn m5u_mic_set_noise_filter_level(_level: c_int) -> bool {
        true
    }

    pub unsafe fn m5u_speaker_is_enabled() -> bool {
        true
    }
    pub unsafe fn m5u_speaker_end() {}
    pub unsafe fn m5u_speaker_get_volume() -> u8 {
        64
    }
    pub unsafe fn m5u_speaker_tone_ex(
        _frequency_hz: c_float,
        _duration_ms: u32,
        _channel: c_int,
    ) -> bool {
        true
    }
    pub unsafe fn m5u_speaker_play_u8(
        _samples: *const u8,
        _len: usize,
        _sample_rate_hz: u32,
    ) -> bool {
        true
    }
    pub unsafe fn m5u_speaker_play_wav(_data: *const u8, _len: usize) -> bool {
        true
    }
    pub unsafe fn m5u_speaker_is_playing(_channel: c_int) -> bool {
        false
    }
    pub unsafe fn m5u_speaker_stop(_channel: c_int) {}
    pub unsafe fn m5u_speaker_get_channel_volume(_channel: c_int) -> u8 {
        255
    }
    pub unsafe fn m5u_speaker_set_channel_volume(_channel: c_int, _volume: u8) {}
    pub unsafe fn m5u_speaker_set_all_channel_volume(_volume: u8) {}

    pub unsafe fn m5u_imu_is_enabled() -> bool {
        true
    }
    pub unsafe fn m5u_imu_get_type() -> c_int {
        0
    }
    pub unsafe fn m5u_imu_update() -> bool {
        true
    }
    pub unsafe fn m5u_imu_load_offset_from_nvs() -> bool {
        false
    }
    pub unsafe fn m5u_imu_save_offset_to_nvs() -> bool {
        false
    }
    pub unsafe fn m5u_imu_get_offset_data(_index: c_int) -> c_float {
        0.0
    }
    pub unsafe fn m5u_imu_set_calibration(_x: c_float, _y: c_float, _z: c_float) {}

    pub unsafe fn m5u_touch_get_detail(_index: c_int, out: *mut m5u_touch_detail_t) -> bool {
        if !out.is_null() {
            *out = m5u_touch_detail_t::default();
        }
        false
    }
    pub unsafe fn m5u_rtc_is_enabled() -> bool {
        true
    }

    pub unsafe fn m5u_power_axp2101_disable_irq(_mask: u64) -> bool {
        false
    }
    pub unsafe fn m5u_power_axp2101_enable_irq(_mask: u64) -> bool {
        false
    }
    pub unsafe fn m5u_power_axp2101_clear_irq_statuses() -> bool {
        false
    }
    pub unsafe fn m5u_power_axp2101_get_irq_statuses() -> u64 {
        0
    }
    pub unsafe fn m5u_power_axp2101_is_bat_charger_under_temperature_irq() -> bool {
        false
    }
    pub unsafe fn m5u_power_axp2101_is_bat_charger_over_temperature_irq() -> bool {
        false
    }
    pub unsafe fn m5u_power_axp2101_is_vbus_insert_irq() -> bool {
        false
    }
    pub unsafe fn m5u_power_axp2101_is_vbus_remove_irq() -> bool {
        false
    }

    pub unsafe fn m5u_log_print(_text: *const c_char) {}
    pub unsafe fn m5u_log_println(_text: *const c_char) {}
    pub unsafe fn m5u_log_level(_level: c_int, _text: *const c_char) {}
    pub unsafe fn m5u_sd_begin() -> bool {
        false
    }
}

#[cfg(not(target_os = "espidf"))]
pub use host_stubs::*;