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 138fc4c

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

File tree

3 files changed

+83
-7
lines changed

3 files changed

+83
-7
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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 DATA_READY_PIN 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, digitalPinToBspPin(DATA_READY_PIN), (uint32_t) (IOPORT_CFG_IRQ_ENABLE | IOPORT_CFG_PORT_DIRECTION_INPUT | IOPORT_CFG_PULLUP_ENABLE));
34+
R_IOPORT_PinCfg(NULL, ESP_RESET, IOPORT_CFG_PORT_DIRECTION_OUTPUT);
35+
R_IOPORT_PinWrite(NULL, ESP_RESET, BSP_IO_LEVEL_HIGH);
36+
R_IOPORT_PinWrite(NULL, ESP_RESET, BSP_IO_LEVEL_LOW);
37+
R_IOPORT_PinWrite(NULL, ESP_RESET, BSP_IO_LEVEL_HIGH);
38+
isInitialized = true;
39+
}
40+
}
41+

‎libraries/ESPhost/src/EspChipManager.h

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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+
private:
35+
CEspChipManager() = default;
36+
~CEspChipManager() = default;
37+
bool isInitialized = false;
38+
};
39+
#endif // ESP_CHIP_MANAGER_H

‎libraries/ESPhost/src/EspSpiDriver.cpp

Lines changed: 3 additions & 7 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
@@ -157,15 +157,11 @@ int esp_host_spi_init(void) {
157157
}
158158

159159
/* ++++++++++++++++++++++++++++++++++
160-
* GPIOs (HANDSHAKE and DATA_READY)
160+
* GPIOs (HANDSHAKE and CS)
161161
* ++++++++++++++++++++++++++++++++++ */
162162
R_IOPORT_PinCfg(NULL, HANDSHAKE, IOPORT_CFG_PORT_DIRECTION_INPUT);
163-
/* DATA READY is configure in attach interrupt function below */
164163
//#ifdef EXPLICIT_PIN_CONFIGURATION
165-
R_IOPORT_PinCfg(NULL, DATA_READY, (uint32_t) (IOPORT_CFG_IRQ_ENABLE | IOPORT_CFG_PORT_DIRECTION_INPUT ));
166-
167164
R_IOPORT_PinCfg(NULL, ESP_CS, IOPORT_CFG_PORT_DIRECTION_OUTPUT);
168-
R_IOPORT_PinCfg(NULL, ESP_RESET, IOPORT_CFG_PORT_DIRECTION_OUTPUT);
169165
//#endif
170166

171167
/* +++++
@@ -270,7 +266,7 @@ int esp_host_spi_init(void) {
270266
return ESP_HOSTED_SPI_DRIVER_SPI_FAIL_OPEN;
271267
}
272268

273-
R_IOPORT_PinWrite(NULL, ESP_RESET, BSP_IO_LEVEL_HIGH);
269+
CEspChipManager::getInstance().initialize();
274270
spi_driver_initialized = true;
275271
return ESP_HOSTED_SPI_DRIVER_OK;
276272
}

0 commit comments

Comments
(0)

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