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

Fork of mbed-STM32F103C8_org by Nothing Special

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 + crystal clock (mbed permanent 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)

    Now the library is complete rebuilt based on mbed-dev v160 (and not yet fully tested).

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

Information

After export to SW4STM (AC6):

  • add line #include "mbed_config.h" in files Serial.h and RawSerial.h
  • in project properties change Optimisation Level to Optimise for size (-Os)
Committer:
mega64
Date:
Thu Apr 27 23:56:38 2017 +0000
Revision:
148:8b0b02bf146f
Parent:
146:03e976389d16
Remove unnecessary folders

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mega64 146:03e976389d16 1
mega64 146:03e976389d16 2 /** \addtogroup platform */
mega64 146:03e976389d16 3 /** @{*/
mega64 146:03e976389d16 4 /* mbed Microcontroller Library
mega64 146:03e976389d16 5 * Copyright (c) 2006-2013 ARM Limited
mega64 146:03e976389d16 6 *
mega64 146:03e976389d16 7 * Licensed under the Apache License, Version 2.0 (the "License");
mega64 146:03e976389d16 8 * you may not use this file except in compliance with the License.
mega64 146:03e976389d16 9 * You may obtain a copy of the License at
mega64 146:03e976389d16 10 *
mega64 146:03e976389d16 11 * http://www.apache.org/licenses/LICENSE-2.0
mega64 146:03e976389d16 12 *
mega64 146:03e976389d16 13 * Unless required by applicable law or agreed to in writing, software
mega64 146:03e976389d16 14 * distributed under the License is distributed on an "AS IS" BASIS,
mega64 146:03e976389d16 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
mega64 146:03e976389d16 16 * See the License for the specific language governing permissions and
mega64 146:03e976389d16 17 * limitations under the License.
mega64 146:03e976389d16 18 */
mega64 146:03e976389d16 19 #ifndef MBED_ASSERT_H
mega64 146:03e976389d16 20 #define MBED_ASSERT_H
mega64 146:03e976389d16 21
mega64 146:03e976389d16 22 #include "mbed_preprocessor.h"
mega64 146:03e976389d16 23
mega64 146:03e976389d16 24 #ifdef __cplusplus
mega64 146:03e976389d16 25 extern "C" {
mega64 146:03e976389d16 26 #endif
mega64 146:03e976389d16 27
mega64 146:03e976389d16 28 /** Internal mbed assert function which is invoked when MBED_ASSERT macro failes.
mega64 146:03e976389d16 29 * This function is active only if NDEBUG is not defined prior to including this
mega64 146:03e976389d16 30 * assert header file.
mega64 146:03e976389d16 31 * In case of MBED_ASSERT failing condition, error() is called with the assertation message.
mega64 146:03e976389d16 32 * @param expr Expresion to be checked.
mega64 146:03e976389d16 33 * @param file File where assertation failed.
mega64 146:03e976389d16 34 * @param line Failing assertation line number.
mega64 146:03e976389d16 35 */
mega64 146:03e976389d16 36 void mbed_assert_internal(const char *expr, const char *file, int line);
mega64 146:03e976389d16 37
mega64 146:03e976389d16 38 #ifdef __cplusplus
mega64 146:03e976389d16 39 }
mega64 146:03e976389d16 40 #endif
mega64 146:03e976389d16 41
mega64 146:03e976389d16 42 #ifdef NDEBUG
mega64 146:03e976389d16 43 #define MBED_ASSERT(expr) ((void)0)
mega64 146:03e976389d16 44
mega64 146:03e976389d16 45 #else
mega64 146:03e976389d16 46 #define MBED_ASSERT(expr) \
mega64 146:03e976389d16 47 do { \
mega64 146:03e976389d16 48 if (!(expr)) { \
mega64 146:03e976389d16 49 mbed_assert_internal(#expr, __FILE__, __LINE__); \
mega64 146:03e976389d16 50 } \
mega64 146:03e976389d16 51 } while (0)
mega64 146:03e976389d16 52 #endif
mega64 146:03e976389d16 53
mega64 146:03e976389d16 54
mega64 146:03e976389d16 55 /** MBED_STATIC_ASSERT
mega64 146:03e976389d16 56 * Declare compile-time assertions, results in compile-time error if condition is false
mega64 146:03e976389d16 57 *
mega64 146:03e976389d16 58 * The assertion acts as a declaration that can be placed at file scope, in a
mega64 146:03e976389d16 59 * code block (except after a label), or as a member of a C++ class/struct/union.
mega64 146:03e976389d16 60 *
mega64 146:03e976389d16 61 * @note
mega64 146:03e976389d16 62 * Use of MBED_STATIC_ASSERT as a member of a struct/union is limited:
mega64 146:03e976389d16 63 * - In C++, MBED_STATIC_ASSERT is valid in class/struct/union scope.
mega64 146:03e976389d16 64 * - In C, MBED_STATIC_ASSERT is not valid in struct/union scope, and
mega64 146:03e976389d16 65 * MBED_STRUCT_STATIC_ASSERT is provided as an alternative that is valid
mega64 146:03e976389d16 66 * in C and C++ class/struct/union scope.
mega64 146:03e976389d16 67 *
mega64 146:03e976389d16 68 * @code
mega64 146:03e976389d16 69 * MBED_STATIC_ASSERT(MBED_LIBRARY_VERSION >= 120,
mega64 146:03e976389d16 70 * "The mbed library must be at least version 120");
mega64 146:03e976389d16 71 *
mega64 146:03e976389d16 72 * int main() {
mega64 146:03e976389d16 73 * MBED_STATIC_ASSERT(sizeof(int) >= sizeof(char),
mega64 146:03e976389d16 74 * "An int must be larger than a char");
mega64 146:03e976389d16 75 * }
mega64 146:03e976389d16 76 * @endcode
mega64 146:03e976389d16 77 */
mega64 146:03e976389d16 78 #if defined(__cplusplus) && (__cplusplus >= 201103L || __cpp_static_assert >= 200410L)
mega64 146:03e976389d16 79 #define MBED_STATIC_ASSERT(expr, msg) static_assert(expr, msg)
mega64 146:03e976389d16 80 #elif !defined(__cplusplus) && __STDC_VERSION__ >= 201112L
mega64 146:03e976389d16 81 #define MBED_STATIC_ASSERT(expr, msg) _Static_assert(expr, msg)
mega64 146:03e976389d16 82 #elif defined(__cplusplus) && defined(__GNUC__) && defined(__GXX_EXPERIMENTAL_CXX0X__) \
mega64 146:03e976389d16 83 && (__GNUC__*100 + __GNUC_MINOR__) > 403L
mega64 146:03e976389d16 84 #define MBED_STATIC_ASSERT(expr, msg) __extension__ static_assert(expr, msg)
mega64 146:03e976389d16 85 #elif !defined(__cplusplus) && defined(__GNUC__) && !defined(__CC_ARM) \
mega64 146:03e976389d16 86 && (__GNUC__*100 + __GNUC_MINOR__) > 406L
mega64 146:03e976389d16 87 #define MBED_STATIC_ASSERT(expr, msg) __extension__ _Static_assert(expr, msg)
mega64 146:03e976389d16 88 #elif defined(__ICCARM__)
mega64 146:03e976389d16 89 #define MBED_STATIC_ASSERT(expr, msg) static_assert(expr, msg)
mega64 146:03e976389d16 90 #else
mega64 146:03e976389d16 91 #define MBED_STATIC_ASSERT(expr, msg) \
mega64 146:03e976389d16 92 enum {MBED_CONCAT(MBED_ASSERTION_AT_, __LINE__) = sizeof(char[(expr) ? 1 : -1])}
mega64 146:03e976389d16 93 #endif
mega64 146:03e976389d16 94
mega64 146:03e976389d16 95 /** MBED_STRUCT_STATIC_ASSERT
mega64 146:03e976389d16 96 * Declare compile-time assertions, results in compile-time error if condition is false
mega64 146:03e976389d16 97 *
mega64 146:03e976389d16 98 * Unlike MBED_STATIC_ASSERT, MBED_STRUCT_STATIC_ASSERT can and must be used
mega64 146:03e976389d16 99 * as a member of a C/C++ class/struct/union.
mega64 146:03e976389d16 100 *
mega64 146:03e976389d16 101 * @code
mega64 146:03e976389d16 102 * struct thing {
mega64 146:03e976389d16 103 * MBED_STATIC_ASSERT(2 + 2 == 4,
mega64 146:03e976389d16 104 * "Hopefully the universe is mathematically consistent");
mega64 146:03e976389d16 105 * };
mega64 146:03e976389d16 106 * @endcode
mega64 146:03e976389d16 107 */
mega64 146:03e976389d16 108 #define MBED_STRUCT_STATIC_ASSERT(expr, msg) int : (expr) ? 0 : -1
mega64 146:03e976389d16 109
mega64 146:03e976389d16 110
mega64 146:03e976389d16 111 #endif
mega64 146:03e976389d16 112
mega64 146:03e976389d16 113 /** @}*/