Skip to content

Commit 9896440

Browse files
committed
feat: update
1 parent 6e56cce commit 9896440

File tree

8 files changed

+351
-187
lines changed

8 files changed

+351
-187
lines changed

ports/esp32/main_esp32s3_box3/esp-box-3/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,5 @@ idf_component_register(
99
SRCS "esp-box-3.c" ${SRC_VER}
1010
INCLUDE_DIRS "include"
1111
PRIV_INCLUDE_DIRS "priv_include"
12-
REQUIRES driver spiffs
13-
PRIV_REQUIRES fatfs esp_lcd
12+
REQUIRES driver spiffs esp_lcd
1413
)

ports/esp32/main_esp32s3_box3/esp-box-3/esp-box-3.c

Lines changed: 70 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@
1414
#include "esp_lcd_panel_io.h"
1515
#include "esp_lcd_panel_vendor.h"
1616
#include "esp_lcd_panel_ops.h"
17-
#include "esp_vfs_fat.h"
1817

19-
#include "iot_button.h"
18+
// #include "iot_button.h"
2019
#include "bsp/esp-box-3.h"
2120
#include "bsp/display.h"
2221
#include "bsp/touch.h"
@@ -29,7 +28,7 @@
2928
static const char *TAG = "ESP-BOX-3";
3029

3130
/** @cond */
32-
_Static_assert(CONFIG_ESP_LCD_TOUCH_MAX_BUTTONS > 0, "Touch buttons must be supported for this BSP");
31+
// _Static_assert(CONFIG_ESP_LCD_TOUCH_MAX_BUTTONS > 0, "Touch buttons must be supported for this BSP");
3332
/** @endcond */
3433

3534
static const ili9341_lcd_init_cmd_t vendor_specific_init[] = {
@@ -55,33 +54,32 @@ static const ili9341_lcd_init_cmd_t vendor_specific_init[] = {
5554
static esp_lcd_touch_handle_t tp; // LCD touch handle
5655
static esp_lcd_panel_handle_t panel_handle = NULL;
5756

58-
sdmmc_card_t *bsp_sdcard = NULL; // Global SD card handler
5957
static bool i2c_initialized = false;
6058

61-
// This is just a wrapper to get function signature for espressif/button API callback
62-
static uint8_t bsp_get_main_button(void *param);
63-
static esp_err_t bsp_init_main_button(void *param);
64-
65-
static const button_config_t bsp_button_config[BSP_BUTTON_NUM] = {
66-
{
67-
.type = BUTTON_TYPE_GPIO,
68-
.gpio_button_config.gpio_num = BSP_BUTTON_CONFIG_IO,
69-
.gpio_button_config.active_level = 0,
70-
},
71-
{
72-
.type = BUTTON_TYPE_GPIO,
73-
.gpio_button_config.gpio_num = BSP_BUTTON_MUTE_IO,
74-
.gpio_button_config.active_level = 0,
75-
},
76-
{
77-
.type = BUTTON_TYPE_CUSTOM,
78-
.custom_button_config.button_custom_init = bsp_init_main_button,
79-
.custom_button_config.button_custom_get_key_value = bsp_get_main_button,
80-
.custom_button_config.button_custom_deinit = NULL,
81-
.custom_button_config.active_level = 1,
82-
.custom_button_config.priv = (void *) BSP_BUTTON_MAIN,
83-
}
84-
};
59+
// // This is just a wrapper to get function signature for espressif/button API callback
60+
// static uint8_t bsp_get_main_button(void *param);
61+
// static esp_err_t bsp_init_main_button(void *param);
62+
63+
// static const button_config_t bsp_button_config[BSP_BUTTON_NUM] = {
64+
// {
65+
// .type = BUTTON_TYPE_GPIO,
66+
// .gpio_button_config.gpio_num = BSP_BUTTON_CONFIG_IO,
67+
// .gpio_button_config.active_level = 0,
68+
// },
69+
// {
70+
// .type = BUTTON_TYPE_GPIO,
71+
// .gpio_button_config.gpio_num = BSP_BUTTON_MUTE_IO,
72+
// .gpio_button_config.active_level = 0,
73+
// },
74+
// {
75+
// .type = BUTTON_TYPE_CUSTOM,
76+
// .custom_button_config.button_custom_init = bsp_init_main_button,
77+
// .custom_button_config.button_custom_get_key_value = bsp_get_main_button,
78+
// .custom_button_config.button_custom_deinit = NULL,
79+
// .custom_button_config.active_level = 1,
80+
// .custom_button_config.priv = (void *) BSP_BUTTON_MAIN,
81+
// }
82+
// };
8583

8684
esp_err_t bsp_i2c_init(void)
8785
{
@@ -160,45 +158,6 @@ esp_err_t bsp_spiffs_unmount(void)
160158
return esp_vfs_spiffs_unregister(CONFIG_BSP_SPIFFS_PARTITION_LABEL);
161159
}
162160

163-
esp_err_t bsp_sdcard_mount(void)
164-
{
165-
gpio_config_t power_gpio_config = {
166-
.mode = GPIO_MODE_OUTPUT,
167-
.pin_bit_mask = 1ULL << BSP_SD_POWER
168-
};
169-
ESP_ERROR_CHECK(gpio_config(&power_gpio_config));
170-
171-
/* SD card power on first */
172-
ESP_ERROR_CHECK(gpio_set_level(BSP_SD_POWER, 0));
173-
174-
const esp_vfs_fat_sdmmc_mount_config_t mount_config = {
175-
#ifdef CONFIG_BSP_SD_FORMAT_ON_MOUNT_FAIL
176-
.format_if_mount_failed = true,
177-
#else
178-
.format_if_mount_failed = false,
179-
#endif
180-
.max_files = 5,
181-
.allocation_unit_size = 16 * 1024
182-
};
183-
184-
sdmmc_host_t host = SDMMC_HOST_DEFAULT();
185-
sdmmc_slot_config_t slot_config = SDMMC_SLOT_CONFIG_DEFAULT();
186-
slot_config.width = 4;
187-
slot_config.cmd = BSP_SD_CMD;
188-
slot_config.clk = BSP_SD_CLK;
189-
slot_config.d0 = BSP_SD_D0;
190-
slot_config.d1 = BSP_SD_D1;
191-
slot_config.d2 = BSP_SD_D2;
192-
slot_config.d3 = BSP_SD_D3;
193-
194-
return esp_vfs_fat_sdmmc_mount(BSP_SD_MOUNT_POINT, &host, &slot_config, &mount_config, &bsp_sdcard);
195-
}
196-
197-
esp_err_t bsp_sdcard_unmount(void)
198-
{
199-
return esp_vfs_fat_sdcard_unmount(BSP_SD_MOUNT_POINT, bsp_sdcard);
200-
}
201-
202161
esp_codec_dev_handle_t bsp_audio_codec_speaker_init(void)
203162
{
204163
const audio_codec_data_if_t *i2s_data_if = bsp_audio_get_codec_itf();
@@ -495,47 +454,47 @@ esp_err_t bsp_touch_new(const bsp_touch_config_t *config, esp_lcd_touch_handle_t
495454
return ESP_OK;
496455
}
497456

498-
static uint8_t bsp_get_main_button(void *param)
499-
{
500-
assert(tp);
501-
#if (CONFIG_ESP_LCD_TOUCH_MAX_BUTTONS > 0)
502-
uint8_t home_btn_val = 0x00;
503-
esp_lcd_touch_get_button_state(tp, 0, &home_btn_val);
504-
return home_btn_val ? true : false;
505-
#else
506-
ESP_LOGE(TAG, "Button main is inaccessible");
507-
return false;
508-
#endif
509-
}
510-
511-
static esp_err_t bsp_init_main_button(void *param)
512-
{
513-
if (tp == NULL) {
514-
BSP_ERROR_CHECK_RETURN_ERR(bsp_touch_new(NULL, &tp));
515-
}
516-
return ESP_OK;
517-
}
518-
519-
esp_err_t bsp_iot_button_create(button_handle_t btn_array[], int *btn_cnt, int btn_array_size)
520-
{
521-
esp_err_t ret = ESP_OK;
522-
if ((btn_array_size < BSP_BUTTON_NUM) ||
523-
(btn_array == NULL)) {
524-
return ESP_ERR_INVALID_ARG;
525-
}
526-
527-
if (btn_cnt) {
528-
*btn_cnt = 0;
529-
}
530-
for (int i = 0; i < BSP_BUTTON_NUM; i++) {
531-
btn_array[i] = iot_button_create(&bsp_button_config[i]);
532-
if (btn_array[i] == NULL) {
533-
ret = ESP_FAIL;
534-
break;
535-
}
536-
if (btn_cnt) {
537-
(*btn_cnt)++;
538-
}
539-
}
540-
return ret;
541-
}
457+
// static uint8_t bsp_get_main_button(void *param)
458+
// {
459+
// assert(tp);
460+
// #if (CONFIG_ESP_LCD_TOUCH_MAX_BUTTONS > 0)
461+
// uint8_t home_btn_val = 0x00;
462+
// esp_lcd_touch_get_button_state(tp, 0, &home_btn_val);
463+
// return home_btn_val ? true : false;
464+
// #else
465+
// ESP_LOGE(TAG, "Button main is inaccessible");
466+
// return false;
467+
// #endif
468+
// }
469+
470+
// static esp_err_t bsp_init_main_button(void *param)
471+
// {
472+
// if (tp == NULL) {
473+
// BSP_ERROR_CHECK_RETURN_ERR(bsp_touch_new(NULL, &tp));
474+
// }
475+
// return ESP_OK;
476+
// }
477+
478+
// esp_err_t bsp_iot_button_create(button_handle_t btn_array[], int *btn_cnt, int btn_array_size)
479+
// {
480+
// esp_err_t ret = ESP_OK;
481+
// if ((btn_array_size < BSP_BUTTON_NUM) ||
482+
// (btn_array == NULL)) {
483+
// return ESP_ERR_INVALID_ARG;
484+
// }
485+
486+
// if (btn_cnt) {
487+
// *btn_cnt = 0;
488+
// }
489+
// for (int i = 0; i < BSP_BUTTON_NUM; i++) {
490+
// btn_array[i] = iot_button_create(&bsp_button_config[i]);
491+
// if (btn_array[i] == NULL) {
492+
// ret = ESP_FAIL;
493+
// break;
494+
// }
495+
// if (btn_cnt) {
496+
// (*btn_cnt)++;
497+
// }
498+
// }
499+
// return ret;
500+
// }

ports/esp32/main_esp32s3_box3/esp-box-3/idf_component.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
dependencies:
2-
button:
3-
public: true
4-
version: '>=2.5'
2+
# button:
3+
# public: true
4+
# version: '>=2.5'
55
esp_codec_dev:
66
public: true
77
version: ^1,<1.2
88
esp_lcd_ili9341: ^1
9-
esp_lcd_touch_gt911: ^1
10-
esp_lcd_touch_tt21100: ^1
9+
esp_lcd_touch_gt911:
10+
version: ^1
11+
public: true
12+
esp_lcd_touch_tt21100:
13+
version: ^1
14+
public: true
1115
icm42670:
1216
public: true
1317
version: ^1

ports/esp32/main_esp32s3_box3/esp-box-3/include/bsp/esp-box-3.h

Lines changed: 14 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@
1414
#include "sdkconfig.h"
1515
#include "driver/gpio.h"
1616
#include "driver/i2c.h"
17-
#include "driver/sdmmc_host.h"
1817
#include "soc/usb_pins.h"
1918
#include "esp_codec_dev.h"
20-
#include "iot_button.h"
19+
// #include "iot_button.h"
2120
#include "bsp/display.h"
2221

2322
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0)
@@ -31,11 +30,11 @@
3130

3231
#define BSP_CAPS_DISPLAY 1
3332
#define BSP_CAPS_TOUCH 1
34-
#define BSP_CAPS_BUTTONS 1
33+
#define BSP_CAPS_BUTTONS 0
3534
#define BSP_CAPS_AUDIO 1
3635
#define BSP_CAPS_AUDIO_SPEAKER 1
3736
#define BSP_CAPS_AUDIO_MIC 1
38-
#define BSP_CAPS_SDCARD 1
37+
#define BSP_CAPS_SDCARD 0
3938
#define BSP_CAPS_IMU 1
4039

4140
/**************************************************************************************************
@@ -68,19 +67,9 @@
6867
#define BSP_USB_POS USBPHY_DP_NUM
6968
#define BSP_USB_NEG USBPHY_DM_NUM
7069

71-
/* Buttons */
72-
#define BSP_BUTTON_CONFIG_IO (GPIO_NUM_0)
73-
#define BSP_BUTTON_MUTE_IO (GPIO_NUM_1)
74-
75-
/* SD card */
76-
#define BSP_SD_D0 (GPIO_NUM_9)
77-
#define BSP_SD_D1 (GPIO_NUM_13)
78-
#define BSP_SD_D2 (GPIO_NUM_42)
79-
#define BSP_SD_D3 (GPIO_NUM_12)
80-
#define BSP_SD_CMD (GPIO_NUM_14)
81-
#define BSP_SD_CLK (GPIO_NUM_11)
82-
#define BSP_SD_DET (GPIO_NUM_NC)
83-
#define BSP_SD_POWER (GPIO_NUM_43)
70+
// /* Buttons */
71+
// #define BSP_BUTTON_CONFIG_IO (GPIO_NUM_0)
72+
// #define BSP_BUTTON_MUTE_IO (GPIO_NUM_1)
8473

8574
/* PMOD */
8675
/*
@@ -119,13 +108,13 @@
119108
#define BSP_PMOD2_IO7 GPIO_NUM_11 // Intended for SPI2 D (MOSI)
120109
#define BSP_PMOD2_IO8 GPIO_NUM_43 // UART0 TX by defaultf
121110

122-
/* Buttons */
123-
typedef enum {
124-
BSP_BUTTON_CONFIG = 0,
125-
BSP_BUTTON_MUTE,
126-
BSP_BUTTON_MAIN,
127-
BSP_BUTTON_NUM
128-
} bsp_button_t;
111+
// /* Buttons */
112+
// typedef enum {
113+
// BSP_BUTTON_CONFIG = 0,
114+
// BSP_BUTTON_MUTE,
115+
// BSP_BUTTON_MAIN,
116+
// BSP_BUTTON_NUM
117+
// } bsp_button_t;
129118

130119
#ifdef __cplusplus
131120
extern "C" {
@@ -270,47 +259,6 @@ esp_err_t bsp_spiffs_mount(void);
270259
*/
271260
esp_err_t bsp_spiffs_unmount(void);
272261

273-
/**************************************************************************************************
274-
*
275-
* SD card
276-
*
277-
* After mounting the SD card, it can be accessed with stdio functions ie.:
278-
* \code{.c}
279-
* FILE* f = fopen(BSP_SD_MOUNT_POINT"/hello.txt", "w");
280-
* fprintf(f, "Hello %s!\n", bsp_sdcard->cid.name);
281-
* fclose(f);
282-
* \endcode
283-
*
284-
* @attention IO2 is also routed to RGB LED and push button
285-
**************************************************************************************************/
286-
#define BSP_SD_MOUNT_POINT CONFIG_BSP_SD_MOUNT_POINT
287-
extern sdmmc_card_t *bsp_sdcard;
288-
289-
/**
290-
* @brief Mount microSD card to virtual file system
291-
*
292-
* @return
293-
* - ESP_OK on success
294-
* - ESP_ERR_INVALID_STATE if esp_vfs_fat_sdmmc_mount was already called
295-
* - ESP_ERR_NO_MEM if memory can not be allocated
296-
* - ESP_FAIL if partition can not be mounted
297-
* - other error codes from SDMMC or SPI drivers, SDMMC protocol, or FATFS drivers
298-
*/
299-
esp_err_t bsp_sdcard_mount(void);
300-
301-
/**
302-
* @brief Unmount micorSD card from virtual file system
303-
*
304-
* @return
305-
* - ESP_OK on success
306-
* - ESP_ERR_NOT_FOUND if the partition table does not contain FATFS partition with given label
307-
* - ESP_ERR_INVALID_STATE if esp_vfs_fat_spiflash_mount was already called
308-
* - ESP_ERR_NO_MEM if memory can not be allocated
309-
* - ESP_FAIL if partition can not be mounted
310-
* - other error codes from wear levelling library, SPI flash driver, or FATFS drivers
311-
*/
312-
esp_err_t bsp_sdcard_unmount(void);
313-
314262
/**************************************************************************************************
315263
*
316264
* LCD interface
@@ -353,7 +301,7 @@ esp_err_t bsp_sdcard_unmount(void);
353301
* - ESP_ERR_INVALID_ARG btn_array is too small or NULL
354302
* - ESP_FAIL Underlaying iot_button_create failed
355303
*/
356-
esp_err_t bsp_iot_button_create(button_handle_t btn_array[], int *btn_cnt, int btn_array_size);
304+
// esp_err_t bsp_iot_button_create(button_handle_t btn_array[], int *btn_cnt, int btn_array_size);
357305

358306
#ifdef __cplusplus
359307
}

0 commit comments

Comments
 (0)