diff --git a/lib/sdk/Applications/EvKitExamples/BLE_beacon/Makefile b/lib/sdk/Applications/EvKitExamples/BLE_beacon/Makefile index c2f673bc244056b300183de64a87890fee05e883..1387fc459860ce66db4aef8769d569d4c384372f 100644 --- a/lib/sdk/Applications/EvKitExamples/BLE_beacon/Makefile +++ b/lib/sdk/Applications/EvKitExamples/BLE_beacon/Makefile @@ -199,7 +199,6 @@ PROJ_CFLAGS+=-DMXC_ASSERT_ENABLE=TRUE PROJ_CFLAGS+=-DWSF_ASSERT_ENABLED=TRUE # PROJ_CFLAGS+=-DLL_TRACE_ENABLED=TRUE # PROJ_CFLAGS+=-DLL_DBG_PIN_ENABLED=TRUE -PROJ_CFLAGS+=-DWSF_MS_PER_TICK=1 #-------------------- @@ -213,6 +212,7 @@ PROJ_CFLAGS+=-DINIT_BROADCASTER # PROJ_CFLAGS+=-DINIT_CENTRAL PROJ_CFLAGS+=-DINIT_PERIPHERAL PROJ_CFLAGS+=-DINIT_ENCRYPTED +PROJ_CFLAGS+=-DINIT_PHY ENABLE_LL_TESTER?=#1 diff --git a/lib/sdk/Applications/EvKitExamples/BLE_beacon/main.c b/lib/sdk/Applications/EvKitExamples/BLE_beacon/main.c index 565782b1c1f8e25c92318fdf3d7af1082b2e7cd9..4379c228f8e7784de6a46e50138480d6c70515b2 100644 --- a/lib/sdk/Applications/EvKitExamples/BLE_beacon/main.c +++ b/lib/sdk/Applications/EvKitExamples/BLE_beacon/main.c @@ -90,16 +90,10 @@ static wsfBufPoolDesc_t mainPoolDesc[WSF_BUF_POOLS] = /*! \brief Stack initialization for app. */ extern void StackInitBeacon(void); -/*************************************************************************************************/ -void PalSysAssertTrap(void) -{ - while(1) {} -} - /*************************************************************************************************/ void SysTick_Handler(void) { - WsfTimerUpdate(1); + WsfTimerUpdate(WSF_MS_PER_TICK); } /*************************************************************************************************/ diff --git a/lib/sdk/Applications/EvKitExamples/BLE_datc/Makefile b/lib/sdk/Applications/EvKitExamples/BLE_datc/Makefile index b198857f3a1c7b7d4cd8c647fda33211d2a0dbe9..e91282b77ed0832cda4821d045e748361e9e4040 100644 --- a/lib/sdk/Applications/EvKitExamples/BLE_datc/Makefile +++ b/lib/sdk/Applications/EvKitExamples/BLE_datc/Makefile @@ -43,6 +43,12 @@ ifeq "$(PROJECT)" "" PROJECT=max32665 endif +# Build directory for image that peer will be udpated with +FW_UPDATE_DIR=../BLE_dats + +# Firmware update files, do not rename +FW_UPDATE_BIN=fw_update.bin + # Specify the target processor ifeq "$(TARGET)" "" TARGET=MAX32665 @@ -72,6 +78,7 @@ endif # This is the path to the CMSIS root directory ifeq "$(MAXIM_PATH)" "" LIBS_DIR=../../../Libraries +NDALIBS_DIR=../../../NDALibraries else LIBS_DIR=/$(subst \,/,$(subst :,,$(MAXIM_PATH))/Firmware/$(TARGET_UC)/Libraries) endif @@ -176,6 +183,30 @@ PROJ_CFLAGS+=-DCONSOLE_UART=$(CONSOLE_UART) endif endif +ifdef ENABLE_WDX +ifneq "$(ENABLE_WDX)" "" +ifneq "$(ENABLE_WDX)" "0" +PROJ_CFLAGS+=-DWDXC_INCLUDED=TRUE +PROJ_CFLAGS+=-DWDXS_INCLUDED=TRUE +# PROJ_CFLAGS+=-DWSF_TRACE_ENABLED=TRUE + +# Include bin file for firmware update image +BINS+=${FW_UPDATE_BIN} + +# Target for creating the fw_update bin file +${FW_UPDATE_BIN}: + $(MAKE) -C ${FW_UPDATE_DIR} + $(MAKE) -C ${FW_UPDATE_DIR} build/${PROJECT}.bin + @cp ${FW_UPDATE_DIR}/build/${PROJECT}.bin ${FW_UPDATE_BIN} + +myclean: + @rm -f ${FW_UPDATE_BIN} + +clean: myclean +endif +endif +endif + ifdef ENABLE_SDMA ifneq "$(ENABLE_SDMA)" "" ifeq "$(ENABLE_SDMA)" "0" @@ -214,7 +245,6 @@ PROJ_CFLAGS+=-DMXC_ASSERT_ENABLE=TRUE PROJ_CFLAGS+=-DWSF_ASSERT_ENABLED=TRUE # PROJ_CFLAGS+=-DLL_TRACE_ENABLED=TRUE # PROJ_CFLAGS+=-DLL_DBG_PIN_ENABLED=TRUE -PROJ_CFLAGS+=-DWSF_MS_PER_TICK=1 #-------------------- @@ -228,6 +258,7 @@ PROJ_CFLAGS+=-DINIT_OBSERVER PROJ_CFLAGS+=-DINIT_CENTRAL # PROJ_CFLAGS+=-DINIT_PERIPHERAL PROJ_CFLAGS+=-DINIT_ENCRYPTED +PROJ_CFLAGS+=-DINIT_PHY ENABLE_LL_TESTER?=#1 diff --git a/lib/sdk/Applications/EvKitExamples/BLE_datc/config.mk b/lib/sdk/Applications/EvKitExamples/BLE_datc/config.mk index aa1167fbd9132691051c58335ece4854921f9f5a..1cda8c842db6fcf242fff97f599caa00204b0b1d 100644 --- a/lib/sdk/Applications/EvKitExamples/BLE_datc/config.mk +++ b/lib/sdk/Applications/EvKitExamples/BLE_datc/config.mk @@ -15,3 +15,6 @@ BTLE_APP_ENABLE_WHITELIST?=0 # Run link layer using SDMA. ENABLE_SDMA?=0 + +# Enable file transfer profile +ENABLE_WDX?=0 diff --git a/lib/sdk/Applications/EvKitExamples/BLE_datc/datc_main.c b/lib/sdk/Applications/EvKitExamples/BLE_datc/datc_main.c index bccef2e6a302c27db89572e50376d09c1c51b79a..ea9786f2ff89a543d6551b91f4b14f0e22d0c0b1 100644 --- a/lib/sdk/Applications/EvKitExamples/BLE_datc/datc_main.c +++ b/lib/sdk/Applications/EvKitExamples/BLE_datc/datc_main.c @@ -38,11 +38,20 @@ #include "app_ui.h" #include "svc_core.h" #include "svc_ch.h" +#include "hci_vs.h" #include "gatt/gatt_api.h" #include "wpc/wpc_api.h" #include "datc/datc_api.h" #include "util/calc128.h" #include "gcr_regs.h" +#include "ll_defs.h" +#include "tmr_utils.h" +#if WDXC_INCLUDED == TRUE +#include "wsf_efs.h" +#include "wdxc/wdxc_api.h" +#include "wdx_defs.h" +#include "hash.h" +#endif /* WDXC_INCLUDED */ /************************************************************************************************** Macros @@ -50,6 +59,37 @@ Macros #define TEST_TIMER_IND 0x99 +#if WDXC_INCLUDED == TRUE +/* Size of WDXC file discovery dataset */ +#define DATC_WDXC_MAX_FILES 4 + +/*! WSF message event starting value */ +#define DATC_MSG_START 0xA0 + +/*! Data rate timer period in seconds */ +#define DATC_WDXS_DATA_RATE_TIMEOUT 4 + +/* Pointer for accessing the fw_update image*/ +uint8_t *fileData; + +extern uint32_t _binary_fw_update_bin_start; +extern uint32_t _binary_fw_update_bin_end; +extern uint32_t _binary_fw_update_bin_size; + +#define FILE_SIZE (uint32_t)&_binary_fw_update_bin_size +#define BLOCK_OFFSET_INIT 0x0 +#define BLOCK_SIZE 224 +#define SHA256_BYTES (256/8) + +char fileHashDigest[SHA256_BYTES]; + +/*! WSF message event enumeration */ +enum +{ + DATC_WDXS_DATA_RATE_TIMER_IND = DATC_MSG_START, /*! Data rate timer expired */ +}; +#endif /* WDXC_INCLUDED */ + /************************************************************************************************** Local Variables **************************************************************************************************/ @@ -63,6 +103,13 @@ struct bool_t autoConnectSync; /*! TRUE if auto-connecting */ uint8_t discState[DM_CONN_MAX]; /*! Service discovery state */ uint8_t hdlListLen; /*! Cached handle list length */ + uint8_t btnConnId; /*! The index of the connection ID for button presses */ +#if WDXC_INCLUDED == TRUE + bool_t sendingFile[DM_CONN_MAX]; + bool_t fileVerified[DM_CONN_MAX]; + uint32_t blockOffset[DM_CONN_MAX]; + wsfEfsFileInfo_t fileList[DM_CONN_MAX][DATC_WDXC_MAX_FILES]; /* Buffer to hold WDXC file list */ +#endif /* WDXC_INCLUDED */ } datcCb; /*! connection control block */ @@ -206,7 +253,7 @@ static const hciConnSpec_t datcConnCfg = 0, /*! Connection latency */ 600, /*! Supervision timeout in 10ms units */ 0, /*! Minimum CE length, in 0.625 ms units */ - 16 /*! Maximum CE length, in 0.625 ms units */ + 0 /*! Maximum CE length, in 0.625 ms units */ }; /*! Configurable parameters for service and characteristic discovery */ @@ -225,8 +272,12 @@ static const appCfg_t datcAppCfg = static const attCfg_t datcAttCfg = { 15, /* ATT server service discovery connection idle timeout in seconds */ - 300, /* desired ATT MTU */ - ATT_MAX_TRANS_TIMEOUT, /* transaction timeout in seconds */ +#if WDXC_INCLUDED == TRUE + 241, /* desired ATT MTU */ +#else + 23, /* desired ATT MTU */ +#endif /* WDXC_INCLUDED */ + ATT_MAX_TRANS_TIMEOUT, /* transcation timeout in seconds */ 4 /* number of queued prepare writes supported by server */ }; @@ -246,6 +297,9 @@ enum DATC_DISC_GATT_SVC, /*! GATT service */ DATC_DISC_GAP_SVC, /*! GAP service */ DATC_DISC_WP_SVC, /*! ARM Ltd. proprietary service */ +#if WDXC_INCLUDED == TRUE + DATC_DISC_WDXC_SCV, /*! ARM Ltd. Wireless Data Exchange service */ +#endif /* WDXC_INCLUDED */ DATC_DISC_SVC_MAX /*! Discovery complete */ }; @@ -269,12 +323,20 @@ enum #define DATC_DISC_GATT_START 0 #define DATC_DISC_GAP_START (DATC_DISC_GATT_START + GATT_HDL_LIST_LEN) #define DATC_DISC_WP_START (DATC_DISC_GAP_START + GAP_HDL_LIST_LEN) +#if WDXC_INCLUDED == TRUE +#define DATC_DISC_WDXC_START (DATC_DISC_WP_START + WPC_P1_HDL_LIST_LEN) +#define DATC_DISC_HDL_LIST_LEN (DATC_DISC_WDXC_START + WDXC_HDL_LIST_LEN) +#else #define DATC_DISC_HDL_LIST_LEN (DATC_DISC_WP_START + WPC_P1_HDL_LIST_LEN) +#endif /* WDXC_INCLUDED */ /*! Pointers into handle list for each service's handles */ static uint16_t *pDatcGattHdlList[DM_CONN_MAX]; static uint16_t *pDatcGapHdlList[DM_CONN_MAX]; static uint16_t *pDatcWpHdlList[DM_CONN_MAX]; +#if WDXC_INCLUDED == TRUE +static uint16_t *pDatcWdxHdlList[DM_CONN_MAX]; +#endif /* WDXC_INCLUDED */ /* LESC OOB configuration */ static dmSecLescOobCfg_t *datcOobCfg; @@ -301,6 +363,14 @@ static const attcDiscCfg_t datcDiscCfgList[] = /* Write: Proprietary data service changed ccc descriptor */ {datcCccNtfVal, sizeof(datcCccNtfVal), (WPC_P1_NA_CCC_HDL_IDX + DATC_DISC_WP_START)}, + +#if WDXC_INCLUDED == TRUE + /* Write: WDXC ccc descriptors */ + {datcCccNtfVal, sizeof(datcCccNtfVal), (WDXC_DC_CCC_HDL_IDX + DATC_DISC_WDXC_START)}, + {datcCccNtfVal, sizeof(datcCccNtfVal), (WDXC_FTC_CCC_HDL_IDX + DATC_DISC_WDXC_START)}, + {datcCccNtfVal, sizeof(datcCccNtfVal), (WDXC_FTD_CCC_HDL_IDX + DATC_DISC_WDXC_START)}, + {datcCccNtfVal, sizeof(datcCccNtfVal), (WDXC_AU_CCC_HDL_IDX + DATC_DISC_WDXC_START)}, +#endif /* WDXC_INCLUDED */ }; /* Characteristic configuration list length */ @@ -655,12 +725,6 @@ static void datcExtScanReport(dmEvt_t *pMsg) pMsg->extScanReport.directAddr[0]); } - //printf(" priPhy %u,", pMsg->extScanReport.priPhy); - //printf(" secPhy %u,", pMsg->extScanReport.secPhy); - //printf(" advSid 0x%02x,", pMsg->extScanReport.advSid); - //printf(" txPower %i,", pMsg->extScanReport.txPower); - //printf(" perAdvInter %i,", pMsg->extScanReport.perAdvInter); - //printf(" directAddrType %x,", pMsg->extScanReport.directAddrType); printf(" len %u, rssi %d, evtType %x, addrType %x", pMsg->extScanReport.len, pMsg->extScanReport.rssi, pMsg->extScanReport.eventType, pMsg->extScanReport.addrType); /* search for the friendly name. */ @@ -954,8 +1018,10 @@ static void datcClose(dmEvt_t *pMsg) /*************************************************************************************************/ static void datcValueNtf(attEvt_t *pMsg) { +#if WDXC_INCLUDED == FALSE /* print the received data */ printf("%s\n", pMsg->pValue); +#endif /* WDXC_INCLUDED */ } /*************************************************************************************************/ @@ -1019,6 +1085,137 @@ static void datcDiscGapCmpl(dmConnId_t connId) } } +#if WDXC_INCLUDED == TRUE + +/*************************************************************************************************/ +/*! + * \brief WDXC File Transfer Data Callback. + * + * \param connId Connection ID. + * \param fileHdl Handle of the file. + * \param len length of pData in bytes. + * \param pData File data. + * + * \return None. + */ +/*************************************************************************************************/ +static void datcWdxcFtdCallback(dmConnId_t connId, uint16_t fileHdl, uint16_t len, uint8_t *pData) +{ + +} + +/*************************************************************************************************/ +/*! + * \brief WDXC File Transfer Control Callback. + * + * \param connId Connection ID. + * \param op Control operation. + * \param status Status of operation. + * + * \return None. + */ +/*************************************************************************************************/ +static void datcWdxcFtcCallback(dmConnId_t connId, uint16_t handle, uint8_t op, uint8_t status) +{ + + if(status != WDX_FTC_ST_SUCCESS) { + APP_TRACE_INFO1("Error with FTC Operation status: %d", status); + } + + if (op == WDX_FTC_OP_PUT_RSP) + { + /* Start timer */ + printf(">>> Starting file transfer <<<\n"); + + TMR_SW_Start(MXC_TMR1, NULL); + datcCb.sendingFile[connId - 1] = TRUE; + WdxcFtdSendBlock(connId, BLOCK_SIZE, (uint8_t*)&fileData[datcCb.blockOffset[connId - 1] - BLOCK_OFFSET_INIT]); + datcCb.blockOffset[connId - 1] += BLOCK_SIZE; + } + else if (op == WDX_FTC_OP_EOF) + { + if(handle == WDX_FLIST_HANDLE) { + /* File discovery complete */ + printf(">>> File discovery complete <<<\n"); + + } else { + /* Stop timer, calculate time and Bps */ + uint32_t usec = TMR_SW_Stop(MXC_TMR1); + printf(">>> File transfer complete %d us <<<\n", usec); + printf("file_size = %d usec = %d Bps = %d\n", FILE_SIZE, usec, ((FILE_SIZE*1000)/(usec / 1000))); + datcCb.sendingFile[connId - 1] = FALSE; + } + } else if (op == WDX_FTC_OP_VERIFY_RSP) { + printf(">>> Verify complete status: %d <<<\n", status); + datcCb.fileVerified[connId - 1] = TRUE; + } + +} +#endif /* WDXC_INCLUDED */ + +/*************************************************************************************************/ +/*! + * \brief Button press callback. + * + * \param btn Button press. + * + * \return None. + */ +/*************************************************************************************************/ +static void datcBtnCback(uint8_t btn) +{ +#if WDXC_INCLUDED == TRUE + dmConnId_t connIdList[DM_CONN_MAX]; + uint8_t numConnections = AppConnOpenList(connIdList); + dmConnId_t connId = datcCb.btnConnId; + + /* button actions when connected */ + if (numConnections > 0) + { + switch (btn) + { + case APP_UI_BTN_2_MED: + if ((datcCb.discState[connId - 1] > DATC_DISC_WDXC_SCV) && + (datcCb.sendingFile[connId - 1] == FALSE)) + { + /* Start the WDXC data stream */ + datcCb.blockOffset[connId - 1] = BLOCK_OFFSET_INIT; + WdxcFtcSendPutReq(connId, datcCb.fileList[connId - 1][0].handle, BLOCK_OFFSET_INIT, FILE_SIZE+SHA256_BYTES, + BLOCK_OFFSET_INIT+FILE_SIZE+SHA256_BYTES, 0); + } + break; + + case APP_UI_BTN_2_SHORT: + if (datcCb.discState[connId - 1] > DATC_DISC_WDXC_SCV) + { + WdxcDiscoverFiles(connId, datcCb.fileList[connId - 1], DATC_WDXC_MAX_FILES); + } + break; + + case APP_UI_BTN_2_LONG: + if (datcCb.discState[connId - 1] > DATC_DISC_WDXC_SCV) + { + /* Send verification request */ + WdxcFtcSendVerifyFile(connId, datcCb.fileList[connId - 1][0].handle); + } + break; + + case APP_UI_BTN_2_EX_LONG: + if (datcCb.fileVerified[connId - 1]) + { + /* Send Disconnect and Reset request to apply firmware update */ + WdxcDcSendDisconnectAndReset(connId); + datcCb.fileVerified[connId - 1] = FALSE; + } + break; + + default: + break; + } + } +#endif /* WDXC_INCLUDED */ +} + /*************************************************************************************************/ /*! * \brief Discovery callback. @@ -1077,6 +1274,12 @@ static void datcDiscCback(dmConnId_t connId, uint8_t status) /* discover proprietary data service */ WpcP1Discover(connId, pDatcWpHdlList[connId-1]); } +#if WDXC_INCLUDED == TRUE + else if (datcCb.discState[connId-1] == DATC_DISC_WDXC_SCV) + { + WdxcWdxsDiscover(connId, pDatcWdxHdlList[connId-1]); + } +#endif /* WDXC_INCLUDED */ else { /* discovery complete */ @@ -1088,6 +1291,9 @@ static void datcDiscCback(dmConnId_t connId, uint8_t status) /* start configuration */ AppDiscConfigure(connId, APP_DISC_CFG_START, DATC_DISC_CFG_LIST_LEN, (attcDiscCfg_t *) datcDiscCfgList, DATC_DISC_HDL_LIST_LEN, datcCb.hdlList[connId-1]); + + /* Update the data length */ + DmConnSetDataLen(connId, LL_MAX_DATA_LEN_ABS_MAX, LL_MAX_DATA_TIME_ABS_MAX_1M); } break; @@ -1155,30 +1361,40 @@ static void testTimerHandler(void) { datcSendData(testCb.connId); DmConnReadRssi(testCb.connId); + HciVsGetConnStats(); } if ((((testCb.counter - testCb.connectCount) % 10) == 0) && (testCb.connId != DM_CONN_ID_NONE) && (datcCb.discState[testCb.connId-1] == DATC_DISC_SVC_MAX)) { - if(testCb.phy == HCI_PHY_LE_2M_BIT) { - /* Change from 1M to 2M PHY */ - testCb.phy = HCI_PHY_LE_1M_BIT; - } else if (testCb.phy == HCI_PHY_LE_1M_BIT) { - - /* Change to the coded PHY if we're not using A1 */ - if(MXC_GCR->revision != 0xA1) { - testCb.phy = HCI_PHY_LE_CODED_BIT; + +#if WDXC_INCLUDED == TRUE + if(datcCb.sendingFile[testCb.connId-1] != TRUE) { +#endif + + if(testCb.phy == HCI_PHY_LE_2M_BIT) { + /* Change from 1M to 2M PHY */ + testCb.phy = HCI_PHY_LE_1M_BIT; + } else if (testCb.phy == HCI_PHY_LE_1M_BIT) { + + /* Change to the coded PHY if we're not using A1 */ + if(MXC_GCR->revision != 0xA1) { + testCb.phy = HCI_PHY_LE_CODED_BIT; + } else { + testCb.phy = HCI_PHY_LE_2M_BIT; + } + } else { + /* Change to 2M PHY */ testCb.phy = HCI_PHY_LE_2M_BIT; } - } else { - /* Change to 2M PHY */ - testCb.phy = HCI_PHY_LE_2M_BIT; - } + DmSetPhy(testCb.connId, 0, testCb.phy, testCb.phy, 0); - DmSetPhy(testCb.connId, 0, testCb.phy, testCb.phy, 0); + #if WDXC_INCLUDED == TRUE + } + #endif } WsfTimerStartMs(&testCb.timer, 1000); @@ -1204,7 +1420,50 @@ static void datcProcMsg(dmEvt_t *pMsg) break; case ATTC_WRITE_CMD_RSP: + { +#if WDXC_INCLUDED == TRUE + + dmConnId_t connId = (dmConnId_t) pMsg->hdr.param; + + if ((((attEvt_t *) pMsg)->hdr.status == ATT_SUCCESS) && + (((attEvt_t *) pMsg)->handle == pDatcWdxHdlList[connId-1][WDXC_FTD_HDL_IDX])) { + + if(datcCb.sendingFile[connId - 1] == TRUE) { + + APP_TRACE_INFO1("blockOffset = 0x%x", datcCb.blockOffset[connId - 1]); + + if(datcCb.blockOffset[connId - 1] >= FILE_SIZE) { + uint32_t blockSize; + if((datcCb.blockOffset[connId - 1] + BLOCK_SIZE) > (FILE_SIZE + SHA256_BYTES)) { + blockSize = FILE_SIZE + SHA256_BYTES - datcCb.blockOffset[connId - 1]; + } else { + blockSize = BLOCK_SIZE; + } + + /* Write the hash digest */ + WdxcFtdSendBlock(connId, blockSize, (uint8_t*)&fileHashDigest[datcCb.blockOffset[connId - 1] - FILE_SIZE]); + datcCb.blockOffset[connId - 1] += blockSize; + + } else { + uint32_t blockSize; + if((datcCb.blockOffset[connId - 1] + BLOCK_SIZE) > FILE_SIZE) { + blockSize = FILE_SIZE - datcCb.blockOffset[connId - 1]; + } else { + blockSize = BLOCK_SIZE; + } + + /* Keep writing the file */ + WdxcFtdSendBlock(connId, blockSize, (uint8_t*)&fileData[datcCb.blockOffset[connId - 1] - BLOCK_OFFSET_INIT]); + datcCb.blockOffset[connId - 1] += blockSize; + } + } + } +#endif break; + } + + case ATTC_WRITE_RSP: + break; case DM_RESET_CMPL_IND: DmSecGenerateEccKeyReq(); @@ -1383,6 +1642,7 @@ void DatcHandlerInit(wsfHandlerId_t handlerId) /* set handle list length */ datcCb.hdlListLen = DATC_DISC_HDL_LIST_LEN; + datcCb.btnConnId = 1; /* Set configuration pointers */ #ifdef BTLE_APP_USE_LEGACY_API pAppMasterCfg = (appMasterCfg_t *) &datcMasterCfg; @@ -1401,6 +1661,26 @@ void DatcHandlerInit(wsfHandlerId_t handlerId) /* Set IRK for the local device */ DmSecSetLocalIrk(localIrk); + +#if WDXC_INCLUDED == TRUE + + /* Set the pointer for the fw_update image */ + fileData = (uint8_t*)&_binary_fw_update_bin_start; + + /* Calculate the SHA256 digest */ + /* Validate the image with SHA256, digest is last 256 bits of the file */ + TPU_Hash_Reset(); + TPU_Hash_Config(TPU_HASH_SHA256); + TPU_SHA((const char *)fileData, TPU_HASH_SHA256, FILE_SIZE, fileHashDigest); + TPU_Hash_Shutdown(); + + int i; + for(i = 0; i < DM_CONN_MAX; i++) { + datcCb.sendingFile[i] = FALSE; + datcCb.fileVerified[i] = FALSE; + datcCb.blockOffset[i] = BLOCK_OFFSET_INIT; + } +#endif } /*************************************************************************************************/ @@ -1417,7 +1697,7 @@ void DatcHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg) { if (pMsg != NULL) { - if (pMsg->event != TEST_TIMER_IND) + if ((pMsg->event != TEST_TIMER_IND) && (pMsg->event != ATTC_WRITE_RSP)) { APP_TRACE_INFO2("Datc got evt 0x%x, param %u", pMsg->event, pMsg->param); } @@ -1443,6 +1723,11 @@ void DatcHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg) /* perform profile and user interface-related operations */ datcProcMsg((dmEvt_t *) pMsg); + +#if WDXC_INCLUDED == TRUE + /* perform wdxc operations */ + WdxcProcMsg((wsfMsgHdr_t *) pMsg); +#endif /*WDXC_INCLUDED */ } } @@ -1453,7 +1738,7 @@ void DatcHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg) * \return None. */ /*************************************************************************************************/ -static void datcInitSvcHdlList() +static void datcInitSvcHdlList(void) { uint8_t i; @@ -1463,6 +1748,9 @@ static void datcInitSvcHdlList() pDatcGattHdlList[i] = &datcCb.hdlList[i][DATC_DISC_GATT_START]; pDatcGapHdlList[i] = &datcCb.hdlList[i][DATC_DISC_GAP_START]; pDatcWpHdlList[i] = &datcCb.hdlList[i][DATC_DISC_WP_START]; +#if WDXC_INCLUDED == TRUE + pDatcWdxHdlList[i] = &datcCb.hdlList[i][DATC_DISC_WDXC_START]; +#endif /* WDXC_INCLUDED */ } } /*************************************************************************************************/ @@ -1482,12 +1770,20 @@ void DatcStart(void) DmConnRegister(DM_CLIENT_ID_APP, datcDmCback); AttRegister(datcAttCback); + /* Register for app framework button callbacks */ + AppUiBtnRegister(datcBtnCback); + /* Register for app framework discovery callbacks */ AppDiscRegister(datcDiscCback); /* Initialize attribute server database */ SvcCoreAddGroup(); +#if WDXC_INCLUDED == TRUE + /* Initialize the WDXC and set the WDXC application callbacks */ + WdxcInit(datcWdxcFtdCallback, datcWdxcFtcCallback); +#endif /* WDXC_INCLUDED */ + /* Reset the device */ DmDevReset(); } diff --git a/lib/sdk/Applications/EvKitExamples/BLE_datc/main.c b/lib/sdk/Applications/EvKitExamples/BLE_datc/main.c index e5ae1eea91bc64ed1d9c1494d169630bb2bd4551..75bc0490c11f764356624be355d69b16bc436e2f 100644 --- a/lib/sdk/Applications/EvKitExamples/BLE_datc/main.c +++ b/lib/sdk/Applications/EvKitExamples/BLE_datc/main.c @@ -48,6 +48,9 @@ #include "radio_drv.h" #include "hci_core.h" #include "hci_vs.h" +#include "pb.h" +#include "tmr.h" +#include "pal_sys.h" /************************************************************************************************** Macros @@ -60,6 +63,13 @@ /* Size of buffer for stdio functions */ #define PRINTF_BUF_SIZE 128 +/* Definitions for push button handling */ +#define BUTTON0_TMR MXC_TMR0 +#define BUTTON1_TMR MXC_TMR1 +#define BUTTON_SHORT_MS 200 +#define BUTTON_MED_MS 500 +#define BUTTON_LONG_MS 1000 + /************************************************************************************************** Local Variables **************************************************************************************************/ @@ -92,7 +102,7 @@ extern void StackInitDatc(void); /*************************************************************************************************/ void SysTick_Handler(void) { - WsfTimerUpdate(1); + WsfTimerUpdate(WSF_MS_PER_TICK); } /*************************************************************************************************/ @@ -109,13 +119,6 @@ static bool_t myTrace(const uint8_t *pBuf, uint32_t len) return FALSE; } -/*************************************************************************************************/ -void PalSysAssertTrap(void) -{ - printf("Assertion detected\n"); - while(1) {} -} - /*************************************************************************************************/ /*! * \brief Initialize WSF. @@ -145,6 +148,59 @@ static void WsfInit(void) WsfTraceEnable(TRUE); } + +/*************************************************************************************************/ +void HandleButton(int button) +{ + mxc_tmr_regs_t* button_tmr = MXC_TMR_GET_TMR(button); + + // Check if rising or falling + if(PB_Get(button)) { + // Start timer + TMR_Enable(button_tmr); + } else { + uint32_t time; + tmr_unit_t unit; + + // Get the elapsed time since the button was pressed + TMR_GetTime(button_tmr, TMR_GetCount(button_tmr), &time, &unit); + TMR_Disable(button_tmr); + TMR_SetCount(button_tmr, 0); + + if(unit == TMR_UNIT_NANOSEC) { + time /= 1000000; + } else if(unit == TMR_UNIT_MICROSEC) { + time /= 1000; + } + + if(time < BUTTON_SHORT_MS) { + APP_TRACE_INFO1("Button %d SHORT", button); + AppUiBtnTest(button ? APP_UI_BTN_2_SHORT : APP_UI_BTN_1_SHORT); + } else if (time < BUTTON_MED_MS) { + APP_TRACE_INFO1("Button %d MED", button); + AppUiBtnTest(button ? APP_UI_BTN_2_MED : APP_UI_BTN_1_MED); + } else if (time < BUTTON_LONG_MS) { + APP_TRACE_INFO1("Button %d LONG", button); + AppUiBtnTest(button ? APP_UI_BTN_2_LONG : APP_UI_BTN_1_LONG); + } else { + APP_TRACE_INFO1("Button %d EX_LONG", button); + AppUiBtnTest(button ? APP_UI_BTN_2_EX_LONG : APP_UI_BTN_1_EX_LONG); + } + } +} + +/*************************************************************************************************/ +void Button0Pressed(void* arg) +{ + HandleButton(0); +} + +/*************************************************************************************************/ +void Button1Pressed(void* arg) +{ + HandleButton(1); +} + /* * In two-chip solutions, setting the address must wait until the HCI interface is initialized. * This handler can also catch other Application events, but none are currently implemented. @@ -185,6 +241,20 @@ int main(void) printf("\n\n***** MAX32665 BLE Data Collector *****\n"); + /* Setup pushbuttons and timers */ + PB_RegisterRiseFallCallback(0, Button0Pressed); + PB_RegisterRiseFallCallback(1, Button1Pressed); + PB_IntEnable(0); + PB_IntEnable(1); + + TMR_Init(BUTTON0_TMR, TMR_PRES_16, NULL); + TMR_Init(BUTTON1_TMR, TMR_PRES_16, NULL); + + tmr_cfg_t button_config; + button_config.mode = TMR_MODE_CONTINUOUS; + TMR_Config(BUTTON0_TMR, &button_config); + TMR_Config(BUTTON1_TMR, &button_config); + /* Initialize Radio */ WsfInit(); StackInitDatc(); diff --git a/lib/sdk/Applications/EvKitExamples/BLE_datc/stack_datc.c b/lib/sdk/Applications/EvKitExamples/BLE_datc/stack_datc.c index 61197b12dd86107085a5ee4ee7541e4fdf7bc81b..dd11f1694c732c23936f5a041e7bab6e8e90686e 100644 --- a/lib/sdk/Applications/EvKitExamples/BLE_datc/stack_datc.c +++ b/lib/sdk/Applications/EvKitExamples/BLE_datc/stack_datc.c @@ -170,7 +170,7 @@ void StackInitDatc(void) SmpHandlerInit(handlerId); SmpiInit(); SmpiScInit(); - HciSetMaxRxAclLen(100); + HciSetMaxRxAclLen(256); handlerId = WsfOsSetNextHandler(AppHandler); AppHandlerInit(handlerId); diff --git a/lib/sdk/Applications/EvKitExamples/BLE_dats/Makefile b/lib/sdk/Applications/EvKitExamples/BLE_dats/Makefile index f2ec21e1358b83cf9244370ceb2d172e55372d0f..ec6998a99e3437addbf7b13c059066d4d2de9e2d 100644 --- a/lib/sdk/Applications/EvKitExamples/BLE_dats/Makefile +++ b/lib/sdk/Applications/EvKitExamples/BLE_dats/Makefile @@ -60,6 +60,10 @@ endif TARGET_UC:=$(shell echo $(TARGET) | tr a-z A-Z) TARGET_LC:=$(shell echo $(TARGET) | tr A-Z a-z) +# Unset PROJ_CFLAGS so remote building of this application does not carry over +# already defined flags +PROJ_CFLAGS= + # Last octet address modifier ifneq "$(BLE_ADDR_LSB)" "" PROJ_CFLAGS+=-DBLE_ADDR_LSB=$(BLE_ADDR_LSB) @@ -72,6 +76,7 @@ endif # This is the path to the CMSIS root directory ifeq "$(MAXIM_PATH)" "" LIBS_DIR=../../../Libraries +NDALIBS_DIR=../../../NDALibraries else LIBS_DIR=/$(subst \,/,$(subst :,,$(MAXIM_PATH))/Firmware/$(TARGET_UC)/Libraries) endif @@ -124,6 +129,27 @@ PROJ_CFLAGS+=-DCONSOLE_UART=$(CONSOLE_UART) endif endif +ifdef FW_VERSION +ifneq "$(FW_VERSION)" "" +PROJ_CFLAGS+=-DFW_VERSION=$(FW_VERSION) +endif +endif + +ifdef ENABLE_WDX +ifneq "$(ENABLE_WDX)" "" +ifneq "$(ENABLE_WDX)" "0" +PROJ_CFLAGS+=-DWDXC_INCLUDED=TRUE +PROJ_CFLAGS+=-DWDXS_INCLUDED=TRUE +# PROJ_CFLAGS+=-DWSF_TRACE_ENABLED=TRUE +SRCS += wdxs_file.c + +# Use linkerfile to create room for bootloader +LINKERFILE=max32665_file.ld + +endif +endif +endif + ifdef ENABLE_SDMA ifneq "$(ENABLE_SDMA)" "" ifeq "$(ENABLE_SDMA)" "0" @@ -162,7 +188,6 @@ PROJ_CFLAGS+=-DMXC_ASSERT_ENABLE=TRUE PROJ_CFLAGS+=-DWSF_ASSERT_ENABLED=TRUE # PROJ_CFLAGS+=-DLL_TRACE_ENABLED=TRUE # PROJ_CFLAGS+=-DLL_DBG_PIN_ENABLED=TRUE -PROJ_CFLAGS+=-DWSF_MS_PER_TICK=1 #-------------------- @@ -176,6 +201,7 @@ PROJ_CFLAGS+=-DINIT_BROADCASTER # PROJ_CFLAGS+=-DINIT_CENTRAL PROJ_CFLAGS+=-DINIT_PERIPHERAL PROJ_CFLAGS+=-DINIT_ENCRYPTED +PROJ_CFLAGS+=-DINIT_PHY ENABLE_LL_TESTER?=#1 diff --git a/lib/sdk/Applications/EvKitExamples/BLE_dats/config.mk b/lib/sdk/Applications/EvKitExamples/BLE_dats/config.mk index 63b6bbbfbf159ebd29f5ed4dd1e43e74c3991c8e..ff9a91845258eaa564959fff78c9374ec34dc0ab 100644 --- a/lib/sdk/Applications/EvKitExamples/BLE_dats/config.mk +++ b/lib/sdk/Applications/EvKitExamples/BLE_dats/config.mk @@ -6,3 +6,11 @@ BTLE_APP_USE_LEGACY_API?=1 # Run link layer using SDMA. ENABLE_SDMA?=0 + +# Firmware version string +# 1.0 in ASCII +FW_VERSION?=0x312E31 + +# Enable file transfer profile +ENABLE_WDX?=0 + diff --git a/lib/sdk/Applications/EvKitExamples/BLE_dats/dats_main.c b/lib/sdk/Applications/EvKitExamples/BLE_dats/dats_main.c index 2732fdfe95de5a0cce460b0c7bdba7f91bd853fb..1c70556c57bfab4cf9de02919d28d411bd0c417d 100644 --- a/lib/sdk/Applications/EvKitExamples/BLE_dats/dats_main.c +++ b/lib/sdk/Applications/EvKitExamples/BLE_dats/dats_main.c @@ -20,6 +20,7 @@ #include <stdio.h> #include <string.h> #include "mxc_device.h" +#include "gcr_regs.h" #include "wsf_types.h" #include "util/bstream.h" #include "wsf_msg.h" @@ -41,7 +42,13 @@ #include "svc_wp.h" #include "util/calc128.h" #include "dats/dats_api.h" -#include "gcr_regs.h" +#if WDXS_INCLUDED == TRUE +#include "wsf_efs.h" +#include "svc_wdxs.h" +#include "wdxs/wdxs_api.h" +#include "wdxs/wdxs_main.h" +#include "wdxs_file.h" +#endif /************************************************************************************************** Macros @@ -50,6 +57,12 @@ /*! Enumeration of client characteristic configuration descriptors */ enum { +#if WDXS_INCLUDED == TRUE + WDXS_DC_CH_CCC_IDX, /*! WDXS DC service, service changed characteristic */ + WDXS_FTC_CH_CCC_IDX, /*! WDXS FTC service, service changed characteristic */ + WDXS_FTD_CH_CCC_IDX, /*! WDXS FTD service, service changed characteristic */ + WDXS_AU_CH_CCC_IDX, /*! WDXS AU service, service changed characteristic */ +#endif /* WDXS_INCLUDED */ DATS_GATT_SC_CCC_IDX, /*! GATT service, service changed characteristic */ DATS_WP_DAT_CCC_IDX, /*! ARM Ltd. proprietary service, data transfer characteristic */ DATS_NUM_CCC_IDX @@ -222,6 +235,12 @@ static const uint8_t datsExtScanDataDisc[] = static const attsCccSet_t datsCccSet[DATS_NUM_CCC_IDX] = { /* cccd handle value range security level */ +#if WDXS_INCLUDED == TRUE + {WDXS_DC_CH_CCC_HDL, ATT_CLIENT_CFG_NOTIFY, DM_SEC_LEVEL_NONE}, /* WDXS_DC_CH_CCC_IDX */ + {WDXS_FTC_CH_CCC_HDL, ATT_CLIENT_CFG_NOTIFY, DM_SEC_LEVEL_NONE}, /* WDXS_FTC_CH_CCC_IDX */ + {WDXS_FTD_CH_CCC_HDL, ATT_CLIENT_CFG_NOTIFY, DM_SEC_LEVEL_NONE}, /* WDXS_FTD_CH_CCC_IDX */ + {WDXS_AU_CH_CCC_HDL, ATT_CLIENT_CFG_NOTIFY, DM_SEC_LEVEL_NONE}, /* WDXS_AU_CH_CCC_IDX */ +#endif /* WDXS_INCLUDED */ {GATT_SC_CH_CCC_HDL, ATT_CLIENT_CFG_INDICATE, DM_SEC_LEVEL_NONE}, /* DATS_GATT_SC_CCC_IDX */ {WP_DAT_CH_CCC_HDL, ATT_CLIENT_CFG_NOTIFY, DM_SEC_LEVEL_NONE} /* DATS_WP_DAT_CCC_IDX */ }; @@ -239,6 +258,8 @@ static struct /* LESC OOB configuration */ static dmSecLescOobCfg_t *datsOobCfg; +bool_t resetFlag; + /*************************************************************************************************/ /*! * \brief Send notification containing data. @@ -321,6 +342,9 @@ static void datsDmCback(dmEvt_t *pDmEvt) /*************************************************************************************************/ static void datsAttCback(attEvt_t *pEvt) { +#if WDXS_INCLUDED == TRUE + WdxsAttCback(pEvt); +#endif /* WDXS_INCLUDED */ } /*************************************************************************************************/ @@ -484,9 +508,11 @@ static void datsSetup(dmEvt_t *pMsg) uint8_t advHandle; #endif /* BTLE_APP_USE_LEGACY_API */ +#if WDXS_INCLUDED != TRUE /* Scan responses and connections limited to the EvKit dats peer */ DmDevWhiteListAdd(DM_ADDR_PUBLIC, (bdAddr_t){0x02, 0x01, 0x44, 0x8B, 0x05, 0x00}); DmDevSetFilterPolicy(DM_FILT_POLICY_MODE_ADV, HCI_FILT_WHITE_LIST); +#endif /* set advertising and scan response data for discoverable mode */ #ifdef BTLE_APP_USE_LEGACY_API @@ -582,9 +608,6 @@ static void datsProcMsg(dmEvt_t *pMsg) case HCI_ERR_CONN_FAIL: printf(" FAIL ESTABLISH\n"); break; case HCI_ERR_MIC_FAILURE: printf(" MIC FAILURE\n"); break; } -#if 0 - WSF_ASSERT(0); -#endif uiEvent = APP_UI_CONN_CLOSE; break; @@ -690,6 +713,8 @@ void DatsHandlerInit(wsfHandlerId_t handlerId) /* Set IRK for the local device */ DmSecSetLocalIrk(localIrk); + + resetFlag = FALSE; } /*************************************************************************************************/ @@ -733,6 +758,11 @@ void DatsHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg) /* process security-related messages */ AppSlaveSecProcDmMsg((dmEvt_t *) pMsg); + +#if WDXS_INCLUDED == TRUE + /* process WDXS-related messages */ + WdxsProcDmMsg((dmEvt_t*) pMsg); +#endif /* WDXS_INCLUDED */ } /* perform profile and user interface-related operations */ @@ -740,6 +770,33 @@ void DatsHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg) } } +#if WDXS_INCLUDED == TRUE +/*************************************************************************************************/ +/*! + * \brief Resets the system. Runs from SRAM. + * + * \return None. + */ +/*************************************************************************************************/ +void WdxsResetSystem(void) +{ +#ifndef BTLE_APP_USE_LEGACY_API + uint8_t advHandle = DM_ADV_HANDLE_DEFAULT; +#endif /* BTLE_APP_USE_LEGACY_API */ + +#ifdef BTLE_APP_USE_LEGACY_API + AppAdvStop(); +#else /* BTLE_APP_USE_LEGACY_API */ + AppExtAdvStop(1, &advHandle); +#endif /* BTLE_APP_USE_LEGACY_API */ + + AppUiAction(APP_UI_ADV_STOP); + + /* set the Reset flag */ + resetFlag = TRUE; +} +#endif + /*************************************************************************************************/ /*! * \brief Start the application. @@ -761,6 +818,15 @@ void DatsStart(void) SvcWpCbackRegister(NULL, datsWpWriteCback); SvcWpAddGroup(); +#if WDXS_INCLUDED == TRUE + /* Initialize the WDXS Stream */ + WdxsFileInit(); + + /* Set the WDXS CCC Identifiers */ + WdxsSetCccIdx(WDXS_DC_CH_CCC_IDX, WDXS_AU_CH_CCC_IDX, WDXS_FTC_CH_CCC_IDX, WDXS_FTD_CH_CCC_IDX); + +#endif /* WDXS_INCLUDED */ + WsfBufDiagRegister(datsWsfBufDiagnostics); /* Reset the device */ diff --git a/lib/sdk/Applications/EvKitExamples/BLE_dats/main.c b/lib/sdk/Applications/EvKitExamples/BLE_dats/main.c index b190be293a48c73b6476b7a22767cb2d7e3c1cd2..a29cafb5bf23130377798c3d7d95ebc43e5c45ca 100644 --- a/lib/sdk/Applications/EvKitExamples/BLE_dats/main.c +++ b/lib/sdk/Applications/EvKitExamples/BLE_dats/main.c @@ -47,6 +47,8 @@ #include "app_ui.h" #include "hci_vs.h" #include "hci_core.h" +#include "bb_drv.h" +#include "board.h" /************************************************************************************************** Macros @@ -81,6 +83,8 @@ static wsfBufPoolDesc_t mainPoolDesc[WSF_BUF_POOLS] = { 512, 4 } }; +extern bool_t resetFlag; + /************************************************************************************************** Functions **************************************************************************************************/ @@ -88,16 +92,10 @@ static wsfBufPoolDesc_t mainPoolDesc[WSF_BUF_POOLS] = /*! \brief Stack initialization for app. */ extern void StackInitDats(void); -/*************************************************************************************************/ -void PalSysAssertTrap(void) -{ - while(1) {} -} - /*************************************************************************************************/ void SysTick_Handler(void) { - WsfTimerUpdate(1); + WsfTimerUpdate(WSF_MS_PER_TICK); } /*************************************************************************************************/ @@ -195,6 +193,17 @@ int main(void) while (1) { wsfOsDispatcher(); + + if(resetFlag && wsfOsReadyToSleep() && (Console_PrepForSleep() == E_NO_ERROR)) { + /* Prevent interrupts from pre-empting this operation */ + __disable_irq(); + + /* Power down the BLE hardware */ + BbDrvDisable(); + + /* Reset and let bootloader run the new image */ + NVIC_SystemReset(); + } } } diff --git a/lib/sdk/Applications/EvKitExamples/BLE_dats/max32665_file.ld b/lib/sdk/Applications/EvKitExamples/BLE_dats/max32665_file.ld new file mode 100644 index 0000000000000000000000000000000000000000..df00d213689b957a88b9ac7e11e814009db5fe91 --- /dev/null +++ b/lib/sdk/Applications/EvKitExamples/BLE_dats/max32665_file.ld @@ -0,0 +1,222 @@ +/******************************************************************************* + * Copyright (C) 2017 Maxim Integrated Products, Inc., All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of Maxim Integrated + * Products, Inc. shall not be used except as stated in the Maxim Integrated + * Products, Inc. Branding Policy. + * + * The mere transfer of this software does not imply any licenses + * of trade secrets, proprietary technology, copyrights, patents, + * trademarks, maskwork rights, or any other form of intellectual + * property whatsoever. Maxim Integrated Products, Inc. retains all + * ownership rights. + * + * $Date: 2019-12-06 15:25:52 -0600 (Fri, 06 Dec 2019) $ + * $Revision: 49605 $ + * + ******************************************************************************/ + + +/* Allocate space if SDMA_SIZE is defined at the start of SRAM*/ +SRAM_ORIGIN = 0x20000000; +SDMA_CODE_LEN = DEFINED(SDMA_CODE_SIZE) ? SDMA_CODE_SIZE : 0; +SDMA_DATA_LEN = DEFINED(SDMA_DATA_SIZE) ? SDMA_DATA_SIZE : 0; +SDMA_LEN = SDMA_CODE_LEN + SDMA_DATA_LEN; +OTP_LEN = DEFINED(SDMA_CODE_SIZE) ? 0x40 : 0; +SHARED_LEN = DEFINED(SDMA_CODE_SIZE) ? 1k : 0; +SHARED_LEN_HALF = SHARED_LEN / 2; + +OTP_ADDR = SRAM_ORIGIN; +SHARED_ADDR = OTP_ADDR + OTP_LEN; +SDMA_DATA_ADDR = SHARED_ADDR + SHARED_LEN; +SDMA_CODE_ADDR = SDMA_DATA_ADDR + SDMA_DATA_LEN; +SRAM_ADDR = SDMA_CODE_ADDR + SDMA_CODE_LEN; + +/* Give leftover SRAM to the SRAM memory region */ +/* SRAM_SIZE must be defined */ +SRAM_LEN = SRAM_SIZE - OTP_LEN - SHARED_LEN - SDMA_LEN; + +/* SPID and SPIX Sections here are maximum possible sizes */ +/* If used, they should be adjusted for the external Flash/RAM size */ +MEMORY { + SPIX (rx) : ORIGIN = 0x08000000, LENGTH = 128M + + /* Create two flash sections for fw_update file storage */ + /* Reserve the first page of flash for the bootloader */ + BOOT (rx) : ORIGIN = 0x10000000, LENGTH = 8k + FLASH (rx) : ORIGIN = 0x10002000, LENGTH = 504k + FLASH1(rx) : ORIGIN = 0x10080000, LENGTH = 512k + + OTP (rwx) : ORIGIN = OTP_ADDR, LENGTH = OTP_LEN + ARM_SHARED(rwx) : ORIGIN = SHARED_ADDR, LENGTH = SHARED_LEN_HALF + SDMA_SHARED(rwx): ORIGIN = SHARED_ADDR + SHARED_LEN_HALF, LENGTH = SHARED_LEN_HALF + SDMA_DATA (rwx) : ORIGIN = SDMA_DATA_ADDR, LENGTH = SDMA_DATA_LEN + SDMA_CODE (rwx) : ORIGIN = SDMA_CODE_ADDR, LENGTH = SDMA_CODE_LEN + + SRAM (rwx) : ORIGIN = SRAM_ADDR, LENGTH = SRAM_LEN + SPID (rw) : ORIGIN = 0x80000000, LENGTH = 512M +} + +SECTIONS { + .text : + { + _text = .; + KEEP(*(.isr_vector)) + *(.text*) /* program code */ + *(.rodata*) /* read-only data: "const" */ + + KEEP(*(.init)) + KEEP(*(.fini)) + + /* C++ Exception handling */ + KEEP(*(.eh_frame*)) + _etext = .; + + } > FLASH + + /* This section will keep the SPIX data until loaded into the external device */ + /* Upon initialization of SPIX (user code needs to do this) */ + .xip_section : + { + KEEP(*(.xip_section*)) + } > SPIX AT>FLASH + + __load_start_xip = LOADADDR(.xip_section); + __load_length_xip = SIZEOF(.xip_section); + + /* it's used for C++ exception handling */ + /* we need to keep this to avoid overlapping */ + .ARM.exidx : + { + __exidx_start = .; + *(.ARM.exidx*) + __exidx_end = .; + } > FLASH + + .data : + { + _data = ALIGN(., 4); + *(.data*) /*read-write initialized data: initialized global variable*/ + *(.spix_config*) /* SPIX configuration functions need to be run from SRAM */ + *(.flashprog*) /* Flash program */ + + + /* These array sections are used by __libc_init_array to call static C++ constructors */ + . = ALIGN(4); + /* preinit data */ + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP(*(.preinit_array)) + PROVIDE_HIDDEN (__preinit_array_end = .); + + . = ALIGN(4); + /* init data */ + PROVIDE_HIDDEN (__init_array_start = .); + KEEP(*(SORT(.init_array.*))) + KEEP(*(.init_array)) + PROVIDE_HIDDEN (__init_array_end = .); + + . = ALIGN(4); + /* finit data */ + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP(*(SORT(.fini_array.*))) + KEEP(*(.fini_array)) + PROVIDE_HIDDEN (__fini_array_end = .); + + _edata = ALIGN(., 4); + } > SRAM AT>FLASH + __load_data = LOADADDR(.data); + + .otp (NOLOAD) : + { + _otp = ALIGN(., 4); + *(.otp*) /*Copy of OTP memory*/ + + _eotp = ALIGN(., 4); + } > OTP + + .arm_shared (NOLOAD) : + { + _arm_shared = ALIGN(., 4); + *(.arm_shared*) /*Shared memory section*/ + + _earm_shared = ALIGN(., 4); + } > ARM_SHARED + + .sdma_shared (NOLOAD) : + { + _sdma_shared = ALIGN(., 4); + *(.sdma_shared*) /*Shared memory section*/ + + _esdma_shared = ALIGN(., 4); + } > SDMA_SHARED + + .sdma_code : + { + _sdma_code = ALIGN(., 4); + *(.sdma_code*) /*SDMA Code*/ + + _esdma_code = ALIGN(., 4); + } > SDMA_CODE AT>FLASH + __load_sdma_code = LOADADDR(.sdma_code); + + .sdma_data : + { + _sdma_data = ALIGN(., 4); + *(.sdma_data*) /*SDMA Data*/ + + _esdma_data = ALIGN(., 4); + } > SDMA_DATA AT>FLASH + __load_sdma_data = LOADADDR(.sdma_data); + + .bss : + { + . = ALIGN(4); + _bss = .; + *(.bss*) /*read-write zero initialized data: uninitialzed global variable*/ + *(COMMON) + _ebss = ALIGN(., 4); + } > SRAM + + /* Setup the stack for Core 1, it will only be used if the user code + * includes a definition of Stack_Size_Core1, which defines the space + * reserved above the main core's stack for core 1's stack */ + + __StackTop_Core1 = ORIGIN(SRAM) + LENGTH(SRAM); + __StackLimit_Core1 = DEFINED(Stack_Size_Core1) ? __StackTop_Core1 - Stack_Size_Core1 : __StackTop_Core1; + + /* Set stack top to end of RAM, and stack limit move down by Stack_Size. + * If core 1 is used, set the stack to the bottom of Core 1's stack region */ + + __StackTop = DEFINED(Stack_Size_Core1) ? __StackLimit_Core1 : ORIGIN(SRAM) + LENGTH(SRAM); + __StackLimit = __StackTop - Stack_Size; + + .heap (COPY): + { + . = ALIGN(4); + *(.heap*) + __HeapLimit = ABSOLUTE(__StackLimit); + } > SRAM + + PROVIDE(__stack = __StackTop); + + /* Check if data + heap + stack(s) exceeds RAM limit */ + ASSERT(__StackLimit >= _ebss, "region RAM overflowed with stack") +} diff --git a/lib/sdk/Applications/EvKitExamples/BLE_dats/stack_dats.c b/lib/sdk/Applications/EvKitExamples/BLE_dats/stack_dats.c index c45bf982cbca42170b95005de4cc5a5f49f6498b..376f1ee5e02711874bd8bdf35eabc43e151f25d7 100644 --- a/lib/sdk/Applications/EvKitExamples/BLE_dats/stack_dats.c +++ b/lib/sdk/Applications/EvKitExamples/BLE_dats/stack_dats.c @@ -167,7 +167,7 @@ void StackInitDats(void) SmpHandlerInit(handlerId); SmprInit(); SmprScInit(); - HciSetMaxRxAclLen(100); + HciSetMaxRxAclLen(256); handlerId = WsfOsSetNextHandler(AppHandler); AppHandlerInit(handlerId); diff --git a/lib/sdk/Applications/EvKitExamples/BLE_dats/wdxs_file.c b/lib/sdk/Applications/EvKitExamples/BLE_dats/wdxs_file.c new file mode 100644 index 0000000000000000000000000000000000000000..467e4aba6a00e8f746a3e0d9831cd2b6b31a7414 --- /dev/null +++ b/lib/sdk/Applications/EvKitExamples/BLE_dats/wdxs_file.c @@ -0,0 +1,259 @@ +/*************************************************************************************************/ +/*! + * \file + * + * \brief Wireless Data Exchange profile implementation - File Example. + * + * Copyright (c) 2013-2018 Arm Ltd. All Rights Reserved. + * ARM Ltd. confidential and proprietary. + * + * IMPORTANT. Your use of this file is governed by a Software License Agreement + * ("Agreement") that must be accepted in order to download or otherwise receive a + * copy of this file. You may not use or copy this file for any purpose other than + * as described in the Agreement. If you do not agree to all of the terms of the + * Agreement do not use this file and delete all copies in your possession or control; + * if you do not have a copy of the Agreement, you must contact ARM Ltd. prior + * to any use, copying or further distribution of this software. + */ +/*************************************************************************************************/ + +#include <string.h> +#include "max32665.h" +#include "wsf_types.h" +#include "util/wstr.h" +#include "wsf_trace.h" +#include "wsf_assert.h" +#include "wsf_efs.h" +#include "util/bstream.h" +#include "svc_wdxs.h" +#include "wdxs/wdxs_api.h" +#include "wdxs/wdxs_main.h" +#include "wdxs_file.h" +#include "dm_api.h" +#include "att_api.h" +#include "app_api.h" +#include "flc.h" +#include "hash.h" + +#define SHA256_BYTES (256/8) + +#define FLASH_START_ADDR MXC_FLASH1_MEM_BASE +#define FLASH_END_ADDR (MXC_FLASH1_MEM_BASE + MXC_FLASH_MEM_SIZE) + +static uint32_t verifyLen; + +/* Prototypes for file functions */ +static uint8_t wdxsFileInitMedia(void); +static uint8_t wdxsFileErase(uint32_t address, uint32_t size); +static uint8_t wdxsFileRead(uint8_t *pBuf, uint32_t address, uint32_t len); +static uint8_t wdxsFileWrite(const uint8_t *pBuf, uint32_t address, uint32_t size); +static uint8_t wsfFileHandle(uint8_t cmd, uint32_t param); + +/* Use the second half of the flash space for scratch space */ +static const wsfEfsMedia_t WDXS_FileMedia = +{ + /* uint32_t startAddress; Start address. */ FLASH_START_ADDR, + /* uint32_t endAddress; End address. */ FLASH_END_ADDR, + /* uint32_t pageSize; Page size. */ MXC_FLASH_PAGE_SIZE, + /* wsfMediaInitFunc_t *init; Media intialization callback. */ wdxsFileInitMedia, + /* wsfMediaEraseFunc_t *erase; Media erase callback. */ wdxsFileErase, + /* wsfMediaReadFunc_t *read; Media read callback. */ wdxsFileRead, + /* wsfMediaWriteFunc_t *write; Media write callback. */ wdxsFileWrite, + /* wsfMediaHandleCmdFunc_t *handleCmd; Media command handler callback. */ wsfFileHandle +}; + +/*************************************************************************************************/ +/*! + * \brief Media Init function, called when media is registered. + * + * \return Status of the operation. + */ +/*************************************************************************************************/ +static uint8_t wdxsFileInitMedia(void) +{ + return wdxsFileErase(WDXS_FileMedia.startAddress, WDXS_FileMedia.endAddress - WDXS_FileMedia.startAddress); +} + +/*************************************************************************************************/ +/*! + * \brief File erase function. Must be page aligned. + * + * \param address Address in media to start erasing. + * \param size Number of bytes to erase. + * + * \return Status of the operation. + */ +/*************************************************************************************************/ +static uint8_t wdxsFileErase(uint32_t address, uint32_t size) +{ + /* See if we can mass erase one of the flash arrays */ + if((address == MXC_FLASH1_MEM_BASE) && (size = MXC_FLASH_MEM_SIZE)) { + if(FLC_MassEraseInst(1) == E_NO_ERROR) { + return WSF_EFS_SUCCESS; + } + } + /* Page erase the flash sections */ + if(FLC_MultiPageErase(address, address+size) == E_NO_ERROR) { + return WSF_EFS_SUCCESS; + } + return WSF_EFS_FAILURE; +} + +/*************************************************************************************************/ +/*! + * \brief File Read function. + * + * \param pBuf Buffer to hold data. + * \param address Address in media to read from. + * \param size Size of pBuf in bytes. + * + * \return Status of the operation. + */ +/*************************************************************************************************/ +static uint8_t wdxsFileRead(uint8_t *pBuf, uint32_t address, uint32_t len) +{ + memcpy(pBuf, (uint32_t*)address, len); + return WSF_EFS_SUCCESS; +} + +/*************************************************************************************************/ +/*! + * \brief File Write function. + * + * \param pBuf Buffer with data to be written. + * \param address Address in media to write to. + * \param size Size of pBuf in bytes. + * + * \return Status of the operation. + */ +/*************************************************************************************************/ +static uint8_t wdxsFileWrite(const uint8_t *pBuf, uint32_t address, uint32_t size) +{ + if(FLC_Write(address, size, (uint32_t *)pBuf) == E_NO_ERROR) { + return WSF_EFS_SUCCESS; + } + return WSF_EFS_FAILURE; +} + +/*************************************************************************************************/ +/*! + * \brief Media Specific Command handler. + * + * \param cmd Identifier of the media specific command. + * \param param Optional Parameter to the command. + * + * \return Status of the operation. + */ +/*************************************************************************************************/ +static uint8_t wsfFileHandle(uint8_t cmd, uint32_t param) +{ + switch(cmd) { + case WSF_EFS_WDXS_PUT_COMPLETE_CMD: + { + /* Currently unimplemented */ + return WDX_FTC_ST_SUCCESS; + } + break; + case WSF_EFS_VALIDATE_CMD: + default: + { + /* Validate the image with SHA256, digest is last 256 bits of the file */ + /* param holds the total file length */ + + char digest[SHA256_BYTES]; + + /* Calculate the digest */ + TPU_Hash_Reset(); + TPU_Hash_Config(TPU_HASH_SHA256); + TPU_SHA((const char *)WDXS_FileMedia.startAddress, TPU_HASH_SHA256, (param - SHA256_BYTES), digest); + TPU_Hash_Shutdown(); + + /* Check the calculated digest against what was received */ + if(memcmp(digest, (const char *)(WDXS_FileMedia.startAddress + param - SHA256_BYTES), SHA256_BYTES) != 0) { + return WDX_FTC_ST_VERIFICATION; + } + + /* Verification successful, save the verification length for future update */ + verifyLen = param; + + return WDX_FTC_ST_SUCCESS; + } + break; + } + return WDX_FTC_ST_SUCCESS; +} + + +/*************************************************************************************************/ +/*! + * \brief Example of creating a WDXS stream. + * + * \param none + * + * \return None. + */ +/*************************************************************************************************/ +void WdxsFileInit(void) +{ + wsfEsfAttributes_t attr; + char versionString[WSF_EFS_VERSION_LEN]; + + /* Add major number */ + versionString[0] = FW_VERSION & 0xFF; + /* Add "." */ + versionString[1] = (FW_VERSION & 0xFF00) >> 8; + /* Minor number */ + versionString[2] = (FW_VERSION & 0xFF0000) >> 16; + /* Add termination character */ + versionString[3] = 0; + + /* Register the media for the stream */ + WsfEfsRegisterMedia(&WDXS_FileMedia, WDX_FLASH_MEDIA); + + /* Set the attributes for the stream */ + attr.permissions = ( + WSF_EFS_REMOTE_GET_PERMITTED | + WSF_EFS_REMOTE_PUT_PERMITTED | + WSF_EFS_REMOTE_ERASE_PERMITTED | + WSF_EFS_REMOTE_VERIFY_PERMITTED | + WSF_EFS_LOCAL_GET_PERMITTED | + WSF_EFS_LOCAL_PUT_PERMITTED | + WSF_EFS_LOCAL_ERASE_PERMITTED | + WSF_EFS_REMOTE_VISIBLE); + + attr.type = WSF_EFS_FILE_TYPE_BULK; + + /* Potential buffer overrun is intentional to zero out fixed length field */ + /* coverity[overrun-buffer-arg] */ + WstrnCpy(attr.name, "File", WSF_EFS_NAME_LEN); + /* coverity[overrun-buffer-arg] */ + WstrnCpy(attr.version, versionString, WSF_EFS_VERSION_LEN); + + /* Add a file for the stream */ + WsfEfsAddFile(WDXS_FileMedia.endAddress - WDXS_FileMedia.startAddress, WDX_FLASH_MEDIA, &attr, 0); +} + + +/*************************************************************************************************/ +/*! + * \brief Get the base address of the WDXS file. + * + * \return Base address of WDXS file. + */ +/*************************************************************************************************/ +uint32_t WdxsFileGetBaseAddr(void) +{ + return WDXS_FileMedia.startAddress; +} + +/*************************************************************************************************/ +/*! + * \brief Get the length of the last verified WDXS file. + * + * \return Verified length of WDXS file. + */ +/*************************************************************************************************/ +uint32_t WdxsFileGetVerifiedLength(void) +{ + return verifyLen; +} diff --git a/lib/sdk/Applications/EvKitExamples/BLE_dats/wdxs_file.h b/lib/sdk/Applications/EvKitExamples/BLE_dats/wdxs_file.h new file mode 100644 index 0000000000000000000000000000000000000000..ca89c233fa3afae74a4d788042dcdb1a1baf4cee --- /dev/null +++ b/lib/sdk/Applications/EvKitExamples/BLE_dats/wdxs_file.h @@ -0,0 +1,72 @@ +/*************************************************************************************************/ +/*! + * \file + * + * \brief Wireless Data Exchange profile implementation - File Example. + * + * Copyright (c) 2013-2018 Arm Ltd. All Rights Reserved. + * ARM Ltd. confidential and proprietary. + * + * IMPORTANT. Your use of this file is governed by a Software License Agreement + * ("Agreement") that must be accepted in order to download or otherwise receive a + * copy of this file. You may not use or copy this file for any purpose other than + * as described in the Agreement. If you do not agree to all of the terms of the + * Agreement do not use this file and delete all copies in your possession or control; + * if you do not have a copy of the Agreement, you must contact ARM Ltd. prior + * to any use, copying or further distribution of this software. + */ +/*************************************************************************************************/ + +#ifndef WDXS_STREAM_H +#define WDXS_STREAM_H + +#ifdef __cplusplus +extern "C" { +#endif + +/*! \addtogroup WIRELESS_DATA_EXCHANGE_PROFILE + * \{ */ + +/************************************************************************************************** + Constant Definitions +**************************************************************************************************/ + +/************************************************************************************************** + Function Declarations +**************************************************************************************************/ + +/*************************************************************************************************/ +/*! + * \brief Initialize the WDXS File. + * + * \return None. + */ +/*************************************************************************************************/ +void WdxsFileInit(void); + +/*************************************************************************************************/ +/*! + * \brief Get the base address of the WDXS file. + * + * \return Base address of WDXS file. + */ +/*************************************************************************************************/ +uint32_t WdxsFileGetBaseAddr(void); + +/*************************************************************************************************/ +/*! + * \brief Get the length of the last verified WDXS file. + * + * \return Verified length of WDXS file. + */ +/*************************************************************************************************/ +uint32_t WdxsFileGetVerifiedLength(void); + +/*! \} */ /* WIRELESS_DATA_EXCHANGE_PROFILE */ + +#ifdef __cplusplus +} +#endif + +#endif /* WDXS_STREAM_H */ + diff --git a/lib/sdk/Applications/EvKitExamples/BLE_fit/Makefile b/lib/sdk/Applications/EvKitExamples/BLE_fit/Makefile index 41b7c0cbeb58cccaa7d5aa45f57107bef43a8d75..5e01bfc6fbf838c5e733b4dd53d5d8dccea9771d 100644 --- a/lib/sdk/Applications/EvKitExamples/BLE_fit/Makefile +++ b/lib/sdk/Applications/EvKitExamples/BLE_fit/Makefile @@ -29,7 +29,7 @@ # property whatsoever. Maxim Integrated Products, Inc. retains all # ownership rights. # -# $Id: Makefile 48012 2019-10-23 18:41:06Z kevin.gillespie $ +# $Id: Makefile 49765 2019-12-13 15:36:13Z kevin.gillespie $ # ################################################################################ @@ -140,7 +140,6 @@ PROJ_CFLAGS+=-DMXC_ASSERT_ENABLE=TRUE PROJ_CFLAGS+=-DWSF_ASSERT_ENABLED=TRUE # PROJ_CFLAGS+=-DLL_TRACE_ENABLED=TRUE # PROJ_CFLAGS+=-DLL_DBG_PIN_ENABLED=TRUE -PROJ_CFLAGS+=-DWSF_MS_PER_TICK=1 #-------------------- @@ -154,6 +153,7 @@ PROJ_CFLAGS+=-DINIT_BROADCASTER # PROJ_CFLAGS+=-DINIT_CENTRAL PROJ_CFLAGS+=-DINIT_PERIPHERAL PROJ_CFLAGS+=-DINIT_ENCRYPTED +PROJ_CFLAGS+=-DINIT_PHY # ENABLE_LL_TESTER?=#1 diff --git a/lib/sdk/Applications/EvKitExamples/BLE_fit/main.c b/lib/sdk/Applications/EvKitExamples/BLE_fit/main.c index e6f36092482b40998ea7ced49117c4b0b3fc0a34..06183ec9b2dc1ea9244b9872ff1490ea74b09ff5 100644 --- a/lib/sdk/Applications/EvKitExamples/BLE_fit/main.c +++ b/lib/sdk/Applications/EvKitExamples/BLE_fit/main.c @@ -29,8 +29,8 @@ * property whatsoever. Maxim Integrated Products, Inc. retains all * ownership rights. * - * $Date: 2019-10-09 11:56:30 -0500 (Wed, 09 Oct 2019) $ - * $Revision: 47576 $ + * $Date: 2019-11-08 11:13:40 -0600 (Fri, 08 Nov 2019) $ + * $Revision: 48553 $ * ******************************************************************************/ @@ -98,16 +98,10 @@ static wsfBufPoolDesc_t mainPoolDesc[WSF_BUF_POOLS] = /*! \brief Stack initialization for app. */ extern void StackInitFit(void); -/*************************************************************************************************/ -void PalSysAssertTrap(void) -{ - while(1) {} -} - /*************************************************************************************************/ void SysTick_Handler(void) { - WsfTimerUpdate(1); + WsfTimerUpdate(WSF_MS_PER_TICK); } /*************************************************************************************************/ diff --git a/lib/sdk/Applications/EvKitExamples/BLE_fit_ds/Makefile b/lib/sdk/Applications/EvKitExamples/BLE_fit_ds/Makefile index 557518c3cc9c2556a4efd635951eb3f32ca6f0e2..a8ed207d81bbb7cc6e7c91222f28a7938d63b747 100644 --- a/lib/sdk/Applications/EvKitExamples/BLE_fit_ds/Makefile +++ b/lib/sdk/Applications/EvKitExamples/BLE_fit_ds/Makefile @@ -29,7 +29,7 @@ # property whatsoever. Maxim Integrated Products, Inc. retains all # ownership rights. # -# $Id: Makefile 48023 2019-10-23 19:56:38Z nathan.goldstick $ +# $Id: Makefile 49765 2019-12-13 15:36:13Z kevin.gillespie $ # ################################################################################ @@ -87,6 +87,7 @@ SRCS = main.c SRCS += stack_fit.c SRCS += fit_main.c SRCS += wakeup.c +SRCS += backup.S # Where to find source files for this test VPATH = . @@ -130,6 +131,12 @@ endif endif endif +ifdef BACKUP_MODE +ifneq "$(BACKUP_MODE)" "0" +PROJ_CFLAGS+=-DBACKUP_MODE=1 +endif +endif + #------------------------------------------------------------------------------- # Configuration specified here. @@ -142,7 +149,6 @@ PROJ_CFLAGS+=-DWSF_ASSERT_ENABLED=TRUE # PROJ_CFLAGS+=-DWSF_TRACE_ENABLED=TRUE # PROJ_CFLAGS+=-DLL_TRACE_ENABLED=TRUE # PROJ_CFLAGS+=-DLL_DBG_PIN_ENABLED=TRUE -PROJ_CFLAGS+=-DWSF_MS_PER_TICK=1 #-------------------- @@ -156,6 +162,7 @@ PROJ_CFLAGS+=-DINIT_BROADCASTER # PROJ_CFLAGS+=-DINIT_CENTRAL PROJ_CFLAGS+=-DINIT_PERIPHERAL PROJ_CFLAGS+=-DINIT_ENCRYPTED +PROJ_CFLAGS+=-DINIT_PHY # ENABLE_LL_TESTER?=#1 diff --git a/lib/sdk/Applications/EvKitExamples/BLE_fit_ds/backup.S b/lib/sdk/Applications/EvKitExamples/BLE_fit_ds/backup.S new file mode 100644 index 0000000000000000000000000000000000000000..6207a1c4c17bd12db8529beb0552f544ad79e64b --- /dev/null +++ b/lib/sdk/Applications/EvKitExamples/BLE_fit_ds/backup.S @@ -0,0 +1,89 @@ +/******************************************************************************* + * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of Maxim Integrated + * Products, Inc. shall not be used except as stated in the Maxim Integrated + * Products, Inc. Branding Policy. + * + * The mere transfer of this software does not imply any licenses + * of trade secrets, proprietary technology, copyrights, patents, + * trademarks, maskwork rights, or any other form of intellectual + * property whatsoever. Maxim Integrated Products, Inc. retains all + * ownership rights. + * + * $Date: 2019-11-27 15:29:47 -0600 (Wed, 27 Nov 2019) $ + * $Revision: 49250 $ + * + ******************************************************************************/ + + .syntax unified + .arch armv7-m + .text + .thumb + .thumb_func + .align 2 + + + .globl Backup_Init + .type Backup_Init %function +/* Code executed out of backup mode */ +Backup_Init: + + /* Clear backup state */ + ldr r0, =0x40006800 + ldr r1, [r0] + orr r2, r1, #0x1 + str r2, [r0] + + /* Restore the stack pointer */ + ldr r0, =0x4000684C /* MXC_PWRSEQ->gp1 */ + ldr sp, [r0] + + /* Pop all of the registers */ + pop {r0,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12,lr} + + /* Return to where Backup_Setup was called */ + bx lr + + + + .globl Backup_Setup + .type Backup_Setup %function +/* Code executed going into backup mode */ +Backup_Setup: + + nop + + /* Push all of the registers to the stack */ + push {r0,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12,lr} + + /* Save the stack pointer */ + ldr r0, =0x4000684C /* MXC_PWRSEQ->gp1 */ + str sp, [r0] + + /* Go to backup */ + ldr r0, =0x4000000C /* MXC_GCR->pm */ + ldr r1, [r0] + orr r2, r1, #0x4 /* Set Backup bit */ + str r2, [r0] + + /* Wait for backup mode, will enter into Backup_Init out of backup mode */ + b . diff --git a/lib/sdk/Applications/EvKitExamples/BLE_fit_ds/config.mk b/lib/sdk/Applications/EvKitExamples/BLE_fit_ds/config.mk index 8f11c6ba95f769aaaf8fdee009f4b105b84d689c..b7ac5ef28849fc2863d7591c45a83f4adf7bbb21 100644 --- a/lib/sdk/Applications/EvKitExamples/BLE_fit_ds/config.mk +++ b/lib/sdk/Applications/EvKitExamples/BLE_fit_ds/config.mk @@ -1,2 +1,5 @@ # Run link layer using SDMA. ENABLE_SDMA?=0 + +# Enter backup mode instead of deep sleep +BACKUP_MODE?=0 diff --git a/lib/sdk/Applications/EvKitExamples/BLE_fit_ds/main.c b/lib/sdk/Applications/EvKitExamples/BLE_fit_ds/main.c index f28b9f0fb4d7416504707d702b7046b25c3c2d53..23a5463bc22633e1d731460902b78a86325ae1f2 100644 --- a/lib/sdk/Applications/EvKitExamples/BLE_fit_ds/main.c +++ b/lib/sdk/Applications/EvKitExamples/BLE_fit_ds/main.c @@ -47,6 +47,8 @@ #include "app_ui.h" #include "hci_vs.h" #include "hci_core.h" +#include "hci_drv_sdma.h" +#include "ipc_defs.h" #include "pb.h" #include "tmr.h" #include "wakeup.h" @@ -57,6 +59,7 @@ #include "sch_api_ble.h" #include "lp.h" #include "bb_drv.h" +#include "led.h" /************************************************************************************************** Macros @@ -104,16 +107,10 @@ static wsfBufPoolDesc_t mainPoolDesc[WSF_BUF_POOLS] = { /*! \brief Stack initialization for app. */ extern void StackInitFit(void); -/*************************************************************************************************/ -void PalSysAssertTrap(void) -{ - while(1) {} -} - /*************************************************************************************************/ void SysTick_Handler(void) { - WsfTimerUpdate(1); + WsfTimerUpdate(WSF_MS_PER_TICK); } /*************************************************************************************************/ @@ -182,15 +179,15 @@ void HandleButton(int button) { mxc_tmr_regs_t* button_tmr = MXC_TMR_GET_TMR(button); - // Check if rising or falling + /* Check if rising or falling */ if(PB_Get(button)) { - // Start timer + /* Start timer */ TMR_Enable(button_tmr); } else { uint32_t time; tmr_unit_t unit; - // Get the elapsed time since the button was pressed + /* Get the elapsed time since the button was pressed */ TMR_GetTime(button_tmr, TMR_GetCount(button_tmr), &time, &unit); TMR_Disable(button_tmr); TMR_SetCount(button_tmr, 0); @@ -230,6 +227,8 @@ void Sleep(void) { WsfTaskLock(); + LED_On(0); + /* WSF and UART are not busy ? */ if (wsfOsReadyToSleep() && UART_PrepForSleep(MXC_UART_GET_UART(CONSOLE_UART)) == E_NO_ERROR) { /* get next due time and sleep time */ @@ -253,16 +252,13 @@ void Sleep(void) /* unschedule next BLE operation */ SchSleep(); - /* power off unused hardware */ - DisableUnused(); - /* enterDeepSleep mode */ - WsfTaskUnlock(); EnterDeepsleep(); + LED_Off(0); + /* initial restore */ ExitDeepsleep(); - WsfTaskLock(); /* Restore BLE hardware state */ BbDrvInitWake(); @@ -270,21 +266,86 @@ void Sleep(void) /* Restore BB clock */ WUT_RestoreBBClock(BB_CLK_RATE_HZ); WsfTimerUpdate((WUT_GetSleepTicks() * 1000) / SYS_WUT_GetFreq() / WSF_MS_PER_TICK ); - + + /* setup the systick */ + SysTick->LOAD = (SystemCoreClock / 1000) * WSF_MS_PER_TICK; + SysTick->VAL = 0; + SysTick->CTRL |= (SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_ENABLE_Msk | SysTick_CTRL_TICKINT_Msk); + /* Re-schedule next BLE operation */ SchWake(); - /* have enough time to sleep ?*/ - } else if (sleep_ticks > US_TO_BBTICKS(MIN_SLEEP_US)) { - WUT_SetInt(sleep_ticks - US_TO_BBTICKS(WAKEUP_TIME_US)); + /* have enough time to sleep ?*/ + } else { LP_EnterSleepMode(); } - /* Nothing scheduled, wait for interrupt */ + /* Nothing scheduled, wait for interrupt */ } else { LP_EnterSleepMode(); } } /* if(not busy) */ + LED_Off(0); + + WsfTaskUnlock(); +} + +/*************************************************************************************************/ +void SDMASleep(void) +{ + WsfTaskLock(); + + /* Signal to the SDMA that the ARM core will restart from sleep */ + SDMASetARMFlag(ARM_FLAG_SLEEP); + + LED_On(0); + + if (wsfOsReadyToSleep() && UART_PrepForSleep(MXC_UART_GET_UART(CONSOLE_UART)) == E_NO_ERROR) { + uint8_t sdmaFlag = SDMAGetSDMAFlag(); + + if((sdmaFlag == SDMA_FLAG_SLEEPING) || (sdmaFlag == SDMA_FLAG_RUNNING)) { + + /* Store the wakeup timer value to restore the WSF timer once we wakeup */ + WUT_Store(); + + /* Stop the Systick interrupt */ + SysTick->CTRL = 0; + + /* Set the wakeup compare value from the SDMA */ + MXC_WUT->cmp = SDMAGetWakeupTime(); + + if(sdmaFlag == SDMA_FLAG_SLEEPING) { + /* Enter Deep Sleep if the SDMA is sleeping */ + EnterDeepsleepSDMA(); + ExitDeepsleepSDMA(); + + /* Restart the SDMA from sleep */ + SDMARestart(); + + } else { + + /* Enter Background mode if the SDMA is running */ + EnterBackground(); + ExitBackground(); + } + + /* Restore the WSF timer from sleep */ + WsfTimerUpdate((WUT_GetSleepTicks() * 1000) / SYS_WUT_GetFreq() / WSF_MS_PER_TICK ); + + /* setup the systick */ + SysTick->LOAD = (SystemCoreClock / 1000) * WSF_MS_PER_TICK; + SysTick->VAL = 0; + SysTick->CTRL |= (SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_ENABLE_Msk | SysTick_CTRL_TICKINT_Msk); + + } + + else { + LP_EnterSleepMode(); + } + } + + LED_Off(0); + WsfTaskUnlock(); } @@ -304,14 +365,23 @@ int main(void) /* Restoring VREGOD when reset out of deep sleep */ MXC_PWRSEQ->lpvddpd &= ~MXC_F_PWRSEQ_LPVDDPD_VREGODPD; + /* Run from the 96MHz oscillator */ + switchTo96M(); + Console_Init(); + printf("\n\n***** MAX32665 BLE Fitness Profile, Deep Sleep *****\n"); + printf("SystemCoreClock = %d\n", SystemCoreClock); + +#if (BACKUP_MODE == 1) + printf("Entering backup mode instead of deep sleep\n"); +#endif /* Initialize Wakeup timer */ WUT_Init(WUT_PRES_1); wut_cfg_t wut_cfg; wut_cfg.mode = WUT_MODE_COMPARE; wut_cfg.cmp_cnt = 0xFFFFFFFF; - + WUT_Config(&wut_cfg); WUT_Enable(); @@ -322,6 +392,9 @@ int main(void) /* Delay before continuing with deep sleep code */ WUT_Delay_MS(3000); + /* power off unused hardware */ + DisableUnused(); + /* Initialize Radio */ WsfInit(); StackInitFit(); @@ -346,16 +419,43 @@ int main(void) printf("Setup Complete\n"); while (1) { + wsfOsDispatcher(); + + #ifdef ENABLE_SDMA + SDMASleep(); + #else Sleep(); + #endif } } /*****************************************************************/ void HardFault_Handler(void) { - printf("\nFaultISR: CFSR %08X, BFAR %08x\n", (unsigned int)SCB->CFSR, (unsigned int)SCB->BFAR); + __asm( + " TST LR, #4\n" + " ITE EQ \n" + " MRSEQ R0, MSP \n" + " MRSNE R0, PSP \n" + " B HardFault_Decoder \n"); +} + + +/*****************************************************************/ +void HardFault_Decoder(unsigned int *f) +{ - // Loop forever - while(1); + printf("\n-- HardFault --\n"); + printf("HFSR 0x%08x CFSR 0x%08X", (unsigned int)SCB->HFSR, (unsigned int)SCB->CFSR); + if (SCB->CFSR & 0x80) { + printf(", MMFAR 0x%08X", (unsigned int)SCB->MMFAR); + } + if (SCB->CFSR & 0x8000) { + printf(", BFAR 0x%08X", (unsigned int)SCB->BFAR); + } + printf("\n"); + + /* Hang here */ + while(1); } diff --git a/lib/sdk/Applications/EvKitExamples/BLE_fit_ds/wakeup.c b/lib/sdk/Applications/EvKitExamples/BLE_fit_ds/wakeup.c index 378219194e918d8ed706cb149be959335a7c792c..3d28f7749ab5143a424f6612e39f936529bba320 100644 --- a/lib/sdk/Applications/EvKitExamples/BLE_fit_ds/wakeup.c +++ b/lib/sdk/Applications/EvKitExamples/BLE_fit_ds/wakeup.c @@ -49,29 +49,36 @@ #include "mxc_sys.h" #include "bb_drv.h" #include "wakeup.h" +#include "led.h" uint32_t wut_count; uint32_t wut_snapshot; uint32_t vrego_d_setting; uint32_t btleldocn_setting; -#define WAKEUP_32M_US 1105 +#ifdef ENABLE_SDMA +#define RUN_VOLTAGE 1000 +#else +#define RUN_VOLTAGE 950 +#endif + +#define BG_VOLTAGE 950 +#define DS_VOLTAGE 810 + +#define WAKEUP_32M_US 1600 #define MXC_R_SIR_SHR13 *((uint32_t*)(0x40000434)) #define MXC_R_SIR_SHR17 *((uint32_t*)(0x40000444)) -/*************************************************/ -void WUT_IRQHandler(void) -{ - WUT_IntClear(); - NVIC_ClearPendingIRQ(WUT_IRQn); -} +/* Assembly functions in backup.S */ +extern void Backup_Init(void); +extern void Backup_Setup(void); /*************************************************/ /* Arm WUT for wakeup from Sleep */ void WUT_SetInt(uint32_t sleep_time) { /* arm WUT for wakeup */ - MXC_WUT->cmp = MXC_WUT->cnt + ((uint64_t)(sleep_time) * SYS_WUT_GetFreq() / BB_CLK_RATE_HZ); + MXC_WUT->cmp = MXC_WUT->cnt + ((uint64_t)(sleep_time) * SYS_WUT_GetFreq() / BB_CLK_RATE_HZ); } /*************************************************/ @@ -85,6 +92,16 @@ void WUT_SetWakeup(uint32_t sleep_time) WUT_SetInt(sleep_time); } +/*************************************************/ +/* Sleep for the given number of us */ +void WUT_sleepUs(uint32_t us) +{ + MXC_WUT->cmp = MXC_WUT->cnt + ((uint64_t)(us) * SYS_WUT_GetFreq() / 1000000); + LED_On(0); + LP_EnterSleepMode(); + LED_Off(0); +} + /*************************************************/ /* This will calculate extra delay needed to power up after WAIT_TICKS long Sleep @@ -125,24 +142,28 @@ static void switchToHIRC(void) MXC_GCR->clkcn |= MXC_S_GCR_CLKCN_PSC_DIV4; MXC_GCR->clkcn |= MXC_F_GCR_CLKCN_HIRC_EN; MXC_SETFIELD(MXC_GCR->clkcn, MXC_F_GCR_CLKCN_CLKSEL, MXC_S_GCR_CLKCN_CLKSEL_HIRC); - // Disable unused clocks - while(!(MXC_GCR->clkcn & MXC_F_GCR_CLKCN_CKRDY)); // Wait for the switch to occur + /* Disable unused clocks */ + while(!(MXC_GCR->clkcn & MXC_F_GCR_CLKCN_CKRDY)); /* Wait for the switch to occur */ MXC_GCR->clkcn &= ~(MXC_F_GCR_CLKCN_HIRC96M_EN); SystemCoreClockUpdate(); } /*************************************************/ /* This will switch system clock to 96MHz source */ -static void switchToHIRC96M(void) +void switchTo96M(void) { MXC_GCR->clkcn &= ~(MXC_S_GCR_CLKCN_PSC_DIV128); +#ifdef ENABLE_SDMA MXC_GCR->clkcn |= MXC_S_GCR_CLKCN_PSC_DIV1; +#else + MXC_GCR->clkcn |= MXC_S_GCR_CLKCN_PSC_DIV2; +#endif MXC_GCR->clkcn |= MXC_F_GCR_CLKCN_HIRC96M_EN; MXC_SETFIELD(MXC_GCR->clkcn, MXC_F_GCR_CLKCN_CLKSEL, MXC_S_GCR_CLKCN_CLKSEL_HIRC96); - while(!(MXC_GCR->clkcn & MXC_F_GCR_CLKCN_CKRDY)); // Wait for the switch to occur + while(!(MXC_GCR->clkcn & MXC_F_GCR_CLKCN_CKRDY)); /* Wait for the switch to occur */ - // Disable unused clocks + /* Disable unused clocks */ MXC_GCR->clkcn &= ~(MXC_F_GCR_CLKCN_HIRC_EN); SystemCoreClockUpdate(); } @@ -151,17 +172,53 @@ static void switchToHIRC96M(void) /* This will power off unused hardware */ void DisableUnused(void) { - // Allow the USB Switch to be turned off in deepsleep and backup modes - LP_USBSWLPDisable(); - - // Shut down all unneeded power gates - LP_ICacheXIPShutdown(); - LP_CryptoShutdown(); - LP_SysCacheShutdown(); - LP_USBFIFOShutdown(); - LP_ROMShutdown(); - LP_ROM1Shutdown(); - LP_ICache1Shutdown(); + /* Prevent SIMO leakage in DS */ + if(MXC_GCR->revision == 0xA2) { + MXC_R_SIR_SHR13 = 0x0; + MXC_R_SIR_SHR17 &= ~(0xC0); + } + + /* Allow the USB Switch to be turned off in deepsleep and backup modes */ + LP_USBSWLPDisable(); + + /* Shut down all unneeded power gates */ + LP_ICacheXIPShutdown(); + LP_CryptoShutdown(); + LP_SysCacheShutdown(); + LP_USBFIFOShutdown(); + LP_ROMShutdown(); + LP_ROM1Shutdown(); + LP_ICache1Shutdown(); +} + +/*************************************************/ +void BackupMode(void) +{ + LP_ClearWakeStatus(); + + /* Assembly function in backup.S called when coming out of backup mode */ + MXC_PWRSEQ->gp0 = (uint32_t)(&Backup_Init) | 1; + + // Enable the VDDCSW to ensure we have enough power to start + MXC_MCR->ctrl |= MXC_F_MCR_CTRL_VDDCSWEN; + + // Enable backup mode + MXC_GCR->pm &= ~MXC_F_GCR_PM_MODE; + + /* Calls into assembly function in backup.S */ + Backup_Setup(); + + /* Executed out of Backup Mode */ + SystemInit(); + + /* Enable WUT interrupt */ + MXC_GCR->pm |= MXC_F_GCR_PM_WUTWKEN; + NVIC_EnableIRQ(WUT_IRQn); + + // ll_dbg_pin_init(); + + /* power off unused hardware */ + DisableUnused(); } /*************************************************/ @@ -171,12 +228,50 @@ void EnterDeepsleep(void) MXC_GCR->pm &= ~ ( MXC_F_GCR_PM_GPIOWKEN | MXC_F_GCR_PM_RTCWKEN | MXC_F_GCR_PM_USBWKEN - | MXC_F_GCR_PM_SDMAWKEN ); // disable other wakeups + | MXC_F_GCR_PM_SDMAWKEN ); /* disable other wakeups */ + MXC_GCR->pm |= MXC_F_GCR_PM_WUTWKEN; /* enable WUT wakeup */ + + /*Shutdown unused power domains */ + MXC_PWRSEQ->lpcn |= MXC_F_PWRSEQ_LPCN_BGOFF; + + ICC_Disable(); + LP_ICacheShutdown(); + + LP_VDD3PowerDown(); + LP_VDD4PowerDown(); + + LP_FastWakeupEnable(); + + BbDrvDisable(); + MXC_PWRSEQ->lpvddpd |= MXC_F_PWRSEQ_LPVDDPD_VREGODPD; + + /* Retain all SRAM */ + MXC_PWRSEQ->lpcn |= (MXC_S_PWRSEQ_LPCN_RAMRET_EN3); + + MXC_MCR->ctrl |= MXC_F_MCR_CTRL_VDDCSWEN; + switchToHIRC(); + SIMO_setVregO_B(DS_VOLTAGE); + SIMO_setVregO_C(DS_VOLTAGE); + +#if (BACKUP_MODE==1) + BackupMode(); +#else + LP_EnterDeepSleepMode(); +#endif +} + +/*************************************************/ +/* This will enter DeepSleep Mode */ +void EnterDeepsleepSDMA(void) +{ + MXC_GCR->pm &= ~ ( MXC_F_GCR_PM_GPIOWKEN + | MXC_F_GCR_PM_RTCWKEN + | MXC_F_GCR_PM_USBWKEN + | MXC_F_GCR_PM_SDMAWKEN); // disable other wakeups MXC_GCR->pm |= MXC_F_GCR_PM_WUTWKEN; // enable WUT wakeup //Shutdown unused power domains MXC_PWRSEQ->lpcn |= MXC_F_PWRSEQ_LPCN_BGOFF; - MXC_PWRSEQ->lpcn |= MXC_F_PWRSEQ_LPCN_FWKM; if(MXC_GCR->revision == 0xA2) { MXC_R_SIR_SHR13 = 0x0; @@ -189,43 +284,102 @@ void EnterDeepsleep(void) LP_VDD3PowerDown(); LP_VDD4PowerDown(); - - /* power down BLE VREGOD and LDOs */ - MXC_PWRSEQ->lpvddpd |= MXC_F_PWRSEQ_LPVDDPD_VREGODPD; - vrego_d_setting = MXC_SIMO->vrego_d; - btleldocn_setting = MXC_GCR->btleldocn; - MXC_GCR->btleldocn = 0x66; - MXC_SIMO->vrego_d = 0; - - BbDrvDisable(); + LP_FastWakeupEnable(); // Retain all SRAM MXC_PWRSEQ->lpcn |= (MXC_S_PWRSEQ_LPCN_RAMRET_EN3); MXC_MCR->ctrl |= MXC_F_MCR_CTRL_VDDCSWEN; switchToHIRC(); - SIMO_setVregO_A(1800); - SIMO_setVregO_B(810); - SIMO_setVregO_C(810); + SIMO_setVregO_B(DS_VOLTAGE); + SIMO_setVregO_C(DS_VOLTAGE); LP_EnterDeepSleepMode(); } + +/*************************************************/ +/* This will enter DeepSleep Mode */ +void EnterBackground(void) +{ + MXC_GCR->pm &= ~ ( MXC_F_GCR_PM_GPIOWKEN + | MXC_F_GCR_PM_RTCWKEN + | MXC_F_GCR_PM_WUTWKEN + | MXC_F_GCR_PM_USBWKEN); // disable other wakeups + MXC_GCR->pm |= (MXC_F_GCR_PM_WUTWKEN); // enable WUT wakeup + + //Shutdown unused power domains + MXC_PWRSEQ->lpcn |= MXC_F_PWRSEQ_LPCN_BGOFF; + + ICC_Disable(); + LP_ICacheShutdown(); + + LP_VDD3PowerDown(); + LP_VDD4PowerDown(); + + LP_FastWakeupEnable(); + + // Retain all SRAM + MXC_PWRSEQ->lpcn |= (MXC_S_PWRSEQ_LPCN_RAMRET_EN3); + + MXC_MCR->ctrl |= MXC_F_MCR_CTRL_VDDCSWEN; + + while(!(MXC_SIMO->buck_out_ready & MXC_F_SIMO_BUCK_OUT_READY_BUCKOUTRDYD)) {} + SIMO_setVregO_B(BG_VOLTAGE); + SIMO_setVregO_C(BG_VOLTAGE); + + LP_EnterBackgroundMode(); +} + /*************************************************/ /* this will restore from DeepSleep Mode */ -void ExitDeepsleep(void) +void ExitBackup(void) { - SIMO_setVregO_B(1100); - SIMO_setVregO_C(1100); + /* Restore the core voltage before restoring the system clock */ + SIMO_setVregO_B(RUN_VOLTAGE); + while(!(MXC_SIMO->buck_out_ready & MXC_F_SIMO_BUCK_OUT_READY_BUCKOUTRDYB)) {} + SIMO_setVregO_C(RUN_VOLTAGE); + while(!(MXC_SIMO->buck_out_ready & MXC_F_SIMO_BUCK_OUT_READY_BUCKOUTRDYC)) {} MXC_WUT->intr = 1; NVIC_ClearPendingIRQ(WUT_IRQn); + MXC_PWRSEQ->lpcn &= ~0x3FE00000; /* Disable voltage Monitors for unused rails */ + + MXC_GCR->pm |= MXC_F_GCR_PM_WUTWKEN; + + SCB->SCR &= ~SCB_SCR_SLEEPDEEP_Msk; + MXC_PWRSEQ->lpcn |= MXC_F_PWRSEQ_LPCN_BCKGRND; + LP_ICacheWakeup(); + ICC_Enable(); + + /* Enable peripheral clocks */ + MXC_GCR->perckcn0 &= ~(MXC_F_GCR_PERCKCN0_GPIO0D | MXC_F_GCR_PERCKCN0_GPIO1D); + MXC_GCR->perckcn1 &= ~(MXC_F_GCR_PERCKCN1_TRNGD); + MXC_PWRSEQ->lpvddpd &= ~MXC_F_PWRSEQ_LPVDDPD_VREGODPD; - MXC_SIMO->vrego_d = vrego_d_setting; while(!(MXC_SIMO->buck_out_ready & MXC_F_SIMO_BUCK_OUT_READY_BUCKOUTRDYD)) {} - MXC_PWRSEQ->lpcn &= ~0x3FE00000; // Disable voltage Monitors for unused rails + /* Wait for SIMO warmup */ + WUT_sleepUs(500); + BbDrvEnable(); + + switchTo96M(); +} + +/*************************************************/ +/* this will restore from DeepSleep Mode */ +void ExitDeepsleep(void) +{ + +#if (BACKUP_MODE==1) + ExitBackup(); + return; +#endif + + MXC_PWRSEQ->lpvddpd &= ~MXC_F_PWRSEQ_LPVDDPD_VREGODPD; + + MXC_PWRSEQ->lpcn &= ~0x3FE00000; /* Disable voltage Monitors for unused rails */ MXC_GCR->pm |= MXC_F_GCR_PM_WUTWKEN; @@ -238,25 +392,69 @@ void ExitDeepsleep(void) MXC_GCR->perckcn0 &= ~(MXC_F_GCR_PERCKCN0_GPIO0D | MXC_F_GCR_PERCKCN0_GPIO1D); MXC_GCR->perckcn1 &= ~(MXC_F_GCR_PERCKCN1_TRNGD); - // Restore BTLELDOCN setting - MXC_GCR->btleldocn = btleldocn_setting; + BbDrvEnable(); - // Power up the 32MHz XO - MXC_GCR->clkcn |= MXC_F_GCR_CLKCN_X32M_EN; + /* Restore the core voltage before restoring the system clock */ + SIMO_setVregO_B(RUN_VOLTAGE); + while(!(MXC_SIMO->buck_out_ready & MXC_F_SIMO_BUCK_OUT_READY_BUCKOUTRDYB)) {} + SIMO_setVregO_C(RUN_VOLTAGE); + while(!(MXC_SIMO->buck_out_ready & MXC_F_SIMO_BUCK_OUT_READY_BUCKOUTRDYC)) {} - // Wait for crystal warmup - WUT_SetInt(US_TO_BBTICKS(WAKEUP_32M_US)); - LP_EnterSleepMode(); + switchTo96M(); +} + +/*************************************************/ +/* this will restore from DeepSleep Mode */ +void ExitDeepsleepSDMA(void) +{ + SIMO_setVregO_B(RUN_VOLTAGE); + while(!(MXC_SIMO->buck_out_ready & MXC_F_SIMO_BUCK_OUT_READY_BUCKOUTRDYB)) {} + SIMO_setVregO_C(RUN_VOLTAGE); + // while(!(MXC_SIMO->buck_out_ready & MXC_F_SIMO_BUCK_OUT_READY_BUCKOUTRDYC)) {} - while(!(MXC_GCR->clkcn & MXC_F_GCR_CLKCN_X32M_RDY)) {} + MXC_WUT->intr = 1; + NVIC_ClearPendingIRQ(WUT_IRQn); - /* setup the systick */ - SysTick->LOAD = (SystemCoreClock / 1000) * WSF_MS_PER_TICK; - SysTick->VAL = 0; - SysTick->CTRL |= (SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_ENABLE_Msk | SysTick_CTRL_TICKINT_Msk); + MXC_PWRSEQ->lpcn &= ~0x3FE00000; // Disable voltage Monitors for unused rails - switchToHIRC96M(); + MXC_GCR->pm |= (MXC_F_GCR_PM_WUTWKEN); + + SCB->SCR &= ~SCB_SCR_SLEEPDEEP_Msk; + MXC_PWRSEQ->lpcn &= ~MXC_F_PWRSEQ_LPCN_BCKGRND; + LP_ICacheWakeup(); + ICC_Enable(); + + /* Enable peripheral clocks */ + MXC_GCR->perckcn0 &= ~(MXC_F_GCR_PERCKCN0_GPIO0D | MXC_F_GCR_PERCKCN0_GPIO1D); + MXC_GCR->perckcn1 &= ~(MXC_F_GCR_PERCKCN1_TRNGD | MXC_F_GCR_PERCKCN1_BTLED); + + switchTo96M(); +} + +/*************************************************/ +/* this will restore from DeepSleep Mode */ +void ExitBackground(void) +{ + SIMO_setVregO_B(RUN_VOLTAGE); + while(!(MXC_SIMO->buck_out_ready & MXC_F_SIMO_BUCK_OUT_READY_BUCKOUTRDYB)) {} + SIMO_setVregO_C(RUN_VOLTAGE); + // while(!(MXC_SIMO->buck_out_ready & MXC_F_SIMO_BUCK_OUT_READY_BUCKOUTRDYC)) {} + + MXC_WUT->intr = 1; + NVIC_ClearPendingIRQ(WUT_IRQn); + + MXC_PWRSEQ->lpcn &= ~0x3FE00000; // Disable voltage Monitors for unused rails + + MXC_GCR->pm |= (MXC_F_GCR_PM_WUTWKEN); + + SCB->SCR &= ~SCB_SCR_SLEEPDEEP_Msk; + MXC_PWRSEQ->lpcn |= MXC_F_PWRSEQ_LPCN_BCKGRND; + LP_ICacheWakeup(); + ICC_Enable(); + + /* Enable peripheral clocks */ + MXC_GCR->perckcn0 &= ~(MXC_F_GCR_PERCKCN0_GPIO0D | MXC_F_GCR_PERCKCN0_GPIO1D); + MXC_GCR->perckcn1 &= ~(MXC_F_GCR_PERCKCN1_TRNGD | MXC_F_GCR_PERCKCN1_BTLED); - /* enable UART */ - Console_Init(); + switchTo96M(); } diff --git a/lib/sdk/Applications/EvKitExamples/BLE_fit_ds/wakeup.h b/lib/sdk/Applications/EvKitExamples/BLE_fit_ds/wakeup.h index ab6090cc973a94762a5a3806c363d8e792900be4..8564e10306a98ea1fb6ed36d731978ea994d4b6f 100644 --- a/lib/sdk/Applications/EvKitExamples/BLE_fit_ds/wakeup.h +++ b/lib/sdk/Applications/EvKitExamples/BLE_fit_ds/wakeup.h @@ -38,16 +38,30 @@ #define WAKEUP_H #define US_TO_BBTICKS(x) (((x)*(BB_CLK_RATE_HZ/100000)+9)/10) -#define DS_WAKEUP_TIME_US (1800) +#if (BACKUP_MODE==1) +#define DS_WAKEUP_TIME_US (2500) +#else +#define DS_WAKEUP_TIME_US (1850) +#endif #define WAKEUP_TIME_US (5) -#define MIN_DEEPSLEEP_US (10000) +#define MIN_DEEPSLEEP_US (5000) #define MIN_SLEEP_US (10) +/* Enter backup mode instead of deep sleep */ +#ifndef BACKUP_MODE +#define BACKUP_MODE 0 +#endif + void WUT_SetInt(uint32_t sleep_time); void WUT_SetWakeup(uint32_t sleep_time); uint32_t GetWakeDelay(uint32_t wait_ticks); void DisableUnused(void); void EnterDeepsleep(void); +void EnterDeepsleepSDMA(void); void ExitDeepsleep(void); +void ExitDeepsleepSDMA(void); +void EnterBackground(void); +void ExitBackground(void); +void switchTo96M(void); #endif diff --git a/lib/sdk/Applications/EvKitExamples/BLE_hci_uart/Makefile b/lib/sdk/Applications/EvKitExamples/BLE_hci_uart/Makefile index 53522b98f76ccf8430b1d32477db6598d0b49a3f..55f6cb87d8ff83d8f414bd7a74b07750ccb4d848 100644 --- a/lib/sdk/Applications/EvKitExamples/BLE_hci_uart/Makefile +++ b/lib/sdk/Applications/EvKitExamples/BLE_hci_uart/Makefile @@ -72,6 +72,7 @@ endif # This is the path to the CMSIS root directory ifeq "$(MAXIM_PATH)" "" LIBS_DIR=../../../Libraries +NDALIBS_DIR=../../../NDALibraries else LIBS_DIR=/$(subst \,/,$(subst :,,$(MAXIM_PATH))/Firmware/$(TARGET_UC)/Libraries) endif @@ -132,7 +133,8 @@ endif endif # Enable assertion checking for development -PROJ_CFLAGS+=-DWSF_ASSERT_ENABLE=TRUE +PROJ_CFLAGS+=-DWSF_ASSERT_ENABLED=TRUE +# PROJ_CFLAGS+=-DWSF_TRACE_ENABLED=TRUE # PROJ_CFLAGS+=-DLL_TRACE_ENABLED=TRUE # PROJ_CFLAGS+=-DLL_DBG_PIN_ENABLED=TRUE @@ -143,6 +145,7 @@ PROJ_CFLAGS+=-DINIT_OBSERVER PROJ_CFLAGS+=-DINIT_CENTRAL PROJ_CFLAGS+=-DINIT_PERIPHERAL PROJ_CFLAGS+=-DINIT_ENCRYPTED +PROJ_CFLAGS+=-DINIT_PHY LL_ENABLE_TESTER=1 diff --git a/lib/sdk/Applications/EvKitExamples/BLE_hci_uart/chci_drv.c b/lib/sdk/Applications/EvKitExamples/BLE_hci_uart/chci_drv.c index 3e8554a29a65e57cfeebf4983ca2a85a2e09cf6d..d7fff06b341a83e94a784c26696de38b7d2ed13d 100644 --- a/lib/sdk/Applications/EvKitExamples/BLE_hci_uart/chci_drv.c +++ b/lib/sdk/Applications/EvKitExamples/BLE_hci_uart/chci_drv.c @@ -114,7 +114,7 @@ void chciDrvInit(void) .stop = UART_STOP_1, .flow = UART_FLOW_CTRL_DIS, .pol = UART_FLOW_POL_DIS, - .baud = 115200, + .baud = 2000000, .clksel = UART_CLKSEL_SYSTEM }; diff --git a/lib/sdk/Applications/EvKitExamples/BLE_hci_uart/main.c b/lib/sdk/Applications/EvKitExamples/BLE_hci_uart/main.c index b8b316005c17990aac840ad3032d26ffc7057307..04622a8bff13840e4a51870427648417afc3c2e5 100644 --- a/lib/sdk/Applications/EvKitExamples/BLE_hci_uart/main.c +++ b/lib/sdk/Applications/EvKitExamples/BLE_hci_uart/main.c @@ -86,7 +86,7 @@ extern void StackInit(void); /*************************************************************************************************/ void SysTick_Handler(void) { - WsfTimerUpdate(1); + WsfTimerUpdate(WSF_MS_PER_TICK); } /*************************************************************************************************/ @@ -103,13 +103,6 @@ static bool_t myTrace(const uint8_t *pBuf, uint32_t len) return FALSE; } -/*************************************************************************************************/ -void PalSysAssertTrap(void) -{ - printf("Assertion detected\n"); - while(1) {} -} - /*************************************************************************************************/ /*! * \brief Initialize WSF. diff --git a/lib/sdk/Applications/EvKitExamples/BLE_hci_uart/stack_setup.c b/lib/sdk/Applications/EvKitExamples/BLE_hci_uart/stack_setup.c index 0e917b87d420eb9a428475ce6ff98a1ef30c5005..d19dda648cdc0a6e55c3fb9a141221f591147b0f 100644 --- a/lib/sdk/Applications/EvKitExamples/BLE_hci_uart/stack_setup.c +++ b/lib/sdk/Applications/EvKitExamples/BLE_hci_uart/stack_setup.c @@ -30,8 +30,7 @@ #define LL_IMPL_REV 0x2303 -#define LL_MEMORY_FOOTPRINT 0x9e92 -// #define LL_MEMORY_FOOTPRINT 0xEA0 +#define LL_MEMORY_FOOTPRINT 0xF022 #ifdef _RTE_ #include "RTE_Components.h" // IAR/Keil Component selection @@ -43,12 +42,12 @@ const LlRtCfg_t _ll_cfg = { /* Device */ /*compId*/ LL_COMP_ID_ARM, /*implRev*/ LL_IMPL_REV, - /*btVer*/ LL_VER_BT_CORE_SPEC_5_0, + /*btVer*/ LL_VER_BT_CORE_SPEC_5_1, /*_align32 */ 0, // padding for alignment /* Advertiser */ - /*maxAdvSets*/ 1, // 4 Extended Advertising Sets - /*maxAdvReports*/ 1, + /*maxAdvSets*/ 6, + /*maxAdvReports*/ 6, /*maxExtAdvDataLen*/ LL_MAX_ADV_DATA_LEN, /*defExtAdvDataFrag*/ 64, /*auxDelayUsec*/ 0, @@ -58,10 +57,10 @@ const LlRtCfg_t _ll_cfg = { /*maxExtScanDataLen*/ LL_MAX_ADV_DATA_LEN, /* Connection */ - /*maxConn*/ 8, + /*maxConn*/ 4, /*numTxBufs*/ 16, /*numRxBufs*/ 16, - /*maxAclLen*/ 512, + /*maxAclLen*/ 256, /*defTxPwrLvl*/ 0, /*ceJitterUsec*/ 0, diff --git a/lib/sdk/Applications/EvKitExamples/BLE_scanner/Makefile b/lib/sdk/Applications/EvKitExamples/BLE_scanner/Makefile index 4e8d5ad6baf9ef17518ca837709f6f7efe14704b..762e702b2b78cff81f6ceacdc9ee052db716b6dc 100644 --- a/lib/sdk/Applications/EvKitExamples/BLE_scanner/Makefile +++ b/lib/sdk/Applications/EvKitExamples/BLE_scanner/Makefile @@ -195,7 +195,6 @@ PROJ_CFLAGS+=-DMXC_ASSERT_ENABLE=TRUE PROJ_CFLAGS+=-DWSF_ASSERT_ENABLED=TRUE # PROJ_CFLAGS+=-DLL_TRACE_ENABLED=TRUE # PROJ_CFLAGS+=-DLL_DBG_PIN_ENABLED=TRUE -PROJ_CFLAGS+=-DWSF_MS_PER_TICK=1 #-------------------- @@ -209,6 +208,7 @@ PROJ_CFLAGS+=-DINIT_OBSERVER PROJ_CFLAGS+=-DINIT_CENTRAL # PROJ_CFLAGS+=-DINIT_PERIPHERAL PROJ_CFLAGS+=-DINIT_ENCRYPTED +PROJ_CFLAGS+=-DINIT_PHY PROJ_CFLAGS+=-DLL_NUM_ADV_FILT=32 ENABLE_LL_TESTER?=#1 diff --git a/lib/sdk/Applications/EvKitExamples/BLE_scanner/main.c b/lib/sdk/Applications/EvKitExamples/BLE_scanner/main.c index 80a2cf44447834d07d0feee9f40d10c4f88f7f2a..dc87627af279c92d4dfe2d003473d66df989b879 100644 --- a/lib/sdk/Applications/EvKitExamples/BLE_scanner/main.c +++ b/lib/sdk/Applications/EvKitExamples/BLE_scanner/main.c @@ -92,7 +92,7 @@ extern void StackInitScanner(void); /*************************************************************************************************/ void SysTick_Handler(void) { - WsfTimerUpdate(1); + WsfTimerUpdate(WSF_MS_PER_TICK); } /*************************************************************************************************/ @@ -109,13 +109,6 @@ static bool_t myTrace(const uint8_t *pBuf, uint32_t len) return FALSE; } -/*************************************************************************************************/ -void PalSysAssertTrap(void) -{ - printf("Assertion detected\n"); - while(1) {} -} - /*************************************************************************************************/ /*! * \brief Initialize WSF. diff --git a/lib/sdk/Applications/EvKitExamples/Bootloader/.cproject b/lib/sdk/Applications/EvKitExamples/Bootloader/.cproject new file mode 100644 index 0000000000000000000000000000000000000000..755e731a076d081910151f84018533b670a65ced --- /dev/null +++ b/lib/sdk/Applications/EvKitExamples/Bootloader/.cproject @@ -0,0 +1,107 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage"> + <storageModule moduleId="org.eclipse.cdt.core.settings"> + <cconfiguration id="ilg.gnuarmeclipse.managedbuild.cross.config.elf.debug.1674944962"> + <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="ilg.gnuarmeclipse.managedbuild.cross.config.elf.debug.1674944962" moduleId="org.eclipse.cdt.core.settings" name="Debug"> + <externalSettings/> + <extensions> + <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/> + <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + </extensions> + </storageModule> + <storageModule moduleId="cdtBuildSystem" version="4.0.0"> + <configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" cleanCommand="${cross_rm} -rf" description="" id="ilg.gnuarmeclipse.managedbuild.cross.config.elf.debug.1674944962" name="Debug" parent="ilg.gnuarmeclipse.managedbuild.cross.config.elf.debug"> + <folderInfo id="ilg.gnuarmeclipse.managedbuild.cross.config.elf.debug.1674944962." name="/" resourcePath=""> + <toolChain id="ilg.gnuarmeclipse.managedbuild.cross.toolchain.elf.debug.548125692" name="Cross ARM GCC" superClass="ilg.gnuarmeclipse.managedbuild.cross.toolchain.elf.debug"> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.level.1448195934" name="Optimization Level" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.level" value="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.level.none" valueType="enumerated"/> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.messagelength.989348626" name="Message length (-fmessage-length=0)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.messagelength" value="true" valueType="boolean"/> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.signedchar.573934961" name="'char' is signed (-fsigned-char)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.signedchar" value="true" valueType="boolean"/> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.functionsections.1195068176" name="Function sections (-ffunction-sections)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.functionsections" value="true" valueType="boolean"/> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.datasections.1035348629" name="Data sections (-fdata-sections)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.datasections" value="true" valueType="boolean"/> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.debugging.level.31679983" name="Debug level" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.debugging.level" value="ilg.gnuarmeclipse.managedbuild.cross.option.debugging.level.max" valueType="enumerated"/> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.debugging.format.1676901946" name="Debug format" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.debugging.format"/> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.toolchain.name.1729767352" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.toolchain.name" value="GNU Tools for ARM Embedded Processors" valueType="string"/> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.architecture.1708484008" name="Architecture" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.architecture" value="ilg.gnuarmeclipse.managedbuild.cross.option.architecture.arm" valueType="enumerated"/> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.arm.target.family.178519983" name="ARM family" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.arm.target.family" value="ilg.gnuarmeclipse.managedbuild.cross.option.arm.target.mcpu.cortex-m3" valueType="enumerated"/> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.arm.target.instructionset.956545422" name="Instruction set" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.arm.target.instructionset" value="ilg.gnuarmeclipse.managedbuild.cross.option.arm.target.instructionset.thumb" valueType="enumerated"/> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.command.prefix.1580514969" name="Prefix" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.command.prefix" value="arm-none-eabi-" valueType="string"/> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.command.c.1246670973" name="C compiler" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.command.c" value="gcc" valueType="string"/> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.command.cpp.1674926322" name="C++ compiler" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.command.cpp" value="g++" valueType="string"/> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.command.ar.2051566192" name="Archiver" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.command.ar" value="ar" valueType="string"/> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.command.objcopy.408066731" name="Hex/Bin converter" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.command.objcopy" value="objcopy" valueType="string"/> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.command.objdump.1900584936" name="Listing generator" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.command.objdump" value="objdump" valueType="string"/> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.command.size.1096852527" name="Size command" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.command.size" value="size" valueType="string"/> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.command.make.937347953" name="Build command" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.command.make" value="make" valueType="string"/> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.command.rm.1468247042" name="Remove command" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.command.rm" value="rm" valueType="string"/> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.addtools.createflash.1529750846" name="Create flash image" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.addtools.createflash" value="true" valueType="boolean"/> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.addtools.printsize.667765305" name="Print size" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.addtools.printsize" value="true" valueType="boolean"/> + <targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="ilg.gnuarmeclipse.managedbuild.cross.targetPlatform.786533016" isAbstract="false" osList="all" superClass="ilg.gnuarmeclipse.managedbuild.cross.targetPlatform"/> + <builder arguments="ECLIPSE=1" buildPath="${workspace_loc:/Bootloader}" command="make" id="ilg.gnuarmeclipse.managedbuild.cross.builder.592880777" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="ilg.gnuarmeclipse.managedbuild.cross.builder"/> + <tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.assembler.1648672385" name="Cross ARM GNU Assembler" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.assembler"> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.usepreprocessor.1969112665" name="Use preprocessor" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.usepreprocessor" value="true" valueType="boolean"/> + <inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.assembler.input.507854261" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.assembler.input"/> + </tool> + <tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.1576427906" name="Cross ARM C Compiler" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler"> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.include.paths.1576427906" name="Include paths (-I)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.include.paths" useByScannerDiscovery="true" valueType="includePath"> + <listOptionValue builtIn="false" value=""${MAXIM_PATH}/Firmware/MAX32665/Libraries/CMSIS/Device/Maxim/MAX32665/Include""/> + <listOptionValue builtIn="false" value=""${MAXIM_PATH}/Firmware/MAX32665/Libraries/MAX32665PeriphDriver/Include""/> + <listOptionValue builtIn="false" value=""${MAXIM_PATH}/Firmware/MAX32665/Libraries/Boards/EvKit_V1/Include""/> + <listOptionValue builtIn="false" value=""${MAXIM_PATH}/Firmware/MAX32665/Libraries/Boards/Include""/> + <listOptionValue builtIn="false" value=""${MAXIM_PATH}/Firmware/MAX32665/Libraries/CMSIS/Include""/> + <listOptionValue builtIn="false" value=""${MAXIM_PATH}/Toolchain/arm-none-eabi/include""/> + <listOptionValue builtIn="false" value=""${MAXIM_PATH}/Toolchain/arm-none-eabi/include/sys""/> + <listOptionValue builtIn="false" value=""${MAXIM_PATH}/Toolchain/lib/gcc/arm-none-eabi/6.3.1/include""/> + </option> + <inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.input.68945223" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.input"/> + </tool> + <tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.compiler.794996645" name="Cross ARM C++ Compiler" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.compiler"/> + <tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.c.linker.675776866" name="Cross ARM C Linker" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.c.linker"> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.gcsections.185399645" name="Remove unused sections (-Xlinker --gc-sections)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.gcsections" value="true" valueType="boolean"/> + <inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.c.linker.input.246156916" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.c.linker.input"> + <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/> + <additionalInput kind="additionalinput" paths="$(LIBS)"/> + </inputType> + </tool> + <tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.linker.391142733" name="Cross ARM C++ Linker" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.linker"> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.gcsections.2099090970" name="Remove unused sections (-Xlinker --gc-sections)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.gcsections" value="true" valueType="boolean"/> + </tool> + <tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.archiver.399743328" name="Cross ARM GNU Archiver" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.archiver"/> + <tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.createflash.822983655" name="Cross ARM GNU Create Flash Image" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.createflash"/> + <tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.createlisting.1050446219" name="Cross ARM GNU Create Listing" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.createlisting"> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.createlisting.source.335976671" name="Display source (--source|-S)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.createlisting.source" value="true" valueType="boolean"/> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.createlisting.allheaders.964898349" name="Display all headers (--all-headers|-x)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.createlisting.allheaders" value="true" valueType="boolean"/> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.createlisting.demangle.972868647" name="Demangle names (--demangle|-C)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.createlisting.demangle" value="true" valueType="boolean"/> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.createlisting.linenumbers.890608562" name="Display line numbers (--line-numbers|-l)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.createlisting.linenumbers" value="true" valueType="boolean"/> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.createlisting.wide.1669392057" name="Wide lines (--wide|-w)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.createlisting.wide" value="true" valueType="boolean"/> + </tool> + <tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.printsize.403251962" name="Cross ARM GNU Print Size" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.printsize"> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.printsize.format.1919947275" name="Size format" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.printsize.format"/> + </tool> + </toolChain> + </folderInfo> + </configuration> + </storageModule> + <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/> + </cconfiguration> + </storageModule> + <storageModule moduleId="cdtBuildSystem" version="4.0.0"> + <project id="Bootloader.ilg.gnuarmeclipse.managedbuild.cross.target.elf.737306620" name="Executable" projectType="ilg.gnuarmeclipse.managedbuild.cross.target.elf"/> + </storageModule> + <storageModule moduleId="scannerConfiguration"> + <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> + <scannerConfigBuildInfo instanceId="ilg.gnuarmeclipse.managedbuild.cross.config.elf.debug.1674944962;ilg.gnuarmeclipse.managedbuild.cross.config.elf.debug.1674944962.;ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.1576427906;ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.input.68945223"> + <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> + </scannerConfigBuildInfo> + </storageModule> + <storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/> + <storageModule moduleId="refreshScope" versionNumber="2"> + <configuration configurationName="Debug"> + <resource resourceType="PROJECT" workspacePath="/Bootloader"/> + </configuration> + </storageModule> + <storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/> +</cproject> diff --git a/lib/sdk/Applications/EvKitExamples/Bootloader/.project b/lib/sdk/Applications/EvKitExamples/Bootloader/.project new file mode 100644 index 0000000000000000000000000000000000000000..de669ffd862d3d727c6ddf20c6b8b992fd1907ce --- /dev/null +++ b/lib/sdk/Applications/EvKitExamples/Bootloader/.project @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>Bootloader</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name> + <triggers>clean,full,incremental,</triggers> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name> + <triggers>full,incremental,</triggers> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.cdt.core.cnature</nature> + <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature> + <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature> + </natures> +</projectDescription> diff --git a/lib/sdk/Applications/EvKitExamples/Bootloader/.settings/language.settings.xml b/lib/sdk/Applications/EvKitExamples/Bootloader/.settings/language.settings.xml new file mode 100644 index 0000000000000000000000000000000000000000..e5a1647610f97197abe406e8ef1bb9e62065f5a1 --- /dev/null +++ b/lib/sdk/Applications/EvKitExamples/Bootloader/.settings/language.settings.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<project> + <configuration id="ilg.gnuarmeclipse.managedbuild.cross.config.elf.debug.1674944962" name="Debug"> + <extension point="org.eclipse.cdt.core.LanguageSettingsProvider"> + <provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/> + <provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/> + <provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/> + </extension> + </configuration> +</project> diff --git a/lib/sdk/Applications/EvKitExamples/Bootloader/Bootloader.launch b/lib/sdk/Applications/EvKitExamples/Bootloader/Bootloader.launch new file mode 100644 index 0000000000000000000000000000000000000000..284b5ffa3bf5367276e89d77801621fe32da47b3 --- /dev/null +++ b/lib/sdk/Applications/EvKitExamples/Bootloader/Bootloader.launch @@ -0,0 +1,64 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<launchConfiguration type="ilg.gnuarmeclipse.debug.gdbjtag.openocd.launchConfigurationType"> +<booleanAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.doContinue" value="true"/> +<booleanAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.doDebugInRam" value="false"/> +<booleanAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.doFirstReset" value="true"/> +<booleanAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.doGdbServerAllocateConsole" value="true"/> +<booleanAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.doGdbServerAllocateTelnetConsole" value="false"/> +<booleanAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.doSecondReset" value="true"/> +<booleanAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.doStartGdbServer" value="true"/> +<booleanAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.enableSemihosting" value="false"/> +<stringAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.firstResetType" value="init"/> +<stringAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.gdbClientOtherCommands" value=""/> +<stringAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.gdbClientOtherOptions" value=""/> +<stringAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.gdbServerConnectionAddress" value=""/> +<stringAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.gdbServerExecutable" value="openocd"/> +<intAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.gdbServerGdbPortNumber" value="3333"/> +<stringAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.gdbServerLog" value=""/> +<stringAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.gdbServerOther" value="-s ${env_var:TOOLCHAIN_PATH}/share/openocd/scripts -f interface/cmsis-dap.cfg -f target/MAX32665.cfg"/> +<intAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.gdbServerTelnetPortNumber" value="4444"/> +<stringAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.otherInitCommands" value=""/> +<stringAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.otherRunCommands" value=""/> +<stringAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.secondResetType" value="halt"/> +<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.imageFileName" value=""/> +<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.imageOffset" value=""/> +<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.ipAddress" value="localhost"/> +<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.jtagDevice" value="GNU ARM OpenOCD"/> +<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadImage" value="true"/> +<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadSymbols" value="true"/> +<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.pcRegister" value=""/> +<intAttribute key="org.eclipse.cdt.debug.gdbjtag.core.portNumber" value="3333"/> +<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setPcRegister" value="false"/> +<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setResume" value="false"/> +<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setStopAt" value="true"/> +<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.stopAt" value="main"/> +<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsFileName" value=""/> +<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsOffset" value=""/> +<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useFileForImage" value="false"/> +<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useFileForSymbols" value="false"/> +<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useProjBinaryForImage" value="true"/> +<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useProjBinaryForSymbols" value="true"/> +<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useRemoteTarget" value="true"/> +<stringAttribute key="org.eclipse.cdt.debug.mi.core.commandFactory" value="Standard (Windows)"/> +<stringAttribute key="org.eclipse.cdt.debug.mi.core.protocol" value="mi"/> +<booleanAttribute key="org.eclipse.cdt.debug.mi.core.verboseMode" value="false"/> +<stringAttribute key="org.eclipse.cdt.dsf.gdb.DEBUG_NAME" value="arm-none-eabi-gdb"/> +<booleanAttribute key="org.eclipse.cdt.dsf.gdb.UPDATE_THREADLIST_ON_SUSPEND" value="false"/> +<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/> +<stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/> +<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="build/MAX32665.elf"/> +<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="Bootloader"/> +<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="true"/> +<stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value="ilg.gnuarmeclipse.managedbuild.cross.config.elf.debug.1674944962"/> +<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> +<listEntry value="/Bootloader"/> +</listAttribute> +<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> +<listEntry value="4"/> +</listAttribute> +<listAttribute key="org.eclipse.debug.ui.favoriteGroups"> +<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/> +</listAttribute> +<stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <memoryBlockExpressionList context="Context string"/> "/> +<stringAttribute key="process_factory_id" value="org.eclipse.cdt.dsf.gdb.GdbProcessFactory"/> +</launchConfiguration> diff --git a/lib/sdk/Applications/EvKitExamples/Bootloader/Makefile b/lib/sdk/Applications/EvKitExamples/Bootloader/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..48f27513bca3c78eed1b1848b2ca53a2214e62fe --- /dev/null +++ b/lib/sdk/Applications/EvKitExamples/Bootloader/Makefile @@ -0,0 +1,107 @@ +################################################################################ +# Copyright (C) 2014 Maxim Integrated Products, Inc., All Rights Reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES +# OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +# OTHER DEALINGS IN THE SOFTWARE. +# +# Except as contained in this notice, the name of Maxim Integrated +# Products, Inc. shall not be used except as stated in the Maxim Integrated +# Products, Inc. Branding Policy. +# +# The mere transfer of this software does not imply any licenses +# of trade secrets, proprietary technology, copyrights, patents, +# trademarks, maskwork rights, or any other form of intellectual +# property whatsoever. Maxim Integrated Products, Inc. retains all +# ownership rights. +# +# $Id: Makefile 49655 2019-12-09 16:21:52Z kevin.gillespie $ +# +################################################################################ + + +# This is the name of the build output file +ifeq "$(PROJECT)" "" +PROJECT=max32665 +endif + +# Specify the target processor +ifeq "$(TARGET)" "" +TARGET=MAX32665 +endif + +# Select 'GCC' or 'IAR' compiler +COMPILER=GCC + +# Create Target name variables +TARGET_UC:=$(shell echo $(TARGET) | tr a-z A-Z) +TARGET_LC:=$(shell echo $(TARGET) | tr A-Z a-z) + + +# Unset PROJ_CFLAGS so remote building of this application does not carry over +# already defined flags +PROJ_CFLAGS= + +# This is the path to the CMSIS root directory +ifeq "$(MAXIM_PATH)" "" +LIBS_DIR=../../../Libraries +else +LIBS_DIR=/$(subst \,/,$(subst :,,$(MAXIM_PATH))/Firmware/$(TARGET_UC)/Libraries) +endif +CMSIS_ROOT=$(LIBS_DIR)/CMSIS + +# Source files for this test (add path to VPATH below) +SRCS = main.c +SRCS += boot_lower.S + +# Where to find source files for this test +VPATH = . + +# Where to find header files for this test +IPATH = . + +############################################################################## +# OS Check/Utility definitions +ifeq '$(findstring ;,$(PATH))' ';' + BUILD_OS := Windows +else + BUILD_OS := $(shell uname 2>/dev/null || echo Unknown) + BUILD_OS := $(patsubst MSYS%,MSYS,$(BUILD_OS)) + BUILD_OS := $(patsubst MINGW%,MSYS,$(BUILD_OS)) +endif + +################################################################################ +# Project build configuration. + +# Use this variable to override default compilier optimization. +#MXC_OPTIMIZE_CFLAGS=-Os +#MXC_OPTIMIZE_CFLAGS=-O0 -fomit-frame-pointer + +# Point this variable to a linker file to override the default file +LINKERFILE=$(TARGET_LC)_bootloader.ld + +################################################################################ +# Include external library makefiles here + +# Include the Peripheral Driver Library +PERIPH_DRIVER_DIR=$(LIBS_DIR)/$(TARGET)PeriphDriver +include ${PERIPH_DRIVER_DIR}/periphdriver.mk + +################################################################################ +# Include the rules for building for this target. All other makefiles should be +# included before this one. +include $(CMSIS_ROOT)/Device/Maxim/$(TARGET_UC)/Source/$(COMPILER)/$(TARGET_LC).mk diff --git a/lib/sdk/Applications/EvKitExamples/Bootloader/addr_defines.h b/lib/sdk/Applications/EvKitExamples/Bootloader/addr_defines.h new file mode 100644 index 0000000000000000000000000000000000000000..4475c247e4667d7fbfc577da6a02d23cdc2f7a9d --- /dev/null +++ b/lib/sdk/Applications/EvKitExamples/Bootloader/addr_defines.h @@ -0,0 +1,48 @@ +/******************************************************************************* +* Copyright (C) Maxim Integrated Products, Inc., All rights Reserved. +* +* This software is protected by copyright laws of the United States and +* of foreign countries. This material may also be protected by patent laws +* and technology transfer regulations of the United States and of foreign +* countries. This software is furnished under a license agreement and/or a +* nondisclosure agreement and may only be used or reproduced in accordance +* with the terms of those agreements. Dissemination of this information to +* any party or parties not specified in the license agreement and/or +* nondisclosure agreement is expressly prohibited. +* +* The above copyright notice and this permission notice shall be included +* in all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +* IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES +* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +* +* Except as contained in this notice, the name of Maxim Integrated +* Products, Inc. shall not be used except as stated in the Maxim Integrated +* Products, Inc. Branding Policy. +* +* The mere transfer of this software does not imply any licenses +* of trade secrets, proprietary technology, copyrights, patents, +* trademarks, maskwork rights, or any other form of intellectual +* property whatsoever. Maxim Integrated Products, Inc. retains all +* ownership rights. +******************************************************************************* +*/ + + +#ifndef _ADDR_DEFINES_H_ +#define _ADDR_DEFINES_H_ + +#define SCB_VTOR_REG 0xE000ED08 + +/* #define FLASH_UPPER_START (MXC_FLASH1_MEM_BASE) */ +#define FLASH_UPPER_START (0x10080000) + +/* #define FLASH_LOWER_START (MXC_FLASH0_MEM_BASE + MXC_FLASH_PAGE_SIZE) */ +#define FLASH_LOWER_START (0x10000000 + 0x2000) + +#endif /* _ADDR_DEFINES_H_ */ diff --git a/lib/sdk/Applications/EvKitExamples/Bootloader/boot_lower.S b/lib/sdk/Applications/EvKitExamples/Bootloader/boot_lower.S new file mode 100644 index 0000000000000000000000000000000000000000..2e3b01ec8146ff283264f8bf65deb50b0a12af1a --- /dev/null +++ b/lib/sdk/Applications/EvKitExamples/Bootloader/boot_lower.S @@ -0,0 +1,65 @@ +/******************************************************************************* + * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of Maxim Integrated + * Products, Inc. shall not be used except as stated in the Maxim Integrated + * Products, Inc. Branding Policy. + * + * The mere transfer of this software does not imply any licenses + * of trade secrets, proprietary technology, copyrights, patents, + * trademarks, maskwork rights, or any other form of intellectual + * property whatsoever. Maxim Integrated Products, Inc. retains all + * ownership rights. + * + * $Date: 2019-12-09 10:40:53 -0600 (Mon, 09 Dec 2019) $ + * $Revision: 49656 $ + * + ******************************************************************************/ + +#include "addr_defines.h" + + .syntax unified + .arch armv7-m + .text + .thumb + .thumb_func + .align 2 + + + .globl Boot_Lower + .type Boot_Lower %function +/* Boot from the lower flash array */ +Boot_Lower: + + ldr r0,=FLASH_LOWER_START + ldr r1,=SCB_VTOR_REG + + /* First 32-bit word in image is initial stack pointer */ + /* Second 32-bit word in image is Address of the Reset Handler */ + + /* Set VTOR with vector table base address */ + str r0,[r1] + /* Load initial SP */ + ldr sp,[r0] + /* Load LR with address of the Reset Handler */ + ldr lr,[r0,#4] + /* Jump to Reset Handler. */ + bx lr diff --git a/lib/sdk/Applications/EvKitExamples/Bootloader/main.c b/lib/sdk/Applications/EvKitExamples/Bootloader/main.c new file mode 100644 index 0000000000000000000000000000000000000000..66876aff5c361c9fcb7f72023b6e2398f2370cf2 --- /dev/null +++ b/lib/sdk/Applications/EvKitExamples/Bootloader/main.c @@ -0,0 +1,176 @@ +/******************************************************************************* + * Copyright (C) 2018 Maxim Integrated Products, Inc., All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of Maxim Integrated + * Products, Inc. shall not be used except as stated in the Maxim Integrated + * Products, Inc. Branding Policy. + * + * The mere transfer of this software does not imply any licenses + * of trade secrets, proprietary technology, copyrights, patents, + * trademarks, maskwork rights, or any other form of intellectual + * property whatsoever. Maxim Integrated Products, Inc. retains all + * ownership rights. + * + * $Date: 2019-12-09 10:40:53 -0600 (Mon, 09 Dec 2019) $ + * $Revision: 49656 $ + * + ******************************************************************************/ + +#include <string.h> +#include "mxc_config.h" +#include "hash.h" +#include "flc.h" + +/************************************************************************************************** + Macros +**************************************************************************************************/ +#define SHA256_BYTES (256/8) +#define FLASH_UPPER_START (MXC_FLASH1_MEM_BASE) +#define FLASH_LOWER_START (MXC_FLASH0_MEM_BASE + MXC_FLASH_PAGE_SIZE) +#define FLASH_ERASED_WORD 0xFFFFFFFF + +/************************************************************************************************** + Local Variables +**************************************************************************************************/ + +/************************************************************************************************** + Functions +**************************************************************************************************/ + +/* Defined in boot_lower.S */ +extern void Boot_Lower(void); + +void bootError(void) +{ + NVIC_SystemReset(); +} + +int flashPageErased(uint32_t* addr) +{ + /* Determine if this page is totally erased */ + int i; + for(i = 0; i < (MXC_FLASH_PAGE_SIZE/4); i++) { + if(*(addr+i) != FLASH_ERASED_WORD) { + return 0; + } + } + + return 1; +} + +uint32_t findUpperLen(void) +{ + uint32_t* flashPagePointer = (uint32_t*)FLASH_UPPER_START; + + /* Find the first erased page in the upper flash*/ + while(1) { + + if(*flashPagePointer == FLASH_ERASED_WORD) { + /* Make sure the entire page is erased */ + if(flashPageErased(flashPagePointer)) { + break; + } + } + + flashPagePointer += (MXC_FLASH_PAGE_SIZE/4); + } + + /* Length is 0 */ + if(flashPagePointer == (uint32_t*)FLASH_UPPER_START) { + return 0; + } + + /* search backwards for the first bytes that isn't erased */ + while(*(flashPagePointer--) == FLASH_ERASED_WORD) {} + flashPagePointer+= 2; + + /* return the starting address of the SHA digest, last address of the image */ + return (uint32_t)(flashPagePointer - (SHA256_BYTES/4) - (FLASH_UPPER_START/4)); +} + + +/* Program the digests of the image, used to test addressing */ +void programDigest(uint8_t *addr, uint32_t len) +{ + char digest[SHA256_BYTES]; + + /* Calculate the digest */ + TPU_Hash_Reset(); + TPU_Hash_Config(TPU_HASH_SHA256); + TPU_SHA((const char*)addr, TPU_HASH_SHA256, len, digest); + TPU_Hash_Shutdown(); + + /* Write the digest at the end of the image */ + FLC_Write((uint32_t)(addr+len), SHA256_BYTES, (uint32_t*)digest); +} + +int main(void) +{ + + char digest[SHA256_BYTES]; + const char *addr = (const char*)FLASH_UPPER_START; + + /* disable interrupts to prevent these operations from being interrupted */ + __disable_irq(); + + /* Get the length of the image in the upper flash array */ + uint32_t len = findUpperLen(); + + /* Attempt to verify the upper image if we get a valid length */ + if(len) { + + /* Used for testing, remove for actual application */ + /* len += SHA256_BYTES; */ + /* programDigest((uint8_t *)addr, len); */ + + /* Calculate the digest */ + TPU_Hash_Reset(); + TPU_Hash_Config(TPU_HASH_SHA256); + TPU_SHA(addr, TPU_HASH_SHA256, len, digest); + TPU_Hash_Shutdown(); + + /* Check the calculated digest against what was received */ + if(memcmp(digest, (const char *)(addr + len), SHA256_BYTES) == 0) { + + /* Erase the destination pages */ + if(FLC_MultiPageErase(FLASH_LOWER_START, (FLASH_LOWER_START + len)) != E_NO_ERROR) { + /* Failed to erase pages */ + bootError(); + } + + /* Copy the new firmware image */ + if(FLC_Write(FLASH_LOWER_START, len, (uint32_t*)FLASH_UPPER_START) != E_NO_ERROR) { + /* Failed to write new image */ + bootError(); + } + + /* Erase the upper pages */ + if(FLC_MultiPageErase(FLASH_UPPER_START, (FLASH_UPPER_START+ len)) != E_NO_ERROR) { + /* Failed to erase update pages, we can still boot from the lower image */ + } + } + } + + /* Boot from lower image */ + Boot_Lower(); + + while (1) {} +} diff --git a/lib/sdk/Applications/EvKitExamples/Bootloader/max32665_bootloader.ld b/lib/sdk/Applications/EvKitExamples/Bootloader/max32665_bootloader.ld new file mode 100644 index 0000000000000000000000000000000000000000..400b04e0a6f1951355dfb8d590911d4b9808af08 --- /dev/null +++ b/lib/sdk/Applications/EvKitExamples/Bootloader/max32665_bootloader.ld @@ -0,0 +1,219 @@ +/******************************************************************************* + * Copyright (C) 2017 Maxim Integrated Products, Inc., All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of Maxim Integrated + * Products, Inc. shall not be used except as stated in the Maxim Integrated + * Products, Inc. Branding Policy. + * + * The mere transfer of this software does not imply any licenses + * of trade secrets, proprietary technology, copyrights, patents, + * trademarks, maskwork rights, or any other form of intellectual + * property whatsoever. Maxim Integrated Products, Inc. retains all + * ownership rights. + * + * $Date: 2019-12-06 15:25:52 -0600 (Fri, 06 Dec 2019) $ + * $Revision: 49605 $ + * + ******************************************************************************/ + + +/* Allocate space if SDMA_SIZE is defined at the start of SRAM*/ +SRAM_ORIGIN = 0x20000000; +SDMA_CODE_LEN = DEFINED(SDMA_CODE_SIZE) ? SDMA_CODE_SIZE : 0; +SDMA_DATA_LEN = DEFINED(SDMA_DATA_SIZE) ? SDMA_DATA_SIZE : 0; +SDMA_LEN = SDMA_CODE_LEN + SDMA_DATA_LEN; +OTP_LEN = DEFINED(SDMA_CODE_SIZE) ? 0x40 : 0; +SHARED_LEN = DEFINED(SDMA_CODE_SIZE) ? 1k : 0; +SHARED_LEN_HALF = SHARED_LEN / 2; + +OTP_ADDR = SRAM_ORIGIN; +SHARED_ADDR = OTP_ADDR + OTP_LEN; +SDMA_DATA_ADDR = SHARED_ADDR + SHARED_LEN; +SDMA_CODE_ADDR = SDMA_DATA_ADDR + SDMA_DATA_LEN; +SRAM_ADDR = SDMA_CODE_ADDR + SDMA_CODE_LEN; + +/* Give leftover SRAM to the SRAM memory region */ +/* SRAM_SIZE must be defined */ +SRAM_LEN = SRAM_SIZE - OTP_LEN - SHARED_LEN - SDMA_LEN; + +/* SPID and SPIX Sections here are maximum possible sizes */ +/* If used, they should be adjusted for the external Flash/RAM size */ +MEMORY { + SPIX (rx) : ORIGIN = 0x08000000, LENGTH = 128M + + /* Reserve the first page of flash for the bootloader */ + FLASH (rx) : ORIGIN = 0x10000000, LENGTH = 8k + + OTP (rwx) : ORIGIN = OTP_ADDR, LENGTH = OTP_LEN + ARM_SHARED(rwx) : ORIGIN = SHARED_ADDR, LENGTH = SHARED_LEN_HALF + SDMA_SHARED(rwx): ORIGIN = SHARED_ADDR + SHARED_LEN_HALF, LENGTH = SHARED_LEN_HALF + SDMA_DATA (rwx) : ORIGIN = SDMA_DATA_ADDR, LENGTH = SDMA_DATA_LEN + SDMA_CODE (rwx) : ORIGIN = SDMA_CODE_ADDR, LENGTH = SDMA_CODE_LEN + + SRAM (rwx) : ORIGIN = SRAM_ADDR, LENGTH = SRAM_LEN + SPID (rw) : ORIGIN = 0x80000000, LENGTH = 512M +} + +SECTIONS { + .text : + { + _text = .; + KEEP(*(.isr_vector)) + *(.text*) /* program code */ + *(.rodata*) /* read-only data: "const" */ + + KEEP(*(.init)) + KEEP(*(.fini)) + + /* C++ Exception handling */ + KEEP(*(.eh_frame*)) + _etext = .; + + } > FLASH + + /* This section will keep the SPIX data until loaded into the external device */ + /* Upon initialization of SPIX (user code needs to do this) */ + .xip_section : + { + KEEP(*(.xip_section*)) + } > SPIX AT>FLASH + + __load_start_xip = LOADADDR(.xip_section); + __load_length_xip = SIZEOF(.xip_section); + + /* it's used for C++ exception handling */ + /* we need to keep this to avoid overlapping */ + .ARM.exidx : + { + __exidx_start = .; + *(.ARM.exidx*) + __exidx_end = .; + } > FLASH + + .data : + { + _data = ALIGN(., 4); + *(.data*) /*read-write initialized data: initialized global variable*/ + *(.spix_config*) /* SPIX configuration functions need to be run from SRAM */ + *(.flashprog*) /* Flash program */ + + + /* These array sections are used by __libc_init_array to call static C++ constructors */ + . = ALIGN(4); + /* preinit data */ + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP(*(.preinit_array)) + PROVIDE_HIDDEN (__preinit_array_end = .); + + . = ALIGN(4); + /* init data */ + PROVIDE_HIDDEN (__init_array_start = .); + KEEP(*(SORT(.init_array.*))) + KEEP(*(.init_array)) + PROVIDE_HIDDEN (__init_array_end = .); + + . = ALIGN(4); + /* finit data */ + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP(*(SORT(.fini_array.*))) + KEEP(*(.fini_array)) + PROVIDE_HIDDEN (__fini_array_end = .); + + _edata = ALIGN(., 4); + } > SRAM AT>FLASH + __load_data = LOADADDR(.data); + + .otp (NOLOAD) : + { + _otp = ALIGN(., 4); + *(.otp*) /*Copy of OTP memory*/ + + _eotp = ALIGN(., 4); + } > OTP + + .arm_shared (NOLOAD) : + { + _arm_shared = ALIGN(., 4); + *(.arm_shared*) /*Shared memory section*/ + + _earm_shared = ALIGN(., 4); + } > ARM_SHARED + + .sdma_shared (NOLOAD) : + { + _sdma_shared = ALIGN(., 4); + *(.sdma_shared*) /*Shared memory section*/ + + _esdma_shared = ALIGN(., 4); + } > SDMA_SHARED + + .sdma_code : + { + _sdma_code = ALIGN(., 4); + *(.sdma_code*) /*SDMA Code*/ + + _esdma_code = ALIGN(., 4); + } > SDMA_CODE AT>FLASH + __load_sdma_code = LOADADDR(.sdma_code); + + .sdma_data : + { + _sdma_data = ALIGN(., 4); + *(.sdma_data*) /*SDMA Data*/ + + _esdma_data = ALIGN(., 4); + } > SDMA_DATA AT>FLASH + __load_sdma_data = LOADADDR(.sdma_data); + + .bss : + { + . = ALIGN(4); + _bss = .; + *(.bss*) /*read-write zero initialized data: uninitialzed global variable*/ + *(COMMON) + _ebss = ALIGN(., 4); + } > SRAM + + /* Setup the stack for Core 1, it will only be used if the user code + * includes a definition of Stack_Size_Core1, which defines the space + * reserved above the main core's stack for core 1's stack */ + + __StackTop_Core1 = ORIGIN(SRAM) + LENGTH(SRAM); + __StackLimit_Core1 = DEFINED(Stack_Size_Core1) ? __StackTop_Core1 - Stack_Size_Core1 : __StackTop_Core1; + + /* Set stack top to end of RAM, and stack limit move down by Stack_Size. + * If core 1 is used, set the stack to the bottom of Core 1's stack region */ + + __StackTop = DEFINED(Stack_Size_Core1) ? __StackLimit_Core1 : ORIGIN(SRAM) + LENGTH(SRAM); + __StackLimit = __StackTop - Stack_Size; + + .heap (COPY): + { + . = ALIGN(4); + *(.heap*) + __HeapLimit = ABSOLUTE(__StackLimit); + } > SRAM + + PROVIDE(__stack = __StackTop); + + /* Check if data + heap + stack(s) exceeds RAM limit */ + ASSERT(__StackLimit >= _ebss, "region RAM overflowed with stack") +} diff --git a/lib/sdk/Applications/EvKitExamples/ECC/main.c b/lib/sdk/Applications/EvKitExamples/ECC/main.c index 1b8300c03e13eeb57ef05cbab56e77e58a7a5832..a6ff31fda51f1f1d859cd38318e7ec8a7600f31a 100644 --- a/lib/sdk/Applications/EvKitExamples/ECC/main.c +++ b/lib/sdk/Applications/EvKitExamples/ECC/main.c @@ -71,12 +71,12 @@ uint32_t ramTop = (MXC_SRAM_MEM_BASE + (MXC_SRAM_MEM_SIZE*0.8)); void ECC_IRQHandler(void) { eccErr = MXC_GCR->eccerr; - eccDErr = MXC_GCR->eccnded; + eccDErr = MXC_GCR->ecc_ced; eccAddr = MXC_GCR->eccerrad; eccFlag = 1; MXC_GCR->eccerr = MXC_GCR->eccerr; - MXC_GCR->eccnded = MXC_GCR->eccnded; + MXC_GCR->ecc_ced = MXC_GCR->ecc_ced; } @@ -95,7 +95,7 @@ int main(void) // Clear all ECC Errors -- write-1-to-clear MXC_GCR->eccerr = MXC_GCR->eccerr; - MXC_GCR->eccnded = MXC_GCR->eccnded; + MXC_GCR->ecc_ced = MXC_GCR->ecc_ced; // Enable interrupts for ECC errors MXC_GCR->eccirqen |= diff --git a/lib/sdk/Applications/EvKitExamples/Flash/main.c b/lib/sdk/Applications/EvKitExamples/Flash/main.c index b44e8174d38a443d7cddf1c6219975ca38e5acc8..53606dbac207699b1ff728a4800590c342e1513a 100644 --- a/lib/sdk/Applications/EvKitExamples/Flash/main.c +++ b/lib/sdk/Applications/EvKitExamples/Flash/main.c @@ -224,11 +224,6 @@ void interrupt_enabler(mxc_flc_regs_t* regs) { } //****************************************************************************** -void flash_burst_mode_en(mxc_flc_regs_t* regs) { - regs->cn |= MXC_F_FLC_CN_BRST; -} -//****************************************************************************** - int main(void) { diff --git a/lib/sdk/Applications/EvKitExamples/FreeRTOSDemo/Makefile b/lib/sdk/Applications/EvKitExamples/FreeRTOSDemo/Makefile index fb54cde35b04901e39c98f365e85c9b4aaacc4c4..5a871893b57fb6df7ba2e7d33d1d7d75a918fae0 100644 --- a/lib/sdk/Applications/EvKitExamples/FreeRTOSDemo/Makefile +++ b/lib/sdk/Applications/EvKitExamples/FreeRTOSDemo/Makefile @@ -73,9 +73,26 @@ VPATH = . # Where to find header files for this test IPATH = . +# Make sure that application is build with hardfp +ifeq "$(MFLOAT_FLAGS)" "soft" +$(error -mfloat-abi=soft not supported by FreeRTOS.) +else +ifeq "$(MFLOAT_FLAGS)" "hard" +else +ifeq "$(MFLOAT_FLAGS)" "hardfp" +else +export MFLOAT_FLAGS=hard +endif +endif +endif + # Enable assertion checking for development PROJ_CFLAGS+=-DMXC_ASSERT_ENABLE +# Prevent warnings for strncat when source buffer is the exact length of the +# length parameter +PROJ_CFLAGS+=-Wno-stringop-overflow + # Point this variable to a linker file to override the default file # LINKERFILE=$(CMSIS_ROOT)/Device/Maxim/$(TARGET_UC)/Source/GCC/$(TARGET_LC).ld diff --git a/lib/sdk/Applications/EvKitExamples/HTMR/HTMR.launch b/lib/sdk/Applications/EvKitExamples/HTMR/HTMR.launch index b20223b4024fc5fe96ee99c1b9c21e852b87fbd4..250a4dc0f3e4f32d0e081e8b21f5cc1095e222fe 100644 --- a/lib/sdk/Applications/EvKitExamples/HTMR/HTMR.launch +++ b/lib/sdk/Applications/EvKitExamples/HTMR/HTMR.launch @@ -47,11 +47,11 @@ <intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/> <stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/> <stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="build/MAX32665.elf"/> -<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="HTimer"/> +<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="HTMR"/> <booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="true"/> <stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value="ilg.gnuarmeclipse.managedbuild.cross.config.elf.debug.1674944962"/> <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> -<listEntry value="/HTimer"/> +<listEntry value="/HTMR"/> </listAttribute> <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> <listEntry value="4"/> diff --git a/lib/sdk/Applications/EvKitExamples/HTMR/main.c b/lib/sdk/Applications/EvKitExamples/HTMR/main.c index 12a59363619e565a4fa06401bebb1f15c215d182..240e99f93cd14711b141db996d1d4a7e4279518d 100644 --- a/lib/sdk/Applications/EvKitExamples/HTMR/main.c +++ b/lib/sdk/Applications/EvKitExamples/HTMR/main.c @@ -36,13 +36,13 @@ /** * @file main.c - * @brief Configures and starts the RTC and demonstrates the use of the alarms. - * @details The RTC is enabled and the sub-second alarm set to trigger every 250 ms. + * @brief Configures and starts the HTMR and demonstrates the use of the alarms. + * @details The HTMR is enabled and the sub-second alarm set to trigger every 250 ms. * P2.25 (LED0) is toggled each time the sub-second alarm triggers. The * time-of-day alarm is set to 2 seconds. When the time-of-day alarm * triggers, the rate of the sub-second alarm is switched to 500 ms. The * time-of-day alarm is then rearmed for another 2 sec. Pressing SW2 will - * output the current value of the RTC to the console UART. + * output the current value of the HTMR to the console UART. */ /***** Includes *****/ diff --git a/lib/sdk/Applications/EvKitExamples/ICC/ICC.launch b/lib/sdk/Applications/EvKitExamples/ICC/ICC.launch index 1da7bbbb51d9244534f2532d120debb9c098e874..eb7f58bab44ae0462d2b20f42154bc94feb5c428 100644 --- a/lib/sdk/Applications/EvKitExamples/ICC/ICC.launch +++ b/lib/sdk/Applications/EvKitExamples/ICC/ICC.launch @@ -47,11 +47,11 @@ <intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/> <stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/> <stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="build/MAX32665.elf"/> -<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="Hello_World"/> +<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="ICC"/> <booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="true"/> <stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value="ilg.gnuarmeclipse.managedbuild.cross.config.elf.debug.1674944962"/> <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> -<listEntry value="/Hello_World"/> +<listEntry value="/ICC"/> </listAttribute> <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> <listEntry value="4"/> diff --git a/lib/sdk/Applications/EvKitExamples/LP/main.c b/lib/sdk/Applications/EvKitExamples/LP/main.c index a92a90979140d839ba48d5da310f538889d0565c..c15dbee2c027172837666df5e06102e32bce596b 100644 --- a/lib/sdk/Applications/EvKitExamples/LP/main.c +++ b/lib/sdk/Applications/EvKitExamples/LP/main.c @@ -176,9 +176,6 @@ void deepsleep(void) { LP_SIMOVregDPowerDown(); SIMO_setVregO_B(810); // Reduce VCOREB to 0.81v - - // Clear background mode enable, enable power failure monitor. - LP_PowerFailMonitorEnable(); // Enable fast wakeup LP_FastWakeupEnable(); @@ -240,12 +237,12 @@ void turnOffUnused(void) { } void turnOffConsole(void) { - MXC_GCR->perckcn0 &= ~MXC_F_GCR_PERCKCN0_T0D; + MXC_GCR->perckcn0 &= ~MXC_F_GCR_PERCKCN0_TIMER0D; TMR_Delay(MXC_TMR0, MSEC(100), NULL); Console_Shutdown(); - MXC_GCR->perckcn0 |= MXC_F_GCR_PERCKCN0_T0D | MXC_F_GCR_PERCKCN0_UART0D; + MXC_GCR->perckcn0 |= MXC_F_GCR_PERCKCN0_TIMER0D | MXC_F_GCR_PERCKCN0_UART0D; } void turnOnConsole(void) { @@ -282,8 +279,6 @@ void setupRTC(void) { } uint32_t ctrl_temp = MXC_RTC->ctrl; - ctrl_temp &= ~MXC_F_RTC_CTRL_X32KMD; - ctrl_temp |= MXC_S_RTC_CTRL_X32KMD_QUIETMODE; MXC_RTC->ctrl = ctrl_temp; if (RTC_CheckBusy()) { printf("Error in setupRTC\n"); diff --git a/lib/sdk/Applications/EvKitExamples/RPU/main.c b/lib/sdk/Applications/EvKitExamples/RPU/main.c index 54f60cbea90247ef633f61c14ce1438d30efd2ba..d8f1cf6c26f5f52b5d2720e3fadb6cb00f560a65 100644 --- a/lib/sdk/Applications/EvKitExamples/RPU/main.c +++ b/lib/sdk/Applications/EvKitExamples/RPU/main.c @@ -102,9 +102,9 @@ int main(void) Core1_Start(); mxc_delay(1000); - // Try to read TMR3's config register - uint32_t invalidaddr = MXC_TMR2->cn; + uint32_t invalidaddr = MXC_TMR3->cn; + printf("TMR3 Control Register: 0x%08x\n", invalidaddr); printf("Did not fault\n"); diff --git a/lib/sdk/Applications/EvKitExamples/RTC/main.c b/lib/sdk/Applications/EvKitExamples/RTC/main.c index d20a54950b6417d9c4b0d0184011d7e9ba83cf16..d9a1d12ea5cebce3760ab78a0137e851e03c4a98 100644 --- a/lib/sdk/Applications/EvKitExamples/RTC/main.c +++ b/lib/sdk/Applications/EvKitExamples/RTC/main.c @@ -156,10 +156,10 @@ int main(void) /* Turn LED off initially */ LED_Off(LED_ALARM); - + int error; sys_cfg_rtc_t sys_cfg = NULL; //No Specific system configuration object - if (RTC_Init(MXC_RTC, 0, 0, &sys_cfg) != E_NO_ERROR) { - printf("Failed RTC_Setup().\n"); + if ((error = RTC_Init(MXC_RTC, 0, 0, &sys_cfg)) != E_NO_ERROR) { + printf("Failed RTC_Setup(). %d \n ", error); printf("Example Failed\n"); while(1); } diff --git a/lib/sdk/Applications/EvKitExamples/SPI/Makefile b/lib/sdk/Applications/EvKitExamples/SPI/Makefile index 41a4289adad8e8bed5dce419d513e889b879a5ad..bf6cf37067dcfda94521a6350b5fa92b72314def 100644 --- a/lib/sdk/Applications/EvKitExamples/SPI/Makefile +++ b/lib/sdk/Applications/EvKitExamples/SPI/Makefile @@ -66,6 +66,7 @@ CMSIS_ROOT=$(LIBS_DIR)/CMSIS # Source files for this test (add path to VPATH below) SRCS = main.c +SRCS += hexdump.c # Where to find source files for this test VPATH=. diff --git a/lib/sdk/Applications/EvKitExamples/SPI/hexdump.c b/lib/sdk/Applications/EvKitExamples/SPI/hexdump.c new file mode 100644 index 0000000000000000000000000000000000000000..5164257205396fc66fd2d2eb5e6ae3c2152d1248 --- /dev/null +++ b/lib/sdk/Applications/EvKitExamples/SPI/hexdump.c @@ -0,0 +1,152 @@ + +/** + * @file hexdump.c + * @brief Contains code for printing debugging information. + */ + +/* **************************************************************************** + * Copyright (C) 2015-2017 Maxim Integrated Products, Inc., All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of Maxim Integrated + * Products, Inc. shall not be used except as stated in the Maxim Integrated + * Products, Inc. Branding Policy. + * + * The mere transfer of this software does not imply any licenses + * of trade secrets, proprietary technology, copyrights, patents, + * trademarks, maskwork rights, or any other form of intellectual + * property whatsoever. Maxim Integrated Products, Inc. retains all + * ownership rights. + * + * $Date$ + * $Revision$ + * + *************************************************************************** */ + +#define _HEXDUMP_C_ + +#include <assert.h> + +#include <stdio.h> + +#include "hexdump.h" + +#define LINE_ENDING "\n" + +/** + * @brief Tabs a specified number of spaces into a line. */ +static void displayIndent(unsigned int indentCount) +{ + unsigned int iter; + + for (iter = 0; iter < indentCount; iter++) + printf(" "); +} + +/** + * @brief Displays a hex dump of the provided memory block. + * @param pMemBlock A pointer to the memory block to dump. + * @param memBlockSize The size of the memory block to dump. + * @param indent The number of indents for each line. */ +static void displayHexDump( + const char * pMemBlock, + size_t memBlockSize, + unsigned int indent) +{ + unsigned int byteIter; + unsigned int wordIter; + unsigned int lineIter; + unsigned int memIter; + unsigned char nibble[2]; + unsigned int nibbleIter; + + byteIter = 0; + wordIter = 0; + lineIter = 0; + for (memIter = 0; memIter < memBlockSize; memIter ++) + { + // If this is the begining of a line, + if (byteIter == 0 && wordIter == 0) + { + // Print an indent. + displayIndent(indent); + + // Print the memory offset. + printf("%08X: ", (lineIter << 4)); + } + // If the begining of a word block, add a large space. + else if (byteIter == 0) + { + printf(" "); + } + // Otherwise, add a space. + else + { + printf(" "); + } + + // Convert current character into a hex representation. + nibble[0] = (pMemBlock[memIter] >> 4) & 0x0F; + nibble[1] = (pMemBlock[memIter] & 0xF); + for (nibbleIter = 0; nibbleIter < 2; nibbleIter ++) + { + if (nibble[nibbleIter] < 0x0AU) + nibble[nibbleIter] += '0'; + else + nibble[nibbleIter] += ('A' - 0x0AU); + } + + // Print current nibble. + printf("%c%c", nibble[0], nibble[1]); + + // Increment counters. + byteIter ++; + if (byteIter == 4) + { + byteIter = 0; + wordIter ++; + } + if (wordIter == 4) + { + wordIter = 0; + lineIter ++; + + // Also need a line break. + printf(LINE_ENDING); + } + } + + // Need a line break after an incomplete terminating line. + if (byteIter != 0 || wordIter != 0) + printf(LINE_ENDING); +} + +/** + * @brief Displays a hex dump of the provided memory block using the default indenting. + * @param pMemBlock A pointer to the memory block to dump. + * @param memBlockSize The size of the memory block to dump. */ +void hexdump( + const char * pMemBlock, + size_t memBlockSize) +{ + displayHexDump(pMemBlock, memBlockSize, 1); +} + +// vim:ts=4:sw=4:ft=c:expandtab diff --git a/lib/sdk/Applications/EvKitExamples/SPI/hexdump.h b/lib/sdk/Applications/EvKitExamples/SPI/hexdump.h new file mode 100644 index 0000000000000000000000000000000000000000..c47da60dc594de2f09f39d6963d198033324a4b7 --- /dev/null +++ b/lib/sdk/Applications/EvKitExamples/SPI/hexdump.h @@ -0,0 +1,52 @@ + +/** + * @file hexdump.h + * @brief Defines routines used to print debugging information. + */ + +/* **************************************************************************** + * Copyright (C) 2015-2017 Maxim Integrated Products, Inc., All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of Maxim Integrated + * Products, Inc. shall not be used except as stated in the Maxim Integrated + * Products, Inc. Branding Policy. + * + * The mere transfer of this software does not imply any licenses + * of trade secrets, proprietary technology, copyrights, patents, + * trademarks, maskwork rights, or any other form of intellectual + * property whatsoever. Maxim Integrated Products, Inc. retains all + * ownership rights. + * + * $Date$ + * $Revision$ + * + *************************************************************************** */ + +#ifndef _HEXDUMP_H_ +#define _HEXDUMP_H_ + +void hexdump( + const char * pMemBlock, + size_t memBlockSize); + +#endif /* _HEXDUMP_H_ */ + +// vim:ts=4:sw=4:ft=c:expandtab diff --git a/lib/sdk/Applications/EvKitExamples/SPI/main.c b/lib/sdk/Applications/EvKitExamples/SPI/main.c index c7577bce48fc18c3a42dca44ecaf4e353a597044..d8bda02c1af1d9392f087ab919ab4e2f4289005e 100644 --- a/lib/sdk/Applications/EvKitExamples/SPI/main.c +++ b/lib/sdk/Applications/EvKitExamples/SPI/main.c @@ -52,9 +52,10 @@ #include "uart.h" #include "pb.h" #include "spi.h" +#include "hexdump.h" /***** Definitions *****/ -#define TEST_LEN 60 // Words +#define TEST_LEN 0x40 // Words #define TEST_VALUE 0xA5A5 // This is for master mode only... #define VALUE 0xFFFF #define SPI_SPEED 100000 // Bit Rate @@ -91,13 +92,11 @@ void buttonHandler() int main(void) { - - int i,j; - uint16_t temp; + int byteWidth; + int byteIndex; sys_cfg_spi_t spi17y_master_cfg; spi_req_t req; - spi17y_master_cfg.map = MAP_A; spi17y_master_cfg.ss0 = Enable; spi17y_master_cfg.ss1 = Disable; @@ -117,13 +116,26 @@ int main(void) PB_RegisterCallback(0, (pb_callback)buttonHandler); while(!buttonPressed); - for (i=1; i<17; i++) { - if (i== 1 || i == 9) { // Sending out 2 to 16 bits except 9 bits... + for (byteWidth=1; byteWidth<17; byteWidth++) { + if (byteWidth == 1 || byteWidth ==9) { // Sending out 2 to 16 bits. continue; } - for (j = 0; j < TEST_LEN; j++) { - tx_data[j] = TEST_VALUE; + + // Initialize TX Data buffer. + memset(tx_data, 0x0, sizeof(tx_data)); + if (byteWidth <= 8) { + for (byteIndex = 0; byteIndex < (TEST_LEN << 1); byteIndex++) { + ((uint8_t*)tx_data)[byteIndex] = (((1U << req.bits) - 1) & TEST_VALUE); + } + } else { + for (byteIndex = 0; byteIndex < TEST_LEN; byteIndex++) { + tx_data[byteIndex] = (((1U << req.bits) - 1) & TEST_VALUE); + } } + + // Clear RX Data buffer. + memset(rx_data, 0x0, sizeof(rx_data)); + // Configure the peripheral if (SPI_Init(SPI, 0, SPI_SPEED, spi17y_master_cfg) != 0) { @@ -132,12 +144,11 @@ int main(void) while (1) {} } - memset(rx_data, 0x0, TEST_LEN*sizeof(uint16_t)); - + // Issue SPI transfer request. req.tx_data = tx_data; req.rx_data = rx_data; - req.len = TEST_LEN; - req.bits = i; + req.len = (sizeof(tx_data) >> ((byteWidth > 8) ? 1 : 0)); + req.bits = byteWidth; req.width = SPI17Y_WIDTH_1; req.ssel = 0; req.deass = 1; @@ -145,7 +156,7 @@ int main(void) req.tx_num = 0; req.rx_num = 0; req.callback = spi_cb; - spi_flag =1; + spi_flag = 1; #ifdef ASYNC SPI_MasterTransAsync(SPI, &req); while (spi_flag == 1); @@ -153,41 +164,22 @@ int main(void) SPI_MasterTrans(SPI, &req); #endif - - for (j=0; j<TEST_LEN; j++) { - if (req.bits <=8) { - if (j<(TEST_LEN/2)) { - temp = VALUE >>(16-req.bits); - temp &= TEST_VALUE; - temp = (temp<<8)|temp; - tx_data[j] = temp; - } else if (j == (TEST_LEN/2) && TEST_LEN % 2 == 1) { - temp = VALUE >> (16-req.bits); - temp &= TEST_VALUE; - tx_data[j] = temp; - } else { - tx_data[j] = 0x0000; - } - } else { - temp = VALUE >>(16-req.bits); - temp &= TEST_VALUE; - tx_data[j] = temp; - } - } - // Compare Sent data vs Received data // Printf needs the Uart turned on since they share the same pins if (memcmp(rx_data, tx_data, sizeof(tx_data)) != 0) { - printf("\nError verifying rx_data %d\n",i); + printf("\nError verifying rx_data %d\n",byteWidth); + printf("\n"); + printf("RX Data:\n"); + hexdump((const char *)rx_data, sizeof(rx_data)); + printf("TX Data:\n"); + hexdump((const char *)tx_data, sizeof(tx_data)); } else { - printf("\nSent %d bits per transaction\n",i); + printf("\nSent %d bits per transaction\n",byteWidth); } SPI_Shutdown(SPI); - } printf("\n Done testing \n"); - while(1); } diff --git a/lib/sdk/Applications/EvKitExamples/SPI_DMA/.cproject b/lib/sdk/Applications/EvKitExamples/SPI_DMA/.cproject new file mode 100644 index 0000000000000000000000000000000000000000..3e9da03b2d4e5be98e1aef88fa59bc4361f14959 --- /dev/null +++ b/lib/sdk/Applications/EvKitExamples/SPI_DMA/.cproject @@ -0,0 +1,107 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage"> + <storageModule moduleId="org.eclipse.cdt.core.settings"> + <cconfiguration id="ilg.gnuarmeclipse.managedbuild.cross.config.elf.debug.1674944962"> + <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="ilg.gnuarmeclipse.managedbuild.cross.config.elf.debug.1674944962" moduleId="org.eclipse.cdt.core.settings" name="Debug"> + <externalSettings/> + <extensions> + <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/> + <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + </extensions> + </storageModule> + <storageModule moduleId="cdtBuildSystem" version="4.0.0"> + <configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" cleanCommand="${cross_rm} -rf" description="" id="ilg.gnuarmeclipse.managedbuild.cross.config.elf.debug.1674944962" name="Debug" parent="ilg.gnuarmeclipse.managedbuild.cross.config.elf.debug"> + <folderInfo id="ilg.gnuarmeclipse.managedbuild.cross.config.elf.debug.1674944962." name="/" resourcePath=""> + <toolChain id="ilg.gnuarmeclipse.managedbuild.cross.toolchain.elf.debug.548125692" name="Cross ARM GCC" superClass="ilg.gnuarmeclipse.managedbuild.cross.toolchain.elf.debug"> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.level.1448195934" name="Optimization Level" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.level" value="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.level.none" valueType="enumerated"/> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.messagelength.989348626" name="Message length (-fmessage-length=0)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.messagelength" value="true" valueType="boolean"/> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.signedchar.573934961" name="'char' is signed (-fsigned-char)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.signedchar" value="true" valueType="boolean"/> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.functionsections.1195068176" name="Function sections (-ffunction-sections)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.functionsections" value="true" valueType="boolean"/> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.datasections.1035348629" name="Data sections (-fdata-sections)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.datasections" value="true" valueType="boolean"/> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.debugging.level.31679983" name="Debug level" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.debugging.level" value="ilg.gnuarmeclipse.managedbuild.cross.option.debugging.level.max" valueType="enumerated"/> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.debugging.format.1676901946" name="Debug format" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.debugging.format"/> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.toolchain.name.1729767352" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.toolchain.name" value="GNU Tools for ARM Embedded Processors" valueType="string"/> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.architecture.1708484008" name="Architecture" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.architecture" value="ilg.gnuarmeclipse.managedbuild.cross.option.architecture.arm" valueType="enumerated"/> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.arm.target.family.178519983" name="ARM family" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.arm.target.family" value="ilg.gnuarmeclipse.managedbuild.cross.option.arm.target.mcpu.cortex-m3" valueType="enumerated"/> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.arm.target.instructionset.956545422" name="Instruction set" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.arm.target.instructionset" value="ilg.gnuarmeclipse.managedbuild.cross.option.arm.target.instructionset.thumb" valueType="enumerated"/> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.command.prefix.1580514969" name="Prefix" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.command.prefix" value="arm-none-eabi-" valueType="string"/> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.command.c.1246670973" name="C compiler" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.command.c" value="gcc" valueType="string"/> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.command.cpp.1674926322" name="C++ compiler" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.command.cpp" value="g++" valueType="string"/> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.command.ar.2051566192" name="Archiver" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.command.ar" value="ar" valueType="string"/> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.command.objcopy.408066731" name="Hex/Bin converter" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.command.objcopy" value="objcopy" valueType="string"/> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.command.objdump.1900584936" name="Listing generator" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.command.objdump" value="objdump" valueType="string"/> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.command.size.1096852527" name="Size command" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.command.size" value="size" valueType="string"/> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.command.make.937347953" name="Build command" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.command.make" value="make" valueType="string"/> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.command.rm.1468247042" name="Remove command" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.command.rm" value="rm" valueType="string"/> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.addtools.createflash.1529750846" name="Create flash image" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.addtools.createflash" value="true" valueType="boolean"/> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.addtools.printsize.667765305" name="Print size" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.addtools.printsize" value="true" valueType="boolean"/> + <targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="ilg.gnuarmeclipse.managedbuild.cross.targetPlatform.786533016" isAbstract="false" osList="all" superClass="ilg.gnuarmeclipse.managedbuild.cross.targetPlatform"/> + <builder arguments="ECLIPSE=1" buildPath="${workspace_loc:/SPI_DMA}" command="make" id="ilg.gnuarmeclipse.managedbuild.cross.builder.592880777" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="ilg.gnuarmeclipse.managedbuild.cross.builder"/> + <tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.assembler.1648672385" name="Cross ARM GNU Assembler" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.assembler"> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.usepreprocessor.1969112665" name="Use preprocessor" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.usepreprocessor" value="true" valueType="boolean"/> + <inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.assembler.input.507854261" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.assembler.input"/> + </tool> + <tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.1576427906" name="Cross ARM C Compiler" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler"> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.include.paths.1576427906" name="Include paths (-I)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.include.paths" useByScannerDiscovery="true" valueType="includePath"> + <listOptionValue builtIn="false" value=""${MAXIM_PATH}/Firmware/MAX32665/Libraries/CMSIS/Device/Maxim/MAX32665/Include""/> + <listOptionValue builtIn="false" value=""${MAXIM_PATH}/Firmware/MAX32665/Libraries/MAX32665PeriphDriver/Include""/> + <listOptionValue builtIn="false" value=""${MAXIM_PATH}/Firmware/MAX32665/Libraries/Boards/EvKit_V1/Include""/> + <listOptionValue builtIn="false" value=""${MAXIM_PATH}/Firmware/MAX32665/Libraries/Boards/Include""/> + <listOptionValue builtIn="false" value=""${MAXIM_PATH}/Firmware/MAX32665/Libraries/CMSIS/Include""/> + <listOptionValue builtIn="false" value=""${MAXIM_PATH}/Toolchain/arm-none-eabi/include""/> + <listOptionValue builtIn="false" value=""${MAXIM_PATH}/Toolchain/arm-none-eabi/include/sys""/> + <listOptionValue builtIn="false" value=""${MAXIM_PATH}/Toolchain/lib/gcc/arm-none-eabi/6.3.1/include""/> + </option> + <inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.input.68945223" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.input"/> + </tool> + <tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.compiler.794996645" name="Cross ARM C++ Compiler" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.compiler"/> + <tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.c.linker.675776866" name="Cross ARM C Linker" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.c.linker"> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.gcsections.185399645" name="Remove unused sections (-Xlinker --gc-sections)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.gcsections" value="true" valueType="boolean"/> + <inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.c.linker.input.246156916" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.c.linker.input"> + <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/> + <additionalInput kind="additionalinput" paths="$(LIBS)"/> + </inputType> + </tool> + <tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.linker.391142733" name="Cross ARM C++ Linker" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.linker"> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.gcsections.2099090970" name="Remove unused sections (-Xlinker --gc-sections)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.gcsections" value="true" valueType="boolean"/> + </tool> + <tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.archiver.399743328" name="Cross ARM GNU Archiver" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.archiver"/> + <tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.createflash.822983655" name="Cross ARM GNU Create Flash Image" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.createflash"/> + <tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.createlisting.1050446219" name="Cross ARM GNU Create Listing" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.createlisting"> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.createlisting.source.335976671" name="Display source (--source|-S)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.createlisting.source" value="true" valueType="boolean"/> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.createlisting.allheaders.964898349" name="Display all headers (--all-headers|-x)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.createlisting.allheaders" value="true" valueType="boolean"/> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.createlisting.demangle.972868647" name="Demangle names (--demangle|-C)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.createlisting.demangle" value="true" valueType="boolean"/> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.createlisting.linenumbers.890608562" name="Display line numbers (--line-numbers|-l)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.createlisting.linenumbers" value="true" valueType="boolean"/> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.createlisting.wide.1669392057" name="Wide lines (--wide|-w)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.createlisting.wide" value="true" valueType="boolean"/> + </tool> + <tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.printsize.403251962" name="Cross ARM GNU Print Size" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.printsize"> + <option id="ilg.gnuarmeclipse.managedbuild.cross.option.printsize.format.1919947275" name="Size format" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.printsize.format"/> + </tool> + </toolChain> + </folderInfo> + </configuration> + </storageModule> + <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/> + </cconfiguration> + </storageModule> + <storageModule moduleId="cdtBuildSystem" version="4.0.0"> + <project id="SPI_DMA.ilg.gnuarmeclipse.managedbuild.cross.target.elf.737306620" name="Executable" projectType="ilg.gnuarmeclipse.managedbuild.cross.target.elf"/> + </storageModule> + <storageModule moduleId="scannerConfiguration"> + <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> + <scannerConfigBuildInfo instanceId="ilg.gnuarmeclipse.managedbuild.cross.config.elf.debug.1674944962;ilg.gnuarmeclipse.managedbuild.cross.config.elf.debug.1674944962.;ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.1576427906;ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.input.68945223"> + <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> + </scannerConfigBuildInfo> + </storageModule> + <storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/> + <storageModule moduleId="refreshScope" versionNumber="2"> + <configuration configurationName="Debug"> + <resource resourceType="PROJECT" workspacePath="/SPI_DMA"/> + </configuration> + </storageModule> + <storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/> +</cproject> diff --git a/lib/sdk/Applications/EvKitExamples/SPI_DMA/.project b/lib/sdk/Applications/EvKitExamples/SPI_DMA/.project new file mode 100644 index 0000000000000000000000000000000000000000..304254b7cdcd1e71c058d4ada1f6b78568283143 --- /dev/null +++ b/lib/sdk/Applications/EvKitExamples/SPI_DMA/.project @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>SPI_DMA</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name> + <triggers>clean,full,incremental,</triggers> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name> + <triggers>full,incremental,</triggers> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.cdt.core.cnature</nature> + <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature> + <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature> + </natures> +</projectDescription> diff --git a/lib/sdk/Applications/EvKitExamples/SPI_DMA/.settings/language.settings.xml b/lib/sdk/Applications/EvKitExamples/SPI_DMA/.settings/language.settings.xml new file mode 100644 index 0000000000000000000000000000000000000000..e5a1647610f97197abe406e8ef1bb9e62065f5a1 --- /dev/null +++ b/lib/sdk/Applications/EvKitExamples/SPI_DMA/.settings/language.settings.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<project> + <configuration id="ilg.gnuarmeclipse.managedbuild.cross.config.elf.debug.1674944962" name="Debug"> + <extension point="org.eclipse.cdt.core.LanguageSettingsProvider"> + <provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/> + <provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/> + <provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/> + </extension> + </configuration> +</project> diff --git a/lib/sdk/Applications/EvKitExamples/SPI_DMA/Makefile b/lib/sdk/Applications/EvKitExamples/SPI_DMA/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..7df48b4967e611e4bc36964f193a747bb75d1f63 --- /dev/null +++ b/lib/sdk/Applications/EvKitExamples/SPI_DMA/Makefile @@ -0,0 +1,116 @@ +################################################################################ + # Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved. + # + # Permission is hereby granted, free of charge, to any person obtaining a + # copy of this software and associated documentation files (the "Software"), + # to deal in the Software without restriction, including without limitation + # the rights to use, copy, modify, merge, publish, distribute, sublicense, + # and/or sell copies of the Software, and to permit persons to whom the + # Software is furnished to do so, subject to the following conditions: + # + # The above copyright notice and this permission notice shall be included + # in all copies or substantial portions of the Software. + # + # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + # IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES + # OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + # OTHER DEALINGS IN THE SOFTWARE. + # + # Except as contained in this notice, the name of Maxim Integrated + # Products, Inc. shall not be used except as stated in the Maxim Integrated + # Products, Inc. Branding Policy. + # + # The mere transfer of this software does not imply any licenses + # of trade secrets, proprietary technology, copyrights, patents, + # trademarks, maskwork rights, or any other form of intellectual + # property whatsoever. Maxim Integrated Products, Inc. retains all + # ownership rights. + # + # $Date: 2018-08-10 09:36:39 -0500 (Fri, 10 Aug 2018) $ + # $Revision: 36825 $ + # + ############################################################################### + +# This is the name of the build output file +ifeq "$(PROJECT)" "" +PROJECT=max32665 +endif + +# Specify the target processor +ifeq "$(TARGET)" "" +TARGET=MAX32665 +endif + +# Create Target name variables +TARGET_UC:=$(shell echo $(TARGET) | tr a-z A-Z) +TARGET_LC:=$(shell echo $(TARGET) | tr A-Z a-z) + +# Select 'GCC' or 'IAR' compiler +COMPILER=GCC + +# Specify the board used +ifeq "$(BOARD)" "" +BOARD=EvKit_V1 +endif + +# This is the path to the CMSIS root directory +ifeq "$(MAXIM_PATH)" "" +LIBS_DIR=../../../Libraries +else +LIBS_DIR=/$(subst \,/,$(subst :,,$(MAXIM_PATH))/Firmware/$(TARGET_UC)/Libraries) +endif +CMSIS_ROOT=$(LIBS_DIR)/CMSIS + +# Source files for this test (add path to VPATH below) +SRCS = main.c + +# Where to find source files for this test +VPATH=. + +# Where to find header files for this test +IPATH = . + +# Enable assertion checking for development +PROJ_CFLAGS+=-DMXC_ASSERT_ENABLE + +# Specify the target revision to override default +# "A2" in ASCII +# TARGET_REV=0x4132 + +# Use this variables to specify and alternate tool path +#TOOL_DIR=/opt/gcc-arm-none-eabi-4_8-2013q4/bin + +# Use these variables to add project specific tool options +#PROJ_CFLAGS+=--specs=nano.specs +#PROJ_LDFLAGS+=--specs=nano.specs + +# Point this variable to a startup file to override the default file +#STARTUPFILE=start.S + +MXC_OPTIMIZE=-O1 + +# Point this variable to a linker file to override the default file +# LINKERFILE=$(CMSIS_ROOT)/Device/Maxim/$(TARGET_UC)/Source/GCC/$(TARGET_LC).ld + +################################################################################ +# Include external library makefiles here + +# Include the BSP +BOARD_DIR=$(LIBS_DIR)/Boards/$(BOARD) +include $(BOARD_DIR)/board.mk + +# Include the peripheral driver +PERIPH_DRIVER_DIR=$(LIBS_DIR)/$(TARGET_UC)PeriphDriver +include $(PERIPH_DRIVER_DIR)/periphdriver.mk + +################################################################################ +# Include the rules for building for this target. All other makefiles should be +# included before this one. +include $(CMSIS_ROOT)/Device/Maxim/$(TARGET_UC)/Source/$(COMPILER)/$(TARGET_LC).mk + +# The rule to clean out all the build products. +distclean: clean + $(MAKE) -C ${PERIPH_DRIVER_DIR} clean diff --git a/lib/sdk/Applications/EvKitExamples/SPI_DMA/SPI_DMA.launch b/lib/sdk/Applications/EvKitExamples/SPI_DMA/SPI_DMA.launch new file mode 100644 index 0000000000000000000000000000000000000000..f41a5c47261171a448f629695d2137944f76bb13 --- /dev/null +++ b/lib/sdk/Applications/EvKitExamples/SPI_DMA/SPI_DMA.launch @@ -0,0 +1,64 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<launchConfiguration type="ilg.gnuarmeclipse.debug.gdbjtag.openocd.launchConfigurationType"> +<booleanAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.doContinue" value="true"/> +<booleanAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.doDebugInRam" value="false"/> +<booleanAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.doFirstReset" value="true"/> +<booleanAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.doGdbServerAllocateConsole" value="true"/> +<booleanAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.doGdbServerAllocateTelnetConsole" value="false"/> +<booleanAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.doSecondReset" value="true"/> +<booleanAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.doStartGdbServer" value="true"/> +<booleanAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.enableSemihosting" value="false"/> +<stringAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.firstResetType" value="init"/> +<stringAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.gdbClientOtherCommands" value=""/> +<stringAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.gdbClientOtherOptions" value=""/> +<stringAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.gdbServerConnectionAddress" value=""/> +<stringAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.gdbServerExecutable" value="openocd"/> +<intAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.gdbServerGdbPortNumber" value="3333"/> +<stringAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.gdbServerLog" value=""/> +<stringAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.gdbServerOther" value="-s ${env_var:TOOLCHAIN_PATH}/share/openocd/scripts -f interface/cmsis-dap.cfg -f target/MAX32665.cfg"/> +<intAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.gdbServerTelnetPortNumber" value="4444"/> +<stringAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.otherInitCommands" value=""/> +<stringAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.otherRunCommands" value=""/> +<stringAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.secondResetType" value="halt"/> +<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.imageFileName" value=""/> +<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.imageOffset" value=""/> +<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.ipAddress" value="localhost"/> +<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.jtagDevice" value="GNU ARM OpenOCD"/> +<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadImage" value="true"/> +<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadSymbols" value="true"/> +<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.pcRegister" value=""/> +<intAttribute key="org.eclipse.cdt.debug.gdbjtag.core.portNumber" value="3333"/> +<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setPcRegister" value="false"/> +<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setResume" value="false"/> +<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setStopAt" value="true"/> +<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.stopAt" value="main"/> +<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsFileName" value=""/> +<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsOffset" value=""/> +<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useFileForImage" value="false"/> +<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useFileForSymbols" value="false"/> +<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useProjBinaryForImage" value="true"/> +<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useProjBinaryForSymbols" value="true"/> +<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useRemoteTarget" value="true"/> +<stringAttribute key="org.eclipse.cdt.debug.mi.core.commandFactory" value="Standard (Windows)"/> +<stringAttribute key="org.eclipse.cdt.debug.mi.core.protocol" value="mi"/> +<booleanAttribute key="org.eclipse.cdt.debug.mi.core.verboseMode" value="false"/> +<stringAttribute key="org.eclipse.cdt.dsf.gdb.DEBUG_NAME" value="arm-none-eabi-gdb"/> +<booleanAttribute key="org.eclipse.cdt.dsf.gdb.UPDATE_THREADLIST_ON_SUSPEND" value="false"/> +<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/> +<stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/> +<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="build/MAX32665.elf"/> +<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="SPI_DMA"/> +<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="true"/> +<stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value="ilg.gnuarmeclipse.managedbuild.cross.config.elf.debug.1674944962"/> +<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> +<listEntry value="/SPI_DMA"/> +</listAttribute> +<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> +<listEntry value="4"/> +</listAttribute> +<listAttribute key="org.eclipse.debug.ui.favoriteGroups"> +<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/> +</listAttribute> +<stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <memoryBlockExpressionList context="Context string"/> "/> +<stringAttribute key="process_factory_id" value="org.eclipse.cdt.dsf.gdb.GdbProcessFactory"/> +</launchConfiguration> diff --git a/lib/sdk/Applications/EvKitExamples/SPI_DMA/main.c b/lib/sdk/Applications/EvKitExamples/SPI_DMA/main.c new file mode 100644 index 0000000000000000000000000000000000000000..a36c0a36cb06c089ef260b8ed12603c76f56ed56 --- /dev/null +++ b/lib/sdk/Applications/EvKitExamples/SPI_DMA/main.c @@ -0,0 +1,267 @@ +/******************************************************************************* + * Copyright (C) 2019 Maxim Integrated Products, Inc., All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of Maxim Integrated + * Products, Inc. shall not be used except as stated in the Maxim Integrated + * Products, Inc. Branding Policy. + * + * The mere transfer of this software does not imply any licenses + * of trade secrets, proprietary technology, copyrights, patents, + * trademarks, maskwork rights, or any other form of intellectual + * property whatsoever. Maxim Integrated Products, Inc. retains all + * ownership rights. + * + ******************************************************************************/ + +#include <stdio.h> +#include <string.h> +#include "spi.h" +#include "dma.h" + +#define SPIRAM_READ_CMD 0x03 +#define SPIRAM_WRITE_CMD 0x02 +#define SPIRAM_EQIO_CMD 0x38 +#define SPIRAM_RSTQIO_CMD 0xFF + +#define SPIRAM_ADDR 0 + +#define SPI_BAUD 400000 + +#define TRANS_LENGTH 400 + +volatile int out_dma_complete = 1; +volatile int in_dma_complete = 1; + +const gpio_cfg_t ssel_pin = {PORT_0, PIN_8, GPIO_FUNC_OUT, GPIO_PAD_NONE}; + +// DMA IRQ Handlers - there needs to be one handler for each channel used. This example uses 2. +void DMA0_IRQHandler() +{ + DMA_Handler(0); +} + +void DMA1_IRQHandler() +{ + DMA_Handler(1); +} + +// A callback function that will be called when the RX DMA completes. +void in_callback(int ch, int reason) +{ + in_dma_complete = 1; +} + +// A callback function that will be called when the TX DMA completes. +void out_callback(int ch, int reason) +{ + out_dma_complete = 1; +} + +// Sends/Receives a SPI packet using DMA. +// out - the buffer containing data to send to the slave. May be NULL if there is +// no data to send or this the send portion of a quad mode transaction. +// in - the buffer to receive data from the slave. May be NULL if thre is no +// data coming from the slave or if this is the receive phase of a quad mode transaction. +// len - the number of bytes to send/receive. +// deass - Whether to deassert the SSEL line at the end of this transaction. +// quad - Whether to send this packet using SPI quad mode or traditional full-duplex SPI. +void send_packet(uint8_t* out, uint8_t* in, unsigned int len, int deass, int quad) +{ + int in_ch = -1; + int out_ch = -1; + + // Assert SSEL + GPIO_OutClr(&ssel_pin); + + // Initialize the CTRL0 register + MXC_SPI0->ctrl0 = MXC_F_SPI17Y_CTRL0_MASTER | // Enable master mode + MXC_F_SPI17Y_CTRL0_EN; // Enable the peripheral + + // Initialize the CTRL1 register + MXC_SPI0->ctrl1 = 0; + if(out || quad) { + // Set how many to characters to send, or when in quad mode how many characters to receive + MXC_SPI0->ctrl1 |= (len << MXC_F_SPI17Y_CTRL1_TX_NUM_CHAR_POS); + } + + if(in) { + // Set how many characters to receive + MXC_SPI0->ctrl1 |= (len << MXC_F_SPI17Y_CTRL1_RX_NUM_CHAR_POS); + } + + // Initialize the CTRL2 register + MXC_SPI0->ctrl2 = (quad ? MXC_S_SPI17Y_CTRL2_DATA_WIDTH_QUAD : MXC_S_SPI17Y_CTRL2_DATA_WIDTH_MONO) | + (8 << MXC_F_SPI17Y_CTRL2_NUMBITS_POS); + + // Initialize the DMA register + MXC_SPI0->dma = 0; + if(out) { + MXC_SPI0->dma |= MXC_F_SPI17Y_DMA_TX_DMA_EN | // Enable DMA for transmit + MXC_F_SPI17Y_DMA_TX_FIFO_EN | // Enable the TX FIFO + (31 << MXC_F_SPI17Y_DMA_TX_FIFO_LEVEL_POS); // Set the threshold of when to add more data to TX FIFO + } + if(in) { + MXC_SPI0->dma |= MXC_F_SPI17Y_DMA_RX_DMA_EN | // Enable DMA for receive + MXC_F_SPI17Y_DMA_RX_FIFO_EN | // Enable the RX FIFO + (0 << MXC_F_SPI17Y_DMA_TX_FIFO_LEVEL_POS); // Set the threshold of when to read data from RX FIFO + } + + // Prepare DMA for unloading RX FIFO. + if(in) { + in_ch = DMA_AcquireChannel(); + DMA_ConfigChannel(in_ch, DMA_PRIO_LOW, DMA_REQSEL_SPI0RX, 0, + DMA_TIMEOUT_4_CLK, DMA_PRESCALE_DISABLE, + DMA_WIDTH_BYTE, 0, DMA_WIDTH_BYTE, 1, 1, 1, 0); + DMA_SetCallback(in_ch, in_callback); + DMA_EnableInterrupt(in_ch); + DMA_SetSrcDstCnt(in_ch, 0, in, len); + in_dma_complete = 0; + DMA_Start(in_ch); + } + else { + in_dma_complete = 1; // Not using the RX DMA, mark it as completed. + } + + // Prepare DMA to fill TX FIFO. + if(out) { + out_ch = DMA_AcquireChannel(); + DMA_ConfigChannel(out_ch, DMA_PRIO_LOW, DMA_REQSEL_SPI0TX, 0, + DMA_TIMEOUT_4_CLK, DMA_PRESCALE_DISABLE, + DMA_WIDTH_BYTE, 1, DMA_WIDTH_BYTE, 0, 1, 1, 0); + DMA_SetCallback(out_ch, out_callback); + DMA_EnableInterrupt(out_ch); + DMA_SetSrcDstCnt(out_ch, out, 0, len); + out_dma_complete = 0; + DMA_Start(out_ch); + } + else { + out_dma_complete = 1; // Not using the TX DMA, mark it as completed. + } + + // Start the SPI transaction + MXC_SPI0->ctrl0 |= MXC_F_SPI17Y_CTRL0_START; + + // Wait here for all DMA transactions to complete. + // This would normally be where this function would + // return so the micro can go do other things. The + // callbacks will be triggered when the DMA completes + // so the application knows its time to do more work. + // For this simple example, we'll just block here. + while(!in_dma_complete || !out_dma_complete); + + if(in) { + DMA_ReleaseChannel(in_ch); + } + if(out) { + DMA_ReleaseChannel(out_ch); + } + + // DMA has completed, but that just means DMA has loaded all of its data to/from + // the FIFOs. We now need to wait for the SPI transaction to fully complete. + if(MXC_SPI0->ctrl0 & MXC_F_SPI17Y_CTRL0_EN) { + while(MXC_SPI0->stat & MXC_F_SPI17Y_STAT_BUSY); + } + + // If the callee wanted SSEL deasserted at the end of the transaction, do that now. + if(deass) { + GPIO_OutSet(&ssel_pin); + } +} + +int main() +{ + int i; + uint8_t cmd_buffer[5]; + uint8_t out_buffer[TRANS_LENGTH]; + uint8_t in_buffer[TRANS_LENGTH]; + + printf("\n************** SPI DMA Demo ********************\n"); + printf("This example configures SPI0 to communicate with\n"); + printf("the external SPI RAM on the evaluation kit. When\n"); + printf("running this example make sure the SPI RAM's\n"); + printf("communication pins are connected to the micro by\n"); + printf("properly placing the JP7 jumper.\n"); + printf("************************************************\n\n"); + + // Initialize DMA peripheral + DMA_Init(); + NVIC_EnableIRQ(DMA0_IRQn); + NVIC_EnableIRQ(DMA1_IRQn); + + // Initialize SPI peripheral + sys_cfg_spi_t cfg = {MAP_B, Disable, Disable, Disable}; + SPI_Init(SPI0, 0, SPI_BAUD, cfg); + MXC_SPI0->ctrl0 |= MXC_F_SPI17Y_CTRL0_MASTER; // Switch SPI to master mode, else the state of the SS pin could cause the SPI periph to appear 'BUSY'; + + MXC_SPI0->ss_time = (4 << MXC_F_SPI17Y_SS_TIME_PRE_POS) | + (8 << MXC_F_SPI17Y_SS_TIME_POST_POS) | + (16 << MXC_F_SPI17Y_SS_TIME_INACT_POS); + + GPIO_OutSet(&ssel_pin); + GPIO_Config(&ssel_pin); + + // Send 'Reset' command to external SPI RAM + printf("Resetting the SPI communication mode...\n"); + cmd_buffer[0] = SPIRAM_RSTQIO_CMD; + send_packet(cmd_buffer, NULL, 1, 1, 0); + + // Send 'Enable QUAD Mode' command to external SPI RAM + printf("Enabling SPI quad mode...\n"); + cmd_buffer[0] = SPIRAM_EQIO_CMD; + send_packet(cmd_buffer, NULL, 1, 1, 0); + + // Send 'Write' command to external SPI RAM + printf("Writing test data to the SPI RAM...\n"); + cmd_buffer[0] = SPIRAM_WRITE_CMD; + cmd_buffer[1] = SPIRAM_ADDR >> 16; + cmd_buffer[2] = SPIRAM_ADDR >> 8; + cmd_buffer[3] = SPIRAM_ADDR; + send_packet(cmd_buffer, NULL, 4, 0, 1); + + // Send the data to the external SPI RAM + for(i = 0; i < TRANS_LENGTH; i++) { + out_buffer[i] = i; + } + send_packet(out_buffer, NULL, TRANS_LENGTH, 1, 1); + + // Send 'Read' command to external SPI RAM + printf("Reading data from the SPI RAM...\n"); + cmd_buffer[0] = SPIRAM_READ_CMD; + cmd_buffer[1] = SPIRAM_ADDR >> 16; + cmd_buffer[2] = SPIRAM_ADDR >> 8; + cmd_buffer[3] = SPIRAM_ADDR; + cmd_buffer[4] = 0xFF; + send_packet(cmd_buffer, NULL, 5, 0, 1); + + // Read data from the external SPI RAM + memset(in_buffer, 0, TRANS_LENGTH); + send_packet(NULL, in_buffer, TRANS_LENGTH, 1, 1); + + // Verify the data read matches what was expected + printf("Verifying the expected data was received...\n"); + for(i = 0; i < TRANS_LENGTH; i++) { + if(in_buffer[i] != out_buffer[i]) { + printf("Data mismatch at offset %d: Exp = 0x%02X Got = 0x%02X\n", i, out_buffer[i], in_buffer[i]); + } + } + + printf("Example complete.\n"); +} diff --git a/lib/sdk/Applications/EvKitExamples/USB_CompositeDevice_CDCACM/USB_CompositeDevice_CDCACM.launch b/lib/sdk/Applications/EvKitExamples/USB_CompositeDevice_CDCACM/USB_CompositeDevice_CDCACM.launch new file mode 100644 index 0000000000000000000000000000000000000000..0638c0302239ced9f896bea0347420955d714fd4 --- /dev/null +++ b/lib/sdk/Applications/EvKitExamples/USB_CompositeDevice_CDCACM/USB_CompositeDevice_CDCACM.launch @@ -0,0 +1,65 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<launchConfiguration type="ilg.gnuarmeclipse.debug.gdbjtag.openocd.launchConfigurationType"> +<booleanAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.doContinue" value="true"/> +<booleanAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.doDebugInRam" value="false"/> +<booleanAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.doFirstReset" value="true"/> +<booleanAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.doGdbServerAllocateConsole" value="true"/> +<booleanAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.doGdbServerAllocateTelnetConsole" value="false"/> +<booleanAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.doSecondReset" value="true"/> +<booleanAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.doStartGdbServer" value="true"/> +<booleanAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.enableSemihosting" value="false"/> +<stringAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.firstResetType" value="init"/> +<stringAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.gdbClientOtherCommands" value=""/> +<stringAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.gdbClientOtherOptions" value=""/> +<stringAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.gdbServerConnectionAddress" value=""/> +<stringAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.gdbServerExecutable" value="openocd"/> +<intAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.gdbServerGdbPortNumber" value="3333"/> +<stringAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.gdbServerLog" value=""/> +<stringAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.gdbServerOther" value="-s ${env_var:TOOLCHAIN_PATH}/share/openocd/scripts -f interface/cmsis-dap.cfg -f target/MAX32665.cfg"/> +<intAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.gdbServerTelnetPortNumber" value="4444"/> +<stringAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.otherInitCommands" value=""/> +<stringAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.otherRunCommands" value=""/> +<stringAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.secondResetType" value="halt"/> +<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.imageFileName" value=""/> +<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.imageOffset" value=""/> +<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.ipAddress" value="localhost"/> +<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.jtagDevice" value="GNU ARM OpenOCD"/> +<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadImage" value="true"/> +<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadSymbols" value="true"/> +<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.pcRegister" value=""/> +<intAttribute key="org.eclipse.cdt.debug.gdbjtag.core.portNumber" value="3333"/> +<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setPcRegister" value="false"/> +<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setResume" value="false"/> +<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setStopAt" value="true"/> +<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.stopAt" value="main"/> +<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsFileName" value=""/> +<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsOffset" value=""/> +<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useFileForImage" value="false"/> +<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useFileForSymbols" value="false"/> +<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useProjBinaryForImage" value="true"/> +<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useProjBinaryForSymbols" value="true"/> +<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useRemoteTarget" value="true"/> +<stringAttribute key="org.eclipse.cdt.debug.mi.core.commandFactory" value="Standard (Windows)"/> +<stringAttribute key="org.eclipse.cdt.debug.mi.core.protocol" value="mi"/> +<booleanAttribute key="org.eclipse.cdt.debug.mi.core.verboseMode" value="false"/> +<stringAttribute key="org.eclipse.cdt.dsf.gdb.DEBUG_NAME" value="arm-none-eabi-gdb"/> +<booleanAttribute key="org.eclipse.cdt.dsf.gdb.UPDATE_THREADLIST_ON_SUSPEND" value="false"/> +<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/> +<stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/> +<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_REGISTER_GROUPS" value=""/> +<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="build/MAX32665.elf"/> +<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="USB_CompositeDevice_CDCACM"/> +<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="true"/> +<stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value="ilg.gnuarmeclipse.managedbuild.cross.config.elf.debug.1674944962"/> +<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> +<listEntry value="/USB_CompositeDevice_CDCACM"/> +</listAttribute> +<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> +<listEntry value="4"/> +</listAttribute> +<listAttribute key="org.eclipse.debug.ui.favoriteGroups"> +<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/> +</listAttribute> +<stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <memoryBlockExpressionList context="Context string"/> "/> +<stringAttribute key="process_factory_id" value="org.eclipse.cdt.dsf.gdb.GdbProcessFactory"/> +</launchConfiguration> diff --git a/lib/sdk/Applications/EvKitExamples/USB_CompositeDevice_CDCACM/descriptors.h b/lib/sdk/Applications/EvKitExamples/USB_CompositeDevice_CDCACM/descriptors.h index c3287599673dc52d45e5e1d6949ca7ed952c06a6..329e66a4b5cf0a17fb08aa7d2f509d179ea85082 100644 --- a/lib/sdk/Applications/EvKitExamples/USB_CompositeDevice_CDCACM/descriptors.h +++ b/lib/sdk/Applications/EvKitExamples/USB_CompositeDevice_CDCACM/descriptors.h @@ -46,12 +46,12 @@ usb_device_descriptor_t __attribute__((aligned(4))) composite_device_descriptor 0x12, /* bLength */ 0x01, /* bDescriptorType = Device */ 0x0200, /* bcdUSB USB spec rev (BCD) */ /// - 0x00, /* bDeviceClass = code specified by interface descriptors */ - 0x00, /* bDeviceSubClass = code specified by interface descriptors */ - 0x00, /* bDeviceProtocol = code specified by interface descriptors */ + 0xEF, /* bDeviceClass = code specified by interface descriptors */ + 0x02, /* bDeviceSubClass = code specified by interface descriptors */ + 0x01, /* bDeviceProtocol = code specified by interface descriptors */ 0x40, /* bMaxPacketSize0 is 64 bytes */ 0x0B6A, /* idVendor (Maxim Integrated) */ - 0x4402, /* idProduct */ /// + 0x003C, /* idProduct */ /// 0x0100, /* bcdDevice */ 0x01, /* iManufacturer Descriptor ID */ 0x02, /* iProduct Descriptor ID */ @@ -64,9 +64,9 @@ usb_device_qualifier_descriptor_t __attribute__((aligned(4))) composite_device_q 0x0A, /* bLength = 10 */ 0x06, /* bDescriptorType = Device Qualifier */ 0x0200, /* bcdUSB USB spec rev (BCD) */ - 0x00, /* bDeviceClass = Unspecified */ - 0x00, /* bDeviceSubClass */ - 0x00, /* bDeviceProtocol */ + 0xEF, /* bDeviceClass = Unspecified */ + 0x02, /* bDeviceSubClass */ + 0x01, /* bDeviceProtocol */ 0x40, /* bMaxPacketSize0 is 64 bytes */ 0x01, /* bNumConfigurations */ 0x00 /* Reserved, must be 0 */ @@ -76,43 +76,85 @@ __attribute__((aligned(4))) struct __attribute__((packed)) { usb_configuration_descriptor_t config_descriptor; - /* Interface #0 CDCACM Device */ + /* Interface #0 Mass Storage Device */ + usb_interface_descriptor_t msc_interface_descriptor; + usb_endpoint_descriptor_t endpoint_descriptor_1; + usb_endpoint_descriptor_t endpoint_descriptor_2; + /* Interface Association Descriptor */ + uint8_t interface_association_descriptor[8]; + /* Interface #1 CDCACM Device */ usb_interface_descriptor_t comm_interface_descriptor; uint8_t header_functional_descriptor[5]; uint8_t call_management_descriptor[5]; uint8_t acm_functional_descriptor[4]; uint8_t union_functional_descriptor[5]; + /* Interface #2 CDC Data*/ usb_endpoint_descriptor_t endpoint_descriptor_3; usb_interface_descriptor_t data_interface_descriptor; usb_endpoint_descriptor_t endpoint_descriptor_4; usb_endpoint_descriptor_t endpoint_descriptor_5; - /* Interface #1 Mass Storage Device */ - usb_interface_descriptor_t msc_interface_descriptor; - usb_endpoint_descriptor_t endpoint_descriptor_1; - usb_endpoint_descriptor_t endpoint_descriptor_2; } composite_config_descriptor = { { 0x09, /* bLength */ 0x02, /* bDescriptorType = Config */ - 0x005A, /* wTotalLength(L/H) = 71 bytes */ + 0x0062, /* wTotalLength(L/H) = 98 bytes */ 0x03, /* bNumInterfaces */ 0x01, /* bConfigurationValue */ 0x02, /* iConfiguration */ /// 0xE0, /* bmAttributes (bus-powered, remote wakeup) */ - 0x32, /* MaxPower is 100ma (units are 2ma/bit) */ + 0x01, /* MaxPower is 100ma (units are 2ma/bit) */ }, - /********** Interface #0 : COMM Interface **********/ - { /* First Interface Descriptor For Comm Class Interface */ + /********** Interface #0 : Mass Storage Device **********/ + { /* Second Interface Descriptor For MSC Interface */ 0x09, /* bLength = 9 */ 0x04, /* bDescriptorType = Interface (4) */ 0x00, /* bInterfaceNumber */ 0x00, /* bAlternateSetting */ + 0x02, /* bNumEndpoints (one for IN one for OUT) */ + 0x08, /* bInterfaceClass = Mass Storage (8) */ + 0x06, /* bInterfaceSubClass = SCSI Transparent Command Set */ + 0x50, /* bInterfaceProtocol = Bulk-Only Transport */ + 0x05, /* iInterface */ + }, + { /* OUT Endpoint 1 (Descriptor #1) */ + 0x07, /* bLength */ + 0x05, /* bDescriptorType (Endpoint) */ + 0x01, /* bEndpointAddress (EP1-OUT) */ + 0x02, /* bmAttributes (bulk) */ + 0x0040, /* wMaxPacketSize */ + 0x00, /* bInterval (N/A) */ + }, + { /* IN Endpoint 2 (Descriptor #2) */ + 0x07, /* bLength */ + 0x05, /* bDescriptorType (Endpoint) */ + 0x82, /* bEndpointAddress (EP2-IN) */ + 0x02, /* bmAttributes (bulk) */ + 0x0040, /* wMaxPacketSize */ + 0x00 /* bInterval (N/A) */ + }, + /********** Interface Association Descriptor **********/ + { + 0x08, /* bLength */ + 0x0B, /* bDescriptorType */ + 0x01, /* bFirstInterface */ + 0x02, /* bInterfaceCount */ + 0x02, /* bFunctionClass */ + 0x02, /* bFunctionSubClass */ + 0x01, /* bFunctionProtocol */ + 0x00, /* iFunction */ + }, + /********** Interface #1 : COMM Interface **********/ + { /* First Interface Descriptor For Comm Class Interface */ + 0x09, /* bLength = 9 */ + 0x04, /* bDescriptorType = Interface (4) */ + 0x01, /* bInterfaceNumber */ + 0x00, /* bAlternateSetting */ 0x01, /* bNumEndpoints (one for OUT) */ - 0x0a, /* bInterfaceClass = Communications Interface Class (2) */ - 0x00, /* bInterfaceSubClass = Abstract Control Model (2) */ - 0x00, /* bInterfaceProtocol = Common "AT" commands (1), no class specific protocol (0) */ + 0x02, /* bInterfaceClass = Communications Interface Class (2) */ + 0x02, /* bInterfaceSubClass = Abstract Control Model (2) */ + 0x01, /* bInterfaceProtocol = Common "AT" commands (1), no class specific protocol (0) */ 0x04, /* iInterface */ }, { /* Header Functional Descriptor */ @@ -152,18 +194,18 @@ composite_config_descriptor = { { /* Second Interface Descriptor For Data Interface */ 0x09, /* bLength */ 0x04, /* bDescriptorType (Interface) */ - 0x01, /* bInterfaceNumber */ + 0x02, /* bInterfaceNumber */ 0x00, /* bAlternateSetting */ 0x02, /* bNumEndpoints */ - 0x02, /* bInterfaceClass = Data Interface (10) */ - 0x02, /* bInterfaceSubClass = none (0) */ - 0x01, /* bInterfaceProtocol = No class specific protocol (0) */ - 0x00, /* biInterface = No Text String (0) */ + 0x0a, /* bInterfaceClass = Data Interface (10) */ + 0x00, /* bInterfaceSubClass = none (0) */ + 0x00, /* bInterfaceProtocol = No class specific protocol (0) */ + 0x04, /* biInterface = No Text String (0) */ }, { /* OUT Endpoint 1 (Descriptor #2) */ 0x07, /* bLength */ 0x05, /* bDescriptorType (Endpoint) */ - 0x02, /* bEndpointAddress (EP1-OUT) */ + 0x05, /* bEndpointAddress (EP1-OUT) */ 0x02, /* bmAttributes (bulk) */ 0x0040, /* wMaxPacketSize */ 0x00, /* bInterval (N/A) */ @@ -176,34 +218,6 @@ composite_config_descriptor = { 0x0040, /* wMaxPacketSize */ 0x00, /* bInterval (N/A) */ }, - /********** Interface #1 : Mass Storage Device **********/ - { /* Second Interface Descriptor For MSC Interface */ - 0x09, /* bLength = 9 */ - 0x04, /* bDescriptorType = Interface (4) */ - 0x02, /* bInterfaceNumber */ - 0x00, /* bAlternateSetting */ - 0x02, /* bNumEndpoints (one for IN one for OUT) */ - 0x08, /* bInterfaceClass = Mass Storage (8) */ - 0x06, /* bInterfaceSubClass = SCSI Transparent Command Set */ - 0x50, /* bInterfaceProtocol = Bulk-Only Transport */ - 0x05, /* iInterface */ - }, - { /* OUT Endpoint 1 (Descriptor #1) */ - 0x07, /* bLength */ - 0x05, /* bDescriptorType (Endpoint) */ - 0x01, /* bEndpointAddress (EP1-OUT) */ - 0x02, /* bmAttributes (bulk) */ - 0x0040, /* wMaxPacketSize */ - 0x00, /* bInterval (N/A) */ - }, - { /* IN Endpoint 2 (Descriptor #2) */ - 0x07, /* bLength */ - 0x05, /* bDescriptorType (Endpoint) */ - 0x82, /* bEndpointAddress (EP2-IN) */ - 0x02, /* bmAttributes (bulk) */ - 0x0040, /* wMaxPacketSize */ - 0x00 /* bInterval (N/A) */ - }, }; @@ -211,44 +225,86 @@ __attribute__((aligned(4))) struct __attribute__((packed)) { usb_configuration_descriptor_t config_descriptor; - /* Interface #0 CDCACM Device */ + /* Interface #0 Mass Storage Device */ + usb_interface_descriptor_t msc_interface_descriptor; + usb_endpoint_descriptor_t endpoint_descriptor_1; + usb_endpoint_descriptor_t endpoint_descriptor_2; + /* Interface Association Descriptor */ + uint8_t interface_association_descriptor[8]; + /* Interface #1 CDCACM Device */ usb_interface_descriptor_t comm_interface_descriptor; uint8_t header_functional_descriptor[5]; uint8_t call_management_descriptor[5]; uint8_t acm_functional_descriptor[4]; uint8_t union_functional_descriptor[5]; usb_endpoint_descriptor_t endpoint_descriptor_3; + /* Interface #2 CDCACM Data */ usb_interface_descriptor_t data_interface_descriptor; usb_endpoint_descriptor_t endpoint_descriptor_4; usb_endpoint_descriptor_t endpoint_descriptor_5; - /* Interface #1 Mass Storage Device */ - usb_interface_descriptor_t msc_interface_descriptor; - usb_endpoint_descriptor_t endpoint_descriptor_1; - usb_endpoint_descriptor_t endpoint_descriptor_2; } composite_config_descriptor_hs = { { 0x09, /* bLength */ 0x02, /* bDescriptorType = Config */ - 0x005A, /* wTotalLength(L/H) */ + 0x0062, /* wTotalLength(L/H) */ 0x03, /* bNumInterfaces */ 0x01, /* bConfigurationValue */ 0x02, /* iConfiguration */ 0xE0, /* bmAttributes (bus-powered, remote wakeup) */ 0x32, /* MaxPower is 100ma (units are 2ma/bit) */ }, - /********** Interface #0 : COMM Interface **********/ - { /* First Interface Descriptor For Comm Class Interface */ + /********** Interface #0 : Mass Storage Device **********/ + { /* Second Interface Descriptor For MSC Interface */ 0x09, /* bLength = 9 */ 0x04, /* bDescriptorType = Interface (4) */ 0x00, /* bInterfaceNumber */ 0x00, /* bAlternateSetting */ + 0x02, /* bNumEndpoints (one for IN one for OUT) */ + 0x08, /* bInterfaceClass = Mass Storage (8) */ + 0x06, /* bInterfaceSubClass = SCSI Transparent Command Set */ + 0x50, /* bInterfaceProtocol = Bulk-Only Transport */ + 0x05, /* iInterface */ + }, + { /* OUT Endpoint 1 (Descriptor #1) */ + 0x07, /* bLength */ + 0x05, /* bDescriptorType (Endpoint) */ + 0x01, /* bEndpointAddress (EP1-OUT) */ + 0x02, /* bmAttributes (bulk) */ + 0x0200, /* wMaxPacketSize */ + 0x01, /* bInterval (N/A) */ + }, + { /* IN Endpoint 2 (Descriptor #2) */ + 0x07, /* bLength */ + 0x05, /* bDescriptorType (Endpoint) */ + 0x82, /* bEndpointAddress (EP2-IN) */ + 0x02, /* bmAttributes (bulk) */ + 0x0200, /* wMaxPacketSize */ + 0x01 /* bInterval (N/A) */ + }, + /********** Interface Association Descriptor **********/ + { + 0x08, /* bLength */ + 0x0B, /* bDescriptorType */ + 0x01, /* bFirstInterface */ + 0x02, /* bInterfaceCount */ + 0x02, /* bFunctionClass */ + 0x02, /* bFunctionSubClass */ + 0x01, /* bFunctionProtocol */ + 0x00, /* iFunction */ + }, + /********** Interface #1 : COMM Interface **********/ + { /* First Interface Descriptor For Comm Class Interface */ + 0x09, /* bLength = 9 */ + 0x04, /* bDescriptorType = Interface (4) */ + 0x01, /* bInterfaceNumber */ + 0x00, /* bAlternateSetting */ 0x01, /* bNumEndpoints (one for OUT) */ - 0x00, /* bInterfaceClass = Communications Interface Class (2) */ - 0x00, /* bInterfaceSubClass = Abstract Control Model (2) */ - 0x00, /* bInterfaceProtocol = Common "AT" commands (1), no class specific protocol (0) */ - 0x00, /* iInterface */ + 0x02, /* bInterfaceClass = Communications Interface Class (2) */ + 0x02, /* bInterfaceSubClass = Abstract Control Model (2) */ + 0x01, /* bInterfaceProtocol = Common "AT" commands (1), no class specific protocol (0) */ + 0x04, /* iInterface */ }, { /* Header Functional Descriptor */ 0x05, /* bFunctionalLength = 5 */ @@ -281,26 +337,26 @@ composite_config_descriptor_hs = { 0x05, /* bDescriptorType (Endpoint) */ 0x84, /* bEndpointAddress (EP3-IN) */ 0x03, /* bmAttributes (interrupt) */ - 0x0040, /* wMaxPacketSize */ + 0x0200, /* wMaxPacketSize */ 0xff, /* bInterval (milliseconds) */ }, { /* Second Interface Descriptor For Data Interface */ 0x09, /* bLength */ 0x04, /* bDescriptorType (Interface) */ - 0x01, /* bInterfaceNumber */ + 0x02, /* bInterfaceNumber */ 0x00, /* bAlternateSetting */ 0x02, /* bNumEndpoints */ - 0x02, /* bInterfaceClass = Data Interface (10) */ - 0x02, /* bInterfaceSubClass = none (0) */ - 0x01, /* bInterfaceProtocol = No class specific protocol (0) */ - 0x00, /* biInterface = No Text String (0) */ + 0x0a, /* bInterfaceClass = Data Interface (10) */ + 0x00, /* bInterfaceSubClass = none (0) */ + 0x00, /* bInterfaceProtocol = No class specific protocol (0) */ + 0x04, /* biInterface = No Text String (0) */ }, { /* OUT Endpoint 1 (Descriptor #2) */ 0x07, /* bLength */ 0x05, /* bDescriptorType (Endpoint) */ - 0x02, /* bEndpointAddress (EP1-OUT) */ + 0x05, /* bEndpointAddress (EP1-OUT) */ 0x02, /* bmAttributes (bulk) */ - 0x0040, /* wMaxPacketSize */ + 0x0200, /* wMaxPacketSize */ 0x00, /* bInterval (N/A) */ }, { /* IN Endpoint 2 (Descriptor #3) */ @@ -308,36 +364,8 @@ composite_config_descriptor_hs = { 0x05, /* bDescriptorType (Endpoint) */ 0x83, /* bEndpointAddress (EP2-IN) */ 0x02, /* bmAttributes (bulk) */ - 0x0040, /* wMaxPacketSize */ - 0x00, /* bInterval (N/A) */ - }, - /********** Interface #1 : Mass Storage Device **********/ - { /* Second Interface Descriptor For MSC Interface */ - 0x09, /* bLength = 9 */ - 0x04, /* bDescriptorType = Interface (4) */ - 0x02, /* bInterfaceNumber */ - 0x00, /* bAlternateSetting */ - 0x02, /* bNumEndpoints (one for IN one for OUT) */ - 0x08, /* bInterfaceClass = Mass Storage (8) */ - 0x06, /* bInterfaceSubClass = SCSI Transparent Command Set */ - 0x50, /* bInterfaceProtocol = Bulk-Only Transport */ - 0x05, /* iInterface */ - }, - { /* OUT Endpoint 1 (Descriptor #1) */ - 0x07, /* bLength */ - 0x05, /* bDescriptorType (Endpoint) */ - 0x01, /* bEndpointAddress (EP1-OUT) */ - 0x02, /* bmAttributes (bulk) */ - 0x0200, /* wMaxPacketSize */ - 0x01, /* bInterval (N/A) */ - }, - { /* IN Endpoint 2 (Descriptor #2) */ - 0x07, /* bLength */ - 0x05, /* bDescriptorType (Endpoint) */ - 0x82, /* bEndpointAddress (EP2-IN) */ - 0x02, /* bmAttributes (bulk) */ 0x0200, /* wMaxPacketSize */ - 0x01 /* bInterval (N/A) */ + 0x00, /* bInterval (N/A) */ }, }; diff --git a/lib/sdk/Applications/EvKitExamples/USB_CompositeDevice_CDCACM/main.c b/lib/sdk/Applications/EvKitExamples/USB_CompositeDevice_CDCACM/main.c index 7ca4cf4cb808355d65ec138271ed34584039e539..5f5d0bec6e136444b8f94c77032c10e766f05d03 100644 --- a/lib/sdk/Applications/EvKitExamples/USB_CompositeDevice_CDCACM/main.c +++ b/lib/sdk/Applications/EvKitExamples/USB_CompositeDevice_CDCACM/main.c @@ -1,16 +1,16 @@ /* ***************************************************************************** * Copyright (C) 2018 Maxim Integrated Products, Inc., All Rights Reserved. - * + * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. @@ -18,20 +18,20 @@ * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. - * + * * Except as contained in this notice, the name of Maxim Integrated * Products, Inc. shall not be used except as stated in the Maxim Integrated * Products, Inc. Branding Policy. - * + * * The mere transfer of this software does not imply any licenses * of trade secrets, proprietary technology, copyrights, patents, * trademarks, maskwork rights, or any other form of intellectual * property whatsoever. Maxim Integrated Products, Inc. retains all * ownership rights. - * + * * $Date: 2018-07-18 13:53:37 -0500 (Wed, 18 Jul 2018) $ * $Revision: 36256 $ - * + * **************************************************************************** */ #include <stdio.h> @@ -89,12 +89,12 @@ static const msc_idstrings_t ids = { }; /* This EP assignment must match the Configuration Descriptor */ -static const acm_cfg_t acm_cfg = { - 1, /* EP OUT */ +static acm_cfg_t acm_cfg = { + 2, /* EP OUT */ MXC_USBHS_MAX_PACKET, /* OUT max packet size */ - 2, /* EP IN */ + 3, /* EP IN */ MXC_USBHS_MAX_PACKET, /* IN max packet size */ - 3, /* EP Notify */ + 4, /* EP Notify */ MXC_USBHS_MAX_PACKET, /* Notify max packet size */ }; @@ -158,7 +158,7 @@ int main(void) remote_wake_en = 0; /* Start out in full speed */ - usb_opts.enable_hs = 0; /* 0:Full Speed 1:High Speed */ + usb_opts.enable_hs = 1; /* 0:Full Speed 1:High Speed */ usb_opts.delay_us = delay_us; /* Function which will be used for delays */ usb_opts.init_callback = usb_startup_cb; usb_opts.shutdown_callback = usb_shutdown_cb; @@ -307,12 +307,21 @@ static int setconfig_callback(usb_setup_pkt *sud, void *cbdata) msc_cfg.in_ep = composite_config_descriptor.endpoint_descriptor_2.bEndpointAddress & 0x7; msc_cfg.in_maxpacket = composite_config_descriptor.endpoint_descriptor_2.wMaxPacketSize; } - acm_configure(&acm_cfg); - return msc_configure(&msc_cfg);/* Configure the device class */ + + acm_cfg.out_ep = composite_config_descriptor.endpoint_descriptor_4.bEndpointAddress & 0x7; + acm_cfg.out_maxpacket = composite_config_descriptor.endpoint_descriptor_4.wMaxPacketSize; + acm_cfg.in_ep = composite_config_descriptor.endpoint_descriptor_5.bEndpointAddress & 0x7; + acm_cfg.in_maxpacket = composite_config_descriptor.endpoint_descriptor_5.wMaxPacketSize; + acm_cfg.notify_ep = composite_config_descriptor.endpoint_descriptor_3.bEndpointAddress & 0x7; + acm_cfg.notify_maxpacket = composite_config_descriptor.endpoint_descriptor_3.wMaxPacketSize; + + msc_configure(&msc_cfg); + return acm_configure(&acm_cfg); + /* Configure the device class */ } else if (sud->wValue == 0) { configured = 0; - acm_deconfigure(); - return msc_deconfigure(); + msc_deconfigure(); + return acm_deconfigure(); } return -1; @@ -363,7 +372,6 @@ static void usb_app_wakeup(void) } /* ************************************************************************** */ - static int event_callback(maxusb_event_t evt, void *data) { /* Set event flag */ @@ -377,8 +385,8 @@ static int event_callback(maxusb_event_t evt, void *data) usb_disconnect(); configured = 0; enum_clearconfig(); - acm_deconfigure(); msc_deconfigure(); + acm_deconfigure(); usb_app_sleep(); break; case MAXUSB_EVENT_VBUS: @@ -394,8 +402,8 @@ static int event_callback(maxusb_event_t evt, void *data) case MAXUSB_EVENT_BRST: usb_app_wakeup(); enum_clearconfig(); - acm_deconfigure(); msc_deconfigure(); + acm_deconfigure(); configured = 0; suspended = 0; break; diff --git a/lib/sdk/Applications/EvKitExamples/USB_MassStorage_SDHC/USB_MassStorage.launch b/lib/sdk/Applications/EvKitExamples/USB_MassStorage_SDHC/USB_MassStorage_SDHC.launch similarity index 100% rename from lib/sdk/Applications/EvKitExamples/USB_MassStorage_SDHC/USB_MassStorage.launch rename to lib/sdk/Applications/EvKitExamples/USB_MassStorage_SDHC/USB_MassStorage_SDHC.launch