accessors.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*
  2. This example code is in the Public Domain (or CC0 licensed, at your option.)
  3. Unless required by applicable law or agreed to in writing, this
  4. software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
  5. CONDITIONS OF ANY KIND, either express or implied.
  6. */
  7. #pragma once
  8. #include "esp_system.h"
  9. #include "driver/i2c.h"
  10. #include "driver/i2s.h"
  11. #include "driver/spi_master.h"
  12. #include "gpio_exp.h"
  13. #include "cJSON.h"
  14. extern const char *i2c_name_type;
  15. extern const char *spi_name_type;
  16. typedef struct {
  17. int width;
  18. int height;
  19. int address;
  20. int RST_pin;
  21. bool hflip;
  22. bool vflip;
  23. const char *drivername;
  24. int CS_pin;
  25. int speed;
  26. int back;
  27. int depth;
  28. const char *type;
  29. bool rotate;
  30. bool invert;
  31. int colorswap;
  32. int mode;
  33. } display_config_t;
  34. typedef struct eth_config_struct {
  35. char model[16];
  36. bool valid;
  37. bool rmii;
  38. bool spi;
  39. int rst;
  40. int mdc, mdio;
  41. int host;
  42. int cs, mosi, miso, intr, clk;
  43. int speed;
  44. } eth_config_t;
  45. typedef struct {
  46. i2s_pin_config_t pin;
  47. char model[32];
  48. int mute_gpio;
  49. int mute_level;
  50. int i2c_addr;
  51. int sda;
  52. int scl;
  53. } i2s_platform_config_t;
  54. typedef struct {
  55. int gpio;
  56. int level;
  57. bool fixed;
  58. } gpio_with_level_t;
  59. typedef struct {
  60. gpio_with_level_t vcc;
  61. gpio_with_level_t gnd;
  62. gpio_with_level_t amp;
  63. gpio_with_level_t ir;
  64. gpio_with_level_t jack;
  65. gpio_with_level_t green;
  66. gpio_with_level_t red;
  67. gpio_with_level_t spkfault;
  68. } set_GPIO_struct_t;
  69. typedef struct {
  70. int A;
  71. int B;
  72. int SW;
  73. bool knobonly;
  74. bool volume_lock;
  75. bool longpress;
  76. int timer;
  77. } rotary_struct_t;
  78. typedef struct {
  79. char type[16];
  80. int length;
  81. int gpio;
  82. int scale;
  83. } ledvu_struct_t;
  84. typedef struct {
  85. bool fixed;
  86. char * name;
  87. char * group;
  88. int gpio;
  89. } gpio_entry_t;
  90. const display_config_t * config_display_get();
  91. const eth_config_t * config_eth_get( );
  92. void config_eth_init( eth_config_t * target );
  93. esp_err_t config_display_set(const display_config_t * config);
  94. esp_err_t config_i2c_set(const i2c_config_t * config, int port);
  95. esp_err_t config_i2s_set(const i2s_platform_config_t * config, const char * nvs_name);
  96. esp_err_t config_spi_set(const spi_bus_config_t * config, int host, int dc);
  97. const i2c_config_t * config_i2c_get(int * i2c_port);
  98. const spi_bus_config_t * config_spi_get(spi_host_device_t * spi_host);
  99. const gpio_exp_config_t * config_gpio_exp_get(int index);
  100. void parse_set_GPIO(void (*cb)(int gpio, char *value));
  101. const i2s_platform_config_t * config_dac_get();
  102. const i2s_platform_config_t * config_spdif_get( );
  103. const i2s_platform_config_t * config_i2s_get_from_str(char * dac_config );
  104. esp_err_t config_spdif_set(const i2s_platform_config_t * config);
  105. bool is_spdif_config_locked();
  106. esp_err_t free_gpio_entry( gpio_entry_t ** gpio);
  107. gpio_entry_t * get_gpio_by_name(char * name,char * group, bool refresh);
  108. gpio_entry_t * get_gpio_by_no(int gpionum, bool refresh);
  109. cJSON * get_gpio_list(bool refresh);
  110. bool is_dac_config_locked();
  111. bool are_statistics_enabled();
  112. const rotary_struct_t * config_rotary_get();
  113. esp_err_t config_rotary_set(rotary_struct_t * rotary);
  114. const ledvu_struct_t * config_ledvu_get();
  115. esp_err_t config_ledvu_set(ledvu_struct_t * ledvu);