claudeheintz/LXESP32DMX

Modified hal not compiling

macdroid53 opened this issue · 1 comments

Not sure where I've gone wrong...esp32-hal-uart.c
I had this working, then I had some issues with VSCode and now when I compile with the modified esp32-hal-uart.c I get the following:

Linking .pio/build/featheresp32/firmware.elf
.pio/build/featheresp32/libFrameworkArduino.a(HardwareSerial.cpp.o):(.literal._ZN14HardwareSerial5beginEmjaabm+0x14): undefined reference to `uartStartDetectBaudrate'
.pio/build/featheresp32/libFrameworkArduino.a(HardwareSerial.cpp.o): In function `HardwareSerial::begin(unsigned long, unsigned int, signed char, signed char, bool, unsigned long)':
/home/mac/.platformio/packages/framework-arduinoespressif32/cores/esp32/Stream.h:104: undefined reference to `uartStartDetectBaudrate'

I believe the equivalent place to [path to sketch folder]/Arduino/hardware/ in VSC and PIO for the esp32 is:
~/.platformio/packages/framework-arduinoespressif32/cores/esp32

(I thought putting there worked ...but, that was a few months back, and my aged brain doesn't do well with time. :) )

Had some time to look at this issue today. So I set up a clean arduino ide and used the input example from this library.

I got the same error on build in the arduino environment.

I looked in the esp32-hal-uart.c file that comes with the esp core and found this:

/*
 * To start detection of baud rate with the uart the auto_baud.en bit needs to be cleared and set. The bit period is 
 * detected calling uartBadrateDetect(). The raw baudrate is computed using the UART_CLK_FREQ. The raw baudrate is 
 * rounded to the closed real baudrate.
*/
void uartStartDetectBaudrate(uart_t *uart) {
  if(!uart) return;

  uart->dev->auto_baud.glitch_filt = 0x08;
  uart->dev->auto_baud.en = 0;
  uart->dev->auto_baud.en = 1;
}

unsigned long
uartDetectBaudrate(uart_t *uart)
{
    static bool uartStateDetectingBaudrate = false;
...

In the replacement esp32-hal-uart.c the uartStartDetectBaudrate function wasn't there.

I added this function to the replacement and the code builds and appears to work.

I don't know if I didn't get this lib installed correctly or something has been changed in the core.
I have no way of knowing if this addition causes other issues...