############################################################################
# arch/arm/src/at32/Make.defs
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.  The
# ASF licenses this file to you 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.
#
############################################################################

include armv7-m/Make.defs

CHIP_CSRCS  = at32_allocateheap.c at32_start.c at32_rcc.c at32_lse.c
CHIP_CSRCS += at32_lsi.c at32_gpio.c at32_exti_gpio.c at32_flash.c
CHIP_CSRCS += at32_irq.c at32_lowputc.c
CHIP_CSRCS += at32_waste.c at32_uid.c
CHIP_CSRCS += at32_serial.c 

ifeq ($(CONFIG_AT32_TIM),y)
CHIP_CSRCS += at32_tim.c
endif

ifeq ($(CONFIG_AT32_SDIO),y)
CHIP_CSRCS += at32_sdio.c
endif

ifeq ($(CONFIG_AT32_SPI),y)
CHIP_CSRCS += at32_spi.c
endif

ifeq ($(CONFIG_AT32_DMA),y)
CHIP_CSRCS += at32_dma.c
endif

ifeq ($(CONFIG_TIMER),y)
CHIP_CSRCS += at32_tim_lowerhalf.c
endif

ifdef CONFIG_AT32_TICKLESS_TIMER
CHIP_CSRCS += at32_tickless.c
else
CHIP_CSRCS += at32_timerisr.c
endif

ifeq ($(CONFIG_AT32_ONESHOT),y)
CHIP_CSRCS += at32_oneshot.c at32_oneshot_lowerhalf.c
endif

ifeq ($(CONFIG_AT32_FREERUN),y)
CHIP_CSRCS += at32_freerun.c
endif

ifeq ($(CONFIG_BUILD_PROTECTED),y)
CHIP_CSRCS += at32_userspace.c at32_mpuinit.c
endif

ifeq ($(CONFIG_AT32_I2C),y)
CHIP_CSRCS += at32_i2c.c
endif

ifeq ($(CONFIG_USBDEV),y)
ifeq ($(CONFIG_AT32_USB),y)
CHIP_CSRCS += at32_usbdev.c
endif
ifeq ($(CONFIG_AT32_USBFS),y)
CHIP_CSRCS += at32_usbfs.c
endif
ifeq ($(CONFIG_AT32_OTGFS),y)
CHIP_CSRCS += at32_otgfsdev.c
endif
endif

ifeq ($(CONFIG_AT32_USBHOST),y)
ifeq ($(CONFIG_AT32_OTGFS),y)
CHIP_CSRCS += at32_otgfshost.c
endif
ifeq ($(CONFIG_USBHOST_TRACE),y)
CHIP_CSRCS += at32_usbhost.c
else
ifeq ($(CONFIG_DEBUG_USB),y)
CHIP_CSRCS += at32_usbhost.c
endif
endif
endif

ifneq ($(CONFIG_ARCH_IDLE_CUSTOM),y)
CHIP_CSRCS += at32_idle.c
endif

CHIP_CSRCS += at32_pmstop.c at32_pmstandby.c at32_pmsleep.c

ifneq ($(CONFIG_ARCH_CUSTOM_PMINIT),y)
CHIP_CSRCS += at32_pminitialize.c
endif

ifeq ($(CONFIG_AT32_ETHMAC),y)
CHIP_CSRCS += at32_eth.c
endif

ifeq ($(CONFIG_AT32_PWR),y)
CHIP_CSRCS += at32_pwr.c at32_exti_pwr.c
endif

ifeq ($(CONFIG_AT32_RTC),y)
CHIP_CSRCS += at32_rtc.c
ifeq ($(CONFIG_RTC_ALARM),y)
CHIP_CSRCS += at32_exti_alarm.c
endif
ifeq ($(CONFIG_RTC_PERIODIC),y)
CHIP_CSRCS += at32_exti_wakeup.c
endif
ifeq ($(CONFIG_RTC_DRIVER),y)
CHIP_CSRCS += at32_rtc_lowerhalf.c
endif
endif

ifeq ($(CONFIG_AT32_ADC),y)
CHIP_CSRCS += at32_adc.c
endif

ifeq ($(CONFIG_AT32_DAC),y)
CHIP_CSRCS += at32_dac.c
endif

ifeq ($(CONFIG_AT32_1WIREDRIVER),y)
CHIP_CSRCS += at32_1wire.c
endif

ifeq ($(CONFIG_AT32_HCIUART),y)
CHIP_CSRCS += at32_hciuart.c
endif

ifeq ($(CONFIG_AT32_PWM),y)
CHIP_CSRCS += at32_pwm.c
endif

ifeq ($(CONFIG_AT32_CAP),y)
CHIP_CSRCS += at32_capture_lowerhalf.c
endif


ifeq ($(CONFIG_SENSORS_HALL3PHASE),y)
CHIP_CSRCS += at32_hall3ph.c
endif

ifeq ($(CONFIG_AT32_CAN),y)
ifeq ($(CONFIG_AT32_CAN_CHARDRIVER),y)
CHIP_CSRCS += at32_can.c
endif
ifeq ($(CONFIG_AT32_CAN_SOCKET),y)
CHIP_CSRCS += at32_can_sock.c
endif
endif

ifeq ($(CONFIG_AT32_IWDG),y)
CHIP_CSRCS += at32_iwdg.c
endif

ifeq ($(CONFIG_AT32_WWDG),y)
CHIP_CSRCS += at32_wwdg.c
endif

ifeq ($(CONFIG_DEBUG_FEATURES),y)
CHIP_CSRCS += at32_dumpgpio.c
endif

ifeq ($(CONFIG_AT32_FOC),y)
CHIP_CSRCS += at32_foc.c
endif