Sound Byte Libs 29c5ff3
C++ firmware library for audio applications on 32-bit ARM Cortex-M processors
Loading...
Searching...
No Matches
input.hpp
Go to the documentation of this file.
1/**
2 * @file input.hpp
3 * @brief Encoder input convenience functions
4 * @ingroup hal
5 *
6 * Composes GPIO driver reads with Encoder update in a single call.
7 *
8 * Usage:
9 * #include <sbl/hal/encoder/input.hpp>
10 *
11 * sbl::encoder::read<sbl::driver::Gpio>(enc, handle_a, handle_b);
12 */
13
14#ifndef SBL_HAL_ENCODER_INPUT_HPP_
15#define SBL_HAL_ENCODER_INPUT_HPP_
16
17#include <sbl/types.hpp>
19
20namespace sbl {
21namespace encoder {
22
24
25/**
26 * @brief Read quadrature GPIO pins and feed into Encoder
27 *
28 * @tparam Driver GPIO driver type (e.g., sbl::driver::Gpio)
29 * @param enc Encoder instance to update
30 * @param a GPIO handle for channel A
31 * @param b GPIO handle for channel B
32 *
33 * @note ISR-safe — two GPIO register reads
34 */
35template<typename Driver>
36inline void read(Encoder& enc, const GpioHandle& a, const GpioHandle& b) {
37 enc.update(Driver::read(a), Driver::read(b));
38}
39
40} // namespace encoder
41} // namespace sbl
42
43#endif // SBL_HAL_ENCODER_INPUT_HPP_
Quadrature encoder with Gray code state machine and position tracking.
Definition encoder.hpp:31
void update(bool a, bool b)
Feed quadrature signals.
Definition encoder.hpp:44
Quadrature encoder component — Gray code state machine.
void read(Encoder &enc, const GpioHandle &a, const GpioHandle &b)
Read quadrature GPIO pins and feed into Encoder.
Definition input.hpp:36
Root namespace for all Sound Byte Libs functionality.
Definition aliases.hpp:24
GPIO pin handle with port, pin number, and polarity.
Definition handle.hpp:29
Common types for SBL hardware abstraction.