package platform.stm32.f4.stm32f4_discovery

@BuildArtifactPath(cppflags="-DSTM32F407xx -DUSE_STM32F4_DISCO")
static module stm32f4_discovery_conf extends third_party.bsp.stmf4cube.stm32f4_conf {
	@IncludeExport(path="")
	source "stm32f4xx_hal_conf.h"
}

@Build(stage=1)
@BuildDepends(stm32f4_discovery_conf)
@BuildDepends(third_party.bsp.stmf4cube.cube)
@BuildArtifactPath(cppflags="-I$(EXTERNAL_BUILD_DIR)/third_party/bsp/stmf4cube/cube/STM32CubeF4-1.27.1/Drivers/BSP/STM32F4-Discovery")
@BuildDepends(third_party.bsp.stmf4cube.bsp_drivers.stm324xg_eval_sd)
static module bsp extends third_party.bsp.st_bsp_api {
	/* STM32F40x and STM32F41x Errata sheet:
	 *
	 * https://www.st.com/content/ccc/resource/technical/document/errata_sheet/0a/98/58/84/86/b6/47/a2/DM00037591.pdf/files/DM00037591.pdf/jcr:content/translations/en.DM00037591.pdf
	 *
	 *  "2.5.2 Corrupted last bit of data and/or CRC,
	 *  received in Master mode with delayed SCK feedback" */
	option boolean errata_spi_wrong_last_bit=false

	source "clock_config.c"

	@AddPrefix("^BUILD/extbld/third_party/bsp/stmf4cube/cube/STM32CubeF4-1.27.1/")
	source "Projects/STM32F4-Discovery/Templates/Src/system_stm32f4xx.c"

	@AddPrefix("^BUILD/extbld/third_party/bsp/stmf4cube/cube/STM32CubeF4-1.27.1/")
	source "Drivers/BSP/STM32F4-Discovery/stm32f4_discovery.c",
			"Drivers/BSP/STM32F4-Discovery/stm32f4_discovery_accelerometer.c"

	/* there is no sd support for STM32F4-Discovery */
	@NoRuntime depends third_party.bsp.stmf4cube.bsp_drivers.stm324xg_eval_sd
	@NoRuntime depends third_party.bsp.stmf4cube.cube
	@NoRuntime depends stm32f4_discovery_conf
	@NoRuntime depends platform.stm32.stm32cube_compat
}

@Build(stage=1)
@BuildDepends(third_party.bsp.stmf4cube.cube)
@BuildDepends(third_party.bsp.stmf4cube.components.cs43l22)
@BuildDepends(third_party.lib.st_audio_pdm.libPDMFilter_CM4_GCC_wc32)
@BuildDepends(bsp)
static module stm32f4_discovery_bsp_audio {
	@AddPrefix("^BUILD/extbld/third_party/bsp/stmf4cube/cube/STM32CubeF4-1.27.1/")
	source "Drivers/BSP/STM32F4-Discovery/stm32f4_discovery_audio.c"

	@NoRuntime depends third_party.bsp.stmf4cube.components.cs43l22

//	depends pdm_filter_stub

	@NoRuntime depends third_party.lib.st_audio_pdm.libPDMFilter_CM4_GCC_wc32
	@NoRuntime depends third_party.bsp.stmf4cube.cube
	@NoRuntime depends bsp
}

/*
@Build(stage=1)
@BuildDepends(third_party.bsp.stmf4cube.cube)
@BuildDepends(bsp)
static module pdm_filter_stub {
	@IncludePath("$(EXTERNAL_BUILD_DIR)/third_party/bsp/stmf4cube/cube/STM32CubeF4-1.27.1/")
	source "Middlewares/ST/STM32_Audio/Addons/PDM/pdm_filter_stub.c"

	@NoRuntime depends third_party.bsp.stmf4cube.cube
	@NoRuntime depends bsp
}
*/
