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_BATTERY
19# include "dawn/io/battery.hxx"
20#endif
21#ifdef CONFIG_DAWN_IO_CONFIG
22# include "dawn/io/config.hxx"
23#endif
24#ifdef CONFIG_DAWN_IO_CONTROL
25# include "dawn/io/control.hxx"
26#endif
27#ifdef CONFIG_DAWN_IO_TRIGGER
28# include "dawn/io/trigger.hxx"
29#endif
30#ifdef CONFIG_DAWN_IO_DUMMY
31# include "dawn/io/dummy.hxx"
32#endif
33#ifdef CONFIG_DAWN_IO_DUMMY_NOTIFY
34# include "dawn/io/dummy_notify.hxx"
35#endif
36#ifdef CONFIG_DAWN_IO_DAC
37# include "dawn/io/dac.hxx"
38#endif
39#ifdef CONFIG_DAWN_IO_ENCODER
40# include "dawn/io/encoder.hxx"
41#endif
42#ifdef CONFIG_DAWN_IO_ENCODER_INDEX
43# include "dawn/io/encoder_index.hxx"
44#endif
45#ifdef CONFIG_DAWN_IO_PWM
46# include "dawn/io/pwm.hxx"
47#endif
48#ifdef CONFIG_DAWN_IO_PULSECOUNT
49# include "dawn/io/pulsecount.hxx"
50#endif
51#ifdef CONFIG_DAWN_IO_DESCRIPTOR
52# include "dawn/io/descriptor.hxx"
53#endif
54#ifdef CONFIG_DAWN_IO_CAPABILITIES
55# include "dawn/io/capabilities.hxx"
56#endif
57#ifdef CONFIG_DAWN_IO_DESC_SELECTOR
58# include "dawn/io/descselector.hxx"
59#endif
60#ifdef CONFIG_DAWN_IO_FILE
61# include "dawn/io/fileio.hxx"
62#endif
63#ifdef CONFIG_DAWN_IO_GPO
64# include "dawn/io/gpo.hxx"
65#endif
66#ifdef CONFIG_DAWN_IO_GPI
67# include "dawn/io/gpi.hxx"
68#endif
69#ifdef CONFIG_DAWN_IO_BUTTONS
70# include "dawn/io/buttons.hxx"
71#endif
72#ifdef CONFIG_DAWN_IO_LTE_SIGNAL
73# include "dawn/io/lte_signal.hxx"
74#endif
75#ifdef CONFIG_DAWN_IO_LEDS
76# include "dawn/io/leds.hxx"
77#endif
78#ifdef CONFIG_DAWN_IO_RGB_LED
79# include "dawn/io/rgbled.hxx"
80#endif
81#ifdef CONFIG_DAWN_IO_VIRT
82# include "dawn/io/virt.hxx"
83#endif
84#ifdef CONFIG_DAWN_IO_SENSOR
85# include "dawn/io/gnss.hxx"
86# include "dawn/io/sensor.hxx"
87#endif
88#ifdef CONFIG_DAWN_IO_SENSOR_PRODUCER
89# include "dawn/io/sensor_producer.hxx"
90#endif
91#ifdef CONFIG_DAWN_IO_BOARDCTL
92# include "dawn/io/boardctl.hxx"
93#endif
94#ifdef CONFIG_DAWN_IO_SYSINFO
95# include "dawn/io/sysinfo.hxx"
96#endif
97#ifdef CONFIG_DAWN_IO_UNAME
98# include "dawn/io/uname.hxx"
99#endif
100#ifdef CONFIG_DAWN_IO_UUID
101# include "dawn/io/uuid.hxx"
102#endif
103#ifdef CONFIG_DAWN_IO_SYSTIME
104# include "dawn/io/systime.hxx"
105#endif
106#ifdef CONFIG_DAWN_IO_TIMESTAMPIO
107# include "dawn/io/timestamp.hxx"
108#endif
109#ifdef CONFIG_DAWN_IO_RANDIO
110# include "dawn/io/rand.hxx"
111#endif
112
113using namespace dawn;
114
116{
117 DEBUGASSERT(desc.getObjectType() == SObjectId::OBJTYPE_IO);
118
119 // Create io object
120
121 switch (desc.getObjectCls())
122 {
123#ifdef CONFIG_DAWN_IO_CONFIG
125 return new CIOConfig(desc);
126#endif
127
128#ifdef CONFIG_DAWN_IO_CONTROL
130 return new CIOControl(desc);
131#endif
132
133#ifdef CONFIG_DAWN_IO_TRIGGER
135 return new CIOTrigger(desc);
136#endif
137
138#ifdef CONFIG_DAWN_IO_DUMMY
140 return new CIODummy(desc);
141#endif
142
143#ifdef CONFIG_DAWN_IO_DUMMY_NOTIFY
145 return new CIODummyNotify(desc);
146#endif
147
148#ifdef CONFIG_DAWN_IO_TIMESTAMPIO
150 return new CIOTimestamp(desc);
151#endif
152
153#ifdef CONFIG_DAWN_IO_RANDIO
155 return new CIORand(desc);
156#endif
157
158#ifdef CONFIG_DAWN_IO_SYSINFO
161 return new CIOSysinfo(desc);
162#endif
163
164#ifdef CONFIG_DAWN_IO_BOARDCTL
168 return new CIOBoardctl(desc);
169#endif
170
171#ifdef CONFIG_DAWN_IO_UNAME
173 return new CIOUname(desc);
174#endif
175
176#ifdef CONFIG_DAWN_IO_UUID
178 return new CIOUuid(desc);
179#endif
180
181#ifdef CONFIG_DAWN_IO_SYSTIME
183 return new CIOSystime(desc);
184#endif
185
186#ifdef CONFIG_DAWN_IO_SENSOR
200 return new CIOSensor(desc);
205 return new CIOSensorGnss(desc);
206#endif
207
208#ifdef CONFIG_DAWN_IO_SENSOR_PRODUCER
222 return new CIOSensorProducer(desc);
223#endif
224
225#ifdef CONFIG_DAWN_IO_ADC_FETCH
227 return new CIOAdcFetch(desc);
228#endif
229
230#ifdef CONFIG_DAWN_IO_ADC_SYNC
232 return new CIOAdcSync(desc);
233#endif
234
235#ifdef CONFIG_DAWN_IO_ADC_STREAM
237 return new CIOAdcStream(desc);
238#endif
239
240#ifdef CONFIG_DAWN_IO_BATT_VOLT
242 return new CIOBattVolt(desc);
243#endif
244
245#ifdef CONFIG_DAWN_IO_BATT_SOC
247 return new CIOBattSoc(desc);
248#endif
249
250#ifdef CONFIG_DAWN_IO_BATT_STATE
252 return new CIOBattState(desc);
253#endif
254
255#ifdef CONFIG_DAWN_IO_DAC
257 return new CIODac(desc);
258#endif
259
260#ifdef CONFIG_DAWN_IO_ENCODER
262 return new CIOEncoder(desc);
263#endif
264
265#ifdef CONFIG_DAWN_IO_ENCODER_INDEX
267 return new CIOEncoderIndex(desc);
268#endif
269
270#ifdef CONFIG_DAWN_IO_PWM
272 return new CIOPwm(desc);
273#endif
274
275#ifdef CONFIG_DAWN_IO_PULSECOUNT
277 return new CIOPulseCount(desc);
278#endif
279
280#ifdef CONFIG_DAWN_IO_DESCRIPTOR
282 return new CIODescriptor(desc);
283#endif
284
285#ifdef CONFIG_DAWN_IO_CAPABILITIES
287 return new CIOCapabilities(desc);
288#endif
289
290#ifdef CONFIG_DAWN_IO_DESC_SELECTOR
292 return new CIODescSelector(desc);
293#endif
294
295#ifdef CONFIG_DAWN_IO_FILE
297 return new CIOFile(desc);
298#endif
299
300#ifdef CONFIG_DAWN_IO_GPO
302 return new CIOGpo(desc);
303#endif
304
305#ifdef CONFIG_DAWN_IO_GPI
307 return new CIOGpi(desc);
308#endif
309
310#ifdef CONFIG_DAWN_IO_BUTTONS
312 return new CIOButtons(desc);
313#endif
314
315#ifdef CONFIG_DAWN_IO_LTE_SIGNAL
317 return new CIOLteSignal(desc);
318#endif
319
320#ifdef CONFIG_DAWN_IO_LEDS
322 return new CIOLeds(desc);
323#endif
324
325#ifdef CONFIG_DAWN_IO_RGB_LED
327 return new CIORgbLed(desc);
328#endif
329
330#ifdef CONFIG_DAWN_IO_VIRT
332 return new CIOVirt(desc);
333#endif
334
335 default:
336 {
337 DAWNERR("Unknown IO class %d\n", desc.getObjectCls());
338 return nullptr;
339 }
340 }
341}
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
Battery state of charge in percent (DTYPE_UINT32).
Definition battery.hxx:111
Battery charge state as a numeric code (BATTERY_*; DTYPE_UINT32).
Definition battery.hxx:137
Battery voltage in mV (DTYPE_UINT32).
Definition battery.hxx:85
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:185
@ IO_CLASS_TRIGGER
Trigger I/O.
Definition common.hxx:91
@ IO_CLASS_PWM
PWM output.
Definition common.hxx:180
@ IO_CLASS_SYSTEM_RESETCAUSE
Reset cause.
Definition common.hxx:161
@ IO_CLASS_ADC_STREAM
ADC stream (batch/high-throughput)
Definition common.hxx:188
@ IO_CLASS_VIRT
Virtual I/O.
Definition common.hxx:207
@ IO_CLASS_SYSTEM_UPTIME
System uptime.
Definition common.hxx:158
@ IO_CLASS_BATTERY_VOLTAGE
Battery voltage (fuel gauge)
Definition common.hxx:197
@ IO_CLASS_SYSTEM_POWEROFF
Power off control.
Definition common.hxx:162
@ IO_CLASS_BATTERY_STATE
Battery charge state.
Definition common.hxx:199
@ IO_CLASS_GPI_SINGLE
Single GPIO input.
Definition common.hxx:172
@ 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:165
@ IO_CLASS_SENSOR_PRODUCER_HUMIDITY
Humidity publisher.
Definition common.hxx:135
@ IO_CLASS_ENCODER_INDEX
Quadrature encoder (position+index)
Definition common.hxx:193
@ IO_CLASS_SENSOR_PRODUCER_IR
Infrared publisher.
Definition common.hxx:139
@ IO_CLASS_ADC_FETCH
ADC fetch (on-demand)
Definition common.hxx:186
@ IO_CLASS_CAPABILITIES
Capabilities bitmask I/O.
Definition common.hxx:94
@ IO_CLASS_PULSECOUNT
Finite pulse-train output.
Definition common.hxx:181
@ 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_GNSS_TIME
GNSS UTC time (seconds since epoch)
Definition common.hxx:148
@ 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:174
@ IO_CLASS_SYSTEM_HOSTNAME
System hostname.
Definition common.hxx:163
@ IO_CLASS_SENSOR_GNSS_INFO
GNSS accuracy + DOP (eph/epv/hdop/pdop/vdop)
Definition common.hxx:149
@ 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_SENSOR_GNSS
GNSS position+velocity (lat/lon/alt/speed/course)
Definition common.hxx:147
@ 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:164
@ IO_CLASS_SENSOR_GNSS_SATELLITES
GNSS satellites used in fix.
Definition common.hxx:150
@ IO_CLASS_ADC_SYNC
ADC sync (HW-triggered control loop)
Definition common.hxx:187
@ IO_CLASS_ENCODER
Quadrature encoder (position)
Definition common.hxx:192
@ IO_CLASS_GPO_SINGLE
Single GPIO output.
Definition common.hxx:173
@ IO_CLASS_SENSOR_IR
Infrared sensor.
Definition common.hxx:123
@ IO_CLASS_SYSTEM_CPULOAD
CPU load.
Definition common.hxx:159
@ IO_CLASS_SENSOR_PRODUCER_PROXIMITY
Proximity publisher.
Definition common.hxx:134
@ IO_CLASS_SENSOR_ATEMPERATURE
Ambient temperature sensor.
Definition common.hxx:121
@ IO_CLASS_BATTERY_SOC
Battery state of charge (%)
Definition common.hxx:198
@ IO_CLASS_DUMMY_NOTIFY
Timer-driven dummy IO.
Definition common.hxx:105
@ IO_CLASS_LEDS
LED output.
Definition common.hxx:175
@ IO_CLASS_RGBLED
RGB LED output.
Definition common.hxx:176
@ IO_CLASS_RAND
Random number generator.
Definition common.hxx:104
@ IO_CLASS_SENSOR_GAS
Gas sensor.
Definition common.hxx:125
@ IO_CLASS_LTE_SIGNAL
LTE signal quality (RSRP/RSRQ/SINR/RSSI)
Definition common.hxx:203
@ 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:160
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:115
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
LTE modem signal-quality I/O (read-only, timer-driven).
Finite pulse-train output backed by the NuttX PULSECOUNT driver.
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
GNSS sensor I/O.
Definition gnss.hxx:31
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