|
5 | 5 |
|
6 | 6 |
|
7 | 7 |
|
8 | | -| :1234: [CAPABILITIES](#1234-capabilities) | :floppy_disk: [SD CARD AND SPIFFS](#floppy_disk-sd-card-and-spiffs) | :musical_note: [AUDIO](#musical_note-audio) | :pager: [DISPLAY AND TOUCH](#pager-display-and-touch) | :radio_button: [BUTTONS](#radio_button-buttons) | :electric_plug: [USB](#electric_plug-usb) | |
9 | | -| :-------------------------: | :-------------------------: | :-------------------------: | :-------------------------: | :-------------------------: | :-------------------------: | |
| 8 | +| :1234: [CAPABILITIES](#1234-capabilities) | :floppy_disk: [SD CARD AND SPIFFS](#floppy_disk-sd-card-and-spiffs) | :musical_note: [AUDIO](#musical_note-audio) | :pager: [DISPLAY AND TOUCH](#pager-display-and-touch) | :radio_button: [BUTTONS](#radio_button-buttons) | :electric_plug: [USB](#electric_plug-usb) | :video_game: [SENSORS](#video_game-sensors) | |
| 9 | +| :-------------------------: | :-------------------------: | :-------------------------: | :-------------------------: | :-------------------------: | :-------------------------: | :-------------------------: | |
10 | 10 |
|
11 | 11 | </div> |
12 | 12 |
|
@@ -149,6 +149,7 @@ You can use these macros to conditionally compile code depending on feature avai |
149 | 149 | | define | [**BSP\_CAPS\_AUDIO\_SPEAKER**](#define-bsp_caps_audio_speaker) 1<br> | |
150 | 150 | | define | [**BSP\_CAPS\_BUTTONS**](#define-bsp_caps_buttons) 1<br> | |
151 | 151 | | define | [**BSP\_CAPS\_DISPLAY**](#define-bsp_caps_display) 1<br> | |
| 152 | +| define | [**BSP\_CAPS\_HUMITURE**](#define-bsp_caps_humiture) 1<br> | |
152 | 153 | | define | [**BSP\_CAPS\_IMU**](#define-bsp_caps_imu) 1<br> | |
153 | 154 | | define | [**BSP\_CAPS\_SDCARD**](#define-bsp_caps_sdcard) 1<br> | |
154 | 155 | | define | [**BSP\_CAPS\_TOUCH**](#define-bsp_caps_touch) 1<br> | |
@@ -213,6 +214,8 @@ You can use these macros to conditionally compile code depending on feature avai |
213 | 214 |
|
214 | 215 | | Type | Name | |
215 | 216 | | ---: | :--- | |
| 217 | +| define | [**BSP\_I2C\_DOCK\_SCL**](#define-bsp_i2c_dock_scl) (GPIO\_NUM\_40)<br> | |
| 218 | +| define | [**BSP\_I2C\_DOCK\_SDA**](#define-bsp_i2c_dock_sda) (GPIO\_NUM\_41)<br> | |
216 | 219 | | define | [**BSP\_I2C\_NUM**](#define-bsp_i2c_num) CONFIG\_BSP\_I2C\_NUM<br> | |
217 | 220 | | define | [**BSP\_I2C\_SCL**](#define-bsp_i2c_scl) (GPIO\_NUM\_18)<br> | |
218 | 221 | | define | [**BSP\_I2C\_SDA**](#define-bsp_i2c_sda) (GPIO\_NUM\_8)<br> | |
@@ -1467,3 +1470,107 @@ For more USB-related APIs and configuration options, check the corresponding BSP |
1467 | 1470 |
|
1468 | 1471 |
|
1469 | 1472 |
|
| 1473 | +
|
| 1474 | +
|
| 1475 | +
|
| 1476 | +## :video_game: Sensors |
| 1477 | +
|
| 1478 | +Boards with integrated sensors (e.g., IMUs, environmental sensors) are abstracted using the sensor hub component. |
| 1479 | +The BSP project provides APIs for initializing each sensor and it is up to the integrating platform to provide configuration of the data acquisition and callback handlers. |
| 1480 | +
|
| 1481 | +For practical usage examples and supported sensors on your board, refer to the relevant examples in the BSP repository, such as: |
| 1482 | +- `sensors` (for reading sensor data) |
| 1483 | +- TODO: `display_rotation` (for IMU setup and orientation control) |
| 1484 | +
|
| 1485 | +### Usage |
| 1486 | +
|
| 1487 | +Create a handler function for sensor hub events |
| 1488 | +``` c |
| 1489 | +void sensor_event_handler(void *handler_args, esp_event_base_t base, int32_t id, void *event_data) |
| 1490 | +{ |
| 1491 | + ... |
| 1492 | +} |
| 1493 | +``` |
| 1494 | + |
| 1495 | +Set up a sensor configuration and initialize it |
| 1496 | +``` c |
| 1497 | +bsp_sensor_config_t imu_config = { |
| 1498 | + .type = IMU_ID, |
| 1499 | + .mode = MODE_POLLING, |
| 1500 | + .period = 1000 |
| 1501 | +}; |
| 1502 | +ESP_ERROR_CHECK(bsp_sensor_init(&imu_config, &imu_sensor_handle)); |
| 1503 | +``` |
| 1504 | +
|
| 1505 | +Associate an event handler with the configured sensor |
| 1506 | +``` c |
| 1507 | +iot_sensor_handler_register(imu_sensor_handle, sensor_event_handler, NULL); |
| 1508 | +``` |
| 1509 | + |
| 1510 | +Start the sensor data acquisition |
| 1511 | +``` c |
| 1512 | +iot_sensor_start(imu_sensor_handle); |
| 1513 | +``` |
| 1514 | +
|
| 1515 | +**Notes:** |
| 1516 | +- More information can be found in [sensor hub documentation page](https://docs.espressif.com/projects/esp-iot-solution/en/latest/sensors/sensor_hub.html). |
| 1517 | +
|
| 1518 | +### Sensors API Reference |
| 1519 | +
|
| 1520 | +## Structures and Types |
| 1521 | +
|
| 1522 | +| Type | Name | |
| 1523 | +| ---: | :--- | |
| 1524 | +| struct | [**bsp\_sensor\_config\_t**](#struct-bsp_sensor_config_t) <br>_BSP sensor configuration structure._ | |
| 1525 | +
|
| 1526 | +## Functions |
| 1527 | +
|
| 1528 | +| Type | Name | |
| 1529 | +| ---: | :--- | |
| 1530 | +| esp\_err\_t | [**bsp\_sensor\_init**](#function-bsp_sensor_init) (const [**bsp\_sensor\_config\_t**](#struct-bsp_sensor_config_t) \*cfg, sensor\_handle\_t \*sensor\_handle) <br>_Initialize a sensor._ | |
| 1531 | +
|
| 1532 | +
|
| 1533 | +
|
| 1534 | +## Structures and Types Documentation |
| 1535 | +
|
| 1536 | +### struct `bsp_sensor_config_t` |
| 1537 | +
|
| 1538 | +_BSP sensor configuration structure._ |
| 1539 | +
|
| 1540 | +Variables: |
| 1541 | +
|
| 1542 | +- sensor\_mode\_t mode |
| 1543 | +
|
| 1544 | +- uint16\_t period |
| 1545 | +
|
| 1546 | +- sensor\_type\_t type |
| 1547 | +
|
| 1548 | +
|
| 1549 | +## Functions Documentation |
| 1550 | +
|
| 1551 | +### function `bsp_sensor_init` |
| 1552 | +
|
| 1553 | +_Initialize a sensor._ |
| 1554 | +```c |
| 1555 | +esp_err_t bsp_sensor_init ( |
| 1556 | + const bsp_sensor_config_t *cfg, |
| 1557 | + sensor_handle_t *sensor_handle |
| 1558 | +) |
| 1559 | +``` |
| 1560 | + |
| 1561 | + |
| 1562 | +**Parameters:** |
| 1563 | + |
| 1564 | + |
| 1565 | +* `cfg` Pointer to the sensor configuration |
| 1566 | +* `sensor_handle` Pointer to the outgoing sensor handle |
| 1567 | + |
| 1568 | + |
| 1569 | +**Returns:** |
| 1570 | + |
| 1571 | + |
| 1572 | + |
| 1573 | +* ESP\_OK on success, otherwise returns ESP\_ERR\_xxx |
| 1574 | + |
| 1575 | + |
| 1576 | + |
0 commit comments