|
| 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 | +#ifdef USE_ESP32_C3_DEVKIT_RUST_1 |
| 26 | +/* GPIOs */ |
| 27 | +#define HANDSHAKE BSP_IO_PORT_05_PIN_05 |
| 28 | +#define DATA_READY BSP_IO_PORT_08_PIN_02 |
| 29 | +#define DATA_READY_PIN 33 |
| 30 | + |
| 31 | +/* SPI PIN definition */ |
| 32 | +#define ESP_MISO BSP_IO_PORT_01_PIN_00 |
| 33 | +#define ESP_MOSI BSP_IO_PORT_01_PIN_01 |
| 34 | +#define ESP_CK BSP_IO_PORT_01_PIN_02 |
| 35 | +#define ESP_CS BSP_IO_PORT_01_PIN_03 |
| 36 | +#else |
| 37 | +/* GPIOs */ |
| 38 | +#define HANDSHAKE BSP_IO_PORT_08_PIN_06 |
| 39 | +#define DATA_READY BSP_IO_PORT_08_PIN_03 |
| 40 | +#define DATA_READY_PIN 100 |
| 41 | + |
| 42 | +/* SPI PIN definition */ |
| 43 | +#define ESP_MISO BSP_IO_PORT_01_PIN_00 |
| 44 | +#define ESP_MOSI BSP_IO_PORT_01_PIN_01 |
| 45 | +#define ESP_CK BSP_IO_PORT_01_PIN_02 |
| 46 | +#define ESP_CS BSP_IO_PORT_01_PIN_04 |
| 47 | +#endif |
| 48 | + |
| 49 | + |
| 50 | +class CEspChipManager { |
| 51 | + public: |
| 52 | + static CEspChipManager& getInstance(); |
| 53 | + |
| 54 | + // Delete copy constructor and assignment operator to enforce singleton |
| 55 | + CEspChipManager(const CEspChipManager&) = delete; |
| 56 | + CEspChipManager& operator=(const CEspChipManager&) = delete; |
| 57 | + // General initialization |
| 58 | + void initialize(); |
| 59 | + // Force a reset of the ESP chip, don't use for initialization |
| 60 | + void forceReset(); |
| 61 | + private: |
| 62 | + CEspChipManager() = default; |
| 63 | + ~CEspChipManager() = default; |
| 64 | + bool isInitialized = false; |
| 65 | +}; |
| 66 | +#endif // ESP_CHIP_MANAGER_H |
0 commit comments