- Notifications
You must be signed in to change notification settings - Fork 7.6k
/
Copy pathesp32-hal-periman.h
148 lines (128 loc) · 6.07 KB
/
esp32-hal-periman.h
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
/*
* SPDX-FileCopyrightText: 2019-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#ifdef__cplusplus
extern"C" {
#endif
#include"soc/soc_caps.h"
#include<stdint.h>
#include<stdbool.h>
#include<stddef.h>
#defineperimanClearPinBus(p) perimanSetPinBus(p, ESP32_BUS_TYPE_INIT, NULL, -1, -1)
typedefenum {
ESP32_BUS_TYPE_INIT, // IO has not been attached to a bus yet
ESP32_BUS_TYPE_GPIO, // IO is used as GPIO
ESP32_BUS_TYPE_UART_RX, // IO is used as UART RX pin
ESP32_BUS_TYPE_UART_TX, // IO is used as UART TX pin
ESP32_BUS_TYPE_UART_CTS, // IO is used as UART CTS pin
ESP32_BUS_TYPE_UART_RTS, // IO is used as UART RTS pin
#ifSOC_SDM_SUPPORTED
ESP32_BUS_TYPE_SIGMADELTA, // IO is used as SigmeDelta output
#endif
#ifSOC_ADC_SUPPORTED
ESP32_BUS_TYPE_ADC_ONESHOT, // IO is used as ADC OneShot input
ESP32_BUS_TYPE_ADC_CONT, // IO is used as ADC continuous input
#endif
#ifSOC_DAC_SUPPORTED
ESP32_BUS_TYPE_DAC_ONESHOT, // IO is used as DAC OneShot output
ESP32_BUS_TYPE_DAC_CONT, // IO is used as DAC continuous output
ESP32_BUS_TYPE_DAC_COSINE, // IO is used as DAC cosine output
#endif
#ifSOC_LEDC_SUPPORTED
ESP32_BUS_TYPE_LEDC, // IO is used as LEDC output
#endif
#ifSOC_RMT_SUPPORTED
ESP32_BUS_TYPE_RMT_TX, // IO is used as RMT output
ESP32_BUS_TYPE_RMT_RX, // IO is used as RMT input
#endif
#ifSOC_I2S_SUPPORTED
ESP32_BUS_TYPE_I2S_STD_MCLK, // IO is used as I2S STD MCLK pin
ESP32_BUS_TYPE_I2S_STD_BCLK, // IO is used as I2S STD BCLK pin
ESP32_BUS_TYPE_I2S_STD_WS, // IO is used as I2S STD WS pin
ESP32_BUS_TYPE_I2S_STD_DOUT, // IO is used as I2S STD DOUT pin
ESP32_BUS_TYPE_I2S_STD_DIN, // IO is used as I2S STD DIN pin
ESP32_BUS_TYPE_I2S_TDM_MCLK, // IO is used as I2S TDM MCLK pin
ESP32_BUS_TYPE_I2S_TDM_BCLK, // IO is used as I2S TDM BCLK pin
ESP32_BUS_TYPE_I2S_TDM_WS, // IO is used as I2S TDM WS pin
ESP32_BUS_TYPE_I2S_TDM_DOUT, // IO is used as I2S TDM DOUT pin
ESP32_BUS_TYPE_I2S_TDM_DIN, // IO is used as I2S TDM DIN pin
ESP32_BUS_TYPE_I2S_PDM_TX_CLK, // IO is used as I2S PDM CLK pin
ESP32_BUS_TYPE_I2S_PDM_TX_DOUT0, // IO is used as I2S PDM DOUT0 pin
ESP32_BUS_TYPE_I2S_PDM_TX_DOUT1, // IO is used as I2S PDM DOUT1 pin
ESP32_BUS_TYPE_I2S_PDM_RX_CLK, // IO is used as I2S PDM CLK pin
ESP32_BUS_TYPE_I2S_PDM_RX_DIN0, // IO is used as I2S PDM DIN0 pin
ESP32_BUS_TYPE_I2S_PDM_RX_DIN1, // IO is used as I2S PDM DIN1 pin
ESP32_BUS_TYPE_I2S_PDM_RX_DIN2, // IO is used as I2S PDM DIN2 pin
ESP32_BUS_TYPE_I2S_PDM_RX_DIN3, // IO is used as I2S PDM DIN3 pin
#endif
#ifSOC_I2C_SUPPORTED
ESP32_BUS_TYPE_I2C_MASTER_SDA, // IO is used as I2C master SDA pin
ESP32_BUS_TYPE_I2C_MASTER_SCL, // IO is used as I2C master SCL pin
ESP32_BUS_TYPE_I2C_SLAVE_SDA, // IO is used as I2C slave SDA pin
ESP32_BUS_TYPE_I2C_SLAVE_SCL, // IO is used as I2C slave SCL pin
#endif
#ifSOC_GPSPI_SUPPORTED
ESP32_BUS_TYPE_SPI_MASTER_SCK, // IO is used as SPI master SCK pin
ESP32_BUS_TYPE_SPI_MASTER_MISO, // IO is used as SPI master MISO pin
ESP32_BUS_TYPE_SPI_MASTER_MOSI, // IO is used as SPI master MOSI pin
ESP32_BUS_TYPE_SPI_MASTER_SS, // IO is used as SPI master SS pin
#endif
#ifSOC_SDMMC_HOST_SUPPORTED
ESP32_BUS_TYPE_SDMMC_CLK, // IO is used as SDMMC CLK pin
ESP32_BUS_TYPE_SDMMC_CMD, // IO is used as SDMMC CMD pin
ESP32_BUS_TYPE_SDMMC_D0, // IO is used as SDMMC D0 pin
ESP32_BUS_TYPE_SDMMC_D1, // IO is used as SDMMC D1 pin
ESP32_BUS_TYPE_SDMMC_D2, // IO is used as SDMMC D2 pin
ESP32_BUS_TYPE_SDMMC_D3, // IO is used as SDMMC D3 pin
#endif
#ifSOC_TOUCH_SENSOR_SUPPORTED
ESP32_BUS_TYPE_TOUCH, // IO is used as TOUCH pin
#endif
#ifSOC_USB_SERIAL_JTAG_SUPPORTED||SOC_USB_OTG_SUPPORTED
ESP32_BUS_TYPE_USB_DM, // IO is used as USB DM (+) pin
ESP32_BUS_TYPE_USB_DP, // IO is used as USB DP (-) pin
#endif
#ifSOC_GPSPI_SUPPORTED
ESP32_BUS_TYPE_ETHERNET_SPI, // IO is used as ETHERNET SPI pin
#endif
#ifCONFIG_ETH_USE_ESP32_EMAC
ESP32_BUS_TYPE_ETHERNET_RMII, // IO is used as ETHERNET RMII pin
ESP32_BUS_TYPE_ETHERNET_CLK, // IO is used as ETHERNET CLK pin
ESP32_BUS_TYPE_ETHERNET_MCD, // IO is used as ETHERNET MCD pin
ESP32_BUS_TYPE_ETHERNET_MDIO, // IO is used as ETHERNET MDIO pin
ESP32_BUS_TYPE_ETHERNET_PWR, // IO is used as ETHERNET PWR pin
#endif
#ifCONFIG_LWIP_PPP_SUPPORT
ESP32_BUS_TYPE_PPP_TX, // IO is used as PPP Modem TX pin
ESP32_BUS_TYPE_PPP_RX, // IO is used as PPP Modem RX pin
ESP32_BUS_TYPE_PPP_RTS, // IO is used as PPP Modem RTS pin
ESP32_BUS_TYPE_PPP_CTS, // IO is used as PPP Modem CTS pin
#endif
ESP32_BUS_TYPE_MAX
} peripheral_bus_type_t;
typedefbool (*peripheral_bus_deinit_cb_t)(void*bus);
constchar*perimanGetTypeName(peripheral_bus_type_ttype);
// Sets the bus type, bus handle, bus number and bus channel for given pin.
boolperimanSetPinBus(uint8_tpin, peripheral_bus_type_ttype, void*bus, int8_tbus_num, int8_tbus_channel);
// Returns handle of the bus for the given pin if type of bus matches. NULL otherwise
void*perimanGetPinBus(uint8_tpin, peripheral_bus_type_ttype);
// Returns the type of the bus for the given pin if attached. ESP32_BUS_TYPE_MAX otherwise
peripheral_bus_type_tperimanGetPinBusType(uint8_tpin);
// Returns the bus number or unit of the bus for the given pin if set. -1 otherwise
int8_tperimanGetPinBusNum(uint8_tpin);
// Returns the bus channel of the bus for the given pin if set. -1 otherwise
int8_tperimanGetPinBusChannel(uint8_tpin);
// Sets the peripheral destructor callback. Used to destroy bus when pin is assigned another function
boolperimanSetBusDeinit(peripheral_bus_type_ttype, peripheral_bus_deinit_cb_tcb);
// Check if given pin is a valid GPIO number
boolperimanPinIsValid(uint8_tpin);
// Sets the extra type for non Init bus. Used to customize pin bus name which can be printed by printPerimanInfo().
boolperimanSetPinBusExtraType(uint8_tpin, constchar*extra_type);
// Returns the extra type of the bus for given pin if set. NULL otherwise
constchar*perimanGetPinBusExtraType(uint8_tpin);
#ifdef__cplusplus
}
#endif