import rtconfig
from building import *

# get current directory
cwd = GetCurrentDir()

# The set of source files associated with this SConscript file.

src = Split('''
STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c
STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cec.c
STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c
STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_crc.c
STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cryp.c
STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cryp_ex.c
STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c
STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c
STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c
STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c
STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c
STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c
STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rng.c
STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c
''')

path = []
CPPDEFINES = []

src += ['STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pccard.c']
src += ['STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd.c']
src += ['STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd_ex.c']
src += ['STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_hcd.c']
src += ['STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c']

src += ['STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.c']
src += ['STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_usart.c']

src += ['STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_exti.c']
src += ['STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spi.c']

src += ['STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c']
src += ['STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c']

src += ['CMSIS/Device/ST/STM32F4xx/Source/Templates/system_stm32f4xx.c']

path += [cwd + '/STM32F4xx_HAL_Driver/Inc']
path += [cwd + '/STM32F4xx_HAL_Driver/Inc/Legacy']
path += [cwd + '/CMSIS/Include']
path += [cwd + '/CMSIS/Device/ST/STM32F4xx/Include']

if rtconfig.PLATFORM in ['gcc']:
    src += ['CMSIS/Device/ST/STM32F4xx/Source/Templates/gcc/startup_stm32f429xx.s']
elif rtconfig.PLATFORM in ['armcc', 'armclang']:
    src += ['CMSIS/Device/ST/STM32F4xx/Source/Templates/arm/startup_stm32f429xx.s']
elif rtconfig.PLATFORM in ['iccarm']:
    src += ['CMSIS/Device/ST/STM32F4xx/Source/Templates/iar/startup_stm32f429xx.s']

CPPDEFINES += ['STM32F429xx']
group = DefineGroup('Drivers/STM32F4xx_HAL_Driver', src, depend = [''], CPPPATH = path, CPPDEFINES = CPPDEFINES)

Return('group')
