Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 63b6f72

Browse files
committed
add esp32 chip manager on ESPHome for portenta C33
1 parent f032b82 commit 63b6f72

File tree

3 files changed

+90
-3
lines changed

3 files changed

+90
-3
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/* ########################################################################## */
2+
/* - File: EspChipManager.h
3+
- Copyright (c): 2025 Arduino srl.
4+
- Author: Fabio Massimo Centonze (f.centonze@arduino.cc)
5+
6+
This library is free software; you can redistribute it and/or
7+
modify it under the terms of the GNU Lesser General Public
8+
License as published by the Free Software Foundation; either
9+
version 2.1 of the License, or (at your option) any later version.
10+
11+
This library is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
Lesser General Public License for more details.
15+
16+
You should have received a copy of the GNU Lesser General Public
17+
License along with this library; if not, write to the Free Software
18+
Foundation, Inc.,51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
19+
/* ########################################################################## */
20+
21+
#include "EspChipManager.h"
22+
23+
#define ESP_RESET BSP_IO_PORT_08_PIN_04
24+
#define ESP_BLE_PIN_EN 100
25+
26+
CEspChipManager& CEspChipManager::getInstance() {
27+
static CEspChipManager instance;
28+
return instance;
29+
}
30+
31+
void CEspChipManager::initialize() {
32+
if (!isInitialized) {
33+
R_IOPORT_PinCfg(NULL, ESP_RESET, IOPORT_CFG_PORT_DIRECTION_OUTPUT);
34+
R_IOPORT_PinWrite(NULL, ESP_RESET, BSP_IO_LEVEL_HIGH);
35+
36+
isInitialized = true;
37+
}
38+
}
39+
40+
void CEspChipManager::initializeBLE() {
41+
if (!isBLEInitialized) {
42+
pinMode(ESP_BLE_PIN_EN, OUTPUT);
43+
digitalWrite(ESP_BLE_PIN_EN, HIGH);
44+
isBLEInitialized = true;
45+
}
46+
}

‎libraries/ESPhost/src/EspChipManager.h

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/* ########################################################################## */
2+
/* - File: EspChipManager.h
3+
- Copyright (c): 2025 Arduino srl.
4+
- Author: Fabio Massimo Centonze (f.centonze@arduino.cc)
5+
6+
This library is free software; you can redistribute it and/or
7+
modify it under the terms of the GNU Lesser General Public
8+
License as published by the Free Software Foundation; either
9+
version 2.1 of the License, or (at your option) any later version.
10+
11+
This library is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
Lesser General Public License for more details.
15+
16+
You should have received a copy of the GNU Lesser General Public
17+
License along with this library; if not, write to the Free Software
18+
Foundation, Inc.,51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
19+
/* ########################################################################## */
20+
21+
#ifndef ESP_CHIP_MANAGER_H
22+
#define ESP_CHIP_MANAGER_H
23+
#include <Arduino.h>
24+
25+
class CEspChipManager {
26+
public:
27+
static CEspChipManager& getInstance();
28+
29+
// Delete copy constructor and assignment operator to enforce singleton
30+
CEspChipManager(const CEspChipManager&) = delete;
31+
CEspChipManager& operator=(const CEspChipManager&) = delete;
32+
// General initialization
33+
void initialize();
34+
// Initialize the BLE
35+
void initializeBLE();
36+
private:
37+
CEspChipManager() = default;
38+
~CEspChipManager() = default;
39+
bool isInitialized = false;
40+
bool isBLEInitialized = false;
41+
};
42+
#endif // ESP_CHIP_MANAGER_H

‎libraries/ESPhost/src/EspSpiDriver.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
* ######## */
3030

3131
#include "EspSpiDriver.h"
32+
#include "EspChipManager.h"
3233

3334
/* #####################
3435
* Configuration defines
@@ -58,7 +59,6 @@
5859
#define ESP_CS BSP_IO_PORT_01_PIN_03
5960
#else
6061
/* GPIOs */
61-
#define ESP_RESET BSP_IO_PORT_08_PIN_04
6262
#define HANDSHAKE BSP_IO_PORT_08_PIN_06
6363
#define DATA_READY BSP_IO_PORT_08_PIN_03
6464
#define DATA_READY_PIN 100
@@ -165,7 +165,6 @@ int esp_host_spi_init(void) {
165165
R_IOPORT_PinCfg(NULL, DATA_READY, (uint32_t) (IOPORT_CFG_IRQ_ENABLE | IOPORT_CFG_PORT_DIRECTION_INPUT ));
166166

167167
R_IOPORT_PinCfg(NULL, ESP_CS, IOPORT_CFG_PORT_DIRECTION_OUTPUT);
168-
R_IOPORT_PinCfg(NULL, ESP_RESET, IOPORT_CFG_PORT_DIRECTION_OUTPUT);
169168
//#endif
170169

171170
/* +++++
@@ -270,7 +269,7 @@ int esp_host_spi_init(void) {
270269
return ESP_HOSTED_SPI_DRIVER_SPI_FAIL_OPEN;
271270
}
272271

273-
R_IOPORT_PinWrite(NULL, ESP_RESET, BSP_IO_LEVEL_HIGH);
272+
CEspChipManager::getInstance().initialize();
274273
spi_driver_initialized = true;
275274
return ESP_HOSTED_SPI_DRIVER_OK;
276275
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /