readme
## Description
[](https://components.espressif.com/components/espressif/extended_vfs)
Extended VFS is designed to make applications read/write/configure peripherals by POSIX APIs, like open, close, read, write, ioctl and so on. This components supports following peripheral:
* GPIO
* I2C
* LEDC
* SPI
You can refer to [examples](https://github.com/espressif/esp-iot-solution/tree/master/examples/extended_vfs) to learn usage and more details.
### Add component to your project
Please use the component manager command `add-dependency` to add the `extended_vfs` to your project's dependency, during the `CMake` step the component will be downloaded automatically
```
idf.py add-dependency "espressif/extended_vfs=*"
```
### Examples
Please use the component manager command `create-project-from-example` to create the project from example template
```
idf.py create-project-from-example "espressif/extended_vfs=*:gpio_simple"
```
Then the example `gpio_simple` will be downloaded in current folder, you can check into it for build and flash.
> Or you can download examples from esp-iot-solution repository:
1. [gpio_simple](https://github.com/espressif/esp-iot-solution/tree/master/examples/extended_vfs/gpio/gpio_simple)
2. [i2c_bh1750](https://github.com/espressif/esp-iot-solution/tree/master/examples/extended_vfs/i2c/i2c_bh1750)
3. [i2c_tt21100](https://github.com/espressif/esp-iot-solution/tree/master/examples/extended_vfs/i2c/i2c_tt21100)
4. [ledc_simple](https://github.com/espressif/esp-iot-solution/tree/master/examples/extended_vfs/ledc/ledc_simple)
5. [spi_master_simple](https://github.com/espressif/esp-iot-solution/tree/master/examples/extended_vfs/spi/spi_master_simple)
6. [spi_slave_simple](https://github.com/espressif/esp-iot-solution/tree/master/examples/extended_vfs/spi/spi_slave_simple)
### Q&A
Q1. I encountered the following problems when using the package manager
```
Executing action: create-project-from-example
CMakeLists.txt not found in project directory /home/username
```
A1. This is because an older version packege manager was used, please run `pip install -U idf-component-manager` in ESP-IDF environment to update.
changelog
# ChangeLog
## v0.3.1 - 2023-04-23
* SPI: fix slave mode transmission error when TX/RX buffer in invalid
* LED: fix open -> close -> open error
## v0.3.0 - 2023-04-12
* Add SPI VFS driver
## v0.2.0 - 2023-04-04
* Add LEDC VFS driver
## v0.1.0 - 2023-02-27
* Add basic component including GPIO and I2C VFS driver
readme of gpio_simple example
## GPIO Simple
This example shows how to configure and flip GPIO by POSIX APIs, this decreases dependence on hardware and platform.
## How to Use Example
Before project configuration and build, be sure to set the correct chip target using `idf.py set-target <chip_name>`.
### Hardware Required
* A development board based on espressif SoC
* A USB cable for power supply and programming
* A LED connecting to your configured GPIO and GND
### Configure the Project
Open the project configuration menu (`idf.py menuconfig`).
In the `Example Configuration` menu:
* Set the LED GPIO number used for the signal in the `GPIO Pin Number` option.
* Set the LED GPIO blinking count in the `GPIO Pin Testing coun` option.
### Build and Flash
Run `idf.py -p PORT flash monitor` to build, flash and monitor the project.
(To exit the serial monitor, type ``Ctrl-]``.)
## Example Output
As you run the example, you will see the LED blinking and following log:
```
(0) cpu_start: Starting scheduler on APP CPU.
I (315) ext_vfs: Extended VFS version: 0.1.0
I (315) gpio: GPIO[9]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
Opening device /dev/gpio/9 for writing OK, fd=3.
Set GPIO-9 to be 1 OK.
Set GPIO-9 to be 0 OK.
Set GPIO-9 to be 1 OK.
Set GPIO-9 to be 0 OK.
Set GPIO-9 to be 1 OK.
Set GPIO-9 to be 0 OK.
Set GPIO-9 to be 1 OK.
Set GPIO-9 to be 0 OK.
Set GPIO-9 to be 1 OK.
Set GPIO-9 to be 0 OK.
Set GPIO-9 to be 1 OK.
Set GPIO-9 to be 0 OK.
Set GPIO-9 to be 1 OK.
Set GPIO-9 to be 0 OK.
Set GPIO-9 to be 1 OK.
Set GPIO-9 to be 0 OK.
Set GPIO-9 to be 1 OK.
Set GPIO-9 to be 0 OK.
Set GPIO-9 to be 1 OK.
Set GPIO-9 to be 0 OK.
I (20335) gpio: GPIO[9]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
Close device OK.
```
readme of i2c_bh1750 example
## I2C BH1750 Example
This example shows how to configure I2C bus and read data from BH1750(light intensity sensor) by POSIX APIs, this decreases dependence on hardware and platform.
## How to Use Example
Before project configuration and build, be sure to set the correct chip target using `idf.py set-target <chip_name>`.
### Hardware Required
* A development board based on espressif SoC
* A USB cable for power supply and programming
* A BH1750 connecting to your configured GPIO, Power and GND, if your development board doesn't integrate BH1750 senor
### Configure the Project
Open the project configuration menu (`idf.py menuconfig`).
In the `Example Configuration` menu:
* Set the I2C GPIO number used for the signal in the following option:
- I2C SDA Pin Number
- I2C SCL Pin Number
* Set the reading sensor data count in the `I2C Testing Count of Reading Sensor's Data` option.
### Build and Flash
Run `idf.py -p PORT flash monitor` to build, flash and monitor the project.
(To exit the serial monitor, type ``Ctrl-]``.)
## Example Output
As you run the example, you will see the light intensity value from following log:
```
I (0) cpu_start: Starting scheduler on APP CPU.
I (328) ext_vfs: Extended VFS version: 0.1.0
Opening device /dev/i2c/0 for writing OK, fd=3.
Sensor val: 190.00 [Lux].
Sensor val: 173.33 [Lux].
Sensor val: 173.33 [Lux].
Sensor val: 173.33 [Lux].
Sensor val: 173.33 [Lux].
Sensor val: 176.67 [Lux].
Sensor val: 180.00 [Lux].
Sensor val: 186.67 [Lux].
Sensor val: 190.00 [Lux].
Sensor val: 193.33 [Lux].
Close device OK.
```
readme of i2c_tt21100 example
## I2C TT21100 Example
This example shows how to configure I2C bus and read data from TT21100(touch pad) by POSIX APIs, this decreases dependence on hardware and platform.
## How to Use Example
Before project configuration and build, be sure to set the correct chip target using `idf.py set-target <chip_name>`.
### Hardware Required
* A development board based on espressif SoC
* A USB cable for power supply and programming
* A TT21100 connecting to your configured GPIO, Power and GND, if your development board doesn't integrate TT21100
### Configure the Project
Open the project configuration menu (`idf.py menuconfig`).
In the `Example Configuration` menu:
* Set the I2C GPIO number used for the signal in the following option:
- I2C SDA Pin Number
- I2C SCL Pin Number
- TT21100 Ready Pin Number
* Set the reading sensor data count in the `I2C Testing Count of Reading Sensor's Data` option.
### Build and Flash
Run `idf.py -p PORT flash monitor` to build, flash and monitor the project.
(To exit the serial monitor, type ``Ctrl-]``.)
## Example Output
As you run the example, you will see following log:
```
I (0) cpu_start: Starting scheduler on APP CPU.
I (315) ext_vfs: Extended VFS version: 0.1.0
I (315) gpio: GPIO[3]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
TT21100 touch screen is initialized, and start reading touch point information:
```
Then you can touch the TT21100 touch pad and see touch point location information as following:
```
X0=122 Y0=146
X0=122 Y0=146
X0=122 Y0=146
X0=122 Y0=146
X0=122 Y0=146
X0=122 Y0=146
X0=152 Y0=169
X0=152 Y0=169
X0=152 Y0=169
X0=152 Y0=169
X0=152 Y0=169
X0=152 Y0=169
X0=153 Y0=169
X0=153 Y0=169
X0=217 Y0=170
X0=217 Y0=170
X0=219 Y0=170
X0=220 Y0=170
X0=221 Y0=169
X0=221 Y0=169
X0=217 Y0=168
X0=217 Y0=168
X0=106 Y0=186
X0=106 Y0=186
X0=106 Y0=186
X0=106 Y0=186
X0=106 Y0=186
X0=106 Y0=186
X0=106 Y0=186
X0=106 Y0=186
X0=68 Y0=173
X0=68 Y0=173
X0=68 Y0=173
X0=67 Y0=173
X0=67 Y0=173
X0=66 Y0=171
X0=65 Y0=166
X0=65 Y0=166
X0=95 Y0=106
X0=95 Y0=106
X0=95 Y0=106
X0=95 Y0=106
X0=94 Y0=106
X0=93 Y0=106
X0=93 Y0=106
X0=93 Y0=106
X0=91 Y0=79
X0=91 Y0=79
X0=91 Y0=79
X0=90 Y0=79
X0=87 Y0=80
X0=84 Y0=82
X0=82 Y0=84
X0=80 Y0=85
X0=80 Y0=85
X0=54 Y0=106
X0=54 Y0=106
X0=54 Y0=106
X0=53 Y0=108
X0=52 Y0=110
X0=50 Y0=111
X0=50 Y0=112
X0=49 Y0=112
X0=49 Y0=112
X0=48 Y0=141
X0=48 Y0=141
X0=48 Y0=141
X0=47 Y0=141
X0=47 Y0=141
X0=46 Y0=141
X0=45 Y0=141
X0=45 Y0=141
X0=67 Y0=152
X0=67 Y0=152
X0=67 Y0=152
X0=67 Y0=152
X0=67 Y0=152
X0=67 Y0=152
X0=66 Y0=152
X0=66 Y0=152
X0=78 Y0=165
X0=78 Y0=165
X0=78 Y0=164
X0=78 Y0=164
X0=78 Y0=163
X0=79 Y0=163
X0=79 Y0=162
X0=79 Y0=162
X0=140 Y0=139
X0=140 Y0=139
X0=140 Y0=139
X0=140 Y0=139
X0=140 Y0=139
X0=141 Y0=138
X0=142 Y0=137
X0=144 Y0=134
X0=144 Y0=134
X0=178 Y0=128
X0=178 Y0=128
X0=178 Y0=128
I (4145) gpio: GPIO[3]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
Test done and de-initialize TT21100 touch screen.
```
readme of ledc_simple example
## LEDC Simple
This example shows how to configure LEDC by POSIX APIs, this decreases dependence on hardware and platform.
## How to Use Example
Before project configuration and build, be sure to set the correct chip target using `idf.py set-target <chip_name>`.
### Hardware Required
* A development board based on espressif SoC
* A USB cable for power supply and programming
* A LED connecting to your configured LEDC output GPIO and GND
### Configure the Project
Open the project configuration menu (`idf.py menuconfig`).
In the `Example Configuration` menu:
* Set the LEDC GPIO Frequency value in the `LEDC Frequency(Hz)` option.
* Set the LEDC output GPIO number used for the signal in the `LEDC Output Pin` option.
### Build and Flash
Run `idf.py -p PORT flash monitor` to build, flash and monitor the project.
(To exit the serial monitor, type ``Ctrl-]``.)
## Example Output
As you run the example, you will see the LED's brightness changes and following log:
```
I (0) cpu_start: Starting scheduler on APP CPU.
I (333) ext_vfs: Extended VFS version: 0.1.0
Opening device /dev/ledc/0 for writing OK, fd=3.
Set LEDC duty to be 0
Set LEDC duty to be 20
Set LEDC duty to be 40
Set LEDC duty to be 60
Set LEDC duty to be 80
Set LEDC duty to be 0
Set LEDC duty to be 20
Set LEDC duty to be 40
Set LEDC duty to be 60
Set LEDC duty to be 80
Close device OK.
```
readme of spi_master_simple example
## SPI Master Simple
This example shows how to configure SPI master by POSIX APIs, this decreases dependence on hardware and platform.
## How to Use Example
Before project configuration and build, be sure to set the correct chip target using `idf.py set-target <chip_name>`.
And this example should be used together with [SPI Slave Simple](../spi_slave_simple/).
### Hardware Required
* 2 development boards based on espressif SoC
* 2 USB cables for power supply and programming
* 5 DuPont lines connecting SPI pins and GND between 2 development boards
### Configure the Project
Open the project configuration menu (`idf.py menuconfig`).
In the `Example Configuration` menu:
* Select SPI port in the `Select SPI Device` option, please note that not all SoC supports `SPI3`
* Set the SPI pins number in the following options according to your development board:
- `SPI CS Pin Number`
- `SPI SCLK Pin Number`
- `SPI MOSI Pin Number`
- `SPI MISO Pin Number`
* Set transmission count in the `SPI Testing Count of Transmitting Data`
### Build and Flash
Run `idf.py -p PORT flash monitor` to build, flash and monitor the project.
(To exit the serial monitor, type ``Ctrl-]``.)
## Example Output
As you run the example, you will see the following log:
```
I (0) cpu_start: Starting scheduler on APP CPU.
I (345) ext_vfs: Extended VFS version: 0.3.0
Opening device /dev/spi/2 for writing OK, fd=3.
Write text total 32 bytes into device OK.
Write text total 32 bytes into device OK.
Write text total 32 bytes into device OK.
Write text total 32 bytes into device OK.
Write text total 32 bytes into device OK.
Write text total 32 bytes into device OK.
Write text total 32 bytes into device OK.
Write text total 32 bytes into device OK.
Write text total 32 bytes into device OK.
Write text total 32 bytes into device OK.
Write text total 32 bytes into device OK.
```
readme of spi_slave_simple example
## SPI Slave Simple
This example shows how to configure SPI slave by POSIX APIs, this decreases dependence on hardware and platform.
## How to Use Example
Before project configuration and build, be sure to set the correct chip target using `idf.py set-target <chip_name>`.
And this example should be used together with [SPI Master Simple](../spi_master_simple/).
### Hardware Required
* 2 development boards based on espressif SoC
* 2 USB cables for power supply and programming
* 5 DuPont lines connecting SPI pins and GND between 2 development boards
### Configure the Project
Open the project configuration menu (`idf.py menuconfig`).
In the `Example Configuration` menu:
* Select SPI port in the `Select SPI Device` option, please note that not all SoC supports `SPI3`
* Set the SPI pins number in the following options according to your development board:
- `SPI CS Pin Number`
- `SPI SCLK Pin Number`
- `SPI MOSI Pin Number`
- `SPI MISO Pin Number`
### Build and Flash
Run `idf.py -p PORT flash monitor` to build, flash and monitor the project.
(To exit the serial monitor, type ``Ctrl-]``.)
## Example Output
As you run the example ,you will see the following log:
```
I (0) cpu_start: Starting scheduler on APP CPU.
I (344) ext_vfs: Extended VFS version: 0.3.0
Opening device /dev/spi/2 for writing OK, fd=3.
Receive total 32 bytes from device: SPI Tx 0
Receive total 32 bytes from device: SPI Tx 1
Receive total 32 bytes from device: SPI Tx 2
Receive total 32 bytes from device: SPI Tx 3
Receive total 32 bytes from device: SPI Tx 4
Receive total 32 bytes from device: SPI Tx 5
Receive total 32 bytes from device: SPI Tx 6
Receive total 32 bytes from device: SPI Tx 7
Receive total 32 bytes from device: SPI Tx 8
Receive total 32 bytes from device: SPI Tx 9
Receive total 32 bytes from device: SPI Tx 10
Receive total 32 bytes from device: SPI Tx 11
```