aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Barksdale <amatus@amatus.name>2016-08-02 18:19:31 -0500
committerDavid Barksdale <amatus@amatus.name>2016-08-02 22:12:15 -0500
commitc96bdbec1c030647a777a975534521bc30b03e6b (patch)
treecba942c63d2957e24f7bcd4b47a3e9f0baff7b98
parent08a23051ab4418ade7708a047c62e479ab19c829 (diff)
Add flash support, multiple LUN support
-rw-r--r--KSDK_1.2.0/usb/usb_core/device/sources/classes/include/usb_class_msc.h1
-rw-r--r--KSDK_1.2.0/usb/usb_core/device/sources/classes/msd/usb_msc.c3
-rw-r--r--laser-tag software/CMakeLists.txt40
-rw-r--r--laser-tag software/disk.c1
-rw-r--r--laser-tag software/disk.h25
-rw-r--r--laser-tag software/flash.c38
-rw-r--r--laser-tag software/flash.h6
-rw-r--r--laser-tag software/main.c4
8 files changed, 101 insertions, 17 deletions
diff --git a/KSDK_1.2.0/usb/usb_core/device/sources/classes/include/usb_class_msc.h b/KSDK_1.2.0/usb/usb_core/device/sources/classes/include/usb_class_msc.h
index 3ada631..168877b 100644
--- a/KSDK_1.2.0/usb/usb_core/device/sources/classes/include/usb_class_msc.h
+++ b/KSDK_1.2.0/usb/usb_core/device/sources/classes/include/usb_class_msc.h
@@ -132,6 +132,7 @@ typedef struct _lba_app_struct
uint32_t offset; /*!< offset of target block need to access*/
uint32_t size; /*!< size need to access*/
uint8_t* buff_ptr; /*!< used to save the content by access the target block*/
+ uint8_t lun;
}lba_app_struct_t;
//extern void USB_Class_Periodic_Task(void);
#define USB_MSC_Periodic_Task USB_Class_Periodic_Task
diff --git a/KSDK_1.2.0/usb/usb_core/device/sources/classes/msd/usb_msc.c b/KSDK_1.2.0/usb/usb_core/device/sources/classes/msd/usb_msc.c
index e29bca8..8f0f048 100644
--- a/KSDK_1.2.0/usb/usb_core/device/sources/classes/msd/usb_msc.c
+++ b/KSDK_1.2.0/usb/usb_core/device/sources/classes/msd/usb_msc.c
@@ -487,6 +487,7 @@ void USB_Service_Bulk_Out(usb_event_struct_t* event,void* arg)
|| (WRITE_12_COMMAND == msc_obj_ptr->cbw_ptr->command_block[0])))
{
lba_app_struct_t lba_data1;
+ lba_data1.lun = cbw_ptr->lun;
lba_data1.offset = 0;
lba_data1.size = 0;
lba_data1.buff_ptr = msc_obj_ptr->msd_buff.msc_bulk_out_ptr;
@@ -1032,6 +1033,8 @@ void* arg
)
{
/* return the maximum number of logical units supported */
+ USB_PRINTF("lun was %d\r\n", msc_dev_ptr->lun);
+ msc_dev_ptr->lun = 4;
*data = &msc_dev_ptr->lun;
*size= (uint32_t)setup_packet->length;
msc_dev_ptr->re_stall_flag = TRUE;
diff --git a/laser-tag software/CMakeLists.txt b/laser-tag software/CMakeLists.txt
index 6fac7c7..3034ecc 100644
--- a/laser-tag software/CMakeLists.txt
+++ b/laser-tag software/CMakeLists.txt
@@ -84,6 +84,7 @@ IF(CMAKE_BUILD_TYPE MATCHES Debug)
INCLUDE_DIRECTORIES(${ProjDirPath}/../KSDK_1.2.0/platform/drivers/inc)
INCLUDE_DIRECTORIES(${ProjDirPath}/../KSDK_1.2.0/platform/system/inc)
INCLUDE_DIRECTORIES(${ProjDirPath}/../KSDK_1.2.0/platform/utilities/inc)
+ INCLUDE_DIRECTORIES(${ProjDirPath}/../KSDK_1.2.0/platform/drivers/src/flash/C90TFS/drvsrc/include)
INCLUDE_DIRECTORIES(${ProjDirPath}/.)
ELSEIF(CMAKE_BUILD_TYPE MATCHES Release)
INCLUDE_DIRECTORIES(${ProjDirPath}/../KSDK_1.2.0/platform/osa/inc)
@@ -108,6 +109,7 @@ ELSEIF(CMAKE_BUILD_TYPE MATCHES Release)
INCLUDE_DIRECTORIES(${ProjDirPath}/../KSDK_1.2.0/platform/drivers/inc)
INCLUDE_DIRECTORIES(${ProjDirPath}/../KSDK_1.2.0/platform/system/inc)
INCLUDE_DIRECTORIES(${ProjDirPath}/../KSDK_1.2.0/platform/utilities/inc)
+ INCLUDE_DIRECTORIES(${ProjDirPath}/../KSDK_1.2.0/platform/drivers/src/flash/C90TFS/drvsrc/include)
INCLUDE_DIRECTORIES(${ProjDirPath}/.)
ENDIF()
@@ -126,6 +128,42 @@ ADD_EXECUTABLE(hello_world
"${ProjDirPath}/../KSDK_1.2.0/platform/drivers/src/lptmr/fsl_lptmr_irq.c"
"${ProjDirPath}/../KSDK_1.2.0/platform/drivers/src/lpuart/fsl_lpuart_irq.c"
"${ProjDirPath}/../KSDK_1.2.0/platform/drivers/src/spi/fsl_spi_irq.c"
+ "${ProjDirPath}/../KSDK_1.2.0/platform/drivers/src/flash/C90TFS/drvsrc/source/CopyToRam.c"
+ "${ProjDirPath}/../KSDK_1.2.0/platform/drivers/src/flash/C90TFS/drvsrc/source/DEFlashPartition.c"
+ "${ProjDirPath}/../KSDK_1.2.0/platform/drivers/src/flash/C90TFS/drvsrc/source/DFlashGetProtection.c"
+ "${ProjDirPath}/../KSDK_1.2.0/platform/drivers/src/flash/C90TFS/drvsrc/source/DFlashSetProtection.c"
+ "${ProjDirPath}/../KSDK_1.2.0/platform/drivers/src/flash/C90TFS/drvsrc/source/EEEWrite.c"
+ "${ProjDirPath}/../KSDK_1.2.0/platform/drivers/src/flash/C90TFS/drvsrc/source/EERAMGetProtection.c"
+ "${ProjDirPath}/../KSDK_1.2.0/platform/drivers/src/flash/C90TFS/drvsrc/source/EERAMSetProtection.c"
+ "${ProjDirPath}/../KSDK_1.2.0/platform/drivers/src/flash/C90TFS/drvsrc/source/FlashCheckSum.c"
+ "${ProjDirPath}/../KSDK_1.2.0/platform/drivers/src/flash/C90TFS/drvsrc/source/FlashCommandSequence.c"
+ "${ProjDirPath}/../KSDK_1.2.0/platform/drivers/src/flash/C90TFS/drvsrc/source/FlashEraseAllBlock.c"
+ "${ProjDirPath}/../KSDK_1.2.0/platform/drivers/src/flash/C90TFS/drvsrc/source/FlashEraseBlock.c"
+ "${ProjDirPath}/../KSDK_1.2.0/platform/drivers/src/flash/C90TFS/drvsrc/source/FlashEraseResume.c"
+ "${ProjDirPath}/../KSDK_1.2.0/platform/drivers/src/flash/C90TFS/drvsrc/source/FlashEraseSector.c"
+ "${ProjDirPath}/../KSDK_1.2.0/platform/drivers/src/flash/C90TFS/drvsrc/source/FlashEraseSuspend.c"
+ "${ProjDirPath}/../KSDK_1.2.0/platform/drivers/src/flash/C90TFS/drvsrc/source/FlashGetSecurityState.c"
+ "${ProjDirPath}/../KSDK_1.2.0/platform/drivers/src/flash/C90TFS/drvsrc/source/FlashInit.c"
+ "${ProjDirPath}/../KSDK_1.2.0/platform/drivers/src/flash/C90TFS/drvsrc/source/FlashProgram.c"
+ "${ProjDirPath}/../KSDK_1.2.0/platform/drivers/src/flash/C90TFS/drvsrc/source/FlashProgramCheck.c"
+ "${ProjDirPath}/../KSDK_1.2.0/platform/drivers/src/flash/C90TFS/drvsrc/source/FlashProgramOnce.c"
+ "${ProjDirPath}/../KSDK_1.2.0/platform/drivers/src/flash/C90TFS/drvsrc/source/FlashProgramSection.c"
+ "${ProjDirPath}/../KSDK_1.2.0/platform/drivers/src/flash/C90TFS/drvsrc/source/FlashReadOnce.c"
+ "${ProjDirPath}/../KSDK_1.2.0/platform/drivers/src/flash/C90TFS/drvsrc/source/FlashReadResource.c"
+ "${ProjDirPath}/../KSDK_1.2.0/platform/drivers/src/flash/C90TFS/drvsrc/source/FlashSecurityBypass.c"
+ "${ProjDirPath}/../KSDK_1.2.0/platform/drivers/src/flash/C90TFS/drvsrc/source/FlashVerifyAllBlock.c"
+ "${ProjDirPath}/../KSDK_1.2.0/platform/drivers/src/flash/C90TFS/drvsrc/source/FlashVerifyBlock.c"
+ "${ProjDirPath}/../KSDK_1.2.0/platform/drivers/src/flash/C90TFS/drvsrc/source/FlashVerifySection.c"
+ "${ProjDirPath}/../KSDK_1.2.0/platform/drivers/src/flash/C90TFS/drvsrc/source/PFlashGetProtection.c"
+ "${ProjDirPath}/../KSDK_1.2.0/platform/drivers/src/flash/C90TFS/drvsrc/source/PFlashSetProtection.c"
+ "${ProjDirPath}/../KSDK_1.2.0/platform/drivers/src/flash/C90TFS/drvsrc/source/PFlashSwap.c"
+ "${ProjDirPath}/../KSDK_1.2.0/platform/drivers/src/flash/C90TFS/drvsrc/source/PFlashSwapCtl.c"
+ "${ProjDirPath}/../KSDK_1.2.0/platform/drivers/src/flash/C90TFS/drvsrc/source/SetEEEEnable.c"
+ "${ProjDirPath}/../KSDK_1.2.0/platform/drivers/src/flash/C90TFS/drvsrc/include/FTFx_KX_flash_config.h"
+ "${ProjDirPath}/../KSDK_1.2.0/platform/drivers/src/flash/C90TFS/drvsrc/include/SSD_FTFx.h"
+ "${ProjDirPath}/../KSDK_1.2.0/platform/drivers/src/flash/C90TFS/drvsrc/include/SSD_FTFx_Common.h"
+ "${ProjDirPath}/../KSDK_1.2.0/platform/drivers/src/flash/C90TFS/drvsrc/include/SSD_FTFx_Internal.h"
+ "${ProjDirPath}/../KSDK_1.2.0/platform/drivers/src/flash/C90TFS/drvsrc/include/SSD_Types.h"
"${ProjDirPath}/main.c"
"${ProjDirPath}/epaper.c"
"${ProjDirPath}/epaper.h"
@@ -138,6 +176,8 @@ ADD_EXECUTABLE(hello_world
"${ProjDirPath}/disk.h"
"${ProjDirPath}/usb_descriptor.c"
"${ProjDirPath}/usb_descriptor.h"
+ "${ProjDirPath}/flash.c"
+ "${ProjDirPath}/flash.h"
)
SET_TARGET_PROPERTIES(hello_world PROPERTIES OUTPUT_NAME "hello_world.elf")
diff --git a/laser-tag software/disk.c b/laser-tag software/disk.c
index 5a89d66..275f63d 100644
--- a/laser-tag software/disk.c
+++ b/laser-tag software/disk.c
@@ -181,6 +181,7 @@ uint8_t USB_App_Class_Callback
case USB_DEV_EVENT_DATA_RECEIVED:
/* Add User defined code -- if required*/
lba_data_ptr = (lba_app_struct_t*) size;
+ USB_PRINTF("DATA_RECEIVED for lun %d\r\n", lba_data_ptr->lun);
break;
case USB_DEV_EVENT_SEND_COMPLETE:
/* Add User defined code -- if required*/
diff --git a/laser-tag software/disk.h b/laser-tag software/disk.h
index eb30314..3c72dd5 100644
--- a/laser-tag software/disk.h
+++ b/laser-tag software/disk.h
@@ -47,27 +47,18 @@
#define RAM_DISK_APP (1)
#define SD_CARD_APP (0)
-#if RAM_DISK_APP
- /* Length of Each Logical Address Block */
- #define LENGTH_OF_EACH_LAB (512)
- /* total number of logical blocks present */
- #define TOTAL_LOGICAL_ADDRESS_BLOCKS_NORMAL (8)
- /* Net Disk Size */
- #define DISK_SIZE_NORMAL (TOTAL_LOGICAL_ADDRESS_BLOCKS_NORMAL * LENGTH_OF_EACH_LAB)
-#endif
+/* Length of Each Logical Address Block */
+#define LENGTH_OF_EACH_LAB (512)
+/* total number of logical blocks present */
+#define TOTAL_LOGICAL_ADDRESS_BLOCKS_NORMAL (8)
+/* Net Disk Size */
+#define DISK_SIZE_NORMAL (TOTAL_LOGICAL_ADDRESS_BLOCKS_NORMAL * LENGTH_OF_EACH_LAB)
-#define LOGICAL_UNIT_SUPPORTED (1)
+#define LOGICAL_UNIT_SUPPORTED (5)
#define SUPPORT_DISK_LOCKING_MECHANISM (0) /*1: TRUE; 0:FALSE*/
-#if SD_CARD_APP
- #define MUTILE_BUFFER (1)
-#endif
-#if MUTILE_BUFFER
- #define MSD_RECV_BUFFER_NUM (2)
- #else
- #define MSD_RECV_BUFFER_NUM (1)
-#endif
+#define MSD_RECV_BUFFER_NUM (1)
#define MSD_RECV_BUFFER_SIZE (512)
#define MSD_SEND_BUFFER_SIZE (512)
/*****************************************************************************
diff --git a/laser-tag software/flash.c b/laser-tag software/flash.c
new file mode 100644
index 0000000..f1e2a93
--- /dev/null
+++ b/laser-tag software/flash.c
@@ -0,0 +1,38 @@
+#include <stdint.h>
+#include "flash.h"
+#include "fsl_debug_console.h"
+#include "SSD_FTFx.h"
+
+FLASH_SSD_CONFIG flash_config = {
+ .ftfxRegBase = FTFA_BASE,
+ .PFlashBase = 0x00000000,
+ .PFlashSize = FSL_FEATURE_FLASH_PFLASH_BLOCK_SIZE
+ * FSL_FEATURE_FLASH_PFLASH_BLOCK_COUNT,
+ .DFlashBase = 0,
+ .DFlashSize = 0,
+ .EERAMBase = 0,
+ .EEESize = 0,
+ .DebugEnable = 0,
+ .CallBack = NULL_CALLBACK,
+};
+
+uint8_t ram_fn[0x30];
+pFLASHCOMMANDSEQUENCE pFlashCommandSequence;
+
+int flash_init()
+{
+ uint32_t rc;
+
+ rc = FlashInit(&flash_config);
+ debug_printf("FlashInit returned %u\r\n", rc);
+ if (FTFx_OK != rc) {
+ return -1;
+ }
+ pFlashCommandSequence = (pFLASHCOMMANDSEQUENCE)RelocateFunction(
+ (intptr_t)ram_fn,
+ sizeof ram_fn,
+ (intptr_t)FlashCommandSequence);
+ return 0;
+}
+
+/* vim: set expandtab ts=4 sw=4: */
diff --git a/laser-tag software/flash.h b/laser-tag software/flash.h
new file mode 100644
index 0000000..a5c06f1
--- /dev/null
+++ b/laser-tag software/flash.h
@@ -0,0 +1,6 @@
+#ifndef _FLASH_H_
+#define _FLASH_H_
+
+int flash_init();
+
+#endif
diff --git a/laser-tag software/main.c b/laser-tag software/main.c
index becf2ca..ba39001 100644
--- a/laser-tag software/main.c
+++ b/laser-tag software/main.c
@@ -31,6 +31,7 @@
#include "disk.h"
#include "epaper.h"
+#include "flash.h"
#include "fsl_clock_manager.h"
#include "fsl_cmp_driver.h"
#include "fsl_dac_driver.h"
@@ -599,6 +600,9 @@ int main (void)
led(0x22, 0x00, 0x22);
}
+ /* Initialize flash stuff */
+ flash_init();
+
/* No good can come of this */
disk_init(images[2]);