21 #ifndef ARCH_GPIO_HPP_INCLUDED 22 #define ARCH_GPIO_HPP_INCLUDED 27 #include <type_traits> 35 template<
char port,
unsigned pin_no >
38 static_assert((port >=
'A') && (port <=
'I'),
"invalid GPIO port");
39 static_assert(pin_no < 16,
"invalid GPIO pin-no");
49 static constexpr uint32_t
pin_mask = (uint32_t)0x1 << pin_no;
53 template<freq_t value>
56 static_assert((value ==
mhz(2)) ||
60 "Illegal frequency for gpio output speed (allowed: mhz(2), mhz(25), mhz(50), mhz(100))");
63 typename GPIOx::template OSPEEDRx<pin_no>,
64 (value ==
mhz(25) ? 1 :
65 value ==
mhz(50) ? 2 :
66 value ==
mhz(100) ? 3 :
71 template<
unsigned value>
72 struct alt_func_num_impl
74 static_assert(value < 16,
"illegal alternate function number");
76 using type =
typename std::conditional<
111 template<freq_t value>
132 template<
unsigned value>
158 template<
char port,
unsigned pin_no, gpio_active_state active_state = gpio_active_state::high >
166 typename gpio_type::mode::input
174 template<
char port,
unsigned pin_no, gpio_active_state active_state = gpio_active_state::high >
182 typename gpio_type::mode::output
190 template<
char port,
unsigned pin_no, freq_t speed = mhz(2)>
198 typename gpio_type::mode::analog,
199 typename gpio_type::output_type::push_pull,
200 typename gpio_type::template speed< speed >,
201 typename gpio_type::resistor::floating
209 template<
char port,
unsigned pin_no, gpio_active_state active_state = gpio_active_state::high>
211 :
public gpio_led_base< gpio_output< port, pin_no, active_state > >
217 typename gpio_type::output_type::push_pull
223 #endif // ARCH_GPIO_HPP_INCLUDED
typename speed_impl< value >::type speed
I/O output speed.
Definition: gpio.hpp:112
typename alt_func_num_impl< value >::type alt_func_num
Alternate function selection.
Definition: gpio.hpp:133
static uint32_t read_output_bit()
Definition: gpio.hpp:149
static constexpr uint32_t pin_mask
Definition: gpio.hpp:49
typename mpl::make_typelist< sane_typelist<>, Tp... >::type typelist
static constexpr freq_t mhz(unsigned long long x)
static uint32_t read_input_bit()
Definition: gpio.hpp:145
static void reset()
Definition: gpio.hpp:141
typelist< typename gpio_type::resources, typename gpio_type::output_type::push_pull > resources
Definition: gpio.hpp:218
static __always_inline void store(Tp const value)
General-purpose and alternate-function I/Os (GPIOs and AFIOs)
Definition: gpio.hpp:40
typelist< typename gpio_type::resources, typename gpio_type::mode::analog, typename gpio_type::output_type::push_pull, typename gpio_type::template speed< speed >, typename gpio_type::resistor::floating > resources
Definition: gpio.hpp:202
typelist< typename gpio_type::resources, typename gpio_type::mode::output > resources
Definition: gpio.hpp:183
static __always_inline value_type test(value_type const value)