1import os
2import rtconfig
3from building import *
4
5Import('SDK_LIB')
6
7cwd = GetCurrentDir()
8
9# add general drivers
10src = Split('''
11board.c
12CubeMX_Config/Common/System/system_stm32mp1xx.c
13CubeMX_Config/CM4/Src/stm32mp1xx_hal_msp.c
14''')
15
16if GetDepend(['BSP_USING_ADC']):
17    src += Glob('ports/drv_hard_i2c.c')
18    src += Glob('ports/stpmic.c')
19
20if GetDepend(['BSP_USING_DAC']):
21    src += Glob('ports/drv_hard_i2c.c')
22    src += Glob('ports/stpmic.c')
23
24if GetDepend(['BSP_USING_WWDG']):
25    src += Glob('ports/drv_wwdg.c')
26
27if GetDepend(['BSP_USING_LPTIM']):
28    src += Glob('ports/drv_lptim.c')
29
30path =  [cwd]
31path += [cwd + '/CubeMX_Config/CM4/Inc']
32path += [cwd + '/ports']
33
34startup_path_prefix = SDK_LIB
35
36if rtconfig.PLATFORM in ['gcc']:
37    src += [startup_path_prefix + '/STM32MPxx_HAL/CMSIS/Device/ST/STM32MP1xx/Source/Templates/gcc/startup_stm32mp15xx.s']
38elif rtconfig.PLATFORM in ['armcc', 'armclang']:
39    src += [startup_path_prefix + '/STM32MPxx_HAL/CMSIS/Device/ST/STM32MP1xx/Source/Templates/arm/startup_stm32mp15xx.s']
40elif rtconfig.PLATFORM in ['iccarm']:
41    src += [startup_path_prefix + '/STM32MPxx_HAL/CMSIS/Device/ST/STM32MP1xx/Source/Templates/iar/startup_stm32mp15xx.s']
42
43CPPDEFINES = ['CORE_CM4','NO_ATOMIC_64_SUPPORT','METAL_INTERNAL','METAL_MAX_DEVICE_REGIONS=2','VIRTIO_SLAVE_ONLY','STM32MP157Axx','__LOG_TRACE_IO_']
44
45group = DefineGroup('Drivers', src, depend = [''], CPPPATH = path, CPPDEFINES = CPPDEFINES)
46
47Return('group')
48