## Description [![Component Registry](https://components.espressif.com/components/espressif/extended_vfs/badge.svg)](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 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) ### 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 ## v0.1.0 - 2023-02-27 * Add basic component including GPIO and I2C VFS driver
## 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. ```
## 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. ```
## 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. ```
idf.py add-dependency "espressif/extended_vfs^0.1.0"
To create a project from this example, run:
idf.py create-project-from-example "espressif/extended_vfs^0.1.0:gpio_simple"
To create a project from this example, run:
idf.py create-project-from-example "espressif/extended_vfs^0.1.0:i2c_bh1750"
To create a project from this example, run:
idf.py create-project-from-example "espressif/extended_vfs^0.1.0:i2c_tt21100"