common_define.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. *
  3. * $Id: common_define.h
  4. *
  5. * Copyright (C) 2019 Bk, sensortek Inc.
  6. *
  7. * This file is subject to the terms and conditions of the GNU General Public
  8. * License. See the file COPYING in the main directory of this archive for
  9. * more details.
  10. *
  11. */
  12. #ifndef __DEFINE_COMMON_H__
  13. #define __DEFINE_COMMON_H__
  14. #include "platform_config.h"
  15. typedef struct stk_timer_info stk_timer_info;
  16. typedef struct stk_gpio_info stk_gpio_info;
  17. struct stk_bus_ops
  18. {
  19. int bustype;
  20. int (*init)(void *);
  21. int (*read)(int, unsigned int, unsigned char *);
  22. int (*read_block)(int, unsigned int, int, void *);
  23. int (*write)(int, unsigned int, unsigned char);
  24. int (*write_block)(int, unsigned int, void *, int);
  25. int (*read_modify_write)(int, unsigned int, unsigned char, unsigned char);
  26. int (*remove)(void *);
  27. };
  28. typedef enum
  29. {
  30. SECOND,
  31. M_SECOND,
  32. U_SECOND,
  33. N_SECOND,
  34. } TIMER_UNIT;
  35. typedef enum
  36. {
  37. US_RANGE_DELAY,
  38. MS_DELAY,
  39. } BUSY_WAIT_TYPE;
  40. struct stk_timer_info
  41. {
  42. char wq_name[4096];
  43. uint32_t interval_time;
  44. TIMER_UNIT timer_unit;
  45. void (*timer_cb)(stk_timer_info *t_info);
  46. bool is_active;
  47. bool is_exist;
  48. bool is_periodic;
  49. bool change_interval_time;
  50. void *any;
  51. } ;
  52. struct stk_timer_ops
  53. {
  54. int (*register_timer)(stk_timer_info *);
  55. int (*start_timer)(stk_timer_info *);
  56. int (*stop_timer)(stk_timer_info *);
  57. int (*remove)(stk_timer_info *);
  58. void (*busy_wait)(unsigned long, unsigned long, BUSY_WAIT_TYPE);
  59. };
  60. typedef enum
  61. {
  62. TRIGGER_RISING,
  63. TRIGGER_FALLING,
  64. TRIGGER_HIGH,
  65. TRIGGER_LOW,
  66. } GPIO_TRIGGER_TYPE;
  67. struct stk_gpio_info
  68. {
  69. char wq_name[4096];
  70. char device_name[4096];
  71. void (*gpio_cb)(stk_gpio_info *gpio_info);
  72. GPIO_TRIGGER_TYPE trig_type;
  73. int int_pin;
  74. int32_t irq;
  75. bool is_active;
  76. bool is_exist;
  77. void *any;
  78. } ;
  79. struct stk_gpio_ops
  80. {
  81. int (*register_gpio_irq)(stk_gpio_info *);
  82. int (*start_gpio_irq)(stk_gpio_info *);
  83. int (*stop_gpio_irq)(stk_gpio_info *);
  84. int (*remove)(stk_gpio_info *);
  85. };
  86. struct stk_storage_ops
  87. {
  88. int (*init_storage)(void);
  89. int (*write_to_storage)(char *, uint8_t *, int);
  90. int (*read_from_storage)(char *, uint8_t *, int);
  91. int (*remove)(void);
  92. };
  93. struct common_function
  94. {
  95. const struct stk_bus_ops *bops;
  96. const struct stk_timer_ops *tops;
  97. const struct stk_gpio_ops *gops;
  98. };
  99. typedef struct stk_register_table
  100. {
  101. uint8_t address;
  102. uint8_t value;
  103. uint8_t mask_bit;
  104. } stk_register_table;
  105. #endif // __DEFINE_COMMON_H__