Comments (18)
So I did a bit of thinking, and I think I know how to use the GPIO now. I can use GPIO_ENABLE_REG to set the pin I want to output, then pull it high with GPIO_OUT_REG. I'm not sure when I'll be able to test my code, but I'm (sorta) confident in my code.
from linux-xtensa.
would this work?
About that pattern: tell me if I'm wrong, but you can compile it, run it and see for yourself?
I mean, the human capacity is limited, it makes sense to ask humans the questions that the hardware cannot answer.
from linux-xtensa.
I can't find the code
I believe there was no kernel code, but a userspace program that was writing registers directly.
from linux-xtensa.
I believe there was no kernel code, but a userspace program that was writing registers directly.
Do you still have the program?
from linux-xtensa.
Do you still have the program?
It's devmem
, part of busybox. See https://olimex.wordpress.com/2023/06/27/running-linux-with-kernel-6-3-on-open-source-hardware-board-with-esp32-s3/ for the use example.
from linux-xtensa.
It's
devmem
, part of busybox. See https://olimex.wordpress.com/2023/06/27/running-linux-with-kernel-6-3-on-open-source-hardware-board-with-esp32-s3/ for the use example.
What about in C code? I plan on trying to write a driver if I can figure out how.
from linux-xtensa.
What about in C code?
Depends on how fancy/portable you want your code. You can just write data directly to the desired physical address from the userspace if you don't care at all.
I plan on trying to write a driver
Then it might be a good idea to take a look at other similar drivers.
from linux-xtensa.
Then it might be a good idea to take a look at other similar drivers.
Are there any similar drivers?
from linux-xtensa.
A whole bunch.
from linux-xtensa.
Could we use the MMIO GPIO driver?
from linux-xtensa.
IDK. Perhaps. Try and see?
from linux-xtensa.
What is the minimum for writing my own driver?
from linux-xtensa.
What is the minimum for writing my own driver?
Minimum what? Minimum understanding: understanding the gpio driver structure and understanding the hardware.
from linux-xtensa.
Minimum what? Minimum understanding: understanding the gpio driver structure and understanding the hardware.
Minimum my driver needs to provide.
from linux-xtensa.
IDK. I don't have any experience with the gpio subsystem whatsoever.
from linux-xtensa.
Tell me if I'm wrong, but each GPIO pin takes up 2 bytes in the MMIO, so GPIO0 is at 0x60004000
, GPIO1 is at 0x60004004
, etc. Is this right?
from linux-xtensa.
Is this right?
No. Take a look at the chapter 6.14 "Register Summary" in the esp32s3 TRM for the details.
from linux-xtensa.
Tell me if I'm wrong, but would this work?
#include <stdint.h>
// Define base address of GPIO matrix
#define GPIO_MATRIX_BASE 0x60004000
// Define GPIO matrix registers (offsets from base address)
#define GPIO_MATRIX_IN_CTRL 0x0
#define GPIO_MATRIX_OUT_CTRL 0x4
// ... Add more register offsets as needed
int main() {
// Pointer to the GPIO matrix base address
volatile uint32_t* gpio_matrix_ptr = (volatile uint32_t*)GPIO_MATRIX_BASE;
// Example: Configure GPIO21 as an input from a specific source
gpio_matrix_ptr[GPIO_MATRIX_IN_CTRL / 4] &= ~(0x1F << 10); // Clear bits 14-10
gpio_matrix_ptr[GPIO_MATRIX_IN_CTRL / 4] |= (0x01 << 10); // Set bits 14-10 to the source you want
// Example: Configure GPIO22 as an output to a specific destination
gpio_matrix_ptr[GPIO_MATRIX_OUT_CTRL / 4] &= ~(0x1F << 10); // Clear bits 14-10
gpio_matrix_ptr[GPIO_MATRIX_OUT_CTRL / 4] |= (0x02 << 10); // Set bits 14-10 to the destination you want
// Add more configurations as needed...
// Now GPIO21 and GPIO22 are configured according to your settings.
// Add your main code here...
return 0;
}
from linux-xtensa.
Related Issues (15)
- Xtensa HiFi 2/4 HOT 1
- USB Serial output instead of UART HOT 19
- USB Host Controller HOT 1
- SD/MMC host controller HOT 3
- Page allocation failure HOT 3
- Booting Linux on ESP32-S3 with U-Boot HOT 4
- OpenCL support HOT 3
- ESP32 UART RX support HOT 3
- How to build for ESP32? HOT 35
- ESP32-S3? HOT 286
- SMP and IPI for ESP32-S3 HOT 21
- Serial Terminal over USB CDC for the ESP32-S3 HOT 1
- SPI Implementation HOT 15
- Xorg on S3 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from linux-xtensa.