1use crate::adi::AdiPort;
4use crate::{
5 bindings,
6 controller::{Controller, ControllerId},
7 smart_port::SmartPort,
8};
9
10pub struct Peripherals {
12 pub master_controller: Controller,
14 pub partner_controller: Controller,
16 pub port01: SmartPort,
18 pub port02: SmartPort,
20 pub port03: SmartPort,
22 pub port04: SmartPort,
24 pub port05: SmartPort,
26 pub port06: SmartPort,
28 pub port07: SmartPort,
30 pub port08: SmartPort,
32 pub port09: SmartPort,
34 pub port10: SmartPort,
36 pub port11: SmartPort,
38 pub port12: SmartPort,
40 pub port13: SmartPort,
42 pub port14: SmartPort,
44 pub port15: SmartPort,
46 pub port16: SmartPort,
48 pub port17: SmartPort,
50 pub port18: SmartPort,
52 pub port19: SmartPort,
54 pub port20: SmartPort,
56 pub port21: SmartPort,
58 pub port_a: AdiPort,
60 pub port_b: AdiPort,
62 pub port_c: AdiPort,
64 pub port_d: AdiPort,
66 pub port_e: AdiPort,
68 pub port_f: AdiPort,
70 pub port_g: AdiPort,
72 pub port_h: AdiPort,
74}
75
76impl Peripherals {
77 pub unsafe fn new() -> Self {
86 Peripherals {
87 master_controller: Controller::new(ControllerId::Master),
88 partner_controller: Controller::new(ControllerId::Partner),
89 port01: SmartPort::new(1),
90 port02: SmartPort::new(2),
91 port03: SmartPort::new(3),
92 port04: SmartPort::new(4),
93 port05: SmartPort::new(5),
94 port06: SmartPort::new(6),
95 port07: SmartPort::new(7),
96 port08: SmartPort::new(8),
97 port09: SmartPort::new(9),
98 port10: SmartPort::new(10),
99 port11: SmartPort::new(11),
100 port12: SmartPort::new(12),
101 port13: SmartPort::new(13),
102 port14: SmartPort::new(14),
103 port15: SmartPort::new(15),
104 port16: SmartPort::new(16),
105 port17: SmartPort::new(17),
106 port18: SmartPort::new(18),
107 port19: SmartPort::new(19),
108 port20: SmartPort::new(20),
109 port21: SmartPort::new(21),
110 port_a: AdiPort::new(1, bindings::INTERNAL_ADI_PORT as u8),
111 port_b: AdiPort::new(2, bindings::INTERNAL_ADI_PORT as u8),
112 port_c: AdiPort::new(3, bindings::INTERNAL_ADI_PORT as u8),
113 port_d: AdiPort::new(4, bindings::INTERNAL_ADI_PORT as u8),
114 port_e: AdiPort::new(5, bindings::INTERNAL_ADI_PORT as u8),
115 port_f: AdiPort::new(6, bindings::INTERNAL_ADI_PORT as u8),
116 port_g: AdiPort::new(7, bindings::INTERNAL_ADI_PORT as u8),
117 port_h: AdiPort::new(8, bindings::INTERNAL_ADI_PORT as u8),
118 }
119 }
120}