Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes UART detach. Fixes #3878 #3894

Merged
merged 4 commits into from
Sep 30, 2020
Merged

Fixes UART detach. Fixes #3878 #3894

merged 4 commits into from
Sep 30, 2020

Conversation

lbernstone
Copy link
Contributor

From what I can tell, there used to be a hidden mechanism to detach the uart pins in gpio_matrix_out. This no longer works, so we need to keep track of what pins we assign.

@aster94
Copy link

aster94 commented Jul 18, 2020

any news on this?

@drojf
Copy link

drojf commented Sep 10, 2020

Are you sure that pinMatrixInDetach() takes the same first argument as pinMatrixOutDetach()? If you look at the definition/SPI code for the same thing, you'll find it takes a different argument to the ...OutDetach() function:

void IRAM_ATTR pinMatrixOutDetach(uint8_t pin, bool invertOut, bool invertEnable)
{
gpio_matrix_out(pin, MATRIX_DETACH_OUT_SIG, invertOut, invertEnable);
}
void IRAM_ATTR pinMatrixInAttach(uint8_t pin, uint8_t signal, bool inverted)
{
gpio_matrix_in(pin, signal, inverted);
}
void IRAM_ATTR pinMatrixInDetach(uint8_t signal, bool high, bool inverted)
{
gpio_matrix_in(high?MATRIX_DETACH_IN_LOW_HIGH:MATRIX_DETACH_IN_LOW_PIN, signal, inverted);
}

void spiDetachMISO(spi_t * spi, int8_t miso)
{
if(!spi) {
return;
}
if(miso < 0) {
if(spi->num == HSPI) {
miso = 12;
} else if(spi->num == VSPI) {
miso = 19;
} else {
miso = 7;
}
}
pinMatrixInDetach(SPI_MISO_IDX(spi->num), false, false);
pinMode(miso, INPUT);
}
void spiDetachMOSI(spi_t * spi, int8_t mosi)
{
if(!spi) {
return;
}
if(mosi < 0) {
if(spi->num == HSPI) {
mosi = 13;
} else if(spi->num == VSPI) {
mosi = 23;
} else {
mosi = 8;
}
}
pinMatrixOutDetach(mosi, false, false);
pinMode(mosi, INPUT);
}

I guess there could also be an error in the esp32-hal-matrix.c file definition for pinMatrixInDetach().

If they really do take different arguments, you only need to change the pinMatrixOutDetach() call (so as to match the SPI example)

@lbernstone
Copy link
Contributor Author

I didn't change the header definitions for either of the pinMatrix detach functions, so I'm pretty sure the arguments are correct. This PR is specifically to deal with the fact that the UART_TXD_IDX pins (which are in the 200s, IIRC) no longer work in the IDF functions. The SPI versions of those pins must still work, since nobody is complaining about SPI::end failing.

@dka23
Copy link

dka23 commented Sep 22, 2020

See also #3205

@me-no-dev me-no-dev merged commit 80418fa into espressif:master Sep 30, 2020
@lbernstone lbernstone deleted the uart_detach branch November 4, 2020 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants