13
13
14
14
#include < modm/architecture/interface/spi_device.hpp>
15
15
16
- // TODO Prototype
17
- template <class Spi >
18
- concept SupportsBit16 = requires () {
19
- Spi::setDataSize (Spi::DataSize::Bit16);
20
- };
21
-
22
16
namespace modm
23
17
{
24
18
@@ -41,7 +35,7 @@ class Ili9341SPIInterface: public ili9341, public modm::SpiDevice<SPI>
41
35
__attribute__ ((noinline)) void
42
36
writeCommand (Command command)
43
37
{
44
- if constexpr ( SupportsBit16 <SPI> )
38
+ if constexpr ( spi::Support_DataSize_Bit16 <SPI> )
45
39
SPI::setDataSize (SPI::DataSize::Bit8);
46
40
Dc::reset (); // enable command
47
41
SPI::transferBlocking (i (command));
@@ -50,7 +44,7 @@ class Ili9341SPIInterface: public ili9341, public modm::SpiDevice<SPI>
50
44
__attribute__ ((noinline)) void
51
45
writeCommand (Command command, uint8_t const *args, std::size_t length)
52
46
{
53
- if constexpr ( SupportsBit16 <SPI> )
47
+ if constexpr ( spi::Support_DataSize_Bit16 <SPI> )
54
48
SPI::setDataSize (SPI::DataSize::Bit8);
55
49
Dc::reset (); // enable command
56
50
SPI::transferBlocking (i (command));
@@ -63,39 +57,39 @@ class Ili9341SPIInterface: public ili9341, public modm::SpiDevice<SPI>
63
57
void
64
58
writeData (uint8_t const *data, std::size_t length)
65
59
{
66
- if constexpr ( SupportsBit16 <SPI> )
60
+ if constexpr ( spi::Support_DataSize_Bit16 <SPI> )
67
61
SPI::setDataSize (SPI::DataSize::Bit8);
68
62
SPI::transferBlocking (data, nullptr , length);
69
63
}
70
64
71
65
void
72
66
writeData (color::Rgb565 rgb565)
73
67
{
74
- if constexpr ( SupportsBit16 <SPI> )
68
+ if constexpr ( spi::Support_DataSize_Bit16 <SPI> )
75
69
SPI::setDataSize (SPI::DataSize::Bit16);
76
70
SPI::transferBlocking (rgb565.color );
77
71
}
78
72
79
73
void
80
74
writeDataRepeat (color::Rgb565 rgb565, std::size_t repeat)
81
75
{
82
- if constexpr ( SupportsBit16 <SPI> )
76
+ if constexpr ( spi::Support_DataSize_Bit16 <SPI> )
83
77
SPI::setDataSize (SPI::DataSize::Bit16);
84
78
SPI::transferBlocking16 (rgb565.color , repeat);
85
79
}
86
80
87
81
void
88
82
writeData (color::Rgb565 const *data, std::size_t length)
89
83
{
90
- if constexpr ( SupportsBit16 <SPI> )
84
+ if constexpr ( spi::Support_DataSize_Bit16 <SPI> )
91
85
SPI::setDataSize (SPI::DataSize::Bit16);
92
86
SPI::transferBlocking16 (reinterpret_cast <const uint16_t *>(data), nullptr , length);
93
87
}
94
88
95
89
void
96
90
writeCommandValue8 (Command command, uint8_t value)
97
91
{
98
- if constexpr ( SupportsBit16 <SPI> )
92
+ if constexpr ( spi::Support_DataSize_Bit16 <SPI> )
99
93
SPI::setDataSize (SPI::DataSize::Bit8);
100
94
writeCommand (command, &value, 1 );
101
95
}
@@ -105,7 +99,7 @@ class Ili9341SPIInterface: public ili9341, public modm::SpiDevice<SPI>
105
99
{
106
100
uint8_t b[4 ];
107
101
108
- if constexpr ( SupportsBit16 <SPI> )
102
+ if constexpr ( spi::Support_DataSize_Bit16 <SPI> )
109
103
SPI::setDataSize (SPI::DataSize::Bit8);
110
104
Dc::reset ();
111
105
SPI::transferBlocking (i (command) << 1 );
@@ -115,7 +109,7 @@ class Ili9341SPIInterface: public ili9341, public modm::SpiDevice<SPI>
115
109
uint8_t
116
110
readData (Command command)
117
111
{
118
- if constexpr ( SupportsBit16 <SPI> )
112
+ if constexpr ( spi::Support_DataSize_Bit16 <SPI> )
119
113
SPI::setDataSize (SPI::DataSize::Bit8);
120
114
writeCommand (command);
121
115
return SPI::transferBlocking (0 );
0 commit comments