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_POT
40# include "dawn/io/pot.hxx"
41#endif
42#ifdef CONFIG_DAWN_IO_ENCODER
43# include "dawn/io/encoder.hxx"
44#endif
45#ifdef CONFIG_DAWN_IO_ENCODER_INDEX
46# include "dawn/io/encoder_index.hxx"
47#endif
48#ifdef CONFIG_DAWN_IO_PWM
49# include "dawn/io/pwm.hxx"
50#endif
51#ifdef CONFIG_DAWN_IO_PULSECOUNT
52# include "dawn/io/pulsecount.hxx"
53#endif
54#ifdef CONFIG_DAWN_IO_DESCRIPTOR
55# include "dawn/io/descriptor.hxx"
56#endif
57#ifdef CONFIG_DAWN_IO_CAPABILITIES
58# include "dawn/io/capabilities.hxx"
59#endif
60#ifdef CONFIG_DAWN_IO_DESC_SELECTOR
61# include "dawn/io/descselector.hxx"
62#endif
63#ifdef CONFIG_DAWN_IO_FILE
64# include "dawn/io/fileio.hxx"
65#endif
66#ifdef CONFIG_DAWN_IO_GPO
67# include "dawn/io/gpo.hxx"
68#endif
69#ifdef CONFIG_DAWN_IO_GPI
70# include "dawn/io/gpi.hxx"
71#endif
72#ifdef CONFIG_DAWN_IO_BUTTONS
73# include "dawn/io/buttons.hxx"
74#endif
75#ifdef CONFIG_DAWN_IO_LTE_SIGNAL
76# include "dawn/io/lte_signal.hxx"
77#endif
78#ifdef CONFIG_DAWN_IO_LEDS
79# include "dawn/io/leds.hxx"
80#endif
81#ifdef CONFIG_DAWN_IO_RGB_LED
82# include "dawn/io/rgbled.hxx"
83#endif
84#ifdef CONFIG_DAWN_IO_VIRT
85# include "dawn/io/virt.hxx"
86#endif
87#ifdef CONFIG_DAWN_IO_SENSOR
88# include "dawn/io/gnss.hxx"
89# include "dawn/io/sensor.hxx"
90#endif
91#ifdef CONFIG_DAWN_IO_SENSOR_PRODUCER
92# include "dawn/io/sensor_producer.hxx"
93#endif
94#ifdef CONFIG_DAWN_IO_BOARDCTL
95# include "dawn/io/boardctl.hxx"
96#endif
97#ifdef CONFIG_DAWN_IO_SYSINFO
98# include "dawn/io/sysinfo.hxx"
99#endif
100#ifdef CONFIG_DAWN_IO_UNAME
101# include "dawn/io/uname.hxx"
102#endif
103#ifdef CONFIG_DAWN_IO_UUID
104# include "dawn/io/uuid.hxx"
105#endif
106#ifdef CONFIG_DAWN_IO_SYSTIME
107# include "dawn/io/systime.hxx"
108#endif
109#ifdef CONFIG_DAWN_IO_TIMESTAMPIO
110# include "dawn/io/timestamp.hxx"
111#endif
112#ifdef CONFIG_DAWN_IO_RANDIO
113# include "dawn/io/rand.hxx"
114#endif
115
116using namespace dawn;
117
119{
120 DEBUGASSERT(desc.getObjectType() == SObjectId::OBJTYPE_IO);
121
122 // Create io object
123
124 switch (desc.getObjectCls())
125 {
126#ifdef CONFIG_DAWN_IO_CONFIG
128 return new CIOConfig(desc);
129#endif
130
131#ifdef CONFIG_DAWN_IO_CONTROL
133 return new CIOControl(desc);
134#endif
135
136#ifdef CONFIG_DAWN_IO_TRIGGER
138 return new CIOTrigger(desc);
139#endif
140
141#ifdef CONFIG_DAWN_IO_DUMMY
143 return new CIODummy(desc);
144#endif
145
146#ifdef CONFIG_DAWN_IO_DUMMY_NOTIFY
148 return new CIODummyNotify(desc);
149#endif
150
151#ifdef CONFIG_DAWN_IO_TIMESTAMPIO
153 return new CIOTimestamp(desc);
154#endif
155
156#ifdef CONFIG_DAWN_IO_RANDIO
158 return new CIORand(desc);
159#endif
160
161#ifdef CONFIG_DAWN_IO_SYSINFO
164 return new CIOSysinfo(desc);
165#endif
166
167#ifdef CONFIG_DAWN_IO_BOARDCTL
171 return new CIOBoardctl(desc);
172#endif
173
174#ifdef CONFIG_DAWN_IO_UNAME
176 return new CIOUname(desc);
177#endif
178
179#ifdef CONFIG_DAWN_IO_UUID
181 return new CIOUuid(desc);
182#endif
183
184#ifdef CONFIG_DAWN_IO_SYSTIME
186 return new CIOSystime(desc);
187#endif
188
189#ifdef CONFIG_DAWN_IO_SENSOR
205 return new CIOSensor(desc);
210 return new CIOSensorGnss(desc);
211#endif
212
213#ifdef CONFIG_DAWN_IO_SENSOR_PRODUCER
229 return new CIOSensorProducer(desc);
230#endif
231
232#ifdef CONFIG_DAWN_IO_ADC_FETCH
234 return new CIOAdcFetch(desc);
235#endif
236
237#ifdef CONFIG_DAWN_IO_ADC_SYNC
239 return new CIOAdcSync(desc);
240#endif
241
242#ifdef CONFIG_DAWN_IO_ADC_STREAM
244 return new CIOAdcStream(desc);
245#endif
246
247#ifdef CONFIG_DAWN_IO_BATT_VOLT
249 return new CIOBattVolt(desc);
250#endif
251
252#ifdef CONFIG_DAWN_IO_BATT_SOC
254 return new CIOBattSoc(desc);
255#endif
256
257#ifdef CONFIG_DAWN_IO_BATT_STATE
259 return new CIOBattState(desc);
260#endif
261
262#ifdef CONFIG_DAWN_IO_DAC
264 return new CIODac(desc);
265#endif
266
267#ifdef CONFIG_DAWN_IO_POT
269 return new CIOPot(desc);
270#endif
271
272#ifdef CONFIG_DAWN_IO_ENCODER
274 return new CIOEncoder(desc);
275#endif
276
277#ifdef CONFIG_DAWN_IO_ENCODER_INDEX
279 return new CIOEncoderIndex(desc);
280#endif
281
282#ifdef CONFIG_DAWN_IO_PWM
284 return new CIOPwm(desc);
285#endif
286
287#ifdef CONFIG_DAWN_IO_PULSECOUNT
289 return new CIOPulseCount(desc);
290#endif
291
292#ifdef CONFIG_DAWN_IO_DESCRIPTOR
294 return new CIODescriptor(desc);
295#endif
296
297#ifdef CONFIG_DAWN_IO_CAPABILITIES
299 return new CIOCapabilities(desc);
300#endif
301
302#ifdef CONFIG_DAWN_IO_DESC_SELECTOR
304 return new CIODescSelector(desc);
305#endif
306
307#ifdef CONFIG_DAWN_IO_FILE
309 return new CIOFile(desc);
310#endif
311
312#ifdef CONFIG_DAWN_IO_GPO
314 return new CIOGpo(desc);
315#endif
316
317#ifdef CONFIG_DAWN_IO_GPI
319 return new CIOGpi(desc);
320#endif
321
322#ifdef CONFIG_DAWN_IO_BUTTONS
324 return new CIOButtons(desc);
325#endif
326
327#ifdef CONFIG_DAWN_IO_LTE_SIGNAL
329 return new CIOLteSignal(desc);
330#endif
331
332#ifdef CONFIG_DAWN_IO_LEDS
334 return new CIOLeds(desc);
335#endif
336
337#ifdef CONFIG_DAWN_IO_RGB_LED
339 return new CIORgbLed(desc);
340#endif
341
342#ifdef CONFIG_DAWN_IO_VIRT
344 return new CIOVirt(desc);
345#endif
346
347 default:
348 {
349 DAWNERR("Unknown IO class %d\n", desc.getObjectCls());
350 return nullptr;
351 }
352 }
353}
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:132
@ IO_CLASS_SENSOR_MAGNETICFIELD
Magnetic field sensor.
Definition common.hxx:114
@ IO_CLASS_SENSOR_PRODUCER_ACCELEROMETER
Accelerometer publisher.
Definition common.hxx:131
@ IO_CLASS_DAC
Digital-to-analog converter.
Definition common.hxx:188
@ IO_CLASS_TRIGGER
Trigger I/O.
Definition common.hxx:91
@ IO_CLASS_PWM
PWM output.
Definition common.hxx:183
@ IO_CLASS_SYSTEM_RESETCAUSE
Reset cause.
Definition common.hxx:164
@ IO_CLASS_ADC_STREAM
ADC stream (batch/high-throughput)
Definition common.hxx:191
@ IO_CLASS_VIRT
Virtual I/O.
Definition common.hxx:214
@ IO_CLASS_SYSTEM_UPTIME
System uptime.
Definition common.hxx:161
@ IO_CLASS_BATTERY_VOLTAGE
Battery voltage (fuel gauge)
Definition common.hxx:204
@ IO_CLASS_SYSTEM_POWEROFF
Power off control.
Definition common.hxx:165
@ IO_CLASS_BATTERY_STATE
Battery charge state.
Definition common.hxx:206
@ IO_CLASS_GPI_SINGLE
Single GPIO input.
Definition common.hxx:175
@ IO_CLASS_SENSOR_PRODUCER_LIGHT
Light publisher.
Definition common.hxx:134
@ IO_CLASS_SENSOR_PRODUCER_ATEMPERATURE
Ambient temperature publisher.
Definition common.hxx:139
@ IO_CLASS_SYSTEM_SYSTEMTIME
System time.
Definition common.hxx:168
@ IO_CLASS_SENSOR_PRODUCER_HUMIDITY
Humidity publisher.
Definition common.hxx:137
@ IO_CLASS_ENCODER_INDEX
Quadrature encoder (position+index)
Definition common.hxx:196
@ IO_CLASS_SENSOR_PRODUCER_IR
Infrared publisher.
Definition common.hxx:141
@ IO_CLASS_ADC_FETCH
ADC fetch (on-demand)
Definition common.hxx:189
@ IO_CLASS_CAPABILITIES
Capabilities bitmask I/O.
Definition common.hxx:94
@ IO_CLASS_PULSECOUNT
Finite pulse-train output.
Definition common.hxx:184
@ IO_CLASS_SENSOR_LIGHT
Light sensor.
Definition common.hxx:116
@ IO_CLASS_SENSOR_CO2
CO2 concentration sensor.
Definition common.hxx:126
@ IO_CLASS_SENSOR_BAROMETER
Barometer sensor.
Definition common.hxx:117
@ IO_CLASS_SENSOR_PRODUCER_UV
Ultraviolet publisher.
Definition common.hxx:142
@ 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:151
@ IO_CLASS_SENSOR_PRODUCER_GAS
Gas publisher.
Definition common.hxx:143
@ 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:133
@ IO_CLASS_SENSOR_PRODUCER_CO2
CO2 concentration publisher.
Definition common.hxx:144
@ IO_CLASS_CONTROL
Control I/O.
Definition common.hxx:93
@ IO_CLASS_BUTTONS
Button input.
Definition common.hxx:177
@ IO_CLASS_SYSTEM_HOSTNAME
System hostname.
Definition common.hxx:166
@ IO_CLASS_SENSOR_GNSS_INFO
GNSS accuracy + DOP (eph/epv/hdop/pdop/vdop)
Definition common.hxx:152
@ IO_CLASS_SENSOR_PRODUCER_RGB
RGB color publisher.
Definition common.hxx:140
@ IO_CLASS_SENSOR_PRODUCER_TEMPERATURE
Temperature publisher.
Definition common.hxx:138
@ 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:150
@ 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:167
@ IO_CLASS_SENSOR_PRODUCER_TVOC
TVOC concentration publisher.
Definition common.hxx:145
@ IO_CLASS_SENSOR_GNSS_SATELLITES
GNSS satellites used in fix.
Definition common.hxx:153
@ IO_CLASS_ADC_SYNC
ADC sync (HW-triggered control loop)
Definition common.hxx:190
@ IO_CLASS_ENCODER
Quadrature encoder (position)
Definition common.hxx:195
@ IO_CLASS_GPO_SINGLE
Single GPIO output.
Definition common.hxx:176
@ IO_CLASS_SENSOR_IR
Infrared sensor.
Definition common.hxx:123
@ IO_CLASS_SYSTEM_CPULOAD
CPU load.
Definition common.hxx:162
@ IO_CLASS_SENSOR_PRODUCER_PROXIMITY
Proximity publisher.
Definition common.hxx:136
@ IO_CLASS_SENSOR_ATEMPERATURE
Ambient temperature sensor.
Definition common.hxx:121
@ IO_CLASS_BATTERY_SOC
Battery state of charge (%)
Definition common.hxx:205
@ IO_CLASS_DUMMY_NOTIFY
Timer-driven dummy IO.
Definition common.hxx:105
@ IO_CLASS_LEDS
LED output.
Definition common.hxx:178
@ IO_CLASS_RGBLED
RGB LED output.
Definition common.hxx:179
@ IO_CLASS_RAND
Random number generator.
Definition common.hxx:104
@ IO_CLASS_SENSOR_TVOC
TVOC concentration sensor.
Definition common.hxx:127
@ IO_CLASS_SENSOR_GAS
Gas sensor.
Definition common.hxx:125
@ IO_CLASS_LTE_SIGNAL
LTE signal quality (RSRP/RSRQ/SINR/RSSI)
Definition common.hxx:210
@ IO_CLASS_POT
Digital potentiometer wiper.
Definition common.hxx:200
@ IO_CLASS_SENSOR_PRODUCER_BAROMETER
Barometer publisher.
Definition common.hxx:135
@ IO_CLASS_DESCRIPTOR
Descriptor I/O.
Definition common.hxx:92
@ IO_CLASS_SYSTEM_RESET
System reset control.
Definition common.hxx:163
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:118
File system I/O access.
Definition fileio.hxx:28
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).
Digital potentiometer (POT) wiper I/O type.
Definition pot.hxx:23
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