Good afternoon, I have this problem: I need the avr/io.h library to work with the ADC. On the Internet, I found only such a link where you can download it - GitHub - vancegroup-mirrors/avr-libc: Automated svn2git mirror of avr-libc - link goes to upstream. I tried different versions, but apparently the library was written on linux or another system, since it contains the aux.c file, which cannot be created, opened, etc. on windows OS. and get this error when installing this library:
When trying to create the same file, but with a different name, of course replacing the name in other files, when installing the library, it also says that:
Error: Request installZip failed with message: 13 INTERNAL: Library install failed: library not valid
Please help, this is my job, but i'm stuck and don't know what to do.
AVR/io.h does not need to be installed. It is part of the toolchain provided for compiling for AVR devices.
If you are trying to make use of code or a library which is #including it, the library was written for only AVR devices, and does not support non-AVR devices like the ESP32.
You absolutely do not need avr/io.h to use the ADC of the ESP32 that I see you have selected in that screenshot. avr/io.h will just cause more errors (if you're lucky)
On an AVR, io.h detects what microcontroller you told the compiler that you're using, and - if it recognizes it - #includes the device specific io header file, which in turn contains definitions for all the registers used to manipulate all the on-chip peripherals. Those are device and architecture specific.
So whatever library you want to use that is #including avr/io.h, must be replaced with a substitute that is written to use the hardware on the chip you are using, ESP32C3 (which is based on a RISC-V CPU core and Espressif's peripherals). You might have trouble finding a library like that, the ESP32C3 is pretty new, until quite recently Espressif was using Xtensa instead of RISC-V (I recall not too long ago hearing about an some initiative to open up the RISC IP. That may have been the catalyst for this). In any event, there are files that serve the same purpose as io.h, which list the registers and provide the constants appropriate for the ESP32C 3for controlling the ADC (and every other on-chip peripheral). They're already installed, assuming you can compile bare minimum or blink for the ESP32C3, otherwise those would not work (certainly, blink would not - because those files also contain the definition of the registers used to control the pins). The on-chip peripherals on any given device are specific to the device or at least the architecture and "part family" or whatever that manufacturer likes to call groups of parts released around the same time, with similar peripherals.
You actually already have avr/io.h - but the IDE is smart enough not to try to use pieces of avr-libc unless you are compiling for an AVR device. When compiling for an avr-based device, Arduino.h always includes avr/io.h.
OK I understood. But I need to read the ADC registers, any advice? Some other library? Tried direct adk but it's not compatible with esp32, the whole library becomes one big mistake:
Thanks for the answer. Blink works on this board, everything is ok. Now I'll write more about what I'm working on. The board is ESP32-C3-DevkitC-02v1.1. an ADC is connected to it - BH45B1225v110 via the i2c bus. I need to read the HIRCC register and set it to a value (enable it). But as I understand it, this requires an ADC control library, because. it uses a special syntax that arduino does not understand by default.
Are you seen the AVR sign in the title of the library?? Why do you think it should be compatible with ESP32?
No, you require specific library for connect to BH45B1225v110 module. The connection should be done via I2c and has nothing to do with ESP32 ADC registers.