diff --git a/EX-IOExpander.ino b/EX-IOExpander.ino index ecd2169..cb84fd9 100644 --- a/EX-IOExpander.ino +++ b/EX-IOExpander.ino @@ -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 /* @@ -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: ")); diff --git a/arduino_blackpill_f401cc.h b/arduino_blackpill_f401cc.h index a9efd16..f196043 100644 --- a/arduino_blackpill_f401cc.h +++ b/arduino_blackpill_f401cc.h @@ -23,12 +23,11 @@ #include #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 @@ -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 \ No newline at end of file diff --git a/arduino_blackpill_f411ce.h b/arduino_blackpill_f411ce.h new file mode 100644 index 0000000..7471663 --- /dev/null +++ b/arduino_blackpill_f411ce.h @@ -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 . + */ + +#ifndef ARDUINO_BLACKPILL_F411CE_H +#define ARDUINO_BLACKPILL_F411CE_H + +#include +#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 \ No newline at end of file diff --git a/defines.h b/defines.h index cf5688c..6992c7e 100644 --- a/defines.h +++ b/defines.h @@ -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 @@ -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 diff --git a/platformio.ini b/platformio.ini index 2b0549c..a7e3ecf 100644 --- a/platformio.ini +++ b/platformio.ini @@ -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