51 enum { type = type_pin_in };
54 enum { features = has_none };
83 enum { type = type_pin_out };
86 enum { features = has_none };
103 static void set(
bool x );
116 enum { type = type_pin_in_out };
119 enum { features = has_none };
154 static void set(
bool x );
169 enum { type = type_pin_oc };
172 enum { features = has_none };
190 static void set(
bool x );
211 enum { features = has_pullup };
230 enum { features = has_ad };
236 static void ad_init();
243 static unsigned int ad_get();
246 static unsigned int ad_bits();
249 static unsigned int ad_max();
274 template<
typename pin,
int flavour = pin::type >
277 ( flavour == bmptk::type_pin_in_out )
278 | ( flavour == bmptk::type_pin_oc ),
279 "pin_in_out_from requires a pin_in_out or a pin_oc"
284 template<
typename pin >
285 struct pin_in_out_from< pin, type_pin_in_out > :
public pin {};
288 template<
typename pin >
289 struct pin_in_out_from< pin, type_pin_oc > :
public pin {
324 template<
typename pin,
int flavour = pin::type >
327 ( flavour == bmptk::type_pin_oc )
328 | ( flavour == bmptk::type_pin_in_out ),
329 "pin_oc_from requires a pin_oc or a pin_in_out"
336 template<
typename pin >
337 class pin_oc_from< pin, type_pin_oc > :
public pin {};
342 template<
typename pin >
343 struct pin_oc_from< pin, type_pin_in_out > :
public pin_oc {
349 static void set(
bool x ){
354 pin::direction_set_input();
359 pin::direction_set_output();
390 template<
typename pin,
int flavour = pin::type >
393 ( flavour == bmptk::type_pin_out )
394 | ( flavour == bmptk::type_pin_in_out )
395 | ( flavour == bmptk::type_pin_oc ),
396 "pin_out_from requires a pin_out, pin_in_out or a pin_oc"
401 template<
class pin >
402 struct pin_out_from< pin, type_pin_out > :
public pin {};
405 template<
class pin >
406 struct pin_out_from< pin, type_pin_in_out > :
public pin_out {
414 pin::direction_set_output();
418 static void set(
bool x ){
424 template<
class pin >
425 struct pin_out_from< pin, type_pin_oc > :
public pin_out {
435 static void set(
bool x ){
458 template<
typename pin,
int flavour = pin::type >
461 ( flavour == bmptk::type_pin_in )
462 | ( flavour == bmptk::type_pin_in_out )
463 | ( flavour == bmptk::type_pin_oc ),
464 "pin_in_from requires a pin_out, pin_in_out or a pin_oc"
469 template<
class pin >
470 struct pin_out_from< pin, type_pin_in > :
public pin {};
473 template<
class pin >
474 struct pin_in_from< pin, type_pin_in_out > :
public pin_in {
482 pin::direction_set_input();
492 template<
class pin >
493 struct pin_in_from< pin, type_pin_oc > :
public pin_in {
540 template<
typename pin_or_port >
class invert :
public pin_or_port {};
545 template<
class t,
int flavour = t::type >
549 flavour == bmptk::type_pin_in,
550 "invert requires a pin or port"
555 template<
class pin >
556 struct invert< pin, type_pin_in > :
public pin {
565 template<
class pin >
566 struct invert< pin, type_pin_out > :
public pin {
569 static void set(
bool x ){
575 template<
class pin >
576 struct invert< pin, type_pin_in_out > :
public pin {
579 static void set(
bool x ){
590 template<
class pin >
591 struct invert< pin, type_pin_oc > :
public pin {
594 static void set(
bool x ){
613 template<
class pin,
int flavour = pin::type >
618 ( flavour == bmptk::type_pin_out )
619 | ( flavour == bmptk::type_pin_in_out )
620 | ( flavour == bmptk::type_pin_oc ),
621 "flipable requires a pin_out, pin_in_out or a pin_oc"
629 static void set(
bool x ){
646 template<
class pin,
int flavour >
bool flipable< pin, flavour >::value;
656 template<
class arg_pin,
int flavour = arg_pin::type >
661 ( flavour == bmptk::type_pin_in )
662 | ( flavour == bmptk::type_pin_in_out )
663 | ( flavour == bmptk::type_pin_oc ),
664 "flipable requires a pin_in, pin_in_out or a pin_oc"
699 template<
class pin,
int flavour >
bool rising_edge< pin, flavour >::last = 0;
714 template<
class arg_pin >
719 ( (
int)arg_pin::type == bmptk::type_pin_in )
720 | ( (
int)arg_pin::type == bmptk::type_pin_in_out )
721 | ( (
int)arg_pin::type == bmptk::type_pin_oc ),
722 "flipable requires a pin_in, pin_in_out or a pin_oc"
743 static bool last_value;
746 if( now >= last_time + interval ){
783 template<
typename port_out >
class tee :
public pin_out {};
787 template<
typename... >
class tee;
790 class tee<> :
public pin_out {
793 static void set(
bool b ){}
796 template<
typename arg_pin,
typename... tail_args >
797 struct tee< arg_pin, tail_args... > :
public pin_out {
800 ( (
int)arg_pin::type == bmptk::type_pin_out )
801 | ( (
int)arg_pin::type == bmptk::type_pin_in_out )
802 | ( (
int)arg_pin::type == bmptk::type_pin_oc ),
803 "flipable requires a pin_out, pin_in_out or a pin_oc"
806 typedef pin_out_from< arg_pin > pin;
808 typedef tee< tail_args... > tail;
815 static void set(
bool b ){
825 struct pin_in_out_dummy : pin_in_out {
827 static void direction_set_input(){}
828 static void direction_set_output(){}
829 static bool get(){
return 0; }
830 static void set(
bool x ){}