M5Unit-HUB 0.3.1 git rev:3cfc07a
Loading...
Searching...
No Matches
unit_PCA9548AP.hpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2024 M5Stack Technology CO LTD
3 *
4 * SPDX-License-Identifier: MIT
5 */
10#ifndef M5_UNIT_PAHUB_UNIT_PCA9548AP_HPP
11#define M5_UNIT_PAHUB_UNIT_PCA9548AP_HPP
12
13#include <M5UnitComponent.hpp>
14#include <array>
15
16namespace m5 {
17namespace unit {
18
24class UnitPCA9548AP : public Component {
25 M5_UNIT_COMPONENT_HPP_BUILDER(UnitPCA9548AP, 0x70);
26
27public:
28 constexpr static uint8_t MAX_CHANNEL{6};
29
32 explicit UnitPCA9548AP(const uint8_t addr = DEFAULT_ADDRESS);
33 virtual ~UnitPCA9548AP() = default;
34
39 uint8_t currentChannel() const
40 {
41 return _current;
42 }
43
49 bool readChannel(uint8_t& bits);
50
51protected:
52 virtual m5::hal::error::error_t select_channel(const uint8_t ch) override;
53 virtual std::shared_ptr<Adapter> ensure_adapter(const uint8_t ch) override;
54
55protected:
56 uint8_t _current{0xFF}; // current channel 0 ~ MAX_CHANNEL
57};
58
59} // namespace unit
60} // namespace m5
61#endif
PCA9548AP I2C multiplexer unit.
UnitPCA9548AP(const uint8_t addr=DEFAULT_ADDRESS)
Constructor.
Definition unit_PCA9548AP.cpp:25
bool readChannel(uint8_t &bits)
Read channel status bits.
Definition unit_PCA9548AP.cpp:33
static constexpr uint8_t MAX_CHANNEL
Maximum number of channels.
Definition unit_PCA9548AP.hpp:28
uint8_t currentChannel() const
Get current channel.
Definition unit_PCA9548AP.hpp:39
Top level namespace of M5Stack.
Unit-related namespace.