Allows to get the CB pointer for a Peripheral Manager Bus Type.
It can be used to verify if it is already set and also in case the application needs to change the CB to something else and latter restore the original CB to that Bus Type.
PR also intializes all CB pinters to NULL.
ESP32 using LOG Debug information.
It is possible to see results by using a wire to ground RX0 while the pin is read.
#include "esp32-hal-periman.h"
static bool _uartRXPinDetachBus(void *busptr) {
// does nothing and keeps the UART driver running attached to RX pin
log_d("_uartRXPinDetachBus called");
return true;
}
void setup(){
Serial.begin(115200); // Serial defaults pins with default detach periman CB
// store the UART RX deinit function, bus#, channel# and bus pointer
peripheral_bus_deinit_cb_t UART_RX_PerimanCB = perimanGetBusDeinit(ESP32_BUS_TYPE_UART_RX);
int8_t UART0_busNum = perimanGetPinBusNum(RX);
int8_t UART0_channel = perimanGetPinBusNum(RX);
void *UART0_bus = perimanGetPinBus(RX, ESP32_BUS_TYPE_UART_RX);
// change the UART RX detaching function -- TX kept the same
perimanSetBusDeinit(ESP32_BUS_TYPE_UART_RX, _uartRXPinDetachBus);
Serial.println("TESTING UART0 TX ...");
pinMode(RX, INPUT); // changes the UART0 RX pin function to GPIO INPUT, but doesn't dettach UART RX function
for (int i = 0; i < 10; i++) {
int val = digitalRead(RX); // read it as DIGITAL level
Serial.println("#" + String(i) + " Read Val = " + String (val ? "HIGH" : "LOW"));
delay(500);
}
// restore the UART RX detach function
perimanSetBusDeinit(ESP32_BUS_TYPE_UART_RX, UART_RX_PerimanCB);
perimanSetPinBus(RX, ESP32_BUS_TYPE_UART_RX, UART0_bus, UART0_busNum, UART0_channel);
Serial.println("Ending the UART0 - Check the verbose log output.");
Serial.flush();
// detaching UART0 RX - check Verbose Log output
pinMode(RX, OUTPUT); // changes the UART0 RX pin function to GPIO OUTPUT
}
void loop() {}
ets Jul 29 2019 12:21:46
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:4980
load:0x40078000,len:16612
load:0x40080400,len:3480
entry 0x400805b4
[ 1][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RX (2) successfully set to 0x400d3ab0
[ 12][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_TX (3) successfully set to 0x400d3a80
[ 26][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_CTS (4) successfully set to 0x400d3a50
[ 39][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RTS (5) successfully set to 0x400d3a20
[ 53][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RX (2) successfully set to 0x400d3ab0
[ 66][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_TX (3) successfully set to 0x400d3a80
[ 80][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_CTS (4) successfully set to 0x400d3a50
[ 93][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RTS (5) successfully set to 0x400d3a20
[ 107][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RX (2) successfully set to 0x400d3ab0
[ 120][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_TX (3) successfully set to 0x400d3a80
[ 133][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_CTS (4) successfully set to 0x400d3a50
[ 147][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RTS (5) successfully set to 0x400d3a20
f�B�ʢJ�*��}��ɕ}�յ�}���͡� Incorrect size of core dump image: 1098975400
[ 163][D][esp32-hal-cpu.c:276] setCpuFrequencyMhz(): PLL: 480 / 2 = 240 Mhz, APB: 80000000 Hz
[ 214][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 3 successfully set to type UART_RX (2) with bus 0x3ffbdb60
[ 224][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 1 successfully set to type UART_TX (3) with bus 0x3ffbdb60
=========== Before Setup Start ===========
Chip Info:
------------------------------------------
Model : ESP32
Package : D0WD-Q5
Revision : 3.00
Cores : 2
CPU Frequency : 240 MHz
XTAL Frequency : 40 MHz
Features Bitfield : 0x00000032
Embedded Flash : No
Embedded PSRAM : No
2.4GHz WiFi : Yes
Classic BT : Yes
BT Low Energy : Yes
IEEE 802.15.4 : No
------------------------------------------
BT Low Energy : Yes
IEEE 802.15.4 : No
------------------------------------------
INTERNAL Memory Info:
------------------------------------------
Total Size : 378936 B ( 370.1 KB)
Free Bytes : 336688 B ( 328.8 KB)
Allocated Bytes : 34764 B ( 33.9 KB)
Minimum Free Bytes: 330836 B ( 323.1 KB)
Largest Free Block: 110580 B ( 108.0 KB)
------------------------------------------
Flash Info:
------------------------------------------
Chip Size : 8388608 B (8 MB)
Block Size : 65536 B ( 64.0 KB)
Sector Size : 4096 B ( 4.0 KB)
Page Size : 256 B ( 0.2 KB)
Bus Speed : 80 MHz
Bus Mode : QIO
------------------------------------------
Partitions Info:
------------------------------------------
nvs : addr: 0x00009000, size: 20.0 KB, type: DATA, subtype: NVS
otadata : addr: 0x0000E000, size: 8.0 KB, type: DATA, subtype: OTA
app0 : addr: 0x00010000, size: 1280.0 KB, type: APP, subtype: OTA_0
app1 : addr: 0x00150000, size: 1280.0 KB, type: APP, subtype: OTA_1
spiffs : addr: 0x00290000, size: 1408.0 KB, type: DATA, subtype: SPIFFS
coredump : addr: 0x003F0000, size: 64.0 KB, type: DATA, subtype: COREDUMP
------------------------------------------
Software Info:
------------------------------------------
Compile Date/Time : Sep 4 2025 11:51:12
Compile Host OS : windows
ESP-IDF Version : v5.5-1-gb66b5448e0
Arduino Version : 3.3.0
------------------------------------------
Board Info:
------------------------------------------
Arduino Board : ESP32_DEV
Arduino Variant : esp32
Arduino FQBN : espressif:orig:esp32:UploadSpeed=921600,CPUFreq=240,FlashFreq=80,FlashMode=qio,FlashSize=4M,PartitionScheme=default,DebugLevel=verbose,PSRAM=disabled,LoopCore=1,EventsCore=1,EraseFlash=none,JTAGAdapter=default,ZigbeeMode=default
============ Before Setup End ============
[ 733][V][esp32-hal-uart.c:707] uartBegin(): UART0 baud(115200) Mode(800001c) rxPin(3) txPin(1)
[ 742][V][esp32-hal-uart.c:805] uartBegin(): UART0 not installed. Starting installation
[ 752][V][esp32-hal-uart.c:815] uartBegin(): UART0 RX FIFO full threshold set to 120 (value requested: 120 || FIFO Max = 128)
[ 766][V][esp32-hal-uart.c:845] uartBegin(): Setting UART0 to use REF_TICK clock
[ 776][V][esp32-hal-uart.c:905] uartBegin(): UART0 initialization done.
[ 791][V][esp32-hal-uart.c:956] uartSetRxFIFOFull(): UART0 RX FIFO Full value set to 120 from a requested value of 120
[ 801][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RX (2) successfully set to 0x400d1840
TESTING UART0 TX ...
[ 812][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type GPIO (1) successfully set to 0x400f3620
[ 825][D][Blink.ino:5] _uartRXPinDetachBus(): _uartRXPinDetachBus called
[ 832][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 3 successfully set to type INIT (0) with bus 0x0
[ 842][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 3 successfully set to type GPIO (1) with bus 0x4
#0 Read Val = HIGH
#1 Read Val = LOW
#2 Read Val = HIGH
#3 Read Val = LOW
#4 Read Val = LOW
#5 Read Val = HIGH
#6 Read Val = HIGH
#7 Read Val = LOW
#8 Read Val = LOW
#9 Read Val = HIGH
[ 5851][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RX (2) successfully set to 0x400d3ab0
[ 5863][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 3 successfully set to type UART_RX (2) with bus 0x3ffbdb60
Ending the UART0 - Check the verbose log output.
[ 5877][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type GPIO (1) successfully set to 0x400f3620
[ 5888][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 3 successfully set to type INIT (0) with bus 0x0
[ 5898][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 3 successfully set to type INIT (0) with bus 0x0
[ 5908][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 3 successfully set to type GPIO (1) with bus 0x4
=========== After Setup Start ============
INTERNAL Memory Info:
------------------------------------------
Total Size : 378936 B ( 370.1 KB)
Free Bytes : 334216 B ( 326.4 KB)
Allocated Bytes : 36948 B ( 36.1 KB)
Minimum Free Bytes: 328216 B ( 320.5 KB)
Largest Free Block: 110580 B ( 108.0 KB)
------------------------------------------
GPIO Info:
------------------------------------------
GPIO : BUS_TYPE[bus/unit][chan]
--------------------------------------
1 : UART_TX[0]
3 : GPIO
============ After Setup End =============
Uh oh!
There was an error while loading. Please reload this page.
Description of Change
Allows to get the CB pointer for a Peripheral Manager Bus Type.
It can be used to verify if it is already set and also in case the application needs to change the CB to something else and latter restore the original CB to that Bus Type.
PR also intializes all CB pinters to NULL.
Tests scenarios
ESP32 using LOG Debug information.
It is possible to see results by using a wire to ground RX0 while the pin is read.
Debug Output:
Related links
Closes #11666