Skip to content

Commit

Permalink
Merge pull request #1 from fpistm/pr/573
Browse files Browse the repository at this point in the history
Clean up
  • Loading branch information
darkspr1te committed Aug 24, 2019
2 parents d700d4c + 66b821b commit ec9ab0e
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 97 deletions.
6 changes: 0 additions & 6 deletions boards.txt
Expand Up @@ -1108,7 +1108,6 @@ RAK.menu.upload_method.dfuMethod.upload.tool=stm32CubeProg

Genericflight.name=Generic flight controllers


Genericflight.build.vid=0x0483
Genericflight.build.core=arduino
Genericflight.build.board=Genericflight
Expand All @@ -1117,8 +1116,6 @@ Genericflight.build.series=STM32F1xx
Genericflight.build.cmsis_lib_gcc=arm_cortexM3l_math
Genericflight.build.extra_flags=-D{build.product_line} {build.enable_usb} {build.xSerial} {build.bootloader_flags}



# AfroFlight Rev5
Genericflight.menu.pnum.AFROFLIGHT_F103CB=Afro Flight Rev5
Genericflight.menu.pnum.AFROFLIGHT_F103CB.upload.maximum_size=131072
Expand All @@ -1128,10 +1125,7 @@ Genericflight.menu.pnum.AFROFLIGHT_F103CB.build.series=STM32F1xx
Genericflight.menu.pnum.AFROFLIGHT_F103CB.build.product_line=STM32F103xB
Genericflight.menu.pnum.AFROFLIGHT_F103CB.build.variant=AFROFLIGHT_F103CB



# Upload menu

Genericflight.menu.upload_method.swdMethod=STM32CubeProgrammer (SWD)
Genericflight.menu.upload_method.swdMethod.upload.protocol=0
Genericflight.menu.upload_method.swdMethod.upload.options=-g
Expand Down
20 changes: 0 additions & 20 deletions variants/AFROFLIGHT_F103CB/PeripheralPins.c
Expand Up @@ -73,9 +73,7 @@ WEAK const PinMap PinMap_ADC[] = {
WEAK const PinMap PinMap_I2C_SDA[] = {
{PB_7, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, AFIO_NONE)},
{PB_9, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, AFIO_I2C1_ENABLE)},
#ifndef ARDUINO_BLUEPILL_F103C6
{PB_11, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, AFIO_NONE)},
#endif
{NC, NP, 0}
};
#endif
Expand All @@ -84,9 +82,7 @@ WEAK const PinMap PinMap_I2C_SDA[] = {
WEAK const PinMap PinMap_I2C_SCL[] = {
{PB_6, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, AFIO_NONE)},
{PB_8, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, AFIO_I2C1_ENABLE)},
#ifndef ARDUINO_BLUEPILL_F103C6
{PB_10, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, AFIO_NONE)},
#endif
{NC, NP, 0}
};
#endif
Expand Down Expand Up @@ -126,7 +122,6 @@ WEAK const PinMap PinMap_PWM[] = {
{PB_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM2_ENABLE, 2, 0)}, // TIM2_CH2
{PB_4, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM3_PARTIAL, 1, 0)}, // TIM3_CH1
{PB_5, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM3_PARTIAL, 2, 0)}, // TIM3_CH2
#ifndef ARDUINO_BLUEPILL_F103C6
{PB_6, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM4_CH1
{PB_7, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 2, 0)}, // TIM4_CH2
{PB_8, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 3, 0)}, // TIM4_CH3
Expand All @@ -150,7 +145,6 @@ WEAK const PinMap PinMap_UART_TX[] = {
{PA_9, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)},
{PB_6, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_USART1_ENABLE)},
{PB_10, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)},
#endif
{NC, NP, 0}
};
#endif
Expand All @@ -160,9 +154,7 @@ WEAK const PinMap PinMap_UART_RX[] = {
{PA_3, USART2, STM_PIN_DATA(STM_MODE_INPUT, GPIO_PULLUP, AFIO_NONE)},
{PA_10, USART1, STM_PIN_DATA(STM_MODE_INPUT, GPIO_PULLUP, AFIO_NONE)},
{PB_7, USART1, STM_PIN_DATA(STM_MODE_INPUT, GPIO_PULLUP, AFIO_USART1_ENABLE)},
#ifndef ARDUINO_BLUEPILL_F103C6
{PB_11, USART3, STM_PIN_DATA(STM_MODE_INPUT, GPIO_PULLUP, AFIO_NONE)},
#endif
{NC, NP, 0}
};
#endif
Expand All @@ -171,10 +163,8 @@ WEAK const PinMap PinMap_UART_RX[] = {
WEAK const PinMap PinMap_UART_RTS[] = {
{PA_1, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)},
{PA_12, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)},
#ifndef ARDUINO_BLUEPILL_F103C6
{PB_14, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)},
// {PB_14, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_USART3_PARTIAL)},
#endif
{NC, NP, 0}
};
#endif
Expand All @@ -183,10 +173,8 @@ WEAK const PinMap PinMap_UART_RTS[] = {
WEAK const PinMap PinMap_UART_CTS[] = {
{PA_0, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)},
{PA_11, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)},
#ifndef ARDUINO_BLUEPILL_F103C6
{PB_13, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)},
// {PB_13, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_USART3_PARTIAL)},
#endif
{NC, NP, 0}
};
#endif
Expand All @@ -197,9 +185,7 @@ WEAK const PinMap PinMap_UART_CTS[] = {
WEAK const PinMap PinMap_SPI_MOSI[] = {
{PA_7, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)},
{PB_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_SPI1_ENABLE)},
#ifndef ARDUINO_BLUEPILL_F103C6
{PB_15, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)},
#endif
{NC, NP, 0}
};
#endif
Expand All @@ -208,9 +194,7 @@ WEAK const PinMap PinMap_SPI_MOSI[] = {
WEAK const PinMap PinMap_SPI_MISO[] = {
{PA_6, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)},
{PB_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_SPI1_ENABLE)},
#ifndef ARDUINO_BLUEPILL_F103C6
{PB_14, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)},
#endif
{NC, NP, 0}
};
#endif
Expand All @@ -219,9 +203,7 @@ WEAK const PinMap PinMap_SPI_MISO[] = {
WEAK const PinMap PinMap_SPI_SCLK[] = {
{PA_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)},
{PB_3, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_SPI1_ENABLE)},
#ifndef ARDUINO_BLUEPILL_F103C6
{PB_13, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)},
#endif
{NC, NP, 0}
};
#endif
Expand All @@ -230,9 +212,7 @@ WEAK const PinMap PinMap_SPI_SCLK[] = {
WEAK const PinMap PinMap_SPI_SSEL[] = {
{PA_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)},
{PA_15, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_SPI1_ENABLE)},
#ifndef ARDUINO_BLUEPILL_F103C6
{PB_12, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)},
#endif
{NC, NP, 0}
};
#endif
Expand Down
25 changes: 5 additions & 20 deletions variants/AFROFLIGHT_F103CB/variant.cpp
Expand Up @@ -35,8 +35,6 @@ extern "C" {

// Pin number
const PinName digitalPin[] = {
/* USB connector on the top, MCU side */
/* Left Side */
PB_9, //D0
PB_8, //D1
PB_7, //D2
Expand All @@ -45,17 +43,16 @@ const PinName digitalPin[] = {
PB_4, //D5
PB_3, //D6
PA_15, //D7
PA_12, //D8 - USB DP
PA_11, //D9 - USB DM
PA_12, //D8
PA_11, //D9
PA_10, //D10
PA_9, //D11
PA_8, //D12
PB_15, //D13
PB_14, //D14
PB_13, //D15
PB_12, //D16 - LED Blackpill
/* Right side */
PC_13, //D17 - LED Bluepill
PB_12, //D16
PC_13, //D17
PC_14, //D18
PC_15, //D19
PA_0, //D20/A0
Expand Down Expand Up @@ -87,24 +84,12 @@ extern "C" {

/**
* @brief System Clock Configuration
* The system Clock is configured as follow :
* System Clock source = PLL (HSE)
* SYSCLK(Hz) = 72000000
* HCLK(Hz) = 72000000
* AHB Prescaler = 1
* APB1 Prescaler = 2
* APB2 Prescaler = 1
* PLL_Source = HSE
* PLL_Mul = 9
* Flash Latency(WS) = 2
* ADC Prescaler = 6
* USB Prescaler = 1.5
* @param None
* @retval None
*/
WEAK void SystemClock_Config(void)
{
//Board has 12mhz xtal, iám currenlty using HSI internal xtal , i've not figured settings for external 12mhz
// Board has external 12MHz Xtal, currenlty using HSI internal Xtal
RCC_OscInitTypeDef RCC_OscInitStruct;
RCC_ClkInitTypeDef RCC_ClkInitStruct;
RCC_PeriphCLKInitTypeDef PeriphClkInit;
Expand Down
89 changes: 38 additions & 51 deletions variants/AFROFLIGHT_F103CB/variant.h
Expand Up @@ -38,27 +38,24 @@ extern "C" {
* Pins
*----------------------------------------------------------------------------*/

// Bluepill USB connector on the top, MCU side - Blackpill USB connector on bottom, MCU Side (pins are reversed vertically for Arduino Ananlog pin correct sequence.
// Left Side
#define PB9 0
#define PB8 1
#define PB7 2
#define PB6 3
#define PB5 4
#define PB4 5
#define PB3 6
#define PB4 5 // LED0
#define PB3 6 // LED1
#define PA15 7
#define PA12 8 // USB DP
#define PA11 9 // USB DM
#define PA12 8
#define PA11 9
#define PA10 10
#define PA9 11
#define PA8 12
#define PB15 13
#define PB14 14
#define PB13 15
#define PB12 16 // LED Blackpill
// Right side
#define PC13 17 // LED Bluepill
#define PB12 16
#define PC13 17
#define PC14 18
#define PC15 19
#define PA0 20 // A0
Expand All @@ -85,14 +82,10 @@ extern "C" {
#define NUM_ANALOG_FIRST 20

// On-board LED pin number
#ifdef ARDUINO_BLUEPILL_F103C8
#define LED_BUILTIN PC13
#else
#define LED_BUILTIN PB4
#endif
#define LED_GREEN PB3
#define LED_RED LED_BUILTIN
#define LED0 PB4
#define LED1 PB3

#define LED_BUILTIN LED0

// SPI Definitions
#define PIN_SPI_SS PA4
Expand All @@ -101,19 +94,13 @@ extern "C" {
#define PIN_SPI_SCK PA5

// I2C Definitions
//#define PIN_WIRE_SDA PB7
//#define PIN_WIRE_SCL PB6
//On afroflight Rev 5 it's on i2c port 2 that MPU6050 is connected too
#define PIN_WIRE_SDA PB11
#define PIN_WIRE_SCL PB10

#define PIN_WIRE_SDA PB11
#define PIN_WIRE_SCL PB10

// Timer Definitions
// Do not use timer used by PWM pins when possible. See PinMap_PWM.
#define TIMER_TONE TIM3

// Do not use basic timer: OC is required
#define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work
#define TIMER_SERVO TIM2

// UART Definitions
#define SERIAL_UART_INSTANCE 1
Expand All @@ -122,38 +109,38 @@ extern "C" {
#define PIN_SERIAL_RX PA10
#define PIN_SERIAL_TX PA9

#define MPU_I2C_SDA PB11;
#define MPU_I2C_SCL PB10;
#define MPU_ADDR 0x68;
#define MPU_INT PB13;
#define MPU_I2C_SDA PB11
#define MPU_I2C_SCL PB10
#define MPU_ADDR 0x68
#define MPU_INT PB13
/*
* RC_CH1 T2C1 PA0
* RC_CH2 T2C2 PA1
* RC_CH3 T2C3/UA2_TX PA2
* RC_CH4 T2C4/UA2_RX PA3
* RC_CH5 T3C1 PA6
* RC_CH6 T3C2 PA7
* RC_CH7 T3C3 PB0
* RC_CH8 T3C4 PB1
* RC_CH1 T2C1 PA0
* RC_CH2 T2C2 PA1
* RC_CH3 T2C3/UA2_TX PA2
* RC_CH4 T2C4/UA2_RX PA3
* RC_CH5 T3C1 PA6
* RC_CH6 T3C2 PA7
* RC_CH7 T3C3 PB0
* RC_CH8 T3C4 PB1
*
* PWM1 T1C1 PA8
* PMW2 T1C4 PA11
* PMW3 T4C1 PB6
* PMW4 T4C2 PB7
* PMW5 T4C3 PB8
* PMW6 T4C4 PB9
* SONAR_INT PA15
* GPIO_BOTTOM PB5
* TELEM_OUT PA13 // Warning, SWD access is lost when using this pin, bootloader via uart is required after
* PWM1 T1C1 PA8
* PMW2 T1C4 PA11
* PMW3 T4C1 PB6
* PMW4 T4C2 PB7
* PMW5 T4C3 PB8
* PMW6 T4C4 PB9
* SONAR_INT PA15
* GPIO_BOTTOM PB5
* TELEM_OUT PA13 // Warning, SWD access is lost when using this pin, bootloader via uart is required after
*
* BAT_ADC PA4 // Connected to 6 pin header Battery voltage in via resistor divider
* ACC_INT PA5 //Connected to Intterupt pin of MMA84520 accelerometer I2C
* BAT_ADC PA4 // Connected to 6 pin header Battery voltage in via resistor divider
* ACC_INT PA5 // Connected to Intterupt pin of MMA84520 accelerometer I2C
*
* MAG_DRD PB12; //Connected to HMC5883L compass I2C
* BEEP PA12; //Connected to Beep out transistor on 6 pin header
* MAG_DRD PB12 //Connected to HMC5883L compass I2C
* BEEP PA12 //Connected to Beep out transistor on 6 pin header
*
*/

#ifdef __cplusplus
} // extern "C"
#endif
Expand Down

0 comments on commit ec9ab0e

Please sign in to comment.