1 /* 2 * Arm SCP/MCP Software 3 * Copyright (c) 2015-2024, Arm Limited and Contributors. All rights reserved. 4 * 5 * SPDX-License-Identifier: BSD-3-Clause 6 */ 7 8 #ifndef MOD_SENSOR_H 9 #define MOD_SENSOR_H 10 11 #include <fwk_id.h> 12 #include <fwk_module_idx.h> 13 14 #include <stdbool.h> 15 #include <stdint.h> 16 17 /*! 18 * \addtogroup GroupModules Modules 19 * \{ 20 */ 21 22 /*! 23 * \defgroup GroupModuleSensor Sensor 24 * 25 * \brief Module for reading hardware sensors. 26 * 27 * \details Module for interfacing with and reading various hardware sensors. 28 * 29 * \{ 30 */ 31 32 /*! 33 * \brief Sensor types as defined by SCMI. 34 */ 35 enum mod_sensor_type { 36 MOD_SENSOR_TYPE_NONE = 0, 37 MOD_SENSOR_TYPE_UNSPECIFIED, 38 MOD_SENSOR_TYPE_DEGREES_C, 39 MOD_SENSOR_TYPE_DEGREES_F, 40 MOD_SENSOR_TYPE_DEGREES_K, 41 MOD_SENSOR_TYPE_VOLTS, 42 MOD_SENSOR_TYPE_AMPS, 43 MOD_SENSOR_TYPE_WATTS, 44 MOD_SENSOR_TYPE_JOULES, 45 MOD_SENSOR_TYPE_COULOMBS, 46 MOD_SENSOR_TYPE_VA, 47 MOD_SENSOR_TYPE_NITS, 48 MOD_SENSOR_TYPE_LUMENS, 49 MOD_SENSOR_TYPE_LUX, 50 MOD_SENSOR_TYPE_CANDELAS, 51 MOD_SENSOR_TYPE_KPA, 52 MOD_SENSOR_TYPE_PSI, 53 MOD_SENSOR_TYPE_NEWTONS, 54 MOD_SENSOR_TYPE_CFM, 55 MOD_SENSOR_TYPE_RPM, 56 MOD_SENSOR_TYPE_HERTZ, 57 MOD_SENSOR_TYPE_SECONDS, 58 MOD_SENSOR_TYPE_MINUTES, 59 MOD_SENSOR_TYPE_HOURS, 60 MOD_SENSOR_TYPE_DAYS, 61 MOD_SENSOR_TYPE_WEEKS, 62 MOD_SENSOR_TYPE_MILS, 63 MOD_SENSOR_TYPE_INCHES, 64 MOD_SENSOR_TYPE_FEET, 65 MOD_SENSOR_TYPE_CUBIC_INCHES, 66 MOD_SENSOR_TYPE_CUBIC_FEET, 67 MOD_SENSOR_TYPE_METERS, 68 MOD_SENSOR_TYPE_CUBIC_CENTIMETERS, 69 MOD_SENSOR_TYPE_CUBIC_METERS, 70 MOD_SENSOR_TYPE_LITRES, 71 MOD_SENSOR_TYPE_FLUID_OUNCES, 72 MOD_SENSOR_TYPE_RADIANS, 73 MOD_SENSOR_TYPE_STERADIANS, 74 MOD_SENSOR_TYPE_REVOLUTIONS, 75 MOD_SENSOR_TYPE_CYCLES, 76 MOD_SENSOR_TYPE_GRAVITIES, 77 MOD_SENSOR_TYPE_OUNCES, 78 MOD_SENSOR_TYPE_POUNDS, 79 MOD_SENSOR_TYPE_FOOT_POUNDS, 80 MOD_SENSOR_TYPE_OUNCE_INCHES, 81 MOD_SENSOR_TYPE_GAUSS, 82 MOD_SENSOR_TYPE_GILBERTS, 83 MOD_SENSOR_TYPE_HENRIES, 84 MOD_SENSOR_TYPE_FARADS, 85 MOD_SENSOR_TYPE_OHMS, 86 MOD_SENSOR_TYPE_SIEMENS, 87 MOD_SENSOR_TYPE_MOLES, 88 MOD_SENSOR_TYPE_BECQUERELS, 89 MOD_SENSOR_TYPE_PPM, 90 MOD_SENSOR_TYPE_DECIBELS, 91 MOD_SENSOR_TYPE_DBA, 92 MOD_SENSOR_TYPE_DBC, 93 MOD_SENSOR_TYPE_GRAYS, 94 MOD_SENSOR_TYPE_SIEVERTS, 95 MOD_SENSOR_TYPE_COLOR_TEMP_DEGREES_K, 96 MOD_SENSOR_TYPE_BITS, 97 MOD_SENSOR_TYPE_BYTES, 98 MOD_SENSOR_TYPE_WORDS, 99 MOD_SENSOR_TYPE_DWORDS, 100 MOD_SENSOR_TYPE_QWORDS, 101 MOD_SENSOR_TYPE_PERCENTAGE, 102 MOD_SENSOR_TYPE_PASCALS, 103 MOD_SENSOR_TYPE_COUNTS, 104 MOD_SENSOR_TYPE_GRAMS, 105 MOD_SENSOR_TYPE_NEWTON_METERS, 106 MOD_SENSOR_TYPE_HITS, 107 MOD_SENSOR_TYPE_MISSES, 108 MOD_SENSOR_TYPE_RETRIES, 109 MOD_SENSOR_TYPE_OVERRUNS, 110 MOD_SENSOR_TYPE_UNDERRUNS, 111 MOD_SENSOR_TYPE_COLLISIONS, 112 MOD_SENSOR_TYPE_PACKETS, 113 MOD_SENSOR_TYPE_MESSAGES, 114 MOD_SENSOR_TYPE_CHARACTERS, 115 MOD_SENSOR_TYPE_ERRORS, 116 MOD_SENSOR_TYPE_CORRECTED_ERRORS, 117 MOD_SENSOR_TYPE_UNCORRECTABLE_ERRORS, 118 MOD_SENSOR_TYPE_SQUARE_MILS, 119 MOD_SENSOR_TYPE_SQUARE_INCHES, 120 MOD_SENSOR_TYPE_SQUARE_FEET, 121 MOD_SENSOR_TYPE_SQUARE_CENTIMETERS, 122 MOD_SENSOR_TYPE_SQUARE_METERS, 123 MOD_SENSOR_TYPE_RADIANS_PER_SECOND, 124 MOD_SENSOR_TYPE_BEATS_PER_MINUTE, 125 MOD_SENSOR_TYPE_METERS_PER_SECOND_SQUARED, 126 MOD_SENSOR_TYPE_METERS_PER_SECOND, 127 MOD_SENSOR_TYPE_CUBIC_METER_PER_SECOND, 128 MOD_SENSOR_TYPE_MILLIMETERS_OF_MERCURY, 129 MOD_SENSOR_TYPE_RADIANS_PER_SECOND_SQUARED, 130 MOD_SENSOR_TYPE_OEM_UNIT = 0xFF, 131 MOD_SENSOR_TYPE_COUNT 132 }; 133 134 /*! 135 * \brief Structure containing all sensor trip point information. 136 */ 137 struct mod_sensor_trip_point_info { 138 /*! Sensor trip point count */ 139 uint32_t count; 140 }; 141 142 /*! 143 * \brief Sensor value signedness type. 144 */ 145 #ifdef BUILD_HAS_SENSOR_SIGNED_VALUE 146 typedef int64_t mod_sensor_value_t; 147 #else 148 typedef uint64_t mod_sensor_value_t; 149 #endif 150 151 #ifdef BUILD_HAS_SENSOR_EXT_ATTRIBS 152 153 /*! 154 * \brief Structure containing all extended attributes for multi axis 155 * information. 156 * 157 * \details Sensor information structure used to configure the sensor multi 158 * axis values. 159 */ 160 struct mod_sensor_axis_attributes { 161 /*! Axis resolution value */ 162 uint32_t axis_resolution; 163 164 /*! Axis minimum range */ 165 int64_t axis_min_range; 166 167 /*! Axis maximum range */ 168 int64_t axis_max_range; 169 }; 170 171 /*! 172 * \brief Structure containing all sensor property information. 173 * 174 * \details Sensor information structure used to configure the sensor 175 * property values. 176 */ 177 struct mod_sensor_ext_properties { 178 /*! Sensor power value */ 179 uint32_t sensor_power; 180 181 /*! Further sensor property values */ 182 struct mod_sensor_axis_attributes sensor_property_vals; 183 }; 184 #endif 185 186 #ifdef BUILD_HAS_SENSOR_TIMESTAMP 187 /*! 188 * \brief Structure containing all timestamp information. 189 */ 190 struct mod_sensor_timestamp_info { 191 /*! Sensor timestamp support */ 192 bool timestamp_support; 193 194 /*! Sensor timestamp enabled */ 195 bool enabled; 196 197 /*! 198 * \brief Sensor timestamp exponent value 199 * 200 * \details It is the power-of-10 multiplier that is applied to the 201 * sensor timestamps (timestamp x 10 ^ [timestamp exponent] ) to 202 * represent it in seconds. 203 */ 204 int8_t exponent; 205 }; 206 #endif 207 #ifdef BUILD_HAS_SENSOR_MULTI_AXIS 208 /*! 209 * \brief Structure containing infomation for a specific sensor axis 210 * 211 * \details Sensor axis information structure used to configure the sensor HAL. 212 */ 213 struct mod_sensor_axis_info { 214 /*! Sensor axis name */ 215 const char *name; 216 217 /*! SCMI sensor type */ 218 enum mod_sensor_type type; 219 220 /*! 221 * \brief Power-of-10 multiplier applied to the unit specified by 222 * ::mod_sensor_info::type. 223 * 224 * \details Used per: 225 * 226 * ```none 227 * unit * 10^(unit_multiplier) 228 * ``` 229 */ 230 int unit_multiplier; 231 # ifdef BUILD_HAS_SENSOR_EXT_ATTRIBS 232 /*! Extended attributes */ 233 bool extended_attribs; 234 235 /*! Multi axis property values */ 236 struct mod_sensor_axis_attributes multi_axis_properties; 237 # endif 238 }; 239 #endif 240 241 /*! 242 * \brief Structure containing all sensor driver information. 243 * 244 * \details Sensor information structure used to configure the sensor HAL. 245 */ 246 struct mod_sensor_info { 247 /*! SCMI sensor type */ 248 enum mod_sensor_type type; 249 250 /*! 251 * \brief Time (in seconds) between sensor updates. 252 * 253 * \details Set this field to 0 to indicate that the sensor does not have a 254 * minimum update interval. This field is used with 255 * ::mod_sensor_info::update_interval_multiplier to calculate the 256 * actual update interval. 257 */ 258 unsigned int update_interval; 259 260 /*! 261 * \brief Power-of-10 multiplier for ::mod_sensor_info::update_interval. 262 * 263 * \details This is used to calculate the actual interval time: 264 * 265 * ```none 266 * actual = update_interval * 10^(update_interval_multiplier) 267 * ``` 268 */ 269 int update_interval_multiplier; 270 271 /*! 272 * \brief Power-of-10 multiplier applied to the unit specified by 273 * ::mod_sensor_info::type. 274 * 275 * \details Used per: 276 * 277 * ```none 278 * unit * 10^(unit_multiplier) 279 * ``` 280 */ 281 int unit_multiplier; 282 283 /*! 284 * \brief Boolean flag to indicate whether a sensor is 285 * enabled or disabled. 286 * 287 * \details Set this to false to indicate that a sensor starts 288 * enabled or true to indicate that it starts disabled. 289 * The flag is updated dynamically when SCMI commands 290 * are received to enable or disable a sensor. 291 */ 292 bool disabled; 293 294 #ifdef BUILD_HAS_SENSOR_EXT_ATTRIBS 295 /*! Extended attributes information */ 296 bool ext_attributes; 297 298 /*! Sensor property values */ 299 struct mod_sensor_ext_properties sensor_properties; 300 #endif 301 }; 302 303 /*! 304 * \brief Structure containing all sensor information for SCMI requests. 305 * 306 * \details Sensor information structure used serve SCMI requests. 307 */ 308 struct mod_sensor_complete_info { 309 /*! 310 * \brief Sensor HAL information. 311 * 312 * \details If multi axis configuration is supported not all parameters will 313 * be filled here. 314 */ 315 struct mod_sensor_info hal_info; 316 317 /*! Sensor trip information */ 318 struct mod_sensor_trip_point_info trip_point; 319 320 #ifdef BUILD_HAS_SENSOR_TIMESTAMP 321 /*! Sensor timestamp information */ 322 struct mod_sensor_timestamp_info timestamp; 323 #endif 324 325 #ifdef BUILD_HAS_SENSOR_MULTI_AXIS 326 /*! Sensor multi axis information */ 327 struct { 328 /*! Multi axis supported feature */ 329 bool support; 330 /*! Number of axis configured */ 331 unsigned int axis_count; 332 } multi_axis; 333 #endif 334 }; 335 336 /*! 337 * \brief Sensor trip point detection mode 338 */ 339 enum mod_sensor_trip_point_mode { 340 MOD_SENSOR_TRIP_POINT_MODE_DISABLED = 0, 341 MOD_SENSOR_TRIP_POINT_MODE_POSITIVE, 342 MOD_SENSOR_TRIP_POINT_MODE_NEGATIVE, 343 MOD_SENSOR_TRIP_POINT_MODE_TRANSITION 344 }; 345 346 /*! 347 * \brief Structure containing trip point parameters. 348 * 349 * \details Sensor trip point information structure used to configure 350 * a trip point value. 351 */ 352 struct mod_sensor_trip_point_params { 353 /*! Sensor trip point value */ 354 uint64_t tp_value; 355 356 /*! Sensor trip point mode */ 357 enum mod_sensor_trip_point_mode mode; 358 }; 359 360 /*! 361 * \brief Sensor device configuration. 362 * 363 * \details Configuration structure for individual sensors. 364 */ 365 struct mod_sensor_dev_config { 366 /*! Module or element identifier of the driver */ 367 fwk_id_t driver_id; 368 369 /*! API identifier of the driver */ 370 fwk_id_t driver_api_id; 371 372 /*! Notifications identifier */ 373 fwk_id_t notification_id; 374 375 /*! Trip point API identifier */ 376 fwk_id_t trip_point_api_id; 377 378 /*! Sensor trip information */ 379 struct mod_sensor_trip_point_info trip_point; 380 381 #ifdef BUILD_HAS_SENSOR_TIMESTAMP 382 /*! Sensor timestamp default values configuration */ 383 struct mod_sensor_timestamp_info timestamp; 384 #endif 385 }; 386 387 /*! 388 * \brief Sensor data. 389 * 390 * \details Sensor data structure that contains all related value reading 391 * information. 392 */ 393 struct mod_sensor_data { 394 /*! Status of the response event */ 395 int status; 396 397 /*! Sensor value */ 398 union { 399 /*! Sensor N-axis value */ 400 mod_sensor_value_t *axis_value; 401 /*! Sensor scalar value */ 402 mod_sensor_value_t value; 403 }; 404 405 #ifdef BUILD_HAS_SENSOR_TIMESTAMP 406 /*! Timestamp value */ 407 uint64_t timestamp; 408 #endif 409 410 #ifdef BUILD_HAS_SENSOR_MULTI_AXIS 411 /*! Number of axis */ 412 uint32_t axis_count; 413 #endif 414 }; 415 416 /*! 417 * \brief Sensor module configuration. 418 * 419 * \details Configuration structure sensor module. 420 */ 421 struct mod_sensor_config { 422 /*! Notifications identifier */ 423 fwk_id_t notification_id; 424 425 /*! Trip point API identifier */ 426 fwk_id_t trip_point_api_id; 427 }; 428 429 /*! 430 * \brief Sensor driver API. 431 * 432 * \details Api used by this module to interface with the driver. 433 */ 434 struct mod_sensor_driver_api { 435 /*! 436 * \brief Get sensor value. 437 * 438 * \param id Specific sensor device id. 439 * \param[out] value Sensor value, which can be either signed or 440 * unsigned, depending upon the build options. 441 * 442 * \retval ::FWK_PENDING The request is pending. The driver will provide the 443 * requested value later through the driver response API. 444 * \retval ::FWK_SUCCESS Value was read successfully. 445 * \return One of the standard framework error codes. 446 */ 447 int (*get_value)(fwk_id_t id, mod_sensor_value_t *value); 448 449 /*! 450 * \brief Get sensor information. 451 * 452 * \param id Specific sensor device id. 453 * \param[out] info The sensor information. 454 * 455 * \retval ::FWK_SUCCESS The information was read successfully. 456 * \return One of the standard framework error codes. 457 */ 458 int (*get_info)(fwk_id_t id, struct mod_sensor_info *info); 459 460 /*! 461 * \brief Enable_sensor. 462 * 463 * \param id Specific sensor device id. 464 * 465 * \retval ::FWK_SUCCESS The operation was performed successfully. 466 * \retval ::FWK_E_SUPPORT The operation is not supported by the driver API. 467 */ 468 int (*enable)(fwk_id_t id); 469 470 /*! 471 * \brief Disable_sensor. 472 * 473 * \param id Specific sensor device id. 474 * 475 * \retval ::FWK_SUCCESS The operation was performed successfully. 476 * \retval ::FWK_E_SUPPORT The operation is not supported by the driver API. 477 */ 478 int (*disable)(fwk_id_t id); 479 480 /*! 481 * \brief Set update interval. 482 * 483 * \param id Specific sensor device id. 484 * \param update_interval The new update interval value. 485 * \param update_interval_multiplier The new update_interval_multiplier 486 * value. 487 * 488 * \retval ::FWK_SUCCESS The operation was performed successfully. 489 */ 490 491 int (*set_update_interval)( 492 fwk_id_t id, 493 unsigned int update_interval, 494 int update_interval_multiplier); 495 496 /*! 497 * \brief Get update interval. 498 * 499 * \param id Specific sensor device id. 500 * \param update_interval An address to hold the update interval value. 501 * \param update_interval_multiplier An address to hold the 502 * update_interval_multiplier value. 503 * 504 * \retval ::FWK_SUCCESS The operation was performed successfully. 505 */ 506 507 int (*get_update_interval)( 508 fwk_id_t id, 509 unsigned int *update_interval, 510 int *update_interval_multiplier); 511 512 #ifdef BUILD_HAS_SENSOR_MULTI_AXIS 513 /*! 514 * \brief Get number of axis. 515 * 516 * \param id Specific sensor device id. 517 * 518 * \retval Number of axis. 519 */ 520 unsigned int (*get_axis_count)(fwk_id_t id); 521 522 /*! 523 * \brief Get axis sensor information. 524 * 525 * \param id Specific sensor device id. 526 * \param axis Specific axis. 527 * \param[out] info The sensor information. 528 * 529 * \retval ::FWK_SUCCESS The information was read successfully. 530 * \return One of the standard framework error codes. 531 */ 532 int (*get_axis_info)( 533 fwk_id_t id, 534 uint32_t axis, 535 struct mod_sensor_axis_info *info); 536 #endif 537 }; 538 539 /*! 540 * \brief Sensor API. 541 */ 542 struct mod_sensor_api { 543 /*! 544 * \brief Read sensor data. 545 * 546 * \details Read current sensor data. 547 * 548 * \param id Specific sensor device id. 549 * \param[out] data Sensor struct data will be returned. 550 * 551 * \retval ::FWK_SUCCESS Operation succeeded. 552 * \retval ::FWK_E_DEVICE Driver error. 553 * \retval ::FWK_E_BUSY At least one reading of the sensor data is already 554 * on-going. 555 * \retval ::FWK_PENDING The request is pending. The requested data will be 556 * provided via a response event. 557 * \return One of the standard framework error codes. 558 */ 559 int (*get_data)(fwk_id_t id, struct mod_sensor_data *data); 560 561 /*! 562 * \brief Get sensor information. 563 * 564 * \details Get a pointer to the sensor_info structure of a specific sensor. 565 * 566 * \param id Specific sensor device id. 567 * \param[out] info The information structure. 568 * 569 * \retval ::FWK_SUCCESS Operation succeeded. 570 * \retval ::FWK_E_DEVICE Driver error. 571 * \return One of the standard framework error codes. 572 */ 573 int (*get_info)(fwk_id_t id, struct mod_sensor_complete_info *info); 574 575 /*! 576 * \brief Set trip point. 577 * 578 * \details Set trip point sensor configuration. 579 * 580 * \param id Specific sensor device id. 581 * \param trip_point_idx Specific trip point index. 582 * \param params Pointer to trip points parameters structure. 583 * 584 * \retval FWK_SUCCESS Operation succeeded. 585 * \return One of the standard framework error codes. 586 */ 587 int (*set_trip_point)( 588 fwk_id_t id, 589 uint32_t trip_point_idx, 590 const struct mod_sensor_trip_point_params *params); 591 592 /*! 593 * \brief Get trip point. 594 * 595 * \details Get trip point sensor configuration. 596 * 597 * \param id Specific sensor device id. 598 * \param trip_point_idx Specific trip point index. 599 * \param[out] params Pointer to trip points parameters structure. 600 * 601 * \retval FWK_SUCCESS Operation succeeded. 602 * \return One of the standard framework error codes. 603 */ 604 int (*get_trip_point)( 605 fwk_id_t id, 606 uint32_t trip_point_idx, 607 struct mod_sensor_trip_point_params *params); 608 609 /*! 610 * \brief Enable. 611 * 612 * \details Changes the "enabled" state of a sensor to true. 613 * 614 * \param id Specific sensor device id. 615 * 616 * \retval FWK_SUCCESS Operation succeeded. 617 * \retval FWK_E_PARAM "sensor_get_timestamp_config" returned 618 * "configuration is null". 619 */ 620 int (*enable)(fwk_id_t id); 621 622 /*! 623 * \brief Disable. 624 * 625 * \details Changes the "enabled" state of a sensor to false. 626 * 627 * \param id Specific sensor device id. 628 * 629 * \retval FWK_SUCCESS Operation succeeded. 630 * \retval FWK_E_PARAM "sensor_get_timestamp_config" returned 631 * "configuration is null". 632 */ 633 int (*disable)(fwk_id_t id); 634 635 /*! 636 * \brief Set update interval. 637 * 638 * \details Updates the update time interval of a sensor. 639 * 640 * \param id Specific sensor device id. 641 * \param time_interval New time interval value. 642 * \param time_interval_multiplier New time interval multiplier value. 643 * 644 * \retval FWK_SUCCESS Operation succeeded. 645 * \retval FWK_E_SUPPORT Operation not supported by driver. 646 */ 647 int (*set_update_interval)( 648 fwk_id_t id, 649 unsigned int time_interval, 650 int time_interval_multiplier); 651 652 /*! 653 * \brief Get update interval. 654 * 655 * \details Returns the current update time interval of a sensor. 656 * 657 * \param id Specific sensor device id. 658 * \param[out] time_interval Pointer to a variable to take 659 * the time interval value. 660 * \param[out] time_interval_multiplier Pointer to a variable 661 * to take the time interval multiplier value. 662 * 663 * \retval FWK_SUCCESS Operation succeeded. 664 * \retval FWK_E_DEVICE "get_info" returned error. 665 * \retval FWK_E_SUPPORT "sensor_get_timestamp_config" returned 666 * "no timestamp support". 667 * \retval FWK_E_PARAM "sensor_get_timestamp_config" returned 668 * "configuration is null". 669 */ 670 int (*get_update_interval)( 671 fwk_id_t id, 672 unsigned int *time_interval, 673 int *time_interval_multiplier); 674 675 #ifdef BUILD_HAS_SENSOR_TIMESTAMP 676 /*! 677 * \brief Configure timestamp 678 * 679 * \details Set timestamp configuration 680 * 681 * \param id Specific sensor device id. 682 * \param config Timestamp configuration structure. 683 * 684 * \retval FWK_SUCCESS Operation succeeded. 685 * \retval FWK_E_SUPPORT Operation not supported by sensor. 686 * \return One of the standard framework error codes. 687 */ 688 int (*set_timestamp_config)( 689 fwk_id_t id, 690 const struct mod_sensor_timestamp_info *config); 691 692 /*! 693 * \brief Read timestamp configuration 694 * 695 * \details Get timestamp configuration 696 * 697 * \param id Specific sensor device id. 698 * \param[out] config Timestamp configuration structure. 699 * 700 * \retval FWK_SUCCESS Operation succeeded. 701 * \return One of the standard framework error codes. 702 */ 703 int (*get_timestamp_config)( 704 fwk_id_t id, 705 struct mod_sensor_timestamp_info *config); 706 707 /*! 708 * \brief Get axis sensor information. 709 * 710 * \param id Specific sensor device id. 711 * \param axis Specific axis. 712 * \param[out] info The sensor information. 713 * 714 * \retval ::FWK_SUCCESS The information was read successfully. 715 * \return One of the standard framework error codes. 716 */ 717 int (*get_axis_info)( 718 fwk_id_t id, 719 uint32_t axis, 720 struct mod_sensor_axis_info *info); 721 #endif 722 }; 723 724 /*! 725 * \brief Driver response parameters. 726 */ 727 struct mod_sensor_driver_resp_params { 728 /*! Status of the requested operation */ 729 int status; 730 731 /*! Sensor value */ 732 union { 733 /*! Sensor N-axis value */ 734 mod_sensor_value_t *axis_value; 735 /*! Sensor scalar value */ 736 mod_sensor_value_t value; 737 }; 738 }; 739 740 /*! 741 * \brief Driver response API. 742 * 743 * \details API used by the driver to notify the HAL when a pending request 744 * has completed. 745 */ 746 struct mod_sensor_driver_response_api { 747 /*! 748 * \brief Inform the completion of a sensor reading. 749 * 750 * \param id Specific sensor device identifier. 751 * \param[out] response The response data structure. 752 */ 753 void (*reading_complete)(fwk_id_t id, 754 struct mod_sensor_driver_resp_params *response); 755 }; 756 757 /*! 758 * \brief API indices. 759 */ 760 enum mod_sensor_api_idx { 761 /*! 762 * \brief Driver API index. 763 * 764 * \note This API implements the ::mod_sensor_api interface. 765 */ 766 MOD_SENSOR_API_IDX_SENSOR, 767 768 /*! 769 * \brief Driver response API. 770 */ 771 MOD_SENSOR_API_IDX_DRIVER_RESPONSE, 772 773 /*! 774 * \brief Number of defined APIs. 775 */ 776 MOD_SENSOR_API_IDX_COUNT, 777 }; 778 779 /*! 780 * \brief Module API identifier. 781 */ 782 static const fwk_id_t mod_sensor_api_id_sensor = 783 FWK_ID_API_INIT(FWK_MODULE_IDX_SENSOR, MOD_SENSOR_API_IDX_SENSOR); 784 785 /*! 786 * \brief Driver input API identifier. 787 */ 788 static const fwk_id_t mod_sensor_api_id_driver_response = 789 FWK_ID_API_INIT(FWK_MODULE_IDX_SENSOR, MOD_SENSOR_API_IDX_DRIVER_RESPONSE); 790 791 /*! 792 * \brief Shared event parameters. 793 */ 794 struct mod_sensor_event_params { 795 /*! Sensor value pointer */ 796 struct mod_sensor_data *sensor_data; 797 }; 798 799 /*! 800 * Sensor module read request event index 801 */ 802 #define MOD_SENSOR_EVENT_IDX_READ_REQUEST 0 803 804 /*! 805 * \brief Read request event identifier. 806 * 807 * \details Clients which expect to receive a response event from this module 808 * should use this identifier to properly identify the response. 809 */ 810 static const fwk_id_t mod_sensor_event_id_read_request = 811 FWK_ID_EVENT_INIT(FWK_MODULE_IDX_SENSOR, MOD_SENSOR_EVENT_IDX_READ_REQUEST); 812 813 /*! 814 * \} 815 */ 816 817 /*! 818 * \} 819 */ 820 821 #endif /* MOD_SENSOR_H */ 822