sensor_tbl.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #ifndef __SENSOR_TBL_H__
  2. #define __SENSOR_TBL_H__
  3. #include <stdint.h>
  4. #include "bmc_conf.h"
  5. /**
  6. ** @brief HAL Error code definitions
  7. ***/
  8. typedef enum
  9. {
  10. /* HAL Error codes */
  11. HAL_ERR_NONE, /* No error */
  12. HAL_ERR_READ, /* Error in reading device */
  13. HAL_ERR_WRITE, /* Error in writing to device*/
  14. HAL_ERR_FUNC_NOT_SUPPORTED, /* Function called is not supported */
  15. } hal_status_codes_e;
  16. /**
  17. ** @brief HAL Supported Hardware functions
  18. ***/
  19. typedef enum
  20. {
  21. HAL_DEVICE_READ, /* General Read function */
  22. HAL_DEVICE_WRITE, /* General Write function */
  23. /* Special I2C functions */
  24. HAL_I2C_READ_REG, /* Read I2C register */
  25. HAL_I2C_READ_WRITE, /* Read/Write I2C */
  26. /* Special GPIO functions */
  27. HAL_SET_GPIO_DIR, /* GPIO Set direction */
  28. HAL_GET_GPIO_DIR, /* GPIO Get direction */
  29. HAL_SET_GPIO_POL, /* GPIO Set Polarity */
  30. HAL_GET_GPIO_POL, /* GPIO Get Polarity */
  31. HAL_SET_GPIO_OUTPUT_REG, /* GPIO Set output data register */
  32. } hal_func_codes_e;
  33. /**
  34. ** @brief This structure necessary hardware information to access any device
  35. ***/
  36. typedef struct
  37. {
  38. hal_status_codes_e status_code; /* HAL api's status codes */
  39. hal_func_codes_e func; /* Hardware function */
  40. union {
  41. uint8_t *pbyte; /* All HAL apis return data
  42. in bytes using this pointer */
  43. uint16_t *pword; /* All HAL apis return data accesed
  44. in words using this pointer */
  45. };
  46. int read_len; /* bytes to read */
  47. uint8_t *pwrite_buf; /* All HAL apis write data
  48. from this buffer */
  49. int write_len; /* bytes to write */
  50. // hal_dev_properties_t dev_prop; /* Device properties information */
  51. // hal_dev_type_e dev_type; /* Type of the device */
  52. //
  53. // hal_i2c_t i2c; /* Hold I2C information */
  54. // hal_gpio_t gpio; /* Hold GPIO information */
  55. // hal_mmap_t mmap; /* Hold memory mapped information */
  56. // hal_adc_t adc; /* Hold ADC information */
  57. //
  58. // hal_fanpwm_t fan; /* Hold FanPwm information Added by winston for fanpwm */
  59. // hal_peci_t peci; /* Hold PECI information Added by winston for peci */
  60. // hal_lpcuart_t lpcuart; /* Hold LPCUART information Added by jcchiu for lpcuart */
  61. // hal_intsensor_t intsensor; /* Hold Interrupt Sensor information */
  62. // hal_nmsensor_t nmsensor; /* Hold Interrupt Sensor information */
  63. } hal_t;
  64. typedef enum {
  65. MonitorOnStandby,
  66. NotMonitorOnStandby
  67. }monit_sta_t;
  68. /**
  69. ** @brief HAL read/write/init function type definition
  70. ***/
  71. typedef int (*phal_hndlr_t) (hal_t *phal);
  72. /**
  73. ** @brief HAL Device Table
  74. ***/
  75. typedef struct
  76. {
  77. uint8_t sensor_number;
  78. uint8_t poweron_delay; //scan this sensor after poweron_delay seconds, when bmc power on.
  79. uint8_t reset_delay; //scan this sensor after reset_delay senconds, when cpu reset.
  80. uint8_t monitor_interval; //Monitoring this sensor every monitor_interval seconds.
  81. monit_sta_t monitor_state; //whether monitoring this sensor when standby.
  82. phal_hndlr_t device_read;
  83. phal_hndlr_t device_write;
  84. phal_hndlr_t device_init;
  85. } sensor_tbl_t;
  86. #endif /* __SENSOR_TBL_H__ */