Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions boards/_boards_json/esp32-c5-devkitc1-n16r8.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"build": {
"arduino": {
"partitions": "default_16MB.csv",
"memory_type": "qio_qspi"
},
"core": "esp32",
"extra_flags": [
"-DBOARD_HAS_PSRAM"
],
"f_cpu": "240000000L",
"f_flash": "80000000L",
"flash_mode": "qio",
"psram_type": "qio",
"mcu": "esp32c5",
"variant": "esp32c5"
},
"connectivity": [
"bluetooth",
"wifi"
],
"debug": {
"openocd_target": "esp32c5.cfg"
},
"frameworks": [
"arduino",
"espidf"
],
"name": "Espressif ESP32-C5-DevKitC-1-N16R8V (16 MB Flash Quad, 8 MB PSRAM Octal)",
"upload": {
"flash_size": "16MB",
"maximum_ram_size": 327680,
"maximum_size": 16777216,
"require_upload_port": true,
"speed": 460800
},
"url": "https://docs.espressif.com/projects/esp-dev-kits/en/latest/esp32c5/esp32-c5-devkitc-1/user_guide.html",
"vendor": "Espressif"
}
2 changes: 2 additions & 0 deletions boards/pinouts/pins_arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,6 @@
#include "../ESP32-C5-tft/pins_arduino.h"
#elif ESP32C5_DEVKITC_1
#include "../ESP32-C5/pins_arduino.h"
#elif WAVESHARE_C5_TFT
#include "../waveshare-c5-tft/pins_arduino.h"
#endif
44 changes: 44 additions & 0 deletions boards/waveshare-c5-tft/connections.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Pinouts diagram to use Bruce

## USING CUSTOM BOARD, with SPI

## Waveshare ESP32-C5 n16r8
## TFT ST7789 172x320 RGB

| Device | SCK | MISO | MOSI | CS | GDO0/CE | GDO2 | TFT_DC | TFT_RES | TFT_BL |
| --- | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| Display | 10 | 9 | - | 23 | --- | --- | 24 | C5 RST | 25 |
| SD Card | 10 | 9 | 8 | 6 | --- | --- | --- | --- | --- |
| CC1101 | 10 | 9 | 8 | 3* | 2* | 7* | --- | --- | --- |
| NRF24 | 10 | 9 | 8 | 3* | 2* | --- | --- | --- | --- |
| W5500 | 10 | 9 | 8 | 3* | 2* | --- | --- | --- | --- |

(*) CC1101, NRF24, W5500 use the same pinouts, need to add a switch on CS and CE/GDO0 to choose which to use.

Pinouts for buttons
| Buttons | GPIO |
| --- | :---: |
| Prev/UP | 1 |
| Sel | 28 |
| Next/DW | 0 |
| Right | 13 |
| Left | 14 |



| Device | RX | TX | GPIO |
| --- | :---: | :---: | :---: |
| GPS | 4 | 5 | --- |
| IR RX | --- | --- | 26 |
| IR TX | --- | --- | 15 |
| LED | --- | --- | 27 |

ESP32-C5 doesn't support USB-OTG, for BadUSB you need to use a CH9329 module

FM Radio, PN532 on I2C, other I2C devices, CH9329, shared with GPS Serial interface.
I2C SDA: 4
I2C SCL: 5

Serial interface to other devices (Flipper)
Serial Tx: 11
Serial Rx: 12
126 changes: 126 additions & 0 deletions boards/waveshare-c5-tft/interface.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
#include "core/powerSave.h"
#include "core/utils.h"
#include <interface.h>

/***************************************************************************************
** Function name: _setup_gpio()
** Location: main.cpp
** Description: initial setup for the device
***************************************************************************************/
void _setup_gpio() {

pinMode(TFT_CS, OUTPUT);
digitalWrite(TFT_CS, HIGH);
pinMode(TFT_MOSI, OUTPUT);
digitalWrite(TFT_MOSI, HIGH);
pinMode(TFT_SCLK, OUTPUT);

pinMode(TFT_BL, OUTPUT);
digitalWrite(TFT_BL, HIGH);
pinMode(TFT_RST, OUTPUT);
pinMode(TFT_DC, OUTPUT);
digitalWrite(TFT_DC, HIGH);

#ifdef HAS_5_BUTTONS
pinMode(UP_BTN, INPUT_PULLUP); // Sets the power btn as an INPUT
pinMode(SEL_BTN, INPUT_PULLUP);
pinMode(DW_BTN, INPUT_PULLUP);
pinMode(R_BTN, INPUT_PULLUP);
pinMode(L_BTN, INPUT_PULLUP);
#endif

pinMode(NRF24_SS_PIN, OUTPUT);
pinMode(CC1101_SS_PIN, OUTPUT);
pinMode(SDCARD_CS, OUTPUT);
pinMode(W5500_SS_PIN, OUTPUT);
pinMode(TFT_CS, OUTPUT);

digitalWrite(NRF24_SS_PIN, HIGH);
digitalWrite(CC1101_SS_PIN, HIGH);
digitalWrite(SDCARD_CS, HIGH);
digitalWrite(W5500_SS_PIN, HIGH);
digitalWrite(TFT_CS, HIGH);
}
/***************************************************************************************
** Function name: _post_setup_gpio()
** Location: main.cpp
** Description: second stage gpio setup to make a few functions work
***************************************************************************************/
void _post_setup_gpio() {}

/***************************************************************************************
** Function name: getBattery()
** location: display.cpp
** Description: Delivers the battery value from 1-100
***************************************************************************************/
int getBattery() { return 0; }

/***************************************************************************************
** Function name: isCharging()
** Description: Default implementation that returns false
***************************************************************************************/
bool isCharging() { return false; }

/*********************************************************************
** Function: setBrightness
** location: settings.cpp
** set brightness value
**********************************************************************/
void _setBrightness(uint8_t brightval) {
if (brightval == 0) {
analogWrite(TFT_BL, brightval);
} else {
int bl = MINBRIGHT + round(((255 - MINBRIGHT) * brightval / 100));
analogWrite(TFT_BL, bl);
}
}

/*********************************************************************
** Function: InputHandler
** Handles the variables PrevPress, NextPress, SelPress, AnyKeyPress and EscPress
**********************************************************************/
void InputHandler(void) {
static unsigned long tm = 0;
if (millis() - tm < 200 && !LongPress) return;
bool _u = digitalRead(UP_BTN);
bool _d = digitalRead(DW_BTN);
bool _l = digitalRead(L_BTN);
bool _r = digitalRead(R_BTN);
bool _s = digitalRead(SEL_BTN);

if (!_s || !_u || !_d || !_r || !_l) {
tm = millis();
if (!wakeUpScreen()) AnyKeyPress = true;
else return;
}
if (!_l) { PrevPress = true; }
if (!_r) { NextPress = true; }
if (!_u) {
UpPress = true;
PrevPagePress = true;
}
if (!_d) {
DownPress = true;
NextPagePress = true;
}
if (!_s) { SelPress = true; }
if (!_l && !_r) {
EscPress = true;
NextPress = false;
PrevPress = false;
}
}

/*********************************************************************
** Function: powerOff
** location: mykeyboard.cpp
** Turns off the device (or try to)
**********************************************************************/
void powerOff() {}

/*********************************************************************
** Function: checkReboot
** location: mykeyboard.cpp
** Btn logic to turnoff the device (name is odd btw)
**********************************************************************/
void checkReboot() {}
151 changes: 151 additions & 0 deletions boards/waveshare-c5-tft/pins_arduino.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
#ifndef Pins_Arduino_h
#define Pins_Arduino_h

#include "soc/soc_caps.h"
#include <stdint.h>

#define PIN_RGB_LED 27
// BUILTIN_LED can be used in new Arduino API digitalWrite() like in Blink.ino
static const uint8_t LED_BUILTIN = SOC_GPIO_PIN_COUNT + PIN_RGB_LED;
#define BUILTIN_LED LED_BUILTIN // backward compatibility
#define LED_BUILTIN LED_BUILTIN // allow testing #ifdef LED_BUILTIN
// RGB_BUILTIN and RGB_BRIGHTNESS can be used in new Arduino API rgbLedWrite()
#define RGB_BUILTIN LED_BUILTIN
#define RGB_BRIGHTNESS 10

static const uint8_t TX = 11;
static const uint8_t RX = 12;

static const uint8_t USB_DM = 13;
static const uint8_t USB_DP = 14;

static const uint8_t SDA = 4;
static const uint8_t SCL = 5;

static const uint8_t SS = 6;
static const uint8_t MOSI = 8;
static const uint8_t MISO = 9;
static const uint8_t SCK = 10;

static const uint8_t A0 = 1;
static const uint8_t A1 = 2;
static const uint8_t A2 = 3;
static const uint8_t A3 = 4;
static const uint8_t A4 = 5;
static const uint8_t A5 = 6;

// LP I2C Pins are fixed on ESP32-C5
static const uint8_t LP_SDA = 4;
static const uint8_t LP_SCL = 5;
#define WIRE1_PIN_DEFINED
#define SDA1 LP_SDA
#define SCL1 LP_SCL

// LP UART Pins are fixed on ESP32-C5
static const uint8_t LP_RX = 12;
static const uint8_t LP_TX = 11;

#define HAS_RGB_LED 1
#define LED_ORDER GRB
#define LED_TYPE_IS_RGBW 1
#define LED_COUNT 1
#define LED_TYPE WS2812
#define LED_COLOR_STEP 15
#define RGB_LED 27

/* Communication Buses*/
// UART
#define SERIAL_TX 11
#define SERIAL_RX 12

// I2C
#define GROVE_SDA 4
#define GROVE_SCL 5

// SPI
#define SPI_SCK_PIN 10
#define SPI_MOSI_PIN 8
#define SPI_MISO_PIN 9
#define SPI_SS_PIN 3

/* TFT definitions */
#define HAS_SCREEN 1
#define ROTATION 1
#define MINBRIGHT (uint8_t)4
#define USER_SETUP_LOADED 1
/* --------------------- */
// Setup for ST7789 170x320

#define ST7789_DRIVER 1
#define TFT_RGB_ORDER 0
#define TFT_WIDTH 172
#define TFT_HEIGHT 320

/* --------------------- */
// Common TFT definitions
#define TFT_BACKLIGHT_ON 1
#define TFT_BL 25
#define TFT_RST -1
#define TFT_DC 24
#define TFT_MISO SPI_MISO_PIN // set to share SPI with other devices
#define TFT_MOSI SPI_MOSI_PIN
#define TFT_SCLK SPI_SCK_PIN
#define TFT_CS 23
#define SMOOTH_FONT 1
#define SPI_FREQUENCY 20000000
#define SPI_READ_FREQUENCY 20000000
#define SPI_TOUCH_FREQUENCY 2500000

/* Peripheral settings */
// Bad USB with CH9329
#define BAD_RX 4
#define BAD_TX 5

// GPS Bus
#define GPS_SERIAL_TX 5
#define GPS_SERIAL_RX 4

#define BTN_ALIAS "\"OK\""
#define HAS_5_BUTTONS
#define SEL_BTN 28
#define DW_BTN 1
#define UP_BTN 0
#define R_BTN 13
#define L_BTN 14
#define BTN_ACT LOW
#define DEEPSLEEP_WAKEUP_PIN SEL_BTN

// InfraRed
#define RXLED 26
#define TXLED 15
#define LED_ON HIGH
#define LED_OFF LOW

// SDCard
#define SDCARD_CS 6
#define SDCARD_SCK SPI_SCK_PIN
#define SDCARD_MISO SPI_MISO_PIN
#define SDCARD_MOSI SPI_MOSI_PIN

// CC1101
#define CC1101_GDO2_PIN 7
#define CC1101_GDO0_PIN 2
#define CC1101_SS_PIN 3
#define CC1101_MOSI_PIN SPI_MOSI_PIN
#define CC1101_SCK_PIN SPI_SCK_PIN
#define CC1101_MISO_PIN SPI_MISO_PIN

// NRF24
#define NRF24_CE_PIN 2
#define NRF24_SS_PIN 3
#define NRF24_MOSI_PIN SPI_MOSI_PIN
#define NRF24_SCK_PIN SPI_SCK_PIN
#define NRF24_MISO_PIN SPI_MISO_PIN

// Ethernet
#define W5500_INT_PIN 2
#define W5500_SS_PIN 3
#define W5500_MOSI_PIN SPI_MOSI_PIN
#define W5500_SCK_PIN SPI_SCK_PIN
#define W5500_MISO_PIN SPI_MISO_PIN
#endif /* Pins_Arduino_h */
Loading