Skip to content

Commit

Permalink
Added BlackPill F411CE support
Browse files Browse the repository at this point in the history
  • Loading branch information
pmantoine committed Jun 29, 2024
1 parent ec86387 commit ba0d308
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 7 deletions.
4 changes: 3 additions & 1 deletion EX-IOExpander.ino
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@
#include "arduino_bluepill_f103c8.h"
#elif defined(ARDUINO_BLACKPILL_F401CC)
#include "arduino_blackpill_f401cc.h"
#elif defined(ARDUINO_BLACKPILL_F411CE)
#include "arduino_blackpill_f411ce.h"
#endif

/*
Expand Down Expand Up @@ -94,7 +96,7 @@ void setup() {
#if defined(ARDUINO_BLUEPILL_F103C8)
disableJTAG();
#endif
Serial.begin(115200);
USB_SERIAL.begin(115200);
USB_SERIAL.print(F("DCC-EX EX-IOExpander v"));
USB_SERIAL.println(VERSION);
USB_SERIAL.print(F("Detected device: "));
Expand Down
9 changes: 5 additions & 4 deletions arduino_blackpill_f401cc.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@

#include <Arduino.h>
#include "globals.h"

pinDefinition pinMap[TOTAL_PINS] = {
{PB12,DIO},{PB13,DIOP},{PB14,DIOP},{PB15,DIOP},{PA8,DIOP},{PA9,DIOP},{PA10,DIOP},{PA15,DIOP}, // P1 (left row)
{PB12,DIOP},{PB13,DIOP},{PB14,DIOP},{PB15,DIOP},{PA8,DIOP},{PA9,DIOP},{PA10,DIOP},{PA15,DIOP}, // P1 (left row)
{PB3,DIOP},{PB4,DIOP},{PB5,DIOP},{PB6,DIOP},{PB7,DIOP}, // P1 (left row)
{PB10,DIOP},{PB2,DIO},{PB1,AIDIOP},{PB0,AIDIOP},{PA7,AIDIOP},{PA6,AIDIOP},{PA5,DIOP}, // P2 (right row)
{PA4,AIDIOP},{PA3,AIDIO},{PA2,DIO},{PA1,AIDIOP},{PA0,AIDIOP},{PC15,DIO},{PC14,DIO},{PC13,DIO}, // P2 (right row)
{PA4,AIDIO},{PA3,AIDIO},{PA2,AIDIO},{PA1,AIDIOP},{PA0,AIDIOP},{PC15,DIO},{PC14,DIO},{PC13,DIO}, // P2 (right row)
};

#define I2C_SDA PB9
Expand All @@ -46,7 +45,9 @@ Pins not available for use:
Digital - PA13|14 (debugger),PH0|1 (clock), PC14|15 (used by 32KHz oscillator)
Digital - PB8|9 (I2C)
Digital - PA11/12 (USB D-/D+)
Note that PC13 has a green LED - 0 to this pin to turn it on
Notes:
PC13 has a green LED - 0 to this pin to turn it on
PA0 has a user button to GND on some variants
*/

#endif
54 changes: 54 additions & 0 deletions arduino_blackpill_f411ce.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* © 2024, Paul M. Antoine
* © 2023, Peter Cole. All rights reserved.
*
* This file is part of EX-IOExpander.
*
* This is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* It is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with CommandStation. If not, see <https://www.gnu.org/licenses/>.
*/

#ifndef ARDUINO_BLACKPILL_F411CE_H
#define ARDUINO_BLACKPILL_F411CE_H

#include <Arduino.h>
#include "globals.h"

pinDefinition pinMap[TOTAL_PINS] = {
{PB12,DIOP},{PB13,DIOP},{PB14,DIOP},{PB15,DIOP},{PA8,DIOP},{PA9,DIOP},{PA10,DIOP},{PA15,DIOP}, // P1 (left row)
{PB3,DIOP},{PB4,DIOP},{PB5,DIOP},{PB6,DIOP},{PB7,DIOP}, // P1 (left row)
{PB10,DIOP},{PB2,DIO},{PB1,AIDIOP},{PB0,AIDIOP},{PA7,AIDIOP},{PA6,AIDIOP},{PA5,DIOP}, // P2 (right row)
{PA4,AIDIO},{PA3,AIDIO},{PA2,AIDIO},{PA1,AIDIOP},{PA0,AIDIOP},{PC15,DIO},{PC14,DIO},{PC13,DIO}, // P2 (right row)
};

#define I2C_SDA PB9
#define I2C_SCL PB8

pinName pinNameMap[TOTAL_PINS] = {
{PB12,"PB12"},{PB13,"PB13"},{PB14,"PB14"},{PB15,"PB15"},{PA8,"PA8"},{PA9,"PA9"},{PA10,"PA10"},{PA15,"PA15"}, // P1 (left row)
{PB3,"PB3"},{PB4,"PB4"},{PB5,"PB5"},{PB6,"PB6"},{PB7,"PB7"}, // P1 (left row)
{PB10,"PB10"},{PB2,"PB2"},{PB1,"PB1"},{PB0,"PB0"},{PA7,"PA7"},{PA6,"PA6"},{PA5,"PA5"}, // P2 (right row)
{PA4,"PA4"},{PA3,"PA3"},{PA2,"PA2"},{PA1,"PA1"},{PA0,"PA0"},{PC15,"PC15"},{PC14,"PC14"},{PC13,"PC13"}, // P2 (right row)
};

/*
Pins not available for use:
Digital - PA13|14 (debugger),PH0|1 (clock), PC14|15 (used by 32KHz oscillator)
Digital - PB8|9 (I2C)
Digital - PA11/12 (USB D-/D+)
Notes:
PC13 has a green LED - 0 to this pin to turn it on
PA0 has a user button to GND on some variants
*/

#endif
9 changes: 7 additions & 2 deletions defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,12 @@
#elif defined(ARDUINO_BLACKPILL_F401CC)
#define BOARD_TYPE F("BLACKPILL-STM32F401CC")
#define TOTAL_PINS 28
#define NUM_PWM_PINS 19
#define NUM_PWM_PINS 21
#define MAX_SUPERPINS 28
#elif defined(ARDUINO_BLACKPILL_F411CE)
#define BOARD_TYPE F("BLACKPILL-STM32F411CE")
#define TOTAL_PINS 28
#define NUM_PWM_PINS 21
#define MAX_SUPERPINS 28
#else
#define CPU_TYPE_ERROR
Expand All @@ -87,7 +92,7 @@

#undef USB_SERIAL // Teensy has this defined by default (in case we ever support Teensy)
#define USB_SERIAL Serial // Standard serial port most of the time!
#if defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_BLACKPILL_F401CC)
#if defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_BLACKPILL_F401CC) || defined(ARDUINO_BLACKPILL_F411CE)
#warning found usb serial
#undef USB_SERIAL
#define USB_SERIAL SerialUSB // Most SAMD21 clones use native USB on the SAMD21G18 variants
Expand Down
18 changes: 18 additions & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,21 @@ build_flags =
-DUSB_PRODUCT="\"BLACKPILL_F401CC\""
monitor_speed = 115200
monitor_echo = yes

[env:blackpill_f411ce]
platform = ststm32
board = blackpill_f411ce
framework = arduino
upload_protocol = dfu
build_flags =
${env.build_flags}
-std=c++17 -Os -g2
-DPIO_FRAMEWORK_ARDUINO_ENABLE_CDC
-DUSBCON
-DHAL_PCD_MODULE_ENABLED
-DUSBD_VID=0x0483
-DUSBD_PID=0x5740
-DUSB_MANUFACTURER="Unknown"
-DUSB_PRODUCT="\"BLACKPILL_F411CE\""
monitor_speed = 115200
monitor_echo = yes

0 comments on commit ba0d308

Please sign in to comment.