Difference between revisions of "Zephyr device driver paradigm"

From Wiki at Neela Nurseries
Jump to: navigation, search
m (sensor_sample_fetch_channel instances)
m (Adding content of Python generated Zephyr app source file containing z_mrsh_sensor_sample_fetch_chan() function.)
Line 85: Line 85:
 
</pre>
 
</pre>
  
                                                                                                                                                     
+
<!-- comment -->
 +
 
 +
== [[#top|^]] Definition of z_mrsh_sensor_sample_fetch_channel ==
 +
 
 
"./z4-sandbox-kionix-work/kionix-driver-demo/build/zephyr/include/generated/syscalls/sensor_sample_fetch_chan_mrsh.c" 27L, 901C      1,1          All
 
"./z4-sandbox-kionix-work/kionix-driver-demo/build/zephyr/include/generated/syscalls/sensor_sample_fetch_chan_mrsh.c" 27L, 901C      1,1          All
  

Revision as of 22:52, 1 September 2021

Notes and links to Zephyr device driver paradigm.


^ sensor_sample_fetch_channel instances

In Zephyr 2.6.0, Zephyr RTOS device driver API function sensor_sample_fetch_chan() entails several key elements of Zephyr's device driver architecture. This function also has no "direct" expression in this RTOS' source code tree. Rather this API function is generated at Zephyr app build time (need link to overview of Zephyr build tools and process). A search for this function in a Zephyr application gives:

ted@localhost:~/projects/zephyr-based/z3-aqw-demo/air-quality-wing-zephyr-demo$ ls
basic  ble  bootloader  golioth  img  Makefile  modules  README.md  tools  west.yml  zephyr
ted@localhost:~/projects/zephyr-based/z3-aqw-demo/air-quality-wing-zephyr-demo$ grep -nr sensor_sample_fetch_chan ./*
./zephyr/drivers/sensor/sensor_handlers.c:41:static inline int z_vrfy_sensor_sample_fetch_chan(const struct device *dev,
./zephyr/drivers/sensor/sensor_handlers.c:45:	return z_impl_sensor_sample_fetch_chan((const struct device *)dev,
./zephyr/drivers/sensor/sensor_handlers.c:48:#include <syscalls/sensor_sample_fetch_chan_mrsh.c>
./zephyr/include/drivers/sensor.h:535:__syscall int sensor_sample_fetch_chan(const struct device *dev,
./zephyr/include/drivers/sensor.h:538:static inline int z_impl_sensor_sample_fetch_chan(const struct device *dev,
./zephyr/include/drivers/sensor.h:553: * @ref sensor_sample_fetch_chan. It is guaranteed that two subsequent
./zephyr/include/drivers/sensor.h:555: * value, if @ref sensor_sample_fetch or @ref sensor_sample_fetch_chan
./zephyr/tests/drivers/sensor/generic/src/main.c:115:	zassert_equal(sensor_sample_fetch_chan(dev, chan_elements[0].chan),
./zephyr/tests/drivers/sensor/sbs_gauge/src/test_sbs_gauge.c:25:	zassert_true(sensor_sample_fetch_chan(dev, channel) < 0, "Sample fetch failed");
./zephyr/tests/drivers/sensor/sbs_gauge/src/test_sbs_gauge.c:33:	zassert_true(sensor_sample_fetch_chan(dev, channel) == -ENOTSUP, "Invalid function");
./zephyr/samples/shields/x_nucleo_iks01a2/sensorhub/src/main.c:19:	sensor_sample_fetch_chan(dev, SENSOR_CHAN_ALL);
./zephyr/samples/shields/x_nucleo_iks01a2/standard/src/main.c:19:	sensor_sample_fetch_chan(dev, SENSOR_CHAN_ALL);
./zephyr/samples/shields/x_nucleo_iks01a3/sensorhub/src/main.c:19:	sensor_sample_fetch_chan(dev, SENSOR_CHAN_ACCEL_XYZ);
./zephyr/samples/shields/x_nucleo_iks01a3/sensorhub/src/main.c:32:	sensor_sample_fetch_chan(dev, SENSOR_CHAN_ACCEL_XYZ);
./zephyr/samples/shields/x_nucleo_iks01a3/sensorhub/src/main.c:39:	sensor_sample_fetch_chan(dev, SENSOR_CHAN_GYRO_XYZ);
./zephyr/samples/shields/x_nucleo_iks01a3/sensorhub/src/main.c:46:	sensor_sample_fetch_chan(dev, SENSOR_CHAN_DIE_TEMP);
./zephyr/samples/shields/x_nucleo_iks01a3/standard/src/main.c:19:	sensor_sample_fetch_chan(dev, SENSOR_CHAN_ALL);
./zephyr/samples/shields/x_nucleo_iks01a3/standard/src/main.c:30:	sensor_sample_fetch_chan(dev, SENSOR_CHAN_PRESS);
./zephyr/samples/shields/x_nucleo_iks01a3/standard/src/main.c:51:	sensor_sample_fetch_chan(dev, SENSOR_CHAN_ACCEL_XYZ);
./zephyr/samples/shields/x_nucleo_iks01a3/standard/src/main.c:64:	sensor_sample_fetch_chan(dev, SENSOR_CHAN_ACCEL_XYZ);
./zephyr/samples/shields/x_nucleo_iks01a3/standard/src/main.c:71:	sensor_sample_fetch_chan(dev, SENSOR_CHAN_GYRO_XYZ);
./zephyr/samples/shields/x_nucleo_iks01a3/standard/src/main.c:78:	sensor_sample_fetch_chan(dev, SENSOR_CHAN_DIE_TEMP);
./zephyr/samples/shields/x_nucleo_iks01a1/src/main.c:19:	sensor_sample_fetch_chan(dev, trig->chan);
./zephyr/samples/shields/x_nucleo_iks02a1/sensorhub/src/main.c:19:	sensor_sample_fetch_chan(dev, SENSOR_CHAN_ACCEL_XYZ);
./zephyr/samples/shields/x_nucleo_iks02a1/sensorhub/src/main.c:32:	sensor_sample_fetch_chan(dev, SENSOR_CHAN_ACCEL_XYZ);
./zephyr/samples/shields/x_nucleo_iks02a1/sensorhub/src/main.c:39:	sensor_sample_fetch_chan(dev, SENSOR_CHAN_GYRO_XYZ);
./zephyr/samples/shields/x_nucleo_iks02a1/sensorhub/src/main.c:46:	sensor_sample_fetch_chan(dev, SENSOR_CHAN_DIE_TEMP);
./zephyr/samples/shields/x_nucleo_iks02a1/standard/src/main.c:19:	sensor_sample_fetch_chan(dev, SENSOR_CHAN_ACCEL_XYZ);
./zephyr/samples/shields/x_nucleo_iks02a1/standard/src/main.c:30:	sensor_sample_fetch_chan(dev, SENSOR_CHAN_ALL);
./zephyr/samples/shields/x_nucleo_iks02a1/standard/src/main.c:42:	sensor_sample_fetch_chan(dev, SENSOR_CHAN_ACCEL_XYZ);
./zephyr/samples/shields/x_nucleo_iks02a1/standard/src/main.c:49:	sensor_sample_fetch_chan(dev, SENSOR_CHAN_GYRO_XYZ);
./zephyr/samples/boards/96b_argonkey/sensors/src/main.c:48:	sensor_sample_fetch_chan(dev, SENSOR_CHAN_ACCEL_XYZ);
./zephyr/samples/boards/96b_argonkey/sensors/src/main.c:60:	sensor_sample_fetch_chan(dev, SENSOR_CHAN_GYRO_XYZ);
./zephyr/samples/boards/96b_argonkey/sensors/src/main.c:73:	sensor_sample_fetch_chan(dev, SENSOR_CHAN_MAGN_XYZ);
./zephyr/samples/boards/96b_argonkey/sensors/src/main.c:87:	sensor_sample_fetch_chan(dev, SENSOR_CHAN_PRESS);
./zephyr/samples/boards/96b_argonkey/sensors/src/main.c:90:	sensor_sample_fetch_chan(dev, SENSOR_CHAN_AMBIENT_TEMP);
./zephyr/samples/boards/96b_argonkey/sensors/src/main.c:311:		sensor_sample_fetch_chan(accel_dev, SENSOR_CHAN_ACCEL_XYZ);
./zephyr/samples/boards/96b_argonkey/sensors/src/main.c:321:		sensor_sample_fetch_chan(accel_dev, SENSOR_CHAN_GYRO_XYZ);
./zephyr/samples/boards/96b_argonkey/sensors/src/main.c:331:		sensor_sample_fetch_chan(accel_dev, SENSOR_CHAN_MAGN_XYZ);
./zephyr/samples/boards/96b_argonkey/sensors/src/main.c:342:		sensor_sample_fetch_chan(accel_dev, SENSOR_CHAN_PRESS);
./zephyr/samples/boards/96b_argonkey/sensors/src/main.c:345:		sensor_sample_fetch_chan(accel_dev, SENSOR_CHAN_AMBIENT_TEMP);
./zephyr/samples/boards/sensortile_box/src/main.c:29:	sensor_sample_fetch_chan(dev, SENSOR_CHAN_PRESS);
./zephyr/samples/boards/sensortile_box/src/main.c:40:	sensor_sample_fetch_chan(dev, SENSOR_CHAN_ACCEL_XYZ);
./zephyr/samples/boards/sensortile_box/src/main.c:53:	sensor_sample_fetch_chan(dev, SENSOR_CHAN_ACCEL_XYZ);
./zephyr/samples/boards/sensortile_box/src/main.c:60:	sensor_sample_fetch_chan(dev, SENSOR_CHAN_GYRO_XYZ);
./zephyr/samples/boards/sensortile_box/src/main.c:67:	sensor_sample_fetch_chan(dev, SENSOR_CHAN_DIE_TEMP);
./zephyr/samples/boards/sensortile_box/src/main.c:88:	sensor_sample_fetch_chan(dev, SENSOR_CHAN_ACCEL_XYZ);
./zephyr/samples/sensor/lsm6dso/src/main.c:34:	sensor_sample_fetch_chan(dev, SENSOR_CHAN_ACCEL_XYZ);
./zephyr/samples/sensor/lsm6dso/src/main.c:43:	sensor_sample_fetch_chan(dev, SENSOR_CHAN_GYRO_XYZ);
./zephyr/samples/sensor/max6675/src/main.c:34:		ret = sensor_sample_fetch_chan(dev, SENSOR_CHAN_AMBIENT_TEMP);
./zephyr/samples/sensor/lsm6dsl/src/main.c:44:	sensor_sample_fetch_chan(dev, SENSOR_CHAN_ACCEL_XYZ);
./zephyr/samples/sensor/lsm6dsl/src/main.c:50:	sensor_sample_fetch_chan(dev, SENSOR_CHAN_GYRO_XYZ);
./zephyr/samples/sensor/lsm6dsl/src/main.c:57:	sensor_sample_fetch_chan(dev, SENSOR_CHAN_MAGN_XYZ);
./zephyr/samples/sensor/lsm6dsl/src/main.c:65:	sensor_sample_fetch_chan(dev, SENSOR_CHAN_PRESS);
./zephyr/samples/sensor/lsm6dsl/src/main.c:68:	sensor_sample_fetch_chan(dev, SENSOR_CHAN_AMBIENT_TEMP);
./zephyr/samples/sensor/max44009/src/main.c:33:		if (sensor_sample_fetch_chan(dev, SENSOR_CHAN_LIGHT) != 0) {
./zephyr/samples/sensor/bq274xx/src/main.c:35:		status = sensor_sample_fetch_chan(dev,
./zephyr/samples/sensor/bq274xx/src/main.c:51:		status = sensor_sample_fetch_chan(dev,
./zephyr/samples/sensor/bq274xx/src/main.c:67:		status = sensor_sample_fetch_chan(dev,
./zephyr/samples/sensor/bq274xx/src/main.c:84:		status = sensor_sample_fetch_chan(dev,
./zephyr/samples/sensor/bq274xx/src/main.c:102:		status = sensor_sample_fetch_chan(dev,
./zephyr/samples/sensor/bq274xx/src/main.c:119:		status = sensor_sample_fetch_chan(dev,
./zephyr/samples/sensor/bq274xx/src/main.c:136:		status = sensor_sample_fetch_chan(dev,
./zephyr/samples/sensor/bq274xx/src/main.c:152:		status = sensor_sample_fetch_chan(dev,
./zephyr/samples/sensor/bq274xx/src/main.c:170:		status = sensor_sample_fetch_chan(dev,
./zephyr/samples/sensor/bq274xx/src/main.c:189:		status = sensor_sample_fetch_chan(dev, SENSOR_CHAN_GAUGE_TEMP);
ted@localhost:~/projects/zephyr-based/z3-aqw-demo/air-quality-wing-zephyr-demo$


^ Definition of z_mrsh_sensor_sample_fetch_channel

"./z4-sandbox-kionix-work/kionix-driver-demo/build/zephyr/include/generated/syscalls/sensor_sample_fetch_chan_mrsh.c" 27L, 901C 1,1 All

  1 /* auto-generated by gen_syscalls.py, don't edit */
  2 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
  3 #pragma GCC diagnostic push
  4 #endif
  5 #ifdef __GNUC__
  6 #pragma GCC diagnostic ignored "-Wstrict-aliasing"
  7 #endif
  8 #include <syscalls/sensor.h>
  9 
 10 extern int z_vrfy_sensor_sample_fetch_chan(const struct device * dev, enum sensor_channel type);
 11 uintptr_t z_mrsh_sensor_sample_fetch_chan(uintptr_t arg0, uintptr_t arg1, uintptr_t arg2,
 12                 uintptr_t arg3, uintptr_t arg4, uintptr_t arg5, void *ssf)
 13 {
 14         _current->syscall_frame = ssf;
 15         (void) arg2;    /* unused */
 16         (void) arg3;    /* unused */
 17         (void) arg4;    /* unused */
 18         (void) arg5;    /* unused */
 19         int ret = z_vrfy_sensor_sample_fetch_chan(*(const struct device **)&arg0, *(enum sensor_channel*)&arg1)
 20 ;
 21         _current->syscall_frame = NULL;
 22         return (uintptr_t) ret;
 23 }
 24 
 25 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
 26 #pragma GCC diagnostic pop
 27 #endif