M5UnitUnified 0.6.3 git rev:e38fc73
Loading...
Searching...
No Matches
pin.hpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2024 M5Stack Technology CO LTD
3 *
4 * SPDX-License-Identifier: MIT
5 */
11#ifndef M5_UNIT_COMPONENT_PIN_HPP
12#define M5_UNIT_COMPONENT_PIN_HPP
13#include <cstdint>
14
15namespace m5 {
16namespace unit {
17namespace gpio {
18
25public:
27 explicit pin_backup_t(int pin_num = 1);
29 inline void setPin(int pin_num)
30 {
31 _pin_num = pin_num;
32 }
34 inline int8_t getPin(void) const
35 {
36 return _pin_num;
37 }
39 inline int16_t getInFuncNum(void) const
40 {
41 return _in_func_num;
42 }
44 void backup(void);
46 void restore(void);
47
48private:
49 uint32_t _io_mux_gpio_reg{};
50 uint32_t _gpio_pin_reg{};
51 uint32_t _gpio_func_out_reg{};
52 uint32_t _gpio_func_in_reg{};
53 int16_t _in_func_num{-1};
54 int8_t _pin_num{-1}; // GPIO_NUM_NC
55 bool _gpio_enable{};
56};
57
58} // namespace gpio
59} // namespace unit
60} // namespace m5
61#endif
Save and restore GPIO pin configuration.
Definition pin.hpp:24
int16_t getInFuncNum(void) const
Get the peripheral input signal routed from this pin at backup(), or -1 if none.
Definition pin.hpp:39
int8_t getPin(void) const
Get the target pin number.
Definition pin.hpp:34
pin_backup_t(int pin_num=1)
Constructor.
Definition pin.cpp:129
void setPin(int pin_num)
Set the target pin number.
Definition pin.hpp:29
void restore(void)
Restore saved pin configuration.
Definition pin.cpp:137
void backup(void)
Save current pin configuration.
Definition pin.cpp:133
Top level namespace of M5Stack.
Definition test_helper.hpp:20
Unit-related namespace.