31#ifndef ETL_IO_PORT_INCLUDED
32#define ETL_IO_PORT_INCLUDED
42#include "static_assert.h"
48 template <
typename, u
intptr_t>
51 namespace private_io_port
56 template <
typename TIO_Port>
57 class iterator :
public etl::iterator<ETL_OR_STD::forward_iterator_tag, typename TIO_Port::value_type>
76 typedef typename TIO_Port::value_type value_type;
151 template <
typename TIO_Port>
152 class const_iterator :
public etl::iterator<ETL_OR_STD::forward_iterator_tag, const typename TIO_Port::value_type>
169 typedef const typename TIO_Port::value_type value_type;
198 const_iterator& operator =(
const iterator_type& other)
207 const_iterator& operator =(
const const_iterator& other)
254 template <
typename T, u
intptr_t Address = 0>
259 ETL_STATIC_ASSERT(etl::is_integral<T>::value,
"Not an integral type");
261 typedef T value_type;
262 typedef volatile T* pointer;
263 typedef volatile const T* const_pointer;
264 typedef volatile T& reference;
265 typedef volatile const T& const_reference;
275 return iterator(*
this);
283 return const_iterator(*
this);
291 return const_iterator(*
this);
297 operator value_type()
const
299 return *
reinterpret_cast<const_pointer
>(Address);
307 return *
reinterpret_cast<const_pointer
>(Address);
315 *
reinterpret_cast<pointer
>(Address) = value_;
323 *
reinterpret_cast<pointer
>(Address) = value_;
332 pointer address =
reinterpret_cast<pointer
>(Address);
333 value_type temp = *address;
345 pointer address =
reinterpret_cast<pointer
>(Address);
346 value_type temp = *address;
358 pointer address =
reinterpret_cast<pointer
>(Address);
359 value_type temp = *address;
371 pointer address =
reinterpret_cast<pointer
>(Address);
372 value_type temp = *address;
384 pointer address =
reinterpret_cast<pointer
>(Address);
385 value_type temp = *address;
397 return ~(*
reinterpret_cast<pointer
>(Address));
405 return reinterpret_cast<pointer
>(Address);
413 return reinterpret_cast<const_pointer
>(Address);
425 template <
typename T, u
intptr_t Address = 0>
430 ETL_STATIC_ASSERT(etl::is_integral<T>::value,
"Not an integral type");
432 typedef T value_type;
433 typedef volatile T* pointer;
434 typedef volatile const T* const_pointer;
435 typedef volatile T& reference;
436 typedef volatile const T& const_reference;
445 return const_iterator(*
this);
453 return const_iterator(*
this);
459 operator value_type()
const
461 return *
reinterpret_cast<const_pointer
>(Address);
469 return *
reinterpret_cast<const_pointer
>(Address);
477 return reinterpret_cast<pointer
>(Address);
485 return reinterpret_cast<const_pointer
>(Address);
500 template <
typename T, u
intptr_t Address = 0>
505 ETL_STATIC_ASSERT(etl::is_integral<T>::value,
"Not an integral type");
507 typedef T value_type;
508 typedef volatile T* pointer;
509 typedef volatile const T* const_pointer;
510 typedef volatile T& reference;
511 typedef volatile const T& const_reference;
520 return iterator(*
this);
528 *
reinterpret_cast<pointer
>(Address) = value;
536 *
reinterpret_cast<pointer
>(Address) = value_;
544 return reinterpret_cast<pointer
>(Address);
552 return reinterpret_cast<const_pointer
>(Address);
567 template <typename T, uintptr_t Address = 0>
572 ETL_STATIC_ASSERT(etl::is_integral<T>::value,
"Not an integral type");
574 typedef T value_type;
575 typedef volatile T* pointer;
576 typedef volatile const T* const_pointer;
577 typedef volatile T& reference;
578 typedef volatile const T& const_reference;
587 : shadow_value(value_type())
596 return iterator(*
this);
604 return const_iterator(*
this);
612 return const_iterator(*
this);
618 operator value_type()
const
636 shadow_value = value_;
637 *
reinterpret_cast<pointer
>(Address) = shadow_value;
645 shadow_value = value_;
646 *
reinterpret_cast<pointer
>(Address) = shadow_value;
655 shadow_value |= value;
656 *
reinterpret_cast<pointer
>(Address) = shadow_value;
666 shadow_value &= value;
667 *
reinterpret_cast<pointer
>(Address) = shadow_value;
677 shadow_value ^= value;
678 *
reinterpret_cast<pointer
>(Address) = shadow_value;
688 shadow_value <<= shift;
689 *
reinterpret_cast<pointer
>(Address) = shadow_value;
699 shadow_value >>= shift;
700 *
reinterpret_cast<pointer
>(Address) = shadow_value;
710 return ~shadow_value;
718 return reinterpret_cast<pointer
>(Address);
733 template <
typename T>
738 ETL_STATIC_ASSERT(etl::is_integral<T>::value,
"Not an integral type");
740 typedef T value_type;
741 typedef volatile T* pointer;
742 typedef volatile const T* const_pointer;
743 typedef volatile T& reference;
744 typedef volatile const T& const_reference;
753 : address(ETL_NULLPTR)
761 : address(reinterpret_cast<pointer>(address_))
769 : address(reinterpret_cast<pointer>(other_.address))
778 address = other_.address;
787 return iterator(*
this);
795 return const_iterator(*
this);
803 return const_iterator(*
this);
811 value_type temp = *address;
823 value_type temp = *address;
835 value_type temp = *address;
847 value_type temp = *address;
859 value_type temp = *address;
869 value_type operator ~()
const
879 address =
reinterpret_cast<pointer
>(address_);
901 operator value_type()
const
940 template <
typename T>
945 ETL_STATIC_ASSERT(etl::is_integral<T>::value,
"Not an integral type");
947 typedef T value_type;
948 typedef volatile T* pointer;
949 typedef volatile const T* const_pointer;
950 typedef volatile T& reference;
951 typedef volatile const T& const_reference;
959 : address(ETL_NULLPTR)
967 : address(reinterpret_cast<pointer>(address_))
975 : address(reinterpret_cast<pointer>(other_.address))
984 address = other_.address;
993 return const_iterator(*
this);
1001 return const_iterator(*
this);
1009 address =
reinterpret_cast<pointer
>(address_);
1023 operator value_type()
const
1039 void operator =(
value_type value) ETL_DELETE;
1048 template <
typename T>
1053 ETL_STATIC_ASSERT(etl::is_integral<T>::value,
"Not an integral type");
1055 typedef T value_type;
1056 typedef volatile T* pointer;
1057 typedef volatile const T* const_pointer;
1058 typedef volatile T& reference;
1059 typedef volatile const T& const_reference;
1067 : address(ETL_NULLPTR)
1075 : address(reinterpret_cast<pointer>(address_))
1083 : address(reinterpret_cast<pointer>(other_.address))
1092 address = other_.address;
1101 return iterator(*
this);
1109 address =
reinterpret_cast<pointer
>(address_);
1139 void operator =(value_type value)
1156 template <typename T>
1161 ETL_STATIC_ASSERT(etl::is_integral<T>::value,
"Not an integral type");
1163 typedef T value_type;
1164 typedef volatile T* pointer;
1165 typedef volatile const T* const_pointer;
1166 typedef volatile T& reference;
1167 typedef volatile const T& const_reference;
1177 , address(ETL_NULLPTR)
1186 , address(reinterpret_cast<pointer>(address_))
1194 : shadow_value(other_.shadow_value)
1195 , address(reinterpret_cast<pointer>(other_.address))
1204 shadow_value = other_.shadow_value;
1205 address = other_.address;
1214 return iterator(*
this);
1222 return const_iterator(*
this);
1230 return const_iterator(*
this);
1238 shadow_value |= value;
1239 *address = shadow_value;
1249 shadow_value &= value;
1250 *address = shadow_value;
1260 shadow_value ^= value;
1261 *address = shadow_value;
1271 shadow_value <<= shift;
1272 *address = shadow_value;
1282 shadow_value >>= shift;
1283 *address = shadow_value;
1291 value_type operator ~()
const
1293 return ~shadow_value;
1301 address =
reinterpret_cast<pointer
>(address_);
1323 operator value_type()
const
1325 return shadow_value;
1333 return shadow_value;
1341 shadow_value = value_;
1342 *address = shadow_value;
1350 shadow_value = value_;
1351 *address = shadow_value;
1366 const_reference operator *()
const
1368 return shadow_value;
void set_address(void *address_)
Set the IO port address.
Definition io_port.h:1007
const_pointer get_address() const
Get the IO port address.
Definition io_port.h:1015
value_type read() const
Read.
Definition io_port.h:1031
const_iterator citer() const
Get a const_iterator to this port.
Definition io_port.h:999
io_port_ro(void *address_)
Constructor.
Definition io_port.h:966
io_port_ro()
Default constructor.
Definition io_port.h:958
const_iterator iter() const
Get a const_iterator to this port.
Definition io_port.h:991
io_port_ro(const io_port_ro &other_)
Copy Constructor.
Definition io_port.h:974
Read only port.
Definition io_port.h:427
value_type read() const
Read.
Definition io_port.h:467
const_iterator citer() const
Get a const_iterator to this port.
Definition io_port.h:451
const_pointer get_address() const
Get the IO port address.
Definition io_port.h:483
const_iterator iter() const
Get a const_iterator to this port.
Definition io_port.h:443
pointer get_address()
Get the IO port address.
Definition io_port.h:475
value_type read() const
Read.
Definition io_port.h:909
const_iterator citer() const
Get a const_iterator to this port.
Definition io_port.h:801
const_pointer get_address() const
Get the IO port address.
Definition io_port.h:893
pointer get_address()
Get the IO port address.
Definition io_port.h:885
const_iterator iter() const
Get a const_iterator to this port.
Definition io_port.h:793
io_port_rw(const io_port_rw &other_)
Copy Constructor.
Definition io_port.h:768
void write(value_type value_)
Write.
Definition io_port.h:917
void set_address(void *address_)
Set the IO port address.
Definition io_port.h:877
iterator iter()
Get an iterator to this port.
Definition io_port.h:785
io_port_rw(void *address_)
Constructor.
Definition io_port.h:760
io_port_rw()
Default constructor.
Definition io_port.h:752
Read write port.
Definition io_port.h:256
io_port_rw & operator&=(value_type value)
And-Equals operator.
Definition io_port.h:343
io_port_rw & operator>>=(int shift)
Right-Shift-Equals operator.
Definition io_port.h:382
io_port_rw & operator=(value_type value_)
Write.
Definition io_port.h:321
pointer get_address()
Get the IO port address.
Definition io_port.h:403
io_port_rw & operator^=(value_type value)
Exclusive-Or-Equals operator.
Definition io_port.h:356
value_type operator~() const
Not operator.
Definition io_port.h:395
const_pointer get_address() const
Get the IO port address.
Definition io_port.h:411
io_port_rw & operator<<=(int shift)
Left-Shift-Equals operator.
Definition io_port.h:369
void write(value_type value_)
Write.
Definition io_port.h:313
value_type read() const
Read.
Definition io_port.h:305
io_port_rw & operator|=(value_type value)
Or-Equals operator.
Definition io_port.h:330
iterator iter()
Get an iterator to this port.
Definition io_port.h:273
const_iterator iter() const
Get a const_iterator to this port.
Definition io_port.h:281
const_iterator citer() const
Get a const_iterator to this port.
Definition io_port.h:289
io_port_wo(const io_port_wo &other_)
Copy Constructor.
Definition io_port.h:1082
void set_address(void *address_)
Set the IO port address.
Definition io_port.h:1107
pointer get_address()
Get the IO port address.
Definition io_port.h:1115
iterator iter()
Get an iterator to this port.
Definition io_port.h:1099
io_port_wo(void *address_)
Constructor.
Definition io_port.h:1074
void write(value_type value_)
Write.
Definition io_port.h:1131
const_pointer get_address() const
Get the IO port address.
Definition io_port.h:1123
io_port_wo()
Default constructor.
Definition io_port.h:1066
Write only port.
Definition io_port.h:502
const_pointer get_address() const
Get the IO port address.
Definition io_port.h:550
iterator iter()
Get an iterator to this port.
Definition io_port.h:518
void operator=(value_type value)
Write.
Definition io_port.h:526
pointer get_address()
Get the IO port address.
Definition io_port.h:542
void write(value_type value_)
Write.
Definition io_port.h:534
const_pointer get_address() const
Get the IO port address.
Definition io_port.h:1315
void write(value_type value_)
Write.
Definition io_port.h:1339
pointer get_address()
Get the IO port address.
Definition io_port.h:1307
void set_address(void *address_)
Set the IO port address.
Definition io_port.h:1299
iterator iter()
Get an iterator to this port.
Definition io_port.h:1212
io_port_wos(void *address_)
Constructor.
Definition io_port.h:1184
io_port_wos()
Default constructor.
Definition io_port.h:1175
value_type read() const
Read.
Definition io_port.h:1331
const_iterator citer() const
Get a const_iterator to this port.
Definition io_port.h:1228
const_iterator iter() const
Get a const_iterator to this port.
Definition io_port.h:1220
io_port_wos(const io_port_wos &other_)
Copy Constructor.
Definition io_port.h:1193
Write only port with shadow register.
Definition io_port.h:569
const_iterator iter() const
Get a const_iterator to this port.
Definition io_port.h:602
pointer get_address()
Get the IO port address.
Definition io_port.h:716
iterator iter()
Get an iterator to this port.
Definition io_port.h:594
void write(value_type value_)
Write.
Definition io_port.h:634
const_iterator citer() const
Get a const_iterator to this port.
Definition io_port.h:610
io_port_wos()
Default constructor.
Definition io_port.h:586
value_type read() const
Read.
Definition io_port.h:626
Common io_port const_iterator implementation.
Definition io_port.h:153
TIO_Port io_port_type
Types.
Definition io_port.h:168
const_iterator & operator++()
Pre-increment operator.
Definition io_port.h:224
friend TIO_Port
Definition io_port.h:163
Common io_port iterator implementation.
Definition io_port.h:58
friend TIO_Port
Definition io_port.h:64
TIO_Port io_port_type
Types.
Definition io_port.h:75
iterator & operator++()
Pre-increment operator.
Definition io_port.h:122
friend class const_iterator
Definition io_port.h:70
bitset_ext
Definition absolute.h:39
etl::byte operator~(etl::byte b)
Not.
Definition byte.h:313
etl::byte & operator^=(etl::byte &lhs, etl::byte rhs)
Exclusive or equals.
Definition byte.h:305
etl::enable_if< etl::is_integral< TInteger >::value, etl::byte & >::type operator<<=(etl::byte &b, TInteger shift)
Shift left equals.
Definition byte.h:243
etl::byte & operator|=(etl::byte &lhs, etl::byte rhs)
Or equals.
Definition byte.h:289
etl::enable_if< etl::is_integral< TInteger >::value, etl::byte & >::type operator>>=(etl::byte &b, TInteger shift)
Shift right equals.
Definition byte.h:255
etl::byte & operator&=(etl::byte &lhs, etl::byte rhs)
And equals.
Definition byte.h:297
iterator
Definition iterator.h:399