Skip to content

Commit

Permalink
Initial configuration for BlackPill F401CC version
Browse files Browse the repository at this point in the history
  • Loading branch information
pmantoine committed Jun 28, 2024
1 parent 4829dcc commit ec86387
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 2 deletions.
3 changes: 3 additions & 0 deletions EX-IOExpander.ino
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* © 2024, Paul M. Antoine
* © 2022, Peter Cole. All rights reserved.
* © 2023, Peter Cole. All rights reserved.
*
Expand Down Expand Up @@ -62,6 +63,8 @@
#include "arduino_arch_samd.h"
#elif defined(ARDUINO_BLUEPILL_F103C8)
#include "arduino_bluepill_f103c8.h"
#elif defined(ARDUINO_BLACKPILL_F401CC)
#include "arduino_blackpill_f401cc.h"
#endif

/*
Expand Down
52 changes: 52 additions & 0 deletions arduino_blackpill_f401cc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* © 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_F401CC_H
#define ARDUINO_BLACKPILL_F401CC_H

#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)
{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)
};

#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+)
Note that PC13 has a green LED - 0 to this pin to turn it on
*/

#endif
9 changes: 8 additions & 1 deletion defines.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* © 2024, Paul M. Antoine
* © 2023, Peter Cole. All rights reserved.
*
* This file is part of EX-IOExpander.
Expand Down Expand Up @@ -71,6 +72,11 @@
#define TOTAL_PINS 28
#define NUM_PWM_PINS 19
#define MAX_SUPERPINS 28
#elif defined(ARDUINO_BLACKPILL_F401CC)
#define BOARD_TYPE F("BLACKPILL-STM32F401CC")
#define TOTAL_PINS 28
#define NUM_PWM_PINS 19
#define MAX_SUPERPINS 28
#else
#define CPU_TYPE_ERROR
#endif
Expand All @@ -81,7 +87,8 @@

#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)
#if defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_BLACKPILL_F401CC)
#warning found usb serial
#undef USB_SERIAL
#define USB_SERIAL SerialUSB // Most SAMD21 clones use native USB on the SAMD21G18 variants
#endif
Expand Down
1 change: 1 addition & 0 deletions globals.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* © 2024, Paul M. Antoine
* © 2023, Peter Cole. All rights reserved.
*
* This file is part of EX-IOExpander.
Expand Down
18 changes: 18 additions & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,21 @@ build_flags =
-DUSB_PRODUCT="\"BLUEPILL_F103C8\""
monitor_speed = 115200
monitor_echo = yes

[env:blackpill_f401cc]
platform = ststm32
board = blackpill_f401cc
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_F401CC\""
monitor_speed = 115200
monitor_echo = yes
4 changes: 3 additions & 1 deletion version.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
#define VERSION_H

// Version must only ever be numeric in order to be able to send it to the CommandStation
#define VERSION "0.0.23"
#define VERSION "0.0.23a"

// 0.0.23a includes:
// - Add experimental definition for BlackPill F401CC devices
// 0.0.23 includes:
// - Add use of Servo library for controlling servos for supported platforms
// - Add SuperPin class for neat dimming of LEDs without needing hardware PWM pins
Expand Down

0 comments on commit ec86387

Please sign in to comment.