STM32F10x Standard Peripherals Firmware Libraryをビルドする

出典: Wikimura

Standard Peripherals Firmware Libraryでは、プロセッサ選択や実行時チェック使用選択がある都合上、1つだけビルドすれば良いというものではありません。 プロセッサ選択が影響するかは不明ですが、とりあえずプロセッサ3種類、実行時チェック有無の2種類、合計6種類が考えられます。

そこで、プロセッサと実行時チェックの有無に合わせてライブラリ用意しようと考えました。使用する際は、実行時チェックの有無でライブラリを切り替えることになります。しかし、それ以外はインクルードディレクトリの追加だけで済むようになります。

ここでは、ライブラリをビルドする方法について示します。

ライブラリプロジェクト作成

静的ライブラリプロジェクト作成

Eclipseで新規Cプロジェクトを作成する際、下図のようにStatic libraryを選択します。

  • lib_dir/Libraries
    • CMSIS/Core/CM3
      • stm32f10x.h
      • core_cm3.h
      • core_cm3.c
      • system_stm32f1ox.h
      • system_stm32f1ox.c
    • STM32F10x_StdPeriph_driver
      • inc
        • stm32f10x_adc.h
        • stm32f10x_bkp.h
        • stm32f10x_can.h
        • stm32f10x_crc.h
        • stm32f10x_dac.h
        • stm32f10x_dbgmcu.h
        • stm32f10x_dma.h
        • stm32f10x_exti.h
        • stm32f10x_flash.h
        • stm32f10x_fsmc.h
        • stm32f10x_gpio.h
        • stm32f10x_i2c.h
        • stm32f10x_iwdg.h
        • stm32f10x_pwr.h
        • stm32f10x_rcc.h
        • stm32f10x_rtc.h
        • stm32f10x_sdio.h
        • stm32f10x_spi.h
        • stm32f10x_tim.h
        • stm32f10x_usart.h
        • stm32f10x_wwdg.h
        • misc.h
      • src
        • stm32f10x_adc.c
        • stm32f10x_bkp.c
        • stm32f10x_can.c
        • stm32f10x_crc.c
        • stm32f10x_dac.c
        • stm32f10x_dbgmcu.c
        • stm32f10x_dma.c
        • stm32f10x_exti.c
        • stm32f10x_flash.c
        • stm32f10x_fsmc.c
        • stm32f10x_gpio.c
        • stm32f10x_i2c.c
        • stm32f10x_iwdg.c
        • stm32f10x_pwr.c
        • stm32f10x_rcc.c
        • stm32f10x_rtc.c
        • stm32f10x_sdio.c
        • stm32f10x_spi.c
        • stm32f10x_tim.c
        • stm32f10x_usart.c
        • stm32f10x_wwdg.c
        • misc.c
  • lib_dir/Project/Template
    • stm32f10x_conf.h