Modification of Mbed-dev library for LQFP48 package microcontrollers: STM32F103C8 (STM32F103C8T6) and STM32F103CB (STM32F103CBT6) (Bluepill boards, Maple mini etc. )

Fork of mbed-dev by mbed official

Warning!

This library is unable to work due to huge changes in the mbed toolchain. Do not use with mbed online!

New wersion:

Import librarymbed-STM32F103C8

Modification of Mbed-dev library for LQFP48 package microcontrollers: STM32F103C8 (STM32F103C8T6) and STM32F103CB (STM32F103CBT6) (Bluepill boards, Maple mini etc. )




Library for STM32F103C8 (Bluepill boards etc.).
Use this instead of mbed library.
This library allows the size of the code in the FLASH up to 128kB. Therefore, code also runs on microcontrollers STM32F103CB (eg. Maple mini).
But in the case of STM32F103C8, check the size of the resulting code would not exceed 64kB.

To compile a program with this library, use NUCLEO-F103RB as the target name. !

Changes:

  • Corrected initialization of the HSE clock (mbed bug), allowing the use of on-board xtal (8MHz).(1)
  • Additionally, it also set USB clock (48Mhz).(2)
  • Definitions of pins and peripherals adjusted to LQFP48 case.
  • Board led LED1 is now PC_13 (3)
  • USER_BUTTON is now PC_14 (4)

notes
(1) - In case 8MHz xtal on board, CPU frequency is 72MHz. Without xtal is 64MHz.
(2) - Using the USB interface is only possible if STM32 is clocking by on-board 8MHz xtal or external clock signal 8MHz on the OSC_IN pin.
(3) - On Bluepill board led operation is reversed, i.e. 0 - led on, 1 - led off.
(4) - Bluepill board has no real user button

Files at this revision

API Documentation at this revision

Comitter:
mega64
Date:
Mon Aug 29 01:00:12 2016 +0000
Parent:
144:816d09523763
Commit message:
Change peripherals and pins definitions from LQFP64 to LQFP48 case.;

Changed in this revision

targets/cmsis/TARGET_STM/TARGET_STM32F1/TARGET_NUCLEO_F103RB/system_stm32f1xx.c Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_STM/TARGET_STM32F1/TARGET_NUCLEO_F103RB/PeripheralPins.c Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_STM/TARGET_STM32F1/TARGET_NUCLEO_F103RB/PinNames.h Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_STM/TARGET_STM32F1/analogin_api.c Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_STM/TARGET_STM32F1/pwmout_api.c Show annotated file Show diff for this revision Revisions of this file
--- a/targets/cmsis/TARGET_STM/TARGET_STM32F1/TARGET_NUCLEO_F103RB/system_stm32f1xx.c	Sun Aug 28 17:20:54 2016 +0000
+++ b/targets/cmsis/TARGET_STM/TARGET_STM32F1/TARGET_NUCLEO_F103RB/system_stm32f1xx.c	Mon Aug 29 01:00:12 2016 +0000
@@ -265,7 +265,8 @@
   
   RCC_PeriphCLKInitTypeDef PeriphClkInit;
 
-  
+  /* Configure USB clock (and ADC). 
+  USB clock is 48Mhz in case 8Mhz HSE source (xtal or external signal). */
   PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_ADC|RCC_PERIPHCLK_USB;
   PeriphClkInit.AdcClockSelection = RCC_ADCPCLK2_DIV6;
   PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_PLL_DIV1_5;
@@ -500,6 +501,7 @@
 #if USE_PLL_HSE_EXTC != 0
   if (SetSysClock_PLL_HSE(1) == 0)
   {
+    /* HSE must be off before second call HAL_RCC_OscConfig (HAL v1.4.4)  */
     __HAL_RCC_HSE_CONFIG(RCC_HSE_OFF);
 #endif
     
--- a/targets/hal/TARGET_STM/TARGET_STM32F1/TARGET_NUCLEO_F103RB/PeripheralPins.c	Sun Aug 28 17:20:54 2016 +0000
+++ b/targets/hal/TARGET_STM/TARGET_STM32F1/TARGET_NUCLEO_F103RB/PeripheralPins.c	Mon Aug 29 01:00:12 2016 +0000
@@ -49,12 +49,6 @@
     {PA_7, ADC_1, STM_PIN_DATA(STM_MODE_ANALOG, GPIO_NOPULL, 0)}, // ADC12_IN7
     {PB_0, ADC_1, STM_PIN_DATA(STM_MODE_ANALOG, GPIO_NOPULL, 0)}, // ADC12_IN8
     {PB_1, ADC_1, STM_PIN_DATA(STM_MODE_ANALOG, GPIO_NOPULL, 0)}, // ADC12_IN9
-    {PC_0, ADC_1, STM_PIN_DATA(STM_MODE_ANALOG, GPIO_NOPULL, 0)}, // ADC12_IN10
-    {PC_1, ADC_1, STM_PIN_DATA(STM_MODE_ANALOG, GPIO_NOPULL, 0)}, // ADC12_IN11
-    {PC_2, ADC_1, STM_PIN_DATA(STM_MODE_ANALOG, GPIO_NOPULL, 0)}, // ADC12_IN12
-    {PC_3, ADC_1, STM_PIN_DATA(STM_MODE_ANALOG, GPIO_NOPULL, 0)}, // ADC12_IN13
-    {PC_4, ADC_1, STM_PIN_DATA(STM_MODE_ANALOG, GPIO_NOPULL, 0)}, // ADC12_IN14
-    {PC_5, ADC_1, STM_PIN_DATA(STM_MODE_ANALOG, GPIO_NOPULL, 0)}, // ADC12_IN15
     {NC,   NC,    0}
 };
 
@@ -107,10 +101,6 @@
     {PB_14, PWM_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, 0)}, // TIM1_CH2N - Default
     {PB_15, PWM_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, 0)}, // TIM1_CH3N - Default
 
-    {PC_6,  PWM_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, 9)}, // TIM3_CH1 - GPIO_FullRemap_TIM3
-    {PC_7,  PWM_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, 9)}, // TIM3_CH2 - GPIO_FullRemap_TIM3
-    {PC_8,  PWM_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, 9)}, // TIM3_CH3 - GPIO_FullRemap_TIM3
-    {PC_9,  PWM_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, 9)}, // TIM3_CH4 - GPIO_FullRemap_TIM3
     {NC,    NC,    0}
 };
 
@@ -121,7 +111,6 @@
     {PA_9,  UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, 0)},
     {PB_6,  UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, 3)}, // GPIO_Remap_USART1
     {PB_10, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, 0)},
-    {PC_10, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, 5)}, // GPIO_PartialRemap_USART3
     {NC,    NC,     0}
 };
 
@@ -130,7 +119,6 @@
     {PA_10, UART_1, STM_PIN_DATA(STM_MODE_INPUT, GPIO_PULLUP, 0)},
     {PB_7,  UART_1, STM_PIN_DATA(STM_MODE_INPUT, GPIO_PULLUP, 3)}, // GPIO_Remap_USART1
     {PB_11, UART_3, STM_PIN_DATA(STM_MODE_INPUT, GPIO_PULLUP, 0)},
-    {PC_11, UART_3, STM_PIN_DATA(STM_MODE_INPUT, GPIO_PULLUP, 5)}, // GPIO_PartialRemap_USART3
     {NC,    NC,     0}
 };
 
--- a/targets/hal/TARGET_STM/TARGET_STM32F1/TARGET_NUCLEO_F103RB/PinNames.h	Sun Aug 28 17:20:54 2016 +0000
+++ b/targets/hal/TARGET_STM/TARGET_STM32F1/TARGET_NUCLEO_F103RB/PinNames.h	Mon Aug 29 01:00:12 2016 +0000
@@ -100,32 +100,18 @@
     PB_14 = 0x1E,
     PB_15 = 0x1F,
 
-    PC_0  = 0x20,
-    PC_1  = 0x21,
-    PC_2  = 0x22,
-    PC_3  = 0x23,
-    PC_4  = 0x24,
-    PC_5  = 0x25,
-    PC_6  = 0x26,
-    PC_7  = 0x27,
-    PC_8  = 0x28,
-    PC_9  = 0x29,
-    PC_10 = 0x2A,
-    PC_11 = 0x2B,
-    PC_12 = 0x2C,
     PC_13 = 0x2D,
     PC_14 = 0x2E,
     PC_15 = 0x2F,
 
-    PD_2  = 0x32,
+    PD_0  = 0x30,
+    PD_1  = 0x31,
 
     // Arduino connector namings
     A0          = PA_0,
     A1          = PA_1,
     A2          = PA_4,
     A3          = PB_0,
-    A4          = PC_1,
-    A5          = PC_0,
     D0          = PA_3,
     D1          = PA_2,
     D2          = PA_10,
@@ -135,7 +121,6 @@
     D6          = PB_10,
     D7          = PA_8,
     D8          = PA_9,
-    D9          = PC_7,
     D10         = PB_6,
     D11         = PA_7,
     D12         = PA_6,
@@ -144,11 +129,11 @@
     D15         = PB_8,
 
     // Generic signals namings
-    LED1        = PA_5,
-    LED2        = PA_5,
-    LED3        = PA_5,
-    LED4        = PA_5,
-    USER_BUTTON = PC_13,
+    LED1        = PC_13,
+    LED2        = PC_13,
+    LED3        = PC_13,
+    LED4        = PC_13,
+    USER_BUTTON = PC_14,
     SERIAL_TX   = PA_2,
     SERIAL_RX   = PA_3,
     USBTX       = PA_2,
--- a/targets/hal/TARGET_STM/TARGET_STM32F1/analogin_api.c	Sun Aug 28 17:20:54 2016 +0000
+++ b/targets/hal/TARGET_STM/TARGET_STM32F1/analogin_api.c	Mon Aug 29 01:00:12 2016 +0000
@@ -124,24 +124,6 @@
         case PB_1:
             sConfig.Channel = ADC_CHANNEL_9;
             break;
-        case PC_0:
-            sConfig.Channel = ADC_CHANNEL_10;
-            break;
-        case PC_1:
-            sConfig.Channel = ADC_CHANNEL_11;
-            break;
-        case PC_2:
-            sConfig.Channel = ADC_CHANNEL_12;
-            break;
-        case PC_3:
-            sConfig.Channel = ADC_CHANNEL_13;
-            break;
-        case PC_4:
-            sConfig.Channel = ADC_CHANNEL_14;
-            break;
-        case PC_5:
-            sConfig.Channel = ADC_CHANNEL_15;
-            break;
         default:
             return 0;
     }
--- a/targets/hal/TARGET_STM/TARGET_STM32F1/pwmout_api.c	Sun Aug 28 17:20:54 2016 +0000
+++ b/targets/hal/TARGET_STM/TARGET_STM32F1/pwmout_api.c	Mon Aug 29 01:00:12 2016 +0000
@@ -100,7 +100,6 @@
         case PA_8:
         case PA_15:
         case PB_4:
-        case PC_6:
             channel = TIM_CHANNEL_1;
             break;
 
@@ -116,7 +115,6 @@
         case PA_9:
         case PB_3:
         case PB_5:
-        case PC_7:
             channel = TIM_CHANNEL_2;
             break;
 
@@ -131,7 +129,6 @@
         case PA_10:
         case PB_0:
         case PB_10:
-        case PC_8:
             channel = TIM_CHANNEL_3;
             break;
 
@@ -146,7 +143,6 @@
         case PA_11:
         case PB_1:
         case PB_11:
-        case PC_9:
             channel = TIM_CHANNEL_4;
             break;