Dawn Framework 1.0
Universal data acquisition framework for embedded systems
factory.cxx
1// dawn/src/io/factory.cxx
2//
3// SPDX-License-Identifier: Apache-2.0
4//
5
6#include "dawn/io/factory.hxx"
7#include "dawn/io/common.hxx"
8
9#ifdef CONFIG_DAWN_IO_ADC_FETCH
10# include "dawn/io/adc_fetch.hxx"
11#endif
12#ifdef CONFIG_DAWN_IO_ADC_SYNC
13# include "dawn/io/adc_sync.hxx"
14#endif
15#ifdef CONFIG_DAWN_IO_ADC_STREAM
16# include "dawn/io/adc_stream.hxx"
17#endif
18#ifdef CONFIG_DAWN_IO_CONFIG
19# include "dawn/io/config.hxx"
20#endif
21#ifdef CONFIG_DAWN_IO_CONTROL
22# include "dawn/io/control.hxx"
23#endif
24#ifdef CONFIG_DAWN_IO_TRIGGER
25# include "dawn/io/trigger.hxx"
26#endif
27#ifdef CONFIG_DAWN_IO_DUMMY
28# include "dawn/io/dummy.hxx"
29#endif
30#ifdef CONFIG_DAWN_IO_DUMMY_NOTIFY
31# include "dawn/io/dummy_notify.hxx"
32#endif
33#ifdef CONFIG_DAWN_IO_DAC
34# include "dawn/io/dac.hxx"
35#endif
36#ifdef CONFIG_DAWN_IO_ENCODER
37# include "dawn/io/encoder.hxx"
38#endif
39#ifdef CONFIG_DAWN_IO_ENCODER_INDEX
40# include "dawn/io/encoder_index.hxx"
41#endif
42#ifdef CONFIG_DAWN_IO_PWM
43# include "dawn/io/pwm.hxx"
44#endif
45#ifdef CONFIG_DAWN_IO_DESCRIPTOR
46# include "dawn/io/descriptor.hxx"
47#endif
48#ifdef CONFIG_DAWN_IO_CAPABILITIES
49# include "dawn/io/capabilities.hxx"
50#endif
51#ifdef CONFIG_DAWN_IO_DESC_SELECTOR
52# include "dawn/io/descselector.hxx"
53#endif
54#ifdef CONFIG_DAWN_IO_FILE
55# include "dawn/io/fileio.hxx"
56#endif
57#ifdef CONFIG_DAWN_IO_GPO
58# include "dawn/io/gpo.hxx"
59#endif
60#ifdef CONFIG_DAWN_IO_GPI
61# include "dawn/io/gpi.hxx"
62#endif
63#ifdef CONFIG_DAWN_IO_BUTTONS
64# include "dawn/io/buttons.hxx"
65#endif
66#ifdef CONFIG_DAWN_IO_LEDS
67# include "dawn/io/leds.hxx"
68#endif
69#ifdef CONFIG_DAWN_IO_RGB_LED
70# include "dawn/io/rgbled.hxx"
71#endif
72#ifdef CONFIG_DAWN_IO_VIRT
73# include "dawn/io/virt.hxx"
74#endif
75#ifdef CONFIG_DAWN_IO_SENSOR
76# include "dawn/io/sensor.hxx"
77#endif
78#ifdef CONFIG_DAWN_IO_SENSOR_PRODUCER
79# include "dawn/io/sensor_producer.hxx"
80#endif
81#ifdef CONFIG_DAWN_IO_BOARDCTL
82# include "dawn/io/boardctl.hxx"
83#endif
84#ifdef CONFIG_DAWN_IO_SYSINFO
85# include "dawn/io/sysinfo.hxx"
86#endif
87#ifdef CONFIG_DAWN_IO_UNAME
88# include "dawn/io/uname.hxx"
89#endif
90#ifdef CONFIG_DAWN_IO_UUID
91# include "dawn/io/uuid.hxx"
92#endif
93#ifdef CONFIG_DAWN_IO_SYSTIME
94# include "dawn/io/systime.hxx"
95#endif
96#ifdef CONFIG_DAWN_IO_TIMESTAMPIO
97# include "dawn/io/timestamp.hxx"
98#endif
99#ifdef CONFIG_DAWN_IO_RANDIO
100# include "dawn/io/rand.hxx"
101#endif
102
103using namespace dawn;
104
106{
107 DEBUGASSERT(desc.getObjectType() == SObjectId::OBJTYPE_IO);
108
109 // Create io object
110
111 switch (desc.getObjectCls())
112 {
113#ifdef CONFIG_DAWN_IO_CONFIG
115 return new CIOConfig(desc);
116#endif
117
118#ifdef CONFIG_DAWN_IO_CONTROL
120 return new CIOControl(desc);
121#endif
122
123#ifdef CONFIG_DAWN_IO_TRIGGER
125 return new CIOTrigger(desc);
126#endif
127
128#ifdef CONFIG_DAWN_IO_DUMMY
130 return new CIODummy(desc);
131#endif
132
133#ifdef CONFIG_DAWN_IO_DUMMY_NOTIFY
135 return new CIODummyNotify(desc);
136#endif
137
138#ifdef CONFIG_DAWN_IO_TIMESTAMPIO
140 return new CIOTimestamp(desc);
141#endif
142
143#ifdef CONFIG_DAWN_IO_RANDIO
145 return new CIORand(desc);
146#endif
147
148#ifdef CONFIG_DAWN_IO_SYSINFO
151 return new CIOSysinfo(desc);
152#endif
153
154#ifdef CONFIG_DAWN_IO_BOARDCTL
158 return new CIOBoardctl(desc);
159#endif
160
161#ifdef CONFIG_DAWN_IO_UNAME
163 return new CIOUname(desc);
164#endif
165
166#ifdef CONFIG_DAWN_IO_UUID
168 return new CIOUuid(desc);
169#endif
170
171#ifdef CONFIG_DAWN_IO_SYSTIME
173 return new CIOSystime(desc);
174#endif
175
176#ifdef CONFIG_DAWN_IO_SENSOR
190 return new CIOSensor(desc);
191#endif
192
193#ifdef CONFIG_DAWN_IO_SENSOR_PRODUCER
207 return new CIOSensorProducer(desc);
208#endif
209
210#ifdef CONFIG_DAWN_IO_ADC_FETCH
212 return new CIOAdcFetch(desc);
213#endif
214
215#ifdef CONFIG_DAWN_IO_ADC_SYNC
217 return new CIOAdcSync(desc);
218#endif
219
220#ifdef CONFIG_DAWN_IO_ADC_STREAM
222 return new CIOAdcStream(desc);
223#endif
224
225#ifdef CONFIG_DAWN_IO_DAC
227 return new CIODac(desc);
228#endif
229
230#ifdef CONFIG_DAWN_IO_ENCODER
232 return new CIOEncoder(desc);
233#endif
234
235#ifdef CONFIG_DAWN_IO_ENCODER_INDEX
237 return new CIOEncoderIndex(desc);
238#endif
239
240#ifdef CONFIG_DAWN_IO_PWM
242 return new CIOPwm(desc);
243#endif
244
245#ifdef CONFIG_DAWN_IO_DESCRIPTOR
247 return new CIODescriptor(desc);
248#endif
249
250#ifdef CONFIG_DAWN_IO_CAPABILITIES
252 return new CIOCapabilities(desc);
253#endif
254
255#ifdef CONFIG_DAWN_IO_DESC_SELECTOR
257 return new CIODescSelector(desc);
258#endif
259
260#ifdef CONFIG_DAWN_IO_FILE
262 return new CIOFile(desc);
263#endif
264
265#ifdef CONFIG_DAWN_IO_GPO
267 return new CIOGpo(desc);
268#endif
269
270#ifdef CONFIG_DAWN_IO_GPI
272 return new CIOGpi(desc);
273#endif
274
275#ifdef CONFIG_DAWN_IO_BUTTONS
277 return new CIOButtons(desc);
278#endif
279
280#ifdef CONFIG_DAWN_IO_LEDS
282 return new CIOLeds(desc);
283#endif
284
285#ifdef CONFIG_DAWN_IO_RGB_LED
287 return new CIORgbLed(desc);
288#endif
289
290#ifdef CONFIG_DAWN_IO_VIRT
292 return new CIOVirt(desc);
293#endif
294
295 default:
296 {
297 DAWNERR("Unknown IO class %d\n", desc.getObjectCls());
298 return nullptr;
299 }
300 }
301}
Descriptor wrapper for individual object configuration.
uint8_t getObjectType() const
Get object type field.
uint16_t getObjectCls() const
Get object class field.
On-demand ADC fetch I/O.
Definition adc_fetch.hxx:15
High-throughput batched ADC stream I/O.
Hardware-triggered single-sample ADC I/O.
Definition adc_sync.hxx:15
Board control I/O for system operations.
Definition boardctl.hxx:23
Button input I/O type for reading button/switch states.
Definition buttons.hxx:23
Read-only seekable capability bitmap IO.
Base class for all I/O objects.
Definition common.hxx:27
@ IO_CLASS_SENSOR_PRODUCER_MAGNETICFIELD
Magnetic field publisher.
Definition common.hxx:130
@ IO_CLASS_SENSOR_MAGNETICFIELD
Magnetic field sensor.
Definition common.hxx:114
@ IO_CLASS_SENSOR_PRODUCER_ACCELEROMETER
Accelerometer publisher.
Definition common.hxx:129
@ IO_CLASS_DAC
Digital-to-analog converter.
Definition common.hxx:176
@ IO_CLASS_TRIGGER
Trigger I/O.
Definition common.hxx:91
@ IO_CLASS_PWM
PWM output.
Definition common.hxx:172
@ IO_CLASS_SYSTEM_RESETCAUSE
Reset cause.
Definition common.hxx:153
@ IO_CLASS_ADC_STREAM
ADC stream (batch/high-throughput)
Definition common.hxx:179
@ IO_CLASS_VIRT
Virtual I/O.
Definition common.hxx:188
@ IO_CLASS_SYSTEM_UPTIME
System uptime.
Definition common.hxx:150
@ IO_CLASS_SYSTEM_POWEROFF
Power off control.
Definition common.hxx:154
@ IO_CLASS_GPI_SINGLE
Single GPIO input.
Definition common.hxx:164
@ IO_CLASS_SENSOR_PRODUCER_LIGHT
Light publisher.
Definition common.hxx:132
@ IO_CLASS_SENSOR_PRODUCER_ATEMPERATURE
Ambient temperature publisher.
Definition common.hxx:137
@ IO_CLASS_SYSTEM_SYSTEMTIME
System time.
Definition common.hxx:157
@ IO_CLASS_SENSOR_PRODUCER_HUMIDITY
Humidity publisher.
Definition common.hxx:135
@ IO_CLASS_ENCODER_INDEX
Quadrature encoder (position+index)
Definition common.hxx:184
@ IO_CLASS_SENSOR_PRODUCER_IR
Infrared publisher.
Definition common.hxx:139
@ IO_CLASS_ADC_FETCH
ADC fetch (on-demand)
Definition common.hxx:177
@ IO_CLASS_CAPABILITIES
Capabilities bitmask I/O.
Definition common.hxx:94
@ IO_CLASS_SENSOR_LIGHT
Light sensor.
Definition common.hxx:116
@ IO_CLASS_SENSOR_BAROMETER
Barometer sensor.
Definition common.hxx:117
@ IO_CLASS_SENSOR_PRODUCER_UV
Ultraviolet publisher.
Definition common.hxx:140
@ IO_CLASS_SENSOR_HUMIDITY
Humidity sensor.
Definition common.hxx:119
@ IO_CLASS_SENSOR_PROXIMITY
Proximity sensor.
Definition common.hxx:118
@ IO_CLASS_SENSOR_PRODUCER_GAS
Gas publisher.
Definition common.hxx:141
@ IO_CLASS_SENSOR_TEMPERATURE
Temperature sensor.
Definition common.hxx:120
@ IO_CLASS_FILE
File system I/O.
Definition common.hxx:109
@ IO_CLASS_SENSOR_PRODUCER_GYROSCOPE
Gyroscope publisher.
Definition common.hxx:131
@ IO_CLASS_CONTROL
Control I/O.
Definition common.hxx:93
@ IO_CLASS_BUTTONS
Button input.
Definition common.hxx:166
@ IO_CLASS_SYSTEM_HOSTNAME
System hostname.
Definition common.hxx:155
@ IO_CLASS_SENSOR_PRODUCER_RGB
RGB color publisher.
Definition common.hxx:138
@ IO_CLASS_SENSOR_PRODUCER_TEMPERATURE
Temperature publisher.
Definition common.hxx:136
@ IO_CLASS_SENSOR_UV
Ultraviolet sensor.
Definition common.hxx:124
@ IO_CLASS_CONFIG
Configuration I/O.
Definition common.hxx:90
@ IO_CLASS_DESC_SELECTOR
Descriptor slot selector I/O.
Definition common.hxx:95
@ IO_CLASS_DUMMY
Dummy I/O (for testing)
Definition common.hxx:99
@ IO_CLASS_SENSOR_ACCELEROMETER
Accelerometer sensor.
Definition common.hxx:113
@ IO_CLASS_SENSOR_RGB
RGB color sensor.
Definition common.hxx:122
@ IO_CLASS_TIMESTAMP
Timestamp generator.
Definition common.hxx:103
@ IO_CLASS_SENSOR_GYROSCOPE
Gyroscope sensor.
Definition common.hxx:115
@ IO_CLASS_SYSTEM_UUID
UUID.
Definition common.hxx:156
@ IO_CLASS_ADC_SYNC
ADC sync (HW-triggered control loop)
Definition common.hxx:178
@ IO_CLASS_ENCODER
Quadrature encoder (position)
Definition common.hxx:183
@ IO_CLASS_GPO_SINGLE
Single GPIO output.
Definition common.hxx:165
@ IO_CLASS_SENSOR_IR
Infrared sensor.
Definition common.hxx:123
@ IO_CLASS_SYSTEM_CPULOAD
CPU load.
Definition common.hxx:151
@ IO_CLASS_SENSOR_PRODUCER_PROXIMITY
Proximity publisher.
Definition common.hxx:134
@ IO_CLASS_SENSOR_ATEMPERATURE
Ambient temperature sensor.
Definition common.hxx:121
@ IO_CLASS_DUMMY_NOTIFY
Timer-driven dummy IO.
Definition common.hxx:105
@ IO_CLASS_LEDS
LED output.
Definition common.hxx:167
@ IO_CLASS_RGBLED
RGB LED output.
Definition common.hxx:168
@ IO_CLASS_RAND
Random number generator.
Definition common.hxx:104
@ IO_CLASS_SENSOR_GAS
Gas sensor.
Definition common.hxx:125
@ IO_CLASS_SENSOR_PRODUCER_BAROMETER
Barometer publisher.
Definition common.hxx:133
@ IO_CLASS_DESCRIPTOR
Descriptor I/O.
Definition common.hxx:92
@ IO_CLASS_SYSTEM_RESET
System reset control.
Definition common.hxx:152
Configuration I/O for runtime object management.
Definition config.hxx:24
Control I/O for lifecycle management of bound objects.
Definition control.hxx:19
Digital-to-Analog Converter (DAC) output I/O type.
Definition dac.hxx:23
Runtime descriptor slot selector I/O.
Device descriptor I/O access.
Timer-driven dummy I/O with notification support.
Dummy I/O type for testing and simulation.
Definition dummy.hxx:23
Quadrature encoder I/O (position + index information).
Quadrature encoder I/O (position only).
Definition encoder.hxx:17
CIOCommon * create(CDescObject &desc)
Create I/O object from descriptor.
Definition factory.cxx:105
File system I/O access.
Definition fileio.hxx:27
GPIO Input (GPI) I/O type for reading digital input states.
Definition gpi.hxx:22
GPIO Output (GPO) I/O type for writing digital output states.
Definition gpo.hxx:22
LED output I/O type for controlling LED indicators.
Definition leds.hxx:22
Pulse Width Modulation (PWM) output I/O type.
Definition pwm.hxx:21
Random number generator I/O type.
Definition rand.hxx:25
RGB LED output I/O type.
Definition rgbled.hxx:23
Sensor/uORB publisher backed by Dawn protocol writes.
Generic sensor interface for various sensor types.
Definition sensor.hxx:26
System information I/O providing uptime and CPU load.
Definition sysinfo.hxx:23
System information I/O providing system time.
Definition systime.hxx:15
System timestamp/monotonic time generator.
Definition timestamp.hxx:25
Trigger I/O for dispatching commands to bound objects.
Definition trigger.hxx:19
System identification I/O providing hostname and version info.
Definition uname.hxx:23
System UUID I/O providing unique device identifier.
Definition uuid.hxx:22
Virtual I/O type for user-provided data and callbacks.
Definition virt.hxx:26
Out-of-tree user-extension hooks for Dawn.
Definition bindable.hxx:13
@ OBJTYPE_IO
Input/Output object type.
Definition objectid.hxx:184