Difference between revisions of "Zephyr drivers"

From Wiki at Neela Nurseries
Jump to navigation Jump to search
m (Add link to sensor_attr_get())
m (Add notes on sensor_attr_set and sensor enums for channels and attributes)
Line 18: Line 18:
  
 
*  https://docs.zephyrproject.org/4.3.0/doxygen/html/group__sensor__interface.html#gaedfdfc71dce702dc1fb1c6e60ff0f73a
 
*  https://docs.zephyrproject.org/4.3.0/doxygen/html/group__sensor__interface.html#gaedfdfc71dce702dc1fb1c6e60ff0f73a
 +
 +
Zephyr's sensor model plays a big role in the design of sensor drivers for this RTOS.  Zephyr's [... sensor.h] header defines many things.  Two important enums from this header file are:
 +
 +
_ Sensor channel enum _
 +
 +
*  https://github.com/zephyrproject-rtos/zephyr/blob/main/include/zephyr/drivers/sensor.h#L65
 +
 +
_ Sensor attribute enum _
 +
 +
*  https://github.com/zephyrproject-rtos/zephyr/blob/main/include/zephyr/drivers/sensor.h#L342
 +
 +
Sensor channels generally correspond to readings of a quantity in specific units, like degrees centigrade and acceleration in the x-axis.  Sensor attributes generally corrrespond to configuration settings for a sensor, where these settings modify the way in which readings are taken and reported.
 +
 +
For a Zephyr driver to support configuration of a sensor's attributes, it must implement a function of the form:
 +
 +
<pre>
 +
sensor_attr_set()
 +
int sensor_attr_set ( const struct device * dev,
 +
enum sensor_channel chan,
 +
enum sensor_attribute attr,
 +
const struct sensor_value * val )
 +
</pre>
 +
 +
. . . whose typedef is at https://github.com/zephyrproject-rtos/zephyr/blob/main/include/zephyr/drivers/sensor.h#L431.
 +
 +
  
 
== [[#top|^]] References ==
 
== [[#top|^]] References ==

Revision as of 22:27, 21 February 2026

Keywords: sensor interrupts : sensor triggers : Zephyr triggers : sensor interrupt support

OVERVIEW

This page a stash point to hold Zephyr driver notes. Zephyr RTOS project includes a range of types of drivers. First type referenced by this page will be Zephyr's sensor drivers.

^ Zephyr Sensor Model

Zephyr 4.3.0 device driver documentation:

Zephyr 4.3.0 sensor model:

"Sensor attribute get" function prototype. This prototype reveals Zephyr's enumerations for sensor yyy . . .

Zephyr's sensor model plays a big role in the design of sensor drivers for this RTOS. Zephyr's [... sensor.h] header defines many things. Two important enums from this header file are:

_ Sensor channel enum _

_ Sensor attribute enum _

Sensor channels generally correspond to readings of a quantity in specific units, like degrees centigrade and acceleration in the x-axis. Sensor attributes generally corrrespond to configuration settings for a sensor, where these settings modify the way in which readings are taken and reported.

For a Zephyr driver to support configuration of a sensor's attributes, it must implement a function of the form:

sensor_attr_set()
int sensor_attr_set	(	const struct device *	dev,
enum sensor_channel	chan,
enum sensor_attribute	attr,
const struct sensor_value *	val )

. . . whose typedef is at https://github.com/zephyrproject-rtos/zephyr/blob/main/include/zephyr/drivers/sensor.h#L431.


^ References

1. https://github.com/zephyrproject-rtos/zephyr/issues/30133


- - - top of page - - -