accessors.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. extern const char *i2c_name_type;
  14. extern const char *spi_name_type;
  15. typedef struct {
  16. int width;
  17. int height;
  18. int address;
  19. int RST_pin;
  20. bool hflip;
  21. bool vflip;
  22. const char *drivername;
  23. int CS_pin;
  24. int speed;
  25. int back;
  26. int depth;
  27. const char *type;
  28. bool rotate;
  29. bool invert;
  30. int colorswap;
  31. } display_config_t;
  32. typedef struct {
  33. bool rmii;
  34. char model[16];
  35. int rst;
  36. int mdc, mdio;
  37. int host;
  38. int cs, mosi, miso, intr, clk;
  39. int speed;
  40. } eth_config_t;
  41. typedef struct {
  42. i2s_pin_config_t pin;
  43. char model[32];
  44. int mute_gpio;
  45. int mute_level;
  46. int i2c_addr;
  47. int sda;
  48. int scl;
  49. } i2s_platform_config_t;
  50. typedef struct {
  51. int gpio;
  52. int level;
  53. bool fixed;
  54. } gpio_with_level_t;
  55. typedef struct {
  56. gpio_with_level_t vcc;
  57. gpio_with_level_t gnd;
  58. gpio_with_level_t amp;
  59. gpio_with_level_t ir;
  60. gpio_with_level_t jack;
  61. gpio_with_level_t green;
  62. gpio_with_level_t red;
  63. gpio_with_level_t spkfault;
  64. } set_GPIO_struct_t;
  65. typedef struct {
  66. int A;
  67. int B;
  68. int SW;
  69. bool knobonly;
  70. bool volume_lock;
  71. bool longpress;
  72. int timer;
  73. } rotary_struct_t;
  74. typedef struct {
  75. bool fixed;
  76. char * name;
  77. char * group;
  78. int gpio;
  79. } gpio_entry_t;
  80. const display_config_t * config_display_get();
  81. esp_err_t config_display_set(const display_config_t * config);
  82. esp_err_t config_i2c_set(const i2c_config_t * config, int port);
  83. esp_err_t config_i2s_set(const i2s_platform_config_t * config, const char * nvs_name);
  84. esp_err_t config_spi_set(const spi_bus_config_t * config, int host, int dc);
  85. const i2c_config_t * config_i2c_get(int * i2c_port);
  86. const spi_bus_config_t * config_spi_get(spi_host_device_t * spi_host);
  87. const gpio_exp_config_t * config_gpio_exp_get(int index);
  88. void parse_set_GPIO(void (*cb)(int gpio, char *value));
  89. const i2s_platform_config_t * config_dac_get();
  90. const i2s_platform_config_t * config_spdif_get( );
  91. esp_err_t config_spdif_set(const i2s_platform_config_t * config);
  92. bool is_spdif_config_locked();
  93. esp_err_t free_gpio_entry( gpio_entry_t ** gpio);
  94. gpio_entry_t * get_gpio_by_name(char * name,char * group, bool refresh);
  95. gpio_entry_t * get_gpio_by_no(int gpionum, bool refresh);
  96. cJSON * get_gpio_list(bool refresh);
  97. bool is_dac_config_locked();
  98. bool are_statistics_enabled();
  99. const rotary_struct_t * config_rotary_get();
  100. esp_err_t config_rotary_set(rotary_struct_t * rotary);