-
Notifications
You must be signed in to change notification settings - Fork 56
Expand file tree
/
Copy pathesp32_mock.h
More file actions
35 lines (27 loc) · 1.27 KB
/
Copy pathesp32_mock.h
File metadata and controls
35 lines (27 loc) · 1.27 KB
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
// Copyright 2024-2025 Jan Delgado jdelgado@gmx.net
#ifndef TEST_ESP32_MOCK_H_
#define TEST_ESP32_MOCK_H_
#include <stdint.h>
#include "esp-idf/driver/ledc.h" // for ledc_*_t types
struct Esp32State {
int64_t timer_us = 0;
ledc_channel_config_t channel_config = {};
ledc_timer_config_t timer_config = {};
esp32_mock_ledc_update_duty_args update_duty[LEDC_CHANNEL_MAX] = {};
esp32_mock_ledc_set_duty_args set_duty[LEDC_CHANNEL_MAX] = {};
// Per-channel duty/hpoint as tracked by real LEDC hardware registers,
// written by both ledc_channel_config() and ledc_set_duty(), and read
// back by ledc_get_duty()/ledc_get_hpoint().
uint32_t duty[LEDC_CHANNEL_MAX] = {};
int hpoint[LEDC_CHANNEL_MAX] = {};
void setTimer(int64_t t) { timer_us = t; }
int64_t getTimer() const { return timer_us; }
ledc_channel_config_t getLedcChannelConfig() const { return channel_config; }
ledc_timer_config_t getLedcTimerConfig() const { return timer_config; }
esp32_mock_ledc_set_duty_args getLedcSetDuty(ledc_channel_t ch) const { return set_duty[ch]; }
esp32_mock_ledc_update_duty_args getLedcUpdateDuty(ledc_channel_t ch) const {
return update_duty[ch];
}
};
void esp32MockSetInstance(Esp32State* state);
#endif // TEST_ESP32_MOCK_H_