nbus_app_driver.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #ifndef _NBUS_APPDRV_H_
  2. #define _NBUS_APPDRV_H_
  3. /**
  4. * @brief Implementation of nbus app driver
  5. * Embed NBus driver.
  6. */
  7. #include <stdint.h>
  8. #include "app_bridge.h"
  9. #include <stdbool.h>
  10. #include "master_config.h"
  11. #include "data_acquirer/data_acquirer.h"
  12. #ifdef __cplusplus
  13. extern "C"
  14. {
  15. #endif
  16. ///////////////////////////////////////// Extended functionality of driver //////////////////////////////////////////
  17. /**
  18. * @brief Constructor of appdrv Driver.
  19. * @param: data buffer for measures
  20. * @return: pointer to interface
  21. */
  22. nBusAppInterface_t *getAppdrvDriver();
  23. ///////////////////////////////////////// Implementation of nBusAppInterface_t ////////////////////////////////////////
  24. void appdrv_init(void *hw_interface, void *hw_config);
  25. void appdrv_reset();
  26. nBus_sensorType_t appdrv_getType(uint8_t sensor_index);
  27. nBus_sensorCount_t appdrv_getSensorCount();
  28. uint8_t appdrv_getData(uint8_t sensor_index, uint8_t *data);
  29. nBus_statusType_t appdrv_setData(uint8_t *data, uint8_t count, uint8_t *response);
  30. uint8_t appdrv_hasParam(uint8_t sensor_index, nBus_param_t param_name);
  31. int32_t appdrv_getParam(uint8_t sensor_index, nBus_param_t param_name);
  32. nBus_statusType_t appdrv_setParam(uint8_t sensor_index, nBus_param_t param_name, int32_t param_value);
  33. nBus_statusType_t appdrv_start(void);
  34. nBus_statusType_t appdrv_stop(void);
  35. void appdrv_read(void);
  36. uint8_t appdrv_store(void);
  37. nBus_statusType_t appdrv_calibrate(uint8_t sensor_index);
  38. nBus_sensorFormat_t appdrv_getSensorFormat(uint8_t sensor_index);
  39. nBus_statusType_t appdrv_find(uint8_t enable);
  40. uint8_t appdrv_device_ready();
  41. #ifdef __cplusplus
  42. }
  43. #endif
  44. //////////////////////////////////////////////// Helper Functions //////////////////////////////////////////////////
  45. /**
  46. * @brief Write sensor values into data buffer.
  47. * @param data_out output byte buffer
  48. * @param offset_out buffer offset
  49. * @param sid sensor id
  50. * @param values sensor values to write
  51. * @param size number of values to write
  52. */
  53. uint16_t _write_sensor_values(uint8_t *data_out, uint16_t offset_out, uint8_t sid, int16_t *values, uint16_t size);
  54. /**
  55. * @brief Logic or for 3 operands. Equivalent to x == a || x == b.
  56. * @param x testing value
  57. * @param a option 1 (sensor ID)
  58. * @param b option 2 (sensor ID)
  59. * @return logic value
  60. */
  61. bool _or(uint8_t x, app_sid_t a, app_sid_t b);
  62. /**
  63. * @brief Logic or for 4 operands. Equivalent to x == a || x == b || x == c.
  64. * @param x testing value
  65. * @param a option 1 (sensor ID)
  66. * @param b option 2 (sensor ID)
  67. * @param b option 3 (sensor ID)
  68. * @return logic value
  69. */
  70. bool _or(uint8_t x, app_sid_t a, app_sid_t b, app_sid_t c);
  71. #endif // _NBUS_APPDRV_H_