M5UnitUnified 0.4.6 git rev:c61a63c
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 void backup(void);
41 void restore(void);
42
43private:
44 uint32_t _io_mux_gpio_reg{};
45 uint32_t _gpio_pin_reg{};
46 uint32_t _gpio_func_out_reg{};
47 uint32_t _gpio_func_in_reg{};
48 int16_t _in_func_num{-1};
49 int8_t _pin_num{-1}; // GPIO_NUM_NC
50 bool _gpio_enable{};
51};
52
53} // namespace gpio
54} // namespace unit
55} // namespace m5
56#endif
Save and restore GPIO pin configuration.
Definition pin.hpp:24
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:22
void setPin(int pin_num)
Set the target pin number.
Definition pin.hpp:29
void restore(void)
Restore saved pin configuration.
Definition pin.cpp:61
void backup(void)
Save current pin configuration.
Definition pin.cpp:29
Top level namespace of M5Stack.
Definition test_helper.hpp:20
Unit-related namespace.