21 #ifndef _utl_com_spi_h__ 22 #define _utl_com_spi_h__ 66 template <
typename impl_t>
92 uint32_t
_clock ()
const {
return impl()._clock (); }
93 void _clock (uint32_t c) { impl()._clock (c); }
151 template<
typename _I>
153 for (
size_t nn {n} ; nn ; --nn)
154 *in++ = _tx_data (*out++);
164 template<
typename _I>
166 for (
size_t nn {n} ; nn ; --nn)
167 *in++ = _tx_data (0xFF);
190 virtual ~spi_i () =
default;
198 virtual uint32_t
_clock ()
const =0;
199 virtual void _clock (uint32_t) =0;
259 for (
size_t nn {n} ; nn ; --nn)
271 for (
size_t nn {n} ; nn ; --nn)
281 #if defined _utl_have_concepts 283 template <
typename T>
284 concept
bool Spi_i = requires (T t,
const T ct,
typename T::Sequence s) {
286 requires not_<std::is_copy_constructible<T>::value>::value;
287 requires not_<std::is_copy_assignable<T>::value>::value;
289 {ct.clock()} -> uint32_t;
290 {t.clock(0)} -> void;
295 namespace spi_i_details {
298 template <
class _Tp>
using try_cclock_t= decltype (declval<const _Tp>().clock());
299 template <
class _Tp>
using try_clock_t = decltype (declval<_Tp>().clock(declval<uint32_t>()));
300 template <
class _Tp>
using try_tx_t = decltype (declval<_Tp>().tx_data(declval<byte_t>()));
301 template <
class _Tp>
using try_rx_t = decltype (declval<_Tp>().rx_data());
304 template <
typename _Tp,
typename =
void>
308 template <
typename _Tp>
312 meta::use_if_same_t <try_cclock_t<_Tp>, uint32_t>,
313 meta::use_if_same_t <try_clock_t<_Tp>, void>,
314 meta::use_if_same_t <try_tx_t<_Tp>, byte_t>,
315 meta::use_if_same_t <try_rx_t<_Tp>, byte_t>
void void_t
void_t type alias
spi_i()=default
Allow constructor from derived only.
~spi_i()=default
Allow destructor from derived only.
void clock(uint32_t c)
set clock frequency of the bus
void clock(uint32_t c)
set clock frequency of the bus
decltype(declval< _Tp >().rx_data()) try_rx_t
A virtual base class implementation.
byte_t tx_data(byte_t out)
byte_t tx_data(byte_t out)
STL's core language concepts.
byte_t _tx_data(byte_t b)
decltype(declval< _Tp >().tx_data(declval< byte_t >())) try_tx_t
decltype(declval< _Tp >().clock(declval< uint32_t >())) try_clock_t
uint32_t _clock() const
clock frequency of the bus [Hz]
uint8_t byte_t
8 bits wide
void _clock(uint32_t c)
set clock frequency of the bus [Hz]
decltype(declval< const _Tp >().clock()) try_cclock_t
type & operator=(const type &)=delete
Implementation detail main forward header.
Primary template to catch any non SPI interface types.