Import('src_env')

# Enable common components for STM32 running FreeRTOS
src_env['crypto'] = True
src_env['external_sha2'] = True
src_env['malloc'] = True
src_env['freertos'] = True
src_env['wsl'] = True
src_env['nvram'] = True

# Build target source
src_env['srcs'].extend(Glob('*.c'))
src_env['srcs'].extend(Glob(src_env['FREE_RTOS_DIR'] + '/Source/*.c'))
src_env['srcs'].extend(File([src_env['FREE_RTOS_DIR'] + '/Source/portable/GCC/ARM_CM3/port.c',
                             src_env['FREE_RTOS_DIR'] + '/Source/portable/MemMang/heap_3.c',
                             src_env['STM_SRC_DIR'] + '/Libraries/CMSIS/ST/STM32F4xx/Source/Templates/gcc_ride7/startup_stm32f4xx.s',
                             src_env['STM_SRC_DIR'] + '/Libraries/CMSIS/ST/STM32F4xx/Source/Templates/system_stm32f4xx.c',
                             src_env['STM_SRC_DIR'] + '/Libraries/STM32F4xx_StdPeriph_Driver/src/misc.c',
                             src_env['STM_SRC_DIR'] + '/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rcc.c',
                             src_env['STM_SRC_DIR'] + '/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_usart.c',
                             src_env['STM_SRC_DIR'] + '/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_gpio.c',
                             src_env['STM_SRC_DIR'] + '/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dma.c',
                             src_env['STM_SRC_DIR'] + '/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_wwdg.c',
                             src_env['STM_SRC_DIR'] + '/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_spi.c',
                             src_env['STM_SRC_DIR'] + '/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_flash.c',
                             src_env['STM_SRC_DIR'] + '/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rng.c',
                             src_env['STM_SRC_DIR'] + '/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_exti.c',
                             src_env['STM_SRC_DIR'] + '/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_tim.c',
                             src_env['STM_SRC_DIR'] + '/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_adc.c',
                             src_env['STM_SRC_DIR'] + '/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_i2c.c',
                             src_env['STM_SRC_DIR'] + '/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_syscfg.c'
]))

