Skip to content

Commit

Permalink
Added support for SDIO LLD driver
Browse files Browse the repository at this point in the history
  • Loading branch information
HorrorTroll committed Aug 11, 2024
1 parent a48b486 commit 635a296
Show file tree
Hide file tree
Showing 7 changed files with 1,273 additions and 25 deletions.
22 changes: 22 additions & 0 deletions os/hal/boards/AT_START_F415/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,28 @@ void __early_init(void) {
at32_clock_init();
}

#if HAL_USE_SDC || defined(__DOXYGEN__)
/**
* @brief SDC card detection.
*/
bool sdc_lld_is_card_inserted(SDCDriver *sdcp) {
static bool last_status = false;

if (blkIsTransferring(sdcp))
return last_status;
return last_status = (bool)palReadPad(GPIOA, GPIOA_ARD_A2);
}

/**
* @brief SDC card write protection detection.
*/
bool sdc_lld_is_write_protected(SDCDriver *sdcp) {

(void)sdcp;
return false;
}
#endif /* HAL_USE_SDC */

/**
* @brief Board-specific initialization code.
* @note You can add your board-specific code here.
Expand Down
2 changes: 1 addition & 1 deletion os/hal/ports/AT32/AT32F415/at32_dmamux.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
#define AT32_DMAMUX_I2C1_TX 42
#define AT32_DMAMUX_I2C2_RX 43
#define AT32_DMAMUX_I2C2_TX 44
#define AT32_DMAMUX_SDIO1 49
#define AT32_DMAMUX_SDIO 49
#define AT32_DMAMUX_TMR1_TRIG 53
#define AT32_DMAMUX_TMR1_HALL 54
#define AT32_DMAMUX_TMR1_OVERFLOW 55
Expand Down
48 changes: 24 additions & 24 deletions os/hal/ports/AT32/AT32F415/at32_registry.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,13 @@
#define AT32_HAS_QUADSPI1 FALSE

/* SDIO attributes.*/
#define AT32_HAS_SDIO1 TRUE
#define AT32_HAS_SDIO TRUE

#if (AT32_DMA_USE_DMAMUX == TRUE) || defined(__DOXYGEN__)
#define AT32_SDC_SDIO1_DMA_STREAM AT32_DMA_STREAM_ID(1, 5)
#define AT32_SDC_SDIO1_DMAMUX_CHANNEL 5
#define AT32_SDC_SDIO_DMA_STREAM AT32_DMA_STREAM_ID(1, 5)
#define AT32_SDC_SDIO_DMAMUX_CHANNEL 5
#else
#define AT32_SDC_SDIO1_DMA_STREAM AT32_DMA_STREAM_ID(2, 4)
#define AT32_SDC_SDIO_DMA_STREAM AT32_DMA_STREAM_ID(2, 4)
#endif

/* SPI attributes.*/
Expand Down Expand Up @@ -357,13 +357,13 @@
#define AT32_HAS_QUADSPI1 FALSE

/* SDIO attributes.*/
#define AT32_HAS_SDIO1 TRUE
#define AT32_HAS_SDIO TRUE

#if (AT32_DMA_USE_DMAMUX == TRUE) || defined(__DOXYGEN__)
#define AT32_SDC_SDIO1_DMA_STREAM AT32_DMA_STREAM_ID(1, 5)
#define AT32_SDC_SDIO1_DMAMUX_CHANNEL 5
#define AT32_SDC_SDIO_DMA_STREAM AT32_DMA_STREAM_ID(1, 5)
#define AT32_SDC_SDIO_DMAMUX_CHANNEL 5
#else
#define AT32_SDC_SDIO1_DMA_STREAM AT32_DMA_STREAM_ID(2, 4)
#define AT32_SDC_SDIO_DMA_STREAM AT32_DMA_STREAM_ID(2, 4)
#endif

/* SPI attributes.*/
Expand Down Expand Up @@ -571,13 +571,13 @@
#define AT32_HAS_QUADSPI1 FALSE

/* SDIO attributes.*/
#define AT32_HAS_SDIO1 TRUE
#define AT32_HAS_SDIO TRUE

#if (AT32_DMA_USE_DMAMUX == TRUE) || defined(__DOXYGEN__)
#define AT32_SDC_SDIO1_DMA_STREAM AT32_DMA_STREAM_ID(1, 5)
#define AT32_SDC_SDIO1_DMAMUX_CHANNEL 5
#define AT32_SDC_SDIO_DMA_STREAM AT32_DMA_STREAM_ID(1, 5)
#define AT32_SDC_SDIO_DMAMUX_CHANNEL 5
#else
#define AT32_SDC_SDIO1_DMA_STREAM AT32_DMA_STREAM_ID(2, 4)
#define AT32_SDC_SDIO_DMA_STREAM AT32_DMA_STREAM_ID(2, 4)
#endif

/* SPI attributes.*/
Expand Down Expand Up @@ -796,13 +796,13 @@
#define AT32_HAS_QUADSPI1 FALSE

/* SDIO attributes.*/
#define AT32_HAS_SDIO1 TRUE
#define AT32_HAS_SDIO TRUE

#if (AT32_DMA_USE_DMAMUX == TRUE) || defined(__DOXYGEN__)
#define AT32_SDC_SDIO1_DMA_STREAM AT32_DMA_STREAM_ID(1, 5)
#define AT32_SDC_SDIO1_DMAMUX_CHANNEL 5
#define AT32_SDC_SDIO_DMA_STREAM AT32_DMA_STREAM_ID(1, 5)
#define AT32_SDC_SDIO_DMAMUX_CHANNEL 5
#else
#define AT32_SDC_SDIO1_DMA_STREAM AT32_DMA_STREAM_ID(2, 4)
#define AT32_SDC_SDIO_DMA_STREAM AT32_DMA_STREAM_ID(2, 4)
#endif

/* SPI attributes.*/
Expand Down Expand Up @@ -1021,13 +1021,13 @@
#define AT32_HAS_QUADSPI1 FALSE

/* SDIO attributes.*/
#define AT32_HAS_SDIO1 TRUE
#define AT32_HAS_SDIO TRUE

#if (AT32_DMA_USE_DMAMUX == TRUE) || defined(__DOXYGEN__)
#define AT32_SDC_SDIO1_DMA_STREAM AT32_DMA_STREAM_ID(1, 5)
#define AT32_SDC_SDIO1_DMAMUX_CHANNEL 5
#define AT32_SDC_SDIO_DMA_STREAM AT32_DMA_STREAM_ID(1, 5)
#define AT32_SDC_SDIO_DMAMUX_CHANNEL 5
#else
#define AT32_SDC_SDIO1_DMA_STREAM AT32_DMA_STREAM_ID(2, 4)
#define AT32_SDC_SDIO_DMA_STREAM AT32_DMA_STREAM_ID(2, 4)
#endif

/* SPI attributes.*/
Expand Down Expand Up @@ -1265,13 +1265,13 @@
#define AT32_HAS_QUADSPI1 FALSE

/* SDIO attributes.*/
#define AT32_HAS_SDIO1 TRUE
#define AT32_HAS_SDIO TRUE

#if (AT32_DMA_USE_DMAMUX == TRUE) || defined(__DOXYGEN__)
#define AT32_SDC_SDIO1_DMA_STREAM AT32_DMA_STREAM_ID(1, 5)
#define AT32_SDC_SDIO1_DMAMUX_CHANNEL 5
#define AT32_SDC_SDIO_DMA_STREAM AT32_DMA_STREAM_ID(1, 5)
#define AT32_SDC_SDIO_DMAMUX_CHANNEL 5
#else
#define AT32_SDC_SDIO1_DMA_STREAM AT32_DMA_STREAM_ID(2, 4)
#define AT32_SDC_SDIO_DMA_STREAM AT32_DMA_STREAM_ID(2, 4)
#endif

/* SPI attributes.*/
Expand Down
1 change: 1 addition & 0 deletions os/hal/ports/AT32/AT32F415/platform.mk
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ include $(CHIBIOS_CONTRIB)/os/hal/ports/AT32/LLD/GPIOv1/driver.mk
include $(CHIBIOS_CONTRIB)/os/hal/ports/AT32/LLD/I2Cv1/driver.mk
include $(CHIBIOS_CONTRIB)/os/hal/ports/AT32/LLD/OTGv1/driver.mk
include $(CHIBIOS_CONTRIB)/os/hal/ports/AT32/LLD/RTCv2/driver.mk
include $(CHIBIOS_CONTRIB)/os/hal/ports/AT32/LLD/SDIOv1/driver.mk
include $(CHIBIOS_CONTRIB)/os/hal/ports/AT32/LLD/SPIv1/driver.mk
include $(CHIBIOS_CONTRIB)/os/hal/ports/AT32/LLD/SYSTICKv1/driver.mk
include $(CHIBIOS_CONTRIB)/os/hal/ports/AT32/LLD/TMRv1/driver.mk
Expand Down
9 changes: 9 additions & 0 deletions os/hal/ports/AT32/LLD/SDIOv1/driver.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ifeq ($(USE_SMART_BUILD),yes)
ifneq ($(findstring HAL_USE_SDC TRUE,$(HALCONF)),)
PLATFORMSRC_CONTRIB += $(CHIBIOS_CONTRIB)/os/hal/ports/AT32/LLD/SDIOv1/hal_sdc_lld.c
endif
else
PLATFORMSRC_CONTRIB += $(CHIBIOS_CONTRIB)/os/hal/ports/AT32/LLD/SDIOv1/hal_sdc_lld.c
endif

PLATFORMINC_CONTRIB += $(CHIBIOS_CONTRIB)/os/hal/ports/AT32/LLD/SDIOv1
Loading

0 comments on commit 635a296

Please sign in to comment.