# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

import os
Import('genv')

inc = [
    'Inc',
    'Inc/Legacy',
    genv["PROJECT_ROOT"]+"/Inc",
    genv["STM32_DRIVERS_PATH"] + "/CMSIS/Device/ST/STM32L0xx/Include",
    genv["STM32_DRIVERS_PATH"] + "/CMSIS/Include",
]

env = Environment()

env["CC"] = genv["CC"]
env["CXX"] = genv["CXX"]
env["AS"] = genv["AS"]
env["AR"] = genv["AR"]
env["LINK"] = genv["LINK"]
env["OBJCOPY"] = genv["OBJCOPY"]
env["NM"] = genv["NM"]
env["ENV"] = genv["ENV"]

env["LINKFLAGS"] = genv["LINKFLAGS"]
env["CFLAGS"] = genv["CFLAGS"]
env["ASFLAGS"] = genv["ASFLAGS"]

dst = "STM32L0XX_HAL"
src = [
    "Src/stm32l0xx_hal_smartcard.c",
    "Src/stm32l0xx_ll_rng.c",
    "Src/stm32l0xx_hal_cortex.c",
    "Src/stm32l0xx_ll_crc.c",
    "Src/stm32l0xx_hal_adc_ex.c",
    "Src/stm32l0xx_hal_comp.c",
    "Src/stm32l0xx_ll_utils.c",
    "Src/stm32l0xx_hal_tim.c",
    "Src/stm32l0xx_hal_smbus.c",
    "Src/stm32l0xx_hal_flash_ex.c",
    "Src/stm32l0xx_hal_pcd.c",
    "Src/stm32l0xx_hal_gpio.c",
    "Src/stm32l0xx_hal_smartcard_ex.c",
    "Src/stm32l0xx_ll_adc.c",
    "Src/stm32l0xx_hal_cryp.c",
    "Src/stm32l0xx_hal_rtc_ex.c",
    "Src/stm32l0xx_hal_msp_template.c",
    "Src/stm32l0xx_ll_lptim.c",
    "Src/stm32l0xx_hal_wwdg.c",
    "Src/stm32l0xx_hal_lcd.c",
    "Src/stm32l0xx_hal_tsc.c",
    "Src/stm32l0xx_hal_pwr.c",
    "Src/stm32l0xx_hal_rcc_ex.c",
    "Src/stm32l0xx_hal_firewall.c",
    "Src/stm32l0xx_hal_tim_ex.c",
    "Src/stm32l0xx_hal_pwr_ex.c",
    "Src/stm32l0xx_hal_spi.c",
    "Src/stm32l0xx_ll_tim.c",
    "Src/stm32l0xx_ll_dac.c",
    "Src/stm32l0xx_hal_usart.c",
    "Src/stm32l0xx_hal_rtc.c",
    "Src/stm32l0xx_hal_comp_ex.c",
    "Src/stm32l0xx_hal_dma.c",
    "Src/stm32l0xx_hal_uart.c",
    "Src/stm32l0xx_hal_iwdg.c",
    "Src/stm32l0xx_hal_crc.c",
    "Src/stm32l0xx_hal_flash_ramfunc.c",
    "Src/stm32l0xx_ll_spi.c",
    "Src/stm32l0xx_hal_irda.c",
    "Src/stm32l0xx_hal_i2c.c",
    "Src/stm32l0xx_ll_rcc.c",
    "Src/stm32l0xx_hal_crc_ex.c",
    "Src/stm32l0xx_hal_flash.c",
    "Src/stm32l0xx_hal.c",
    "Src/stm32l0xx_hal_uart_ex.c",
    "Src/stm32l0xx_hal_lptim.c",
    "Src/stm32l0xx_ll_comp.c",
    "Src/stm32l0xx_hal_i2c_ex.c",
    "Src/stm32l0xx_hal_pcd_ex.c",
    "Src/stm32l0xx_ll_crs.c",
    "Src/stm32l0xx_ll_rtc.c",
    "Src/stm32l0xx_ll_gpio.c",
    "Src/stm32l0xx_hal_adc.c",
    "Src/stm32l0xx_ll_dma.c",
    "Src/stm32l0xx_hal_rcc.c",
    "Src/stm32l0xx_hal_cryp_ex.c",
    "Src/stm32l0xx_ll_usart.c",
    "Src/stm32l0xx_hal_i2s.c",
    "Src/stm32l0xx_ll_lpuart.c",
    "Src/stm32l0xx_hal_rng.c",
    "Src/stm32l0xx_ll_i2c.c",
    "Src/stm32l0xx_hal_dac.c",
    "Src/stm32l0xx_ll_pwr.c",
    "Src/stm32l0xx_hal_dac_ex.c",
    "Src/stm32l0xx_ll_exti.c",
]
lib = []

stm32_hal_driver = env.StaticLibrary(target=dst, source=src, LIBS=lib, CPPPATH=inc)
Return("stm32_hal_driver")
