Zephyr in tree driver use
Jump to navigation
Jump to search
This page holding notes on how to use Zephyr in-tree drivers.
Code excerpt:
+
+2021-10-13
+
+In file ./z4-sandbox-kionix-work/modules/hal/st/sensor/stmemsc/iis2dh_STdC/driver/iis2dh_reg.c
+
+ 789 /**
+ 790 * @defgroup IIS2DH_Common
+ 791 * @brief This section group common usefull functions
+ 792 * @{
+ 793 *
+ 794 */
+ 795
+ 796 /**
+ 797 * @brief DeviceWhoamI .[get]
+ 798 *
+ 799 * @param ctx read / write interface definitions
+ 800 * @param buff buffer that stores data read
+ 801 * @retval interface status (MANDATORY: return 0 -> no Error)
+ 802 *
+ 803 */
+ 804 int32_t iis2dh_device_id_get(stmdev_ctx_t *ctx, uint8_t *buff)
+ 805 {
+ 806 int32_t ret;
+ 807 ret = iis2dh_read_reg(ctx, IIS2DH_WHO_AM_I, buff, 1);
+ 808 return ret;
+ 809 }
+ 810 /**
+ 811 * @brief Self Test.[set]
+ 812 *
+ 813 * @param ctx read / write interface definitions
+ 814 * @param val change the values of st in reg CTRL_REG4
+ 815 * @retval interface status (MANDATORY: return 0 -> no Error)
+ 816 *
+ 817 */
+
(2)
ted@localhost:~/projects/zephyr-based/z4-sandbox-kionix-work/modules$ grep -nr iis2dh_device_id_get ./* ./hal/st/sensor/stmemsc/iis2dh_STdC/driver/iis2dh_reg.h:762:int32_t iis2dh_device_id_get(stmdev_ctx_t *ctx, uint8_t *buff); ./hal/st/sensor/stmemsc/iis2dh_STdC/driver/iis2dh_reg.c:804:int32_t iis2dh_device_id_get(stmdev_ctx_t *ctx, uint8_t *buff) ted@localhost:~/projects/zephyr-based/z4-sandbox-kionix-work/modules$
(3)
zephyr/../modules/hal/st/sensor/stmemsc/iis2dh_STdC/driver/iis2dh_reg.h:119:} stmdev_ctx_t;
102 /** @addtogroup Interfaces_Functions
103 * @brief This section provide a set of functions used to read and
104 * write a generic register of the device.
105 * MANDATORY: return 0 -> no Error.
106 * @{
107 *
108 */
109
110 typedef int32_t (*stmdev_write_ptr)(void *, uint8_t, uint8_t*, uint16_t);
111 typedef int32_t (*stmdev_read_ptr) (void *, uint8_t, uint8_t*, uint16_t);
112
113 typedef struct {
114 /** Component mandatory fields **/
115 stmdev_write_ptr write_reg;
116 stmdev_read_ptr read_reg;
117 /** Customizable optional pointer **/
118 void *handle;
119 } stmdev_ctx_t;
(4)
./drivers/sensor/iis2dh/iis2dh_i2c.c:39:stmdev_ctx_t iis2dh_i2c_ctx = {