Memory mapped IO for GPIO access

apuder
Posts: 53
Joined: Mon Mar 26, 2018 7:27 pm

Memory mapped IO for GPIO access

Postby apuder » Mon Mar 26, 2018 7:34 pm

Hi,

someone knowledgeable out there who can post something equivalent to the AVR's memory mapped IO for GPIO pins?
https://www.arduino.cc/en/Reference/PortManipulation

I am interested in reading and writing multiple GPIO pins in parallel without having to loop through digitalRead/Write for performance reasons.

TIA,
AP

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: Memory mapped IO for GPIO access

Postby kolban » Tue Mar 27, 2018 1:40 am

Howdy,
Have a review of this post and see if it meets your needs:

viewtopic.php?t=1746
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

apuder
Posts: 53
Joined: Mon Mar 26, 2018 7:27 pm

Re: Memory mapped IO for GPIO access

Postby apuder » Tue Mar 27, 2018 11:00 am

thanks! That clarifies a few things indeed. Please allow me a couple of follow-up questions:

* it seems that there are two registers for setting a GPIO pin to 1 (W1TS) and setting a GPIO pin to 0 (W1TC). If I want to write an 8-bit value (using 8 GPIO pins), it is not possible to do this atomically? One has to use two operations (one that sets the 1-bits and a second that sets the 0-bits)?
* I want to use the ESP32 to read and write to an 8-bit I/O bus. It seems there is no efficient way to reconfigure those 8-bits to either mode input or mode output. If performance is an issue, would it be the preferred way to use 8 pins for reading and some other 8 pins for writing? Uses more pins but at least one does not have to reconfigure the pins when switching to reading and writing.
* last one: where can I find the implementation of gpio_config()?

TIA,
AP

apuder
Posts: 53
Joined: Mon Mar 26, 2018 7:27 pm

Re: Memory mapped IO for GPIO access

Postby apuder » Wed Mar 28, 2018 2:28 am

perhaps a more important question: is there any documentation on GPIO_MODE_INPUT_OUTPUT_OD and GPIO_MODE_INPUT_OUTPUT?

Thx,
AP

User avatar
Vader_Mester
Posts: 300
Joined: Tue Dec 05, 2017 8:28 pm
Location: Hungary
Contact:

Re: Memory mapped IO for GPIO access

Postby Vader_Mester » Fri Mar 30, 2018 1:16 pm

I have the feelin you want to send and receive an 8bit wide parallel datastream.

If this is the case then you can use the I2S periferial in LCD mode.
There is an I2S parallel driver somewhere, that can be used for that. As far as I know the theoretical max clock here is 40MHz for the sending, which is prett fast and provides clock from hardware. NO need to do bit banging.

Code: Select all

task_t coffeeTask()
{
	while(atWork){
		if(!xStreamBufferIsEmpty(mug)){
			coffeeDrink(mug);
		} else {
			xTaskCreate(sBrew, "brew", 9000, &mug, 1, NULL);
			xSemaphoreTake(sCoffeeRdy, portMAX_DELAY);
		}
	}
	vTaskDelete(NULL);
}

apuder
Posts: 53
Joined: Mon Mar 26, 2018 7:27 pm

Re: Memory mapped IO for GPIO access

Postby apuder » Tue Apr 03, 2018 5:15 am

yes, I want to read and write to an 8-bit wide bus. If you can point me to some code sniplets for the I2S solution you mentioned, I would most appreciate it.

AP


Who is online

Users browsing this forum: No registered users and 100 guests