/
board_pins_config.c
167 lines (140 loc) · 4.13 KB
/
board_pins_config.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/*
* ESPRESSIF MIT License
*
* Copyright (c) 2021 <ESPRESSIF SYSTEMS (SHANGHAI) CO., LTD>
*
* Permission is hereby granted for use on all ESPRESSIF SYSTEMS products, in which case,
* it is free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished
* to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or
* substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#include "esp_log.h"
#include "driver/gpio.h"
#include <string.h>
#include "board.h"
#include "audio_error.h"
#include "audio_mem.h"
#include "soc/soc_caps.h"
static const char *TAG = "ESP32_S3_KORVO_2";
esp_err_t get_i2c_pins(i2c_port_t port, i2c_config_t *i2c_config)
{
AUDIO_NULL_CHECK(TAG, i2c_config, return ESP_FAIL);
if (port == I2C_NUM_0 || port == I2C_NUM_1) {
i2c_config->sda_io_num = GPIO_NUM_17;
i2c_config->scl_io_num = GPIO_NUM_18;
} else {
i2c_config->sda_io_num = -1;
i2c_config->scl_io_num = -1;
ESP_LOGE(TAG, "i2c port %d is not supported", port);
return ESP_FAIL;
}
return ESP_OK;
}
esp_err_t get_i2s_pins(int port, board_i2s_pin_t *i2s_config)
{
AUDIO_NULL_CHECK(TAG, i2s_config, return ESP_FAIL);
if (port == 0) {
i2s_config->bck_io_num = GPIO_NUM_9;
i2s_config->ws_io_num = GPIO_NUM_45;
i2s_config->data_out_num = GPIO_NUM_8;
i2s_config->data_in_num = GPIO_NUM_10;
i2s_config->mck_io_num = GPIO_NUM_16;
} else if (port == 1) {
i2s_config->bck_io_num = -1;
i2s_config->ws_io_num = -1;
i2s_config->data_out_num = -1;
i2s_config->data_in_num = -1;
i2s_config->mck_io_num = -1;
} else {
memset(i2s_config, -1, sizeof(board_i2s_pin_t));
ESP_LOGE(TAG, "i2s port %d is not supported", port);
return ESP_FAIL;
}
return ESP_OK;
}
esp_err_t get_spi_pins(spi_bus_config_t *spi_config, spi_device_interface_config_t *spi_device_interface_config)
{
AUDIO_NULL_CHECK(TAG, spi_config, return ESP_FAIL);
AUDIO_NULL_CHECK(TAG, spi_device_interface_config, return ESP_FAIL);
spi_config->mosi_io_num = -1;
spi_config->miso_io_num = -1;
spi_config->sclk_io_num = -1;
spi_config->quadwp_io_num = -1;
spi_config->quadhd_io_num = -1;
spi_device_interface_config->spics_io_num = -1;
ESP_LOGW(TAG, "SPI interface is not supported");
return ESP_OK;
}
// sdcard
int8_t get_sdcard_intr_gpio(void)
{
return SDCARD_INTR_GPIO;
}
int8_t get_sdcard_open_file_num_max(void)
{
return SDCARD_OPEN_FILE_NUM_MAX;
}
int8_t get_sdcard_power_ctrl_gpio(void)
{
return SDCARD_PWR_CTRL;
}
// input-output pins
int8_t get_headphone_detect_gpio(void)
{
return HEADPHONE_DETECT;
}
int8_t get_pa_enable_gpio(void)
{
return PA_ENABLE_GPIO;
}
// adc button id
int8_t get_input_rec_id(void)
{
return BUTTON_REC_ID;
}
int8_t get_input_mode_id(void)
{
return BUTTON_MODE_ID;
}
int8_t get_input_set_id(void)
{
return BUTTON_SET_ID;
}
int8_t get_input_play_id(void)
{
return BUTTON_PLAY_ID;
}
int8_t get_input_volup_id(void)
{
return BUTTON_VOLUP_ID;
}
int8_t get_input_voldown_id(void)
{
return BUTTON_VOLDOWN_ID;
}
// led pins
int8_t get_green_led_gpio(void)
{
return GREEN_LED_GPIO;
}
int8_t get_blue_led_gpio(void)
{
return BLUE_LED_GPIO;
}
int8_t get_es8311_mclk_src(void)
{
return ES8311_MCLK_SOURCE;
}