Skip to content

Commit

Permalink
Add SDIO support for NXP LPC55S69
Browse files Browse the repository at this point in the history
Tested this with the block device test inside features-storage-tests-blockdevice-general_block_device
Below was the change made to add SDIO test

--- a/features/storage/TESTS/blockdevice/general_block_device/main.cpp
+++ b/features/storage/TESTS/blockdevice/general_block_device/main.cpp
@@ -47,6 +47,8 @@
 #include "FlashIAPBlockDevice.h"
 #endif

+#include "SDIOBlockDevice.h"
+
 using namespace utest::v1;

 #define TEST_BLOCK_COUNT 10
@@ -69,6 +71,7 @@ enum bd_type {
     dataflash,
     sd,
     flashiap,
+    sdio,
     default_bd
 };

@@ -90,6 +93,11 @@ static inline uint32_t align_up(uint32_t val, uint32_t size)
 static BlockDevice *get_bd_instance(uint8_t bd_type)
 {
     switch (bd_arr[bd_type]) {
+        case sdio: {
+            static SDIOBlockDevice default_bd(P0_17);
+            return &default_bd;
+            break;
+        }
         case spif: {
 #if COMPONENT_SPIF
             static SPIFBlockDevice default_bd(
@@ -632,6 +640,8 @@ void test_get_type_functionality()
     const char *bd_type = block_device->get_type();
     TEST_ASSERT_NOT_EQUAL(0, bd_type);

+    TEST_ASSERT_EQUAL(0, strcmp(bd_type, "SDIO"));
+
 #if COMPONENT_QSPIF
     TEST_ASSERT_EQUAL(0, strcmp(bd_type, "QSPIF"));
 #elif COMPONENT_SPIF
@@ -708,10 +718,12 @@ int get_bd_count()
     bd_arr[count++] = flashiap;       //4
 #endif

+    bd_arr[count++] = sdio;       //5
+
     return count;
 }

-static const char *prefix[] = {"SPIF ", "QSPIF ", "DATAFLASH ", "SD ", "FLASHIAP ", "DEFAULT "};
+static const char *prefix[] = {"SPIF ", "QSPIF ", "DATAFLASH ", "SD ", "FLASHIAP ", "SDIO ", "DEFAULT "};

 int main()
 {

Signed-off-by: Mahesh Mahadevan <[email protected]>
  • Loading branch information
mmahadevan108 committed Feb 19, 2019
1 parent 7fb810f commit 370c51a
Show file tree
Hide file tree
Showing 10 changed files with 5,241 additions and 0 deletions.
41 changes: 41 additions & 0 deletions target/TARGET_NXP/board.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright 2017-2018 NXP
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/

#ifndef _BOARD_H_
#define _BOARD_H_

#include "fsl_common.h"
#include "fsl_gpio.h"
#include "fsl_iocon.h"

/*******************************************************************************
* Definitions
******************************************************************************/

#define BOARD_SDIF_BASEADDR SDIF
#define BOARD_SDIF_CLKSRC kCLOCK_SDio
#define BOARD_SDIF_CLK_FREQ CLOCK_GetFreq(kCLOCK_SDio)
#define BOARD_SDIF_CLK_ATTACH kMAIN_CLK_to_SDIO_CLK
#define BOARD_SDIF_IRQ SDIO_IRQn
#define BOARD_MMC_VCC_SUPPLY kMMC_VoltageWindows270to360
#define BOARD_SD_CARD_DETECT_PIN 17
#define BOARD_SD_CARD_DETECT_PORT 0
#define BOARD_SD_CARD_DETECT_GPIO GPIO
#define BOARD_SD_DETECT_TYPE kSDMMCHOST_DetectCardByHostCD

#define BOARD_SDIF_CD_GPIO_INIT() \
{ \
CLOCK_EnableClock(kCLOCK_Gpio2); \
GPIO_PinInit(BOARD_SD_CARD_DETECT_GPIO, BOARD_SD_CARD_DETECT_PORT, BOARD_SD_CARD_DETECT_PIN, \
&(gpio_pin_config_t){kGPIO_DigitalInput, 0U}); \
}
#define BOARD_SDIF_CD_STATUS() \
GPIO_PinRead(BOARD_SD_CARD_DETECT_GPIO, BOARD_SD_CARD_DETECT_PORT, BOARD_SD_CARD_DETECT_PIN)

#define BOARD_SDIF_CLK_ATTACH kMAIN_CLK_to_SDIO_CLK

#endif /* _BOARD_H_ */
Loading

0 comments on commit 370c51a

Please sign in to comment.