ESPHome  2024.9.2
datatypes.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <cstdint>
4 
5 #include "esphome/core/helpers.h"
6 
7 namespace esphome {
8 
9 namespace internal {
10 
12 template<typename T> class BigEndianLayout {
13  public:
14  constexpr14 operator T() { return convert_big_endian(val_); }
15 
16  private:
17  T val_;
18 } __attribute__((packed));
19 
21 template<typename T> class LittleEndianLayout {
22  public:
23  constexpr14 operator T() { return convert_little_endian(val_); }
24 
25  private:
26  T val_;
27 } __attribute__((packed));
28 
29 } // namespace internal
30 
32 struct uint24_t { // NOLINT(readability-identifier-naming)
33  operator uint32_t() { return val; }
34  uint32_t val : 24;
35 } __attribute__((packed));
36 
38 struct int24_t { // NOLINT(readability-identifier-naming)
39  operator int32_t() { return val; }
40  int32_t val : 24;
41 } __attribute__((packed));
42 
43 // Integer types in big or little endian data layout.
60 
61 } // namespace esphome
24-bit unsigned integer type, transparently converting to 32-bit.
Definition: datatypes.h:32
constexpr14 T convert_big_endian(T val)
Convert a value between host byte order and big endian (most significant byte first) order...
Definition: helpers.h:239
24-bit signed integer type, transparently converting to 32-bit.
Definition: datatypes.h:38
uint32_t val
Definition: datatypes.h:34
Wrapper class for memory using big endian data layout, transparently converting it to native order...
Definition: datatypes.h:12
constexpr14 T convert_little_endian(T val)
Convert a value between host byte order and little endian (least significant byte first) order...
Definition: helpers.h:248
class esphome::internal::BigEndianLayout __attribute__((packed))
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
uint32_t val
Definition: datatypes.h:133
Wrapper class for memory using big endian data layout, transparently converting it to native order...
Definition: datatypes.h:21