Embedded Template Library 1.0
Loading...
Searching...
No Matches
io_port.h
Go to the documentation of this file.
1
2
3/******************************************************************************
4The MIT License(MIT)
5
6Embedded Template Library.
7https://github.com/ETLCPP/etl
8https://www.etlcpp.com
9
10Copyright(c) 2014 John Wellbelove
11
12Permission is hereby granted, free of charge, to any person obtaining a copy
13of this software and associated documentation files(the "Software"), to deal
14in the Software without restriction, including without limitation the rights
15to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
16copies of the Software, and to permit persons to whom the Software is
17furnished to do so, subject to the following conditions :
18
19The above copyright notice and this permission notice shall be included in all
20copies or substantial portions of the Software.
21
22THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
25AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28SOFTWARE.
29******************************************************************************/
30
31#ifndef ETL_IO_PORT_INCLUDED
32#define ETL_IO_PORT_INCLUDED
33
37
38#include "platform.h"
39#include "nullptr.h"
40#include "iterator.h"
41#include "utility.h"
42#include "static_assert.h"
43
44#include <stdint.h>
45
46namespace etl
47{
48 template <typename, uintptr_t>
49 class io_port_rw;
50
51 namespace private_io_port
52 {
53 //***************************************************************************
55 //***************************************************************************
56 template <typename TIO_Port>
57 class iterator : public etl::iterator<ETL_OR_STD::forward_iterator_tag, typename TIO_Port::value_type>
58 {
59 public:
60
61 //********************************
63 //********************************
64 friend TIO_Port;
65
66 //********************************
68 //********************************
69 template <typename U>
70 friend class const_iterator;
71
72 //********************************
74 //********************************
76 typedef typename TIO_Port::value_type value_type;
77
78 //********************************
80 //********************************
81 iterator()
82 : p_iop(ETL_NULLPTR)
83 {
84 }
85
86 //********************************
88 //********************************
89 iterator(const iterator& other)
90 : p_iop(other.p_iop)
91 {
92 }
93
94 //********************************
96 //********************************
97 iterator& operator =(const iterator& other)
98 {
99 p_iop = other.p_iop;
100 return *this;
101 }
102
103 //********************************
105 //********************************
106 io_port_type& operator *()
107 {
108 return *p_iop;
109 }
110
111 //********************************
113 //********************************
114 const io_port_type& operator *() const
115 {
116 return *p_iop;
117 }
118
119 //********************************
121 //********************************
122 iterator& operator ++()
123 {
124 return *this;
125 }
126
127 //********************************
129 //********************************
130 iterator operator ++(int)
131 {
132 return *this;
133 }
134
135 private:
136
137 //********************************
139 //********************************
141 : p_iop(&iop)
142 {
143 }
144
145 io_port_type* p_iop;
146 };
147
148 //***************************************************************************
150 //***************************************************************************
151 template <typename TIO_Port>
152 class const_iterator : public etl::iterator<ETL_OR_STD::forward_iterator_tag, const typename TIO_Port::value_type>
153 {
154 private:
155
156 typedef etl::private_io_port::iterator<TIO_Port> iterator_type;
157
158 public:
159
160 //********************************
162 //********************************
163 friend TIO_Port;
164
165 //********************************
167 //********************************
169 typedef const typename TIO_Port::value_type value_type;
170
171 //********************************
173 //********************************
174 const_iterator()
175 : p_iop(ETL_NULLPTR)
176 {
177 }
178
179 //********************************
181 //********************************
182 const_iterator(const iterator_type& other)
183 : p_iop(other.p_iop)
184 {
185 }
186
187 //********************************
189 //********************************
190 const_iterator(const const_iterator& other)
191 : p_iop(other.p_iop)
192 {
193 }
194
195 //********************************
197 //********************************
198 const_iterator& operator =(const iterator_type& other)
199 {
200 p_iop = other.p_iop;
201 return *this;
202 }
203
204 //********************************
206 //********************************
207 const_iterator& operator =(const const_iterator& other)
208 {
209 p_iop = other.p_iop;
210 return *this;
211 }
212
213 //********************************
215 //********************************
216 const io_port_type& operator *() const
217 {
218 return *p_iop;
219 }
220
221 //********************************
223 //********************************
224 const_iterator& operator ++()
225 {
226 return *this;
227 }
228
229 //********************************
231 //********************************
232 const_iterator operator ++(int)
233 {
234 return *this;
235 }
236
237 private:
238
239 //********************************
241 //********************************
242 const_iterator(const io_port_type& iop)
243 : p_iop(&iop)
244 {
245 }
246
247 const io_port_type* p_iop;
248 };
249 }
250
251 //***************************************************************************
253 //***************************************************************************
254 template <typename T, uintptr_t Address = 0>
256 {
257 public:
258
259 ETL_STATIC_ASSERT(etl::is_integral<T>::value, "Not an integral type");
260
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;
266
269
270 //**********************************
272 //**********************************
273 iterator iter()
274 {
275 return iterator(*this);
276 }
277
278 //**********************************
280 //**********************************
281 const_iterator iter() const
282 {
283 return const_iterator(*this);
284 }
285
286 //**********************************
288 //**********************************
289 const_iterator citer() const
290 {
291 return const_iterator(*this);
292 }
293
294 //**********************************
296 //**********************************
297 operator value_type() const
298 {
299 return *reinterpret_cast<const_pointer>(Address);
300 }
301
302 //**********************************
304 //**********************************
305 value_type read() const
306 {
307 return *reinterpret_cast<const_pointer>(Address);
308 }
309
310 //**********************************
312 //**********************************
313 void write(value_type value_)
314 {
315 *reinterpret_cast<pointer>(Address) = value_;
316 }
317
318 //**********************************
320 //**********************************
321 io_port_rw& operator =(value_type value_)
322 {
323 *reinterpret_cast<pointer>(Address) = value_;
324 return *this;
325 }
326
327 //**********************************
329 //**********************************
330 io_port_rw& operator |=(value_type value)
331 {
332 pointer address = reinterpret_cast<pointer>(Address);
333 value_type temp = *address;
334 temp |= value;
335 *address = temp;
336
337 return *this;
338 }
339
340 //**********************************
342 //**********************************
343 io_port_rw& operator &=(value_type value)
344 {
345 pointer address = reinterpret_cast<pointer>(Address);
346 value_type temp = *address;
347 temp &= value;
348 *address = temp;
349
350 return *this;
351 }
352
353 //**********************************
355 //**********************************
356 io_port_rw& operator ^=(value_type value)
357 {
358 pointer address = reinterpret_cast<pointer>(Address);
359 value_type temp = *address;
360 temp ^= value;
361 *address = temp;
362
363 return *this;
364 }
365
366 //**********************************
368 //**********************************
370 {
371 pointer address = reinterpret_cast<pointer>(Address);
372 value_type temp = *address;
373 temp <<= shift;
374 *address = temp;
375
376 return *this;
377 }
378
379 //**********************************
381 //**********************************
383 {
384 pointer address = reinterpret_cast<pointer>(Address);
385 value_type temp = *address;
386 temp >>= shift;
387 *address = temp;
388
389 return *this;
390 }
391
392 //**********************************
394 //**********************************
395 value_type operator ~() const
396 {
397 return ~(*reinterpret_cast<pointer>(Address));
398 }
399
400 //**********************************
402 //**********************************
403 pointer get_address()
404 {
405 return reinterpret_cast<pointer>(Address);
406 }
407
408 //**********************************
410 //**********************************
411 const_pointer get_address() const
412 {
413 return reinterpret_cast<const_pointer>(Address);
414 }
415
416 private:
417
420 };
421
422 //***************************************************************************
424 //***************************************************************************
425 template <typename T, uintptr_t Address = 0>
427 {
428 public:
429
430 ETL_STATIC_ASSERT(etl::is_integral<T>::value, "Not an integral type");
431
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;
437
439
440 //**********************************
442 //**********************************
443 const_iterator iter() const
444 {
445 return const_iterator(*this);
446 }
447
448 //**********************************
450 //**********************************
451 const_iterator citer() const
452 {
453 return const_iterator(*this);
454 }
455
456 //**********************************
458 //**********************************
459 operator value_type() const
460 {
461 return *reinterpret_cast<const_pointer>(Address);
462 }
463
464 //**********************************
466 //**********************************
467 value_type read() const
468 {
469 return *reinterpret_cast<const_pointer>(Address);
470 }
471
472 //**********************************
474 //**********************************
475 pointer get_address()
476 {
477 return reinterpret_cast<pointer>(Address);
478 }
479
480 //**********************************
482 //**********************************
483 const_pointer get_address() const
484 {
485 return reinterpret_cast<const_pointer>(Address);
486 }
487
488 private:
489
491 void operator =(value_type value) ETL_DELETE;
492
494 io_port_ro& operator =(const io_port_ro&) ETL_DELETE;
495 };
496
497 //***************************************************************************
499 //***************************************************************************
500 template <typename T, uintptr_t Address = 0>
502 {
503 public:
504
505 ETL_STATIC_ASSERT(etl::is_integral<T>::value, "Not an integral type");
506
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;
512
514
515 //**********************************
517 //**********************************
518 iterator iter()
519 {
520 return iterator(*this);
521 }
522
523 //**********************************
525 //**********************************
526 void operator =(value_type value)
527 {
528 *reinterpret_cast<pointer>(Address) = value;
529 }
530
531 //**********************************
533 //**********************************
534 void write(value_type value_)
535 {
536 *reinterpret_cast<pointer>(Address) = value_;
537 }
538
539 //**********************************
541 //**********************************
542 pointer get_address()
543 {
544 return reinterpret_cast<pointer>(Address);
545 }
546
547 //**********************************
549 //**********************************
550 const_pointer get_address() const
551 {
552 return reinterpret_cast<const_pointer>(Address);
553 }
554
555 private:
556
558 operator value_type() const ETL_DELETE;
559
561 io_port_wo& operator =(const io_port_wo&) ETL_DELETE;
562 };
563
564 //***************************************************************************
566 //***************************************************************************
567 template <typename T, uintptr_t Address = 0>
569 {
570 public:
571
572 ETL_STATIC_ASSERT(etl::is_integral<T>::value, "Not an integral type");
573
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;
579
582
583 //**********************************
585 //**********************************
587 : shadow_value(value_type())
588 {
589 }
590
591 //**********************************
593 //**********************************
594 iterator iter()
595 {
596 return iterator(*this);
597 }
598
599 //**********************************
601 //**********************************
602 const_iterator iter() const
603 {
604 return const_iterator(*this);
605 }
606
607 //**********************************
609 //**********************************
610 const_iterator citer() const
611 {
612 return const_iterator(*this);
613 }
614
615 //**********************************
617 //**********************************
618 operator value_type() const
619 {
620 return shadow_value;
621 }
622
623 //**********************************
625 //**********************************
626 value_type read() const
627 {
628 return shadow_value;
629 }
630
631 //**********************************
633 //**********************************
634 void write(value_type value_)
635 {
636 shadow_value = value_;
637 *reinterpret_cast<pointer>(Address) = shadow_value;
638 }
639
640 //**********************************
642 //**********************************
643 io_port_wos& operator =(value_type value_)
644 {
645 shadow_value = value_;
646 *reinterpret_cast<pointer>(Address) = shadow_value;
647 return *this;
648 }
649
650 //**********************************
652 //**********************************
653 io_port_wos& operator |=(value_type value)
654 {
655 shadow_value |= value;
656 *reinterpret_cast<pointer>(Address) = shadow_value;
657
658 return *this;
659 }
660
661 //**********************************
663 //**********************************
664 io_port_wos& operator &=(value_type value)
665 {
666 shadow_value &= value;
667 *reinterpret_cast<pointer>(Address) = shadow_value;
668
669 return *this;
670 }
671
672 //**********************************
674 //**********************************
675 io_port_wos& operator ^=(value_type value)
676 {
677 shadow_value ^= value;
678 *reinterpret_cast<pointer>(Address) = shadow_value;
679
680 return *this;
681 }
682
683 //**********************************
685 //**********************************
687 {
688 shadow_value <<= shift;
689 *reinterpret_cast<pointer>(Address) = shadow_value;
690
691 return *this;
692 }
693
694 //**********************************
696 //**********************************
698 {
699 shadow_value >>= shift;
700 *reinterpret_cast<pointer>(Address) = shadow_value;
701
702 return *this;
703 }
704
705 //**********************************
707 //**********************************
708 value_type operator ~() const
709 {
710 return ~shadow_value;
711 }
712
713 //**********************************
715 //**********************************
716 pointer get_address()
717 {
718 return reinterpret_cast<pointer>(Address);
719 }
720
721 private:
722
725
726 value_type shadow_value;
727 };
728
729 //***************************************************************************
732 //***************************************************************************
733 template <typename T>
734 class io_port_rw<T, 0>
735 {
736 public:
737
738 ETL_STATIC_ASSERT(etl::is_integral<T>::value, "Not an integral type");
739
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;
745
748
749 //**********************************
751 //**********************************
753 : address(ETL_NULLPTR)
754 {
755 }
756
757 //**********************************
759 //**********************************
760 io_port_rw(void* address_)
761 : address(reinterpret_cast<pointer>(address_))
762 {
763 }
764
765 //**********************************
767 //**********************************
768 io_port_rw(const io_port_rw& other_)
769 : address(reinterpret_cast<pointer>(other_.address))
770 {
771 }
772
773 //**********************************
775 //**********************************
776 io_port_rw& operator =(const io_port_rw& other_)
777 {
778 address = other_.address;
779 return *this;
780 }
781
782 //**********************************
784 //**********************************
785 iterator iter()
786 {
787 return iterator(*this);
788 }
789
790 //**********************************
792 //**********************************
793 const_iterator iter() const
794 {
795 return const_iterator(*this);
796 }
797
798 //**********************************
800 //**********************************
801 const_iterator citer() const
802 {
803 return const_iterator(*this);
804 }
805
806 //**********************************
808 //**********************************
809 io_port_rw& operator |=(value_type value)
810 {
811 value_type temp = *address;
812 temp |= value;
813 *address = temp;
814
815 return *this;
816 }
817
818 //**********************************
820 //**********************************
821 io_port_rw& operator &=(value_type value)
822 {
823 value_type temp = *address;
824 temp &= value;
825 *address = temp;
826
827 return *this;
828 }
829
830 //**********************************
832 //**********************************
833 io_port_rw& operator ^=(value_type value)
834 {
835 value_type temp = *address;
836 temp ^= value;
837 *address = temp;
838
839 return *this;
840 }
841
842 //**********************************
844 //**********************************
845 io_port_rw& operator <<=(int shift)
846 {
847 value_type temp = *address;
848 temp <<= shift;
849 *address = temp;
850
851 return *this;
852 }
853
854 //**********************************
856 //**********************************
857 io_port_rw& operator >>=(int shift)
858 {
859 value_type temp = *address;
860 temp >>= shift;
861 *address = temp;
862
863 return *this;
864 }
865
866 //**********************************
868 //**********************************
869 value_type operator ~() const
870 {
871 return ~(*address);
872 }
873
874 //**********************************
876 //**********************************
877 void set_address(void* address_)
878 {
879 address = reinterpret_cast<pointer>(address_);
880 }
881
882 //**********************************
884 //**********************************
885 pointer get_address()
886 {
887 return address;
888 }
889
890 //**********************************
892 //**********************************
893 const_pointer get_address() const
894 {
895 return address;
896 }
897
898 //**********************************
900 //**********************************
901 operator value_type() const
902 {
903 return *address;
904 }
905
906 //**********************************
908 //**********************************
909 value_type read() const
910 {
911 return *address;
912 }
913
914 //**********************************
916 //**********************************
917 void write(value_type value_)
918 {
919 *address = value_;
920 }
921
922 //**********************************
924 //**********************************
925 io_port_rw& operator =(value_type value_)
926 {
927 *address = value_;
928 return *this;
929 }
930
931 private:
932
933 pointer address;
934 };
935
936 //***************************************************************************
939 //***************************************************************************
940 template <typename T>
941 class io_port_ro<T, 0>
942 {
943 public:
944
945 ETL_STATIC_ASSERT(etl::is_integral<T>::value, "Not an integral type");
946
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;
952
954
955 //**********************************
957 //**********************************
959 : address(ETL_NULLPTR)
960 {
961 }
962
963 //**********************************
965 //**********************************
966 io_port_ro(void* address_)
967 : address(reinterpret_cast<pointer>(address_))
968 {
969 }
970
971 //**********************************
973 //**********************************
974 io_port_ro(const io_port_ro& other_)
975 : address(reinterpret_cast<pointer>(other_.address))
976 {
977 }
978
979 //**********************************
981 //**********************************
982 io_port_ro& operator =(const io_port_ro& other_)
983 {
984 address = other_.address;
985 return *this;
986 }
987
988 //**********************************
990 //**********************************
991 const_iterator iter() const
992 {
993 return const_iterator(*this);
994 }
995
996 //**********************************
998 //**********************************
999 const_iterator citer() const
1000 {
1001 return const_iterator(*this);
1002 }
1003
1004 //**********************************
1006 //**********************************
1007 void set_address(void* address_)
1008 {
1009 address = reinterpret_cast<pointer>(address_);
1010 }
1011
1012 //**********************************
1014 //**********************************
1015 const_pointer get_address() const
1016 {
1017 return address;
1018 }
1019
1020 //**********************************
1022 //**********************************
1023 operator value_type() const
1024 {
1025 return *address;
1026 }
1027
1028 //**********************************
1030 //**********************************
1031 value_type read() const
1032 {
1033 return *address;
1034 }
1035
1036 private:
1037
1039 void operator =(value_type value) ETL_DELETE;
1040
1041 pointer address;
1042 };
1043
1044 //***************************************************************************
1047 //***************************************************************************
1048 template <typename T>
1049 class io_port_wo<T, 0>
1050 {
1051 public:
1052
1053 ETL_STATIC_ASSERT(etl::is_integral<T>::value, "Not an integral type");
1054
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;
1060
1062
1063 //**********************************
1065 //**********************************
1067 : address(ETL_NULLPTR)
1068 {
1069 }
1070
1071 //**********************************
1073 //**********************************
1074 io_port_wo(void* address_)
1075 : address(reinterpret_cast<pointer>(address_))
1076 {
1077 }
1078
1079 //**********************************
1081 //**********************************
1082 io_port_wo(const io_port_wo& other_)
1083 : address(reinterpret_cast<pointer>(other_.address))
1084 {
1085 }
1086
1087 //**********************************
1089 //**********************************
1090 io_port_wo& operator =(const io_port_wo& other_)
1091 {
1092 address = other_.address;
1093 return *this;
1094 }
1095
1096 //**********************************
1098 //**********************************
1099 iterator iter()
1100 {
1101 return iterator(*this);
1102 }
1103
1104 //**********************************
1106 //**********************************
1107 void set_address(void* address_)
1108 {
1109 address = reinterpret_cast<pointer>(address_);
1110 }
1111
1112 //**********************************
1114 //**********************************
1115 pointer get_address()
1116 {
1117 return address;
1118 }
1119
1120 //**********************************
1122 //**********************************
1123 const_pointer get_address() const
1124 {
1125 return address;
1126 }
1127
1128 //**********************************
1130 //**********************************
1131 void write(value_type value_)
1132 {
1133 *address = value_;
1134 }
1135
1136 //**********************************
1138 //**********************************
1139 void operator =(value_type value)
1140 {
1141 *address = value;
1142 }
1143
1144 private:
1145
1147 operator value_type() const ETL_DELETE;
1148
1149 pointer address;
1150 };
1151
1152 //***************************************************************************
1155 //***************************************************************************
1156 template <typename T>
1157 class io_port_wos<T, 0>
1158 {
1159 public:
1160
1161 ETL_STATIC_ASSERT(etl::is_integral<T>::value, "Not an integral type");
1162
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;
1168
1171
1172 //**********************************
1174 //**********************************
1176 : shadow_value(T())
1177 , address(ETL_NULLPTR)
1178 {
1179 }
1180
1181 //**********************************
1183 //**********************************
1184 io_port_wos(void* address_)
1185 : shadow_value(T())
1186 , address(reinterpret_cast<pointer>(address_))
1187 {
1188 }
1189
1190 //**********************************
1192 //**********************************
1194 : shadow_value(other_.shadow_value)
1195 , address(reinterpret_cast<pointer>(other_.address))
1196 {
1197 }
1198
1199 //**********************************
1201 //**********************************
1202 io_port_wos& operator =(const io_port_wos& other_)
1203 {
1204 shadow_value = other_.shadow_value;
1205 address = other_.address;
1206 return *this;
1207 }
1208
1209 //**********************************
1211 //**********************************
1212 iterator iter()
1213 {
1214 return iterator(*this);
1215 }
1216
1217 //**********************************
1219 //**********************************
1220 const_iterator iter() const
1221 {
1222 return const_iterator(*this);
1223 }
1224
1225 //**********************************
1227 //**********************************
1228 const_iterator citer() const
1229 {
1230 return const_iterator(*this);
1231 }
1232
1233 //**********************************
1235 //**********************************
1236 io_port_wos& operator |=(value_type value)
1237 {
1238 shadow_value |= value;
1239 *address = shadow_value;
1240
1241 return *this;
1242 }
1243
1244 //**********************************
1246 //**********************************
1247 io_port_wos& operator &=(value_type value)
1248 {
1249 shadow_value &= value;
1250 *address = shadow_value;
1251
1252 return *this;
1253 }
1254
1255 //**********************************
1257 //**********************************
1258 io_port_wos& operator ^=(value_type value)
1259 {
1260 shadow_value ^= value;
1261 *address = shadow_value;
1262
1263 return *this;
1264 }
1265
1266 //**********************************
1268 //**********************************
1269 io_port_wos& operator <<=(int shift)
1270 {
1271 shadow_value <<= shift;
1272 *address = shadow_value;
1273
1274 return *this;
1275 }
1276
1277 //**********************************
1279 //**********************************
1280 io_port_wos& operator >>=(int shift)
1281 {
1282 shadow_value >>= shift;
1283 *address = shadow_value;
1284
1285 return *this;
1286 }
1287
1288 //**********************************
1290 //**********************************
1291 value_type operator ~() const
1292 {
1293 return ~shadow_value;
1294 }
1295
1296 //**********************************
1298 //**********************************
1299 void set_address(void* address_)
1300 {
1301 address = reinterpret_cast<pointer>(address_);
1302 }
1303
1304 //**********************************
1306 //**********************************
1307 pointer get_address()
1308 {
1309 return address;
1310 }
1311
1312 //**********************************
1314 //**********************************
1315 const_pointer get_address() const
1316 {
1317 return address;
1318 }
1319
1320 //**********************************
1322 //**********************************
1323 operator value_type() const
1324 {
1325 return shadow_value;
1326 }
1327
1328 //**********************************
1330 //**********************************
1331 value_type read() const
1332 {
1333 return shadow_value;
1334 }
1335
1336 //**********************************
1338 //**********************************
1339 void write(value_type value_)
1340 {
1341 shadow_value = value_;
1342 *address = shadow_value;
1343 }
1344
1345 //**********************************
1347 //**********************************
1348 io_port_wos& operator =(value_type value_)
1349 {
1350 shadow_value = value_;
1351 *address = shadow_value;
1352 return *this;
1353 }
1354
1355 //**********************************
1357 //**********************************
1358 io_port_wos& operator *()
1359 {
1360 return *this;
1361 }
1362
1363 //**********************************
1365 //**********************************
1366 const_reference operator *() const
1367 {
1368 return shadow_value;
1369 }
1370
1371 private:
1372
1373 value_type shadow_value;
1374 pointer address;
1375 };
1376}
1377
1378#endif
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
Common io_port iterator implementation.
Definition io_port.h:58
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