31#ifndef ETL_IO_PORT_INCLUDED
32#define ETL_IO_PORT_INCLUDED
41#include "static_assert.h"
50 template <
typename, u
intptr_t>
53 namespace private_io_port
58 template <
typename TIO_Port>
59 class iterator :
public etl::iterator<ETL_OR_STD::forward_iterator_tag, typename TIO_Port::value_type>
78 typedef typename TIO_Port::value_type value_type;
153 template <
typename TIO_Port>
154 class const_iterator :
public etl::iterator<ETL_OR_STD::forward_iterator_tag, const typename TIO_Port::value_type>
171 typedef const typename TIO_Port::value_type value_type;
200 const_iterator& operator=(
const iterator_type& other)
209 const_iterator& operator=(
const const_iterator& other)
256 template <
typename T, u
intptr_t Address = 0>
261 ETL_STATIC_ASSERT(etl::is_integral<T>::value,
"Not an integral type");
263 typedef T value_type;
264 typedef volatile T* pointer;
265 typedef volatile const T* const_pointer;
266 typedef volatile T& reference;
267 typedef volatile const T& const_reference;
277 return iterator(*
this);
285 return const_iterator(*
this);
293 return const_iterator(*
this);
299 operator value_type()
const
301 return *
reinterpret_cast<const_pointer
>(Address);
309 return *
reinterpret_cast<const_pointer
>(Address);
317 *
reinterpret_cast<pointer
>(Address) = value_;
325 *
reinterpret_cast<pointer
>(Address) = value_;
334 pointer address =
reinterpret_cast<pointer
>(Address);
335 value_type temp = *address;
347 pointer address =
reinterpret_cast<pointer
>(Address);
348 value_type temp = *address;
360 pointer address =
reinterpret_cast<pointer
>(Address);
361 value_type temp = *address;
373 pointer address =
reinterpret_cast<pointer
>(Address);
374 value_type temp = *address;
386 pointer address =
reinterpret_cast<pointer
>(Address);
387 value_type temp = *address;
399 return ~(*
reinterpret_cast<pointer
>(Address));
407 return reinterpret_cast<pointer
>(Address);
415 return reinterpret_cast<const_pointer
>(Address);
427 template <
typename T, u
intptr_t Address = 0>
432 ETL_STATIC_ASSERT(etl::is_integral<T>::value,
"Not an integral type");
434 typedef T value_type;
435 typedef volatile T* pointer;
436 typedef volatile const T* const_pointer;
437 typedef volatile T& reference;
438 typedef volatile const T& const_reference;
447 return const_iterator(*
this);
455 return const_iterator(*
this);
461 operator value_type()
const
463 return *
reinterpret_cast<const_pointer
>(Address);
471 return *
reinterpret_cast<const_pointer
>(Address);
479 return reinterpret_cast<pointer
>(Address);
487 return reinterpret_cast<const_pointer
>(Address);
502 template <
typename T, u
intptr_t Address = 0>
507 ETL_STATIC_ASSERT(etl::is_integral<T>::value,
"Not an integral type");
509 typedef T value_type;
510 typedef volatile T* pointer;
511 typedef volatile const T* const_pointer;
512 typedef volatile T& reference;
513 typedef volatile const T& const_reference;
522 return iterator(*
this);
530 *
reinterpret_cast<pointer
>(Address) = value;
538 *
reinterpret_cast<pointer
>(Address) = value_;
546 return reinterpret_cast<pointer
>(Address);
554 return reinterpret_cast<const_pointer
>(Address);
569 template <typename T, uintptr_t Address = 0>
574 ETL_STATIC_ASSERT(etl::is_integral<T>::value,
"Not an integral type");
576 typedef T value_type;
577 typedef volatile T* pointer;
578 typedef volatile const T* const_pointer;
579 typedef volatile T& reference;
580 typedef volatile const T& const_reference;
589 : shadow_value(value_type())
598 return iterator(*
this);
606 return const_iterator(*
this);
614 return const_iterator(*
this);
620 operator value_type()
const
638 shadow_value = value_;
639 *
reinterpret_cast<pointer
>(Address) = shadow_value;
647 shadow_value = value_;
648 *
reinterpret_cast<pointer
>(Address) = shadow_value;
657 shadow_value |= value;
658 *
reinterpret_cast<pointer
>(Address) = shadow_value;
668 shadow_value &= value;
669 *
reinterpret_cast<pointer
>(Address) = shadow_value;
679 shadow_value ^= value;
680 *
reinterpret_cast<pointer
>(Address) = shadow_value;
690 shadow_value <<= shift;
691 *
reinterpret_cast<pointer
>(Address) = shadow_value;
701 shadow_value >>= shift;
702 *
reinterpret_cast<pointer
>(Address) = shadow_value;
712 return ~shadow_value;
720 return reinterpret_cast<pointer
>(Address);
735 template <
typename T>
740 ETL_STATIC_ASSERT(etl::is_integral<T>::value,
"Not an integral type");
742 typedef T value_type;
743 typedef volatile T* pointer;
744 typedef volatile const T* const_pointer;
745 typedef volatile T& reference;
746 typedef volatile const T& const_reference;
755 : address(ETL_NULLPTR)
763 : address(reinterpret_cast<pointer>(address_))
771 : address(reinterpret_cast<pointer>(other_.address))
780 address = other_.address;
789 return iterator(*
this);
797 return const_iterator(*
this);
805 return const_iterator(*
this);
813 value_type temp = *address;
825 value_type temp = *address;
837 value_type temp = *address;
849 value_type temp = *address;
861 value_type temp = *address;
881 address =
reinterpret_cast<pointer
>(address_);
903 operator value_type()
const
942 template <
typename T>
947 ETL_STATIC_ASSERT(etl::is_integral<T>::value,
"Not an integral type");
949 typedef T value_type;
950 typedef volatile T* pointer;
951 typedef volatile const T* const_pointer;
952 typedef volatile T& reference;
953 typedef volatile const T& const_reference;
961 : address(ETL_NULLPTR)
969 : address(reinterpret_cast<pointer>(address_))
977 : address(reinterpret_cast<pointer>(other_.address))
986 address = other_.address;
995 return const_iterator(*
this);
1003 return const_iterator(*
this);
1011 address =
reinterpret_cast<pointer
>(address_);
1025 operator value_type()
const
1050 template <
typename T>
1055 ETL_STATIC_ASSERT(etl::is_integral<T>::value,
"Not an integral type");
1057 typedef T value_type;
1058 typedef volatile T* pointer;
1059 typedef volatile const T* const_pointer;
1060 typedef volatile T& reference;
1061 typedef volatile const T& const_reference;
1069 : address(ETL_NULLPTR)
1077 : address(reinterpret_cast<pointer>(address_))
1085 : address(reinterpret_cast<pointer>(other_.address))
1094 address = other_.address;
1103 return iterator(*
this);
1111 address =
reinterpret_cast<pointer
>(address_);
1158 template <typename T>
1163 ETL_STATIC_ASSERT(etl::is_integral<T>::value,
"Not an integral type");
1165 typedef T value_type;
1166 typedef volatile T* pointer;
1167 typedef volatile const T* const_pointer;
1168 typedef volatile T& reference;
1169 typedef volatile const T& const_reference;
1179 , address(ETL_NULLPTR)
1188 , address(reinterpret_cast<pointer>(address_))
1196 : shadow_value(other_.shadow_value)
1197 , address(reinterpret_cast<pointer>(other_.address))
1206 shadow_value = other_.shadow_value;
1207 address = other_.address;
1216 return iterator(*
this);
1224 return const_iterator(*
this);
1232 return const_iterator(*
this);
1240 shadow_value |= value;
1241 *address = shadow_value;
1251 shadow_value &= value;
1252 *address = shadow_value;
1262 shadow_value ^= value;
1263 *address = shadow_value;
1273 shadow_value <<= shift;
1274 *address = shadow_value;
1284 shadow_value >>= shift;
1285 *address = shadow_value;
1295 return ~shadow_value;
1303 address =
reinterpret_cast<pointer
>(address_);
1325 operator value_type()
const
1327 return shadow_value;
1335 return shadow_value;
1343 shadow_value = value_;
1344 *address = shadow_value;
1352 shadow_value = value_;
1353 *address = shadow_value;
1370 return shadow_value;
void set_address(void *address_)
Set the IO port address.
Definition io_port.h:1009
const_pointer get_address() const
Get the IO port address.
Definition io_port.h:1017
value_type read() const
Read.
Definition io_port.h:1033
io_port_ro & operator=(const io_port_ro &other_)
Assignment.
Definition io_port.h:984
const_iterator citer() const
Get a const_iterator to this port.
Definition io_port.h:1001
io_port_ro(void *address_)
Constructor.
Definition io_port.h:968
io_port_ro()
Default constructor.
Definition io_port.h:960
const_iterator iter() const
Get a const_iterator to this port.
Definition io_port.h:993
io_port_ro(const io_port_ro &other_)
Copy Constructor.
Definition io_port.h:976
Read only port.
Definition io_port.h:429
value_type read() const
Read.
Definition io_port.h:469
const_iterator citer() const
Get a const_iterator to this port.
Definition io_port.h:453
const_pointer get_address() const
Get the IO port address.
Definition io_port.h:485
const_iterator iter() const
Get a const_iterator to this port.
Definition io_port.h:445
pointer get_address()
Get the IO port address.
Definition io_port.h:477
io_port_rw & operator>>=(int shift)
Right-Shift-Equals operator.
Definition io_port.h:859
value_type read() const
Read.
Definition io_port.h:911
const_iterator citer() const
Get a const_iterator to this port.
Definition io_port.h:803
const_pointer get_address() const
Get the IO port address.
Definition io_port.h:895
io_port_rw & operator&=(value_type value)
And-Equals operator.
Definition io_port.h:823
pointer get_address()
Get the IO port address.
Definition io_port.h:887
io_port_rw & operator=(const io_port_rw &other_)
Assignment.
Definition io_port.h:778
io_port_rw & operator<<=(int shift)
Left-Shift-Equals operator.
Definition io_port.h:847
const_iterator iter() const
Get a const_iterator to this port.
Definition io_port.h:795
io_port_rw(const io_port_rw &other_)
Copy Constructor.
Definition io_port.h:770
void write(value_type value_)
Write.
Definition io_port.h:919
void set_address(void *address_)
Set the IO port address.
Definition io_port.h:879
iterator iter()
Get an iterator to this port.
Definition io_port.h:787
value_type operator~() const
Not operator.
Definition io_port.h:871
io_port_rw & operator|=(value_type value)
Or-Equals operator.
Definition io_port.h:811
io_port_rw & operator=(value_type value_)
Write.
Definition io_port.h:927
io_port_rw & operator^=(value_type value)
Exclusive-Or-Equals operator.
Definition io_port.h:835
io_port_rw(void *address_)
Constructor.
Definition io_port.h:762
io_port_rw()
Default constructor.
Definition io_port.h:754
Read write port.
Definition io_port.h:258
io_port_rw & operator&=(value_type value)
And-Equals operator.
Definition io_port.h:345
io_port_rw & operator>>=(int shift)
Right-Shift-Equals operator.
Definition io_port.h:384
io_port_rw & operator=(value_type value_)
Write.
Definition io_port.h:323
pointer get_address()
Get the IO port address.
Definition io_port.h:405
io_port_rw & operator^=(value_type value)
Exclusive-Or-Equals operator.
Definition io_port.h:358
value_type operator~() const
Not operator.
Definition io_port.h:397
const_pointer get_address() const
Get the IO port address.
Definition io_port.h:413
io_port_rw & operator<<=(int shift)
Left-Shift-Equals operator.
Definition io_port.h:371
void write(value_type value_)
Write.
Definition io_port.h:315
value_type read() const
Read.
Definition io_port.h:307
io_port_rw & operator|=(value_type value)
Or-Equals operator.
Definition io_port.h:332
iterator iter()
Get an iterator to this port.
Definition io_port.h:275
const_iterator iter() const
Get a const_iterator to this port.
Definition io_port.h:283
const_iterator citer() const
Get a const_iterator to this port.
Definition io_port.h:291
io_port_wo(const io_port_wo &other_)
Copy Constructor.
Definition io_port.h:1084
void set_address(void *address_)
Set the IO port address.
Definition io_port.h:1109
io_port_wo & operator=(const io_port_wo &other_)
Assignment.
Definition io_port.h:1092
pointer get_address()
Get the IO port address.
Definition io_port.h:1117
iterator iter()
Get an iterator to this port.
Definition io_port.h:1101
void operator=(value_type value)
Write.
Definition io_port.h:1141
io_port_wo(void *address_)
Constructor.
Definition io_port.h:1076
void write(value_type value_)
Write.
Definition io_port.h:1133
const_pointer get_address() const
Get the IO port address.
Definition io_port.h:1125
io_port_wo()
Default constructor.
Definition io_port.h:1068
Write only port.
Definition io_port.h:504
const_pointer get_address() const
Get the IO port address.
Definition io_port.h:552
iterator iter()
Get an iterator to this port.
Definition io_port.h:520
void operator=(value_type value)
Write.
Definition io_port.h:528
pointer get_address()
Get the IO port address.
Definition io_port.h:544
void write(value_type value_)
Write.
Definition io_port.h:536
io_port_wos & operator=(const io_port_wos &other_)
Assignment.
Definition io_port.h:1204
const_pointer get_address() const
Get the IO port address.
Definition io_port.h:1317
void write(value_type value_)
Write.
Definition io_port.h:1341
value_type operator~() const
Not operator.
Definition io_port.h:1293
pointer get_address()
Get the IO port address.
Definition io_port.h:1309
io_port_wos & operator^=(value_type value)
Exclusive-Or-Equals operator.
Definition io_port.h:1260
void set_address(void *address_)
Set the IO port address.
Definition io_port.h:1301
io_port_wos & operator&=(value_type value)
And-Equals operator.
Definition io_port.h:1249
io_port_wos & operator*()
Read / Write.
Definition io_port.h:1360
io_port_wos & operator=(value_type value_)
Write.
Definition io_port.h:1350
iterator iter()
Get an iterator to this port.
Definition io_port.h:1214
const_reference operator*() const
Read.
Definition io_port.h:1368
io_port_wos & operator<<=(int shift)
Left-Shift-Equals operator.
Definition io_port.h:1271
io_port_wos(void *address_)
Constructor.
Definition io_port.h:1186
io_port_wos()
Default constructor.
Definition io_port.h:1177
value_type read() const
Read.
Definition io_port.h:1333
const_iterator citer() const
Get a const_iterator to this port.
Definition io_port.h:1230
const_iterator iter() const
Get a const_iterator to this port.
Definition io_port.h:1222
io_port_wos(const io_port_wos &other_)
Copy Constructor.
Definition io_port.h:1195
io_port_wos & operator>>=(int shift)
Right-Shift-Equals operator.
Definition io_port.h:1282
io_port_wos & operator|=(value_type value)
Or-Equals operator.
Definition io_port.h:1238
Write only port with shadow register.
Definition io_port.h:571
const_iterator iter() const
Get a const_iterator to this port.
Definition io_port.h:604
io_port_wos & operator>>=(int shift)
Right-Shift-Equals operator.
Definition io_port.h:699
pointer get_address()
Get the IO port address.
Definition io_port.h:718
iterator iter()
Get an iterator to this port.
Definition io_port.h:596
io_port_wos & operator<<=(int shift)
Left-Shift-Equals operator.
Definition io_port.h:688
void write(value_type value_)
Write.
Definition io_port.h:636
io_port_wos & operator=(value_type value_)
Write.
Definition io_port.h:645
value_type operator~() const
Not operator.
Definition io_port.h:710
const_iterator citer() const
Get a const_iterator to this port.
Definition io_port.h:612
io_port_wos()
Default constructor.
Definition io_port.h:588
io_port_wos & operator^=(value_type value)
Exclusive-Or-Equals operator.
Definition io_port.h:677
io_port_wos & operator&=(value_type value)
And-Equals operator.
Definition io_port.h:666
io_port_wos & operator|=(value_type value)
Or-Equals operator.
Definition io_port.h:655
value_type read() const
Read.
Definition io_port.h:628
Common io_port const_iterator implementation.
Definition io_port.h:155
const_iterator operator++(int)
Post-increment operator.
Definition io_port.h:234
TIO_Port io_port_type
Types.
Definition io_port.h:170
const_iterator & operator++()
Pre-increment operator.
Definition io_port.h:226
friend TIO_Port
Definition io_port.h:165
Common io_port iterator implementation.
Definition io_port.h:60
friend TIO_Port
Definition io_port.h:66
TIO_Port io_port_type
Types.
Definition io_port.h:77
iterator operator++(int)
Post-increment operator.
Definition io_port.h:132
iterator & operator++()
Pre-increment operator.
Definition io_port.h:124
friend class const_iterator
Definition io_port.h:72
iterator
Definition iterator.h:482