diff --git a/.github/workflows/ci_set_matrix.py b/.github/workflows/ci_set_matrix.py
index a56bd4214..c9698c934 100644
--- a/.github/workflows/ci_set_matrix.py
+++ b/.github/workflows/ci_set_matrix.py
@@ -22,6 +22,7 @@ family_list = {
"lpc11 lpc13 lpc15": ["arm-gcc", "arm-clang"],
"lpc17 lpc18 lpc40 lpc43": ["arm-gcc", "arm-clang"],
"lpc51 lpc54 lpc55": ["arm-gcc", "arm-clang"],
+ "max32650 max32666 max32690 max78002": ["arm-gcc"],
"mcx": ["arm-gcc"],
"mm32": ["arm-gcc"],
"msp430": ["msp430-gcc"],
diff --git a/.idea/cmake.xml b/.idea/cmake.xml
index 729309ebb..e8b46d468 100644
--- a/.idea/cmake.xml
+++ b/.idea/cmake.xml
@@ -114,7 +114,6 @@
-
@@ -122,11 +121,12 @@
-
-
+
-
+
+
+
@@ -140,6 +140,9 @@
+
+
+
\ No newline at end of file
diff --git a/README.rst b/README.rst
index 1ae8c5375..422f23271 100644
--- a/README.rst
+++ b/README.rst
@@ -1,4 +1,4 @@
-|Build Status| |Documentation Status| |Fuzzing Status| |License|
+|Build Status| |CircleCI Status| |Documentation Status| |Fuzzing Status| |License|
Sponsors
========
@@ -197,6 +197,8 @@ Docs
.. |Build Status| image:: https://github.com/hathach/tinyusb/actions/workflows/cmake_arm.yml/badge.svg
:target: https://github.com/hathach/tinyusb/actions
+.. |CircleCI Status| image:: https://dl.circleci.com/status-badge/img/circleci/4AYHvUhFxdnY4rA7LEsdqW/QmrpoL2AjGqetvFQNqtWyq/tree/master.svg?style=svg
+ :target: https://dl.circleci.com/status-badge/redirect/circleci/4AYHvUhFxdnY4rA7LEsdqW/QmrpoL2AjGqetvFQNqtWyq/tree/master
.. |Documentation Status| image:: https://readthedocs.org/projects/tinyusb/badge/?version=latest
:target: https://docs.tinyusb.org/en/latest/?badge=latest
.. |Fuzzing Status| image:: https://oss-fuzz-build-logs.storage.googleapis.com/badges/tinyusb.svg
diff --git a/examples/build_system/make/rules.mk b/examples/build_system/make/rules.mk
index f322dbae6..86de17b6c 100644
--- a/examples/build_system/make/rules.mk
+++ b/examples/build_system/make/rules.mk
@@ -166,6 +166,11 @@ flash-bmp: $(BUILD)/$(PROJECT).elf
debug-bmp: $(BUILD)/$(PROJECT).elf
$(GDB) -ex 'target extended-remote $(BMP)' -ex 'monitor swdp_scan' -ex 'attach 1' $<
+# --------------- TI Uniflash -----------------
+DSLITE ?= dslite.sh
+flash-uniflash: $(BUILD)/$(PROJECT).hex
+ ${DSLITE} ${UNIFLASH_OPTION} -f $<
+
#-------------- Artifacts --------------
# Create binary directory
diff --git a/examples/device/cdc_dual_ports/src/usb_descriptors.c b/examples/device/cdc_dual_ports/src/usb_descriptors.c
index de2505c07..ca4fe279b 100644
--- a/examples/device/cdc_dual_ports/src/usb_descriptors.c
+++ b/examples/device/cdc_dual_ports/src/usb_descriptors.c
@@ -98,19 +98,19 @@ enum
#define EPNUM_CDC_1_OUT 0x05
#define EPNUM_CDC_1_IN 0x85
-#elif CFG_TUSB_MCU == OPT_MCU_SAMG || CFG_TUSB_MCU == OPT_MCU_SAMX7X
- // SAMG & SAME70 don't support a same endpoint number with different direction IN and OUT
- // e.g EP1 OUT & EP1 IN cannot exist together
- #define EPNUM_CDC_0_NOTIF 0x81
+#elif CFG_TUSB_MCU == OPT_MCU_CXD56
+ // CXD56 USB driver has fixed endpoint type (bulk/interrupt/iso) and direction (IN/OUT) by its number
+ // 0 control (IN/OUT), 1 Bulk (IN), 2 Bulk (OUT), 3 In (IN), 4 Bulk (IN), 5 Bulk (OUT), 6 In (IN)
+ #define EPNUM_CDC_0_NOTIF 0x83
#define EPNUM_CDC_0_OUT 0x02
- #define EPNUM_CDC_0_IN 0x83
+ #define EPNUM_CDC_0_IN 0x81
- #define EPNUM_CDC_1_NOTIF 0x84
+ #define EPNUM_CDC_1_NOTIF 0x86
#define EPNUM_CDC_1_OUT 0x05
- #define EPNUM_CDC_1_IN 0x86
+ #define EPNUM_CDC_1_IN 0x84
-#elif CFG_TUSB_MCU == OPT_MCU_FT90X || CFG_TUSB_MCU == OPT_MCU_FT93X
- // FT9XX doesn't support a same endpoint number with different direction IN and OUT
+#elif defined(TUD_ENDPOINT_EXCLUSIVE_NUMBER)
+ // MCUs that don't support a same endpoint number with different direction IN and OUT defined in tusb_mcu.h
// e.g EP1 OUT & EP1 IN cannot exist together
#define EPNUM_CDC_0_NOTIF 0x81
#define EPNUM_CDC_0_OUT 0x02
diff --git a/examples/device/cdc_msc/src/usb_descriptors.c b/examples/device/cdc_msc/src/usb_descriptors.c
index 2afa24903..4789f5a9b 100644
--- a/examples/device/cdc_msc/src/usb_descriptors.c
+++ b/examples/device/cdc_msc/src/usb_descriptors.c
@@ -93,19 +93,7 @@ enum {
#define EPNUM_MSC_OUT 0x05
#define EPNUM_MSC_IN 0x85
-#elif CFG_TUSB_MCU == OPT_MCU_SAMG || CFG_TUSB_MCU == OPT_MCU_SAMX7X
- // SAMG & SAME70 don't support a same endpoint number with different direction IN and OUT
- // e.g EP1 OUT & EP1 IN cannot exist together
- #define EPNUM_CDC_NOTIF 0x81
- #define EPNUM_CDC_OUT 0x02
- #define EPNUM_CDC_IN 0x83
-
- #define EPNUM_MSC_OUT 0x04
- #define EPNUM_MSC_IN 0x85
-
#elif CFG_TUSB_MCU == OPT_MCU_CXD56
- // CXD56 doesn't support a same endpoint number with different direction IN and OUT
- // e.g EP1 OUT & EP1 IN cannot exist together
// CXD56 USB driver has fixed endpoint type (bulk/interrupt/iso) and direction (IN/OUT) by its number
// 0 control (IN/OUT), 1 Bulk (IN), 2 Bulk (OUT), 3 In (IN), 4 Bulk (IN), 5 Bulk (OUT), 6 In (IN)
#define EPNUM_CDC_NOTIF 0x83
@@ -115,8 +103,8 @@ enum {
#define EPNUM_MSC_OUT 0x05
#define EPNUM_MSC_IN 0x84
-#elif CFG_TUSB_MCU == OPT_MCU_FT90X || CFG_TUSB_MCU == OPT_MCU_FT93X
- // FT9XX doesn't support a same endpoint number with different direction IN and OUT
+#elif defined(TUD_ENDPOINT_EXCLUSIVE_NUMBER)
+ // MCUs that don't support a same endpoint number with different direction IN and OUT defined in tusb_mcu.h
// e.g EP1 OUT & EP1 IN cannot exist together
#define EPNUM_CDC_NOTIF 0x81
#define EPNUM_CDC_OUT 0x02
diff --git a/examples/device/cdc_msc_freertos/src/usb_descriptors.c b/examples/device/cdc_msc_freertos/src/usb_descriptors.c
index 9c29701c7..7f9338753 100644
--- a/examples/device/cdc_msc_freertos/src/usb_descriptors.c
+++ b/examples/device/cdc_msc_freertos/src/usb_descriptors.c
@@ -42,8 +42,7 @@
//--------------------------------------------------------------------+
// Device Descriptors
//--------------------------------------------------------------------+
-tusb_desc_device_t const desc_device =
-{
+tusb_desc_device_t const desc_device = {
.bLength = sizeof(tusb_desc_device_t),
.bDescriptorType = TUSB_DESC_DEVICE,
.bcdUSB = USB_BCD,
@@ -69,8 +68,7 @@ tusb_desc_device_t const desc_device =
// Invoked when received GET DEVICE DESCRIPTOR
// Application return pointer to descriptor
-uint8_t const * tud_descriptor_device_cb(void)
-{
+uint8_t const *tud_descriptor_device_cb(void) {
return (uint8_t const *) &desc_device;
}
@@ -78,8 +76,7 @@ uint8_t const * tud_descriptor_device_cb(void)
// Configuration Descriptor
//--------------------------------------------------------------------+
-enum
-{
+enum {
ITF_NUM_CDC = 0,
ITF_NUM_CDC_DATA,
ITF_NUM_MSC,
@@ -96,8 +93,18 @@ enum
#define EPNUM_MSC_OUT 0x05
#define EPNUM_MSC_IN 0x85
-#elif CFG_TUSB_MCU == OPT_MCU_SAMG
- // SAMG doesn't support a same endpoint number with different direction IN and OUT
+#elif CFG_TUSB_MCU == OPT_MCU_CXD56
+ // CXD56 USB driver has fixed endpoint type (bulk/interrupt/iso) and direction (IN/OUT) by its number
+ // 0 control (IN/OUT), 1 Bulk (IN), 2 Bulk (OUT), 3 In (IN), 4 Bulk (IN), 5 Bulk (OUT), 6 In (IN)
+ #define EPNUM_CDC_NOTIF 0x83
+ #define EPNUM_CDC_OUT 0x02
+ #define EPNUM_CDC_IN 0x81
+
+ #define EPNUM_MSC_OUT 0x05
+ #define EPNUM_MSC_IN 0x84
+
+#elif defined(TUD_ENDPOINT_EXCLUSIVE_NUMBER)
+ // MCUs that don't support a same endpoint number with different direction IN and OUT defined in tusb_mcu.h
// e.g EP1 OUT & EP1 IN cannot exist together
#define EPNUM_CDC_NOTIF 0x81
#define EPNUM_CDC_OUT 0x02
diff --git a/examples/device/cdc_uac2/src/usb_descriptors.c b/examples/device/cdc_uac2/src/usb_descriptors.c
index 72a695622..6384f722a 100644
--- a/examples/device/cdc_uac2/src/usb_descriptors.c
+++ b/examples/device/cdc_uac2/src/usb_descriptors.c
@@ -97,18 +97,8 @@ uint8_t const * tud_descriptor_device_cb(void)
#define EPNUM_CDC_OUT 0x02
#define EPNUM_CDC_IN 0x82
-#elif CFG_TUSB_MCU == OPT_MCU_SAMG || CFG_TUSB_MCU == OPT_MCU_SAMX7X
- // SAMG & SAME70 don't support a same endpoint number with different direction IN and OUT
- // e.g EP1 OUT & EP1 IN cannot exist together
- #define EPNUM_AUDIO_IN 0x01
- #define EPNUM_AUDIO_OUT 0x02
-
- #define EPNUM_CDC_NOTIF 0x83
- #define EPNUM_CDC_OUT 0x04
- #define EPNUM_CDC_IN 0x85
-
-#elif CFG_TUSB_MCU == OPT_MCU_FT90X || CFG_TUSB_MCU == OPT_MCU_FT93X
- // FT9XX doesn't support a same endpoint number with different direction IN and OUT
+#elif defined(TUD_ENDPOINT_EXCLUSIVE_NUMBER)
+ // MCUs that don't support a same endpoint number with different direction IN and OUT defined in tusb_mcu.h
// e.g EP1 OUT & EP1 IN cannot exist together
#define EPNUM_AUDIO_IN 0x01
#define EPNUM_AUDIO_OUT 0x02
diff --git a/examples/device/dynamic_configuration/src/usb_descriptors.c b/examples/device/dynamic_configuration/src/usb_descriptors.c
index 7f35b4b22..7be3d7da5 100644
--- a/examples/device/dynamic_configuration/src/usb_descriptors.c
+++ b/examples/device/dynamic_configuration/src/usb_descriptors.c
@@ -132,21 +132,8 @@ enum
#define EPNUM_1_MSC_OUT 0x02
#define EPNUM_1_MSC_IN 0x82
-#elif CFG_TUSB_MCU == OPT_MCU_SAMG
- // SAMG doesn't support a same endpoint number with different direction IN and OUT
- // e.g EP1 OUT & EP1 IN cannot exist together
- #define EPNUM_0_CDC_NOTIF 0x81
- #define EPNUM_0_CDC_OUT 0x02
- #define EPNUM_0_CDC_IN 0x83
-
- #define EPNUM_0_MIDI_OUT 0x04
- #define EPNUM_0_MIDI_IN 0x85
-
- #define EPNUM_1_MSC_OUT 0x01
- #define EPNUM_1_MSC_IN 0x82
-
-#elif CFG_TUSB_MCU == OPT_MCU_FT90X || CFG_TUSB_MCU == OPT_MCU_FT93X
- // FT9XX doesn't support a same endpoint number with different direction IN and OUT
+#elif defined(TUD_ENDPOINT_EXCLUSIVE_NUMBER)
+ // MCUs that don't support a same endpoint number with different direction IN and OUT defined in tusb_mcu.h
// e.g EP1 OUT & EP1 IN cannot exist together
#define EPNUM_0_CDC_NOTIF 0x81
#define EPNUM_0_CDC_OUT 0x02
diff --git a/examples/device/midi_test/src/usb_descriptors.c b/examples/device/midi_test/src/usb_descriptors.c
index 9781d3d6f..3511f7eba 100644
--- a/examples/device/midi_test/src/usb_descriptors.c
+++ b/examples/device/midi_test/src/usb_descriptors.c
@@ -84,15 +84,24 @@ enum
#if CFG_TUSB_MCU == OPT_MCU_LPC175X_6X || CFG_TUSB_MCU == OPT_MCU_LPC177X_8X || CFG_TUSB_MCU == OPT_MCU_LPC40XX
// LPC 17xx and 40xx endpoint type (bulk/interrupt/iso) are fixed by its number
// 0 control, 1 In, 2 Bulk, 3 Iso, 4 In etc ...
- #define EPNUM_MIDI_OUT 0x02
- #define EPNUM_MIDI_IN 0x02
-#elif CFG_TUSB_MCU == OPT_MCU_FT90X || CFG_TUSB_MCU == OPT_MCU_FT93X
- // On Bridgetek FT9xx endpoint numbers must be unique...
- #define EPNUM_MIDI_OUT 0x02
- #define EPNUM_MIDI_IN 0x03
+ #define EPNUM_MIDI_OUT 0x02
+ #define EPNUM_MIDI_IN 0x82
+
+#elif CFG_TUSB_MCU == OPT_MCU_CXD56
+ // CXD56 USB driver has fixed endpoint type (bulk/interrupt/iso) and direction (IN/OUT) by its number
+ // 0 control (IN/OUT), 1 Bulk (IN), 2 Bulk (OUT), 3 In (IN), 4 Bulk (IN), 5 Bulk (OUT), 6 In (IN)
+ #define EPNUM_MIDI_OUT 0x02
+ #define EPNUM_MIDI_IN 0x81
+
+#elif defined(TUD_ENDPOINT_EXCLUSIVE_NUMBER)
+ // MCUs that don't support a same endpoint number with different direction IN and OUT defined in tusb_mcu.h
+ // e.g EP1 OUT & EP1 IN cannot exist together
+ #define EPNUM_MIDI_OUT 0x01
+ #define EPNUM_MIDI_IN 0x82
+
#else
- #define EPNUM_MIDI_OUT 0x01
- #define EPNUM_MIDI_IN 0x01
+ #define EPNUM_MIDI_OUT 0x01
+ #define EPNUM_MIDI_IN 0x81
#endif
uint8_t const desc_fs_configuration[] =
diff --git a/examples/device/msc_dual_lun/src/usb_descriptors.c b/examples/device/msc_dual_lun/src/usb_descriptors.c
index c0610945f..bc2f2577c 100644
--- a/examples/device/msc_dual_lun/src/usb_descriptors.c
+++ b/examples/device/msc_dual_lun/src/usb_descriptors.c
@@ -85,17 +85,17 @@ enum
#define EPNUM_MSC_OUT 0x02
#define EPNUM_MSC_IN 0x82
-#elif CFG_TUSB_MCU == OPT_MCU_SAMG
- // SAMG doesn't support a same endpoint number with different direction IN and OUT
- // e.g EP1 OUT & EP1 IN cannot exist together
- #define EPNUM_MSC_OUT 0x01
- #define EPNUM_MSC_IN 0x82
+#elif CFG_TUSB_MCU == OPT_MCU_CXD56
+ // CXD56 USB driver has fixed endpoint type (bulk/interrupt/iso) and direction (IN/OUT) by its number
+ // 0 control (IN/OUT), 1 Bulk (IN), 2 Bulk (OUT), 3 In (IN), 4 Bulk (IN), 5 Bulk (OUT), 6 In (IN)
+ #define EPNUM_MSC_OUT 0x02
+ #define EPNUM_MSC_IN 0x81
-#elif CFG_TUSB_MCU == OPT_MCU_FT90X || CFG_TUSB_MCU == OPT_MCU_FT93X
- // FT9XX doesn't support a same endpoint number with different direction IN and OUT
+#elif defined(TUD_ENDPOINT_EXCLUSIVE_NUMBER)
+ // MCUs that don't support a same endpoint number with different direction IN and OUT defined in tusb_mcu.h
// e.g EP1 OUT & EP1 IN cannot exist together
- #define EPNUM_MSC_OUT 0x01
- #define EPNUM_MSC_IN 0x82
+ #define EPNUM_MSC_OUT 0x01
+ #define EPNUM_MSC_IN 0x82
#else
#define EPNUM_MSC_OUT 0x01
diff --git a/examples/device/net_lwip_webserver/src/tusb_config.h b/examples/device/net_lwip_webserver/src/tusb_config.h
index d3e094517..22082fc81 100644
--- a/examples/device/net_lwip_webserver/src/tusb_config.h
+++ b/examples/device/net_lwip_webserver/src/tusb_config.h
@@ -91,6 +91,8 @@ extern "C" {
#define USE_ECM 1
#elif TU_CHECK_MCU(OPT_MCU_STM32F0, OPT_MCU_STM32F1)
#define USE_ECM 1
+#elif TU_CHECK_MCU(OPT_MCU_MAX32690, OPT_MCU_MAX32650, OPT_MCU_MAX32666, OPT_MCU_MAX78002)
+ #define USE_ECM 1
#else
#define USE_ECM 0
#define INCLUDE_IPERF
diff --git a/examples/device/net_lwip_webserver/src/usb_descriptors.c b/examples/device/net_lwip_webserver/src/usb_descriptors.c
index da628c8be..2a3061162 100644
--- a/examples/device/net_lwip_webserver/src/usb_descriptors.c
+++ b/examples/device/net_lwip_webserver/src/usb_descriptors.c
@@ -113,8 +113,15 @@ uint8_t const * tud_descriptor_device_cb(void)
#define EPNUM_NET_OUT 0x02
#define EPNUM_NET_IN 0x82
-#elif CFG_TUSB_MCU == OPT_MCU_SAMG || CFG_TUSB_MCU == OPT_MCU_SAMX7X
- // SAMG & SAME70 don't support a same endpoint number with different direction IN and OUT
+#elif CFG_TUSB_MCU == OPT_MCU_CXD56
+ // CXD56 USB driver has fixed endpoint type (bulk/interrupt/iso) and direction (IN/OUT) by its number
+ // 0 control (IN/OUT), 1 Bulk (IN), 2 Bulk (OUT), 3 In (IN), 4 Bulk (IN), 5 Bulk (OUT), 6 In (IN)
+ #define EPNUM_NET_NOTIF 0x83
+ #define EPNUM_NET_OUT 0x02
+ #define EPNUM_NET_IN 0x81
+
+#elif defined(TUD_ENDPOINT_EXCLUSIVE_NUMBER)
+ // MCUs that don't support a same endpoint number with different direction IN and OUT defined in tusb_mcu.h
// e.g EP1 OUT & EP1 IN cannot exist together
#define EPNUM_NET_NOTIF 0x81
#define EPNUM_NET_OUT 0x02
diff --git a/examples/device/uac2_headset/src/usb_descriptors.c b/examples/device/uac2_headset/src/usb_descriptors.c
index ff4dc2acc..e8dc5ec15 100644
--- a/examples/device/uac2_headset/src/usb_descriptors.c
+++ b/examples/device/uac2_headset/src/usb_descriptors.c
@@ -84,21 +84,21 @@ uint8_t const * tud_descriptor_device_cb(void)
#define EPNUM_AUDIO_OUT 0x03
#define EPNUM_AUDIO_INT 0x01
+#elif CFG_TUSB_MCU == OPT_MCU_CXD56
+ // CXD56 USB driver has fixed endpoint type (bulk/interrupt/iso) and direction (IN/OUT) by its number
+ // 0 control (IN/OUT), 1 Bulk (IN), 2 Bulk (OUT), 3 In (IN), 4 Bulk (IN), 5 Bulk (OUT), 6 In (IN)
+ // #define EPNUM_AUDIO_IN 0x01
+ // #define EPNUM_AUDIO_OUT 0x02
+ // #define EPNUM_AUDIO_INT 0x03
+
#elif CFG_TUSB_MCU == OPT_MCU_NRF5X
// ISO endpoints for NRF5x are fixed to 0x08 (0x88)
#define EPNUM_AUDIO_IN 0x08
#define EPNUM_AUDIO_OUT 0x08
#define EPNUM_AUDIO_INT 0x01
-#elif CFG_TUSB_MCU == OPT_MCU_SAMG || CFG_TUSB_MCU == OPT_MCU_SAMX7X
- // SAMG & SAME70 don't support a same endpoint number with different direction IN and OUT
- // e.g EP1 OUT & EP1 IN cannot exist together
- #define EPNUM_AUDIO_IN 0x01
- #define EPNUM_AUDIO_OUT 0x02
- #define EPNUM_AUDIO_INT 0x03
-
-#elif CFG_TUSB_MCU == OPT_MCU_FT90X || CFG_TUSB_MCU == OPT_MCU_FT93X
- // FT9XX doesn't support a same endpoint number with different direction IN and OUT
+#elif defined(TUD_ENDPOINT_EXCLUSIVE_NUMBER)
+ // MCUs that don't support a same endpoint number with different direction IN and OUT defined in tusb_mcu.h
// e.g EP1 OUT & EP1 IN cannot exist together
#define EPNUM_AUDIO_IN 0x01
#define EPNUM_AUDIO_OUT 0x02
diff --git a/examples/device/uac2_speaker_fb/src/usb_descriptors.c b/examples/device/uac2_speaker_fb/src/usb_descriptors.c
index 31c5e116d..aadeb7e8a 100644
--- a/examples/device/uac2_speaker_fb/src/usb_descriptors.c
+++ b/examples/device/uac2_speaker_fb/src/usb_descriptors.c
@@ -131,15 +131,8 @@ uint8_t const * tud_hid_descriptor_report_cb(uint8_t itf)
#define EPNUM_AUDIO_OUT 0x08
#define EPNUM_DEBUG 0x01
-#elif CFG_TUSB_MCU == OPT_MCU_SAMG || CFG_TUSB_MCU == OPT_MCU_SAMX7X
- // SAMG & SAME70 don't support a same endpoint number with different direction IN and OUT
- // e.g EP1 OUT & EP1 IN cannot exist together
- #define EPNUM_AUDIO_FB 0x01
- #define EPNUM_AUDIO_OUT 0x02
- #define EPNUM_DEBUG 0x03
-
-#elif CFG_TUSB_MCU == OPT_MCU_FT90X || CFG_TUSB_MCU == OPT_MCU_FT93X
- // FT9XX doesn't support a same endpoint number with different direction IN and OUT
+#elif defined(TUD_ENDPOINT_EXCLUSIVE_NUMBER)
+ // MCUs that don't support a same endpoint number with different direction IN and OUT defined in tusb_mcu.h
// e.g EP1 OUT & EP1 IN cannot exist together
#define EPNUM_AUDIO_FB 0x01
#define EPNUM_AUDIO_OUT 0x02
diff --git a/examples/device/webusb_serial/src/usb_descriptors.c b/examples/device/webusb_serial/src/usb_descriptors.c
index b01fae8e3..2ff6d9ced 100644
--- a/examples/device/webusb_serial/src/usb_descriptors.c
+++ b/examples/device/webusb_serial/src/usb_descriptors.c
@@ -87,29 +87,40 @@ enum
#if CFG_TUSB_MCU == OPT_MCU_LPC175X_6X || CFG_TUSB_MCU == OPT_MCU_LPC177X_8X || CFG_TUSB_MCU == OPT_MCU_LPC40XX
// LPC 17xx and 40xx endpoint type (bulk/interrupt/iso) are fixed by its number
// 0 control, 1 In, 2 Bulk, 3 Iso, 4 In etc ...
- #define EPNUM_CDC_IN 2
- #define EPNUM_CDC_OUT 2
- #define EPNUM_VENDOR_IN 5
- #define EPNUM_VENDOR_OUT 5
-#elif CFG_TUSB_MCU == OPT_MCU_SAMG || CFG_TUSB_MCU == OPT_MCU_SAMX7X
- // SAMG & SAME70 don't support a same endpoint number with different direction IN and OUT
+ #define EPNUM_CDC_NOTIF 0x81
+ #define EPNUM_CDC_OUT 0x02
+ #define EPNUM_CDC_IN 0x82
+
+ #define EPNUM_VENDOR_OUT 0x05
+ #define EPNUM_VENDOR_IN 0x85
+
+#elif CFG_TUSB_MCU == OPT_MCU_CXD56
+ // CXD56 USB driver has fixed endpoint type (bulk/interrupt/iso) and direction (IN/OUT) by its number
+ // 0 control (IN/OUT), 1 Bulk (IN), 2 Bulk (OUT), 3 In (IN), 4 Bulk (IN), 5 Bulk (OUT), 6 In (IN)
+ #define EPNUM_CDC_NOTIF 0x83
+ #define EPNUM_CDC_OUT 0x02
+ #define EPNUM_CDC_IN 0x81
+
+ #define EPNUM_VENDOR_OUT 0x05
+ #define EPNUM_VENDOR_IN 0x84
+
+#elif defined(TUD_ENDPOINT_EXCLUSIVE_NUMBER)
+ // MCUs that don't support a same endpoint number with different direction IN and OUT defined in tusb_mcu.h
// e.g EP1 OUT & EP1 IN cannot exist together
- #define EPNUM_CDC_IN 2
- #define EPNUM_CDC_OUT 3
- #define EPNUM_VENDOR_IN 4
- #define EPNUM_VENDOR_OUT 5
-#elif CFG_TUSB_MCU == OPT_MCU_FT90X || CFG_TUSB_MCU == OPT_MCU_FT93X
- // FT9XX doesn't support a same endpoint number with different direction IN and OUT
- // e.g EP1 OUT & EP1 IN cannot exist together
- #define EPNUM_CDC_IN 2
- #define EPNUM_CDC_OUT 3
- #define EPNUM_VENDOR_IN 4
- #define EPNUM_VENDOR_OUT 5
+ #define EPNUM_CDC_NOTIF 0x81
+ #define EPNUM_CDC_OUT 0x02
+ #define EPNUM_CDC_IN 0x83
+
+ #define EPNUM_VENDOR_OUT 0x04
+ #define EPNUM_VENDOR_IN 0x85
+
#else
- #define EPNUM_CDC_IN 2
- #define EPNUM_CDC_OUT 2
- #define EPNUM_VENDOR_IN 3
- #define EPNUM_VENDOR_OUT 3
+ #define EPNUM_CDC_NOTIF 0x81
+ #define EPNUM_CDC_OUT 0x02
+ #define EPNUM_CDC_IN 0x82
+
+ #define EPNUM_VENDOR_OUT 0x03
+ #define EPNUM_VENDOR_IN 0x83
#endif
uint8_t const desc_configuration[] =
@@ -118,7 +129,7 @@ uint8_t const desc_configuration[] =
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, 0x00, 100),
// Interface number, string index, EP notification address and size, EP data address (out, in) and size.
- TUD_CDC_DESCRIPTOR(ITF_NUM_CDC, 4, 0x81, 8, EPNUM_CDC_OUT, 0x80 | EPNUM_CDC_IN, TUD_OPT_HIGH_SPEED ? 512 : 64),
+ TUD_CDC_DESCRIPTOR(ITF_NUM_CDC, 4, EPNUM_CDC_NOTIF, 8, EPNUM_CDC_OUT, 0x80 | EPNUM_CDC_IN, TUD_OPT_HIGH_SPEED ? 512 : 64),
// Interface number, string index, EP Out & IN address, EP size
TUD_VENDOR_DESCRIPTOR(ITF_NUM_VENDOR, 5, EPNUM_VENDOR_OUT, 0x80 | EPNUM_VENDOR_IN, TUD_OPT_HIGH_SPEED ? 512 : 64)
diff --git a/hw/bsp/board_mcu.h b/hw/bsp/board_mcu.h
index 013eb1c83..d3a33cf36 100644
--- a/hw/bsp/board_mcu.h
+++ b/hw/bsp/board_mcu.h
@@ -170,6 +170,18 @@
#elif TU_CHECK_MCU(OPT_MCU_BCM2711, OPT_MCU_BCM2835, OPT_MCU_BCM2837)
// no header needed
+#elif CFG_TUSB_MCU == OPT_MCU_MAX32690
+ #include "max32690.h"
+
+#elif CFG_TUSB_MCU == OPT_MCU_MAX32650
+ #include "max32650.h"
+
+#elif CFG_TUSB_MCU == OPT_MCU_MAX32666
+ #include "max32665.h"
+
+#elif CFG_TUSB_MCU == OPT_MCU_MAX78002
+ #include "max78002.h"
+
#else
#error "Missing MCU header"
#endif
diff --git a/hw/bsp/family_support.cmake b/hw/bsp/family_support.cmake
index 03a24c95b..1df8a6f53 100644
--- a/hw/bsp/family_support.cmake
+++ b/hw/bsp/family_support.cmake
@@ -480,6 +480,25 @@ function(family_flash_openocd_wch TARGET)
endfunction()
+# Add flash openocd adi (Analog Devices) target
+# included with msdk or compiled from release branch of https://github.com/analogdevicesinc/openocd
+function(family_flash_openocd_adi TARGET)
+ if (DEFINED $ENV{MAXIM_PATH})
+ # use openocd from msdk
+ set(OPENOCD ENV{MAXIM_PATH}/Tools/OpenOCD/openocd)
+ set(OPENOCD_OPTION2 "-s ENV{MAXIM_PATH}/Tools/OpenOCD/scripts")
+ else()
+ # compiled from source
+ if (NOT DEFINED OPENOCD_ADI_PATH)
+ set(OPENOCD_ADI_PATH $ENV{HOME}/app/openocd_adi)
+ endif ()
+ set(OPENOCD ${OPENOCD_ADI_PATH}/src/openocd)
+ set(OPENOCD_OPTION2 "-s ${OPENOCD_ADI_PATH}/tcl")
+ endif ()
+
+ family_flash_openocd(${TARGET})
+endfunction()
+
# Add flash with https://github.com/ch32-rs/wlink
function(family_flash_wlink_rs TARGET)
if (NOT DEFINED WLINK_RS)
@@ -573,6 +592,21 @@ function(family_flash_msp430flasher TARGET)
)
endfunction()
+
+function(family_flash_uniflash TARGET)
+ if (NOT DEFINED DSLITE)
+ set(DSLITE dslite.sh)
+ endif ()
+
+ separate_arguments(OPTION_LIST UNIX_COMMAND ${UNIFLASH_OPTION})
+
+ add_custom_target(${TARGET}-uniflash
+ DEPENDS ${TARGET}
+ COMMAND ${DSLITE} ${UNIFLASH_OPTION} -f $/${TARGET}.hex
+ VERBATIM
+ )
+endfunction()
+
#----------------------------------
# Family specific
#----------------------------------
diff --git a/hw/bsp/max32650/FreeRTOSConfig/FreeRTOSConfig.h b/hw/bsp/max32650/FreeRTOSConfig/FreeRTOSConfig.h
new file mode 100644
index 000000000..e5a76af85
--- /dev/null
+++ b/hw/bsp/max32650/FreeRTOSConfig/FreeRTOSConfig.h
@@ -0,0 +1,149 @@
+/*
+ * FreeRTOS Kernel V10.0.0
+ * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. 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. If you wish to use our Amazon
+ * FreeRTOS name, please do so in a fair use way that does not cause confusion.
+ *
+ * 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 THE AUTHORS OR
+ * COPYRIGHT HOLDERS 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.
+ *
+ * http://www.FreeRTOS.org
+ * http://aws.amazon.com/freertos
+ *
+ * 1 tab == 4 spaces!
+ */
+
+
+#ifndef FREERTOS_CONFIG_H
+#define FREERTOS_CONFIG_H
+
+/*-----------------------------------------------------------
+ * Application specific definitions.
+ *
+ * These definitions should be adjusted for your particular hardware and
+ * application requirements.
+ *
+ * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
+ * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
+ *
+ * See http://www.freertos.org/a00110.html.
+ *----------------------------------------------------------*/
+
+// skip if included from IAR assembler
+#ifndef __IASMARM__
+ #include "mxc_device.h"
+#endif
+
+/* Cortex M23/M33 port configuration. */
+#define configENABLE_MPU 0
+#define configENABLE_FPU 1
+#define configENABLE_TRUSTZONE 0
+#define configMINIMAL_SECURE_STACK_SIZE (1024)
+
+#define configUSE_PREEMPTION 1
+#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
+#define configCPU_CLOCK_HZ SystemCoreClock
+#define configTICK_RATE_HZ ( 1000 )
+#define configMAX_PRIORITIES ( 5 )
+#define configMINIMAL_STACK_SIZE ( 128 )
+#define configTOTAL_HEAP_SIZE ( configSUPPORT_DYNAMIC_ALLOCATION*4*1024 )
+#define configMAX_TASK_NAME_LEN 16
+#define configUSE_16_BIT_TICKS 0
+#define configIDLE_SHOULD_YIELD 1
+#define configUSE_MUTEXES 1
+#define configUSE_RECURSIVE_MUTEXES 1
+#define configUSE_COUNTING_SEMAPHORES 1
+#define configQUEUE_REGISTRY_SIZE 4
+#define configUSE_QUEUE_SETS 0
+#define configUSE_TIME_SLICING 0
+#define configUSE_NEWLIB_REENTRANT 0
+#define configENABLE_BACKWARD_COMPATIBILITY 1
+#define configSTACK_ALLOCATION_FROM_SEPARATE_HEAP 0
+
+#define configSUPPORT_STATIC_ALLOCATION 1
+#define configSUPPORT_DYNAMIC_ALLOCATION 0
+
+/* Hook function related definitions. */
+#define configUSE_IDLE_HOOK 0
+#define configUSE_TICK_HOOK 0
+#define configUSE_MALLOC_FAILED_HOOK 0 // cause nested extern warning
+#define configCHECK_FOR_STACK_OVERFLOW 2
+#define configCHECK_HANDLER_INSTALLATION 0
+
+/* Run time and task stats gathering related definitions. */
+#define configGENERATE_RUN_TIME_STATS 0
+#define configRECORD_STACK_HIGH_ADDRESS 1
+#define configUSE_TRACE_FACILITY 1 // legacy trace
+#define configUSE_STATS_FORMATTING_FUNCTIONS 0
+
+/* Co-routine definitions. */
+#define configUSE_CO_ROUTINES 0
+#define configMAX_CO_ROUTINE_PRIORITIES 2
+
+/* Software timer related definitions. */
+#define configUSE_TIMERS 1
+#define configTIMER_TASK_PRIORITY (configMAX_PRIORITIES-2)
+#define configTIMER_QUEUE_LENGTH 32
+#define configTIMER_TASK_STACK_DEPTH configMINIMAL_STACK_SIZE
+
+/* Optional functions - most linkers will remove unused functions anyway. */
+#define INCLUDE_vTaskPrioritySet 0
+#define INCLUDE_uxTaskPriorityGet 0
+#define INCLUDE_vTaskDelete 0
+#define INCLUDE_vTaskSuspend 1 // required for queue, semaphore, mutex to be blocked indefinitely with portMAX_DELAY
+#define INCLUDE_xResumeFromISR 0
+#define INCLUDE_vTaskDelayUntil 1
+#define INCLUDE_vTaskDelay 1
+#define INCLUDE_xTaskGetSchedulerState 0
+#define INCLUDE_xTaskGetCurrentTaskHandle 1
+#define INCLUDE_uxTaskGetStackHighWaterMark 0
+#define INCLUDE_xTaskGetIdleTaskHandle 0
+#define INCLUDE_xTimerGetTimerDaemonTaskHandle 0
+#define INCLUDE_pcTaskGetTaskName 0
+#define INCLUDE_eTaskGetState 0
+#define INCLUDE_xEventGroupSetBitFromISR 0
+#define INCLUDE_xTimerPendFunctionCall 0
+
+/* FreeRTOS hooks to NVIC vectors */
+#define xPortPendSVHandler PendSV_Handler
+#define xPortSysTickHandler SysTick_Handler
+#define vPortSVCHandler SVC_Handler
+
+//--------------------------------------------------------------------+
+// Interrupt nesting behavior configuration.
+//--------------------------------------------------------------------+
+
+// For Cortex-M specific: __NVIC_PRIO_BITS is defined in mcu header
+#define configPRIO_BITS __NVIC_PRIO_BITS
+
+/* The lowest interrupt priority that can be used in a call to a "set priority" function. */
+#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY ((1<-jlink` target for CMake.
+
+Both the Evaluation Kit and Feather boards are shipped with a CMSIS-DAP
+compatible debug probe. However, at the time of writing, the necessary flashing
+algorithms for OpenOCD have not yet been incorporated into the OpenOCD master
+branch. To utilize the provided debug probes, please install the bundled MSDK
+package which includes the appropriate OpenOCD modifications. To leverage this
+OpenOCD instance, run the `flash-msdk` Makefile rule, or `-msdk` CMake
+target.
+
+### MAX32651
+
+The MAX32651 features an integrated secure bootloader which requires the
+application image be signed prior to flashing. Both the Makefile and CMake
+scripts account for this signing automatically when building for the
+MAX32651EVKIT.
+
+To flash the signed image, the MSDK's OpenOCD variant must be used. To flash
+the MAX32651EVKIT please install the bundled MSDK, and utilize the `flash-msdk`
+and `-msdk` rule and target.
diff --git a/hw/bsp/max32650/boards/max32650evkit/board.cmake b/hw/bsp/max32650/boards/max32650evkit/board.cmake
new file mode 100644
index 000000000..fffdcc9fb
--- /dev/null
+++ b/hw/bsp/max32650/boards/max32650evkit/board.cmake
@@ -0,0 +1,10 @@
+# Use the standard, non-secure linker file
+set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/max32650.ld)
+
+function(update_board_extras TARGET)
+ #No extra arguments
+endfunction()
+
+function(prepare_image TARGET_IN)
+ #No signing required
+endfunction()
diff --git a/hw/bsp/max32650/boards/max32650evkit/board.h b/hw/bsp/max32650/boards/max32650evkit/board.h
new file mode 100644
index 000000000..196abdaca
--- /dev/null
+++ b/hw/bsp/max32650/boards/max32650evkit/board.h
@@ -0,0 +1,56 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2024, Brent Kowal (Analog Devices, Inc)
+ *
+ * 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 THE
+ * AUTHORS OR COPYRIGHT HOLDERS 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.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#include "gpio.h"
+#include "mxc_sys.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// LED
+#define LED_PORT MXC_GPIO2
+#define LED_PIN MXC_GPIO_PIN_25
+#define LED_VDDIO MXC_GPIO_VSSEL_VDDIOH
+#define LED_STATE_ON 0
+
+// Button
+#define BUTTON_PORT MXC_GPIO2
+#define BUTTON_PIN MXC_GPIO_PIN_28
+#define BUTTON_PULL MXC_GPIO_PAD_WEAK_PULL_UP
+#define BUTTON_STATE_ACTIVE 0
+
+// UART Enable for EvKit's Integrated FTDI Adapter. Pin Mux handled by the HAL
+#define UART_NUM 0
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/hw/bsp/max32650/boards/max32650evkit/board.mk b/hw/bsp/max32650/boards/max32650evkit/board.mk
new file mode 100644
index 000000000..0bc210e11
--- /dev/null
+++ b/hw/bsp/max32650/boards/max32650evkit/board.mk
@@ -0,0 +1,2 @@
+# Use the standard, non-secure linker file
+LD_FILE = $(BOARD_PATH)/max32650.ld
diff --git a/hw/bsp/max32650/boards/max32650evkit/max32650.ld b/hw/bsp/max32650/boards/max32650evkit/max32650.ld
new file mode 100644
index 000000000..0e56a91ec
--- /dev/null
+++ b/hw/bsp/max32650/boards/max32650evkit/max32650.ld
@@ -0,0 +1,119 @@
+MEMORY {
+ ROM (rx) : ORIGIN = 0x00000000, LENGTH = 0x00010000 /* 64kB ROM */
+ FLASH (rx) : ORIGIN = 0x10000000, LENGTH = 0x00300000 /* 3MB flash */
+ SRAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00100000 /* 1MB SRAM */
+}
+
+SECTIONS {
+ .text :
+ {
+ _text = .;
+ KEEP(*(.isr_vector))
+ *(.text*) /* program code */
+ *(.rodata*) /* read-only data: "const" */
+
+ KEEP(*(.init))
+ KEEP(*(.fini))
+
+ /* .ctors */
+ *crtbegin.o(.ctors)
+ *crtbegin?.o(.ctors)
+ *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
+ *(SORT(.ctors.*))
+ *(.ctors)
+
+ /* .dtors */
+ *crtbegin.o(.dtors)
+ *crtbegin?.o(.dtors)
+ *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
+ *(SORT(.dtors.*))
+ *(.dtors)
+
+ /* C++ Exception handling */
+ KEEP(*(.eh_frame*))
+ _etext = .;
+ } > FLASH
+
+ .ARM.extab :
+ {
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ } > FLASH
+
+ /* it's used for C++ exception handling */
+ /* we need to keep this to avoid overlapping */
+ .ARM.exidx :
+ {
+ __exidx_start = .;
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ __exidx_end = .;
+ } > FLASH
+
+ .data :
+ {
+ _data = ALIGN(., 4);
+ *(vtable)
+ *(.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);
+ .bss :
+ {
+ . = ALIGN(4);
+ _bss = .;
+ *(.bss*) /*read-write zero initialized data: uninitialized global variable*/
+ *(COMMON)
+ _ebss = ALIGN(., 4);
+ } > SRAM
+
+ /* Set stack top to end of RAM, and stack limit move down by
+ * size of stack_dummy section */
+ __StackTop = ORIGIN(SRAM) + LENGTH(SRAM);
+ __StackLimit = __StackTop - SIZEOF(.stack_dummy);
+
+ /* .stack_dummy section doesn't contains any symbols. It is only
+ * used for linker to calculate size of stack sections, and assign
+ * values to stack symbols later */
+ .stack_dummy (COPY):
+ {
+ *(.stack*)
+ } > SRAM
+
+ .heap (COPY):
+ {
+ . = ALIGN(4);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ *(.heap*)
+ __HeapLimit = ABSOLUTE(__StackLimit);
+ } > SRAM
+
+ PROVIDE(__stack = __StackTop);
+
+ /* Check if data + heap + stack exceeds RAM limit */
+ ASSERT(__StackLimit >= _ebss, "region RAM overflowed with stack")
+}
diff --git a/hw/bsp/max32650/boards/max32650fthr/board.cmake b/hw/bsp/max32650/boards/max32650fthr/board.cmake
new file mode 100644
index 000000000..fffdcc9fb
--- /dev/null
+++ b/hw/bsp/max32650/boards/max32650fthr/board.cmake
@@ -0,0 +1,10 @@
+# Use the standard, non-secure linker file
+set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/max32650.ld)
+
+function(update_board_extras TARGET)
+ #No extra arguments
+endfunction()
+
+function(prepare_image TARGET_IN)
+ #No signing required
+endfunction()
diff --git a/src/portable/mentor/musb/musb_tm4c.h b/hw/bsp/max32650/boards/max32650fthr/board.h
similarity index 67%
rename from src/portable/mentor/musb/musb_tm4c.h
rename to hw/bsp/max32650/boards/max32650fthr/board.h
index 65a1751b0..d80a8fcae 100644
--- a/src/portable/mentor/musb/musb_tm4c.h
+++ b/hw/bsp/max32650/boards/max32650fthr/board.h
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2021, Ha Thach (tinyusb.org)
+ * Copyright (c) 2024, Brent Kowal (Analog Devices, Inc)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -24,22 +24,34 @@
* This file is part of the TinyUSB stack.
*/
-#ifndef _TUSB_MUSB_TM4C_H_
-#define _TUSB_MUSB_TM4C_H_
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#include "gpio.h"
+#include "mxc_sys.h"
#ifdef __cplusplus
- extern "C" {
+extern "C" {
#endif
-#if CFG_TUSB_MCU == OPT_MCU_TM4C123
- #include "TM4C123.h"
-//#elif CFG_TUSB_MCU == OPT_MCU_TM4C129
-#else
- #error "Unsupported MCUs"
-#endif
+// LED
+#define LED_PORT MXC_GPIO1
+#define LED_PIN MXC_GPIO_PIN_14
+#define LED_VDDIO MXC_GPIO_VSSEL_VDDIO
+#define LED_STATE_ON 0
+
+// Button
+#define BUTTON_PORT MXC_GPIO1
+#define BUTTON_PIN MXC_GPIO_PIN_19
+#define BUTTON_PULL MXC_GPIO_PAD_WEAK_PULL_UP
+#define BUTTON_STATE_ACTIVE 0
+
+// UART Enable for SWD UART Pins. Pin Mux handled by the HAL
+#define UART_NUM 0
+
#ifdef __cplusplus
- }
+}
#endif
-#endif
+#endif /* BOARD_H_ */
diff --git a/hw/bsp/max32650/boards/max32650fthr/board.mk b/hw/bsp/max32650/boards/max32650fthr/board.mk
new file mode 100644
index 000000000..0bc210e11
--- /dev/null
+++ b/hw/bsp/max32650/boards/max32650fthr/board.mk
@@ -0,0 +1,2 @@
+# Use the standard, non-secure linker file
+LD_FILE = $(BOARD_PATH)/max32650.ld
diff --git a/hw/bsp/max32650/boards/max32650fthr/max32650.ld b/hw/bsp/max32650/boards/max32650fthr/max32650.ld
new file mode 100644
index 000000000..0e56a91ec
--- /dev/null
+++ b/hw/bsp/max32650/boards/max32650fthr/max32650.ld
@@ -0,0 +1,119 @@
+MEMORY {
+ ROM (rx) : ORIGIN = 0x00000000, LENGTH = 0x00010000 /* 64kB ROM */
+ FLASH (rx) : ORIGIN = 0x10000000, LENGTH = 0x00300000 /* 3MB flash */
+ SRAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00100000 /* 1MB SRAM */
+}
+
+SECTIONS {
+ .text :
+ {
+ _text = .;
+ KEEP(*(.isr_vector))
+ *(.text*) /* program code */
+ *(.rodata*) /* read-only data: "const" */
+
+ KEEP(*(.init))
+ KEEP(*(.fini))
+
+ /* .ctors */
+ *crtbegin.o(.ctors)
+ *crtbegin?.o(.ctors)
+ *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
+ *(SORT(.ctors.*))
+ *(.ctors)
+
+ /* .dtors */
+ *crtbegin.o(.dtors)
+ *crtbegin?.o(.dtors)
+ *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
+ *(SORT(.dtors.*))
+ *(.dtors)
+
+ /* C++ Exception handling */
+ KEEP(*(.eh_frame*))
+ _etext = .;
+ } > FLASH
+
+ .ARM.extab :
+ {
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ } > FLASH
+
+ /* it's used for C++ exception handling */
+ /* we need to keep this to avoid overlapping */
+ .ARM.exidx :
+ {
+ __exidx_start = .;
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ __exidx_end = .;
+ } > FLASH
+
+ .data :
+ {
+ _data = ALIGN(., 4);
+ *(vtable)
+ *(.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);
+ .bss :
+ {
+ . = ALIGN(4);
+ _bss = .;
+ *(.bss*) /*read-write zero initialized data: uninitialized global variable*/
+ *(COMMON)
+ _ebss = ALIGN(., 4);
+ } > SRAM
+
+ /* Set stack top to end of RAM, and stack limit move down by
+ * size of stack_dummy section */
+ __StackTop = ORIGIN(SRAM) + LENGTH(SRAM);
+ __StackLimit = __StackTop - SIZEOF(.stack_dummy);
+
+ /* .stack_dummy section doesn't contains any symbols. It is only
+ * used for linker to calculate size of stack sections, and assign
+ * values to stack symbols later */
+ .stack_dummy (COPY):
+ {
+ *(.stack*)
+ } > SRAM
+
+ .heap (COPY):
+ {
+ . = ALIGN(4);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ *(.heap*)
+ __HeapLimit = ABSOLUTE(__StackLimit);
+ } > SRAM
+
+ PROVIDE(__stack = __StackTop);
+
+ /* Check if data + heap + stack exceeds RAM limit */
+ ASSERT(__StackLimit >= _ebss, "region RAM overflowed with stack")
+}
diff --git a/hw/bsp/max32650/boards/max32651evkit/board.cmake b/hw/bsp/max32650/boards/max32651evkit/board.cmake
new file mode 100644
index 000000000..bd8077a42
--- /dev/null
+++ b/hw/bsp/max32650/boards/max32651evkit/board.cmake
@@ -0,0 +1,30 @@
+# Use the secure linker file
+set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/max32651.ld)
+
+function(update_board_extras TARGET)
+ # for the signed target, need to add the __SLA_FWK__ define
+ target_compile_definitions(${TARGET} PUBLIC
+ __SLA_FWK__
+ )
+endfunction()
+
+function(prepare_image TARGET_IN)
+ #For the signed target, set up a POST_BUILD command to sign the elf file once
+ #created
+ if((WIN32) OR (MINGW) OR (MSYS))
+ set(SIGN_EXE "sign_app.exe")
+ else()
+ set(SIGN_EXE "sign_app")
+ endif()
+ set(MCU_PATH "${TOP}/hw/mcu/analog/max32/")
+
+ # Custom POST_BUILD command
+ add_custom_command(
+ TARGET ${TARGET_IN} POST_BUILD
+ COMMAND ${CMAKE_OBJCOPY} $ -R .sig -O binary $/${TARGET_IN}.bin
+ COMMAND ${MCU_PATH}/Tools/SBT/bin/${SIGN_EXE} -c MAX32651 key_file=${MCU_PATH}/Tools/SBT/devices/MAX32651/keys/maximtestcrk.key
+ ca=$/${TARGET_IN}.bin sca=$/${TARGET_IN}.sbin
+ COMMAND ${CMAKE_OBJCOPY} $ --update-section .sig=$/${TARGET_IN}.sig
+ VERBATIM
+ )
+endfunction()
diff --git a/hw/bsp/max32650/boards/max32651evkit/board.h b/hw/bsp/max32650/boards/max32651evkit/board.h
new file mode 100644
index 000000000..196abdaca
--- /dev/null
+++ b/hw/bsp/max32650/boards/max32651evkit/board.h
@@ -0,0 +1,56 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2024, Brent Kowal (Analog Devices, Inc)
+ *
+ * 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 THE
+ * AUTHORS OR COPYRIGHT HOLDERS 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.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#include "gpio.h"
+#include "mxc_sys.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// LED
+#define LED_PORT MXC_GPIO2
+#define LED_PIN MXC_GPIO_PIN_25
+#define LED_VDDIO MXC_GPIO_VSSEL_VDDIOH
+#define LED_STATE_ON 0
+
+// Button
+#define BUTTON_PORT MXC_GPIO2
+#define BUTTON_PIN MXC_GPIO_PIN_28
+#define BUTTON_PULL MXC_GPIO_PAD_WEAK_PULL_UP
+#define BUTTON_STATE_ACTIVE 0
+
+// UART Enable for EvKit's Integrated FTDI Adapter. Pin Mux handled by the HAL
+#define UART_NUM 0
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/hw/bsp/max32650/boards/max32651evkit/board.mk b/hw/bsp/max32650/boards/max32651evkit/board.mk
new file mode 100644
index 000000000..b609598c1
--- /dev/null
+++ b/hw/bsp/max32650/boards/max32651evkit/board.mk
@@ -0,0 +1,5 @@
+# Use the secure linker file
+LD_FILE = $(BOARD_PATH)/max32651.ld
+
+# Let the family script know the build needs to be signed
+SIGNED_BUILD := 1
diff --git a/hw/bsp/max32650/boards/max32651evkit/max32651.ld b/hw/bsp/max32650/boards/max32651evkit/max32651.ld
new file mode 100644
index 000000000..3921d10f2
--- /dev/null
+++ b/hw/bsp/max32650/boards/max32651evkit/max32651.ld
@@ -0,0 +1,132 @@
+MEMORY {
+ HEADER (rx): ORIGIN = 0x10000000, LENGTH = 0x200
+ FLASH (rx) : ORIGIN = 0x10000200, LENGTH = 0x002FFE00 /* 3MB flash */
+ SRAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00100000 /* 1MB SRAM */
+}
+
+/* Added Oct 9, 2018 to go to correct reset vector. */
+ENTRY(Reset_Handler)
+PROVIDE( _start_SWAP = (((Reset_Handler) >> 24) | (((Reset_Handler) & 0x00FF0000) >> 8) | (((Reset_Handler) & 0x0000FF00) << 8) | ((Reset_Handler) << 24)));
+PROVIDE_HIDDEN( _SLA_Size = _endimage - __end_header );
+PROVIDE( _SLA_Size_SWAP = (((_SLA_Size) >> 24) | (((_SLA_Size) & 0x00FF0000) >> 8) | (((_SLA_Size) & 0x0000FF00) << 8) | ((_SLA_Size) << 24)));
+
+/* Sections Definitions */
+SECTIONS {
+ .sb_sla_header : ALIGN(4)
+ {
+ FILL(0xFF)
+ KEEP(*(.sb_sla_header)) /* Header for ROM code */
+ __end_header = . ;
+ . = ALIGN(512);
+ } > HEADER
+
+ .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
+
+ /* 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);
+ _enddata = LOADADDR(.data)+SIZEOF(.data);
+
+ .sb_sla_trailer : AT(_enddata)
+ {
+ KEEP(*(.sb_sla_trailer))
+ /* Align image with 16 byte boundary to conform to flash encryption block size. */
+ FILL(0xDEADC0DE);
+ /* NOTE: The FILL and ALIGN will not work unless something is written to the section. So, we use LONG. */
+ LONG(0xDEADC0DE);
+ . = ALIGN(16);
+ } > FLASH
+ _endimage = LOADADDR(.sb_sla_trailer)+SIZEOF(.sb_sla_trailer);
+ .sig :
+ {
+ KEEP(*(.sig))
+ LONG(0xDEADBEEF);
+
+ } > FLASH
+ .bss :
+ {
+ . = ALIGN(4);
+ _bss = .;
+ *(.bss*) /*read-write zero initialized data: uninitialized global variable*/
+ *(COMMON)
+ _ebss = ALIGN(., 4);
+ } > SRAM
+
+ /* Set stack top to end of RAM, and stack limit move down by
+ * size of stack_dummy section */
+ __StackTop = ORIGIN(SRAM) + LENGTH(SRAM);
+ __StackLimit = __StackTop - SIZEOF(.stack_dummy);
+
+ /* .stack_dummy section doesn't contains any symbols. It is only
+ * used for linker to calculate size of stack sections, and assign
+ * values to stack symbols later */
+ .stack_dummy (COPY):
+ {
+ *(.stack*)
+ } > SRAM
+
+ .heap (COPY):
+ {
+ . = ALIGN(4);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ *(.heap*)
+ __HeapLimit = ABSOLUTE(__StackLimit);
+ } > SRAM
+
+ PROVIDE(__stack = __StackTop);
+
+ /* Check if data + heap + stack exceeds RAM limit */
+ ASSERT(__StackLimit >= _ebss, "region RAM overflowed with stack")
+}
diff --git a/hw/bsp/max32650/family.c b/hw/bsp/max32650/family.c
new file mode 100644
index 000000000..89a5db160
--- /dev/null
+++ b/hw/bsp/max32650/family.c
@@ -0,0 +1,172 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2024 Brent Kowal (Analog Devices, Inc)
+ *
+ * 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 THE
+ * AUTHORS OR COPYRIGHT HOLDERS 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.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wstrict-prototypes" // _mxc_crit_get_state()
+#endif
+
+#include "gpio.h"
+#include "mxc_sys.h"
+#include "mxc_device.h"
+#include "uart.h"
+
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
+
+#include "board.h"
+#include "bsp/board_api.h"
+
+
+//--------------------------------------------------------------------+
+// Forward USB interrupt events to TinyUSB IRQ Handler
+//--------------------------------------------------------------------+
+void USB_IRQHandler(void) {
+ tud_int_handler(0);
+}
+
+//--------------------------------------------------------------------+
+// MACRO TYPEDEF CONSTANT ENUM
+//--------------------------------------------------------------------+
+mxc_uart_regs_t *ConsoleUart = MXC_UART_GET_UART(UART_NUM);
+
+void board_init(void) {
+#if CFG_TUSB_OS == OPT_OS_NONE
+ // 1ms tick timer
+ SysTick_Config(SystemCoreClock / 1000);
+#elif CFG_TUSB_OS == OPT_OS_FREERTOS
+ // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
+ NVIC_SetPriority(USB_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY);
+#endif
+ mxc_gpio_cfg_t gpioConfig;
+
+ // LED
+ gpioConfig.drvstr = MXC_GPIO_DRVSTR_0;
+ gpioConfig.func = MXC_GPIO_FUNC_OUT;
+ gpioConfig.mask = LED_PIN;
+ gpioConfig.pad = MXC_GPIO_PAD_NONE;
+ gpioConfig.port = LED_PORT;
+ gpioConfig.vssel = LED_VDDIO;
+ MXC_GPIO_Config(&gpioConfig);
+ board_led_write(false);
+
+ // Button
+ gpioConfig.drvstr = MXC_GPIO_DRVSTR_0;
+ gpioConfig.func = MXC_GPIO_FUNC_IN;
+ gpioConfig.mask = BUTTON_PIN;
+ gpioConfig.pad = BUTTON_PULL;
+ gpioConfig.port = BUTTON_PORT;
+ gpioConfig.vssel = MXC_GPIO_VSSEL_VDDIO;
+ MXC_GPIO_Config(&gpioConfig);
+
+ // UART
+ MXC_UART_Init(ConsoleUart, CFG_BOARD_UART_BAUDRATE);
+
+ //USB
+ // Startup the HIRC96M clock if it's not on already
+ if (!(MXC_GCR->clk_ctrl & MXC_F_GCR_CLK_CTRL_HIRC96_EN)) {
+ MXC_GCR->clk_ctrl |= MXC_F_GCR_CLK_CTRL_HIRC96_EN;
+ MXC_SYS_Clock_Timeout(MXC_F_GCR_CLK_CTRL_HIRC96_RDY);
+ }
+
+ MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_USB);
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state) {
+#if LED_STATE_ON
+ state = !state;
+#endif
+ if (state) {
+ MXC_GPIO_OutClr(LED_PORT, LED_PIN);
+ } else {
+ MXC_GPIO_OutSet(LED_PORT, LED_PIN);
+ }
+}
+
+uint32_t board_button_read(void) {
+ uint32_t state = MXC_GPIO_InGet(BUTTON_PORT, BUTTON_PIN) ? 1 : 0;
+ return BUTTON_STATE_ACTIVE == state;
+}
+
+size_t board_get_unique_id(uint8_t id[], size_t max_len) {
+ uint8_t hw_id[13];//USN Buffer
+ MXC_SYS_GetUSN(hw_id, 13);
+
+ size_t act_len = TU_MIN(max_len, 13);
+ memcpy(id, hw_id, act_len);
+ return act_len;
+}
+
+int board_uart_read(uint8_t *buf, int len) {
+ int uart_val;
+ int act_len = 0;
+
+ while (act_len < len) {
+ if ((uart_val = MXC_UART_ReadCharacterRaw(ConsoleUart)) == E_UNDERFLOW) {
+ break;
+ } else {
+ *buf++ = (uint8_t) uart_val;
+ act_len++;
+ }
+ }
+ return act_len;
+}
+
+int board_uart_write(void const *buf, int len) {
+ int act_len = 0;
+ const uint8_t *ch_ptr = (const uint8_t *) buf;
+ while (act_len < len) {
+ MXC_UART_WriteCharacter(ConsoleUart, *ch_ptr++);
+ act_len++;
+ }
+ return len;
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+
+void SysTick_Handler(void) {
+ system_ticks++;
+}
+
+uint32_t board_millis(void) {
+ return system_ticks;
+}
+#endif
+
+void HardFault_Handler(void) {
+ __asm("BKPT #0\n");
+}
+
+// Required by __libc_init_array in startup code if we are compiling using
+// -nostdlib/-nostartfiles.
+void _init(void) {
+}
diff --git a/hw/bsp/max32650/family.cmake b/hw/bsp/max32650/family.cmake
new file mode 100644
index 000000000..e05bd7652
--- /dev/null
+++ b/hw/bsp/max32650/family.cmake
@@ -0,0 +1,169 @@
+include_guard()
+
+set(MAX32_PERIPH ${TOP}/hw/mcu/analog/max32/Libraries/PeriphDrivers)
+set(MAX32_CMSIS ${TOP}/hw/mcu/analog/max32/Libraries/CMSIS)
+set(CMSIS_5 ${TOP}/lib/CMSIS_5)
+
+# include board specific information and functions
+include(${CMAKE_CURRENT_LIST_DIR}/boards/${BOARD}/board.cmake)
+
+# Get the linker file
+set(LD_FILE_Clang ${LD_FILE_GNU})
+
+# toolchain set up
+set(CMAKE_SYSTEM_PROCESSOR cortex-m4 CACHE INTERNAL "System Processor")
+set(CMAKE_TOOLCHAIN_FILE ${TOP}/examples/build_system/cmake/toolchain/arm_${TOOLCHAIN}.cmake)
+set(JLINK_DEVICE max32650)
+set(OPENOCD_OPTION "-f interface/cmsis-dap.cfg -f target/max32650.cfg")
+
+set(FAMILY_MCUS MAX32650 CACHE INTERNAL "")
+
+function(update_board TARGET)
+ target_compile_definitions(${TARGET} PUBLIC
+ TARGET=MAX32650
+ TARGET_REV=0x4131
+ MXC_ASSERT_ENABLE
+ MAX32650
+ IAR_PRAGMAS=0
+ CFG_TUSB_MCU=OPT_MCU_MAX32650
+ BOARD_TUD_MAX_SPEED=OPT_MODE_HIGH_SPEED
+ )
+
+ # Run any board specific updates
+ update_board_extras(${TARGET})
+endfunction()
+
+#------------------------------------
+# BOARD_TARGET
+#------------------------------------
+# only need to be built ONCE for all examples
+function(add_board_target BOARD_TARGET)
+ if (TARGET ${BOARD_TARGET})
+ return()
+ endif ()
+
+ # Startup & Linker script
+ set(STARTUP_FILE_GNU ${MAX32_CMSIS}/Device/Maxim/MAX32650/Source/GCC/startup_max32650.S)
+ set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+
+ set(PERIPH_SRC ${MAX32_PERIPH}/Source)
+ add_library(${BOARD_TARGET} STATIC
+ ${MAX32_CMSIS}/Device/Maxim/MAX32650/Source/heap.c
+ ${MAX32_CMSIS}/Device/Maxim/MAX32650/Source/header_MAX32650.c
+ ${MAX32_CMSIS}/Device/Maxim/MAX32650/Source/system_max32650.c
+ ${PERIPH_SRC}/SYS/mxc_assert.c
+ ${PERIPH_SRC}/SYS/mxc_delay.c
+ ${PERIPH_SRC}/SYS/mxc_lock.c
+ ${PERIPH_SRC}/SYS/nvic_table.c
+ ${PERIPH_SRC}/SYS/pins_me10.c
+ ${PERIPH_SRC}/SYS/sys_me10.c
+ ${PERIPH_SRC}/TPU/tpu_me10.c
+ ${PERIPH_SRC}/TPU/tpu_reva.c
+ ${PERIPH_SRC}/FLC/flc_common.c
+ ${PERIPH_SRC}/FLC/flc_me10.c
+ ${PERIPH_SRC}/FLC/flc_reva.c
+ ${PERIPH_SRC}/GPIO/gpio_common.c
+ ${PERIPH_SRC}/GPIO/gpio_me10.c
+ ${PERIPH_SRC}/GPIO/gpio_reva.c
+ ${PERIPH_SRC}/ICC/icc_me10.c
+ ${PERIPH_SRC}/ICC/icc_reva.c
+ ${PERIPH_SRC}/ICC/icc_common.c
+ ${PERIPH_SRC}/UART/uart_common.c
+ ${PERIPH_SRC}/UART/uart_me10.c
+ ${PERIPH_SRC}/UART/uart_reva.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
+ )
+ target_include_directories(${BOARD_TARGET} PUBLIC
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}
+ ${MAX32_CMSIS}/Include
+ ${MAX32_CMSIS}/Device/Maxim/MAX32650/Include
+ ${MAX32_PERIPH}/Include/MAX32650
+ ${PERIPH_SRC}/SYS
+ ${PERIPH_SRC}/GPIO
+ ${PERIPH_SRC}/TPU
+ ${PERIPH_SRC}/ICC
+ ${PERIPH_SRC}/FLC
+ ${PERIPH_SRC}/UART
+ )
+
+ target_compile_options(${BOARD_TARGET} PRIVATE
+ -Wno-error=strict-prototypes
+ )
+ update_board(${BOARD_TARGET})
+
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${BOARD_TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ -nostartfiles
+ --specs=nosys.specs --specs=nano.specs
+ -u sb_header #Needed when linking libraries to not lose the Signing header
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${BOARD_TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_Clang}"
+ )
+ endif ()
+endfunction()
+
+
+#------------------------------------
+# Functions
+#------------------------------------
+function(family_configure_example TARGET RTOS)
+ family_configure_common(${TARGET} ${RTOS})
+
+ # Board target
+ add_board_target(board_${BOARD})
+
+ #---------- Port Specific ----------
+ # These files are built for each example since it depends on example's tusb_config.h
+ target_sources(${TARGET} PUBLIC
+ # BSP
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ )
+ target_include_directories(${TARGET} PUBLIC
+ # family, hw, board
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
+ )
+
+ # Add TinyUSB target and port source
+ family_add_tinyusb(${TARGET} OPT_MCU_MAX32650 ${RTOS})
+ target_sources(${TARGET}-tinyusb PUBLIC
+ ${TOP}/src/portable/mentor/musb/dcd_musb.c
+ )
+ target_compile_options(${TARGET} PRIVATE
+ -Wno-error=strict-prototypes
+ )
+
+ target_link_libraries(${TARGET}-tinyusb PUBLIC board_${BOARD})
+ target_compile_options(${TARGET}-tinyusb PRIVATE
+ -Wno-error=strict-prototypes
+ )
+
+ # Link dependencies
+ target_link_libraries(${TARGET} PUBLIC board_${BOARD} ${TARGET}-tinyusb)
+
+ # Flashing
+ family_flash_jlink(${TARGET})
+
+ # Add the optional MSDK OpenOCD flashing
+ family_flash_msdk(${TARGET})
+ family_flash_openocd_adi(${TARGET})
+endfunction()
+
+function(family_flash_msdk TARGET)
+ # Prepare the image (signed) if the board requires it
+ prepare_image(${TARGET})
+
+ set(MAXIM_PATH "$ENV{MAXIM_PATH}")
+ add_custom_target(${TARGET}-msdk
+ DEPENDS ${TARGET}
+ COMMAND ${MAXIM_PATH}/Tools/OpenOCD/openocd -s ${MAXIM_PATH}/Tools/OpenOCD/scripts
+ -f interface/cmsis-dap.cfg -f target/max32650.cfg
+ -c "program $ verify; init; reset; exit"
+ VERBATIM
+ )
+endfunction()
diff --git a/hw/bsp/max32650/family.mk b/hw/bsp/max32650/family.mk
new file mode 100644
index 000000000..d2fc293e4
--- /dev/null
+++ b/hw/bsp/max32650/family.mk
@@ -0,0 +1,140 @@
+DEPS_SUBMODULES += lib/CMSIS_5 hw/mcu/analog/max32
+
+# Important locations in the hw support for MCU
+MAX32_CMSIS = hw/mcu/analog/max32/Libraries/CMSIS
+MAX32_PERIPH = hw/mcu/analog/max32/Libraries/PeriphDrivers
+
+# Add any board specific make rules
+include $(TOP)/$(BOARD_PATH)/board.mk
+
+CPU_CORE ?= cortex-m4
+PORT ?= 0
+
+# GCC
+SRC_S_GCC += $(MAX32_CMSIS)/Device/Maxim/MAX32650/Source/GCC/startup_max32650.S
+
+# --------------
+# Compiler Flags
+# --------------
+# Flags for the MAX32650/1/2 SDK
+CFLAGS += -DTARGET=MAX32650 \
+ -DTARGET_REV=0x4131 \
+ -DMXC_ASSERT_ENABLE \
+ -DMAX32650 \
+ -DIAR_PRAGMAS=0
+
+# Flags for TUSB features
+CFLAGS += \
+ -DCFG_TUSB_MCU=OPT_MCU_MAX32650 \
+ -DBOARD_TUD_MAX_SPEED=OPT_MODE_HIGH_SPEED
+
+# mcu driver cause following warnings
+CFLAGS += -Wno-error=strict-prototypes \
+ -Wno-error=unused-parameter \
+ -Wno-error=cast-align \
+ -Wno-error=cast-qual \
+ -Wno-error=sign-compare
+
+LDFLAGS_GCC += -nostartfiles --specs=nosys.specs --specs=nano.specs
+
+# Configure the flash rule. By default, use JLink.
+SIGNED_BUILD ?= 0
+DEFAULT_FLASH = flash-jlink
+
+# If the applications needs to be signed (for the MAX32651), sign it first and
+# then need to use MSDK's OpenOCD to flash it
+# Also need to include the __SLA_FWK__ define to enable the signed header into
+# memory
+ifeq ($(SIGNED_BUILD), 1)
+# Extra definitions to build for the secure part
+CFLAGS += -D__SLA_FWK__
+DEFAULT_FLASH := sign-build flash-msdk
+endif
+
+# For flash-jlink target
+JLINK_DEVICE = max32650
+
+# Configure the flash rule
+flash: $(DEFAULT_FLASH)
+
+# -----------------
+# Sources & Include
+# -----------------
+PERIPH_SRC = $(TOP)/$(MAX32_PERIPH)/Source
+SRC_C += \
+ src/portable/mentor/musb/dcd_musb.c \
+ $(MAX32_CMSIS)/Device/Maxim/MAX32650/Source/heap.c \
+ $(MAX32_CMSIS)/Device/Maxim/MAX32650/Source/system_max32650.c \
+ $(MAX32_CMSIS)/Device/Maxim/MAX32650/Source/header_MAX32650.c \
+ $(PERIPH_SRC)/SYS/mxc_assert.c \
+ $(PERIPH_SRC)/SYS/mxc_delay.c \
+ $(PERIPH_SRC)/SYS/mxc_lock.c \
+ $(PERIPH_SRC)/SYS/nvic_table.c \
+ $(PERIPH_SRC)/SYS/pins_me10.c \
+ $(PERIPH_SRC)/SYS/sys_me10.c \
+ $(PERIPH_SRC)/FLC/flc_common.c \
+ $(PERIPH_SRC)/FLC/flc_me10.c \
+ $(PERIPH_SRC)/FLC/flc_reva.c \
+ $(PERIPH_SRC)/GPIO/gpio_common.c \
+ $(PERIPH_SRC)/GPIO/gpio_me10.c \
+ $(PERIPH_SRC)/GPIO/gpio_reva.c \
+ $(PERIPH_SRC)/ICC/icc_me10.c \
+ $(PERIPH_SRC)/ICC/icc_reva.c \
+ $(PERIPH_SRC)/ICC/icc_common.c \
+ $(PERIPH_SRC)/TPU/tpu_me10.c \
+ $(PERIPH_SRC)/TPU/tpu_reva.c \
+ $(PERIPH_SRC)/UART/uart_common.c \
+ $(PERIPH_SRC)/UART/uart_me10.c \
+ $(PERIPH_SRC)/UART/uart_reva.c \
+
+INC += \
+ $(TOP)/$(BOARD_PATH) \
+ $(TOP)/$(MAX32_CMSIS)/Include \
+ $(TOP)/$(MAX32_CMSIS)/Device/Maxim/MAX32650/Include \
+ $(TOP)/$(MAX32_PERIPH)/Include/MAX32650 \
+ $(PERIPH_SRC)/SYS \
+ $(PERIPH_SRC)/GPIO \
+ $(PERIPH_SRC)/ICC \
+ $(PERIPH_SRC)/FLC \
+ $(PERIPH_SRC)/TPU \
+ $(PERIPH_SRC)/UART
+
+
+# The MAX32651EVKIT is pin for pin identical to the MAX32650EVKIT, however the
+# MAX32651 has a secure bootloader which requires the image to be signed before
+# loading into flash. All MAX32651EVKIT's have the same key for evaluation
+# purposes, so create a special flash rule to sign the binary and flash using
+# the MSDK.
+MCU_PATH = $(TOP)/hw/mcu/analog/max32/
+# Assume no extension for sign utility
+SIGN_EXE = sign_app
+ifeq ($(OS), Windows_NT)
+# Must use .exe extension on Windows, since the binaries
+# for Linux may live in the same place.
+SIGN_EXE := sign_app.exe
+else
+UNAME = $(shell uname -s)
+ifneq ($(findstring MSYS_NT,$(UNAME)),)
+# Must also use .exe extension for MSYS2
+SIGN_EXE := sign_app.exe
+endif
+endif
+
+# Rule to sign the build. This will in-place modify the existing .elf file
+# an populate the .sig section with the signature value
+sign-build: $(BUILD)/$(PROJECT).elf
+ $(OBJCOPY) $(BUILD)/$(PROJECT).elf -R .sig -O binary $(BUILD)/$(PROJECT).bin
+ $(MCU_PATH)/Tools/SBT/bin/$(SIGN_EXE) -c MAX32651 \
+ key_file="$(MCU_PATH)/Tools/SBT/devices/MAX32651/keys/maximtestcrk.key" \
+ ca=$(BUILD)/$(PROJECT).bin sca=$(BUILD)/$(PROJECT).sbin
+ $(OBJCOPY) $(BUILD)/$(PROJECT).elf --update-section .sig=$(BUILD)/$(PROJECT).sig
+
+# Optional flash option when running within an installed MSDK to use OpenOCD
+# Mainline OpenOCD does not yet have the MAX32's flash algorithm integrated.
+# If the MSDK is installed, flash-msdk can be run to utilize the the modified
+# openocd with the algorithms
+MAXIM_PATH := $(subst \,/,$(MAXIM_PATH))
+flash-msdk: $(BUILD)/$(PROJECT).elf
+ $(MAXIM_PATH)/Tools/OpenOCD/openocd -s $(MAXIM_PATH)/Tools/OpenOCD/scripts \
+ -f interface/cmsis-dap.cfg -f target/max32650.cfg \
+ -c "program $(BUILD)/$(PROJECT).elf verify; init; reset; exit"
diff --git a/hw/bsp/max32666/FreeRTOSConfig/FreeRTOSConfig.h b/hw/bsp/max32666/FreeRTOSConfig/FreeRTOSConfig.h
new file mode 100644
index 000000000..e5a76af85
--- /dev/null
+++ b/hw/bsp/max32666/FreeRTOSConfig/FreeRTOSConfig.h
@@ -0,0 +1,149 @@
+/*
+ * FreeRTOS Kernel V10.0.0
+ * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. 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. If you wish to use our Amazon
+ * FreeRTOS name, please do so in a fair use way that does not cause confusion.
+ *
+ * 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 THE AUTHORS OR
+ * COPYRIGHT HOLDERS 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.
+ *
+ * http://www.FreeRTOS.org
+ * http://aws.amazon.com/freertos
+ *
+ * 1 tab == 4 spaces!
+ */
+
+
+#ifndef FREERTOS_CONFIG_H
+#define FREERTOS_CONFIG_H
+
+/*-----------------------------------------------------------
+ * Application specific definitions.
+ *
+ * These definitions should be adjusted for your particular hardware and
+ * application requirements.
+ *
+ * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
+ * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
+ *
+ * See http://www.freertos.org/a00110.html.
+ *----------------------------------------------------------*/
+
+// skip if included from IAR assembler
+#ifndef __IASMARM__
+ #include "mxc_device.h"
+#endif
+
+/* Cortex M23/M33 port configuration. */
+#define configENABLE_MPU 0
+#define configENABLE_FPU 1
+#define configENABLE_TRUSTZONE 0
+#define configMINIMAL_SECURE_STACK_SIZE (1024)
+
+#define configUSE_PREEMPTION 1
+#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
+#define configCPU_CLOCK_HZ SystemCoreClock
+#define configTICK_RATE_HZ ( 1000 )
+#define configMAX_PRIORITIES ( 5 )
+#define configMINIMAL_STACK_SIZE ( 128 )
+#define configTOTAL_HEAP_SIZE ( configSUPPORT_DYNAMIC_ALLOCATION*4*1024 )
+#define configMAX_TASK_NAME_LEN 16
+#define configUSE_16_BIT_TICKS 0
+#define configIDLE_SHOULD_YIELD 1
+#define configUSE_MUTEXES 1
+#define configUSE_RECURSIVE_MUTEXES 1
+#define configUSE_COUNTING_SEMAPHORES 1
+#define configQUEUE_REGISTRY_SIZE 4
+#define configUSE_QUEUE_SETS 0
+#define configUSE_TIME_SLICING 0
+#define configUSE_NEWLIB_REENTRANT 0
+#define configENABLE_BACKWARD_COMPATIBILITY 1
+#define configSTACK_ALLOCATION_FROM_SEPARATE_HEAP 0
+
+#define configSUPPORT_STATIC_ALLOCATION 1
+#define configSUPPORT_DYNAMIC_ALLOCATION 0
+
+/* Hook function related definitions. */
+#define configUSE_IDLE_HOOK 0
+#define configUSE_TICK_HOOK 0
+#define configUSE_MALLOC_FAILED_HOOK 0 // cause nested extern warning
+#define configCHECK_FOR_STACK_OVERFLOW 2
+#define configCHECK_HANDLER_INSTALLATION 0
+
+/* Run time and task stats gathering related definitions. */
+#define configGENERATE_RUN_TIME_STATS 0
+#define configRECORD_STACK_HIGH_ADDRESS 1
+#define configUSE_TRACE_FACILITY 1 // legacy trace
+#define configUSE_STATS_FORMATTING_FUNCTIONS 0
+
+/* Co-routine definitions. */
+#define configUSE_CO_ROUTINES 0
+#define configMAX_CO_ROUTINE_PRIORITIES 2
+
+/* Software timer related definitions. */
+#define configUSE_TIMERS 1
+#define configTIMER_TASK_PRIORITY (configMAX_PRIORITIES-2)
+#define configTIMER_QUEUE_LENGTH 32
+#define configTIMER_TASK_STACK_DEPTH configMINIMAL_STACK_SIZE
+
+/* Optional functions - most linkers will remove unused functions anyway. */
+#define INCLUDE_vTaskPrioritySet 0
+#define INCLUDE_uxTaskPriorityGet 0
+#define INCLUDE_vTaskDelete 0
+#define INCLUDE_vTaskSuspend 1 // required for queue, semaphore, mutex to be blocked indefinitely with portMAX_DELAY
+#define INCLUDE_xResumeFromISR 0
+#define INCLUDE_vTaskDelayUntil 1
+#define INCLUDE_vTaskDelay 1
+#define INCLUDE_xTaskGetSchedulerState 0
+#define INCLUDE_xTaskGetCurrentTaskHandle 1
+#define INCLUDE_uxTaskGetStackHighWaterMark 0
+#define INCLUDE_xTaskGetIdleTaskHandle 0
+#define INCLUDE_xTimerGetTimerDaemonTaskHandle 0
+#define INCLUDE_pcTaskGetTaskName 0
+#define INCLUDE_eTaskGetState 0
+#define INCLUDE_xEventGroupSetBitFromISR 0
+#define INCLUDE_xTimerPendFunctionCall 0
+
+/* FreeRTOS hooks to NVIC vectors */
+#define xPortPendSVHandler PendSV_Handler
+#define xPortSysTickHandler SysTick_Handler
+#define vPortSVCHandler SVC_Handler
+
+//--------------------------------------------------------------------+
+// Interrupt nesting behavior configuration.
+//--------------------------------------------------------------------+
+
+// For Cortex-M specific: __NVIC_PRIO_BITS is defined in mcu header
+#define configPRIO_BITS __NVIC_PRIO_BITS
+
+/* The lowest interrupt priority that can be used in a call to a "set priority" function. */
+#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY ((1<-jlink` target for CMake.
+
+Both the Evaluation Kit and Feather boards are shipped with a CMSIS-DAP
+compatible debug probe. However, at the time of writing, the necessary flashing
+algorithms for OpenOCD have not yet been incorporated into the OpenOCD master
+branch. To utilize the provided debug probes, please install the bundled MSDK
+package which includes the appropriate OpenOCD modifications. To leverage this
+OpenOCD instance, run the `flash-msdk` Makefile rule, or `-msdk` CMake
+target.
diff --git a/hw/bsp/max32666/boards/max32666evkit/board.cmake b/hw/bsp/max32666/boards/max32666evkit/board.cmake
new file mode 100644
index 000000000..9dc6962eb
--- /dev/null
+++ b/hw/bsp/max32666/boards/max32666evkit/board.cmake
@@ -0,0 +1 @@
+# Nothing to be done at the board level
diff --git a/hw/bsp/max32666/boards/max32666evkit/board.h b/hw/bsp/max32666/boards/max32666evkit/board.h
new file mode 100644
index 000000000..0ab1483b8
--- /dev/null
+++ b/hw/bsp/max32666/boards/max32666evkit/board.h
@@ -0,0 +1,57 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2024, Brent Kowal (Analog Devices, Inc)
+ *
+ * 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 THE
+ * AUTHORS OR COPYRIGHT HOLDERS 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.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#include "gpio.h"
+#include "mxc_sys.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// LED
+#define LED_PORT MXC_GPIO1
+#define LED_PIN MXC_GPIO_PIN_14
+#define LED_VDDIO MXC_GPIO_VSSEL_VDDIOH
+#define LED_STATE_ON 0
+
+// Button
+#define BUTTON_PORT MXC_GPIO1
+#define BUTTON_PIN MXC_GPIO_PIN_6
+#define BUTTON_PULL MXC_GPIO_PAD_PULL_UP
+#define BUTTON_STATE_ACTIVE 0
+
+// UART Enable for EvKit's Integrated FTDI Adapter. Pin Mux handled by the HAL
+#define UART_NUM 1
+#define UART_MAP MAP_A
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/hw/bsp/max32666/boards/max32666evkit/board.mk b/hw/bsp/max32666/boards/max32666evkit/board.mk
new file mode 100644
index 000000000..a813a5327
--- /dev/null
+++ b/hw/bsp/max32666/boards/max32666evkit/board.mk
@@ -0,0 +1 @@
+# No specific build requirements for the board.
diff --git a/hw/bsp/max32666/boards/max32666fthr/board.cmake b/hw/bsp/max32666/boards/max32666fthr/board.cmake
new file mode 100644
index 000000000..9dc6962eb
--- /dev/null
+++ b/hw/bsp/max32666/boards/max32666fthr/board.cmake
@@ -0,0 +1 @@
+# Nothing to be done at the board level
diff --git a/hw/bsp/max32666/boards/max32666fthr/board.h b/hw/bsp/max32666/boards/max32666fthr/board.h
new file mode 100644
index 000000000..c719b748a
--- /dev/null
+++ b/hw/bsp/max32666/boards/max32666fthr/board.h
@@ -0,0 +1,57 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2024, Brent Kowal (Analog Devices, Inc)
+ *
+ * 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 THE
+ * AUTHORS OR COPYRIGHT HOLDERS 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.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#include "gpio.h"
+#include "mxc_sys.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// LED
+#define LED_PORT MXC_GPIO0
+#define LED_PIN MXC_GPIO_PIN_29
+#define LED_VDDIO MXC_GPIO_VSSEL_VDDIOH
+#define LED_STATE_ON 0
+
+// Button
+#define BUTTON_PORT MXC_GPIO1
+#define BUTTON_PIN MXC_GPIO_PIN_10
+#define BUTTON_PULL MXC_GPIO_PAD_PULL_UP
+#define BUTTON_STATE_ACTIVE 0
+
+// UART Enable for UART on SWD. Pin Mux handled by the HAL
+#define UART_NUM 1
+#define UART_MAP MAP_B
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/hw/bsp/max32666/boards/max32666fthr/board.mk b/hw/bsp/max32666/boards/max32666fthr/board.mk
new file mode 100644
index 000000000..a813a5327
--- /dev/null
+++ b/hw/bsp/max32666/boards/max32666fthr/board.mk
@@ -0,0 +1 @@
+# No specific build requirements for the board.
diff --git a/hw/bsp/max32666/family.c b/hw/bsp/max32666/family.c
new file mode 100644
index 000000000..8ee4b6762
--- /dev/null
+++ b/hw/bsp/max32666/family.c
@@ -0,0 +1,172 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2024 Brent Kowal (Analog Devices, Inc)
+ *
+ * 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 THE
+ * AUTHORS OR COPYRIGHT HOLDERS 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.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wstrict-prototypes" // _mxc_crit_get_state()
+#endif
+
+#include "gpio.h"
+#include "mxc_sys.h"
+#include "mcr_regs.h"
+#include "mxc_device.h"
+#include "uart.h"
+
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
+
+#include "board.h"
+#include "bsp/board_api.h"
+
+//--------------------------------------------------------------------+
+// Forward USB interrupt events to TinyUSB IRQ Handler
+//--------------------------------------------------------------------+
+void USB_IRQHandler(void) {
+ tud_int_handler(0);
+}
+
+//--------------------------------------------------------------------+
+// MACRO TYPEDEF CONSTANT ENUM
+//--------------------------------------------------------------------+
+mxc_uart_regs_t *ConsoleUart = MXC_UART_GET_UART(UART_NUM);
+
+void board_init(void) {
+#if CFG_TUSB_OS == OPT_OS_NONE
+ // 1ms tick timer
+ SysTick_Config(SystemCoreClock / 1000);
+#elif CFG_TUSB_OS == OPT_OS_FREERTOS
+ // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
+ NVIC_SetPriority(USB_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY);
+#endif
+ mxc_gpio_cfg_t gpioConfig;
+
+ // LED
+ gpioConfig.drvstr = MXC_GPIO_DRVSTR_0;
+ gpioConfig.func = MXC_GPIO_FUNC_OUT;
+ gpioConfig.mask = LED_PIN;
+ gpioConfig.pad = MXC_GPIO_PAD_NONE;
+ gpioConfig.port = LED_PORT;
+ gpioConfig.vssel = LED_VDDIO;
+ MXC_GPIO_Config(&gpioConfig);
+ board_led_write(false);
+
+ // Button
+ gpioConfig.drvstr = MXC_GPIO_DRVSTR_0;
+ gpioConfig.func = MXC_GPIO_FUNC_IN;
+ gpioConfig.mask = BUTTON_PIN;
+ gpioConfig.pad = BUTTON_PULL;
+ gpioConfig.port = BUTTON_PORT;
+ gpioConfig.vssel = MXC_GPIO_VSSEL_VDDIO;
+ MXC_GPIO_Config(&gpioConfig);
+
+ // UART
+ MXC_UART_Init(ConsoleUart, CFG_BOARD_UART_BAUDRATE, UART_MAP);
+
+ //USB
+ // Startup the HIRC96M clock if it's not on already
+ if (!(MXC_GCR->clkcn & MXC_F_GCR_CLKCN_HIRC96M_EN)) {
+ MXC_GCR->clkcn |= MXC_F_GCR_CLKCN_HIRC96M_EN;
+ }
+
+ MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_USB);
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state) {
+#if LED_STATE_ON
+ state = !state;
+#endif
+ if (state) {
+ MXC_GPIO_OutClr(LED_PORT, LED_PIN);
+ } else {
+ MXC_GPIO_OutSet(LED_PORT, LED_PIN);
+ }
+}
+
+uint32_t board_button_read(void) {
+ uint32_t state = MXC_GPIO_InGet(BUTTON_PORT, BUTTON_PIN) ? 1 : 0;
+ return BUTTON_STATE_ACTIVE == state;
+}
+
+size_t board_get_unique_id(uint8_t id[], size_t max_len) {
+ uint8_t hw_id[MXC_SYS_USN_CHECKSUM_LEN];//USN Buffer
+ /* All other 2nd parameter is optional checksum buffer */
+ MXC_SYS_GetUSN(hw_id, NULL);
+
+ size_t act_len = TU_MIN(max_len, MXC_SYS_USN_LEN);
+ memcpy(id, hw_id, act_len);
+ return act_len;
+}
+
+int board_uart_read(uint8_t *buf, int len) {
+ int uart_val;
+ int act_len = 0;
+
+ while (act_len < len) {
+ if ((uart_val = MXC_UART_ReadCharacterRaw(ConsoleUart)) == E_UNDERFLOW) {
+ break;
+ } else {
+ *buf++ = (uint8_t) uart_val;
+ act_len++;
+ }
+ }
+ return act_len;
+}
+
+int board_uart_write(void const *buf, int len) {
+ int act_len = 0;
+ const uint8_t *ch_ptr = (const uint8_t *) buf;
+ while (act_len < len) {
+ MXC_UART_WriteCharacter(ConsoleUart, *ch_ptr++);
+ act_len++;
+ }
+ return len;
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+
+void SysTick_Handler(void) {
+ system_ticks++;
+}
+
+uint32_t board_millis(void) {
+ return system_ticks;
+}
+#endif
+
+void HardFault_Handler(void) {
+ __asm("BKPT #0\n");
+}
+
+// Required by __libc_init_array in startup code if we are compiling using
+// -nostdlib/-nostartfiles.
+void _init(void) {
+}
diff --git a/hw/bsp/max32666/family.cmake b/hw/bsp/max32666/family.cmake
new file mode 100644
index 000000000..fb8c32295
--- /dev/null
+++ b/hw/bsp/max32666/family.cmake
@@ -0,0 +1,147 @@
+include_guard()
+
+set(MAX32_PERIPH ${TOP}/hw/mcu/analog/max32/Libraries/PeriphDrivers)
+set(MAX32_CMSIS ${TOP}/hw/mcu/analog/max32/Libraries/CMSIS)
+set(CMSIS_5 ${TOP}/lib/CMSIS_5)
+
+# include board specific
+include(${CMAKE_CURRENT_LIST_DIR}/boards/${BOARD}/board.cmake)
+
+# Get the linker file from current location (family)
+set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/max32666.ld)
+set(LD_FILE_Clang ${LD_FILE_GNU})
+
+# toolchain set up
+set(CMAKE_SYSTEM_PROCESSOR cortex-m4 CACHE INTERNAL "System Processor")
+set(CMAKE_TOOLCHAIN_FILE ${TOP}/examples/build_system/cmake/toolchain/arm_${TOOLCHAIN}.cmake)
+set(JLINK_DEVICE max32666)
+set(OPENOCD_OPTION "-f interface/cmsis-dap.cfg -f target/max32665.cfg")
+
+set(FAMILY_MCUS MAX32666 CACHE INTERNAL "")
+
+function(update_board TARGET)
+ target_compile_definitions(${TARGET} PUBLIC
+ TARGET=MAX32665
+ TARGET_REV=0x4131
+ MXC_ASSERT_ENABLE
+ MAX32665
+ IAR_PRAGMAS=0
+ CFG_TUSB_MCU=OPT_MCU_MAX32666
+ BOARD_TUD_MAX_SPEED=OPT_MODE_HIGH_SPEED
+ )
+endfunction()
+
+#------------------------------------
+# BOARD_TARGET
+#------------------------------------
+# only need to be built ONCE for all examples
+function(add_board_target BOARD_TARGET)
+ if (TARGET ${BOARD_TARGET})
+ return()
+ endif ()
+
+ # Startup & Linker script
+ set(STARTUP_FILE_GNU ${MAX32_CMSIS}/Device/Maxim/MAX32665/Source/GCC/startup_max32665.S)
+ set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+
+ set(PERIPH_SRC ${MAX32_PERIPH}/Source)
+ add_library(${BOARD_TARGET} STATIC
+ ${MAX32_CMSIS}/Device/Maxim/MAX32665/Source/heap.c
+ ${MAX32_CMSIS}/Device/Maxim/MAX32665/Source/system_max32665.c
+ ${PERIPH_SRC}/SYS/mxc_assert.c
+ ${PERIPH_SRC}/SYS/mxc_delay.c
+ ${PERIPH_SRC}/SYS/mxc_lock.c
+ ${PERIPH_SRC}/SYS/nvic_table.c
+ ${PERIPH_SRC}/SYS/pins_me14.c
+ ${PERIPH_SRC}/SYS/sys_me14.c
+ ${PERIPH_SRC}/TPU/tpu_me14.c
+ ${PERIPH_SRC}/TPU/tpu_reva.c
+ ${PERIPH_SRC}/FLC/flc_common.c
+ ${PERIPH_SRC}/FLC/flc_me14.c
+ ${PERIPH_SRC}/FLC/flc_reva.c
+ ${PERIPH_SRC}/GPIO/gpio_common.c
+ ${PERIPH_SRC}/GPIO/gpio_me14.c
+ ${PERIPH_SRC}/GPIO/gpio_reva.c
+ ${PERIPH_SRC}/ICC/icc_me14.c
+ ${PERIPH_SRC}/ICC/icc_reva.c
+ ${PERIPH_SRC}/UART/uart_common.c
+ ${PERIPH_SRC}/UART/uart_me14.c
+ ${PERIPH_SRC}/UART/uart_reva.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
+ )
+ target_include_directories(${BOARD_TARGET} PUBLIC
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}
+ ${MAX32_CMSIS}/Include
+ ${MAX32_CMSIS}/Device/Maxim/MAX32665/Include
+ ${MAX32_PERIPH}/Include/MAX32665
+ ${PERIPH_SRC}/SYS
+ ${PERIPH_SRC}/GPIO
+ ${PERIPH_SRC}/TPU
+ ${PERIPH_SRC}/ICC
+ ${PERIPH_SRC}/FLC
+ ${PERIPH_SRC}/UART
+ )
+
+ target_compile_options(${BOARD_TARGET} PRIVATE
+ -Wno-error=strict-prototypes
+ )
+ update_board(${BOARD_TARGET})
+
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${BOARD_TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ -nostartfiles
+ --specs=nosys.specs --specs=nano.specs
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${BOARD_TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_Clang}"
+ )
+ endif ()
+endfunction()
+
+
+#------------------------------------
+# Functions
+#------------------------------------
+function(family_configure_example TARGET RTOS)
+ family_configure_common(${TARGET} ${RTOS})
+
+ # Board target
+ add_board_target(board_${BOARD})
+
+ #---------- Port Specific ----------
+ # These files are built for each example since it depends on example's tusb_config.h
+ target_sources(${TARGET} PUBLIC
+ # BSP
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ )
+ target_include_directories(${TARGET} PUBLIC
+ # family, hw, board
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
+ )
+
+ # Add TinyUSB target and port source
+ family_add_tinyusb(${TARGET} OPT_MCU_MAX32666 ${RTOS})
+ target_sources(${TARGET}-tinyusb PUBLIC
+ ${TOP}/src/portable/mentor/musb/dcd_musb.c
+ )
+ target_compile_options(${TARGET} PRIVATE
+ -Wno-error=strict-prototypes
+ )
+
+ target_link_libraries(${TARGET}-tinyusb PUBLIC board_${BOARD})
+ target_compile_options(${TARGET}-tinyusb PRIVATE
+ -Wno-error=strict-prototypes
+ )
+
+ # Link dependencies
+ target_link_libraries(${TARGET} PUBLIC board_${BOARD} ${TARGET}-tinyusb)
+
+ # Flashing
+ family_flash_jlink(${TARGET})
+ family_flash_openocd_adi(${TARGET})
+endfunction()
diff --git a/hw/bsp/max32666/family.mk b/hw/bsp/max32666/family.mk
new file mode 100644
index 000000000..b4f7d1e57
--- /dev/null
+++ b/hw/bsp/max32666/family.mk
@@ -0,0 +1,93 @@
+DEPS_SUBMODULES += lib/CMSIS_5 hw/mcu/analog/max32
+
+# Important locations in the hw support for MCU
+MAX32_CMSIS = hw/mcu/analog/max32/Libraries/CMSIS
+MAX32_PERIPH = hw/mcu/analog/max32/Libraries/PeriphDrivers
+
+# Add any board specific make rules
+include $(TOP)/$(BOARD_PATH)/board.mk
+
+CPU_CORE ?= cortex-m4
+PORT ?= 0
+
+# GCC
+SRC_S_GCC += $(MAX32_CMSIS)/Device/Maxim/MAX32665/Source/GCC/startup_max32665.S
+LD_FILE = $(FAMILY_PATH)/max32666.ld
+
+# --------------
+# Compiler Flags
+# --------------
+# Flags for the MAX32665/6 SDK
+CFLAGS += -DTARGET=MAX32665 \
+ -DTARGET_REV=0x4131 \
+ -DMXC_ASSERT_ENABLE \
+ -DMAX32665 \
+ -DIAR_PRAGMAS=0
+
+# Flags for TUSB features
+CFLAGS += \
+ -DCFG_TUSB_MCU=OPT_MCU_MAX32666 \
+ -DBOARD_TUD_MAX_SPEED=OPT_MODE_HIGH_SPEED
+
+# mcu driver cause following warnings
+CFLAGS += -Wno-error=strict-prototypes \
+ -Wno-error=unused-parameter \
+ -Wno-error=cast-align \
+ -Wno-error=cast-qual
+LDFLAGS_GCC += -nostartfiles --specs=nosys.specs --specs=nano.specs
+
+# For flash-jlink target
+JLINK_DEVICE = max32666
+
+# flash target using Jlink by default
+flash: flash-jlink
+
+# Optional flash option when running within an installed MSDK to use OpenOCD
+# Mainline OpenOCD does not yet have the MAX32's flash algorithm integrated.
+# If the MSDK is installed, flash-msdk can be run to utilize the the modified
+# openocd with the algorithms
+MAXIM_PATH := $(subst \,/,$(MAXIM_PATH))
+flash-msdk: $(BUILD)/$(PROJECT).elf
+ $(MAXIM_PATH)/Tools/OpenOCD/openocd -s $(MAXIM_PATH)/Tools/OpenOCD/scripts \
+ -f interface/cmsis-dap.cfg -f target/max32665.cfg \
+ -c "program $(BUILD)/$(PROJECT).elf verify; init; reset; exit"
+
+# -----------------
+# Sources & Include
+# -----------------
+PERIPH_SRC = $(TOP)/$(MAX32_PERIPH)/Source
+SRC_C += \
+ src/portable/mentor/musb/dcd_musb.c \
+ $(MAX32_CMSIS)/Device/Maxim/MAX32665/Source/heap.c \
+ $(MAX32_CMSIS)/Device/Maxim/MAX32665/Source/system_max32665.c \
+ $(PERIPH_SRC)/SYS/mxc_assert.c \
+ $(PERIPH_SRC)/SYS/mxc_delay.c \
+ $(PERIPH_SRC)/SYS/mxc_lock.c \
+ $(PERIPH_SRC)/SYS/nvic_table.c \
+ $(PERIPH_SRC)/SYS/pins_me14.c \
+ $(PERIPH_SRC)/SYS/sys_me14.c \
+ $(PERIPH_SRC)/FLC/flc_common.c \
+ $(PERIPH_SRC)/FLC/flc_me14.c \
+ $(PERIPH_SRC)/FLC/flc_reva.c \
+ $(PERIPH_SRC)/GPIO/gpio_common.c \
+ $(PERIPH_SRC)/GPIO/gpio_me14.c \
+ $(PERIPH_SRC)/GPIO/gpio_reva.c \
+ $(PERIPH_SRC)/ICC/icc_me14.c \
+ $(PERIPH_SRC)/ICC/icc_reva.c \
+ $(PERIPH_SRC)/TPU/tpu_me14.c \
+ $(PERIPH_SRC)/TPU/tpu_reva.c \
+ $(PERIPH_SRC)/UART/uart_common.c \
+ $(PERIPH_SRC)/UART/uart_me14.c \
+ $(PERIPH_SRC)/UART/uart_reva.c \
+
+INC += \
+ $(TOP)/$(BOARD_PATH) \
+ $(TOP)/$(MAX32_CMSIS)/Include \
+ $(TOP)/$(MAX32_CMSIS)/Device/Maxim/MAX32665/Include \
+ $(TOP)/$(MAX32_PERIPH)/Include/MAX32665 \
+ $(PERIPH_SRC)/SYS \
+ $(PERIPH_SRC)/GPIO \
+ $(PERIPH_SRC)/ICC \
+ $(PERIPH_SRC)/FLC \
+ $(PERIPH_SRC)/TPU \
+ $(PERIPH_SRC)/UART
diff --git a/hw/bsp/max32666/max32666.ld b/hw/bsp/max32666/max32666.ld
new file mode 100644
index 000000000..06c124247
--- /dev/null
+++ b/hw/bsp/max32666/max32666.ld
@@ -0,0 +1,135 @@
+/* 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 = 0x08000000
+ FLASH (rx) : ORIGIN = 0x10000000, LENGTH = 0x00100000
+ SRAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x0008C000
+ SPID (rw) : ORIGIN = 0x80000000, LENGTH = 512M
+}
+
+/* Sections Definitions */
+SECTIONS {
+ .text :
+ {
+ _text = .;
+ KEEP(*(.isr_vector))
+ *(.text*) /* program code */
+ *(.rodata*) /* read-only data: "const" */
+
+ KEEP(*(.init))
+ KEEP(*(.fini))
+
+ /* .ctors */
+ *crtbegin.o(.ctors)
+ *crtbegin?.o(.ctors)
+ *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
+ *(SORT(.ctors.*))
+ *(.ctors)
+
+ /* .dtors */
+ *crtbegin.o(.dtors)
+ *crtbegin?.o(.dtors)
+ *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
+ *(SORT(.dtors.*))
+ *(.dtors)
+
+ /* C++ Exception handling */
+ KEEP(*(.eh_frame*))
+ _etext = .;
+ } > FLASH
+
+ .ARM.extab :
+ {
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ } > 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* .gnu.linkonce.armexidx.*)
+ __exidx_end = .;
+ } > FLASH
+
+ .data :
+ {
+ _data = ALIGN(., 4);
+ *(vtable)
+ *(.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);
+
+ .bss :
+ {
+ . = ALIGN(4);
+ _bss = .;
+ *(.bss*) /*read-write zero initialized data: uninitialized 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);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ *(.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/hw/bsp/max32690/FreeRTOSConfig/FreeRTOSConfig.h b/hw/bsp/max32690/FreeRTOSConfig/FreeRTOSConfig.h
new file mode 100644
index 000000000..e5a76af85
--- /dev/null
+++ b/hw/bsp/max32690/FreeRTOSConfig/FreeRTOSConfig.h
@@ -0,0 +1,149 @@
+/*
+ * FreeRTOS Kernel V10.0.0
+ * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. 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. If you wish to use our Amazon
+ * FreeRTOS name, please do so in a fair use way that does not cause confusion.
+ *
+ * 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 THE AUTHORS OR
+ * COPYRIGHT HOLDERS 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.
+ *
+ * http://www.FreeRTOS.org
+ * http://aws.amazon.com/freertos
+ *
+ * 1 tab == 4 spaces!
+ */
+
+
+#ifndef FREERTOS_CONFIG_H
+#define FREERTOS_CONFIG_H
+
+/*-----------------------------------------------------------
+ * Application specific definitions.
+ *
+ * These definitions should be adjusted for your particular hardware and
+ * application requirements.
+ *
+ * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
+ * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
+ *
+ * See http://www.freertos.org/a00110.html.
+ *----------------------------------------------------------*/
+
+// skip if included from IAR assembler
+#ifndef __IASMARM__
+ #include "mxc_device.h"
+#endif
+
+/* Cortex M23/M33 port configuration. */
+#define configENABLE_MPU 0
+#define configENABLE_FPU 1
+#define configENABLE_TRUSTZONE 0
+#define configMINIMAL_SECURE_STACK_SIZE (1024)
+
+#define configUSE_PREEMPTION 1
+#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
+#define configCPU_CLOCK_HZ SystemCoreClock
+#define configTICK_RATE_HZ ( 1000 )
+#define configMAX_PRIORITIES ( 5 )
+#define configMINIMAL_STACK_SIZE ( 128 )
+#define configTOTAL_HEAP_SIZE ( configSUPPORT_DYNAMIC_ALLOCATION*4*1024 )
+#define configMAX_TASK_NAME_LEN 16
+#define configUSE_16_BIT_TICKS 0
+#define configIDLE_SHOULD_YIELD 1
+#define configUSE_MUTEXES 1
+#define configUSE_RECURSIVE_MUTEXES 1
+#define configUSE_COUNTING_SEMAPHORES 1
+#define configQUEUE_REGISTRY_SIZE 4
+#define configUSE_QUEUE_SETS 0
+#define configUSE_TIME_SLICING 0
+#define configUSE_NEWLIB_REENTRANT 0
+#define configENABLE_BACKWARD_COMPATIBILITY 1
+#define configSTACK_ALLOCATION_FROM_SEPARATE_HEAP 0
+
+#define configSUPPORT_STATIC_ALLOCATION 1
+#define configSUPPORT_DYNAMIC_ALLOCATION 0
+
+/* Hook function related definitions. */
+#define configUSE_IDLE_HOOK 0
+#define configUSE_TICK_HOOK 0
+#define configUSE_MALLOC_FAILED_HOOK 0 // cause nested extern warning
+#define configCHECK_FOR_STACK_OVERFLOW 2
+#define configCHECK_HANDLER_INSTALLATION 0
+
+/* Run time and task stats gathering related definitions. */
+#define configGENERATE_RUN_TIME_STATS 0
+#define configRECORD_STACK_HIGH_ADDRESS 1
+#define configUSE_TRACE_FACILITY 1 // legacy trace
+#define configUSE_STATS_FORMATTING_FUNCTIONS 0
+
+/* Co-routine definitions. */
+#define configUSE_CO_ROUTINES 0
+#define configMAX_CO_ROUTINE_PRIORITIES 2
+
+/* Software timer related definitions. */
+#define configUSE_TIMERS 1
+#define configTIMER_TASK_PRIORITY (configMAX_PRIORITIES-2)
+#define configTIMER_QUEUE_LENGTH 32
+#define configTIMER_TASK_STACK_DEPTH configMINIMAL_STACK_SIZE
+
+/* Optional functions - most linkers will remove unused functions anyway. */
+#define INCLUDE_vTaskPrioritySet 0
+#define INCLUDE_uxTaskPriorityGet 0
+#define INCLUDE_vTaskDelete 0
+#define INCLUDE_vTaskSuspend 1 // required for queue, semaphore, mutex to be blocked indefinitely with portMAX_DELAY
+#define INCLUDE_xResumeFromISR 0
+#define INCLUDE_vTaskDelayUntil 1
+#define INCLUDE_vTaskDelay 1
+#define INCLUDE_xTaskGetSchedulerState 0
+#define INCLUDE_xTaskGetCurrentTaskHandle 1
+#define INCLUDE_uxTaskGetStackHighWaterMark 0
+#define INCLUDE_xTaskGetIdleTaskHandle 0
+#define INCLUDE_xTimerGetTimerDaemonTaskHandle 0
+#define INCLUDE_pcTaskGetTaskName 0
+#define INCLUDE_eTaskGetState 0
+#define INCLUDE_xEventGroupSetBitFromISR 0
+#define INCLUDE_xTimerPendFunctionCall 0
+
+/* FreeRTOS hooks to NVIC vectors */
+#define xPortPendSVHandler PendSV_Handler
+#define xPortSysTickHandler SysTick_Handler
+#define vPortSVCHandler SVC_Handler
+
+//--------------------------------------------------------------------+
+// Interrupt nesting behavior configuration.
+//--------------------------------------------------------------------+
+
+// For Cortex-M specific: __NVIC_PRIO_BITS is defined in mcu header
+#define configPRIO_BITS __NVIC_PRIO_BITS
+
+/* The lowest interrupt priority that can be used in a call to a "set priority" function. */
+#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY ((1<-jlink` target for CMake.
+
+Both the Evaluation Kit and APARD boards are shipped with a CMSIS-DAP
+compatible debug probe. However, at the time of writing, the necessary flashing
+algorithms for OpenOCD have not yet been incorporated into the OpenOCD master
+branch. To utilize the provided debug probes, please install the bundled MSDK
+package which includes the appropriate OpenOCD modifications. To leverage this
+OpenOCD instance, run the `flash-msdk` Makefile rule, or `-msdk` CMake
+target.
diff --git a/hw/bsp/max32690/boards/apard32690/board.cmake b/hw/bsp/max32690/boards/apard32690/board.cmake
new file mode 100644
index 000000000..9dc6962eb
--- /dev/null
+++ b/hw/bsp/max32690/boards/apard32690/board.cmake
@@ -0,0 +1 @@
+# Nothing to be done at the board level
diff --git a/src/portable/mentor/musb/musb_msp432e.h b/hw/bsp/max32690/boards/apard32690/board.h
similarity index 68%
rename from src/portable/mentor/musb/musb_msp432e.h
rename to hw/bsp/max32690/boards/apard32690/board.h
index fce21de88..f94097ca9 100644
--- a/src/portable/mentor/musb/musb_msp432e.h
+++ b/hw/bsp/max32690/boards/apard32690/board.h
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2021, Ha Thach (tinyusb.org)
+ * Copyright (c) 2024, Brent Kowal (Analog Devices, Inc)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -24,17 +24,33 @@
* This file is part of the TinyUSB stack.
*/
-#ifndef _TUSB_MUSB_MSP432E_H_
-#define _TUSB_MUSB_MSP432E_H_
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#include "gpio.h"
+#include "mxc_sys.h"
#ifdef __cplusplus
- extern "C" {
+extern "C" {
#endif
-#include "msp.h"
+// LED
+#define LED_PORT MXC_GPIO2
+#define LED_PIN MXC_GPIO_PIN_1
+#define LED_VDDIO MXC_GPIO_VSSEL_VDDIOH
+#define LED_STATE_ON 1
+
+// Button
+#define BUTTON_PORT MXC_GPIO1
+#define BUTTON_PIN MXC_GPIO_PIN_27
+#define BUTTON_PULL MXC_GPIO_PAD_NONE
+#define BUTTON_STATE_ACTIVE 1
+
+// UART Enable for UART on ARM SWD Connector
+#define UART_NUM 0
#ifdef __cplusplus
- }
+}
#endif
-#endif
+#endif /* BOARD_H_ */
diff --git a/hw/bsp/max32690/boards/apard32690/board.mk b/hw/bsp/max32690/boards/apard32690/board.mk
new file mode 100644
index 000000000..a813a5327
--- /dev/null
+++ b/hw/bsp/max32690/boards/apard32690/board.mk
@@ -0,0 +1 @@
+# No specific build requirements for the board.
diff --git a/hw/bsp/max32690/boards/max32690evkit/board.cmake b/hw/bsp/max32690/boards/max32690evkit/board.cmake
new file mode 100644
index 000000000..9dc6962eb
--- /dev/null
+++ b/hw/bsp/max32690/boards/max32690evkit/board.cmake
@@ -0,0 +1 @@
+# Nothing to be done at the board level
diff --git a/hw/bsp/max32690/boards/max32690evkit/board.h b/hw/bsp/max32690/boards/max32690evkit/board.h
new file mode 100644
index 000000000..05d60f220
--- /dev/null
+++ b/hw/bsp/max32690/boards/max32690evkit/board.h
@@ -0,0 +1,56 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2024, Brent Kowal (Analog Devices, Inc)
+ *
+ * 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 THE
+ * AUTHORS OR COPYRIGHT HOLDERS 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.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#include "gpio.h"
+#include "mxc_sys.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// LED
+#define LED_PORT MXC_GPIO0
+#define LED_PIN MXC_GPIO_PIN_14
+#define LED_VDDIO MXC_GPIO_VSSEL_VDDIOH
+#define LED_STATE_ON 0
+
+// Button
+#define BUTTON_PORT MXC_GPIO4
+#define BUTTON_PIN MXC_GPIO_PIN_0
+#define BUTTON_PULL MXC_GPIO_PAD_PULL_UP
+#define BUTTON_STATE_ACTIVE 0
+
+// UART Enable for EvKit's Integrated FTDI Adapter. Pin Mux handled by the HAL
+#define UART_NUM 2
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/hw/bsp/max32690/boards/max32690evkit/board.mk b/hw/bsp/max32690/boards/max32690evkit/board.mk
new file mode 100644
index 000000000..a813a5327
--- /dev/null
+++ b/hw/bsp/max32690/boards/max32690evkit/board.mk
@@ -0,0 +1 @@
+# No specific build requirements for the board.
diff --git a/hw/bsp/max32690/family.c b/hw/bsp/max32690/family.c
new file mode 100644
index 000000000..2418168d4
--- /dev/null
+++ b/hw/bsp/max32690/family.c
@@ -0,0 +1,171 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2024 Brent Kowal (Analog Devices, Inc)
+ *
+ * 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 THE
+ * AUTHORS OR COPYRIGHT HOLDERS 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.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wstrict-prototypes" // _mxc_crit_get_state()
+#endif
+
+#include "gpio.h"
+#include "mxc_sys.h"
+#include "mcr_regs.h"
+#include "mxc_device.h"
+#include "uart.h"
+
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
+
+#include "board.h"
+#include "bsp/board_api.h"
+
+
+//--------------------------------------------------------------------+
+// Forward USB interrupt events to TinyUSB IRQ Handler
+//--------------------------------------------------------------------+
+void USB_IRQHandler(void) {
+ tud_int_handler(0);
+}
+
+//--------------------------------------------------------------------+
+// MACRO TYPEDEF CONSTANT ENUM
+//--------------------------------------------------------------------+
+mxc_uart_regs_t *ConsoleUart = MXC_UART_GET_UART(UART_NUM);
+
+void board_init(void) {
+#if CFG_TUSB_OS == OPT_OS_NONE
+ // 1ms tick timer
+ SysTick_Config(SystemCoreClock / 1000);
+#elif CFG_TUSB_OS == OPT_OS_FREERTOS
+ // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
+ NVIC_SetPriority(USB_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY);
+#endif
+ mxc_gpio_cfg_t gpioConfig;
+
+ // LED
+ gpioConfig.drvstr = MXC_GPIO_DRVSTR_0;
+ gpioConfig.func = MXC_GPIO_FUNC_OUT;
+ gpioConfig.mask = LED_PIN;
+ gpioConfig.pad = MXC_GPIO_PAD_NONE;
+ gpioConfig.port = LED_PORT;
+ gpioConfig.vssel = LED_VDDIO;
+ MXC_GPIO_Config(&gpioConfig);
+ board_led_write(false);
+
+ // Button
+ gpioConfig.drvstr = MXC_GPIO_DRVSTR_0;
+ gpioConfig.func = MXC_GPIO_FUNC_IN;
+ gpioConfig.mask = BUTTON_PIN;
+ gpioConfig.pad = BUTTON_PULL;
+ gpioConfig.port = BUTTON_PORT;
+ gpioConfig.vssel = MXC_GPIO_VSSEL_VDDIO;
+ MXC_GPIO_Config(&gpioConfig);
+
+ // UART
+ MXC_UART_Init(ConsoleUart, CFG_BOARD_UART_BAUDRATE, MXC_UART_IBRO_CLK);
+
+ //USB
+ MXC_SYS_ClockSourceEnable(MXC_SYS_CLOCK_IPO);
+ MXC_MCR->ldoctrl |= MXC_F_MCR_LDOCTRL_0P9EN;
+ MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_USB);
+ MXC_SYS_Reset_Periph(MXC_SYS_RESET0_USB);
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state) {
+#if LED_STATE_ON
+ state = !state;
+#endif
+ if (state) {
+ MXC_GPIO_OutClr(LED_PORT, LED_PIN);
+ } else {
+ MXC_GPIO_OutSet(LED_PORT, LED_PIN);
+ }
+}
+
+uint32_t board_button_read(void) {
+ uint32_t state = MXC_GPIO_InGet(BUTTON_PORT, BUTTON_PIN) ? 1 : 0;
+ return BUTTON_STATE_ACTIVE == state;
+}
+
+size_t board_get_unique_id(uint8_t id[], size_t max_len) {
+ uint8_t hw_id[MXC_SYS_USN_CHECKSUM_LEN];//USN Buffer
+ /* All other 2nd parameter is optional checksum buffer */
+ MXC_SYS_GetUSN(hw_id, NULL);
+
+ size_t act_len = TU_MIN(max_len, MXC_SYS_USN_LEN);
+ memcpy(id, hw_id, act_len);
+ return act_len;
+}
+
+int board_uart_read(uint8_t *buf, int len) {
+ int uart_val;
+ int act_len = 0;
+
+ while (act_len < len) {
+ if ((uart_val = MXC_UART_ReadCharacterRaw(ConsoleUart)) == E_UNDERFLOW) {
+ break;
+ } else {
+ *buf++ = (uint8_t) uart_val;
+ act_len++;
+ }
+ }
+ return act_len;
+}
+
+int board_uart_write(void const *buf, int len) {
+ int act_len = 0;
+ const uint8_t *ch_ptr = (const uint8_t *) buf;
+ while (act_len < len) {
+ MXC_UART_WriteCharacter(ConsoleUart, *ch_ptr++);
+ act_len++;
+ }
+ return len;
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+
+void SysTick_Handler(void) {
+ system_ticks++;
+}
+
+uint32_t board_millis(void) {
+ return system_ticks;
+}
+#endif
+
+void HardFault_Handler(void) {
+ __asm("BKPT #0\n");
+}
+
+// Required by __libc_init_array in startup code if we are compiling using
+// -nostdlib/-nostartfiles.
+void _init(void) {
+}
diff --git a/hw/bsp/max32690/family.cmake b/hw/bsp/max32690/family.cmake
new file mode 100644
index 000000000..736ca8eac
--- /dev/null
+++ b/hw/bsp/max32690/family.cmake
@@ -0,0 +1,165 @@
+include_guard()
+
+set(MAX32_PERIPH ${TOP}/hw/mcu/analog/max32/Libraries/PeriphDrivers)
+set(MAX32_CMSIS ${TOP}/hw/mcu/analog/max32/Libraries/CMSIS)
+set(CMSIS_5 ${TOP}/lib/CMSIS_5)
+
+# include board specific
+include(${CMAKE_CURRENT_LIST_DIR}/boards/${BOARD}/board.cmake)
+
+# Get the linker file from current location (family)
+set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/max32690.ld)
+set(LD_FILE_Clang ${LD_FILE_GNU})
+
+# toolchain set up
+set(CMAKE_SYSTEM_PROCESSOR cortex-m4 CACHE INTERNAL "System Processor")
+set(CMAKE_TOOLCHAIN_FILE ${TOP}/examples/build_system/cmake/toolchain/arm_${TOOLCHAIN}.cmake)
+set(JLINK_DEVICE max32690)
+set(OPENOCD_OPTION "-f interface/cmsis-dap.cfg -f target/max32690.cfg")
+
+set(FAMILY_MCUS MAX32690 CACHE INTERNAL "")
+
+function(update_board TARGET)
+ target_compile_definitions(${TARGET} PUBLIC
+ TARGET=MAX32690
+ TARGET_REV=0x4131
+ MXC_ASSERT_ENABLE
+ MAX32690
+ FLASH_ORIGIN=0x10000000
+ FLASH_SIZE=0x340000
+ SRAM_ORIGIN=0x20000000
+ SRAM_SIZE=0x100000
+ IAR_PRAGMAS=0
+ CFG_TUSB_MCU=OPT_MCU_MAX32690
+ BOARD_TUD_MAX_SPEED=OPT_MODE_HIGH_SPEED
+ )
+endfunction()
+
+#------------------------------------
+# BOARD_TARGET
+#------------------------------------
+# only need to be built ONCE for all examples
+function(add_board_target BOARD_TARGET)
+ if (TARGET ${BOARD_TARGET})
+ return()
+ endif ()
+
+ # Startup & Linker script
+ set(STARTUP_FILE_GNU ${MAX32_CMSIS}/Device/Maxim/MAX32690/Source/GCC/startup_max32690.S)
+ set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+
+ set(PERIPH_SRC ${MAX32_PERIPH}/Source)
+ add_library(${BOARD_TARGET} STATIC
+ ${MAX32_CMSIS}/Device/Maxim/MAX32690/Source/heap.c
+ ${MAX32_CMSIS}/Device/Maxim/MAX32690/Source/system_max32690.c
+ ${PERIPH_SRC}/SYS/mxc_assert.c
+ ${PERIPH_SRC}/SYS/mxc_delay.c
+ ${PERIPH_SRC}/SYS/mxc_lock.c
+ ${PERIPH_SRC}/SYS/nvic_table.c
+ ${PERIPH_SRC}/SYS/pins_me18.c
+ ${PERIPH_SRC}/SYS/sys_me18.c
+ ${PERIPH_SRC}/CTB/ctb_me18.c
+ ${PERIPH_SRC}/CTB/ctb_reva.c
+ ${PERIPH_SRC}/CTB/ctb_common.c
+ ${PERIPH_SRC}/FLC/flc_common.c
+ ${PERIPH_SRC}/FLC/flc_me18.c
+ ${PERIPH_SRC}/FLC/flc_reva.c
+ ${PERIPH_SRC}/GPIO/gpio_common.c
+ ${PERIPH_SRC}/GPIO/gpio_me18.c
+ ${PERIPH_SRC}/GPIO/gpio_reva.c
+ ${PERIPH_SRC}/ICC/icc_me18.c
+ ${PERIPH_SRC}/ICC/icc_reva.c
+ ${PERIPH_SRC}/UART/uart_common.c
+ ${PERIPH_SRC}/UART/uart_me18.c
+ ${PERIPH_SRC}/UART/uart_revb.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
+ )
+ target_include_directories(${BOARD_TARGET} PUBLIC
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}
+ ${MAX32_CMSIS}/Include
+ ${MAX32_CMSIS}/Device/Maxim/MAX32690/Include
+ ${MAX32_PERIPH}/Include/MAX32690
+ ${PERIPH_SRC}/SYS
+ ${PERIPH_SRC}/GPIO
+ ${PERIPH_SRC}/CTB
+ ${PERIPH_SRC}/ICC
+ ${PERIPH_SRC}/FLC
+ ${PERIPH_SRC}/UART
+ )
+
+ target_compile_options(${BOARD_TARGET} PRIVATE
+ -Wno-error=strict-prototypes
+ )
+ update_board(${BOARD_TARGET})
+
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${BOARD_TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ -nostartfiles
+ --specs=nosys.specs --specs=nano.specs
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${BOARD_TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_Clang}"
+ )
+ endif ()
+endfunction()
+
+
+#------------------------------------
+# Functions
+#------------------------------------
+function(family_configure_example TARGET RTOS)
+ family_configure_common(${TARGET} ${RTOS})
+
+ # Board target
+ add_board_target(board_${BOARD})
+
+ #---------- Port Specific ----------
+ # These files are built for each example since it depends on example's tusb_config.h
+ target_sources(${TARGET} PUBLIC
+ # BSP
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ )
+ target_include_directories(${TARGET} PUBLIC
+ # family, hw, board
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
+ )
+
+ # Add TinyUSB target and port source
+ family_add_tinyusb(${TARGET} OPT_MCU_MAX32690 ${RTOS})
+ target_sources(${TARGET}-tinyusb PUBLIC
+ ${TOP}/src/portable/mentor/musb/dcd_musb.c
+ )
+ target_compile_options(${TARGET} PRIVATE
+ -Wno-error=strict-prototypes
+ )
+
+ target_link_libraries(${TARGET}-tinyusb PUBLIC board_${BOARD})
+ target_compile_options(${TARGET}-tinyusb PRIVATE
+ -Wno-error=strict-prototypes
+ )
+
+ # Link dependencies
+ target_link_libraries(${TARGET} PUBLIC board_${BOARD} ${TARGET}-tinyusb)
+
+ # Flashing
+ family_flash_jlink(${TARGET})
+ family_flash_msdk(${TARGET})
+endfunction()
+
+# Add flash msdk target
+function(family_flash_msdk TARGET)
+ set(MAXIM_PATH "$ENV{MAXIM_PATH}")
+
+ add_custom_target(${TARGET}-msdk
+ DEPENDS ${TARGET}
+ COMMAND ${MAXIM_PATH}/Tools/OpenOCD/openocd -s ${MAXIM_PATH}/Tools/OpenOCD/scripts
+ -f interface/cmsis-dap.cfg -f target/max32690.cfg
+ -c "program $ verify; init; reset; exit"
+ VERBATIM
+ )
+endfunction()
diff --git a/hw/bsp/max32690/family.mk b/hw/bsp/max32690/family.mk
new file mode 100644
index 000000000..d4df8ef2f
--- /dev/null
+++ b/hw/bsp/max32690/family.mk
@@ -0,0 +1,101 @@
+DEPS_SUBMODULES += lib/CMSIS_5 hw/mcu/analog/max32
+
+# Important locations in the hw support for MCU
+MAX32_CMSIS = hw/mcu/analog/max32/Libraries/CMSIS
+MAX32_PERIPH = hw/mcu/analog/max32/Libraries/PeriphDrivers
+
+# Add any board specific make rules
+include $(TOP)/$(BOARD_PATH)/board.mk
+
+CPU_CORE ?= cortex-m4
+PORT ?= 0
+
+# GCC
+SRC_S_GCC += $(MAX32_CMSIS)/Device/Maxim/MAX32690/Source/GCC/startup_max32690.S
+LD_FILE = $(FAMILY_PATH)/max32690.ld
+
+# --------------
+# Compiler Flags
+# --------------
+# Flags for the MAX32690 SDK
+CFLAGS += -DTARGET=MAX32690 \
+ -DTARGET_REV=0x4131 \
+ -DMXC_ASSERT_ENABLE \
+ -DMAX32690 \
+ -DFLASH_ORIGIN=0x10000000 \
+ -DFLASH_SIZE=0x340000 \
+ -DSRAM_ORIGIN=0x20000000 \
+ -DSRAM_SIZE=0x100000 \
+ -DIAR_PRAGMAS=0
+
+# Flags for TUSB features
+CFLAGS += \
+ -DCFG_TUSB_MCU=OPT_MCU_MAX32690 \
+ -DBOARD_TUD_MAX_SPEED=OPT_MODE_HIGH_SPEED
+
+# mcu driver cause following warnings
+CFLAGS += -Wno-error=unused-parameter \
+ -Wno-error=strict-prototypes \
+ -Wno-error=old-style-declaration \
+ -Wno-error=sign-compare \
+ -Wno-error=cast-qual \
+ -Wno-lto-type-mismatch
+
+LDFLAGS_GCC += -nostartfiles --specs=nosys.specs --specs=nano.specs
+
+# For flash-jlink target
+JLINK_DEVICE = max32690
+
+# flash target using Jlink by default
+flash: flash-jlink
+
+# Optional flash option when running within an installed MSDK to use OpenOCD
+# Mainline OpenOCD does not yet have the MAX32's flash algorithm integrated.
+# If the MSDK is installed, flash-msdk can be run to utilize the the modified
+# openocd with the algorithms
+MAXIM_PATH := $(subst \,/,$(MAXIM_PATH))
+flash-msdk: $(BUILD)/$(PROJECT).elf
+ $(MAXIM_PATH)/Tools/OpenOCD/openocd -s $(MAXIM_PATH)/Tools/OpenOCD/scripts \
+ -f interface/cmsis-dap.cfg -f target/max32690.cfg \
+ -c "program $(BUILD)/$(PROJECT).elf verify; init; reset; exit"
+
+# -----------------
+# Sources & Include
+# -----------------
+PERIPH_SRC = $(TOP)/$(MAX32_PERIPH)/Source
+SRC_C += \
+ src/portable/mentor/musb/dcd_musb.c \
+ $(MAX32_CMSIS)/Device/Maxim/MAX32690/Source/heap.c \
+ $(MAX32_CMSIS)/Device/Maxim/MAX32690/Source/system_max32690.c \
+ $(PERIPH_SRC)/SYS/mxc_assert.c \
+ $(PERIPH_SRC)/SYS/mxc_delay.c \
+ $(PERIPH_SRC)/SYS/mxc_lock.c \
+ $(PERIPH_SRC)/SYS/nvic_table.c \
+ $(PERIPH_SRC)/SYS/pins_me18.c \
+ $(PERIPH_SRC)/SYS/sys_me18.c \
+ $(PERIPH_SRC)/CTB/ctb_me18.c \
+ $(PERIPH_SRC)/CTB/ctb_reva.c \
+ $(PERIPH_SRC)/CTB/ctb_common.c \
+ $(PERIPH_SRC)/FLC/flc_common.c \
+ $(PERIPH_SRC)/FLC/flc_me18.c \
+ $(PERIPH_SRC)/FLC/flc_reva.c \
+ $(PERIPH_SRC)/GPIO/gpio_common.c \
+ $(PERIPH_SRC)/GPIO/gpio_me18.c \
+ $(PERIPH_SRC)/GPIO/gpio_reva.c \
+ $(PERIPH_SRC)/ICC/icc_me18.c \
+ $(PERIPH_SRC)/ICC/icc_reva.c \
+ $(PERIPH_SRC)/UART/uart_common.c \
+ $(PERIPH_SRC)/UART/uart_me18.c \
+ $(PERIPH_SRC)/UART/uart_revb.c \
+
+INC += \
+ $(TOP)/$(BOARD_PATH) \
+ $(TOP)/$(MAX32_CMSIS)/Include \
+ $(TOP)/$(MAX32_CMSIS)/Device/Maxim/MAX32690/Include \
+ $(TOP)/$(MAX32_PERIPH)/Include/MAX32690 \
+ $(PERIPH_SRC)/SYS \
+ $(PERIPH_SRC)/GPIO \
+ $(PERIPH_SRC)/CTB \
+ $(PERIPH_SRC)/ICC \
+ $(PERIPH_SRC)/FLC \
+ $(PERIPH_SRC)/UART
diff --git a/hw/bsp/max32690/max32690.ld b/hw/bsp/max32690/max32690.ld
new file mode 100644
index 000000000..64b906a54
--- /dev/null
+++ b/hw/bsp/max32690/max32690.ld
@@ -0,0 +1,164 @@
+MEMORY {
+ ROM (rx) : ORIGIN = 0x00000000, LENGTH = 0x00020000 /* 128kB ROM */
+ FLASH (rx) : ORIGIN = 0x10000000, LENGTH = 0x00340000
+ SRAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00100000
+
+ /*
+ * Note that CS0/CS1 address mappings may be reversed using MXC_HPC->mbr0 and ->mbr1
+ * The following mappings are selected for simplicity
+ */
+ HPB_CS0 (rwx) : ORIGIN = 0x60000000, LENGTH = 0x10000000 /* External Hyperbus/Xccelabus chip select 0 */
+ HPB_CS1 (rwx) : ORIGIN = 0x70000000, LENGTH = 0x10000000 /* External Hyperbus/Xccelabus chip select 1 */
+}
+
+SECTIONS {
+ .rom :
+ {
+ KEEP(*(.rom_vector))
+ *(.rom_handlers*)
+ } > ROM
+
+ .text :
+ {
+ _text = .;
+ KEEP(*(.isr_vector))
+ EXCLUDE_FILE (*riscv.o) *(.text*) /* program code, exclude RISCV code */
+ *(.rodata*) /* read-only data: "const" */
+
+ KEEP(*(.init))
+ KEEP(*(.fini))
+
+ /* .ctors */
+ *crtbegin.o(.ctors)
+ *crtbegin?.o(.ctors)
+ *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
+ *(SORT(.ctors.*))
+ *(.ctors)
+
+ /* .dtors */
+ *crtbegin.o(.dtors)
+ *crtbegin?.o(.dtors)
+ *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
+ *(SORT(.dtors.*))
+ *(.dtors)
+
+ /* C++ Exception handling */
+ KEEP(*(.eh_frame*))
+ _etext = .;
+ } > FLASH
+
+ .ARM.extab :
+ {
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ } > FLASH
+
+ /* These sections allow code to be compiled/linked for HPB addresses, but reside in
+ * flash until copied by code to the external HPB flash device
+ */
+ .hpb_cs0_section :
+ {
+ __hpb_cs0_start = ABSOLUTE(.);
+ KEEP(*(.hpb_cs0_section*))
+ } > HPB_CS0 AT>FLASH
+
+ __load_start_hpb_cs0 = LOADADDR(.hpb_cs0_section);
+ __load_length_hpb_cs0 = SIZEOF(.hpb_cs0_section);
+
+ .hpb_cs1_section :
+ {
+ __hpb_cs1_start = ABSOLUTE(.);
+ KEEP(*(.hpb_cs1_section*))
+ } > HPB_CS1 AT>FLASH
+
+ __load_start_hpb_cs1 = LOADADDR(.hpb_cs1_section);
+ __load_length_hpb_cs1 = SIZEOF(.hpb_cs1_section);
+
+ /* Binary import */
+ .bin_storage :
+ {
+ FILL(0xFF)
+ _bin_start_ = .;
+ KEEP(*(.bin_storage_img))
+ _bin_end_ = .;
+ . = ALIGN(4);
+ } > FLASH
+
+ /* it's used for C++ exception handling */
+ /* we need to keep this to avoid overlapping */
+ .ARM.exidx :
+ {
+ __exidx_start = .;
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ __exidx_end = .;
+ } > FLASH
+
+ .data :
+ {
+ _data = ALIGN(., 4);
+ *(vtable)
+ *(.data*) /*read-write initialized data: initialized global variable*/
+
+ /* 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 = .);
+
+ /* Run the flash programming functions from SRAM */
+ *(.flashprog)
+
+ _edata = ALIGN(., 4);
+ } > SRAM AT>FLASH
+ __load_data = LOADADDR(.data);
+
+ .bss :
+ {
+ . = ALIGN(4);
+ _bss = .;
+ *(.bss*) /*read-write zero initialized data: uninitialized global variable*/
+ *(COMMON)
+ _ebss = ALIGN(., 4);
+ } > SRAM
+
+ /* Set stack top to end of RAM, and stack limit move down by
+ * size of stack_dummy section */
+ __StackTop = ORIGIN(SRAM) + LENGTH(SRAM);
+ __StackLimit = __StackTop - SIZEOF(.stack_dummy);
+
+ /* .stack_dummy section doesn't contains any symbols. It is only
+ * used for linker to calculate size of stack sections, and assign
+ * values to stack symbols later */
+ .stack_dummy (COPY):
+ {
+ *(.stack*)
+ } > SRAM
+
+ .heap (COPY):
+ {
+ . = ALIGN(4);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ *(.heap*)
+ __HeapLimit = ABSOLUTE(__StackLimit);
+ } > SRAM
+
+ PROVIDE(__stack = __StackTop);
+
+ /* Check if data + heap + stack exceeds RAM limit */
+ ASSERT(__StackLimit >= _ebss, "region RAM overflowed with stack")
+}
diff --git a/hw/bsp/max78002/FreeRTOSConfig/FreeRTOSConfig.h b/hw/bsp/max78002/FreeRTOSConfig/FreeRTOSConfig.h
new file mode 100644
index 000000000..e5a76af85
--- /dev/null
+++ b/hw/bsp/max78002/FreeRTOSConfig/FreeRTOSConfig.h
@@ -0,0 +1,149 @@
+/*
+ * FreeRTOS Kernel V10.0.0
+ * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. 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. If you wish to use our Amazon
+ * FreeRTOS name, please do so in a fair use way that does not cause confusion.
+ *
+ * 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 THE AUTHORS OR
+ * COPYRIGHT HOLDERS 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.
+ *
+ * http://www.FreeRTOS.org
+ * http://aws.amazon.com/freertos
+ *
+ * 1 tab == 4 spaces!
+ */
+
+
+#ifndef FREERTOS_CONFIG_H
+#define FREERTOS_CONFIG_H
+
+/*-----------------------------------------------------------
+ * Application specific definitions.
+ *
+ * These definitions should be adjusted for your particular hardware and
+ * application requirements.
+ *
+ * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
+ * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
+ *
+ * See http://www.freertos.org/a00110.html.
+ *----------------------------------------------------------*/
+
+// skip if included from IAR assembler
+#ifndef __IASMARM__
+ #include "mxc_device.h"
+#endif
+
+/* Cortex M23/M33 port configuration. */
+#define configENABLE_MPU 0
+#define configENABLE_FPU 1
+#define configENABLE_TRUSTZONE 0
+#define configMINIMAL_SECURE_STACK_SIZE (1024)
+
+#define configUSE_PREEMPTION 1
+#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
+#define configCPU_CLOCK_HZ SystemCoreClock
+#define configTICK_RATE_HZ ( 1000 )
+#define configMAX_PRIORITIES ( 5 )
+#define configMINIMAL_STACK_SIZE ( 128 )
+#define configTOTAL_HEAP_SIZE ( configSUPPORT_DYNAMIC_ALLOCATION*4*1024 )
+#define configMAX_TASK_NAME_LEN 16
+#define configUSE_16_BIT_TICKS 0
+#define configIDLE_SHOULD_YIELD 1
+#define configUSE_MUTEXES 1
+#define configUSE_RECURSIVE_MUTEXES 1
+#define configUSE_COUNTING_SEMAPHORES 1
+#define configQUEUE_REGISTRY_SIZE 4
+#define configUSE_QUEUE_SETS 0
+#define configUSE_TIME_SLICING 0
+#define configUSE_NEWLIB_REENTRANT 0
+#define configENABLE_BACKWARD_COMPATIBILITY 1
+#define configSTACK_ALLOCATION_FROM_SEPARATE_HEAP 0
+
+#define configSUPPORT_STATIC_ALLOCATION 1
+#define configSUPPORT_DYNAMIC_ALLOCATION 0
+
+/* Hook function related definitions. */
+#define configUSE_IDLE_HOOK 0
+#define configUSE_TICK_HOOK 0
+#define configUSE_MALLOC_FAILED_HOOK 0 // cause nested extern warning
+#define configCHECK_FOR_STACK_OVERFLOW 2
+#define configCHECK_HANDLER_INSTALLATION 0
+
+/* Run time and task stats gathering related definitions. */
+#define configGENERATE_RUN_TIME_STATS 0
+#define configRECORD_STACK_HIGH_ADDRESS 1
+#define configUSE_TRACE_FACILITY 1 // legacy trace
+#define configUSE_STATS_FORMATTING_FUNCTIONS 0
+
+/* Co-routine definitions. */
+#define configUSE_CO_ROUTINES 0
+#define configMAX_CO_ROUTINE_PRIORITIES 2
+
+/* Software timer related definitions. */
+#define configUSE_TIMERS 1
+#define configTIMER_TASK_PRIORITY (configMAX_PRIORITIES-2)
+#define configTIMER_QUEUE_LENGTH 32
+#define configTIMER_TASK_STACK_DEPTH configMINIMAL_STACK_SIZE
+
+/* Optional functions - most linkers will remove unused functions anyway. */
+#define INCLUDE_vTaskPrioritySet 0
+#define INCLUDE_uxTaskPriorityGet 0
+#define INCLUDE_vTaskDelete 0
+#define INCLUDE_vTaskSuspend 1 // required for queue, semaphore, mutex to be blocked indefinitely with portMAX_DELAY
+#define INCLUDE_xResumeFromISR 0
+#define INCLUDE_vTaskDelayUntil 1
+#define INCLUDE_vTaskDelay 1
+#define INCLUDE_xTaskGetSchedulerState 0
+#define INCLUDE_xTaskGetCurrentTaskHandle 1
+#define INCLUDE_uxTaskGetStackHighWaterMark 0
+#define INCLUDE_xTaskGetIdleTaskHandle 0
+#define INCLUDE_xTimerGetTimerDaemonTaskHandle 0
+#define INCLUDE_pcTaskGetTaskName 0
+#define INCLUDE_eTaskGetState 0
+#define INCLUDE_xEventGroupSetBitFromISR 0
+#define INCLUDE_xTimerPendFunctionCall 0
+
+/* FreeRTOS hooks to NVIC vectors */
+#define xPortPendSVHandler PendSV_Handler
+#define xPortSysTickHandler SysTick_Handler
+#define vPortSVCHandler SVC_Handler
+
+//--------------------------------------------------------------------+
+// Interrupt nesting behavior configuration.
+//--------------------------------------------------------------------+
+
+// For Cortex-M specific: __NVIC_PRIO_BITS is defined in mcu header
+#define configPRIO_BITS __NVIC_PRIO_BITS
+
+/* The lowest interrupt priority that can be used in a call to a "set priority" function. */
+#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY ((1<-jlink` target for CMake.
+
+The Evaluation Kit is shipped with a CMSIS-DAP compatible debug probe. However,
+at the time of writing, the necessary flashing algorithms for OpenOCD have not
+yet been incorporated into the OpenOCD master branch. To utilize the provided
+debug probes, please install the bundled MSDK package which includes the
+appropriate OpenOCD modifications. To leverage this OpenOCD instance, run the
+`flash-msdk` Makefile rule, or `-msdk` CMake target.
diff --git a/hw/bsp/max78002/boards/max78002evkit/board.cmake b/hw/bsp/max78002/boards/max78002evkit/board.cmake
new file mode 100644
index 000000000..9dc6962eb
--- /dev/null
+++ b/hw/bsp/max78002/boards/max78002evkit/board.cmake
@@ -0,0 +1 @@
+# Nothing to be done at the board level
diff --git a/hw/bsp/max78002/boards/max78002evkit/board.h b/hw/bsp/max78002/boards/max78002evkit/board.h
new file mode 100644
index 000000000..f8102c394
--- /dev/null
+++ b/hw/bsp/max78002/boards/max78002evkit/board.h
@@ -0,0 +1,58 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2024, Brent Kowal (Analog Devices, Inc)
+ *
+ * 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 THE
+ * AUTHORS OR COPYRIGHT HOLDERS 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.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#include "gpio.h"
+#include "mxc_sys.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// LED
+#define LED_PORT MXC_GPIO2
+#define LED_PIN MXC_GPIO_PIN_4
+#define LED_VDDIO MXC_GPIO_VSSEL_VDDIOH
+#define LED_STATE_ON 1
+
+// Button
+#define BUTTON_PORT MXC_GPIO2
+#define BUTTON_PIN MXC_GPIO_PIN_6
+#define BUTTON_PULL MXC_GPIO_PAD_PULL_UP
+#define BUTTON_STATE_ACTIVE 0
+
+// UART Enable for EvKit's Integrated FTDI Adapter. Pin Mux handled by the HAL
+#define UART_NUM 0
+#define UART_PORT MXC_GPIO0
+#define UART_VDDIO_BITS 0xF
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/hw/bsp/max78002/boards/max78002evkit/board.mk b/hw/bsp/max78002/boards/max78002evkit/board.mk
new file mode 100644
index 000000000..a813a5327
--- /dev/null
+++ b/hw/bsp/max78002/boards/max78002evkit/board.mk
@@ -0,0 +1 @@
+# No specific build requirements for the board.
diff --git a/hw/bsp/max78002/family.c b/hw/bsp/max78002/family.c
new file mode 100644
index 000000000..8d51f141c
--- /dev/null
+++ b/hw/bsp/max78002/family.c
@@ -0,0 +1,169 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2024 Brent Kowal (Analog Devices, Inc)
+ *
+ * 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 THE
+ * AUTHORS OR COPYRIGHT HOLDERS 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.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wstrict-prototypes" // _mxc_crit_get_state()
+#endif
+
+#include "gpio.h"
+#include "mxc_sys.h"
+#include "mcr_regs.h"
+#include "mxc_device.h"
+#include "uart.h"
+
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
+
+#include "board.h"
+#include "bsp/board_api.h"
+
+//--------------------------------------------------------------------+
+// Forward USB interrupt events to TinyUSB IRQ Handler
+//--------------------------------------------------------------------+
+void USB_IRQHandler(void) {
+ tud_int_handler(0);
+}
+
+//--------------------------------------------------------------------+
+// MACRO TYPEDEF CONSTANT ENUM
+//--------------------------------------------------------------------+
+mxc_uart_regs_t *ConsoleUart = MXC_UART_GET_UART(UART_NUM);
+
+void board_init(void) {
+#if CFG_TUSB_OS == OPT_OS_NONE
+ // 1ms tick timer
+ SysTick_Config(SystemCoreClock / 1000);
+#elif CFG_TUSB_OS == OPT_OS_FREERTOS
+ // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
+ NVIC_SetPriority(USB_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY);
+#endif
+ mxc_gpio_cfg_t gpioConfig;
+
+ // LED
+ gpioConfig.drvstr = MXC_GPIO_DRVSTR_0;
+ gpioConfig.func = MXC_GPIO_FUNC_OUT;
+ gpioConfig.mask = LED_PIN;
+ gpioConfig.pad = MXC_GPIO_PAD_NONE;
+ gpioConfig.port = LED_PORT;
+ gpioConfig.vssel = LED_VDDIO;
+ MXC_GPIO_Config(&gpioConfig);
+ board_led_write(false);
+
+ // Button
+ gpioConfig.drvstr = MXC_GPIO_DRVSTR_0;
+ gpioConfig.func = MXC_GPIO_FUNC_IN;
+ gpioConfig.mask = BUTTON_PIN;
+ gpioConfig.pad = BUTTON_PULL;
+ gpioConfig.port = BUTTON_PORT;
+ gpioConfig.vssel = MXC_GPIO_VSSEL_VDDIO;
+ MXC_GPIO_Config(&gpioConfig);
+
+ // UART
+ MXC_UART_Init(ConsoleUart, CFG_BOARD_UART_BAUDRATE, MXC_UART_IBRO_CLK);
+ UART_PORT->vssel |= UART_VDDIO_BITS; //Set necessary bits to 3.3V
+
+ //USB
+ MXC_MCR->ldoctrl |= MXC_F_MCR_LDOCTRL_0P9EN;
+ MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_USB);
+}
+
+//--------------------------------------------------------------------+
+// Board porting API
+//--------------------------------------------------------------------+
+
+void board_led_write(bool state) {
+#if LED_STATE_ON
+ state = !state;
+#endif
+ if (state) {
+ MXC_GPIO_OutClr(LED_PORT, LED_PIN);
+ } else {
+ MXC_GPIO_OutSet(LED_PORT, LED_PIN);
+ }
+}
+
+uint32_t board_button_read(void) {
+ uint32_t state = MXC_GPIO_InGet(BUTTON_PORT, BUTTON_PIN) ? 1 : 0;
+ return BUTTON_STATE_ACTIVE == state;
+}
+
+size_t board_get_unique_id(uint8_t id[], size_t max_len) {
+ uint8_t hw_id[MXC_SYS_USN_CHECKSUM_LEN];//USN Buffer
+ /* All other 2nd parameter is optional checksum buffer */
+ MXC_SYS_GetUSN(hw_id, NULL);
+
+ size_t act_len = TU_MIN(max_len, MXC_SYS_USN_LEN);
+ memcpy(id, hw_id, act_len);
+ return act_len;
+}
+
+int board_uart_read(uint8_t *buf, int len) {
+ int uart_val;
+ int act_len = 0;
+
+ while (act_len < len) {
+ if ((uart_val = MXC_UART_ReadCharacterRaw(ConsoleUart)) == E_UNDERFLOW) {
+ break;
+ } else {
+ *buf++ = (uint8_t) uart_val;
+ act_len++;
+ }
+ }
+ return act_len;
+}
+
+int board_uart_write(void const *buf, int len) {
+ int act_len = 0;
+ const uint8_t *ch_ptr = (const uint8_t *) buf;
+ while (act_len < len) {
+ MXC_UART_WriteCharacter(ConsoleUart, *ch_ptr++);
+ act_len++;
+ }
+ return len;
+}
+
+#if CFG_TUSB_OS == OPT_OS_NONE
+volatile uint32_t system_ticks = 0;
+
+void SysTick_Handler(void) {
+ system_ticks++;
+}
+
+uint32_t board_millis(void) {
+ return system_ticks;
+}
+#endif
+
+void HardFault_Handler(void) {
+ __asm("BKPT #0\n");
+}
+
+// Required by __libc_init_array in startup code if we are compiling using
+// -nostdlib/-nostartfiles.
+void _init(void) {
+}
diff --git a/hw/bsp/max78002/family.cmake b/hw/bsp/max78002/family.cmake
new file mode 100644
index 000000000..446930bd8
--- /dev/null
+++ b/hw/bsp/max78002/family.cmake
@@ -0,0 +1,166 @@
+include_guard()
+
+set(MAX32_PERIPH ${TOP}/hw/mcu/analog/max32/Libraries/PeriphDrivers)
+set(MAX32_CMSIS ${TOP}/hw/mcu/analog/max32/Libraries/CMSIS)
+set(CMSIS_5 ${TOP}/lib/CMSIS_5)
+
+# include board specific
+include(${CMAKE_CURRENT_LIST_DIR}/boards/${BOARD}/board.cmake)
+
+# Get the linker file from current location (family)
+set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/max78002.ld)
+set(LD_FILE_Clang ${LD_FILE_GNU})
+
+# toolchain set up
+set(CMAKE_SYSTEM_PROCESSOR cortex-m4 CACHE INTERNAL "System Processor")
+set(CMAKE_TOOLCHAIN_FILE ${TOP}/examples/build_system/cmake/toolchain/arm_${TOOLCHAIN}.cmake)
+set(JLINK_DEVICE max78000)
+
+set(FAMILY_MCUS MAX78002 CACHE INTERNAL "")
+
+function(update_board TARGET)
+ target_compile_definitions(${TARGET} PUBLIC
+ TARGET=MAX78002
+ TARGET_REV=0x4131
+ MXC_ASSERT_ENABLE
+ MAX78002
+ IAR_PRAGMAS=0
+ CFG_TUSB_MCU=OPT_MCU_MAX78002
+ BOARD_TUD_MAX_SPEED=OPT_MODE_HIGH_SPEED
+ )
+endfunction()
+
+#------------------------------------
+# BOARD_TARGET
+#------------------------------------
+# only need to be built ONCE for all examples
+function(add_board_target BOARD_TARGET)
+ if (TARGET ${BOARD_TARGET})
+ return()
+ endif ()
+
+ # Startup & Linker script
+ set(STARTUP_FILE_GNU ${MAX32_CMSIS}/Device/Maxim/MAX78002/Source/GCC/startup_max78002.S)
+ set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+
+ set(PERIPH_SRC ${MAX32_PERIPH}/Source)
+ add_library(${BOARD_TARGET} STATIC
+ ${MAX32_CMSIS}/Device/Maxim/MAX78002/Source/heap.c
+ ${MAX32_CMSIS}/Device/Maxim/MAX78002/Source/system_max78002.c
+ ${PERIPH_SRC}/SYS/mxc_assert.c
+ ${PERIPH_SRC}/SYS/mxc_delay.c
+ ${PERIPH_SRC}/SYS/mxc_lock.c
+ ${PERIPH_SRC}/SYS/nvic_table.c
+ ${PERIPH_SRC}/SYS/pins_ai87.c
+ ${PERIPH_SRC}/SYS/sys_ai87.c
+ ${PERIPH_SRC}/AES/aes_ai87.c
+ ${PERIPH_SRC}/AES/aes_revb.c
+ ${PERIPH_SRC}/FLC/flc_common.c
+ ${PERIPH_SRC}/FLC/flc_ai87.c
+ ${PERIPH_SRC}/FLC/flc_reva.c
+ ${PERIPH_SRC}/GPIO/gpio_common.c
+ ${PERIPH_SRC}/GPIO/gpio_ai87.c
+ ${PERIPH_SRC}/GPIO/gpio_reva.c
+ ${PERIPH_SRC}/ICC/icc_ai87.c
+ ${PERIPH_SRC}/ICC/icc_reva.c
+ ${PERIPH_SRC}/TRNG/trng_ai87.c
+ ${PERIPH_SRC}/TRNG/trng_revb.c
+ ${PERIPH_SRC}/UART/uart_common.c
+ ${PERIPH_SRC}/UART/uart_ai87.c
+ ${PERIPH_SRC}/UART/uart_revb.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
+ )
+ target_include_directories(${BOARD_TARGET} PUBLIC
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}
+ ${MAX32_CMSIS}/Include
+ ${MAX32_CMSIS}/Device/Maxim/MAX78002/Include
+ ${MAX32_PERIPH}/Include/MAX78002
+ ${PERIPH_SRC}/SYS
+ ${PERIPH_SRC}/GPIO
+ ${PERIPH_SRC}/AES
+ ${PERIPH_SRC}/TRNG
+ ${PERIPH_SRC}/ICC
+ ${PERIPH_SRC}/FLC
+ ${PERIPH_SRC}/UART
+ )
+
+ target_compile_options(${BOARD_TARGET} PRIVATE
+ -Wno-error=strict-prototypes
+ -Wno-error=redundant-decls
+ )
+ update_board(${BOARD_TARGET})
+
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${BOARD_TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ -nostartfiles
+ --specs=nosys.specs --specs=nano.specs
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${BOARD_TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_Clang}"
+ )
+ endif ()
+endfunction()
+
+
+#------------------------------------
+# Functions
+#------------------------------------
+function(family_configure_example TARGET RTOS)
+ family_configure_common(${TARGET} ${RTOS})
+
+ # Board target
+ add_board_target(board_${BOARD})
+
+ #---------- Port Specific ----------
+ # These files are built for each example since it depends on example's tusb_config.h
+ target_sources(${TARGET} PUBLIC
+ # BSP
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
+ )
+ target_include_directories(${TARGET} PUBLIC
+ # family, hw, board
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
+ )
+
+ target_compile_options(${TARGET} PRIVATE
+ -Wno-error=strict-prototypes
+ -Wno-error=redundant-decls
+ )
+
+
+ # Add TinyUSB target and port source
+ family_add_tinyusb(${TARGET} OPT_MCU_MAX78002 ${RTOS})
+ target_sources(${TARGET}-tinyusb PUBLIC
+ ${TOP}/src/portable/mentor/musb/dcd_musb.c
+ )
+ target_link_libraries(${TARGET}-tinyusb PUBLIC board_${BOARD})
+ target_compile_options(${TARGET}-tinyusb PRIVATE
+ -Wno-error=strict-prototypes
+ -Wno-error=redundant-decls
+ )
+
+ # Link dependencies
+ target_link_libraries(${TARGET} PUBLIC board_${BOARD} ${TARGET}-tinyusb)
+
+ # Flashing
+ family_flash_jlink(${TARGET})
+ family_flash_msdk(${TARGET})
+endfunction()
+
+# Add flash msdk target
+function(family_flash_msdk TARGET)
+ set(MAXIM_PATH "$ENV{MAXIM_PATH}")
+
+ add_custom_target(${TARGET}-msdk
+ DEPENDS ${TARGET}
+ COMMAND ${MAXIM_PATH}/Tools/OpenOCD/openocd -s ${MAXIM_PATH}/Tools/OpenOCD/scripts
+ -f interface/cmsis-dap.cfg -f target/max78002.cfg
+ -c "program $ verify; init; reset; exit"
+ VERBATIM
+ )
+endfunction()
diff --git a/hw/bsp/max78002/family.mk b/hw/bsp/max78002/family.mk
new file mode 100644
index 000000000..997816261
--- /dev/null
+++ b/hw/bsp/max78002/family.mk
@@ -0,0 +1,99 @@
+DEPS_SUBMODULES += lib/CMSIS_5 hw/mcu/analog/max32
+
+# Important locations in the hw support for MCU
+MAX32_CMSIS = hw/mcu/analog/max32/Libraries/CMSIS
+MAX32_PERIPH = hw/mcu/analog/max32/Libraries/PeriphDrivers
+
+# Add any board specific make rules
+include $(TOP)/$(BOARD_PATH)/board.mk
+
+CPU_CORE ?= cortex-m4
+PORT ?= 0
+
+# GCC
+SRC_S_GCC += $(MAX32_CMSIS)/Device/Maxim/MAX78002/Source/GCC/startup_max78002.S
+LD_FILE = $(FAMILY_PATH)/max78002.ld
+
+# --------------
+# Compiler Flags
+# --------------
+# Flags for the MAX78002 SDK
+CFLAGS += -DTARGET=MAX78002 \
+ -DTARGET_REV=0x4131 \
+ -DMXC_ASSERT_ENABLE \
+ -DMAX78002 \
+ -DIAR_PRAGMAS=0
+
+# Flags for TUSB features
+CFLAGS += \
+ -DCFG_TUSB_MCU=OPT_MCU_MAX78002 \
+ -DBOARD_TUD_MAX_SPEED=OPT_MODE_HIGH_SPEED
+
+# mcu driver cause following warnings
+CFLAGS += -Wno-error=redundant-decls \
+ -Wno-error=strict-prototypes \
+ -Wno-error=unused-parameter \
+ -Wno-error=enum-conversion \
+ -Wno-error=sign-compare \
+ -Wno-error=cast-qual
+
+LDFLAGS_GCC += -nostartfiles --specs=nosys.specs --specs=nano.specs
+
+# For flash-jlink target
+JLINK_DEVICE = max78000
+
+# flash target using Jlink by default
+flash: flash-jlink
+
+# Optional flash option when running within an installed MSDK to use OpenOCD
+# Mainline OpenOCD does not yet have the MAX32's flash algorithm integrated.
+# If the MSDK is installed, flash-msdk can be run to utilize the the modified
+# openocd with the algorithms
+MAXIM_PATH := $(subst \,/,$(MAXIM_PATH))
+flash-msdk: $(BUILD)/$(PROJECT).elf
+ $(MAXIM_PATH)/Tools/OpenOCD/openocd -s $(MAXIM_PATH)/Tools/OpenOCD/scripts \
+ -f interface/cmsis-dap.cfg -f target/max78002.cfg \
+ -c "program $(BUILD)/$(PROJECT).elf verify; init; reset; exit"
+
+# -----------------
+# Sources & Include
+# -----------------
+PERIPH_SRC = $(TOP)/$(MAX32_PERIPH)/Source
+SRC_C += \
+ src/portable/mentor/musb/dcd_musb.c \
+ $(MAX32_CMSIS)/Device/Maxim/MAX78002/Source/heap.c \
+ $(MAX32_CMSIS)/Device/Maxim/MAX78002/Source/system_max78002.c \
+ $(PERIPH_SRC)/SYS/mxc_assert.c \
+ $(PERIPH_SRC)/SYS/mxc_delay.c \
+ $(PERIPH_SRC)/SYS/mxc_lock.c \
+ $(PERIPH_SRC)/SYS/nvic_table.c \
+ $(PERIPH_SRC)/SYS/pins_ai87.c \
+ $(PERIPH_SRC)/SYS/sys_ai87.c \
+ $(PERIPH_SRC)/AES/aes_ai87.c \
+ $(PERIPH_SRC)/AES/aes_revb.c \
+ $(PERIPH_SRC)/FLC/flc_common.c \
+ $(PERIPH_SRC)/FLC/flc_ai87.c \
+ $(PERIPH_SRC)/FLC/flc_reva.c \
+ $(PERIPH_SRC)/GPIO/gpio_common.c \
+ $(PERIPH_SRC)/GPIO/gpio_ai87.c \
+ $(PERIPH_SRC)/GPIO/gpio_reva.c \
+ $(PERIPH_SRC)/ICC/icc_ai87.c \
+ $(PERIPH_SRC)/ICC/icc_reva.c \
+ $(PERIPH_SRC)/TRNG/trng_ai87.c \
+ $(PERIPH_SRC)/TRNG/trng_revb.c \
+ $(PERIPH_SRC)/UART/uart_common.c \
+ $(PERIPH_SRC)/UART/uart_ai87.c \
+ $(PERIPH_SRC)/UART/uart_revb.c \
+
+INC += \
+ $(TOP)/$(BOARD_PATH) \
+ $(TOP)/$(MAX32_CMSIS)/Include \
+ $(TOP)/$(MAX32_CMSIS)/Device/Maxim/MAX78002/Include \
+ $(TOP)/$(MAX32_PERIPH)/Include/MAX78002 \
+ $(PERIPH_SRC)/SYS \
+ $(PERIPH_SRC)/GPIO \
+ $(PERIPH_SRC)/AES \
+ $(PERIPH_SRC)/ICC \
+ $(PERIPH_SRC)/FLC \
+ $(PERIPH_SRC)/TRNG \
+ $(PERIPH_SRC)/UART
diff --git a/hw/bsp/max78002/max78002.ld b/hw/bsp/max78002/max78002.ld
new file mode 100644
index 000000000..e5c4866ee
--- /dev/null
+++ b/hw/bsp/max78002/max78002.ld
@@ -0,0 +1,182 @@
+MEMORY {
+ ROM (rx) : ORIGIN = 0x00000000, LENGTH = 0x00010000 /* 64 kB ROM */
+ FLASH (rx) : ORIGIN = 0x10000000, LENGTH = 0x00280000 /* 2.5 MB Flash */
+ SRAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00060000 /* 384 kB SRAM */
+ /*CSI2 (rwx) : ORIGIN = 0x2001F000, LENGTH = 0x00001000 4096 B CSI2 Buffer */
+}
+
+SECTIONS {
+ .rom :
+ {
+ KEEP(*(.rom_vector))
+ *(.rom_handlers*)
+ } > ROM
+
+ .text :
+ {
+ _text = .;
+ KEEP(*(.isr_vector))
+ EXCLUDE_FILE (*riscv.o) *(.text*) /* Program code (exclude RISCV code) */
+ *(.rodata*) /* read-only data: "const" */
+
+ KEEP(*(.init))
+ KEEP(*(.fini))
+
+ /* .ctors */
+ *crtbegin.o(.ctors)
+ *crtbegin?.o(.ctors)
+ *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
+ *(SORT(.ctors.*))
+ *(.ctors)
+
+ /* .dtors */
+ *crtbegin.o(.dtors)
+ *crtbegin?.o(.dtors)
+ *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
+ *(SORT(.dtors.*))
+ *(.dtors)
+
+ /* C++ Exception handling */
+ KEEP(*(.eh_frame*))
+ _etext = .;
+ } > FLASH
+
+ .ARM.extab :
+ {
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ } > FLASH
+
+ /* Binary import */
+ .bin_storage :
+ {
+ FILL(0xFF)
+ _bin_start_ = .;
+ KEEP(*(.bin_storage_img))
+ _bin_end_ = .;
+ . = ALIGN(4);
+ } > FLASH
+
+ .rom_code :
+ {
+ . = ALIGN(16);
+ _sran_code = .;
+ *(.rom_code_section)
+ _esran_code = .;
+ } > ROM
+
+ .flash_code :
+ {
+ . = ALIGN(16);
+ _sran_code = .;
+ *(.flash_code_section)
+ _esran_code = .;
+ } > FLASH
+
+ .sram_code :
+ {
+ . = ALIGN(16);
+ _sran_code = .;
+ *(.sram_code_section)
+ _esran_code = .;
+ } > SRAM
+
+ /* it's used for C++ exception handling */
+ /* we need to keep this to avoid overlapping */
+ .ARM.exidx :
+ {
+ __exidx_start = .;
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ __exidx_end = .;
+ } > FLASH
+
+ .data :
+ {
+ _data = ALIGN(., 4);
+ _csi = . + 0x20000;
+ *(vtable)
+ *(.data*) /*read-write initialized data: initialized global variable*/
+
+
+ /* 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);
+
+ .bss :
+ {
+ . = ALIGN(4);
+ _bss = .;
+ *(.bss*) /*read-write zero initialized data: uninitialized global variable*/
+ *(COMMON)
+ _ebss = ALIGN(., 4);
+ } > SRAM
+
+ .shared :
+ {
+ . = ALIGN(4);
+ _shared = .;
+ *(.mailbox*)
+ . = ALIGN(4);
+ *(.shared*) /*read-write zero initialized data: uninitialized global variable*/
+ _eshared = ALIGN(., 4);
+ } > SRAM
+ __shared_data = LOADADDR(.shared);
+
+ /* Set stack top to end of RAM, and stack limit move down by
+ * size of stack_dummy section */
+ __StackTop = ORIGIN(SRAM) + LENGTH(SRAM);
+ __StackLimit = __StackTop - SIZEOF(.stack_dummy);
+
+ /* .stack_dummy section doesn't contains any symbols. It is only
+ * used for linker to calculate size of stack sections, and assign
+ * values to stack symbols later */
+ .stack_dummy (COPY):
+ {
+ *(.stack*)
+ } > SRAM
+
+ .heap (COPY):
+ {
+ . = ALIGN(4);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ *(.heap*)
+ __HeapLimit = ABSOLUTE(__StackLimit);
+ } > SRAM
+
+ PROVIDE(__stack = __StackTop);
+
+ /* Check if data + heap + stack exceeds RAM limit */
+ ASSERT(__StackLimit >= _ebss, "region RAM overflowed with stack")
+
+ /* Section used by RISCV loader projects. See RISCV_LOAD documentation in the build system. */
+ .riscv_flash :
+ {
+ /* Align address to mod 256 with a small offset. This is required to match the flash page size.*/
+ . = ALIGN(256); /* ALIGN operatator is used here. Note that (. & 0x1FFFFF00) was used in the past, but a strange bug was seen on Windows where the & did not behave as expected.*/
+ . += 0x100;
+ _riscv_boot = .;
+ KEEP(*riscv.o (.text*))
+ } > FLASH
+}
diff --git a/hw/bsp/tm4c/boards/ek_tm4c123gxl/board.cmake b/hw/bsp/tm4c/boards/ek_tm4c123gxl/board.cmake
index a86b5c0e5..b8df9f189 100644
--- a/hw/bsp/tm4c/boards/ek_tm4c123gxl/board.cmake
+++ b/hw/bsp/tm4c/boards/ek_tm4c123gxl/board.cmake
@@ -4,6 +4,7 @@ set(JLINK_DEVICE TM4C123GH6PM)
set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/tm4c123.ld)
set(OPENOCD_OPTION "-f board/ti_ek-tm4c123gxl.cfg")
+set(UNIFLASH_OPTION "-c ${CMAKE_CURRENT_LIST_DIR}/${BOARD}.ccxml -r 1")
function(update_board TARGET)
target_compile_definitions(${TARGET} PUBLIC
diff --git a/hw/bsp/tm4c/boards/ek_tm4c123gxl/board.mk b/hw/bsp/tm4c/boards/ek_tm4c123gxl/board.mk
index a3e8df62c..b3ded8007 100644
--- a/hw/bsp/tm4c/boards/ek_tm4c123gxl/board.mk
+++ b/hw/bsp/tm4c/boards/ek_tm4c123gxl/board.mk
@@ -10,4 +10,6 @@ JLINK_DEVICE = TM4C123GH6PM
# flash using openocd
OPENOCD_OPTION = -f board/ti_ek-tm4c123gxl.cfg
+UNIFLASH_OPTION = -c ${TOP}/${BOARD_PATH}/${BOARD}.ccxml -r 1
+
flash: flash-openocd
diff --git a/hw/bsp/tm4c/boards/ek_tm4c123gxl/ek_tm4c123gxl.ccxml b/hw/bsp/tm4c/boards/ek_tm4c123gxl/ek_tm4c123gxl.ccxml
new file mode 100644
index 000000000..426a6f368
--- /dev/null
+++ b/hw/bsp/tm4c/boards/ek_tm4c123gxl/ek_tm4c123gxl.ccxml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/hw/bsp/tm4c/family.c b/hw/bsp/tm4c/family.c
index 738bc3fa0..5e1f6d3ff 100644
--- a/hw/bsp/tm4c/family.c
+++ b/hw/bsp/tm4c/family.c
@@ -5,8 +5,7 @@
//--------------------------------------------------------------------+
// Forward USB interrupt events to TinyUSB IRQ Handler
//--------------------------------------------------------------------+
-void USB0_Handler(void)
-{
+void USB0_Handler(void) {
#if CFG_TUH_ENABLED
tuh_int_handler(0, true);
#endif
@@ -20,8 +19,7 @@ void USB0_Handler(void)
// MACRO TYPEDEF CONSTANT ENUM
//--------------------------------------------------------------------+
-static void board_uart_init (void)
-{
+static void board_uart_init(void) {
SYSCTL->RCGCUART |= (1 << 0); // Enable the clock to UART0
SYSCTL->RCGCGPIO |= (1 << 0); // Enable the clock to GPIOA
@@ -42,13 +40,12 @@ static void board_uart_init (void)
UART0->CTL = (1 << 0) | (1 << 8) | (1 << 9); // UART0 Enable, Transmit Enable, Receive Enable
}
-static void initialize_board_led (GPIOA_Type *port, uint8_t PinMsk, uint8_t dirmsk)
-{
+static void initialize_board_led(GPIOA_Type* port, uint8_t PinMsk, uint8_t dirmsk) {
/* Enable PortF Clock */
SYSCTL->RCGCGPIO |= (1 << 5);
/* Let the clock stabilize */
- while ( !((SYSCTL->PRGPIO) & (1 << 5)) ) {}
+ while (!((SYSCTL->PRGPIO) & (1 << 5))) {}
/* Port Digital Enable */
port->DEN |= PinMsk;
@@ -57,46 +54,33 @@ static void initialize_board_led (GPIOA_Type *port, uint8_t PinMsk, uint8_t dirm
port->DIR = dirmsk;
}
-static void board_switch_init (void)
-{
- GPIOF->DIR &= ~(1 << BOARD_BTN);
- GPIOF->PUR |= (1 << BOARD_BTN);
- GPIOF->DEN |= (1 << BOARD_BTN);
-}
-
-static void WriteGPIOPin (GPIOA_Type *port, uint8_t PinMsk, bool state)
-{
- if ( state )
- {
+static void WriteGPIOPin(GPIOA_Type* port, uint8_t PinMsk, bool state) {
+ if (state) {
port->DATA |= PinMsk;
- }
- else
- {
+ } else {
port->DATA &= ~(PinMsk);
}
}
-static uint32_t ReadGPIOPin (GPIOA_Type *port, uint8_t pinMsk)
-{
+static uint32_t ReadGPIOPin(GPIOA_Type* port, uint8_t pinMsk) {
return (port->DATA & pinMsk);
}
-void board_init (void)
-{
+void board_init(void) {
SystemCoreClockUpdate();
#if CFG_TUSB_OS == OPT_OS_NONE
// 1ms tick timer
SysTick_Config(SystemCoreClock / 1000);
#elif CFG_TUSB_OS == OPT_OS_FREERTOS
- // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
- NVIC_SetPriority(USB0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
+ // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher )
+ NVIC_SetPriority(USB0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
#endif
/* Reset USB */
SYSCTL->SRCR2 |= (1u << 16);
- for ( volatile uint8_t i = 0; i < 20; i++ ) {}
+ for (volatile uint8_t i = 0; i < 20; i++) {}
SYSCTL->SRCR2 &= ~(1u << 16);
@@ -110,7 +94,7 @@ void board_init (void)
SYSCTL->RCGCGPIO |= (1u << 3);
/* Let the clock stabilize */
- while ( !(SYSCTL->PRGPIO & (1u << 3)) ) {}
+ while (!(SYSCTL->PRGPIO & (1u << 3))) {}
/* USB IOs to Analog Mode */
GPIOD->AFSEL &= ~((1u << 4) | (1u << 5));
@@ -124,7 +108,9 @@ void board_init (void)
initialize_board_led(LED_PORT, leds, dirmsk);
/* Configure GPIO for board switch */
- board_switch_init();
+ GPIOF->DIR &= ~(1 << BOARD_BTN);
+ GPIOF->PUR |= (1 << BOARD_BTN);
+ GPIOF->DEN |= (1 << BOARD_BTN);
/* Initialize board UART */
board_uart_init();
@@ -132,32 +118,35 @@ void board_init (void)
TU_LOG1_INT(SystemCoreClock);
}
-void board_led_write (bool state)
-{
+void board_led_write(bool state) {
WriteGPIOPin(LED_PORT, (1 << LED_PIN_BLUE), state);
}
-uint32_t board_button_read (void)
-{
+uint32_t board_button_read(void) {
uint32_t gpio_value = ReadGPIOPin(BOARD_BTN_PORT, BOARD_BTN_Msk);
return BUTTON_STATE_ACTIVE ? gpio_value : !gpio_value;
}
-int board_uart_write (void const *buf, int len)
-{
- uint8_t const * data = buf;
+size_t board_get_unique_id(uint8_t id[], size_t max_len) {
+ (void) max_len;
+ uint8_t const len = 8;
+ // Note: DID0, DID1 are variant ID, they aer used since TM4C123 does not have unique ID
+ memcpy(id, (void*)(uintptr_t) &SYSCTL->DID0, len);
+ return len;
+}
- for ( int i = 0; i < len; i++ )
- {
- while ( (UART0->FR & (1 << 5)) != 0 ) {} // Poll until previous data was shofted out
- UART0->DR = data[i]; // Write UART0 DATA REGISTER
+int board_uart_write(void const* buf, int len) {
+ uint8_t const* data = buf;
+
+ for (int i = 0; i < len; i++) {
+ while ((UART0->FR & (1 << 5)) != 0) {} // Poll until previous data was shofted out
+ UART0->DR = data[i]; // Write UART0 DATA REGISTER
}
return len;
}
-int board_uart_read (uint8_t *buf, int len)
-{
+int board_uart_read(uint8_t* buf, int len) {
(void) buf;
(void) len;
return 0;
@@ -165,13 +154,13 @@ int board_uart_read (uint8_t *buf, int len)
#if CFG_TUSB_OS == OPT_OS_NONE
volatile uint32_t system_ticks = 0;
-void SysTick_Handler (void)
-{
+
+void SysTick_Handler(void) {
system_ticks++;
}
-uint32_t board_millis (void)
-{
+uint32_t board_millis(void) {
return system_ticks;
}
+
#endif
diff --git a/hw/bsp/tm4c/family.cmake b/hw/bsp/tm4c/family.cmake
index 86db985d6..9c083759b 100644
--- a/hw/bsp/tm4c/family.cmake
+++ b/hw/bsp/tm4c/family.cmake
@@ -92,4 +92,5 @@ function(family_configure_example TARGET RTOS)
# Flashing
family_add_bin_hex(${TARGET})
family_flash_openocd(${TARGET})
+ family_flash_uniflash(${TARGET})
endfunction()
diff --git a/src/common/tusb_mcu.h b/src/common/tusb_mcu.h
index e3ad0f627..e86f55c1d 100644
--- a/src/common/tusb_mcu.h
+++ b/src/common/tusb_mcu.h
@@ -138,21 +138,21 @@
#elif TU_CHECK_MCU(OPT_MCU_SAMG)
#define TUP_DCD_ENDPOINT_MAX 6
- #define TUP_DCD_ENDPOINT_EXCLUSIVE_NUMBER
+ #define TUD_ENDPOINT_EXCLUSIVE_NUMBER
#elif TU_CHECK_MCU(OPT_MCU_SAMX7X)
#define TUP_DCD_ENDPOINT_MAX 10
#define TUP_RHPORT_HIGHSPEED 1
- #define TUP_DCD_ENDPOINT_EXCLUSIVE_NUMBER
+ #define TUD_ENDPOINT_EXCLUSIVE_NUMBER
#elif TU_CHECK_MCU(OPT_MCU_PIC32MZ)
#define TUP_DCD_ENDPOINT_MAX 8
- #define TUP_DCD_ENDPOINT_EXCLUSIVE_NUMBER
+ #define TUD_ENDPOINT_EXCLUSIVE_NUMBER
#elif TU_CHECK_MCU(OPT_MCU_PIC32MX, OPT_MCU_PIC32MM, OPT_MCU_PIC32MK) || \
TU_CHECK_MCU(OPT_MCU_PIC24, OPT_MCU_DSPIC33)
#define TUP_DCD_ENDPOINT_MAX 16
- #define TUP_DCD_ENDPOINT_EXCLUSIVE_NUMBER
+ #define TUD_ENDPOINT_EXCLUSIVE_NUMBER
//--------------------------------------------------------------------+
// ST
@@ -299,7 +299,7 @@
#elif TU_CHECK_MCU(OPT_MCU_CXD56)
#define TUP_DCD_ENDPOINT_MAX 7
#define TUP_RHPORT_HIGHSPEED 1
- #define TUP_DCD_ENDPOINT_EXCLUSIVE_NUMBER
+ #define TUD_ENDPOINT_EXCLUSIVE_NUMBER
//--------------------------------------------------------------------+
// TI
@@ -308,6 +308,8 @@
#define TUP_DCD_ENDPOINT_MAX 8
#elif TU_CHECK_MCU(OPT_MCU_MSP432E4, OPT_MCU_TM4C123, OPT_MCU_TM4C129)
+ #define TUP_USBIP_MUSB
+ #define TUP_USBIP_MUSB_TI
#define TUP_DCD_ENDPOINT_MAX 8
//--------------------------------------------------------------------+
@@ -398,10 +400,12 @@
#elif TU_CHECK_MCU(OPT_MCU_FT90X)
#define TUP_DCD_ENDPOINT_MAX 8
#define TUP_RHPORT_HIGHSPEED 1
+ #define TUD_ENDPOINT_EXCLUSIVE_NUMBER
#elif TU_CHECK_MCU(OPT_MCU_FT93X)
#define TUP_DCD_ENDPOINT_MAX 16
#define TUP_RHPORT_HIGHSPEED 1
+ #define TUD_ENDPOINT_EXCLUSIVE_NUMBER
//--------------------------------------------------------------------+
// Allwinner
@@ -468,6 +472,16 @@
#define TUP_RHPORT_HIGHSPEED CFG_TUD_WCH_USBIP_USBHS
#define TUP_DCD_ENDPOINT_MAX (CFG_TUD_WCH_USBIP_USBHS ? 16 : 8)
+//--------------------------------------------------------------------+
+// Analog Devices
+//--------------------------------------------------------------------+
+#elif TU_CHECK_MCU(OPT_MCU_MAX32650, OPT_MCU_MAX32666, OPT_MCU_MAX32690, OPT_MCU_MAX78002)
+ #define TUP_USBIP_MUSB
+ #define TUP_USBIP_MUSB_ADI
+ #define TUP_DCD_ENDPOINT_MAX 12
+ #define TUP_RHPORT_HIGHSPEED 1
+ #define TUD_ENDPOINT_EXCLUSIVE_NUMBER
+
#endif
//--------------------------------------------------------------------+
@@ -504,7 +518,8 @@
#define TU_ATTR_FAST_FUNC
#endif
-#if defined(TUP_USBIP_DWC2) || defined(TUP_USBIP_FSDEV)
+// USBIP that support ISO alloc & activate API
+#if defined(TUP_USBIP_DWC2) || defined(TUP_USBIP_FSDEV) || defined(TUP_USBIP_MUSB)
#define TUP_DCD_EDPT_ISO_ALLOC
#endif
diff --git a/src/device/dcd.h b/src/device/dcd.h
index 41e0fbee3..d1d4e4897 100644
--- a/src/device/dcd.h
+++ b/src/device/dcd.h
@@ -157,10 +157,6 @@ bool dcd_edpt_open (uint8_t rhport, tusb_desc_endpoint_t const * desc
// required for multiple configuration support.
void dcd_edpt_close_all (uint8_t rhport);
-// Close an endpoint.
-// Since it is weak, caller must TU_ASSERT this function's existence before calling it.
-void dcd_edpt_close (uint8_t rhport, uint8_t ep_addr) TU_ATTR_WEAK;
-
// Submit a transfer, When complete dcd_event_xfer_complete() is invoked to notify the stack
bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes);
@@ -175,12 +171,19 @@ void dcd_edpt_stall (uint8_t rhport, uint8_t ep_addr);
// This API never calls with control endpoints, since it is auto cleared when receiving setup packet
void dcd_edpt_clear_stall (uint8_t rhport, uint8_t ep_addr);
+#ifdef TUP_DCD_EDPT_ISO_ALLOC
// Allocate packet buffer used by ISO endpoints
// Some MCU need manual packet buffer allocation, we allocate the largest size to avoid clustering
-TU_ATTR_WEAK bool dcd_edpt_iso_alloc(uint8_t rhport, uint8_t ep_addr, uint16_t largest_packet_size);
+bool dcd_edpt_iso_alloc(uint8_t rhport, uint8_t ep_addr, uint16_t largest_packet_size);
// Configure and enable an ISO endpoint according to descriptor
-TU_ATTR_WEAK bool dcd_edpt_iso_activate(uint8_t rhport, tusb_desc_endpoint_t const * desc_ep);
+bool dcd_edpt_iso_activate(uint8_t rhport, tusb_desc_endpoint_t const * desc_ep);
+
+#else
+// Close an endpoint.
+void dcd_edpt_close (uint8_t rhport, uint8_t ep_addr) TU_ATTR_WEAK;
+
+#endif
//--------------------------------------------------------------------+
// Event API (implemented by stack)
diff --git a/src/device/usbd.c b/src/device/usbd.c
index 7089e9cf1..67faf0da7 100644
--- a/src/device/usbd.c
+++ b/src/device/usbd.c
@@ -1418,9 +1418,12 @@ bool usbd_edpt_stalled(uint8_t rhport, uint8_t ep_addr) {
* In progress transfers on this EP may be delivered after this call.
*/
void usbd_edpt_close(uint8_t rhport, uint8_t ep_addr) {
+#ifdef TUP_DCD_EDPT_ISO_ALLOC
+ (void) rhport; (void) ep_addr;
+ // ISO alloc/activate Should be used instead
+#else
rhport = _usbd_rhport;
- TU_ASSERT(dcd_edpt_close, /**/);
TU_LOG_USBD(" CLOSING Endpoint: 0x%02X\r\n", ep_addr);
uint8_t const epnum = tu_edpt_number(ep_addr);
@@ -1430,6 +1433,7 @@ void usbd_edpt_close(uint8_t rhport, uint8_t ep_addr) {
_usbd_dev.ep_status[epnum][dir].stalled = 0;
_usbd_dev.ep_status[epnum][dir].busy = 0;
_usbd_dev.ep_status[epnum][dir].claimed = 0;
+#endif
return;
}
@@ -1452,21 +1456,24 @@ void usbd_sof_enable(uint8_t rhport, sof_consumer_t consumer, bool en) {
}
bool usbd_edpt_iso_alloc(uint8_t rhport, uint8_t ep_addr, uint16_t largest_packet_size) {
+#ifdef TUP_DCD_EDPT_ISO_ALLOC
rhport = _usbd_rhport;
- TU_ASSERT(dcd_edpt_iso_alloc);
TU_ASSERT(tu_edpt_number(ep_addr) < CFG_TUD_ENDPPOINT_MAX);
-
return dcd_edpt_iso_alloc(rhport, ep_addr, largest_packet_size);
+#else
+ (void) rhport; (void) ep_addr; (void) largest_packet_size;
+ return false;
+#endif
}
bool usbd_edpt_iso_activate(uint8_t rhport, tusb_desc_endpoint_t const* desc_ep) {
+#ifdef TUP_DCD_EDPT_ISO_ALLOC
rhport = _usbd_rhport;
uint8_t const epnum = tu_edpt_number(desc_ep->bEndpointAddress);
uint8_t const dir = tu_edpt_dir(desc_ep->bEndpointAddress);
- TU_ASSERT(dcd_edpt_iso_activate);
TU_ASSERT(epnum < CFG_TUD_ENDPPOINT_MAX);
TU_ASSERT(tu_edpt_validate(desc_ep, (tusb_speed_t) _usbd_dev.speed));
@@ -1474,6 +1481,10 @@ bool usbd_edpt_iso_activate(uint8_t rhport, tusb_desc_endpoint_t const* desc_ep)
_usbd_dev.ep_status[epnum][dir].busy = 0;
_usbd_dev.ep_status[epnum][dir].claimed = 0;
return dcd_edpt_iso_activate(rhport, desc_ep);
+#else
+ (void) rhport; (void) desc_ep;
+ return false;
+#endif
}
#endif
diff --git a/src/portable/mentor/musb/dcd_musb.c b/src/portable/mentor/musb/dcd_musb.c
index a817c5d6e..a40b3dc07 100644
--- a/src/portable/mentor/musb/dcd_musb.c
+++ b/src/portable/mentor/musb/dcd_musb.c
@@ -2,6 +2,7 @@
* The MIT License (MIT)
*
* Copyright (c) 2021 Koji KITAYAMA
+ * Copyright (c) 2024, Brent Kowal (Analog Devices, Inc)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -26,8 +27,10 @@
#include "tusb_option.h"
-#if CFG_TUD_ENABLED && \
- TU_CHECK_MCU(OPT_MCU_MSP432E4, OPT_MCU_TM4C123, OPT_MCU_TM4C129)
+#if CFG_TUD_ENABLED && defined(TUP_USBIP_MUSB)
+
+#define MUSB_DEBUG 2
+#define MUSB_REGS(rhport) ((musb_regs_t*) MUSB_BASES[rhport])
#if __GNUC__ > 8 && defined(__ARM_FEATURE_UNALIGNED)
/* GCC warns that an address may be unaligned, even though
@@ -35,48 +38,30 @@
_Pragma("GCC diagnostic ignored \"-Waddress-of-packed-member\"");
#endif
+#include "musb_type.h"
#include "device/dcd.h"
-#if TU_CHECK_MCU(OPT_MCU_MSP432E4)
- #include "musb_msp432e.h"
-
-#elif TU_CHECK_MCU(OPT_MCU_TM4C123, OPT_MCU_TM4C129)
- #include "musb_tm4c.h"
-
- // HACK generalize later
- #include "musb_type.h"
- #define FIFO0_WORD FIFO0
- #define FIFO1_WORD FIFO1
-
+// Following symbols must be defined by port header
+// - musb_dcd_int_enable/disable/clear/get_enable
+// - musb_dcd_int_handler_enter/exit
+#if defined(TUP_USBIP_MUSB_TI)
+ #include "musb_ti.h"
+#elif defined(TUP_USBIP_MUSB_ADI)
+ #include "musb_max32.h"
#else
- #error "Unsupported MCUs"
+ #error "Unsupported MCU"
#endif
/*------------------------------------------------------------------
* MACRO TYPEDEF CONSTANT ENUM DECLARATION
*------------------------------------------------------------------*/
+
#define REQUEST_TYPE_INVALID (0xFFu)
-typedef struct {
- uint_fast16_t beg; /* offset of including first element */
- uint_fast16_t end; /* offset of excluding the last element */
-} free_block_t;
-
-typedef struct TU_ATTR_PACKED {
- uint16_t TXMAXP;
- uint8_t TXCSRL;
- uint8_t TXCSRH;
- uint16_t RXMAXP;
- uint8_t RXCSRL;
- uint8_t RXCSRH;
- uint16_t RXCOUNT;
- uint16_t RESERVED[3];
-} hw_endpoint_t;
-
typedef union {
- uint8_t u8;
- uint16_t u16;
- uint32_t u32;
+ volatile uint8_t u8;
+ volatile uint16_t u16;
+ volatile uint32_t u32;
} hw_fifo_t;
typedef struct TU_ATTR_PACKED
@@ -92,134 +77,97 @@ typedef struct
uint16_t remaining_ctrl; /* The number of bytes remaining in data stage of control transfer. */
int8_t status_out;
pipe_state_t pipe0;
- pipe_state_t pipe[2][7]; /* pipe[direction][endpoint number - 1] */
+ pipe_state_t pipe[2][TUP_DCD_ENDPOINT_MAX-1]; /* pipe[direction][endpoint number - 1] */
uint16_t pipe_buf_is_fifo[2]; /* Bitmap. Each bit means whether 1:TU_FIFO or 0:POD. */
} dcd_data_t;
-/*------------------------------------------------------------------
- * INTERNAL OBJECT & FUNCTION DECLARATION
- *------------------------------------------------------------------*/
static dcd_data_t _dcd;
+//--------------------------------------------------------------------
+// HW FIFO Helper
+// Note: Index register is already set by caller
+//--------------------------------------------------------------------
-static inline free_block_t *find_containing_block(free_block_t *beg, free_block_t *end, uint_fast16_t addr)
-{
- free_block_t *cur = beg;
- for (; cur < end && ((addr < cur->beg) || (cur->end <= addr)); ++cur) ;
- return cur;
-}
+#if MUSB_CFG_DYNAMIC_FIFO
-static inline int update_free_block_list(free_block_t *blks, unsigned num, uint_fast16_t addr, uint_fast16_t size)
-{
- free_block_t *p = find_containing_block(blks, blks + num, addr);
- TU_ASSERT(p != blks + num, -2);
- if (p->beg == addr) {
- /* Shrink block */
- p->beg = addr + size;
- if (p->beg != p->end) return 0;
- /* remove block */
- free_block_t *end = blks + num;
- while (p + 1 < end) {
- *p = *(p + 1);
- ++p;
- }
- return -1;
- } else {
- /* Split into 2 blocks */
- free_block_t tmp = {
- .beg = addr + size,
- .end = p->end
- };
- p->end = addr;
- if (p->beg == p->end) {
- if (tmp.beg != tmp.end) {
- *p = tmp;
- return 0;
- }
- /* remove block */
- free_block_t *end = blks + num;
- while (p + 1 < end) {
- *p = *(p + 1);
- ++p;
- }
- return -1;
- }
- if (tmp.beg == tmp.end) return 0;
- blks[num] = tmp;
- return 1;
+// musb is configured to use dynamic FIFO sizing.
+// FF Size is encodded: 1 << (fifo_size[3:0] + 3) = 8 << fifo_size[3:0]
+// FF Address is 8*ff_addr[12:0]
+// First 64 bytes are reserved for EP0
+static uint32_t alloced_fifo_bytes;
+
+// ffsize is log2(mps) - 3 (round up)
+TU_ATTR_ALWAYS_INLINE static inline uint8_t hwfifo_byte2size(uint16_t nbytes) {
+ uint8_t ffsize = 28 - tu_min8(28, __builtin_clz(nbytes));
+ if ((8u << ffsize) < nbytes) {
+ ++ffsize;
}
+ return ffsize;
}
-static inline unsigned free_block_size(free_block_t const *blk)
-{
- return blk->end - blk->beg;
+TU_ATTR_ALWAYS_INLINE static inline void hwfifo_reset(musb_regs_t* musb, unsigned epnum, unsigned is_rx) {
+ (void) epnum;
+ musb->fifo_size[is_rx] = 0;
+ musb->fifo_addr[is_rx] = 0;
}
-#if 0
-static inline void print_block_list(free_block_t const *blk, unsigned num)
-{
- TU_LOG1("*************\r\n");
- for (unsigned i = 0; i < num; ++i) {
- TU_LOG1(" Blk%u %u %u\r\n", i, blk->beg, blk->end);
- ++blk;
+TU_ATTR_ALWAYS_INLINE static inline bool hwfifo_config(musb_regs_t* musb, unsigned epnum, unsigned is_rx, unsigned mps,
+ bool double_packet) {
+ (void) epnum;
+ uint8_t ffsize = hwfifo_byte2size(mps);
+ mps = 8 << ffsize; // round up to the next power of 2
+
+ if (double_packet) {
+ ffsize |= MUSB_FIFOSZ_DOUBLE_PACKET;
+ mps <<= 1;
}
+
+ TU_ASSERT(alloced_fifo_bytes + mps <= MUSB_CFG_DYNAMIC_FIFO_SIZE);
+ musb->fifo_addr[is_rx] = alloced_fifo_bytes / 8;
+ musb->fifo_size[is_rx] = ffsize;
+
+ alloced_fifo_bytes += mps;
+ return true;
}
+
#else
-#define print_block_list(a,b)
+
+TU_ATTR_ALWAYS_INLINE static inline void hwfifo_reset(musb_regs_t* musb, unsigned epnum, unsigned is_rx) {
+ (void) musb; (void) epnum; (void) is_rx;
+ // nothing to do for static FIFO
+}
+
+TU_ATTR_ALWAYS_INLINE static inline bool hwfifo_config(musb_regs_t* musb, unsigned epnum, unsigned is_rx, unsigned mps,
+ bool double_packet) {
+ (void) epnum; (void) mps;
+ if (!double_packet) {
+ #if defined(TUP_USBIP_MUSB_ADI)
+ musb->indexed_csr.maxp_csr[is_rx].csrh |= MUSB_CSRH_DISABLE_DOUBLE_PACKET(is_rx);
+ #else
+ if (is_rx) {
+ musb->rx_doulbe_packet_disable |= 1u << epnum;
+ } else {
+ musb->tx_double_packet_disable |= 1u << epnum;
+ }
+ #endif
+ }
+
+ return true;
+}
+
#endif
-static unsigned find_free_memory(uint_fast16_t size_in_log2_minus3)
-{
- free_block_t free_blocks[2 * (TUP_DCD_ENDPOINT_MAX - 1)];
- unsigned num_blocks = 1;
-
- /* Initialize free memory block list */
- free_blocks[0].beg = 64 / 8;
- free_blocks[0].end = (4 << 10) / 8; /* 4KiB / 8 bytes */
- for (int i = 1; i < TUP_DCD_ENDPOINT_MAX; ++i) {
- uint_fast16_t addr;
- int num;
- USB0->EPIDX = i;
- addr = USB0->TXFIFOADD;
- if (addr) {
- unsigned sz = USB0->TXFIFOSZ;
- unsigned sft = (sz & USB_TXFIFOSZ_SIZE_M) + ((sz & USB_TXFIFOSZ_DPB) ? 1: 0);
- num = update_free_block_list(free_blocks, num_blocks, addr, 1 << sft);
- TU_ASSERT(-2 < num, 0);
- num_blocks += num;
- print_block_list(free_blocks, num_blocks);
- }
- addr = USB0->RXFIFOADD;
- if (addr) {
- unsigned sz = USB0->RXFIFOSZ;
- unsigned sft = (sz & USB_RXFIFOSZ_SIZE_M) + ((sz & USB_RXFIFOSZ_DPB) ? 1: 0);
- num = update_free_block_list(free_blocks, num_blocks, addr, 1 << sft);
- TU_ASSERT(-2 < num, 0);
- num_blocks += num;
- print_block_list(free_blocks, num_blocks);
+// Flush FIFO and clear data toggle
+TU_ATTR_ALWAYS_INLINE static inline void hwfifo_flush(musb_regs_t* musb, unsigned epnum, unsigned is_rx, bool clear_dtog) {
+ (void) epnum;
+ const uint8_t csrl_dtog = clear_dtog ? MUSB_CSRL_CLEAR_DATA_TOGGLE(is_rx) : 0;
+ musb_ep_maxp_csr_t* maxp_csr = &musb->indexed_csr.maxp_csr[is_rx];
+ // may need to flush twice for double packet
+ for (unsigned i=0; i<2; i++) {
+ if (maxp_csr->csrl & MUSB_CSRL_PACKET_READY(is_rx)) {
+ maxp_csr->csrl = MUSB_CSRL_FLUSH_FIFO(is_rx) | csrl_dtog;
}
}
- print_block_list(free_blocks, num_blocks);
-
- /* Find the best fit memory block */
- uint_fast16_t size_in_8byte_unit = 1 << size_in_log2_minus3;
- free_block_t const *min = NULL;
- uint_fast16_t min_sz = 0xFFFFu;
- free_block_t const *end = &free_blocks[num_blocks];
- for (free_block_t const *cur = &free_blocks[0]; cur < end; ++cur) {
- uint_fast16_t sz = free_block_size(cur);
- if (sz < size_in_8byte_unit) continue;
- if (size_in_8byte_unit == sz) return cur->beg;
- if (sz < min_sz) min = cur;
- }
- TU_ASSERT(min, 0);
- return min->beg;
-}
-
-static inline volatile hw_endpoint_t* edpt_regs(unsigned epnum_minus1)
-{
- volatile hw_endpoint_t *regs = (volatile hw_endpoint_t*)((uintptr_t)&USB0->TXMAXP1);
- return regs + epnum_minus1;
}
static void pipe_write_packet(void *buf, volatile void *fifo, unsigned len)
@@ -284,11 +232,14 @@ static void pipe_read_write_packet_ff(tu_fifo_t *f, volatile void *fifo, unsigne
ops[dir].tu_fifo_advance(f, total_len - rem);
}
-static void process_setup_packet(uint8_t rhport)
-{
+static void process_setup_packet(uint8_t rhport) {
+ musb_regs_t* musb_regs = MUSB_REGS(rhport);
+
+ // Read setup packet
uint32_t *p = (void*)&_dcd.setup_packet;
- p[0] = USB0->FIFO0_WORD;
- p[1] = USB0->FIFO0_WORD;
+ volatile uint32_t *fifo_ptr = &musb_regs->fifo[0];
+ p[0] = *fifo_ptr;
+ p[1] = *fifo_ptr;
_dcd.pipe0.buf = NULL;
_dcd.pipe0.length = 0;
@@ -299,12 +250,16 @@ static void process_setup_packet(uint8_t rhport)
_dcd.remaining_ctrl = len;
const unsigned dir_in = tu_edpt_dir(_dcd.setup_packet.bmRequestType);
/* Clear RX FIFO and reverse the transaction direction */
- if (len && dir_in) USB0->CSRL0 = USB_CSRL0_RXRDYC;
+ if (len && dir_in) {
+ musb_ep_csr_t* ep_csr = get_ep_csr(musb_regs, 0);
+ ep_csr->csr0l = MUSB_CSRL0_RXRDYC;
+ }
}
-static bool handle_xfer_in(uint_fast8_t ep_addr)
+static bool handle_xfer_in(uint8_t rhport, uint_fast8_t ep_addr)
{
- unsigned epnum_minus1 = tu_edpt_number(ep_addr) - 1;
+ unsigned epnum = tu_edpt_number(ep_addr);
+ unsigned epnum_minus1 = epnum - 1;
pipe_state_t *pipe = &_dcd.pipe[tu_edpt_dir(ep_addr)][epnum_minus1];
const unsigned rem = pipe->remaining;
@@ -313,44 +268,49 @@ static bool handle_xfer_in(uint_fast8_t ep_addr)
return true;
}
- volatile hw_endpoint_t *regs = edpt_regs(epnum_minus1);
- const unsigned mps = regs->TXMAXP;
+ musb_regs_t* musb_regs = MUSB_REGS(rhport);
+ musb_ep_csr_t* ep_csr = get_ep_csr(musb_regs, epnum);
+ const unsigned mps = ep_csr->tx_maxp;
const unsigned len = TU_MIN(mps, rem);
void *buf = pipe->buf;
+ volatile void *fifo_ptr = &musb_regs->fifo[epnum];
// TU_LOG1(" %p mps %d len %d rem %d\r\n", buf, mps, len, rem);
if (len) {
if (_dcd.pipe_buf_is_fifo[TUSB_DIR_IN] & TU_BIT(epnum_minus1)) {
- pipe_read_write_packet_ff(buf, &USB0->FIFO1_WORD + epnum_minus1, len, TUSB_DIR_IN);
+ pipe_read_write_packet_ff(buf, fifo_ptr, len, TUSB_DIR_IN);
} else {
- pipe_write_packet(buf, &USB0->FIFO1_WORD + epnum_minus1, len);
+ pipe_write_packet(buf, fifo_ptr, len);
pipe->buf = buf + len;
}
pipe->remaining = rem - len;
}
- regs->TXCSRL = USB_TXCSRL1_TXRDY;
- // TU_LOG1(" TXCSRL%d = %x %d\r\n", epnum_minus1 + 1, regs->TXCSRL, rem - len);
+ ep_csr->tx_csrl = MUSB_TXCSRL1_TXRDY;
+ // TU_LOG1(" TXCSRL%d = %x %d\r\n", epnum, ep_csr->tx_csrl, rem - len);
return false;
}
-static bool handle_xfer_out(uint_fast8_t ep_addr)
+static bool handle_xfer_out(uint8_t rhport, uint_fast8_t ep_addr)
{
- unsigned epnum_minus1 = tu_edpt_number(ep_addr) - 1;
+ unsigned epnum = tu_edpt_number(ep_addr);
+ unsigned epnum_minus1 = epnum - 1;
pipe_state_t *pipe = &_dcd.pipe[tu_edpt_dir(ep_addr)][epnum_minus1];
- volatile hw_endpoint_t *regs = edpt_regs(epnum_minus1);
- // TU_LOG1(" RXCSRL%d = %x\r\n", epnum_minus1 + 1, regs->RXCSRL);
+ musb_regs_t* musb_regs = MUSB_REGS(rhport);
+ musb_ep_csr_t* ep_csr = get_ep_csr(musb_regs, epnum);
+ // TU_LOG1(" RXCSRL%d = %x\r\n", epnum_minus1 + 1, ep_csr->rx_csrl);
- TU_ASSERT(regs->RXCSRL & USB_RXCSRL1_RXRDY);
+ TU_ASSERT(ep_csr->rx_csrl & MUSB_RXCSRL1_RXRDY);
- const unsigned mps = regs->RXMAXP;
+ const unsigned mps = ep_csr->rx_maxp;
const unsigned rem = pipe->remaining;
- const unsigned vld = regs->RXCOUNT;
+ const unsigned vld = ep_csr->rx_count;
const unsigned len = TU_MIN(TU_MIN(rem, mps), vld);
void *buf = pipe->buf;
+ volatile void *fifo_ptr = &musb_regs->fifo[epnum];
if (len) {
if (_dcd.pipe_buf_is_fifo[TUSB_DIR_OUT] & TU_BIT(epnum_minus1)) {
- pipe_read_write_packet_ff(buf, &USB0->FIFO1_WORD + epnum_minus1, len, TUSB_DIR_OUT);
+ pipe_read_write_packet_ff(buf, fifo_ptr, len, TUSB_DIR_OUT);
} else {
- pipe_read_packet(buf, &USB0->FIFO1_WORD + epnum_minus1, len);
+ pipe_read_packet(buf, fifo_ptr, len);
pipe->buf = buf + len;
}
pipe->remaining = rem - len;
@@ -359,15 +319,14 @@ static bool handle_xfer_out(uint_fast8_t ep_addr)
pipe->buf = NULL;
return NULL != buf;
}
- regs->RXCSRL = 0; /* Clear RXRDY bit */
+ ep_csr->rx_csrl = 0; /* Clear RXRDY bit */
return false;
}
static bool edpt_n_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t *buffer, uint16_t total_bytes)
{
- (void)rhport;
-
- unsigned epnum_minus1 = tu_edpt_number(ep_addr) - 1;
+ unsigned epnum = tu_edpt_number(ep_addr);
+ unsigned epnum_minus1 = epnum - 1;
unsigned dir_in = tu_edpt_dir(ep_addr);
pipe_state_t *pipe = &_dcd.pipe[dir_in][epnum_minus1];
@@ -376,10 +335,11 @@ static bool edpt_n_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t *buffer, uint16
pipe->remaining = total_bytes;
if (dir_in) {
- handle_xfer_in(ep_addr);
+ handle_xfer_in(rhport, ep_addr);
} else {
- volatile hw_endpoint_t *regs = edpt_regs(epnum_minus1);
- if (regs->RXCSRL & USB_RXCSRL1_RXRDY) regs->RXCSRL = 0;
+ musb_regs_t* musb_regs = MUSB_REGS(rhport);
+ musb_ep_csr_t* ep_csr = get_ep_csr(musb_regs, epnum);
+ if (ep_csr->rx_csrl & MUSB_RXCSRL1_RXRDY) ep_csr->rx_csrl = 0;
}
return true;
}
@@ -388,7 +348,8 @@ static bool edpt0_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t *buffer, uint16_
{
(void)rhport;
TU_ASSERT(total_bytes <= 64); /* Current implementation supports for only up to 64 bytes. */
-
+ musb_regs_t* musb_regs = MUSB_REGS(rhport);
+ musb_ep_csr_t* ep_csr = get_ep_csr(musb_regs, 0);
const unsigned req = _dcd.setup_packet.bmRequestType;
TU_ASSERT(req != REQUEST_TYPE_INVALID || total_bytes == 0);
@@ -399,7 +360,7 @@ static bool edpt0_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t *buffer, uint16_
* may have already finished and received the next setup packet
* without calling this function, so we have no choice but to
* invoke the callback function of status packet here. */
- // TU_LOG1(" STATUS OUT USB0->CSRL0 = %x\r\n", USB0->CSRL0);
+ // TU_LOG1(" STATUS OUT ep_csr->csr0l = %x\r\n", ep_csr->csr0l);
_dcd.status_out = 0;
if (req == REQUEST_TYPE_INVALID) {
dcd_event_xfer_complete(rhport, ep_addr, total_bytes, XFER_RESULT_SUCCESS, false);
@@ -415,8 +376,9 @@ static bool edpt0_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t *buffer, uint16_
TU_ASSERT(total_bytes <= _dcd.remaining_ctrl);
const unsigned rem = _dcd.remaining_ctrl;
const unsigned len = TU_MIN(TU_MIN(rem, 64), total_bytes);
+ volatile void *fifo_ptr = &musb_regs->fifo[0];
if (dir_in) {
- pipe_write_packet(buffer, &USB0->FIFO0_WORD, len);
+ pipe_write_packet(buffer, fifo_ptr, len);
_dcd.pipe0.buf = buffer + len;
_dcd.pipe0.length = len;
@@ -427,45 +389,48 @@ static bool edpt0_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t *buffer, uint16_
_dcd.setup_packet.bmRequestType = REQUEST_TYPE_INVALID; /* Change to STATUS/SETUP stage */
_dcd.status_out = 1;
/* Flush TX FIFO and reverse the transaction direction. */
- USB0->CSRL0 = USB_CSRL0_TXRDY | USB_CSRL0_DATAEND;
+ ep_csr->csr0l = MUSB_CSRL0_TXRDY | MUSB_CSRL0_DATAEND;
} else {
- USB0->CSRL0 = USB_CSRL0_TXRDY; /* Flush TX FIFO to return ACK. */
+ ep_csr->csr0l = MUSB_CSRL0_TXRDY; /* Flush TX FIFO to return ACK. */
}
- // TU_LOG1(" IN USB0->CSRL0 = %x\r\n", USB0->CSRL0);
+ // TU_LOG1(" IN ep_csr->csr0l = %x\r\n", ep_csr->csr0l);
} else {
- // TU_LOG1(" OUT USB0->CSRL0 = %x\r\n", USB0->CSRL0);
+ // TU_LOG1(" OUT ep_csr->csr0l = %x\r\n", ep_csr->csr0l);
_dcd.pipe0.buf = buffer;
_dcd.pipe0.length = len;
_dcd.pipe0.remaining = len;
- USB0->CSRL0 = USB_CSRL0_RXRDYC; /* Clear RX FIFO to return ACK. */
+ ep_csr->csr0l = MUSB_CSRL0_RXRDYC; /* Clear RX FIFO to return ACK. */
}
} else if (dir_in) {
- // TU_LOG1(" STATUS IN USB0->CSRL0 = %x\r\n", USB0->CSRL0);
+ // TU_LOG1(" STATUS IN ep_csr->csr0l = %x\r\n", ep_csr->csr0l);
_dcd.pipe0.buf = NULL;
_dcd.pipe0.length = 0;
_dcd.pipe0.remaining = 0;
/* Clear RX FIFO and reverse the transaction direction */
- USB0->CSRL0 = USB_CSRL0_RXRDYC | USB_CSRL0_DATAEND;
+ ep_csr->csr0l = MUSB_CSRL0_RXRDYC | MUSB_CSRL0_DATAEND;
}
return true;
}
static void process_ep0(uint8_t rhport)
{
- uint_fast8_t csrl = USB0->CSRL0;
+ musb_regs_t* musb_regs = MUSB_REGS(rhport);
+ musb_ep_csr_t* ep_csr = get_ep_csr(musb_regs, 0);
+ uint_fast8_t csrl = ep_csr->csr0l;
- // TU_LOG1(" EP0 USB0->CSRL0 = %x\r\n", csrl);
+ // TU_LOG1(" EP0 ep_csr->csr0l = %x\r\n", csrl);
+ // 21.1.5: endpoint 0 service routine as peripheral
- if (csrl & USB_CSRL0_STALLED) {
+ if (csrl & MUSB_CSRL0_STALLED) {
/* Returned STALL packet to HOST. */
- USB0->CSRL0 = 0; /* Clear STALL */
+ ep_csr->csr0l = 0; /* Clear STALL */
return;
}
unsigned req = _dcd.setup_packet.bmRequestType;
- if (csrl & USB_CSRL0_SETEND) {
+ if (csrl & MUSB_CSRL0_SETEND) {
TU_LOG1(" ABORT by the next packets\r\n");
- USB0->CSRL0 = USB_CSRL0_SETENDC;
+ ep_csr->csr0l = MUSB_CSRL0_SETENDC;
if (req != REQUEST_TYPE_INVALID && _dcd.pipe0.buf) {
/* DATA stage was aborted by receiving STATUS or SETUP packet. */
_dcd.pipe0.buf = NULL;
@@ -476,23 +441,24 @@ static void process_ep0(uint8_t rhport)
XFER_RESULT_SUCCESS, true);
}
req = REQUEST_TYPE_INVALID;
- if (!(csrl & USB_CSRL0_RXRDY)) return; /* Received SETUP packet */
+ if (!(csrl & MUSB_CSRL0_RXRDY)) return; /* Received SETUP packet */
}
- if (csrl & USB_CSRL0_RXRDY) {
+ if (csrl & MUSB_CSRL0_RXRDY) {
/* Received SETUP or DATA OUT packet */
if (req == REQUEST_TYPE_INVALID) {
/* SETUP */
- TU_ASSERT(sizeof(tusb_control_request_t) == USB0->COUNT0,);
+ TU_ASSERT(sizeof(tusb_control_request_t) == ep_csr->count0,);
process_setup_packet(rhport);
return;
}
if (_dcd.pipe0.buf) {
/* DATA OUT */
- const unsigned vld = USB0->COUNT0;
+ const unsigned vld = ep_csr->count0;
const unsigned rem = _dcd.pipe0.remaining;
const unsigned len = TU_MIN(TU_MIN(rem, 64), vld);
- pipe_read_packet(_dcd.pipe0.buf, &USB0->FIFO0_WORD, len);
+ volatile void *fifo_ptr = &musb_regs->fifo[0];
+ pipe_read_packet(_dcd.pipe0.buf, fifo_ptr, len);
_dcd.pipe0.remaining = rem - len;
_dcd.remaining_ctrl -= len;
@@ -512,7 +478,7 @@ static void process_ep0(uint8_t rhport)
/* STATUS IN */
if (*(const uint16_t*)(uintptr_t)&_dcd.setup_packet == 0x0500) {
/* The address must be changed on completion of the control transfer. */
- USB0->FADDR = (uint8_t)_dcd.setup_packet.wValue;
+ musb_regs->faddr = (uint8_t)_dcd.setup_packet.wValue;
}
_dcd.setup_packet.bmRequestType = REQUEST_TYPE_INVALID;
dcd_event_xfer_complete(rhport,
@@ -534,118 +500,147 @@ static void process_ep0(uint8_t rhport)
static void process_edpt_n(uint8_t rhport, uint_fast8_t ep_addr)
{
bool completed;
- const unsigned dir_in = tu_edpt_dir(ep_addr);
- const unsigned epn_minus1 = tu_edpt_number(ep_addr) - 1;
+ const unsigned dir_in = tu_edpt_dir(ep_addr);
+ const unsigned epn = tu_edpt_number(ep_addr);
+ const unsigned epn_minus1 = epn - 1;
- volatile hw_endpoint_t *regs = edpt_regs(epn_minus1);
+ musb_regs_t* musb_regs = MUSB_REGS(rhport);
+ musb_ep_csr_t* ep_csr = get_ep_csr(musb_regs, epn);
if (dir_in) {
- // TU_LOG1(" TXCSRL%d = %x\r\n", epn_minus1 + 1, regs->TXCSRL);
- if (regs->TXCSRL & USB_TXCSRL1_STALLED) {
- regs->TXCSRL &= ~(USB_TXCSRL1_STALLED | USB_TXCSRL1_UNDRN);
+ // TU_LOG1(" TX CSRL%d = %x\r\n", epn, ep_csr->tx_csrl);
+ if (ep_csr->tx_csrl & MUSB_TXCSRL1_STALLED) {
+ ep_csr->tx_csrl &= ~(MUSB_TXCSRL1_STALLED | MUSB_TXCSRL1_UNDRN);
return;
}
- completed = handle_xfer_in(ep_addr);
+ completed = handle_xfer_in(rhport, ep_addr);
} else {
- // TU_LOG1(" RXCSRL%d = %x\r\n", epn_minus1 + 1, regs->RXCSRL);
- if (regs->RXCSRL & USB_RXCSRL1_STALLED) {
- regs->RXCSRL &= ~(USB_RXCSRL1_STALLED | USB_RXCSRL1_OVER);
+ // TU_LOG1(" RX CSRL%d = %x\r\n", epn, ep_csr->rx_csrl);
+ if (ep_csr->rx_csrl & MUSB_RXCSRL1_STALLED) {
+ ep_csr->rx_csrl &= ~(MUSB_RXCSRL1_STALLED | MUSB_RXCSRL1_OVER);
return;
}
- completed = handle_xfer_out(ep_addr);
+ completed = handle_xfer_out(rhport, ep_addr);
}
if (completed) {
- pipe_state_t *pipe = &_dcd.pipe[dir_in][tu_edpt_number(ep_addr) - 1];
+ pipe_state_t *pipe = &_dcd.pipe[dir_in][epn_minus1];
dcd_event_xfer_complete(rhport, ep_addr,
pipe->length - pipe->remaining,
XFER_RESULT_SUCCESS, true);
}
}
-static void process_bus_reset(uint8_t rhport)
-{
- /* When bmRequestType is REQUEST_TYPE_INVALID(0xFF),
- * a control transfer state is SETUP or STATUS stage. */
+// Upon BUS RESET is detected, hardware havs already done:
+// faddr = 0, index = 0, flushes all ep fifos, clears all ep csr, enabled all ep interrupts
+static void process_bus_reset(uint8_t rhport) {
+ musb_regs_t* musb = MUSB_REGS(rhport);
+
+#if MUSB_CFG_DYNAMIC_FIFO
+ alloced_fifo_bytes = CFG_TUD_ENDPOINT0_SIZE;
+#endif
+
+ /* When bmRequestType is REQUEST_TYPE_INVALID(0xFF), a control transfer state is SETUP or STATUS stage. */
_dcd.setup_packet.bmRequestType = REQUEST_TYPE_INVALID;
_dcd.status_out = 0;
/* When pipe0.buf has not NULL, DATA stage works in progress. */
_dcd.pipe0.buf = NULL;
- USB0->TXIE = 1; /* Enable only EP0 */
- USB0->RXIE = 0;
+ musb->intr_txen = 1; /* Enable only EP0 */
+ musb->intr_rxen = 0;
/* Clear FIFO settings */
for (unsigned i = 1; i < TUP_DCD_ENDPOINT_MAX; ++i) {
- USB0->EPIDX = i;
- USB0->TXFIFOSZ = 0;
- USB0->TXFIFOADD = 0;
- USB0->RXFIFOSZ = 0;
- USB0->RXFIFOADD = 0;
+ musb->index = i;
+ hwfifo_reset(musb, i, 0);
+ hwfifo_reset(musb, i, 1);
}
- dcd_event_bus_reset(rhport, TUSB_SPEED_FULL, true);
+ dcd_event_bus_reset(rhport, (musb->power & MUSB_POWER_HSMODE) ? TUSB_SPEED_HIGH : TUSB_SPEED_FULL, true);
}
/*------------------------------------------------------------------
* Device API
*------------------------------------------------------------------*/
-void dcd_init(uint8_t rhport)
-{
- (void)rhport;
- USB0->IE |= USB_IE_SUSPND;
- NVIC_ClearPendingIRQ(USB0_IRQn);
+#if CFG_TUSB_DEBUG >= MUSB_DEBUG
+void print_musb_info(musb_regs_t* musb_regs) {
+ // print version, epinfo, raminfo, config_data0, fifo_size
+ TU_LOG1("musb version = %u.%u\r\n", musb_regs->hwvers_bit.major, musb_regs->hwvers_bit.minor);
+ TU_LOG1("Number of endpoints: %u TX, %u RX\r\n", musb_regs->epinfo_bit.tx_ep_num, musb_regs->epinfo_bit.rx_ep_num);
+ TU_LOG1("RAM Info: %u DMA Channel, %u RAM address width\r\n", musb_regs->raminfo_bit.dma_channel, musb_regs->raminfo_bit.ram_bits);
+ musb_regs->index = 0;
+ TU_LOG1("config_data0 = 0x%x\r\n", musb_regs->indexed_csr.config_data0);
+
+#if MUSB_CFG_DYNAMIC_FIFO
+ TU_LOG1("Dynamic FIFO configuration\r\n");
+#else
+ for (uint8_t i=1; i <= musb_regs->epinfo_bit.tx_ep_num; i++) {
+ musb_regs->index = i;
+ TU_LOG1("FIFO %u Size: TX %u RX %u\r\n", i, musb_regs->indexed_csr.fifo_size_bit.tx, musb_regs->indexed_csr.fifo_size_bit.rx);
+ }
+#endif
+}
+#endif
+
+void dcd_init(uint8_t rhport) {
+ musb_regs_t* musb_regs = MUSB_REGS(rhport);
+
+#if CFG_TUSB_DEBUG >= MUSB_DEBUG
+ print_musb_info(musb_regs);
+#endif
+
+ musb_regs->intr_usben |= MUSB_IE_SUSPND;
+ musb_dcd_int_clear(rhport);
+ musb_dcd_phy_init(rhport);
dcd_connect(rhport);
}
-void dcd_int_enable(uint8_t rhport)
-{
- (void)rhport;
- NVIC_EnableIRQ(USB0_IRQn);
+void dcd_int_enable(uint8_t rhport) {
+ musb_dcd_int_enable(rhport);
}
-void dcd_int_disable(uint8_t rhport)
-{
- (void)rhport;
- NVIC_DisableIRQ(USB0_IRQn);
+void dcd_int_disable(uint8_t rhport) {
+ musb_dcd_int_disable(rhport);
}
// Receive Set Address request, mcu port must also include status IN response
void dcd_set_address(uint8_t rhport, uint8_t dev_addr)
{
- (void)rhport;
(void)dev_addr;
+ musb_regs_t* musb_regs = MUSB_REGS(rhport);
+ musb_ep_csr_t* ep_csr = get_ep_csr(musb_regs, 0);
+
_dcd.pipe0.buf = NULL;
_dcd.pipe0.length = 0;
_dcd.pipe0.remaining = 0;
/* Clear RX FIFO to return ACK. */
- USB0->CSRL0 = USB_CSRL0_RXRDYC | USB_CSRL0_DATAEND;
+ ep_csr->csr0l = MUSB_CSRL0_RXRDYC | MUSB_CSRL0_DATAEND;
}
// Wake up host
-void dcd_remote_wakeup(uint8_t rhport)
-{
- (void)rhport;
- USB0->POWER |= USB_POWER_RESUME;
+void dcd_remote_wakeup(uint8_t rhport) {
+ musb_regs_t* musb_regs = MUSB_REGS(rhport);
+ musb_regs->power |= MUSB_POWER_RESUME;
unsigned cnt = SystemCoreClock / 1000;
while (cnt--) __NOP();
- USB0->POWER &= ~USB_POWER_RESUME;
+ musb_regs->power &= ~MUSB_POWER_RESUME;
}
// Connect by enabling internal pull-up resistor on D+/D-
void dcd_connect(uint8_t rhport)
{
- (void)rhport;
- USB0->POWER |= USB_POWER_SOFTCONN;
+ musb_regs_t* musb_regs = MUSB_REGS(rhport);
+ musb_regs->power |= TUD_OPT_HIGH_SPEED ? MUSB_POWER_HSENAB : 0;
+ musb_regs->power |= MUSB_POWER_SOFTCONN;
}
// Disconnect by disabling internal pull-up resistor on D+/D-
void dcd_disconnect(uint8_t rhport)
{
- (void)rhport;
- USB0->POWER &= ~USB_POWER_SOFTCONN;
+ musb_regs_t* musb_regs = MUSB_REGS(rhport);
+ musb_regs->power &= ~MUSB_POWER_SOFTCONN;
}
void dcd_sof_enable(uint8_t rhport, bool en)
@@ -659,129 +654,119 @@ void dcd_sof_enable(uint8_t rhport, bool en)
//--------------------------------------------------------------------+
// Endpoint API
//--------------------------------------------------------------------+
+// static void edpt_setup(musb_regs_t* musb, uint8_t ep_addr, uint8_t ep_type, uint16_t ep_size){
+// const unsigned epn = tu_edpt_number(ep_addr);
+// const unsigned dir_in = tu_edpt_dir(ep_addr);
+// }
// Configure endpoint's registers according to descriptor
-bool dcd_edpt_open(uint8_t rhport, tusb_desc_endpoint_t const * ep_desc)
-{
- (void) rhport;
-
+bool dcd_edpt_open(uint8_t rhport, tusb_desc_endpoint_t const * ep_desc) {
const unsigned ep_addr = ep_desc->bEndpointAddress;
const unsigned epn = tu_edpt_number(ep_addr);
const unsigned dir_in = tu_edpt_dir(ep_addr);
- const unsigned xfer = ep_desc->bmAttributes.xfer;
const unsigned mps = tu_edpt_packet_size(ep_desc);
- TU_ASSERT(epn < TUP_DCD_ENDPOINT_MAX);
-
pipe_state_t *pipe = &_dcd.pipe[dir_in][epn - 1];
pipe->buf = NULL;
pipe->length = 0;
pipe->remaining = 0;
- volatile hw_endpoint_t *regs = edpt_regs(epn - 1);
- if (dir_in) {
- regs->TXMAXP = mps;
- regs->TXCSRH = (xfer == TUSB_XFER_ISOCHRONOUS) ? USB_TXCSRH1_ISO : 0;
- if (regs->TXCSRL & USB_TXCSRL1_TXRDY)
- regs->TXCSRL = USB_TXCSRL1_CLRDT | USB_TXCSRL1_FLUSH;
- else
- regs->TXCSRL = USB_TXCSRL1_CLRDT;
- USB0->TXIE |= TU_BIT(epn);
- } else {
- regs->RXMAXP = mps;
- regs->RXCSRH = (xfer == TUSB_XFER_ISOCHRONOUS) ? USB_RXCSRH1_ISO : 0;
- if (regs->RXCSRL & USB_RXCSRL1_RXRDY)
- regs->RXCSRL = USB_RXCSRL1_CLRDT | USB_RXCSRL1_FLUSH;
- else
- regs->RXCSRL = USB_RXCSRL1_CLRDT;
- USB0->RXIE |= TU_BIT(epn);
- }
+ musb_regs_t* musb = MUSB_REGS(rhport);
+ musb_ep_csr_t* ep_csr = get_ep_csr(musb, epn);
+ const uint8_t is_rx = 1 - dir_in;
+ musb_ep_maxp_csr_t* maxp_csr = &ep_csr->maxp_csr[is_rx];
- /* Setup FIFO */
- int size_in_log2_minus3 = 28 - TU_MIN(28, __CLZ((uint32_t)mps));
- if ((8u << size_in_log2_minus3) < mps) ++size_in_log2_minus3;
- unsigned addr = find_free_memory(size_in_log2_minus3);
- TU_ASSERT(addr);
-
- USB0->EPIDX = epn;
+ maxp_csr->maxp = mps;
+ maxp_csr->csrh = 0;
+#if MUSB_CFG_SHARED_FIFO
if (dir_in) {
- USB0->TXFIFOADD = addr;
- USB0->TXFIFOSZ = size_in_log2_minus3;
- } else {
- USB0->RXFIFOADD = addr;
- USB0->RXFIFOSZ = size_in_log2_minus3;
+ maxp_csr->csrh |= MUSB_CSRH_TX_MODE;
}
+#endif
+
+ hwfifo_flush(musb, epn, is_rx, true);
+
+ TU_ASSERT(hwfifo_config(musb, epn, is_rx, mps, false));
+ musb->intren_ep[is_rx] |= TU_BIT(epn);
+
+ return true;
+}
+
+bool dcd_edpt_iso_alloc(uint8_t rhport, uint8_t ep_addr, uint16_t largest_packet_size) {
+ const unsigned epn = tu_edpt_number(ep_addr);
+ const unsigned dir_in = tu_edpt_dir(ep_addr);
+ musb_regs_t* musb = MUSB_REGS(rhport);
+ musb_ep_csr_t* ep_csr = get_ep_csr(musb, epn);
+ const uint8_t is_rx = 1 - dir_in;
+ ep_csr->maxp_csr[is_rx].csrh = 0;
+ return hwfifo_config(musb, epn, is_rx, largest_packet_size, true);
+}
+
+bool dcd_edpt_iso_activate(uint8_t rhport, tusb_desc_endpoint_t const *ep_desc ) {
+ const unsigned ep_addr = ep_desc->bEndpointAddress;
+ const unsigned epn = tu_edpt_number(ep_addr);
+ const unsigned dir_in = tu_edpt_dir(ep_addr);
+ const unsigned mps = tu_edpt_packet_size(ep_desc);
+
+ unsigned const ie = musb_dcd_get_int_enable(rhport);
+ musb_dcd_int_disable(rhport);
+
+ pipe_state_t *pipe = &_dcd.pipe[dir_in][epn - 1];
+ pipe->buf = NULL;
+ pipe->length = 0;
+ pipe->remaining = 0;
+
+ musb_regs_t* musb = MUSB_REGS(rhport);
+ musb_ep_csr_t* ep_csr = get_ep_csr(musb, epn);
+ const uint8_t is_rx = 1 - dir_in;
+ musb_ep_maxp_csr_t* maxp_csr = &ep_csr->maxp_csr[is_rx];
+
+ maxp_csr->maxp = mps;
+ maxp_csr->csrh |= MUSB_CSRH_ISO;
+#if MUSB_CFG_SHARED_FIFO
+ if (dir_in) {
+ maxp_csr->csrh |= MUSB_CSRH_TX_MODE;
+ }
+#endif
+
+ hwfifo_flush(musb, epn, is_rx, true);
+
+#if MUSB_CFG_DYNAMIC_FIFO
+ // fifo space is already allocated, keep the address and just change packet size
+ musb->fifo_size[is_rx] = hwfifo_byte2size(mps) | MUSB_FIFOSZ_DOUBLE_PACKET;
+#endif
+
+ musb->intren_ep[is_rx] |= TU_BIT(epn);
+
+ if (ie) musb_dcd_int_enable(rhport);
return true;
}
void dcd_edpt_close_all(uint8_t rhport)
{
- (void) rhport;
- volatile hw_endpoint_t *regs = (volatile hw_endpoint_t *)(uintptr_t)&USB0->TXMAXP1;
- unsigned const ie = NVIC_GetEnableIRQ(USB0_IRQn);
- NVIC_DisableIRQ(USB0_IRQn);
- USB0->TXIE = 1; /* Enable only EP0 */
- USB0->RXIE = 0;
+ musb_regs_t* musb = MUSB_REGS(rhport);
+ unsigned const ie = musb_dcd_get_int_enable(rhport);
+ musb_dcd_int_disable(rhport);
+
+ musb->intr_txen = 1; /* Enable only EP0 */
+ musb->intr_rxen = 0;
for (unsigned i = 1; i < TUP_DCD_ENDPOINT_MAX; ++i) {
- regs->TXMAXP = 0;
- regs->TXCSRH = 0;
- if (regs->TXCSRL & USB_TXCSRL1_TXRDY)
- regs->TXCSRL = USB_TXCSRL1_CLRDT | USB_TXCSRL1_FLUSH;
- else
- regs->TXCSRL = USB_TXCSRL1_CLRDT;
-
- regs->RXMAXP = 0;
- regs->RXCSRH = 0;
- if (regs->RXCSRL & USB_RXCSRL1_RXRDY)
- regs->RXCSRL = USB_RXCSRL1_CLRDT | USB_RXCSRL1_FLUSH;
- else
- regs->RXCSRL = USB_RXCSRL1_CLRDT;
-
- USB0->EPIDX = i;
- USB0->TXFIFOSZ = 0;
- USB0->TXFIFOADD = 0;
- USB0->RXFIFOSZ = 0;
- USB0->RXFIFOADD = 0;
+ musb_ep_csr_t* ep_csr = get_ep_csr(musb, i);
+ for (unsigned d = 0; d < 2; d++) {
+ musb_ep_maxp_csr_t* maxp_csr = &ep_csr->maxp_csr[d];
+ hwfifo_flush(musb, i, d, true);
+ hwfifo_reset(musb, i, d);
+ maxp_csr->maxp = 0;
+ maxp_csr->csrh = 0;
+ }
}
- if (ie) NVIC_EnableIRQ(USB0_IRQn);
-}
-void dcd_edpt_close(uint8_t rhport, uint8_t ep_addr)
-{
- (void)rhport;
- unsigned const epn = tu_edpt_number(ep_addr);
- unsigned const dir_in = tu_edpt_dir(ep_addr);
+#if MUSB_CFG_DYNAMIC_FIFO
+ alloced_fifo_bytes = CFG_TUD_ENDPOINT0_SIZE;
+#endif
- hw_endpoint_t volatile *regs = edpt_regs(epn - 1);
- unsigned const ie = NVIC_GetEnableIRQ(USB0_IRQn);
- NVIC_DisableIRQ(USB0_IRQn);
- if (dir_in) {
- USB0->TXIE &= ~TU_BIT(epn);
- regs->TXMAXP = 0;
- regs->TXCSRH = 0;
- if (regs->TXCSRL & USB_TXCSRL1_TXRDY)
- regs->TXCSRL = USB_TXCSRL1_CLRDT | USB_TXCSRL1_FLUSH;
- else
- regs->TXCSRL = USB_TXCSRL1_CLRDT;
-
- USB0->EPIDX = epn;
- USB0->TXFIFOSZ = 0;
- USB0->TXFIFOADD = 0;
- } else {
- USB0->RXIE &= ~TU_BIT(epn);
- regs->RXMAXP = 0;
- regs->RXCSRH = 0;
- if (regs->RXCSRL & USB_RXCSRL1_RXRDY)
- regs->RXCSRL = USB_RXCSRL1_CLRDT | USB_RXCSRL1_FLUSH;
- else
- regs->RXCSRL = USB_RXCSRL1_CLRDT;
-
- USB0->EPIDX = epn;
- USB0->RXFIFOSZ = 0;
- USB0->RXFIFOADD = 0;
- }
- if (ie) NVIC_EnableIRQ(USB0_IRQn);
+ if (ie) musb_dcd_int_enable(rhport);
}
// Submit a transfer, When complete dcd_event_xfer_complete() is invoked to notify the stack
@@ -791,18 +776,22 @@ bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t t
bool ret;
// TU_LOG1("X %x %d\r\n", ep_addr, total_bytes);
unsigned const epnum = tu_edpt_number(ep_addr);
- unsigned const ie = NVIC_GetEnableIRQ(USB0_IRQn);
- NVIC_DisableIRQ(USB0_IRQn);
+ unsigned const ie = musb_dcd_get_int_enable(rhport);
+ musb_dcd_int_disable(rhport);
+
if (epnum) {
_dcd.pipe_buf_is_fifo[tu_edpt_dir(ep_addr)] &= ~TU_BIT(epnum - 1);
ret = edpt_n_xfer(rhport, ep_addr, buffer, total_bytes);
- } else
+ } else {
ret = edpt0_xfer(rhport, ep_addr, buffer, total_bytes);
- if (ie) NVIC_EnableIRQ(USB0_IRQn);
+ }
+
+ if (ie) musb_dcd_int_enable(rhport);
return ret;
}
-// Submit a transfer where is managed by FIFO, When complete dcd_event_xfer_complete() is invoked to notify the stack - optional, however, must be listed in usbd.c
+// Submit a transfer where is managed by FIFO, When complete dcd_event_xfer_complete() is invoked to notify the stack
+// - optional, however, must be listed in usbd.c
bool dcd_edpt_xfer_fifo(uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes)
{
(void)rhport;
@@ -810,99 +799,104 @@ bool dcd_edpt_xfer_fifo(uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_
// TU_LOG1("X %x %d\r\n", ep_addr, total_bytes);
unsigned const epnum = tu_edpt_number(ep_addr);
TU_ASSERT(epnum);
- unsigned const ie = NVIC_GetEnableIRQ(USB0_IRQn);
- NVIC_DisableIRQ(USB0_IRQn);
+ unsigned const ie = musb_dcd_get_int_enable(rhport);
+ musb_dcd_int_disable(rhport);
_dcd.pipe_buf_is_fifo[tu_edpt_dir(ep_addr)] |= TU_BIT(epnum - 1);
ret = edpt_n_xfer(rhport, ep_addr, (uint8_t*)ff, total_bytes);
- if (ie) NVIC_EnableIRQ(USB0_IRQn);
+ if (ie) musb_dcd_int_enable(rhport);
return ret;
}
// Stall endpoint
-void dcd_edpt_stall(uint8_t rhport, uint8_t ep_addr)
-{
- (void)rhport;
+void dcd_edpt_stall(uint8_t rhport, uint8_t ep_addr) {
+ unsigned const ie = musb_dcd_get_int_enable(rhport);
+ musb_dcd_int_disable(rhport);
+
unsigned const epn = tu_edpt_number(ep_addr);
- unsigned const ie = NVIC_GetEnableIRQ(USB0_IRQn);
- NVIC_DisableIRQ(USB0_IRQn);
+ musb_regs_t* musb_regs = MUSB_REGS(rhport);
+ musb_ep_csr_t* ep_csr = get_ep_csr(musb_regs, epn);
+
if (0 == epn) {
if (!ep_addr) { /* Ignore EP80 */
_dcd.setup_packet.bmRequestType = REQUEST_TYPE_INVALID;
_dcd.pipe0.buf = NULL;
- USB0->CSRL0 = USB_CSRL0_STALL;
+ ep_csr->csr0l = MUSB_CSRL0_STALL;
}
} else {
- volatile hw_endpoint_t *regs = edpt_regs(epn - 1);
- if (tu_edpt_dir(ep_addr)) { /* IN */
- regs->TXCSRL = USB_TXCSRL1_STALL;
- } else { /* OUT */
- TU_ASSERT(!(regs->RXCSRL & USB_RXCSRL1_RXRDY),);
- regs->RXCSRL = USB_RXCSRL1_STALL;
- }
+ const uint8_t is_rx = 1 - tu_edpt_dir(ep_addr);
+ ep_csr->maxp_csr[is_rx].csrl = MUSB_CSRL_SEND_STALL(is_rx);
}
- if (ie) NVIC_EnableIRQ(USB0_IRQn);
+
+ if (ie) musb_dcd_int_enable(rhport);
}
// clear stall, data toggle is also reset to DATA0
void dcd_edpt_clear_stall(uint8_t rhport, uint8_t ep_addr)
{
(void)rhport;
+ unsigned const ie = musb_dcd_get_int_enable(rhport);
+ musb_dcd_int_disable(rhport);
+
unsigned const epn = tu_edpt_number(ep_addr);
- hw_endpoint_t volatile *regs = edpt_regs(epn - 1);
- unsigned const ie = NVIC_GetEnableIRQ(USB0_IRQn);
- NVIC_DisableIRQ(USB0_IRQn);
- if (tu_edpt_dir(ep_addr)) { /* IN */
- regs->TXCSRL = USB_TXCSRL1_CLRDT;
- } else { /* OUT */
- regs->RXCSRL = USB_RXCSRL1_CLRDT;
- }
- if (ie) NVIC_EnableIRQ(USB0_IRQn);
+ musb_regs_t* musb_regs = MUSB_REGS(rhport);
+ musb_ep_csr_t* ep_csr = get_ep_csr(musb_regs, epn);
+ const uint8_t is_rx = 1 - tu_edpt_dir(ep_addr);
+
+ ep_csr->maxp_csr[is_rx].csrl = MUSB_CSRL_CLEAR_DATA_TOGGLE(is_rx);
+
+ if (ie) musb_dcd_int_enable(rhport);
}
/*-------------------------------------------------------------------
* ISR
*-------------------------------------------------------------------*/
-void dcd_int_handler(uint8_t rhport)
-{
- uint_fast8_t is, txis, rxis;
+void dcd_int_handler(uint8_t rhport) {
+ musb_regs_t* musb_regs = MUSB_REGS(rhport);
+ const uint8_t saved_index = musb_regs->index; // save endpoint index
- is = USB0->IS; /* read and clear interrupt status */
- txis = USB0->TXIS; /* read and clear interrupt status */
- rxis = USB0->RXIS; /* read and clear interrupt status */
+ //Part specific ISR setup/entry
+ musb_dcd_int_handler_enter(rhport);
+
+ uint_fast8_t intr_usb = musb_regs->intr_usb; // a read will clear this interrupt status
+ uint_fast8_t intr_tx = musb_regs->intr_tx; // a read will clear this interrupt status
+ uint_fast8_t intr_rx = musb_regs->intr_rx; // a read will clear this interrupt status
// TU_LOG1("D%2x T%2x R%2x\r\n", is, txis, rxis);
- is &= USB0->IE; /* Clear disabled interrupts */
- if (is & USB_IS_DISCON) {
+ intr_usb &= musb_regs->intr_usben; /* Clear disabled interrupts */
+ if (intr_usb & MUSB_IS_DISCON) {
}
- if (is & USB_IS_SOF) {
+ if (intr_usb & MUSB_IS_SOF) {
dcd_event_bus_signal(rhport, DCD_EVENT_SOF, true);
}
- if (is & USB_IS_RESET) {
+ if (intr_usb & MUSB_IS_RESET) {
process_bus_reset(rhport);
}
- if (is & USB_IS_RESUME) {
+ if (intr_usb & MUSB_IS_RESUME) {
dcd_event_bus_signal(rhport, DCD_EVENT_RESUME, true);
}
- if (is & USB_IS_SUSPEND) {
+ if (intr_usb & MUSB_IS_SUSPEND) {
dcd_event_bus_signal(rhport, DCD_EVENT_SUSPEND, true);
}
- txis &= USB0->TXIE; /* Clear disabled interrupts */
- if (txis & USB_TXIE_EP0) {
+ intr_tx &= musb_regs->intr_txen; /* Clear disabled interrupts */
+ if (intr_tx & TU_BIT(0)) {
process_ep0(rhport);
- txis &= ~TU_BIT(0);
+ intr_tx &= ~TU_BIT(0);
}
- while (txis) {
- unsigned const num = __builtin_ctz(txis);
+ while (intr_tx) {
+ unsigned const num = __builtin_ctz(intr_tx);
process_edpt_n(rhport, tu_edpt_addr(num, TUSB_DIR_IN));
- txis &= ~TU_BIT(num);
+ intr_tx &= ~TU_BIT(num);
}
- rxis &= USB0->RXIE; /* Clear disabled interrupts */
- while (rxis) {
- unsigned const num = __builtin_ctz(rxis);
+
+ intr_rx &= musb_regs->intr_rxen; /* Clear disabled interrupts */
+ while (intr_rx) {
+ unsigned const num = __builtin_ctz(intr_rx);
process_edpt_n(rhport, tu_edpt_addr(num, TUSB_DIR_OUT));
- rxis &= ~TU_BIT(num);
+ intr_rx &= ~TU_BIT(num);
}
+
+ musb_regs->index = saved_index; // restore endpoint index
}
#endif
diff --git a/src/portable/mentor/musb/hcd_musb.c b/src/portable/mentor/musb/hcd_musb.c
index 5312c2812..8fc225676 100644
--- a/src/portable/mentor/musb/hcd_musb.c
+++ b/src/portable/mentor/musb/hcd_musb.c
@@ -37,16 +37,10 @@ _Pragma("GCC diagnostic ignored \"-Waddress-of-packed-member\"");
#include "host/hcd.h"
-#if TU_CHECK_MCU(OPT_MCU_MSP432E4)
- #include "musb_msp432e.h"
-
-#elif TU_CHECK_MCU(OPT_MCU_TM4C123, OPT_MCU_TM4C129)
- #include "musb_tm4c.h"
-
- // HACK generalize later
- #include "musb_type.h"
- #define FIFO0_WORD FIFO0
+#include "musb_type.h"
+#if TU_CHECK_MCU(OPT_MCU_MSP432E4, OPT_MCU_TM4C123, OPT_MCU_TM4C129)
+ #include "musb_ti.h"
#else
#error "Unsupported MCUs"
#endif
diff --git a/src/portable/mentor/musb/musb_max32.h b/src/portable/mentor/musb/musb_max32.h
new file mode 100644
index 000000000..35849b5f8
--- /dev/null
+++ b/src/portable/mentor/musb/musb_max32.h
@@ -0,0 +1,150 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2024, Brent Kowal (Analog Devices, Inc)
+ *
+ * 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 THE
+ * AUTHORS OR COPYRIGHT HOLDERS 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.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef TUSB_MUSB_MAX32_H_
+#define TUSB_MUSB_MAX32_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "mxc_device.h"
+#include "usbhs_regs.h"
+
+#define MUSB_CFG_SHARED_FIFO 1 // shared FIFO for TX and RX endpoints
+#define MUSB_CFG_DYNAMIC_FIFO 0 // dynamic EP FIFO sizing
+
+const uintptr_t MUSB_BASES[] = { MXC_BASE_USBHS };
+
+#if CFG_TUD_ENABLED
+#define USBHS_M31_CLOCK_RECOVERY
+
+// Mapping of IRQ numbers to port. Currently just 1.
+static const IRQn_Type musb_irqs[] = {
+ USB_IRQn
+};
+
+TU_ATTR_ALWAYS_INLINE static inline void musb_dcd_int_enable(uint8_t rhport) {
+ NVIC_EnableIRQ(musb_irqs[rhport]);
+}
+
+TU_ATTR_ALWAYS_INLINE static inline void musb_dcd_int_disable(uint8_t rhport) {
+ NVIC_DisableIRQ(musb_irqs[rhport]);
+}
+
+TU_ATTR_ALWAYS_INLINE static inline unsigned musb_dcd_get_int_enable(uint8_t rhport) {
+ #ifdef NVIC_GetEnableIRQ // only defined in CMSIS 5
+ return NVIC_GetEnableIRQ(musb_irqs[rhport]);
+ #else
+ uint32_t IRQn = (uint32_t) musb_irqs[rhport];
+ return ((NVIC->ISER[IRQn >> 5UL] & (1UL << (IRQn & 0x1FUL))) != 0UL) ? 1UL : 0UL;
+ #endif
+}
+
+TU_ATTR_ALWAYS_INLINE static inline void musb_dcd_int_clear(uint8_t rhport) {
+ NVIC_ClearPendingIRQ(musb_irqs[rhport]);
+}
+
+static inline void musb_dcd_int_handler_enter(uint8_t rhport) {
+ mxc_usbhs_regs_t* hs_phy = MXC_USBHS;
+ uint32_t mxm_int, mxm_int_en, mxm_is;
+
+ //Handle PHY specific events
+ mxm_int = hs_phy->mxm_int;
+ mxm_int_en = hs_phy->mxm_int_en;
+ mxm_is = mxm_int & mxm_int_en;
+ hs_phy->mxm_int = mxm_is;
+
+ if (mxm_is & MXC_F_USBHS_MXM_INT_NOVBUS) {
+ dcd_event_bus_signal(rhport, DCD_EVENT_UNPLUGGED, true);
+ }
+}
+
+static inline void musb_dcd_phy_init(uint8_t rhport) {
+ (void) rhport;
+ mxc_usbhs_regs_t* hs_phy = MXC_USBHS;
+
+ // Interrupt for VBUS disconnect
+ hs_phy->mxm_int_en |= MXC_F_USBHS_MXM_INT_EN_NOVBUS;
+
+ musb_dcd_int_clear(rhport);
+
+ // Unsuspend the MAC
+ hs_phy->mxm_suspend = 0;
+
+ // Configure PHY
+ hs_phy->m31_phy_xcfgi_31_0 = (0x1 << 3) | (0x1 << 11);
+ hs_phy->m31_phy_xcfgi_63_32 = 0;
+ hs_phy->m31_phy_xcfgi_95_64 = 0x1 << (72 - 64);
+ hs_phy->m31_phy_xcfgi_127_96 = 0;
+
+ #ifdef USBHS_M31_CLOCK_RECOVERY
+ hs_phy->m31_phy_noncry_rstb = 1;
+ hs_phy->m31_phy_noncry_en = 1;
+ hs_phy->m31_phy_outclksel = 0;
+ hs_phy->m31_phy_coreclkin = 0;
+ hs_phy->m31_phy_xtlsel = 2; /* Select 25 MHz clock */
+ #else
+ hs_phy->m31_phy_noncry_rstb = 0;
+ hs_phy->m31_phy_noncry_en = 0;
+ hs_phy->m31_phy_outclksel = 1;
+ hs_phy->m31_phy_coreclkin = 1;
+ hs_phy->m31_phy_xtlsel = 3; /* Select 30 MHz clock */
+ #endif
+ hs_phy->m31_phy_pll_en = 1;
+ hs_phy->m31_phy_oscouten = 1;
+
+ /* Reset PHY */
+ hs_phy->m31_phy_ponrst = 0;
+ hs_phy->m31_phy_ponrst = 1;
+}
+
+// static inline void musb_dcd_setup_fifo(uint8_t rhport, unsigned epnum, unsigned dir_in, unsigned mps) {
+// (void) mps;
+//
+// //Most likely the caller has already grabbed the right register block. But
+// //as a precaution save and restore the register bank anyways
+// unsigned saved_index = musb_periph_inst[rhport]->index;
+//
+// musb_periph_inst[rhport]->index = epnum;
+//
+// //Disable double buffering
+// if (dir_in) {
+// musb_periph_inst[rhport]->incsru |= (MXC_F_USBHS_INCSRU_DPKTBUFDIS | MXC_F_USBHS_INCSRU_MODE);
+// } else {
+// musb_periph_inst[rhport]->outcsru |= (MXC_F_USBHS_OUTCSRU_DPKTBUFDIS);
+// }
+//
+// musb_periph_inst[rhport]->index = saved_index;
+// }
+
+#endif // CFG_TUD_ENABLED
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // TUSB_MUSB_MAX32_H_
diff --git a/src/portable/mentor/musb/musb_ti.h b/src/portable/mentor/musb/musb_ti.h
new file mode 100644
index 000000000..d17e836ee
--- /dev/null
+++ b/src/portable/mentor/musb/musb_ti.h
@@ -0,0 +1,91 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2024, Brent Kowal (Analog Devices, Inc)
+ *
+ * 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 THE
+ * AUTHORS OR COPYRIGHT HOLDERS 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.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef TUSB_MUSB_TI_H_
+#define TUSB_MUSB_TI_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#if CFG_TUSB_MCU == OPT_MCU_TM4C123
+ #include "TM4C123.h"
+ #define FIFO0_WORD FIFO0
+ #define FIFO1_WORD FIFO1
+//#elif CFG_TUSB_MCU == OPT_MCU_TM4C129
+#elif CFG_TUSB_MCU == OPT_MCU_MSP432E4
+ #include "msp.h"
+#else
+ #error "Unsupported MCUs"
+#endif
+
+#define MUSB_CFG_SHARED_FIFO 0
+#define MUSB_CFG_DYNAMIC_FIFO 1
+#define MUSB_CFG_DYNAMIC_FIFO_SIZE 4096
+
+const uintptr_t MUSB_BASES[] = { USB0_BASE };
+
+// Header supports both device and host modes. Only include what's necessary
+#if CFG_TUD_ENABLED
+
+// Mapping of IRQ numbers to port. Currently just 1.
+static const IRQn_Type musb_irqs[] = {
+ USB0_IRQn
+};
+
+static inline void musb_dcd_phy_init(uint8_t rhport){
+ (void)rhport;
+ //Nothing to do for this part
+}
+
+TU_ATTR_ALWAYS_INLINE static inline void musb_dcd_int_enable(uint8_t rhport) {
+ NVIC_EnableIRQ(musb_irqs[rhport]);
+}
+
+TU_ATTR_ALWAYS_INLINE static inline void musb_dcd_int_disable(uint8_t rhport) {
+ NVIC_DisableIRQ(musb_irqs[rhport]);
+}
+
+TU_ATTR_ALWAYS_INLINE static inline unsigned musb_dcd_get_int_enable(uint8_t rhport) {
+ return NVIC_GetEnableIRQ(musb_irqs[rhport]);
+}
+
+TU_ATTR_ALWAYS_INLINE static inline void musb_dcd_int_clear(uint8_t rhport) {
+ NVIC_ClearPendingIRQ(musb_irqs[rhport]);
+}
+
+static inline void musb_dcd_int_handler_enter(uint8_t rhport) {
+ (void)rhport;
+ //Nothing to do for this part
+}
+
+#endif // CFG_TUD_ENABLED
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif // TUSB_MUSB_TI_H_
diff --git a/src/portable/mentor/musb/musb_type.h b/src/portable/mentor/musb/musb_type.h
index 8f83305a5..4e448c0ed 100644
--- a/src/portable/mentor/musb/musb_type.h
+++ b/src/portable/mentor/musb/musb_type.h
@@ -1,3 +1,29 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Ha Thach (tinyusb.org)
+ *
+ * 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 THE
+ * AUTHORS OR COPYRIGHT HOLDERS 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.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
/******************************************************************************
*
* Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/
@@ -32,2590 +58,696 @@
*
*******************************************************************************/
-#ifndef _TUSB_MUSB_TYPE_H_
-#define _TUSB_MUSB_TYPE_H_
+#ifndef TUSB_MUSB_TYPE_H_
+#define TUSB_MUSB_TYPE_H_
+
+#include "stdint.h"
#ifdef __cplusplus
extern "C" {
#endif
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_FADDR register.
-//
-//*****************************************************************************
-#define USB_FADDR_M 0x0000007F // Function Address
-#define USB_FADDR_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_POWER register.
-//
-//*****************************************************************************
-#define USB_POWER_ISOUP 0x00000080 // Isochronous Update
-#define USB_POWER_SOFTCONN 0x00000040 // Soft Connect/Disconnect
-#define USB_POWER_HSENAB 0x00000020 // High Speed Enable
-#define USB_POWER_HSMODE 0x00000010 // High Speed Enable
-#define USB_POWER_RESET 0x00000008 // RESET Signaling
-#define USB_POWER_RESUME 0x00000004 // RESUME Signaling
-#define USB_POWER_SUSPEND 0x00000002 // SUSPEND Mode
-#define USB_POWER_PWRDNPHY 0x00000001 // Power Down PHY
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_TXIS register.
-//
-//*****************************************************************************
-#define USB_TXIS_EP7 0x00000080 // TX Endpoint 7 Interrupt
-#define USB_TXIS_EP6 0x00000040 // TX Endpoint 6 Interrupt
-#define USB_TXIS_EP5 0x00000020 // TX Endpoint 5 Interrupt
-#define USB_TXIS_EP4 0x00000010 // TX Endpoint 4 Interrupt
-#define USB_TXIS_EP3 0x00000008 // TX Endpoint 3 Interrupt
-#define USB_TXIS_EP2 0x00000004 // TX Endpoint 2 Interrupt
-#define USB_TXIS_EP1 0x00000002 // TX Endpoint 1 Interrupt
-#define USB_TXIS_EP0 0x00000001 // TX and RX Endpoint 0 Interrupt
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RXIS register.
-//
-//*****************************************************************************
-#define USB_RXIS_EP7 0x00000080 // RX Endpoint 7 Interrupt
-#define USB_RXIS_EP6 0x00000040 // RX Endpoint 6 Interrupt
-#define USB_RXIS_EP5 0x00000020 // RX Endpoint 5 Interrupt
-#define USB_RXIS_EP4 0x00000010 // RX Endpoint 4 Interrupt
-#define USB_RXIS_EP3 0x00000008 // RX Endpoint 3 Interrupt
-#define USB_RXIS_EP2 0x00000004 // RX Endpoint 2 Interrupt
-#define USB_RXIS_EP1 0x00000002 // RX Endpoint 1 Interrupt
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_TXIE register.
-//
-//*****************************************************************************
-#define USB_TXIE_EP7 0x00000080 // TX Endpoint 7 Interrupt Enable
-#define USB_TXIE_EP6 0x00000040 // TX Endpoint 6 Interrupt Enable
-#define USB_TXIE_EP5 0x00000020 // TX Endpoint 5 Interrupt Enable
-#define USB_TXIE_EP4 0x00000010 // TX Endpoint 4 Interrupt Enable
-#define USB_TXIE_EP3 0x00000008 // TX Endpoint 3 Interrupt Enable
-#define USB_TXIE_EP2 0x00000004 // TX Endpoint 2 Interrupt Enable
-#define USB_TXIE_EP1 0x00000002 // TX Endpoint 1 Interrupt Enable
-#define USB_TXIE_EP0 0x00000001 // TX and RX Endpoint 0 Interrupt
- // Enable
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RXIE register.
-//
-//*****************************************************************************
-#define USB_RXIE_EP7 0x00000080 // RX Endpoint 7 Interrupt Enable
-#define USB_RXIE_EP6 0x00000040 // RX Endpoint 6 Interrupt Enable
-#define USB_RXIE_EP5 0x00000020 // RX Endpoint 5 Interrupt Enable
-#define USB_RXIE_EP4 0x00000010 // RX Endpoint 4 Interrupt Enable
-#define USB_RXIE_EP3 0x00000008 // RX Endpoint 3 Interrupt Enable
-#define USB_RXIE_EP2 0x00000004 // RX Endpoint 2 Interrupt Enable
-#define USB_RXIE_EP1 0x00000002 // RX Endpoint 1 Interrupt Enable
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_IS register.
-//
-//*****************************************************************************
-#define USB_IS_VBUSERR 0x00000080 // VBUS Error (OTG only)
-#define USB_IS_SESREQ 0x00000040 // SESSION REQUEST (OTG only)
-#define USB_IS_DISCON 0x00000020 // Session Disconnect (OTG only)
-#define USB_IS_CONN 0x00000010 // Session Connect
-#define USB_IS_SOF 0x00000008 // Start of Frame
-#define USB_IS_BABBLE 0x00000004 // Babble Detected
-#define USB_IS_RESET 0x00000004 // RESET Signaling Detected
-#define USB_IS_RESUME 0x00000002 // RESUME Signaling Detected
-#define USB_IS_SUSPEND 0x00000001 // SUSPEND Signaling Detected
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_IE register.
-//
-//*****************************************************************************
-#define USB_IE_VBUSERR 0x00000080 // Enable VBUS Error Interrupt (OTG
- // only)
-#define USB_IE_SESREQ 0x00000040 // Enable Session Request (OTG
- // only)
-#define USB_IE_DISCON 0x00000020 // Enable Disconnect Interrupt
-#define USB_IE_CONN 0x00000010 // Enable Connect Interrupt
-#define USB_IE_SOF 0x00000008 // Enable Start-of-Frame Interrupt
-#define USB_IE_BABBLE 0x00000004 // Enable Babble Interrupt
-#define USB_IE_RESET 0x00000004 // Enable RESET Interrupt
-#define USB_IE_RESUME 0x00000002 // Enable RESUME Interrupt
-#define USB_IE_SUSPND 0x00000001 // Enable SUSPEND Interrupt
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_FRAME register.
-//
-//*****************************************************************************
-#define USB_FRAME_M 0x000007FF // Frame Number
-#define USB_FRAME_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_EPIDX register.
-//
-//*****************************************************************************
-#define USB_EPIDX_EPIDX_M 0x0000000F // Endpoint Index
-#define USB_EPIDX_EPIDX_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_TEST register.
-//
-//*****************************************************************************
-#define USB_TEST_FORCEH 0x00000080 // Force Host Mode
-#define USB_TEST_FIFOACC 0x00000040 // FIFO Access
-#define USB_TEST_FORCEFS 0x00000020 // Force Full-Speed Mode
-#define USB_TEST_FORCEHS 0x00000010 // Force High-Speed Mode
-#define USB_TEST_TESTPKT 0x00000008 // Test Packet Mode Enable
-#define USB_TEST_TESTK 0x00000004 // Test_K Mode Enable
-#define USB_TEST_TESTJ 0x00000002 // Test_J Mode Enable
-#define USB_TEST_TESTSE0NAK 0x00000001 // Test_SE0_NAK Test Mode Enable
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_FIFO0 register.
-//
-//*****************************************************************************
-#define USB_FIFO0_EPDATA_M 0xFFFFFFFF // Endpoint Data
-#define USB_FIFO0_EPDATA_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_FIFO1 register.
-//
-//*****************************************************************************
-#define USB_FIFO1_EPDATA_M 0xFFFFFFFF // Endpoint Data
-#define USB_FIFO1_EPDATA_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_FIFO2 register.
-//
-//*****************************************************************************
-#define USB_FIFO2_EPDATA_M 0xFFFFFFFF // Endpoint Data
-#define USB_FIFO2_EPDATA_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_FIFO3 register.
-//
-//*****************************************************************************
-#define USB_FIFO3_EPDATA_M 0xFFFFFFFF // Endpoint Data
-#define USB_FIFO3_EPDATA_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_FIFO4 register.
-//
-//*****************************************************************************
-#define USB_FIFO4_EPDATA_M 0xFFFFFFFF // Endpoint Data
-#define USB_FIFO4_EPDATA_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_FIFO5 register.
-//
-//*****************************************************************************
-#define USB_FIFO5_EPDATA_M 0xFFFFFFFF // Endpoint Data
-#define USB_FIFO5_EPDATA_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_FIFO6 register.
-//
-//*****************************************************************************
-#define USB_FIFO6_EPDATA_M 0xFFFFFFFF // Endpoint Data
-#define USB_FIFO6_EPDATA_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_FIFO7 register.
-//
-//*****************************************************************************
-#define USB_FIFO7_EPDATA_M 0xFFFFFFFF // Endpoint Data
-#define USB_FIFO7_EPDATA_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_DEVCTL register.
-//
-//*****************************************************************************
-#define USB_DEVCTL_DEV 0x00000080 // Device Mode (OTG only)
-#define USB_DEVCTL_FSDEV 0x00000040 // Full-Speed Device Detected
-#define USB_DEVCTL_LSDEV 0x00000020 // Low-Speed Device Detected
-#define USB_DEVCTL_VBUS_M 0x00000018 // VBUS Level (OTG only)
-#define USB_DEVCTL_VBUS_NONE 0x00000000 // Below SessionEnd
-#define USB_DEVCTL_VBUS_SEND 0x00000008 // Above SessionEnd, below AValid
-#define USB_DEVCTL_VBUS_AVALID 0x00000010 // Above AValid, below VBUSValid
-#define USB_DEVCTL_VBUS_VALID 0x00000018 // Above VBUSValid
-#define USB_DEVCTL_HOST 0x00000004 // Host Mode
-#define USB_DEVCTL_HOSTREQ 0x00000002 // Host Request (OTG only)
-#define USB_DEVCTL_SESSION 0x00000001 // Session Start/End (OTG only)
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_CCONF register.
-//
-//*****************************************************************************
-#define USB_CCONF_TXEDMA 0x00000002 // TX Early DMA Enable
-#define USB_CCONF_RXEDMA 0x00000001 // TX Early DMA Enable
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_TXFIFOSZ register.
-//
-//*****************************************************************************
-#define USB_TXFIFOSZ_DPB 0x00000010 // Double Packet Buffer Support
-#define USB_TXFIFOSZ_SIZE_M 0x0000000F // Max Packet Size
-#define USB_TXFIFOSZ_SIZE_8 0x00000000 // 8
-#define USB_TXFIFOSZ_SIZE_16 0x00000001 // 16
-#define USB_TXFIFOSZ_SIZE_32 0x00000002 // 32
-#define USB_TXFIFOSZ_SIZE_64 0x00000003 // 64
-#define USB_TXFIFOSZ_SIZE_128 0x00000004 // 128
-#define USB_TXFIFOSZ_SIZE_256 0x00000005 // 256
-#define USB_TXFIFOSZ_SIZE_512 0x00000006 // 512
-#define USB_TXFIFOSZ_SIZE_1024 0x00000007 // 1024
-#define USB_TXFIFOSZ_SIZE_2048 0x00000008 // 2048
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RXFIFOSZ register.
-//
-//*****************************************************************************
-#define USB_RXFIFOSZ_DPB 0x00000010 // Double Packet Buffer Support
-#define USB_RXFIFOSZ_SIZE_M 0x0000000F // Max Packet Size
-#define USB_RXFIFOSZ_SIZE_8 0x00000000 // 8
-#define USB_RXFIFOSZ_SIZE_16 0x00000001 // 16
-#define USB_RXFIFOSZ_SIZE_32 0x00000002 // 32
-#define USB_RXFIFOSZ_SIZE_64 0x00000003 // 64
-#define USB_RXFIFOSZ_SIZE_128 0x00000004 // 128
-#define USB_RXFIFOSZ_SIZE_256 0x00000005 // 256
-#define USB_RXFIFOSZ_SIZE_512 0x00000006 // 512
-#define USB_RXFIFOSZ_SIZE_1024 0x00000007 // 1024
-#define USB_RXFIFOSZ_SIZE_2048 0x00000008 // 2048
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_TXFIFOADD
-// register.
-//
-//*****************************************************************************
-#define USB_TXFIFOADD_ADDR_M 0x000001FF // Transmit/Receive Start Address
-#define USB_TXFIFOADD_ADDR_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RXFIFOADD
-// register.
-//
-//*****************************************************************************
-#define USB_RXFIFOADD_ADDR_M 0x000001FF // Transmit/Receive Start Address
-#define USB_RXFIFOADD_ADDR_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_ULPIVBUSCTL
-// register.
-//
-//*****************************************************************************
-#define USB_ULPIVBUSCTL_USEEXTVBUSIND \
- 0x00000002 // Use External VBUS Indicator
-#define USB_ULPIVBUSCTL_USEEXTVBUS \
- 0x00000001 // Use External VBUS
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_ULPIREGDATA
-// register.
-//
-//*****************************************************************************
-#define USB_ULPIREGDATA_REGDATA_M \
- 0x000000FF // Register Data
-#define USB_ULPIREGDATA_REGDATA_S \
- 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_ULPIREGADDR
-// register.
-//
-//*****************************************************************************
-#define USB_ULPIREGADDR_ADDR_M 0x000000FF // Register Address
-#define USB_ULPIREGADDR_ADDR_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_ULPIREGCTL
-// register.
-//
-//*****************************************************************************
-#define USB_ULPIREGCTL_RDWR 0x00000004 // Read/Write Control
-#define USB_ULPIREGCTL_REGCMPLT 0x00000002 // Register Access Complete
-#define USB_ULPIREGCTL_REGACC 0x00000001 // Initiate Register Access
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_EPINFO register.
-//
-//*****************************************************************************
-#define USB_EPINFO_RXEP_M 0x000000F0 // RX Endpoints
-#define USB_EPINFO_TXEP_M 0x0000000F // TX Endpoints
-#define USB_EPINFO_RXEP_S 4
-#define USB_EPINFO_TXEP_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RAMINFO register.
-//
-//*****************************************************************************
-#define USB_RAMINFO_DMACHAN_M 0x000000F0 // DMA Channels
-#define USB_RAMINFO_RAMBITS_M 0x0000000F // RAM Address Bus Width
-#define USB_RAMINFO_DMACHAN_S 4
-#define USB_RAMINFO_RAMBITS_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_CONTIM register.
-//
-//*****************************************************************************
-#define USB_CONTIM_WTCON_M 0x000000F0 // Connect Wait
-#define USB_CONTIM_WTID_M 0x0000000F // Wait ID
-#define USB_CONTIM_WTCON_S 4
-#define USB_CONTIM_WTID_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_VPLEN register.
-//
-//*****************************************************************************
-#define USB_VPLEN_VPLEN_M 0x000000FF // VBUS Pulse Length
-#define USB_VPLEN_VPLEN_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_HSEOF register.
-//
-//*****************************************************************************
-#define USB_HSEOF_HSEOFG_M 0x000000FF // HIgh-Speed End-of-Frame Gap
-#define USB_HSEOF_HSEOFG_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_FSEOF register.
-//
-//*****************************************************************************
-#define USB_FSEOF_FSEOFG_M 0x000000FF // Full-Speed End-of-Frame Gap
-#define USB_FSEOF_FSEOFG_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_LSEOF register.
-//
-//*****************************************************************************
-#define USB_LSEOF_LSEOFG_M 0x000000FF // Low-Speed End-of-Frame Gap
-#define USB_LSEOF_LSEOFG_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_TXFUNCADDR0
-// register.
-//
-//*****************************************************************************
-#define USB_TXFUNCADDR0_ADDR_M 0x0000007F // Device Address
-#define USB_TXFUNCADDR0_ADDR_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_TXHUBADDR0
-// register.
-//
-//*****************************************************************************
-#define USB_TXHUBADDR0_ADDR_M 0x0000007F // Hub Address
-#define USB_TXHUBADDR0_ADDR_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_TXHUBPORT0
-// register.
-//
-//*****************************************************************************
-#define USB_TXHUBPORT0_PORT_M 0x0000007F // Hub Port
-#define USB_TXHUBPORT0_PORT_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_TXFUNCADDR1
-// register.
-//
-//*****************************************************************************
-#define USB_TXFUNCADDR1_ADDR_M 0x0000007F // Device Address
-#define USB_TXFUNCADDR1_ADDR_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_TXHUBADDR1
-// register.
-//
-//*****************************************************************************
-#define USB_TXHUBADDR1_ADDR_M 0x0000007F // Hub Address
-#define USB_TXHUBADDR1_ADDR_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_TXHUBPORT1
-// register.
-//
-//*****************************************************************************
-#define USB_TXHUBPORT1_PORT_M 0x0000007F // Hub Port
-#define USB_TXHUBPORT1_PORT_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RXFUNCADDR1
-// register.
-//
-//*****************************************************************************
-#define USB_RXFUNCADDR1_ADDR_M 0x0000007F // Device Address
-#define USB_RXFUNCADDR1_ADDR_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RXHUBADDR1
-// register.
-//
-//*****************************************************************************
-#define USB_RXHUBADDR1_ADDR_M 0x0000007F // Hub Address
-#define USB_RXHUBADDR1_ADDR_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RXHUBPORT1
-// register.
-//
-//*****************************************************************************
-#define USB_RXHUBPORT1_PORT_M 0x0000007F // Hub Port
-#define USB_RXHUBPORT1_PORT_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_TXFUNCADDR2
-// register.
-//
-//*****************************************************************************
-#define USB_TXFUNCADDR2_ADDR_M 0x0000007F // Device Address
-#define USB_TXFUNCADDR2_ADDR_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_TXHUBADDR2
-// register.
-//
-//*****************************************************************************
-#define USB_TXHUBADDR2_ADDR_M 0x0000007F // Hub Address
-#define USB_TXHUBADDR2_ADDR_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_TXHUBPORT2
-// register.
-//
-//*****************************************************************************
-#define USB_TXHUBPORT2_PORT_M 0x0000007F // Hub Port
-#define USB_TXHUBPORT2_PORT_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RXFUNCADDR2
-// register.
-//
-//*****************************************************************************
-#define USB_RXFUNCADDR2_ADDR_M 0x0000007F // Device Address
-#define USB_RXFUNCADDR2_ADDR_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RXHUBADDR2
-// register.
-//
-//*****************************************************************************
-#define USB_RXHUBADDR2_ADDR_M 0x0000007F // Hub Address
-#define USB_RXHUBADDR2_ADDR_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RXHUBPORT2
-// register.
-//
-//*****************************************************************************
-#define USB_RXHUBPORT2_PORT_M 0x0000007F // Hub Port
-#define USB_RXHUBPORT2_PORT_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_TXFUNCADDR3
-// register.
-//
-//*****************************************************************************
-#define USB_TXFUNCADDR3_ADDR_M 0x0000007F // Device Address
-#define USB_TXFUNCADDR3_ADDR_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_TXHUBADDR3
-// register.
-//
-//*****************************************************************************
-#define USB_TXHUBADDR3_ADDR_M 0x0000007F // Hub Address
-#define USB_TXHUBADDR3_ADDR_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_TXHUBPORT3
-// register.
-//
-//*****************************************************************************
-#define USB_TXHUBPORT3_PORT_M 0x0000007F // Hub Port
-#define USB_TXHUBPORT3_PORT_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RXFUNCADDR3
-// register.
-//
-//*****************************************************************************
-#define USB_RXFUNCADDR3_ADDR_M 0x0000007F // Device Address
-#define USB_RXFUNCADDR3_ADDR_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RXHUBADDR3
-// register.
-//
-//*****************************************************************************
-#define USB_RXHUBADDR3_ADDR_M 0x0000007F // Hub Address
-#define USB_RXHUBADDR3_ADDR_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RXHUBPORT3
-// register.
-//
-//*****************************************************************************
-#define USB_RXHUBPORT3_PORT_M 0x0000007F // Hub Port
-#define USB_RXHUBPORT3_PORT_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_TXFUNCADDR4
-// register.
-//
-//*****************************************************************************
-#define USB_TXFUNCADDR4_ADDR_M 0x0000007F // Device Address
-#define USB_TXFUNCADDR4_ADDR_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_TXHUBADDR4
-// register.
-//
-//*****************************************************************************
-#define USB_TXHUBADDR4_ADDR_M 0x0000007F // Hub Address
-#define USB_TXHUBADDR4_ADDR_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_TXHUBPORT4
-// register.
-//
-//*****************************************************************************
-#define USB_TXHUBPORT4_PORT_M 0x0000007F // Hub Port
-#define USB_TXHUBPORT4_PORT_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RXFUNCADDR4
-// register.
-//
-//*****************************************************************************
-#define USB_RXFUNCADDR4_ADDR_M 0x0000007F // Device Address
-#define USB_RXFUNCADDR4_ADDR_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RXHUBADDR4
-// register.
-//
-//*****************************************************************************
-#define USB_RXHUBADDR4_ADDR_M 0x0000007F // Hub Address
-#define USB_RXHUBADDR4_ADDR_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RXHUBPORT4
-// register.
-//
-//*****************************************************************************
-#define USB_RXHUBPORT4_PORT_M 0x0000007F // Hub Port
-#define USB_RXHUBPORT4_PORT_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_TXFUNCADDR5
-// register.
-//
-//*****************************************************************************
-#define USB_TXFUNCADDR5_ADDR_M 0x0000007F // Device Address
-#define USB_TXFUNCADDR5_ADDR_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_TXHUBADDR5
-// register.
-//
-//*****************************************************************************
-#define USB_TXHUBADDR5_ADDR_M 0x0000007F // Hub Address
-#define USB_TXHUBADDR5_ADDR_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_TXHUBPORT5
-// register.
-//
-//*****************************************************************************
-#define USB_TXHUBPORT5_PORT_M 0x0000007F // Hub Port
-#define USB_TXHUBPORT5_PORT_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RXFUNCADDR5
-// register.
-//
-//*****************************************************************************
-#define USB_RXFUNCADDR5_ADDR_M 0x0000007F // Device Address
-#define USB_RXFUNCADDR5_ADDR_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RXHUBADDR5
-// register.
-//
-//*****************************************************************************
-#define USB_RXHUBADDR5_ADDR_M 0x0000007F // Hub Address
-#define USB_RXHUBADDR5_ADDR_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RXHUBPORT5
-// register.
-//
-//*****************************************************************************
-#define USB_RXHUBPORT5_PORT_M 0x0000007F // Hub Port
-#define USB_RXHUBPORT5_PORT_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_TXFUNCADDR6
-// register.
-//
-//*****************************************************************************
-#define USB_TXFUNCADDR6_ADDR_M 0x0000007F // Device Address
-#define USB_TXFUNCADDR6_ADDR_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_TXHUBADDR6
-// register.
-//
-//*****************************************************************************
-#define USB_TXHUBADDR6_ADDR_M 0x0000007F // Hub Address
-#define USB_TXHUBADDR6_ADDR_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_TXHUBPORT6
-// register.
-//
-//*****************************************************************************
-#define USB_TXHUBPORT6_PORT_M 0x0000007F // Hub Port
-#define USB_TXHUBPORT6_PORT_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RXFUNCADDR6
-// register.
-//
-//*****************************************************************************
-#define USB_RXFUNCADDR6_ADDR_M 0x0000007F // Device Address
-#define USB_RXFUNCADDR6_ADDR_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RXHUBADDR6
-// register.
-//
-//*****************************************************************************
-#define USB_RXHUBADDR6_ADDR_M 0x0000007F // Hub Address
-#define USB_RXHUBADDR6_ADDR_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RXHUBPORT6
-// register.
-//
-//*****************************************************************************
-#define USB_RXHUBPORT6_PORT_M 0x0000007F // Hub Port
-#define USB_RXHUBPORT6_PORT_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_TXFUNCADDR7
-// register.
-//
-//*****************************************************************************
-#define USB_TXFUNCADDR7_ADDR_M 0x0000007F // Device Address
-#define USB_TXFUNCADDR7_ADDR_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_TXHUBADDR7
-// register.
-//
-//*****************************************************************************
-#define USB_TXHUBADDR7_ADDR_M 0x0000007F // Hub Address
-#define USB_TXHUBADDR7_ADDR_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_TXHUBPORT7
-// register.
-//
-//*****************************************************************************
-#define USB_TXHUBPORT7_PORT_M 0x0000007F // Hub Port
-#define USB_TXHUBPORT7_PORT_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RXFUNCADDR7
-// register.
-//
-//*****************************************************************************
-#define USB_RXFUNCADDR7_ADDR_M 0x0000007F // Device Address
-#define USB_RXFUNCADDR7_ADDR_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RXHUBADDR7
-// register.
-//
-//*****************************************************************************
-#define USB_RXHUBADDR7_ADDR_M 0x0000007F // Hub Address
-#define USB_RXHUBADDR7_ADDR_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RXHUBPORT7
-// register.
-//
-//*****************************************************************************
-#define USB_RXHUBPORT7_PORT_M 0x0000007F // Hub Port
-#define USB_RXHUBPORT7_PORT_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_CSRL0 register.
-//
-//*****************************************************************************
-#define USB_CSRL0_NAKTO 0x00000080 // NAK Timeout
-#define USB_CSRL0_SETENDC 0x00000080 // Setup End Clear
-#define USB_CSRL0_STATUS 0x00000040 // STATUS Packet
-#define USB_CSRL0_RXRDYC 0x00000040 // RXRDY Clear
-#define USB_CSRL0_REQPKT 0x00000020 // Request Packet
-#define USB_CSRL0_STALL 0x00000020 // Send Stall
-#define USB_CSRL0_SETEND 0x00000010 // Setup End
-#define USB_CSRL0_ERROR 0x00000010 // Error
-#define USB_CSRL0_DATAEND 0x00000008 // Data End
-#define USB_CSRL0_SETUP 0x00000008 // Setup Packet
-#define USB_CSRL0_STALLED 0x00000004 // Endpoint Stalled
-#define USB_CSRL0_TXRDY 0x00000002 // Transmit Packet Ready
-#define USB_CSRL0_RXRDY 0x00000001 // Receive Packet Ready
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_CSRH0 register.
-//
-//*****************************************************************************
-#define USB_CSRH0_DISPING 0x00000008 // PING Disable
-#define USB_CSRH0_DTWE 0x00000004 // Data Toggle Write Enable
-#define USB_CSRH0_DT 0x00000002 // Data Toggle
-#define USB_CSRH0_FLUSH 0x00000001 // Flush FIFO
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_COUNT0 register.
-//
-//*****************************************************************************
-#define USB_COUNT0_COUNT_M 0x0000007F // FIFO Count
-#define USB_COUNT0_COUNT_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_TYPE0 register.
-//
-//*****************************************************************************
-#define USB_TYPE0_SPEED_M 0x000000C0 // Operating Speed
-#define USB_TYPE0_SPEED_HIGH 0x00000040 // High
-#define USB_TYPE0_SPEED_FULL 0x00000080 // Full
-#define USB_TYPE0_SPEED_LOW 0x000000C0 // Low
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_NAKLMT register.
-//
-//*****************************************************************************
-#define USB_NAKLMT_NAKLMT_M 0x0000001F // EP0 NAK Limit
-#define USB_NAKLMT_NAKLMT_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_TXMAXP1 register.
-//
-//*****************************************************************************
-#define USB_TXMAXP1_MAXLOAD_M 0x000007FF // Maximum Payload
-#define USB_TXMAXP1_MAXLOAD_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_TXCSRL1 register.
-//
-//*****************************************************************************
-#define USB_TXCSRL1_NAKTO 0x00000080 // NAK Timeout
-#define USB_TXCSRL1_CLRDT 0x00000040 // Clear Data Toggle
-#define USB_TXCSRL1_STALLED 0x00000020 // Endpoint Stalled
-#define USB_TXCSRL1_STALL 0x00000010 // Send STALL
-#define USB_TXCSRL1_SETUP 0x00000010 // Setup Packet
-#define USB_TXCSRL1_FLUSH 0x00000008 // Flush FIFO
-#define USB_TXCSRL1_ERROR 0x00000004 // Error
-#define USB_TXCSRL1_UNDRN 0x00000004 // Underrun
-#define USB_TXCSRL1_FIFONE 0x00000002 // FIFO Not Empty
-#define USB_TXCSRL1_TXRDY 0x00000001 // Transmit Packet Ready
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_TXCSRH1 register.
-//
-//*****************************************************************************
-#define USB_TXCSRH1_AUTOSET 0x00000080 // Auto Set
-#define USB_TXCSRH1_ISO 0x00000040 // Isochronous Transfers
-#define USB_TXCSRH1_MODE 0x00000020 // Mode
-#define USB_TXCSRH1_DMAEN 0x00000010 // DMA Request Enable
-#define USB_TXCSRH1_FDT 0x00000008 // Force Data Toggle
-#define USB_TXCSRH1_DMAMOD 0x00000004 // DMA Request Mode
-#define USB_TXCSRH1_DTWE 0x00000002 // Data Toggle Write Enable
-#define USB_TXCSRH1_DT 0x00000001 // Data Toggle
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RXMAXP1 register.
-//
-//*****************************************************************************
-#define USB_RXMAXP1_MAXLOAD_M 0x000007FF // Maximum Payload
-#define USB_RXMAXP1_MAXLOAD_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RXCSRL1 register.
-//
-//*****************************************************************************
-#define USB_RXCSRL1_CLRDT 0x00000080 // Clear Data Toggle
-#define USB_RXCSRL1_STALLED 0x00000040 // Endpoint Stalled
-#define USB_RXCSRL1_STALL 0x00000020 // Send STALL
-#define USB_RXCSRL1_REQPKT 0x00000020 // Request Packet
-#define USB_RXCSRL1_FLUSH 0x00000010 // Flush FIFO
-#define USB_RXCSRL1_DATAERR 0x00000008 // Data Error
-#define USB_RXCSRL1_NAKTO 0x00000008 // NAK Timeout
-#define USB_RXCSRL1_OVER 0x00000004 // Overrun
-#define USB_RXCSRL1_ERROR 0x00000004 // Error
-#define USB_RXCSRL1_FULL 0x00000002 // FIFO Full
-#define USB_RXCSRL1_RXRDY 0x00000001 // Receive Packet Ready
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RXCSRH1 register.
-//
-//*****************************************************************************
-#define USB_RXCSRH1_AUTOCL 0x00000080 // Auto Clear
-#define USB_RXCSRH1_AUTORQ 0x00000040 // Auto Request
-#define USB_RXCSRH1_ISO 0x00000040 // Isochronous Transfers
-#define USB_RXCSRH1_DMAEN 0x00000020 // DMA Request Enable
-#define USB_RXCSRH1_DISNYET 0x00000010 // Disable NYET
-#define USB_RXCSRH1_PIDERR 0x00000010 // PID Error
-#define USB_RXCSRH1_DMAMOD 0x00000008 // DMA Request Mode
-#define USB_RXCSRH1_DTWE 0x00000004 // Data Toggle Write Enable
-#define USB_RXCSRH1_DT 0x00000002 // Data Toggle
-#define USB_RXCSRH1_INCOMPRX 0x00000001 // Incomplete RX Transmission
- // Status
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RXCOUNT1 register.
-//
-//*****************************************************************************
-#define USB_RXCOUNT1_COUNT_M 0x00001FFF // Receive Packet Count
-#define USB_RXCOUNT1_COUNT_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_TXTYPE1 register.
-//
-//*****************************************************************************
-#define USB_TXTYPE1_SPEED_M 0x000000C0 // Operating Speed
-#define USB_TXTYPE1_SPEED_DFLT 0x00000000 // Default
-#define USB_TXTYPE1_SPEED_HIGH 0x00000040 // High
-#define USB_TXTYPE1_SPEED_FULL 0x00000080 // Full
-#define USB_TXTYPE1_SPEED_LOW 0x000000C0 // Low
-#define USB_TXTYPE1_PROTO_M 0x00000030 // Protocol
-#define USB_TXTYPE1_PROTO_CTRL 0x00000000 // Control
-#define USB_TXTYPE1_PROTO_ISOC 0x00000010 // Isochronous
-#define USB_TXTYPE1_PROTO_BULK 0x00000020 // Bulk
-#define USB_TXTYPE1_PROTO_INT 0x00000030 // Interrupt
-#define USB_TXTYPE1_TEP_M 0x0000000F // Target Endpoint Number
-#define USB_TXTYPE1_TEP_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_TXINTERVAL1
-// register.
-//
-//*****************************************************************************
-#define USB_TXINTERVAL1_NAKLMT_M \
- 0x000000FF // NAK Limit
-#define USB_TXINTERVAL1_TXPOLL_M \
- 0x000000FF // TX Polling
-#define USB_TXINTERVAL1_TXPOLL_S \
- 0
-#define USB_TXINTERVAL1_NAKLMT_S \
- 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RXTYPE1 register.
-//
-//*****************************************************************************
-#define USB_RXTYPE1_SPEED_M 0x000000C0 // Operating Speed
-#define USB_RXTYPE1_SPEED_DFLT 0x00000000 // Default
-#define USB_RXTYPE1_SPEED_HIGH 0x00000040 // High
-#define USB_RXTYPE1_SPEED_FULL 0x00000080 // Full
-#define USB_RXTYPE1_SPEED_LOW 0x000000C0 // Low
-#define USB_RXTYPE1_PROTO_M 0x00000030 // Protocol
-#define USB_RXTYPE1_PROTO_CTRL 0x00000000 // Control
-#define USB_RXTYPE1_PROTO_ISOC 0x00000010 // Isochronous
-#define USB_RXTYPE1_PROTO_BULK 0x00000020 // Bulk
-#define USB_RXTYPE1_PROTO_INT 0x00000030 // Interrupt
-#define USB_RXTYPE1_TEP_M 0x0000000F // Target Endpoint Number
-#define USB_RXTYPE1_TEP_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RXINTERVAL1
-// register.
-//
-//*****************************************************************************
-#define USB_RXINTERVAL1_TXPOLL_M \
- 0x000000FF // RX Polling
-#define USB_RXINTERVAL1_NAKLMT_M \
- 0x000000FF // NAK Limit
-#define USB_RXINTERVAL1_TXPOLL_S \
- 0
-#define USB_RXINTERVAL1_NAKLMT_S \
- 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_TXMAXP2 register.
-//
-//*****************************************************************************
-#define USB_TXMAXP2_MAXLOAD_M 0x000007FF // Maximum Payload
-#define USB_TXMAXP2_MAXLOAD_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_TXCSRL2 register.
-//
-//*****************************************************************************
-#define USB_TXCSRL2_NAKTO 0x00000080 // NAK Timeout
-#define USB_TXCSRL2_CLRDT 0x00000040 // Clear Data Toggle
-#define USB_TXCSRL2_STALLED 0x00000020 // Endpoint Stalled
-#define USB_TXCSRL2_SETUP 0x00000010 // Setup Packet
-#define USB_TXCSRL2_STALL 0x00000010 // Send STALL
-#define USB_TXCSRL2_FLUSH 0x00000008 // Flush FIFO
-#define USB_TXCSRL2_ERROR 0x00000004 // Error
-#define USB_TXCSRL2_UNDRN 0x00000004 // Underrun
-#define USB_TXCSRL2_FIFONE 0x00000002 // FIFO Not Empty
-#define USB_TXCSRL2_TXRDY 0x00000001 // Transmit Packet Ready
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_TXCSRH2 register.
-//
-//*****************************************************************************
-#define USB_TXCSRH2_AUTOSET 0x00000080 // Auto Set
-#define USB_TXCSRH2_ISO 0x00000040 // Isochronous Transfers
-#define USB_TXCSRH2_MODE 0x00000020 // Mode
-#define USB_TXCSRH2_DMAEN 0x00000010 // DMA Request Enable
-#define USB_TXCSRH2_FDT 0x00000008 // Force Data Toggle
-#define USB_TXCSRH2_DMAMOD 0x00000004 // DMA Request Mode
-#define USB_TXCSRH2_DTWE 0x00000002 // Data Toggle Write Enable
-#define USB_TXCSRH2_DT 0x00000001 // Data Toggle
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RXMAXP2 register.
-//
-//*****************************************************************************
-#define USB_RXMAXP2_MAXLOAD_M 0x000007FF // Maximum Payload
-#define USB_RXMAXP2_MAXLOAD_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RXCSRL2 register.
-//
-//*****************************************************************************
-#define USB_RXCSRL2_CLRDT 0x00000080 // Clear Data Toggle
-#define USB_RXCSRL2_STALLED 0x00000040 // Endpoint Stalled
-#define USB_RXCSRL2_REQPKT 0x00000020 // Request Packet
-#define USB_RXCSRL2_STALL 0x00000020 // Send STALL
-#define USB_RXCSRL2_FLUSH 0x00000010 // Flush FIFO
-#define USB_RXCSRL2_DATAERR 0x00000008 // Data Error
-#define USB_RXCSRL2_NAKTO 0x00000008 // NAK Timeout
-#define USB_RXCSRL2_ERROR 0x00000004 // Error
-#define USB_RXCSRL2_OVER 0x00000004 // Overrun
-#define USB_RXCSRL2_FULL 0x00000002 // FIFO Full
-#define USB_RXCSRL2_RXRDY 0x00000001 // Receive Packet Ready
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RXCSRH2 register.
-//
-//*****************************************************************************
-#define USB_RXCSRH2_AUTOCL 0x00000080 // Auto Clear
-#define USB_RXCSRH2_AUTORQ 0x00000040 // Auto Request
-#define USB_RXCSRH2_ISO 0x00000040 // Isochronous Transfers
-#define USB_RXCSRH2_DMAEN 0x00000020 // DMA Request Enable
-#define USB_RXCSRH2_DISNYET 0x00000010 // Disable NYET
-#define USB_RXCSRH2_PIDERR 0x00000010 // PID Error
-#define USB_RXCSRH2_DMAMOD 0x00000008 // DMA Request Mode
-#define USB_RXCSRH2_DTWE 0x00000004 // Data Toggle Write Enable
-#define USB_RXCSRH2_DT 0x00000002 // Data Toggle
-#define USB_RXCSRH2_INCOMPRX 0x00000001 // Incomplete RX Transmission
- // Status
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RXCOUNT2 register.
-//
-//*****************************************************************************
-#define USB_RXCOUNT2_COUNT_M 0x00001FFF // Receive Packet Count
-#define USB_RXCOUNT2_COUNT_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_TXTYPE2 register.
-//
-//*****************************************************************************
-#define USB_TXTYPE2_SPEED_M 0x000000C0 // Operating Speed
-#define USB_TXTYPE2_SPEED_DFLT 0x00000000 // Default
-#define USB_TXTYPE2_SPEED_HIGH 0x00000040 // High
-#define USB_TXTYPE2_SPEED_FULL 0x00000080 // Full
-#define USB_TXTYPE2_SPEED_LOW 0x000000C0 // Low
-#define USB_TXTYPE2_PROTO_M 0x00000030 // Protocol
-#define USB_TXTYPE2_PROTO_CTRL 0x00000000 // Control
-#define USB_TXTYPE2_PROTO_ISOC 0x00000010 // Isochronous
-#define USB_TXTYPE2_PROTO_BULK 0x00000020 // Bulk
-#define USB_TXTYPE2_PROTO_INT 0x00000030 // Interrupt
-#define USB_TXTYPE2_TEP_M 0x0000000F // Target Endpoint Number
-#define USB_TXTYPE2_TEP_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_TXINTERVAL2
-// register.
-//
-//*****************************************************************************
-#define USB_TXINTERVAL2_TXPOLL_M \
- 0x000000FF // TX Polling
-#define USB_TXINTERVAL2_NAKLMT_M \
- 0x000000FF // NAK Limit
-#define USB_TXINTERVAL2_NAKLMT_S \
- 0
-#define USB_TXINTERVAL2_TXPOLL_S \
- 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RXTYPE2 register.
-//
-//*****************************************************************************
-#define USB_RXTYPE2_SPEED_M 0x000000C0 // Operating Speed
-#define USB_RXTYPE2_SPEED_DFLT 0x00000000 // Default
-#define USB_RXTYPE2_SPEED_HIGH 0x00000040 // High
-#define USB_RXTYPE2_SPEED_FULL 0x00000080 // Full
-#define USB_RXTYPE2_SPEED_LOW 0x000000C0 // Low
-#define USB_RXTYPE2_PROTO_M 0x00000030 // Protocol
-#define USB_RXTYPE2_PROTO_CTRL 0x00000000 // Control
-#define USB_RXTYPE2_PROTO_ISOC 0x00000010 // Isochronous
-#define USB_RXTYPE2_PROTO_BULK 0x00000020 // Bulk
-#define USB_RXTYPE2_PROTO_INT 0x00000030 // Interrupt
-#define USB_RXTYPE2_TEP_M 0x0000000F // Target Endpoint Number
-#define USB_RXTYPE2_TEP_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RXINTERVAL2
-// register.
-//
-//*****************************************************************************
-#define USB_RXINTERVAL2_TXPOLL_M \
- 0x000000FF // RX Polling
-#define USB_RXINTERVAL2_NAKLMT_M \
- 0x000000FF // NAK Limit
-#define USB_RXINTERVAL2_TXPOLL_S \
- 0
-#define USB_RXINTERVAL2_NAKLMT_S \
- 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_TXMAXP3 register.
-//
-//*****************************************************************************
-#define USB_TXMAXP3_MAXLOAD_M 0x000007FF // Maximum Payload
-#define USB_TXMAXP3_MAXLOAD_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_TXCSRL3 register.
-//
-//*****************************************************************************
-#define USB_TXCSRL3_NAKTO 0x00000080 // NAK Timeout
-#define USB_TXCSRL3_CLRDT 0x00000040 // Clear Data Toggle
-#define USB_TXCSRL3_STALLED 0x00000020 // Endpoint Stalled
-#define USB_TXCSRL3_SETUP 0x00000010 // Setup Packet
-#define USB_TXCSRL3_STALL 0x00000010 // Send STALL
-#define USB_TXCSRL3_FLUSH 0x00000008 // Flush FIFO
-#define USB_TXCSRL3_ERROR 0x00000004 // Error
-#define USB_TXCSRL3_UNDRN 0x00000004 // Underrun
-#define USB_TXCSRL3_FIFONE 0x00000002 // FIFO Not Empty
-#define USB_TXCSRL3_TXRDY 0x00000001 // Transmit Packet Ready
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_TXCSRH3 register.
-//
-//*****************************************************************************
-#define USB_TXCSRH3_AUTOSET 0x00000080 // Auto Set
-#define USB_TXCSRH3_ISO 0x00000040 // Isochronous Transfers
-#define USB_TXCSRH3_MODE 0x00000020 // Mode
-#define USB_TXCSRH3_DMAEN 0x00000010 // DMA Request Enable
-#define USB_TXCSRH3_FDT 0x00000008 // Force Data Toggle
-#define USB_TXCSRH3_DMAMOD 0x00000004 // DMA Request Mode
-#define USB_TXCSRH3_DTWE 0x00000002 // Data Toggle Write Enable
-#define USB_TXCSRH3_DT 0x00000001 // Data Toggle
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RXMAXP3 register.
-//
-//*****************************************************************************
-#define USB_RXMAXP3_MAXLOAD_M 0x000007FF // Maximum Payload
-#define USB_RXMAXP3_MAXLOAD_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RXCSRL3 register.
-//
-//*****************************************************************************
-#define USB_RXCSRL3_CLRDT 0x00000080 // Clear Data Toggle
-#define USB_RXCSRL3_STALLED 0x00000040 // Endpoint Stalled
-#define USB_RXCSRL3_STALL 0x00000020 // Send STALL
-#define USB_RXCSRL3_REQPKT 0x00000020 // Request Packet
-#define USB_RXCSRL3_FLUSH 0x00000010 // Flush FIFO
-#define USB_RXCSRL3_DATAERR 0x00000008 // Data Error
-#define USB_RXCSRL3_NAKTO 0x00000008 // NAK Timeout
-#define USB_RXCSRL3_ERROR 0x00000004 // Error
-#define USB_RXCSRL3_OVER 0x00000004 // Overrun
-#define USB_RXCSRL3_FULL 0x00000002 // FIFO Full
-#define USB_RXCSRL3_RXRDY 0x00000001 // Receive Packet Ready
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RXCSRH3 register.
-//
-//*****************************************************************************
-#define USB_RXCSRH3_AUTOCL 0x00000080 // Auto Clear
-#define USB_RXCSRH3_AUTORQ 0x00000040 // Auto Request
-#define USB_RXCSRH3_ISO 0x00000040 // Isochronous Transfers
-#define USB_RXCSRH3_DMAEN 0x00000020 // DMA Request Enable
-#define USB_RXCSRH3_DISNYET 0x00000010 // Disable NYET
-#define USB_RXCSRH3_PIDERR 0x00000010 // PID Error
-#define USB_RXCSRH3_DMAMOD 0x00000008 // DMA Request Mode
-#define USB_RXCSRH3_DTWE 0x00000004 // Data Toggle Write Enable
-#define USB_RXCSRH3_DT 0x00000002 // Data Toggle
-#define USB_RXCSRH3_INCOMPRX 0x00000001 // Incomplete RX Transmission
- // Status
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RXCOUNT3 register.
-//
-//*****************************************************************************
-#define USB_RXCOUNT3_COUNT_M 0x00001FFF // Receive Packet Count
-#define USB_RXCOUNT3_COUNT_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_TXTYPE3 register.
-//
-//*****************************************************************************
-#define USB_TXTYPE3_SPEED_M 0x000000C0 // Operating Speed
-#define USB_TXTYPE3_SPEED_DFLT 0x00000000 // Default
-#define USB_TXTYPE3_SPEED_HIGH 0x00000040 // High
-#define USB_TXTYPE3_SPEED_FULL 0x00000080 // Full
-#define USB_TXTYPE3_SPEED_LOW 0x000000C0 // Low
-#define USB_TXTYPE3_PROTO_M 0x00000030 // Protocol
-#define USB_TXTYPE3_PROTO_CTRL 0x00000000 // Control
-#define USB_TXTYPE3_PROTO_ISOC 0x00000010 // Isochronous
-#define USB_TXTYPE3_PROTO_BULK 0x00000020 // Bulk
-#define USB_TXTYPE3_PROTO_INT 0x00000030 // Interrupt
-#define USB_TXTYPE3_TEP_M 0x0000000F // Target Endpoint Number
-#define USB_TXTYPE3_TEP_S 0
+#ifndef __IO
+ #define __IO volatile
+#endif
+
+#ifndef __I
+ #define __I volatile const
+#endif
+
+#ifndef __O
+ #define __O volatile
+#endif
+
+#ifndef __R
+ #define __R volatile const
+#endif
+
+typedef struct TU_ATTR_PACKED {
+ __IO uint16_t maxp; // 0x00, 0x04: MAXP
+ __IO uint8_t csrl; // 0x02, 0x06: CSRL
+ __IO uint8_t csrh; // 0x03, 0x07: CSRH
+}musb_ep_maxp_csr_t;
+
+// 0: TX (device IN, host OUT)
+// 1: RX (device OUT, host IN)
+typedef struct TU_ATTR_PACKED {
+ union {
+ struct {
+ __IO uint16_t tx_maxp; // 0x00: TXMAXP
+ union {
+ __IO uint8_t csr0l; // 0x02: CSR0
+ __IO uint8_t tx_csrl; // 0x02: TX CSRL
+ };
+ union {
+ __IO uint8_t csr0h; // 0x03: CSR0H
+ __IO uint8_t tx_csrh; // 0x03: TX CSRH
+ };
+
+ __IO uint16_t rx_maxp; // 0x04: RX MAXP
+ __IO uint8_t rx_csrl; // 0x06: RX CSRL
+ __IO uint8_t rx_csrh; // 0x07: RX CSRH
+ };
+
+ musb_ep_maxp_csr_t maxp_csr[2];
+ };
+
+ union {
+ __IO uint16_t count0; // 0x08: COUNT0
+ __IO uint16_t rx_count; // 0x08: RX COUNT
+ };
+ union {
+ __IO uint8_t type0; // 0x0A: TYPE0 (host only)
+ __IO uint8_t tx_type; // 0x0A: TX TYPE
+ };
+ __IO uint8_t tx_interval; // 0x0B: TX INTERVAL
+ __IO uint8_t rx_type; // 0x0C: RX TYPE
+ __IO uint8_t rx_interval; // 0x0D: RX INTERVAL
+ __IO uint8_t reserved_0x0e; // 0x0E: Reserved
+ union {
+ __IO uint8_t config_data0; // 0x0F: CONFIG DATA
+ struct {
+ __IO uint8_t utmi_data_width : 1; // [0] UTMI Data Width
+ __IO uint8_t softconn_en : 1; // [1] Soft Connect Enable
+ __IO uint8_t dynamic_fifo : 1; // [2] Dynamic FIFO Sizing
+ __IO uint8_t hb_tx_en : 1; // [3] High Bandwidth TX ISO Enable
+ __IO uint8_t hb_rx_en : 1; // [4] High Bandwidth RX ISO Enable
+ __IO uint8_t big_endian : 1; // [5] Big Endian
+ __IO uint8_t mp_tx_en : 1; // [6] Auto splitting BULK TX Enable
+ __IO uint8_t mp_rx_en : 1; // [7] Auto amalgamation BULK RX Enable
+ } config_data0_bit;
+
+ __IO uint8_t fifo_size; // 0x0F: FIFO_SIZE
+ struct {
+ __IO uint8_t tx : 4; // [3:0] TX FIFO Size
+ __IO uint8_t rx : 4; // [7:4] RX FIFO Size
+ }fifo_size_bit;
+ };
+} musb_ep_csr_t;
+
+TU_VERIFY_STATIC(sizeof(musb_ep_csr_t) == 16, "size is not correct");
+
+typedef struct TU_ATTR_PACKED {
+ //------------- Common -------------//
+ __IO uint8_t faddr; // 0x00: FADDR
+ union {
+ __IO uint8_t power; // 0x01: POWER
+ struct {
+ __IO uint8_t suspend_mode_en : 1; // [0] SUSPEND Mode Enable
+ __IO uint8_t suspend_mode : 1; // [1] SUSPEND Mode
+ __IO uint8_t resume_mode : 1; // [2] RESUME
+ __IO uint8_t reset : 1; // [3] RESET
+ __IO uint8_t highspeed_mode : 1; // [4] High Speed Mode
+ __IO uint8_t highspeed_en : 1; // [5] High Speed Enable
+ __IO uint8_t soft_conn : 1; // [6] Soft Connect/Disconnect
+ __IO uint8_t iso_update : 1; // [7] Isochronous Update
+ } power_bit;
+ };
+
+ union {
+ struct {
+ __IO uint16_t intr_tx; // 0x02: INTR_TX
+ __IO uint16_t intr_rx; // 0x04: INTR_RX
+ };
+
+ __IO uint16_t intr_ep[2]; // 0x02-0x05: INTR_EP0-1
+ };
+
+ union {
+ struct {
+ __IO uint16_t intr_txen; // 0x06: INTR_TXEN
+ __IO uint16_t intr_rxen; // 0x08: INTR_RXEN
+ };
+
+ __IO uint16_t intren_ep[2]; // 0x06-0x09: INTREN_EP0-1
+ };
+
+ __IO uint8_t intr_usb; // 0x0A: INTRUSB
+ __IO uint8_t intr_usben; // 0x0B: INTRUSBEN
+
+ __IO uint16_t frame; // 0x0C: FRAME
+ __IO uint8_t index; // 0x0E: INDEX
+ __IO uint8_t testmode; // 0x0F: TESTMODE
+
+ //------------- Endpoint CSR (indexed) -------------//
+ musb_ep_csr_t indexed_csr; // 0x10-0x1F: Indexed CSR 0-15
+
+ //------------- FIFOs -------------//
+ __IO uint32_t fifo[16]; // 0x20-0x5C: FIFO 0-15
+
+ // Common (2)
+ __IO uint8_t devctl; // 0x60: DEVCTL
+ __IO uint8_t misc; // 0x61: MISC
+
+ //------------- Dynammic FIFO (indexed) -------------//
+ union {
+ struct {
+ __IO uint8_t txfifo_sz; // 0x62: TXFIFO_SZ
+ __IO uint8_t rxfifo_sz; // 0x63: RXFIFO_SZ
+ };
+ __IO uint8_t fifo_size[2];
+ };
+
+ union {
+ struct {
+ __IO uint16_t txfifo_addr; // 0x64: TXFIFO_ADDR
+ __IO uint16_t rxfifo_addr; // 0x66: RXFIFO_ADDR
+ };
+ __IO uint16_t fifo_addr[2];
+ };
+
+ //------------- Additional Control and Configuration -------------//
+ union {
+ __O uint32_t vcontrol; // 0x68: PHY VCONTROL
+ __IO uint32_t vstatus; // 0x68: PHY VSTATUS
+ };
+ union {
+ __IO uint16_t hwvers; // 0x6C: HWVERS
+ struct {
+ __IO uint16_t minor : 10; // [9:0] Minor
+ __IO uint16_t major : 5; // [14:10] Major
+ __IO uint16_t rc : 1; // [15] Release Candidate
+ } hwvers_bit;
+ };
+ __R uint16_t rsv_0x6e_0x77[5]; // 0x6E-0x77: Reserved
+
+ //------------- Additional Configuration -------------//
+ union {
+ __IO uint8_t epinfo; // 0x78: EPINFO
+ struct {
+ __IO uint8_t tx_ep_num : 4; // [3:0] TX Endpoints
+ __IO uint8_t rx_ep_num : 4; // [7:4] RX Endpoints
+ } epinfo_bit;
+ };
+ union {
+ __IO uint8_t raminfo; // 0x79: RAMINFO
+ struct {
+ __IO uint8_t ram_bits : 4; // [3:0] RAM Address Bus Width
+ __IO uint8_t dma_channel : 4; // [7:4] DMA Channels
+ }raminfo_bit;
+ };
+ union {
+ __IO uint8_t link_info; // 0x7A: LINK_INFO
+ __IO uint8_t adi_softreset; // 0x7A: AnalogDevice SOFTRESET
+ };
+ __IO uint8_t vplen; // 0x7B: VPLEN
+ __IO uint8_t hs_eof1; // 0x7C: HS_EOF1
+ __IO uint8_t fs_eof1; // 0x7D: FS_EOF1
+ __IO uint8_t ls_eof1; // 0x7E: LS_EOF1
+ __IO uint8_t soft_rst; // 0x7F: SOFT_RST
+
+ //------------- Target Endpoints (multipoint option) -------------//
+ __IO uint16_t ctuch; // 0x80: CTUCH
+ __IO uint16_t cthsrtn; // 0x82: CTHSRTN
+ __R uint32_t rsv_0x84_0xff[31]; // 0x84-0xFF: Reserved
+
+ //------------- Non-Indexed Endpoint CSRs -------------//
+ // TI tm4c can access this directly, but should use indexed_csr for portability
+ musb_ep_csr_t abs_csr[16]; // 0x100-0x1FF: EP0-15 CSR
+
+ //------------- DMA -------------//
+ __IO uint8_t dma_intr; // 0x200: DMA_INTR
+ __R uint8_t rsv_0x201_0x203[3]; // 0x201-0x203: Reserved
+ struct {
+ __IO uint16_t cntl; // 0x204: DMA_CNTL
+ __IO uint16_t rsv_0x206; // 0x206: Reserved
+ __IO uint32_t addr; // 0x208: DMA_ADDR
+ __IO uint32_t count; // 0x20C: DMA_COUNT
+ __IO uint32_t rsv_0x210; // 0x210: Reserved
+ }dma[8];
+ __R uint32_t rsv_0x284_0x2FF[31]; // 0x284-0x2FF: Reserved
+
+ //------------- Extended -------------//
+ __R uint32_t rsv_0x300; // 0x300: Reserved
+ struct {
+ __IO uint16_t count; // 0x304: REQ_PACKET_COUNT
+ __R uint16_t rsv_0x306; // 0x306: Reserved
+ }req_packet[15];
+
+ __IO uint16_t rx_doulbe_packet_disable; // 0x340: RX_DOUBLE_PACKET_DISABLE
+ __IO uint16_t tx_double_packet_disable; // 0x342: TX_DOUBLE_PACKET_DISABLE
+
+ __IO uint16_t chirp_timeout; // 0x344: CHIRP_TIMEOUT
+ __IO uint16_t hs_to_utm; // 0x346: HS_TO_UTM delay
+ __IO uint16_t hs_timeout_adder; // 0x348: HS_TIMEOUT_ADDER
+
+ __R uint8_t rsv_34A_34f[6]; // 0x34A-0x34F: Reserved
+} musb_regs_t;
+
+TU_VERIFY_STATIC(sizeof(musb_regs_t) == 0x350, "size is not correct");
+
+//--------------------------------------------------------------------+
+// Helper
+//--------------------------------------------------------------------+
+TU_ATTR_ALWAYS_INLINE static inline musb_ep_csr_t* get_ep_csr(musb_regs_t* musb_regs, unsigned epnum) {
+ musb_regs->index = epnum;
+ return &musb_regs->indexed_csr;
+}
+
+//--------------------------------------------------------------------+
+// Register Bit Field
+//--------------------------------------------------------------------+
+
+// 0x01: Power
+#define MUSB_POWER_ISOUP 0x0080 // Isochronous Update
+#define MUSB_POWER_SOFTCONN 0x0040 // Soft Connect/Disconnect
+#define MUSB_POWER_HSENAB 0x0020 // High Speed Enable
+#define MUSB_POWER_HSMODE 0x0010 // High Speed Enable
+#define MUSB_POWER_RESET 0x0008 // RESET Signaling
+#define MUSB_POWER_RESUME 0x0004 // RESUME Signaling
+#define MUSB_POWER_SUSPEND 0x0002 // SUSPEND Mode
+#define MUSB_POWER_PWRDNPHY 0x0001 // Power Down PHY
+
+// Interrupt TX/RX Status and Enable: each bit is for an endpoint
+
+// 0x6c: HWVERS
+#define MUSB_HWVERS_RC_SHIFT 15
+#define MUSB_HWVERS_RC_MASK 0x8000
+#define MUSB_HWVERS_MAJOR_SHIFT 10
+#define MUSB_HWVERS_MAJOR_MASK 0x7C00
+#define MUSB_HWVERS_MINOR_SHIFT 0
+#define MUSB_HWVERS_MINOR_MASK 0x03FF
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_TXINTERVAL3
-// register.
-//
-//*****************************************************************************
-#define USB_TXINTERVAL3_TXPOLL_M \
- 0x000000FF // TX Polling
-#define USB_TXINTERVAL3_NAKLMT_M \
- 0x000000FF // NAK Limit
-#define USB_TXINTERVAL3_TXPOLL_S \
- 0
-#define USB_TXINTERVAL3_NAKLMT_S \
- 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RXTYPE3 register.
-//
-//*****************************************************************************
-#define USB_RXTYPE3_SPEED_M 0x000000C0 // Operating Speed
-#define USB_RXTYPE3_SPEED_DFLT 0x00000000 // Default
-#define USB_RXTYPE3_SPEED_HIGH 0x00000040 // High
-#define USB_RXTYPE3_SPEED_FULL 0x00000080 // Full
-#define USB_RXTYPE3_SPEED_LOW 0x000000C0 // Low
-#define USB_RXTYPE3_PROTO_M 0x00000030 // Protocol
-#define USB_RXTYPE3_PROTO_CTRL 0x00000000 // Control
-#define USB_RXTYPE3_PROTO_ISOC 0x00000010 // Isochronous
-#define USB_RXTYPE3_PROTO_BULK 0x00000020 // Bulk
-#define USB_RXTYPE3_PROTO_INT 0x00000030 // Interrupt
-#define USB_RXTYPE3_TEP_M 0x0000000F // Target Endpoint Number
-#define USB_RXTYPE3_TEP_S 0
+// 0x12, 0x16: TX/RX CSRL
+#define MUSB_CSRL_PACKET_READY(_rx) (1u << 0)
+#define MUSB_CSRL_FLUSH_FIFO(_rx) (1u << ((_rx) ? 4 : 3))
+#define MUSB_CSRL_SEND_STALL(_rx) (1u << ((_rx) ? 5 : 4))
+#define MUSB_CSRL_STALLED(_rx) (1u << ((_rx) ? 6 : 5))
+#define MUSB_CSRL_CLEAR_DATA_TOGGLE(_rx) (1u << ((_rx) ? 7 : 6))
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RXINTERVAL3
-// register.
-//
-//*****************************************************************************
-#define USB_RXINTERVAL3_TXPOLL_M \
- 0x000000FF // RX Polling
-#define USB_RXINTERVAL3_NAKLMT_M \
- 0x000000FF // NAK Limit
-#define USB_RXINTERVAL3_TXPOLL_S \
- 0
-#define USB_RXINTERVAL3_NAKLMT_S \
- 0
+// 0x13, 0x17: TX/RX CSRH
+#define MUSB_CSRH_DISABLE_DOUBLE_PACKET(_rx) (1u << 1)
+#define MUSB_CSRH_TX_MODE (1u << 5) // 1 = TX, 0 = RX. only relevant for SHARED FIFO
+#define MUSB_CSRH_ISO (1u << 6)
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_TXMAXP4 register.
-//
-//*****************************************************************************
-#define USB_TXMAXP4_MAXLOAD_M 0x000007FF // Maximum Payload
-#define USB_TXMAXP4_MAXLOAD_S 0
+// 0x62, 0x63: TXFIFO_SZ, RXFIFO_SZ
+#define MUSB_FIFOSZ_DOUBLE_PACKET (1u << 4)
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_TXCSRL4 register.
-//
-//*****************************************************************************
-#define USB_TXCSRL4_NAKTO 0x00000080 // NAK Timeout
-#define USB_TXCSRL4_CLRDT 0x00000040 // Clear Data Toggle
-#define USB_TXCSRL4_STALLED 0x00000020 // Endpoint Stalled
-#define USB_TXCSRL4_SETUP 0x00000010 // Setup Packet
-#define USB_TXCSRL4_STALL 0x00000010 // Send STALL
-#define USB_TXCSRL4_FLUSH 0x00000008 // Flush FIFO
-#define USB_TXCSRL4_ERROR 0x00000004 // Error
-#define USB_TXCSRL4_UNDRN 0x00000004 // Underrun
-#define USB_TXCSRL4_FIFONE 0x00000002 // FIFO Not Empty
-#define USB_TXCSRL4_TXRDY 0x00000001 // Transmit Packet Ready
//*****************************************************************************
//
-// The following are defines for the bit fields in the USB_O_TXCSRH4 register.
+// The following are defines for the bit fields in the MUSB_O_IS register.
//
//*****************************************************************************
-#define USB_TXCSRH4_AUTOSET 0x00000080 // Auto Set
-#define USB_TXCSRH4_ISO 0x00000040 // Isochronous Transfers
-#define USB_TXCSRH4_MODE 0x00000020 // Mode
-#define USB_TXCSRH4_DMAEN 0x00000010 // DMA Request Enable
-#define USB_TXCSRH4_FDT 0x00000008 // Force Data Toggle
-#define USB_TXCSRH4_DMAMOD 0x00000004 // DMA Request Mode
-#define USB_TXCSRH4_DTWE 0x00000002 // Data Toggle Write Enable
-#define USB_TXCSRH4_DT 0x00000001 // Data Toggle
+#define MUSB_IS_VBUSERR 0x0080 // VBUS Error (OTG only)
+#define MUSB_IS_SESREQ 0x0040 // SESSION REQUEST (OTG only)
+#define MUSB_IS_DISCON 0x0020 // Session Disconnect (OTG only)
+#define MUSB_IS_CONN 0x0010 // Session Connect
+#define MUSB_IS_SOF 0x0008 // Start of Frame
+#define MUSB_IS_BABBLE 0x0004 // Babble Detected
+#define MUSB_IS_RESET 0x0004 // RESET Signaling Detected
+#define MUSB_IS_RESUME 0x0002 // RESUME Signaling Detected
+#define MUSB_IS_SUSPEND 0x0001 // SUSPEND Signaling Detected
//*****************************************************************************
//
-// The following are defines for the bit fields in the USB_O_RXMAXP4 register.
+// The following are defines for the bit fields in the MUSB_O_IE register.
//
//*****************************************************************************
-#define USB_RXMAXP4_MAXLOAD_M 0x000007FF // Maximum Payload
-#define USB_RXMAXP4_MAXLOAD_S 0
+#define MUSB_IE_VBUSERR 0x0080 // Enable VBUS Error Interrupt (OTG only)
+#define MUSB_IE_SESREQ 0x0040 // Enable Session Request (OTG only)
+#define MUSB_IE_DISCON 0x0020 // Enable Disconnect Interrupt
+#define MUSB_IE_CONN 0x0010 // Enable Connect Interrupt
+#define MUSB_IE_SOF 0x0008 // Enable Start-of-Frame Interrupt
+#define MUSB_IE_BABBLE 0x0004 // Enable Babble Interrupt
+#define MUSB_IE_RESET 0x0004 // Enable RESET Interrupt
+#define MUSB_IE_RESUME 0x0002 // Enable RESUME Interrupt
+#define MUSB_IE_SUSPND 0x0001 // Enable SUSPEND Interrupt
//*****************************************************************************
//
-// The following are defines for the bit fields in the USB_O_RXCSRL4 register.
+// The following are defines for the bit fields in the MUSB_O_FRAME register.
//
//*****************************************************************************
-#define USB_RXCSRL4_CLRDT 0x00000080 // Clear Data Toggle
-#define USB_RXCSRL4_STALLED 0x00000040 // Endpoint Stalled
-#define USB_RXCSRL4_STALL 0x00000020 // Send STALL
-#define USB_RXCSRL4_REQPKT 0x00000020 // Request Packet
-#define USB_RXCSRL4_FLUSH 0x00000010 // Flush FIFO
-#define USB_RXCSRL4_NAKTO 0x00000008 // NAK Timeout
-#define USB_RXCSRL4_DATAERR 0x00000008 // Data Error
-#define USB_RXCSRL4_OVER 0x00000004 // Overrun
-#define USB_RXCSRL4_ERROR 0x00000004 // Error
-#define USB_RXCSRL4_FULL 0x00000002 // FIFO Full
-#define USB_RXCSRL4_RXRDY 0x00000001 // Receive Packet Ready
+#define MUSB_FRAME_M 0x07FF // Frame Number
+#define MUSB_FRAME_S 0
//*****************************************************************************
//
-// The following are defines for the bit fields in the USB_O_RXCSRH4 register.
+// The following are defines for the bit fields in the MUSB_O_TEST register.
//
//*****************************************************************************
-#define USB_RXCSRH4_AUTOCL 0x00000080 // Auto Clear
-#define USB_RXCSRH4_AUTORQ 0x00000040 // Auto Request
-#define USB_RXCSRH4_ISO 0x00000040 // Isochronous Transfers
-#define USB_RXCSRH4_DMAEN 0x00000020 // DMA Request Enable
-#define USB_RXCSRH4_DISNYET 0x00000010 // Disable NYET
-#define USB_RXCSRH4_PIDERR 0x00000010 // PID Error
-#define USB_RXCSRH4_DMAMOD 0x00000008 // DMA Request Mode
-#define USB_RXCSRH4_DTWE 0x00000004 // Data Toggle Write Enable
-#define USB_RXCSRH4_DT 0x00000002 // Data Toggle
-#define USB_RXCSRH4_INCOMPRX 0x00000001 // Incomplete RX Transmission
- // Status
+#define MUSB_TEST_FORCEH 0x0080 // Force Host Mode
+#define MUSB_TEST_FIFOACC 0x0040 // FIFO Access
+#define MUSB_TEST_FORCEFS 0x0020 // Force Full-Speed Mode
+#define MUSB_TEST_FORCEHS 0x0010 // Force High-Speed Mode
+#define MUSB_TEST_TESTPKT 0x0008 // Test Packet Mode Enable
+#define MUSB_TEST_TESTK 0x0004 // Test_K Mode Enable
+#define MUSB_TEST_TESTJ 0x0002 // Test_J Mode Enable
+#define MUSB_TEST_TESTSE0NAK 0x0001 // Test_SE0_NAK Test Mode Enable
//*****************************************************************************
//
-// The following are defines for the bit fields in the USB_O_RXCOUNT4 register.
+// The following are defines for the bit fields in the MUSB_O_DEVCTL register.
//
//*****************************************************************************
-#define USB_RXCOUNT4_COUNT_M 0x00001FFF // Receive Packet Count
-#define USB_RXCOUNT4_COUNT_S 0
+#define MUSB_DEVCTL_DEV 0x0080 // Device Mode (OTG only)
+#define MUSB_DEVCTL_FSDEV 0x0040 // Full-Speed Device Detected
+#define MUSB_DEVCTL_LSDEV 0x0020 // Low-Speed Device Detected
+#define MUSB_DEVCTL_VBUS_M 0x0018 // VBUS Level (OTG only)
+#define MUSB_DEVCTL_VBUS_NONE 0x0000 // Below SessionEnd
+#define MUSB_DEVCTL_VBUS_SEND 0x0008 // Above SessionEnd, below AValid
+#define MUSB_DEVCTL_VBUS_AVALID 0x0010 // Above AValid, below VBUSValid
+#define MUSB_DEVCTL_VBUS_VALID 0x0018 // Above VBUSValid
+#define MUSB_DEVCTL_HOST 0x0004 // Host Mode
+#define MUSB_DEVCTL_HOSTREQ 0x0002 // Host Request (OTG only)
+#define MUSB_DEVCTL_SESSION 0x0001 // Session Start/End (OTG only)
//*****************************************************************************
//
-// The following are defines for the bit fields in the USB_O_TXTYPE4 register.
+// The following are defines for the bit fields in the MUSB_O_CCONF register.
//
//*****************************************************************************
-#define USB_TXTYPE4_SPEED_M 0x000000C0 // Operating Speed
-#define USB_TXTYPE4_SPEED_DFLT 0x00000000 // Default
-#define USB_TXTYPE4_SPEED_HIGH 0x00000040 // High
-#define USB_TXTYPE4_SPEED_FULL 0x00000080 // Full
-#define USB_TXTYPE4_SPEED_LOW 0x000000C0 // Low
-#define USB_TXTYPE4_PROTO_M 0x00000030 // Protocol
-#define USB_TXTYPE4_PROTO_CTRL 0x00000000 // Control
-#define USB_TXTYPE4_PROTO_ISOC 0x00000010 // Isochronous
-#define USB_TXTYPE4_PROTO_BULK 0x00000020 // Bulk
-#define USB_TXTYPE4_PROTO_INT 0x00000030 // Interrupt
-#define USB_TXTYPE4_TEP_M 0x0000000F // Target Endpoint Number
-#define USB_TXTYPE4_TEP_S 0
+#define MUSB_CCONF_TXEDMA 0x0002 // TX Early DMA Enable
+#define MUSB_CCONF_RXEDMA 0x0001 // TX Early DMA Enable
//*****************************************************************************
//
-// The following are defines for the bit fields in the USB_O_TXINTERVAL4
+// The following are defines for the bit fields in the MUSB_O_ULPIVBUSCTL
// register.
//
//*****************************************************************************
-#define USB_TXINTERVAL4_TXPOLL_M \
- 0x000000FF // TX Polling
-#define USB_TXINTERVAL4_NAKLMT_M \
- 0x000000FF // NAK Limit
-#define USB_TXINTERVAL4_NAKLMT_S \
- 0
-#define USB_TXINTERVAL4_TXPOLL_S \
- 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RXTYPE4 register.
-//
-//*****************************************************************************
-#define USB_RXTYPE4_SPEED_M 0x000000C0 // Operating Speed
-#define USB_RXTYPE4_SPEED_DFLT 0x00000000 // Default
-#define USB_RXTYPE4_SPEED_HIGH 0x00000040 // High
-#define USB_RXTYPE4_SPEED_FULL 0x00000080 // Full
-#define USB_RXTYPE4_SPEED_LOW 0x000000C0 // Low
-#define USB_RXTYPE4_PROTO_M 0x00000030 // Protocol
-#define USB_RXTYPE4_PROTO_CTRL 0x00000000 // Control
-#define USB_RXTYPE4_PROTO_ISOC 0x00000010 // Isochronous
-#define USB_RXTYPE4_PROTO_BULK 0x00000020 // Bulk
-#define USB_RXTYPE4_PROTO_INT 0x00000030 // Interrupt
-#define USB_RXTYPE4_TEP_M 0x0000000F // Target Endpoint Number
-#define USB_RXTYPE4_TEP_S 0
+#define MUSB_ULPIVBUSCTL_USEEXTVBUSIND 0x0002 // Use External VBUS Indicator
+#define MUSB_ULPIVBUSCTL_USEEXTVBUS 0x0001 // Use External VBUS
//*****************************************************************************
//
-// The following are defines for the bit fields in the USB_O_RXINTERVAL4
+// The following are defines for the bit fields in the MUSB_O_ULPIREGDATA
// register.
//
//*****************************************************************************
-#define USB_RXINTERVAL4_TXPOLL_M \
- 0x000000FF // RX Polling
-#define USB_RXINTERVAL4_NAKLMT_M \
- 0x000000FF // NAK Limit
-#define USB_RXINTERVAL4_NAKLMT_S \
- 0
-#define USB_RXINTERVAL4_TXPOLL_S \
- 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_TXMAXP5 register.
-//
-//*****************************************************************************
-#define USB_TXMAXP5_MAXLOAD_M 0x000007FF // Maximum Payload
-#define USB_TXMAXP5_MAXLOAD_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_TXCSRL5 register.
-//
-//*****************************************************************************
-#define USB_TXCSRL5_NAKTO 0x00000080 // NAK Timeout
-#define USB_TXCSRL5_CLRDT 0x00000040 // Clear Data Toggle
-#define USB_TXCSRL5_STALLED 0x00000020 // Endpoint Stalled
-#define USB_TXCSRL5_SETUP 0x00000010 // Setup Packet
-#define USB_TXCSRL5_STALL 0x00000010 // Send STALL
-#define USB_TXCSRL5_FLUSH 0x00000008 // Flush FIFO
-#define USB_TXCSRL5_ERROR 0x00000004 // Error
-#define USB_TXCSRL5_UNDRN 0x00000004 // Underrun
-#define USB_TXCSRL5_FIFONE 0x00000002 // FIFO Not Empty
-#define USB_TXCSRL5_TXRDY 0x00000001 // Transmit Packet Ready
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_TXCSRH5 register.
-//
-//*****************************************************************************
-#define USB_TXCSRH5_AUTOSET 0x00000080 // Auto Set
-#define USB_TXCSRH5_ISO 0x00000040 // Isochronous Transfers
-#define USB_TXCSRH5_MODE 0x00000020 // Mode
-#define USB_TXCSRH5_DMAEN 0x00000010 // DMA Request Enable
-#define USB_TXCSRH5_FDT 0x00000008 // Force Data Toggle
-#define USB_TXCSRH5_DMAMOD 0x00000004 // DMA Request Mode
-#define USB_TXCSRH5_DTWE 0x00000002 // Data Toggle Write Enable
-#define USB_TXCSRH5_DT 0x00000001 // Data Toggle
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RXMAXP5 register.
-//
-//*****************************************************************************
-#define USB_RXMAXP5_MAXLOAD_M 0x000007FF // Maximum Payload
-#define USB_RXMAXP5_MAXLOAD_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RXCSRL5 register.
-//
-//*****************************************************************************
-#define USB_RXCSRL5_CLRDT 0x00000080 // Clear Data Toggle
-#define USB_RXCSRL5_STALLED 0x00000040 // Endpoint Stalled
-#define USB_RXCSRL5_STALL 0x00000020 // Send STALL
-#define USB_RXCSRL5_REQPKT 0x00000020 // Request Packet
-#define USB_RXCSRL5_FLUSH 0x00000010 // Flush FIFO
-#define USB_RXCSRL5_NAKTO 0x00000008 // NAK Timeout
-#define USB_RXCSRL5_DATAERR 0x00000008 // Data Error
-#define USB_RXCSRL5_ERROR 0x00000004 // Error
-#define USB_RXCSRL5_OVER 0x00000004 // Overrun
-#define USB_RXCSRL5_FULL 0x00000002 // FIFO Full
-#define USB_RXCSRL5_RXRDY 0x00000001 // Receive Packet Ready
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RXCSRH5 register.
-//
-//*****************************************************************************
-#define USB_RXCSRH5_AUTOCL 0x00000080 // Auto Clear
-#define USB_RXCSRH5_AUTORQ 0x00000040 // Auto Request
-#define USB_RXCSRH5_ISO 0x00000040 // Isochronous Transfers
-#define USB_RXCSRH5_DMAEN 0x00000020 // DMA Request Enable
-#define USB_RXCSRH5_DISNYET 0x00000010 // Disable NYET
-#define USB_RXCSRH5_PIDERR 0x00000010 // PID Error
-#define USB_RXCSRH5_DMAMOD 0x00000008 // DMA Request Mode
-#define USB_RXCSRH5_DTWE 0x00000004 // Data Toggle Write Enable
-#define USB_RXCSRH5_DT 0x00000002 // Data Toggle
-#define USB_RXCSRH5_INCOMPRX 0x00000001 // Incomplete RX Transmission
- // Status
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RXCOUNT5 register.
-//
-//*****************************************************************************
-#define USB_RXCOUNT5_COUNT_M 0x00001FFF // Receive Packet Count
-#define USB_RXCOUNT5_COUNT_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_TXTYPE5 register.
-//
-//*****************************************************************************
-#define USB_TXTYPE5_SPEED_M 0x000000C0 // Operating Speed
-#define USB_TXTYPE5_SPEED_DFLT 0x00000000 // Default
-#define USB_TXTYPE5_SPEED_HIGH 0x00000040 // High
-#define USB_TXTYPE5_SPEED_FULL 0x00000080 // Full
-#define USB_TXTYPE5_SPEED_LOW 0x000000C0 // Low
-#define USB_TXTYPE5_PROTO_M 0x00000030 // Protocol
-#define USB_TXTYPE5_PROTO_CTRL 0x00000000 // Control
-#define USB_TXTYPE5_PROTO_ISOC 0x00000010 // Isochronous
-#define USB_TXTYPE5_PROTO_BULK 0x00000020 // Bulk
-#define USB_TXTYPE5_PROTO_INT 0x00000030 // Interrupt
-#define USB_TXTYPE5_TEP_M 0x0000000F // Target Endpoint Number
-#define USB_TXTYPE5_TEP_S 0
-
+#define MUSB_ULPIREGDATA_REGDATA_M 0x00FF // Register Data
+#define MUSB_ULPIREGDATA_REGDATA_S 0
//*****************************************************************************
//
-// The following are defines for the bit fields in the USB_O_TXINTERVAL5
+// The following are defines for the bit fields in the MUSB_O_ULPIREGADDR
// register.
//
//*****************************************************************************
-#define USB_TXINTERVAL5_TXPOLL_M \
- 0x000000FF // TX Polling
-#define USB_TXINTERVAL5_NAKLMT_M \
- 0x000000FF // NAK Limit
-#define USB_TXINTERVAL5_NAKLMT_S \
- 0
-#define USB_TXINTERVAL5_TXPOLL_S \
- 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RXTYPE5 register.
-//
-//*****************************************************************************
-#define USB_RXTYPE5_SPEED_M 0x000000C0 // Operating Speed
-#define USB_RXTYPE5_SPEED_DFLT 0x00000000 // Default
-#define USB_RXTYPE5_SPEED_HIGH 0x00000040 // High
-#define USB_RXTYPE5_SPEED_FULL 0x00000080 // Full
-#define USB_RXTYPE5_SPEED_LOW 0x000000C0 // Low
-#define USB_RXTYPE5_PROTO_M 0x00000030 // Protocol
-#define USB_RXTYPE5_PROTO_CTRL 0x00000000 // Control
-#define USB_RXTYPE5_PROTO_ISOC 0x00000010 // Isochronous
-#define USB_RXTYPE5_PROTO_BULK 0x00000020 // Bulk
-#define USB_RXTYPE5_PROTO_INT 0x00000030 // Interrupt
-#define USB_RXTYPE5_TEP_M 0x0000000F // Target Endpoint Number
-#define USB_RXTYPE5_TEP_S 0
+#define MUSB_ULPIREGADDR_ADDR_M 0x00FF // Register Address
+#define MUSB_ULPIREGADDR_ADDR_S 0
//*****************************************************************************
//
-// The following are defines for the bit fields in the USB_O_RXINTERVAL5
+// The following are defines for the bit fields in the MUSB_O_ULPIREGCTL
// register.
//
//*****************************************************************************
-#define USB_RXINTERVAL5_TXPOLL_M \
- 0x000000FF // RX Polling
-#define USB_RXINTERVAL5_NAKLMT_M \
- 0x000000FF // NAK Limit
-#define USB_RXINTERVAL5_TXPOLL_S \
- 0
-#define USB_RXINTERVAL5_NAKLMT_S \
- 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_TXMAXP6 register.
-//
-//*****************************************************************************
-#define USB_TXMAXP6_MAXLOAD_M 0x000007FF // Maximum Payload
-#define USB_TXMAXP6_MAXLOAD_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_TXCSRL6 register.
-//
-//*****************************************************************************
-#define USB_TXCSRL6_NAKTO 0x00000080 // NAK Timeout
-#define USB_TXCSRL6_CLRDT 0x00000040 // Clear Data Toggle
-#define USB_TXCSRL6_STALLED 0x00000020 // Endpoint Stalled
-#define USB_TXCSRL6_STALL 0x00000010 // Send STALL
-#define USB_TXCSRL6_SETUP 0x00000010 // Setup Packet
-#define USB_TXCSRL6_FLUSH 0x00000008 // Flush FIFO
-#define USB_TXCSRL6_ERROR 0x00000004 // Error
-#define USB_TXCSRL6_UNDRN 0x00000004 // Underrun
-#define USB_TXCSRL6_FIFONE 0x00000002 // FIFO Not Empty
-#define USB_TXCSRL6_TXRDY 0x00000001 // Transmit Packet Ready
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_TXCSRH6 register.
-//
-//*****************************************************************************
-#define USB_TXCSRH6_AUTOSET 0x00000080 // Auto Set
-#define USB_TXCSRH6_ISO 0x00000040 // Isochronous Transfers
-#define USB_TXCSRH6_MODE 0x00000020 // Mode
-#define USB_TXCSRH6_DMAEN 0x00000010 // DMA Request Enable
-#define USB_TXCSRH6_FDT 0x00000008 // Force Data Toggle
-#define USB_TXCSRH6_DMAMOD 0x00000004 // DMA Request Mode
-#define USB_TXCSRH6_DTWE 0x00000002 // Data Toggle Write Enable
-#define USB_TXCSRH6_DT 0x00000001 // Data Toggle
+#define MUSB_ULPIREGCTL_RDWR 0x0004 // Read/Write Control
+#define MUSB_ULPIREGCTL_REGCMPLT 0x0002 // Register Access Complete
+#define MUSB_ULPIREGCTL_REGACC 0x0001 // Initiate Register Access
//*****************************************************************************
//
-// The following are defines for the bit fields in the USB_O_RXMAXP6 register.
+// The following are defines for the bit fields in the MUSB_O_EPINFO register.
//
//*****************************************************************************
-#define USB_RXMAXP6_MAXLOAD_M 0x000007FF // Maximum Payload
-#define USB_RXMAXP6_MAXLOAD_S 0
+#define MUSB_EPINFO_RXEP_M 0x00F0 // RX Endpoints
+#define MUSB_EPINFO_TXEP_M 0x000F // TX Endpoints
+#define MUSB_EPINFO_RXEP_S 4
+#define MUSB_EPINFO_TXEP_S 0
//*****************************************************************************
//
-// The following are defines for the bit fields in the USB_O_RXCSRL6 register.
+// The following are defines for the bit fields in the MUSB_O_RAMINFO register.
//
//*****************************************************************************
-#define USB_RXCSRL6_CLRDT 0x00000080 // Clear Data Toggle
-#define USB_RXCSRL6_STALLED 0x00000040 // Endpoint Stalled
-#define USB_RXCSRL6_REQPKT 0x00000020 // Request Packet
-#define USB_RXCSRL6_STALL 0x00000020 // Send STALL
-#define USB_RXCSRL6_FLUSH 0x00000010 // Flush FIFO
-#define USB_RXCSRL6_NAKTO 0x00000008 // NAK Timeout
-#define USB_RXCSRL6_DATAERR 0x00000008 // Data Error
-#define USB_RXCSRL6_ERROR 0x00000004 // Error
-#define USB_RXCSRL6_OVER 0x00000004 // Overrun
-#define USB_RXCSRL6_FULL 0x00000002 // FIFO Full
-#define USB_RXCSRL6_RXRDY 0x00000001 // Receive Packet Ready
+#define MUSB_RAMINFO_DMACHAN_M 0x00F0 // DMA Channels
+#define MUSB_RAMINFO_RAMBITS_M 0x000F // RAM Address Bus Width
+#define MUSB_RAMINFO_DMACHAN_S 4
+#define MUSB_RAMINFO_RAMBITS_S 0
//*****************************************************************************
//
-// The following are defines for the bit fields in the USB_O_RXCSRH6 register.
+// The following are defines for the bit fields in the MUSB_O_CONTIM register.
//
//*****************************************************************************
-#define USB_RXCSRH6_AUTOCL 0x00000080 // Auto Clear
-#define USB_RXCSRH6_AUTORQ 0x00000040 // Auto Request
-#define USB_RXCSRH6_ISO 0x00000040 // Isochronous Transfers
-#define USB_RXCSRH6_DMAEN 0x00000020 // DMA Request Enable
-#define USB_RXCSRH6_DISNYET 0x00000010 // Disable NYET
-#define USB_RXCSRH6_PIDERR 0x00000010 // PID Error
-#define USB_RXCSRH6_DMAMOD 0x00000008 // DMA Request Mode
-#define USB_RXCSRH6_DTWE 0x00000004 // Data Toggle Write Enable
-#define USB_RXCSRH6_DT 0x00000002 // Data Toggle
-#define USB_RXCSRH6_INCOMPRX 0x00000001 // Incomplete RX Transmission
- // Status
+#define MUSB_CONTIM_WTCON_M 0x00F0 // Connect Wait
+#define MUSB_CONTIM_WTID_M 0x000F // Wait ID
+#define MUSB_CONTIM_WTCON_S 4
+#define MUSB_CONTIM_WTID_S 0
//*****************************************************************************
//
-// The following are defines for the bit fields in the USB_O_RXCOUNT6 register.
+// The following are defines for the bit fields in the MUSB_O_VPLEN register.
//
//*****************************************************************************
-#define USB_RXCOUNT6_COUNT_M 0x00001FFF // Receive Packet Count
-#define USB_RXCOUNT6_COUNT_S 0
+#define MUSB_VPLEN_VPLEN_M 0x00FF // VBUS Pulse Length
+#define MUSB_VPLEN_VPLEN_S 0
//*****************************************************************************
//
-// The following are defines for the bit fields in the USB_O_TXTYPE6 register.
+// The following are defines for the bit fields in the MUSB_O_HSEOF register.
//
//*****************************************************************************
-#define USB_TXTYPE6_SPEED_M 0x000000C0 // Operating Speed
-#define USB_TXTYPE6_SPEED_DFLT 0x00000000 // Default
-#define USB_TXTYPE6_SPEED_HIGH 0x00000040 // High
-#define USB_TXTYPE6_SPEED_FULL 0x00000080 // Full
-#define USB_TXTYPE6_SPEED_LOW 0x000000C0 // Low
-#define USB_TXTYPE6_PROTO_M 0x00000030 // Protocol
-#define USB_TXTYPE6_PROTO_CTRL 0x00000000 // Control
-#define USB_TXTYPE6_PROTO_ISOC 0x00000010 // Isochronous
-#define USB_TXTYPE6_PROTO_BULK 0x00000020 // Bulk
-#define USB_TXTYPE6_PROTO_INT 0x00000030 // Interrupt
-#define USB_TXTYPE6_TEP_M 0x0000000F // Target Endpoint Number
-#define USB_TXTYPE6_TEP_S 0
+#define MUSB_HSEOF_HSEOFG_M 0x00FF // HIgh-Speed End-of-Frame Gap
+#define MUSB_HSEOF_HSEOFG_S 0
//*****************************************************************************
//
-// The following are defines for the bit fields in the USB_O_TXINTERVAL6
-// register.
+// The following are defines for the bit fields in the MUSB_O_FSEOF register.
//
//*****************************************************************************
-#define USB_TXINTERVAL6_TXPOLL_M \
- 0x000000FF // TX Polling
-#define USB_TXINTERVAL6_NAKLMT_M \
- 0x000000FF // NAK Limit
-#define USB_TXINTERVAL6_TXPOLL_S \
- 0
-#define USB_TXINTERVAL6_NAKLMT_S \
- 0
+#define MUSB_FSEOF_FSEOFG_M 0x00FF // Full-Speed End-of-Frame Gap
+#define MUSB_FSEOF_FSEOFG_S 0
//*****************************************************************************
//
-// The following are defines for the bit fields in the USB_O_RXTYPE6 register.
+// The following are defines for the bit fields in the MUSB_O_LSEOF register.
//
//*****************************************************************************
-#define USB_RXTYPE6_SPEED_M 0x000000C0 // Operating Speed
-#define USB_RXTYPE6_SPEED_DFLT 0x00000000 // Default
-#define USB_RXTYPE6_SPEED_HIGH 0x00000040 // High
-#define USB_RXTYPE6_SPEED_FULL 0x00000080 // Full
-#define USB_RXTYPE6_SPEED_LOW 0x000000C0 // Low
-#define USB_RXTYPE6_PROTO_M 0x00000030 // Protocol
-#define USB_RXTYPE6_PROTO_CTRL 0x00000000 // Control
-#define USB_RXTYPE6_PROTO_ISOC 0x00000010 // Isochronous
-#define USB_RXTYPE6_PROTO_BULK 0x00000020 // Bulk
-#define USB_RXTYPE6_PROTO_INT 0x00000030 // Interrupt
-#define USB_RXTYPE6_TEP_M 0x0000000F // Target Endpoint Number
-#define USB_RXTYPE6_TEP_S 0
+#define MUSB_LSEOF_LSEOFG_M 0x00FF // Low-Speed End-of-Frame Gap
+#define MUSB_LSEOF_LSEOFG_S 0
//*****************************************************************************
//
-// The following are defines for the bit fields in the USB_O_RXINTERVAL6
-// register.
+// The following are defines for the bit fields in the MUSB_O_CSRL0 register.
//
//*****************************************************************************
-#define USB_RXINTERVAL6_TXPOLL_M \
- 0x000000FF // RX Polling
-#define USB_RXINTERVAL6_NAKLMT_M \
- 0x000000FF // NAK Limit
-#define USB_RXINTERVAL6_NAKLMT_S \
- 0
-#define USB_RXINTERVAL6_TXPOLL_S \
- 0
+#define MUSB_CSRL0_NAKTO 0x0080 // NAK Timeout
+#define MUSB_CSRL0_SETENDC 0x0080 // Setup End Clear
+#define MUSB_CSRL0_STATUS 0x0040 // STATUS Packet
+#define MUSB_CSRL0_RXRDYC 0x0040 // RXRDY Clear
+#define MUSB_CSRL0_REQPKT 0x0020 // Request Packet
+#define MUSB_CSRL0_STALL 0x0020 // Send Stall
+#define MUSB_CSRL0_SETEND 0x0010 // Setup End
+#define MUSB_CSRL0_ERROR 0x0010 // Error
+#define MUSB_CSRL0_DATAEND 0x0008 // Data End
+#define MUSB_CSRL0_SETUP 0x0008 // Setup Packet
+#define MUSB_CSRL0_STALLED 0x0004 // Endpoint Stalled
+#define MUSB_CSRL0_TXRDY 0x0002 // Transmit Packet Ready
+#define MUSB_CSRL0_RXRDY 0x0001 // Receive Packet Ready
//*****************************************************************************
//
-// The following are defines for the bit fields in the USB_O_TXMAXP7 register.
+// The following are defines for the bit fields in the MUSB_O_CSRH0 register.
//
//*****************************************************************************
-#define USB_TXMAXP7_MAXLOAD_M 0x000007FF // Maximum Payload
-#define USB_TXMAXP7_MAXLOAD_S 0
+#define MUSB_CSRH0_DISPING 0x0008 // PING Disable
+#define MUSB_CSRH0_DTWE 0x0004 // Data Toggle Write Enable
+#define MUSB_CSRH0_DT 0x0002 // Data Toggle
+#define MUSB_CSRH0_FLUSH 0x0001 // Flush FIFO
//*****************************************************************************
//
-// The following are defines for the bit fields in the USB_O_TXCSRL7 register.
+// The following are defines for the bit fields in the MUSB_O_TYPE0 register.
//
//*****************************************************************************
-#define USB_TXCSRL7_NAKTO 0x00000080 // NAK Timeout
-#define USB_TXCSRL7_CLRDT 0x00000040 // Clear Data Toggle
-#define USB_TXCSRL7_STALLED 0x00000020 // Endpoint Stalled
-#define USB_TXCSRL7_STALL 0x00000010 // Send STALL
-#define USB_TXCSRL7_SETUP 0x00000010 // Setup Packet
-#define USB_TXCSRL7_FLUSH 0x00000008 // Flush FIFO
-#define USB_TXCSRL7_ERROR 0x00000004 // Error
-#define USB_TXCSRL7_UNDRN 0x00000004 // Underrun
-#define USB_TXCSRL7_FIFONE 0x00000002 // FIFO Not Empty
-#define USB_TXCSRL7_TXRDY 0x00000001 // Transmit Packet Ready
+#define MUSB_TYPE0_SPEED_M 0x00C0 // Operating Speed
+#define MUSB_TYPE0_SPEED_HIGH 0x0040 // High
+#define MUSB_TYPE0_SPEED_FULL 0x0080 // Full
+#define MUSB_TYPE0_SPEED_LOW 0x00C0 // Low
//*****************************************************************************
//
-// The following are defines for the bit fields in the USB_O_TXCSRH7 register.
+// The following are defines for the bit fields in the MUSB_O_NAKLMT register.
//
//*****************************************************************************
-#define USB_TXCSRH7_AUTOSET 0x00000080 // Auto Set
-#define USB_TXCSRH7_ISO 0x00000040 // Isochronous Transfers
-#define USB_TXCSRH7_MODE 0x00000020 // Mode
-#define USB_TXCSRH7_DMAEN 0x00000010 // DMA Request Enable
-#define USB_TXCSRH7_FDT 0x00000008 // Force Data Toggle
-#define USB_TXCSRH7_DMAMOD 0x00000004 // DMA Request Mode
-#define USB_TXCSRH7_DTWE 0x00000002 // Data Toggle Write Enable
-#define USB_TXCSRH7_DT 0x00000001 // Data Toggle
+#define MUSB_NAKLMT_NAKLMT_M 0x001F // EP0 NAK Limit
+#define MUSB_NAKLMT_NAKLMT_S 0
//*****************************************************************************
//
-// The following are defines for the bit fields in the USB_O_RXMAXP7 register.
+// The following are defines for the bit fields in the MUSB_O_TXCSRL1 register.
//
//*****************************************************************************
-#define USB_RXMAXP7_MAXLOAD_M 0x000007FF // Maximum Payload
-#define USB_RXMAXP7_MAXLOAD_S 0
+#define MUSB_TXCSRL1_NAKTO 0x0080 // NAK Timeout
+#define MUSB_TXCSRL1_CLRDT 0x0040 // Clear Data Toggle
+#define MUSB_TXCSRL1_STALLED 0x0020 // Endpoint Stalled
+#define MUSB_TXCSRL1_STALL 0x0010 // Send STALL
+#define MUSB_TXCSRL1_SETUP 0x0010 // Setup Packet
+#define MUSB_TXCSRL1_FLUSH 0x0008 // Flush FIFO
+#define MUSB_TXCSRL1_ERROR 0x0004 // Error
+#define MUSB_TXCSRL1_UNDRN 0x0004 // Underrun
+#define MUSB_TXCSRL1_FIFONE 0x0002 // FIFO Not Empty
+#define MUSB_TXCSRL1_TXRDY 0x0001 // Transmit Packet Ready
//*****************************************************************************
//
-// The following are defines for the bit fields in the USB_O_RXCSRL7 register.
+// The following are defines for the bit fields in the MUSB_O_TXCSRH1 register.
//
//*****************************************************************************
-#define USB_RXCSRL7_CLRDT 0x00000080 // Clear Data Toggle
-#define USB_RXCSRL7_STALLED 0x00000040 // Endpoint Stalled
-#define USB_RXCSRL7_REQPKT 0x00000020 // Request Packet
-#define USB_RXCSRL7_STALL 0x00000020 // Send STALL
-#define USB_RXCSRL7_FLUSH 0x00000010 // Flush FIFO
-#define USB_RXCSRL7_DATAERR 0x00000008 // Data Error
-#define USB_RXCSRL7_NAKTO 0x00000008 // NAK Timeout
-#define USB_RXCSRL7_ERROR 0x00000004 // Error
-#define USB_RXCSRL7_OVER 0x00000004 // Overrun
-#define USB_RXCSRL7_FULL 0x00000002 // FIFO Full
-#define USB_RXCSRL7_RXRDY 0x00000001 // Receive Packet Ready
+#define MUSB_TXCSRH1_AUTOSET 0x0080 // Auto Set
+#define MUSB_TXCSRH1_ISO 0x0040 // Isochronous Transfers
+#define MUSB_TXCSRH1_MODE 0x0020 // Mode
+#define MUSB_TXCSRH1_DMAEN 0x0010 // DMA Request Enable
+#define MUSB_TXCSRH1_FDT 0x0008 // Force Data Toggle
+#define MUSB_TXCSRH1_DMAMOD 0x0004 // DMA Request Mode
+#define MUSB_TXCSRH1_DTWE 0x0002 // Data Toggle Write Enable
+#define MUSB_TXCSRH1_DT 0x0001 // Data Toggle
//*****************************************************************************
//
-// The following are defines for the bit fields in the USB_O_RXCSRH7 register.
+// The following are defines for the bit fields in the MUSB_O_RXCSRL1 register.
//
//*****************************************************************************
-#define USB_RXCSRH7_AUTOCL 0x00000080 // Auto Clear
-#define USB_RXCSRH7_ISO 0x00000040 // Isochronous Transfers
-#define USB_RXCSRH7_AUTORQ 0x00000040 // Auto Request
-#define USB_RXCSRH7_DMAEN 0x00000020 // DMA Request Enable
-#define USB_RXCSRH7_PIDERR 0x00000010 // PID Error
-#define USB_RXCSRH7_DISNYET 0x00000010 // Disable NYET
-#define USB_RXCSRH7_DMAMOD 0x00000008 // DMA Request Mode
-#define USB_RXCSRH7_DTWE 0x00000004 // Data Toggle Write Enable
-#define USB_RXCSRH7_DT 0x00000002 // Data Toggle
-#define USB_RXCSRH7_INCOMPRX 0x00000001 // Incomplete RX Transmission
- // Status
+#define MUSB_RXCSRL1_CLRDT 0x0080 // Clear Data Toggle
+#define MUSB_RXCSRL1_STALLED 0x0040 // Endpoint Stalled
+#define MUSB_RXCSRL1_STALL 0x0020 // Send STALL
+#define MUSB_RXCSRL1_REQPKT 0x0020 // Request Packet
+#define MUSB_RXCSRL1_FLUSH 0x0010 // Flush FIFO
+#define MUSB_RXCSRL1_DATAERR 0x0008 // Data Error
+#define MUSB_RXCSRL1_NAKTO 0x0008 // NAK Timeout
+#define MUSB_RXCSRL1_OVER 0x0004 // Overrun
+#define MUSB_RXCSRL1_ERROR 0x0004 // Error
+#define MUSB_RXCSRL1_FULL 0x0002 // FIFO Full
+#define MUSB_RXCSRL1_RXRDY 0x0001 // Receive Packet Ready
//*****************************************************************************
//
-// The following are defines for the bit fields in the USB_O_RXCOUNT7 register.
+// The following are defines for the bit fields in the MUSB_O_RXCSRH1 register.
//
//*****************************************************************************
-#define USB_RXCOUNT7_COUNT_M 0x00001FFF // Receive Packet Count
-#define USB_RXCOUNT7_COUNT_S 0
+#define MUSB_RXCSRH1_AUTOCL 0x0080 // Auto Clear
+#define MUSB_RXCSRH1_AUTORQ 0x0040 // Auto Request
+#define MUSB_RXCSRH1_ISO 0x0040 // Isochronous Transfers
+#define MUSB_RXCSRH1_DMAEN 0x0020 // DMA Request Enable
+#define MUSB_RXCSRH1_DISNYET 0x0010 // Disable NYET
+#define MUSB_RXCSRH1_PIDERR 0x0010 // PID Error
+#define MUSB_RXCSRH1_DMAMOD 0x0008 // DMA Request Mode
+#define MUSB_RXCSRH1_DTWE 0x0004 // Data Toggle Write Enable
+#define MUSB_RXCSRH1_DT 0x0002 // Data Toggle
+#define MUSB_RXCSRH1_INCOMPRX 0x0001 // Incomplete RX Transmission Status
//*****************************************************************************
//
-// The following are defines for the bit fields in the USB_O_TXTYPE7 register.
+// The following are defines for the bit fields in the MUSB_O_TXTYPE1 register.
//
//*****************************************************************************
-#define USB_TXTYPE7_SPEED_M 0x000000C0 // Operating Speed
-#define USB_TXTYPE7_SPEED_DFLT 0x00000000 // Default
-#define USB_TXTYPE7_SPEED_HIGH 0x00000040 // High
-#define USB_TXTYPE7_SPEED_FULL 0x00000080 // Full
-#define USB_TXTYPE7_SPEED_LOW 0x000000C0 // Low
-#define USB_TXTYPE7_PROTO_M 0x00000030 // Protocol
-#define USB_TXTYPE7_PROTO_CTRL 0x00000000 // Control
-#define USB_TXTYPE7_PROTO_ISOC 0x00000010 // Isochronous
-#define USB_TXTYPE7_PROTO_BULK 0x00000020 // Bulk
-#define USB_TXTYPE7_PROTO_INT 0x00000030 // Interrupt
-#define USB_TXTYPE7_TEP_M 0x0000000F // Target Endpoint Number
-#define USB_TXTYPE7_TEP_S 0
+#define MUSB_TXTYPE1_SPEED_M 0x00C0 // Operating Speed
+#define MUSB_TXTYPE1_SPEED_DFLT 0x0000 // Default
+#define MUSB_TXTYPE1_SPEED_HIGH 0x0040 // High
+#define MUSB_TXTYPE1_SPEED_FULL 0x0080 // Full
+#define MUSB_TXTYPE1_SPEED_LOW 0x00C0 // Low
+#define MUSB_TXTYPE1_PROTO_M 0x0030 // Protocol
+#define MUSB_TXTYPE1_PROTO_CTRL 0x0000 // Control
+#define MUSB_TXTYPE1_PROTO_ISOC 0x0010 // Isochronous
+#define MUSB_TXTYPE1_PROTO_BULK 0x0020 // Bulk
+#define MUSB_TXTYPE1_PROTO_INT 0x0030 // Interrupt
+#define MUSB_TXTYPE1_TEP_M 0x000F // Target Endpoint Number
+#define MUSB_TXTYPE1_TEP_S 0
//*****************************************************************************
//
-// The following are defines for the bit fields in the USB_O_TXINTERVAL7
+// The following are defines for the bit fields in the MUSB_O_TXINTERVAL1
// register.
//
//*****************************************************************************
-#define USB_TXINTERVAL7_TXPOLL_M \
- 0x000000FF // TX Polling
-#define USB_TXINTERVAL7_NAKLMT_M \
- 0x000000FF // NAK Limit
-#define USB_TXINTERVAL7_NAKLMT_S \
- 0
-#define USB_TXINTERVAL7_TXPOLL_S \
- 0
+#define MUSB_TXINTERVAL1_NAKLMT_M 0x00FF // NAK Limit
+#define MUSB_TXINTERVAL1_TXPOLL_M 0x00FF // TX Polling
+#define MUSB_TXINTERVAL1_TXPOLL_S 0
+#define MUSB_TXINTERVAL1_NAKLMT_S 0
//*****************************************************************************
//
-// The following are defines for the bit fields in the USB_O_RXTYPE7 register.
+// The following are defines for the bit fields in the MUSB_O_RXTYPE1 register.
//
//*****************************************************************************
-#define USB_RXTYPE7_SPEED_M 0x000000C0 // Operating Speed
-#define USB_RXTYPE7_SPEED_DFLT 0x00000000 // Default
-#define USB_RXTYPE7_SPEED_HIGH 0x00000040 // High
-#define USB_RXTYPE7_SPEED_FULL 0x00000080 // Full
-#define USB_RXTYPE7_SPEED_LOW 0x000000C0 // Low
-#define USB_RXTYPE7_PROTO_M 0x00000030 // Protocol
-#define USB_RXTYPE7_PROTO_CTRL 0x00000000 // Control
-#define USB_RXTYPE7_PROTO_ISOC 0x00000010 // Isochronous
-#define USB_RXTYPE7_PROTO_BULK 0x00000020 // Bulk
-#define USB_RXTYPE7_PROTO_INT 0x00000030 // Interrupt
-#define USB_RXTYPE7_TEP_M 0x0000000F // Target Endpoint Number
-#define USB_RXTYPE7_TEP_S 0
+#define MUSB_RXTYPE1_SPEED_M 0x00C0 // Operating Speed
+#define MUSB_RXTYPE1_SPEED_DFLT 0x0000 // Default
+#define MUSB_RXTYPE1_SPEED_HIGH 0x0040 // High
+#define MUSB_RXTYPE1_SPEED_FULL 0x0080 // Full
+#define MUSB_RXTYPE1_SPEED_LOW 0x00C0 // Low
+#define MUSB_RXTYPE1_PROTO_M 0x0030 // Protocol
+#define MUSB_RXTYPE1_PROTO_CTRL 0x0000 // Control
+#define MUSB_RXTYPE1_PROTO_ISOC 0x0010 // Isochronous
+#define MUSB_RXTYPE1_PROTO_BULK 0x0020 // Bulk
+#define MUSB_RXTYPE1_PROTO_INT 0x0030 // Interrupt
+#define MUSB_RXTYPE1_TEP_M 0x000F // Target Endpoint Number
+#define MUSB_RXTYPE1_TEP_S 0
//*****************************************************************************
//
-// The following are defines for the bit fields in the USB_O_RXINTERVAL7
+// The following are defines for the bit fields in the MUSB_O_RXINTERVAL1
// register.
//
//*****************************************************************************
-#define USB_RXINTERVAL7_TXPOLL_M \
- 0x000000FF // RX Polling
-#define USB_RXINTERVAL7_NAKLMT_M \
- 0x000000FF // NAK Limit
-#define USB_RXINTERVAL7_NAKLMT_S \
- 0
-#define USB_RXINTERVAL7_TXPOLL_S \
- 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_DMAINTR register.
-//
-//*****************************************************************************
-#define USB_DMAINTR_CH7 0x00000080 // Channel 7 DMA Interrupt
-#define USB_DMAINTR_CH6 0x00000040 // Channel 6 DMA Interrupt
-#define USB_DMAINTR_CH5 0x00000020 // Channel 5 DMA Interrupt
-#define USB_DMAINTR_CH4 0x00000010 // Channel 4 DMA Interrupt
-#define USB_DMAINTR_CH3 0x00000008 // Channel 3 DMA Interrupt
-#define USB_DMAINTR_CH2 0x00000004 // Channel 2 DMA Interrupt
-#define USB_DMAINTR_CH1 0x00000002 // Channel 1 DMA Interrupt
-#define USB_DMAINTR_CH0 0x00000001 // Channel 0 DMA Interrupt
+#define MUSB_RXINTERVAL1_TXPOLL_M 0x00FF // RX Polling
+#define MUSB_RXINTERVAL1_NAKLMT_M 0x00FF // NAK Limit
+#define MUSB_RXINTERVAL1_TXPOLL_S 0
+#define MUSB_RXINTERVAL1_NAKLMT_S 0
//*****************************************************************************
//
-// The following are defines for the bit fields in the USB_O_DMACTL0 register.
+// The following are defines for the bit fields in the MUSB_O_DMACTL0 register.
//
//*****************************************************************************
-#define USB_DMACTL0_BRSTM_M 0x00000600 // Burst Mode
-#define USB_DMACTL0_BRSTM_ANY 0x00000000 // Bursts of unspecified length
-#define USB_DMACTL0_BRSTM_INC4 0x00000200 // INCR4 or unspecified length
-#define USB_DMACTL0_BRSTM_INC8 0x00000400 // INCR8, INCR4 or unspecified
+#define MUSB_DMACTL0_BRSTM_M 0x0600 // Burst Mode
+#define MUSB_DMACTL0_BRSTM_ANY 0x0000 // Bursts of unspecified length
+#define MUSB_DMACTL0_BRSTM_INC4 0x0200 // INCR4 or unspecified length
+#define MUSB_DMACTL0_BRSTM_INC8 0x0400 // INCR8, INCR4 or unspecified
// length
-#define USB_DMACTL0_BRSTM_INC16 0x00000600 // INCR16, INCR8, INCR4 or
+#define MUSB_DMACTL0_BRSTM_INC16 0x0600 // INCR16, INCR8, INCR4 or
// unspecified length
-#define USB_DMACTL0_ERR 0x00000100 // Bus Error Bit
-#define USB_DMACTL0_EP_M 0x000000F0 // Endpoint number
-#define USB_DMACTL0_IE 0x00000008 // DMA Interrupt Enable
-#define USB_DMACTL0_MODE 0x00000004 // DMA Transfer Mode
-#define USB_DMACTL0_DIR 0x00000002 // DMA Direction
-#define USB_DMACTL0_ENABLE 0x00000001 // DMA Transfer Enable
-#define USB_DMACTL0_EP_S 4
+#define MUSB_DMACTL0_ERR 0x0100 // Bus Error Bit
+#define MUSB_DMACTL0_EP_M 0x00F0 // Endpoint number
+#define MUSB_DMACTL0_IE 0x0008 // DMA Interrupt Enable
+#define MUSB_DMACTL0_MODE 0x0004 // DMA Transfer Mode
+#define MUSB_DMACTL0_DIR 0x0002 // DMA Direction
+#define MUSB_DMACTL0_ENABLE 0x0001 // DMA Transfer Enable
+#define MUSB_DMACTL0_EP_S 4
//*****************************************************************************
//
-// The following are defines for the bit fields in the USB_O_DMAADDR0 register.
+// The following are defines for the bit fields in the MUSB_O_DMAADDR0 register.
//
//*****************************************************************************
-#define USB_DMAADDR0_ADDR_M 0xFFFFFFFC // DMA Address
-#define USB_DMAADDR0_ADDR_S 2
+#define MUSB_DMAADDR0_ADDR_M 0xFFFFFFFC // DMA Address
+#define MUSB_DMAADDR0_ADDR_S 2
//*****************************************************************************
//
-// The following are defines for the bit fields in the USB_O_DMACOUNT0
+// The following are defines for the bit fields in the MUSB_O_DMACOUNT0
// register.
//
//*****************************************************************************
-#define USB_DMACOUNT0_COUNT_M 0xFFFFFFFC // DMA Count
-#define USB_DMACOUNT0_COUNT_S 2
+#define MUSB_DMACOUNT0_COUNT_M 0xFFFFFFFC // DMA Count
+#define MUSB_DMACOUNT0_COUNT_S 2
//*****************************************************************************
//
-// The following are defines for the bit fields in the USB_O_DMACTL1 register.
+// The following are defines for the bit fields in the MUSB_O_CTO register.
//
//*****************************************************************************
-#define USB_DMACTL1_BRSTM_M 0x00000600 // Burst Mode
-#define USB_DMACTL1_BRSTM_ANY 0x00000000 // Bursts of unspecified length
-#define USB_DMACTL1_BRSTM_INC4 0x00000200 // INCR4 or unspecified length
-#define USB_DMACTL1_BRSTM_INC8 0x00000400 // INCR8, INCR4 or unspecified
- // length
-#define USB_DMACTL1_BRSTM_INC16 0x00000600 // INCR16, INCR8, INCR4 or
- // unspecified length
-#define USB_DMACTL1_ERR 0x00000100 // Bus Error Bit
-#define USB_DMACTL1_EP_M 0x000000F0 // Endpoint number
-#define USB_DMACTL1_IE 0x00000008 // DMA Interrupt Enable
-#define USB_DMACTL1_MODE 0x00000004 // DMA Transfer Mode
-#define USB_DMACTL1_DIR 0x00000002 // DMA Direction
-#define USB_DMACTL1_ENABLE 0x00000001 // DMA Transfer Enable
-#define USB_DMACTL1_EP_S 4
+#define MUSB_CTO_CCTV_M 0xFFFF // Configurable Chirp Timeout Value
+#define MUSB_CTO_CCTV_S 0
//*****************************************************************************
//
-// The following are defines for the bit fields in the USB_O_DMAADDR1 register.
+// The following are defines for the bit fields in the MUSB_O_HHSRTN register.
//
//*****************************************************************************
-#define USB_DMAADDR1_ADDR_M 0xFFFFFFFC // DMA Address
-#define USB_DMAADDR1_ADDR_S 2
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_DMACOUNT1
-// register.
-//
-//*****************************************************************************
-#define USB_DMACOUNT1_COUNT_M 0xFFFFFFFC // DMA Count
-#define USB_DMACOUNT1_COUNT_S 2
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_DMACTL2 register.
-//
-//*****************************************************************************
-#define USB_DMACTL2_BRSTM_M 0x00000600 // Burst Mode
-#define USB_DMACTL2_BRSTM_ANY 0x00000000 // Bursts of unspecified length
-#define USB_DMACTL2_BRSTM_INC4 0x00000200 // INCR4 or unspecified length
-#define USB_DMACTL2_BRSTM_INC8 0x00000400 // INCR8, INCR4 or unspecified
- // length
-#define USB_DMACTL2_BRSTM_INC16 0x00000600 // INCR16, INCR8, INCR4 or
- // unspecified length
-#define USB_DMACTL2_ERR 0x00000100 // Bus Error Bit
-#define USB_DMACTL2_EP_M 0x000000F0 // Endpoint number
-#define USB_DMACTL2_IE 0x00000008 // DMA Interrupt Enable
-#define USB_DMACTL2_MODE 0x00000004 // DMA Transfer Mode
-#define USB_DMACTL2_DIR 0x00000002 // DMA Direction
-#define USB_DMACTL2_ENABLE 0x00000001 // DMA Transfer Enable
-#define USB_DMACTL2_EP_S 4
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_DMAADDR2 register.
-//
-//*****************************************************************************
-#define USB_DMAADDR2_ADDR_M 0xFFFFFFFC // DMA Address
-#define USB_DMAADDR2_ADDR_S 2
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_DMACOUNT2
-// register.
-//
-//*****************************************************************************
-#define USB_DMACOUNT2_COUNT_M 0xFFFFFFFC // DMA Count
-#define USB_DMACOUNT2_COUNT_S 2
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_DMACTL3 register.
-//
-//*****************************************************************************
-#define USB_DMACTL3_BRSTM_M 0x00000600 // Burst Mode
-#define USB_DMACTL3_BRSTM_ANY 0x00000000 // Bursts of unspecified length
-#define USB_DMACTL3_BRSTM_INC4 0x00000200 // INCR4 or unspecified length
-#define USB_DMACTL3_BRSTM_INC8 0x00000400 // INCR8, INCR4 or unspecified
- // length
-#define USB_DMACTL3_BRSTM_INC16 0x00000600 // INCR16, INCR8, INCR4 or
- // unspecified length
-#define USB_DMACTL3_ERR 0x00000100 // Bus Error Bit
-#define USB_DMACTL3_EP_M 0x000000F0 // Endpoint number
-#define USB_DMACTL3_IE 0x00000008 // DMA Interrupt Enable
-#define USB_DMACTL3_MODE 0x00000004 // DMA Transfer Mode
-#define USB_DMACTL3_DIR 0x00000002 // DMA Direction
-#define USB_DMACTL3_ENABLE 0x00000001 // DMA Transfer Enable
-#define USB_DMACTL3_EP_S 4
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_DMAADDR3 register.
-//
-//*****************************************************************************
-#define USB_DMAADDR3_ADDR_M 0xFFFFFFFC // DMA Address
-#define USB_DMAADDR3_ADDR_S 2
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_DMACOUNT3
-// register.
-//
-//*****************************************************************************
-#define USB_DMACOUNT3_COUNT_M 0xFFFFFFFC // DMA Count
-#define USB_DMACOUNT3_COUNT_S 2
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_DMACTL4 register.
-//
-//*****************************************************************************
-#define USB_DMACTL4_BRSTM_M 0x00000600 // Burst Mode
-#define USB_DMACTL4_BRSTM_ANY 0x00000000 // Bursts of unspecified length
-#define USB_DMACTL4_BRSTM_INC4 0x00000200 // INCR4 or unspecified length
-#define USB_DMACTL4_BRSTM_INC8 0x00000400 // INCR8, INCR4 or unspecified
- // length
-#define USB_DMACTL4_BRSTM_INC16 0x00000600 // INCR16, INCR8, INCR4 or
- // unspecified length
-#define USB_DMACTL4_ERR 0x00000100 // Bus Error Bit
-#define USB_DMACTL4_EP_M 0x000000F0 // Endpoint number
-#define USB_DMACTL4_IE 0x00000008 // DMA Interrupt Enable
-#define USB_DMACTL4_MODE 0x00000004 // DMA Transfer Mode
-#define USB_DMACTL4_DIR 0x00000002 // DMA Direction
-#define USB_DMACTL4_ENABLE 0x00000001 // DMA Transfer Enable
-#define USB_DMACTL4_EP_S 4
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_DMAADDR4 register.
-//
-//*****************************************************************************
-#define USB_DMAADDR4_ADDR_M 0xFFFFFFFC // DMA Address
-#define USB_DMAADDR4_ADDR_S 2
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_DMACOUNT4
-// register.
-//
-//*****************************************************************************
-#define USB_DMACOUNT4_COUNT_M 0xFFFFFFFC // DMA Count
-#define USB_DMACOUNT4_COUNT_S 2
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_DMACTL5 register.
-//
-//*****************************************************************************
-#define USB_DMACTL5_BRSTM_M 0x00000600 // Burst Mode
-#define USB_DMACTL5_BRSTM_ANY 0x00000000 // Bursts of unspecified length
-#define USB_DMACTL5_BRSTM_INC4 0x00000200 // INCR4 or unspecified length
-#define USB_DMACTL5_BRSTM_INC8 0x00000400 // INCR8, INCR4 or unspecified
- // length
-#define USB_DMACTL5_BRSTM_INC16 0x00000600 // INCR16, INCR8, INCR4 or
- // unspecified length
-#define USB_DMACTL5_ERR 0x00000100 // Bus Error Bit
-#define USB_DMACTL5_EP_M 0x000000F0 // Endpoint number
-#define USB_DMACTL5_IE 0x00000008 // DMA Interrupt Enable
-#define USB_DMACTL5_MODE 0x00000004 // DMA Transfer Mode
-#define USB_DMACTL5_DIR 0x00000002 // DMA Direction
-#define USB_DMACTL5_ENABLE 0x00000001 // DMA Transfer Enable
-#define USB_DMACTL5_EP_S 4
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_DMAADDR5 register.
-//
-//*****************************************************************************
-#define USB_DMAADDR5_ADDR_M 0xFFFFFFFC // DMA Address
-#define USB_DMAADDR5_ADDR_S 2
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_DMACOUNT5
-// register.
-//
-//*****************************************************************************
-#define USB_DMACOUNT5_COUNT_M 0xFFFFFFFC // DMA Count
-#define USB_DMACOUNT5_COUNT_S 2
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_DMACTL6 register.
-//
-//*****************************************************************************
-#define USB_DMACTL6_BRSTM_M 0x00000600 // Burst Mode
-#define USB_DMACTL6_BRSTM_ANY 0x00000000 // Bursts of unspecified length
-#define USB_DMACTL6_BRSTM_INC4 0x00000200 // INCR4 or unspecified length
-#define USB_DMACTL6_BRSTM_INC8 0x00000400 // INCR8, INCR4 or unspecified
- // length
-#define USB_DMACTL6_BRSTM_INC16 0x00000600 // INCR16, INCR8, INCR4 or
- // unspecified length
-#define USB_DMACTL6_ERR 0x00000100 // Bus Error Bit
-#define USB_DMACTL6_EP_M 0x000000F0 // Endpoint number
-#define USB_DMACTL6_IE 0x00000008 // DMA Interrupt Enable
-#define USB_DMACTL6_MODE 0x00000004 // DMA Transfer Mode
-#define USB_DMACTL6_DIR 0x00000002 // DMA Direction
-#define USB_DMACTL6_ENABLE 0x00000001 // DMA Transfer Enable
-#define USB_DMACTL6_EP_S 4
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_DMAADDR6 register.
-//
-//*****************************************************************************
-#define USB_DMAADDR6_ADDR_M 0xFFFFFFFC // DMA Address
-#define USB_DMAADDR6_ADDR_S 2
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_DMACOUNT6
-// register.
-//
-//*****************************************************************************
-#define USB_DMACOUNT6_COUNT_M 0xFFFFFFFC // DMA Count
-#define USB_DMACOUNT6_COUNT_S 2
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_DMACTL7 register.
-//
-//*****************************************************************************
-#define USB_DMACTL7_BRSTM_M 0x00000600 // Burst Mode
-#define USB_DMACTL7_BRSTM_ANY 0x00000000 // Bursts of unspecified length
-#define USB_DMACTL7_BRSTM_INC4 0x00000200 // INCR4 or unspecified length
-#define USB_DMACTL7_BRSTM_INC8 0x00000400 // INCR8, INCR4 or unspecified
- // length
-#define USB_DMACTL7_BRSTM_INC16 0x00000600 // INCR16, INCR8, INCR4 or
- // unspecified length
-#define USB_DMACTL7_ERR 0x00000100 // Bus Error Bit
-#define USB_DMACTL7_EP_M 0x000000F0 // Endpoint number
-#define USB_DMACTL7_IE 0x00000008 // DMA Interrupt Enable
-#define USB_DMACTL7_MODE 0x00000004 // DMA Transfer Mode
-#define USB_DMACTL7_DIR 0x00000002 // DMA Direction
-#define USB_DMACTL7_ENABLE 0x00000001 // DMA Transfer Enable
-#define USB_DMACTL7_EP_S 4
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_DMAADDR7 register.
-//
-//*****************************************************************************
-#define USB_DMAADDR7_ADDR_M 0xFFFFFFFC // DMA Address
-#define USB_DMAADDR7_ADDR_S 2
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_DMACOUNT7
-// register.
-//
-//*****************************************************************************
-#define USB_DMACOUNT7_COUNT_M 0xFFFFFFFC // DMA Count
-#define USB_DMACOUNT7_COUNT_S 2
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RQPKTCOUNT1
-// register.
-//
-//*****************************************************************************
-#define USB_RQPKTCOUNT1_M 0x0000FFFF // Block Transfer Packet Count
-#define USB_RQPKTCOUNT1_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RQPKTCOUNT2
-// register.
-//
-//*****************************************************************************
-#define USB_RQPKTCOUNT2_M 0x0000FFFF // Block Transfer Packet Count
-#define USB_RQPKTCOUNT2_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RQPKTCOUNT3
-// register.
-//
-//*****************************************************************************
-#define USB_RQPKTCOUNT3_M 0x0000FFFF // Block Transfer Packet Count
-#define USB_RQPKTCOUNT3_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RQPKTCOUNT4
-// register.
-//
-//*****************************************************************************
-#define USB_RQPKTCOUNT4_COUNT_M 0x0000FFFF // Block Transfer Packet Count
-#define USB_RQPKTCOUNT4_COUNT_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RQPKTCOUNT5
-// register.
-//
-//*****************************************************************************
-#define USB_RQPKTCOUNT5_COUNT_M 0x0000FFFF // Block Transfer Packet Count
-#define USB_RQPKTCOUNT5_COUNT_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RQPKTCOUNT6
-// register.
-//
-//*****************************************************************************
-#define USB_RQPKTCOUNT6_COUNT_M 0x0000FFFF // Block Transfer Packet Count
-#define USB_RQPKTCOUNT6_COUNT_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RQPKTCOUNT7
-// register.
-//
-//*****************************************************************************
-#define USB_RQPKTCOUNT7_COUNT_M 0x0000FFFF // Block Transfer Packet Count
-#define USB_RQPKTCOUNT7_COUNT_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_RXDPKTBUFDIS
-// register.
-//
-//*****************************************************************************
-#define USB_RXDPKTBUFDIS_EP7 0x00000080 // EP7 RX Double-Packet Buffer
- // Disable
-#define USB_RXDPKTBUFDIS_EP6 0x00000040 // EP6 RX Double-Packet Buffer
- // Disable
-#define USB_RXDPKTBUFDIS_EP5 0x00000020 // EP5 RX Double-Packet Buffer
- // Disable
-#define USB_RXDPKTBUFDIS_EP4 0x00000010 // EP4 RX Double-Packet Buffer
- // Disable
-#define USB_RXDPKTBUFDIS_EP3 0x00000008 // EP3 RX Double-Packet Buffer
- // Disable
-#define USB_RXDPKTBUFDIS_EP2 0x00000004 // EP2 RX Double-Packet Buffer
- // Disable
-#define USB_RXDPKTBUFDIS_EP1 0x00000002 // EP1 RX Double-Packet Buffer
- // Disable
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_TXDPKTBUFDIS
-// register.
-//
-//*****************************************************************************
-#define USB_TXDPKTBUFDIS_EP7 0x00000080 // EP7 TX Double-Packet Buffer
- // Disable
-#define USB_TXDPKTBUFDIS_EP6 0x00000040 // EP6 TX Double-Packet Buffer
- // Disable
-#define USB_TXDPKTBUFDIS_EP5 0x00000020 // EP5 TX Double-Packet Buffer
- // Disable
-#define USB_TXDPKTBUFDIS_EP4 0x00000010 // EP4 TX Double-Packet Buffer
- // Disable
-#define USB_TXDPKTBUFDIS_EP3 0x00000008 // EP3 TX Double-Packet Buffer
- // Disable
-#define USB_TXDPKTBUFDIS_EP2 0x00000004 // EP2 TX Double-Packet Buffer
- // Disable
-#define USB_TXDPKTBUFDIS_EP1 0x00000002 // EP1 TX Double-Packet Buffer
- // Disable
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_CTO register.
-//
-//*****************************************************************************
-#define USB_CTO_CCTV_M 0x0000FFFF // Configurable Chirp Timeout Value
-#define USB_CTO_CCTV_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_HHSRTN register.
-//
-//*****************************************************************************
-#define USB_HHSRTN_HHSRTN_M 0x0000FFFF // HIgh Speed to UTM Operating
+#define MUSB_HHSRTN_HHSRTN_M 0xFFFF // HIgh Speed to UTM Operating
// Delay
-#define USB_HHSRTN_HHSRTN_S 0
+#define MUSB_HHSRTN_HHSRTN_S 0
//*****************************************************************************
//
-// The following are defines for the bit fields in the USB_O_HSBT register.
+// The following are defines for the bit fields in the MUSB_O_HSBT register.
//
//*****************************************************************************
-#define USB_HSBT_HSBT_M 0x0000000F // High Speed Timeout Adder
-#define USB_HSBT_HSBT_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_LPMATTR register.
-//
-//*****************************************************************************
-#define USB_LPMATTR_ENDPT_M 0x0000F000 // Endpoint
-#define USB_LPMATTR_RMTWAK 0x00000100 // Remote Wake
-#define USB_LPMATTR_HIRD_M 0x000000F0 // Host Initiated Resume Duration
-#define USB_LPMATTR_LS_M 0x0000000F // Link State
-#define USB_LPMATTR_LS_L1 0x00000001 // Sleep State (L1)
-#define USB_LPMATTR_ENDPT_S 12
-#define USB_LPMATTR_HIRD_S 4
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_LPMCNTRL register.
-//
-//*****************************************************************************
-#define USB_LPMCNTRL_NAK 0x00000010 // LPM NAK
-#define USB_LPMCNTRL_EN_M 0x0000000C // LPM Enable
-#define USB_LPMCNTRL_EN_NONE 0x00000000 // LPM and Extended transactions
- // are not supported. In this case,
- // the USB does not respond to LPM
- // transactions and LPM
- // transactions cause a timeout
-#define USB_LPMCNTRL_EN_EXT 0x00000004 // LPM is not supported but
- // extended transactions are
- // supported. In this case, the USB
- // does respond to an LPM
- // transaction with a STALL
-#define USB_LPMCNTRL_EN_LPMEXT 0x0000000C // The USB supports LPM extended
- // transactions. In this case, the
- // USB responds with a NYET or an
- // ACK as determined by the value
- // of TXLPM and other conditions
-#define USB_LPMCNTRL_RES 0x00000002 // LPM Resume
-#define USB_LPMCNTRL_TXLPM 0x00000001 // Transmit LPM Transaction Enable
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_LPMIM register.
-//
-//*****************************************************************************
-#define USB_LPMIM_ERR 0x00000020 // LPM Error Interrupt Mask
-#define USB_LPMIM_RES 0x00000010 // LPM Resume Interrupt Mask
-#define USB_LPMIM_NC 0x00000008 // LPM NC Interrupt Mask
-#define USB_LPMIM_ACK 0x00000004 // LPM ACK Interrupt Mask
-#define USB_LPMIM_NY 0x00000002 // LPM NY Interrupt Mask
-#define USB_LPMIM_STALL 0x00000001 // LPM STALL Interrupt Mask
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_LPMRIS register.
-//
-//*****************************************************************************
-#define USB_LPMRIS_ERR 0x00000020 // LPM Interrupt Status
-#define USB_LPMRIS_RES 0x00000010 // LPM Resume Interrupt Status
-#define USB_LPMRIS_NC 0x00000008 // LPM NC Interrupt Status
-#define USB_LPMRIS_ACK 0x00000004 // LPM ACK Interrupt Status
-#define USB_LPMRIS_NY 0x00000002 // LPM NY Interrupt Status
-#define USB_LPMRIS_LPMST 0x00000001 // LPM STALL Interrupt Status
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_LPMFADDR register.
-//
-//*****************************************************************************
-#define USB_LPMFADDR_ADDR_M 0x0000007F // LPM Function Address
-#define USB_LPMFADDR_ADDR_S 0
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_EPC register.
-//
-//*****************************************************************************
-#define USB_EPC_PFLTACT_M 0x00000300 // Power Fault Action
-#define USB_EPC_PFLTACT_UNCHG 0x00000000 // Unchanged
-#define USB_EPC_PFLTACT_TRIS 0x00000100 // Tristate
-#define USB_EPC_PFLTACT_LOW 0x00000200 // Low
-#define USB_EPC_PFLTACT_HIGH 0x00000300 // High
-#define USB_EPC_PFLTAEN 0x00000040 // Power Fault Action Enable
-#define USB_EPC_PFLTSEN_HIGH 0x00000020 // Power Fault Sense
-#define USB_EPC_PFLTEN 0x00000010 // Power Fault Input Enable
-#define USB_EPC_EPENDE 0x00000004 // EPEN Drive Enable
-#define USB_EPC_EPEN_M 0x00000003 // External Power Supply Enable
- // Configuration
-#define USB_EPC_EPEN_LOW 0x00000000 // Power Enable Active Low
-#define USB_EPC_EPEN_HIGH 0x00000001 // Power Enable Active High
-#define USB_EPC_EPEN_VBLOW 0x00000002 // Power Enable High if VBUS Low
- // (OTG only)
-#define USB_EPC_EPEN_VBHIGH 0x00000003 // Power Enable High if VBUS High
- // (OTG only)
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_EPCRIS register.
-//
-//*****************************************************************************
-#define USB_EPCRIS_PF 0x00000001 // USB Power Fault Interrupt Status
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_EPCIM register.
-//
-//*****************************************************************************
-#define USB_EPCIM_PF 0x00000001 // USB Power Fault Interrupt Mask
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_EPCISC register.
-//
-//*****************************************************************************
-#define USB_EPCISC_PF 0x00000001 // USB Power Fault Interrupt Status
- // and Clear
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_DRRIS register.
-//
-//*****************************************************************************
-#define USB_DRRIS_RESUME 0x00000001 // RESUME Interrupt Status
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_DRIM register.
-//
-//*****************************************************************************
-#define USB_DRIM_RESUME 0x00000001 // RESUME Interrupt Mask
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_DRISC register.
-//
-//*****************************************************************************
-#define USB_DRISC_RESUME 0x00000001 // RESUME Interrupt Status and
- // Clear
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_GPCS register.
-//
-//*****************************************************************************
-#define USB_GPCS_DEVMOD_M 0x00000007 // Device Mode
-#define USB_GPCS_DEVMOD_OTG 0x00000000 // Use USB0VBUS and USB0ID pin
-#define USB_GPCS_DEVMOD_HOST 0x00000002 // Force USB0VBUS and USB0ID low
-#define USB_GPCS_DEVMOD_DEV 0x00000003 // Force USB0VBUS and USB0ID high
-#define USB_GPCS_DEVMOD_HOSTVBUS \
- 0x00000004 // Use USB0VBUS and force USB0ID
- // low
-#define USB_GPCS_DEVMOD_DEVVBUS 0x00000005 // Use USB0VBUS and force USB0ID
- // high
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_VDC register.
-//
-//*****************************************************************************
-#define USB_VDC_VBDEN 0x00000001 // VBUS Droop Enable
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_VDCRIS register.
-//
-//*****************************************************************************
-#define USB_VDCRIS_VD 0x00000001 // VBUS Droop Raw Interrupt Status
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_VDCIM register.
-//
-//*****************************************************************************
-#define USB_VDCIM_VD 0x00000001 // VBUS Droop Interrupt Mask
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_VDCISC register.
-//
-//*****************************************************************************
-#define USB_VDCISC_VD 0x00000001 // VBUS Droop Interrupt Status and
- // Clear
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_PP register.
-//
-//*****************************************************************************
-#define USB_PP_ECNT_M 0x0000FF00 // Endpoint Count
-#define USB_PP_USB_M 0x000000C0 // USB Capability
-#define USB_PP_USB_DEVICE 0x00000040 // DEVICE
-#define USB_PP_USB_HOSTDEVICE 0x00000080 // HOST
-#define USB_PP_USB_OTG 0x000000C0 // OTG
-#define USB_PP_ULPI 0x00000020 // ULPI Present
-#define USB_PP_PHY 0x00000010 // PHY Present
-#define USB_PP_TYPE_M 0x0000000F // Controller Type
-#define USB_PP_TYPE_0 0x00000000 // The first-generation USB
- // controller
-#define USB_PP_TYPE_1 0x00000001 // The second-generation USB
- // controller revision
-#define USB_PP_ECNT_S 8
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_PC register.
-//
-//*****************************************************************************
-#define USB_PC_ULPIEN 0x00010000 // ULPI Enable
-
-//*****************************************************************************
-//
-// The following are defines for the bit fields in the USB_O_CC register.
-//
-//*****************************************************************************
-#define USB_CC_CLKEN 0x00000200 // USB Clock Enable
-#define USB_CC_CSD 0x00000100 // Clock Source/Direction
-#define USB_CC_CLKDIV_M 0x0000000F // PLL Clock Divisor
-#define USB_CC_CLKDIV_S 0
+#define MUSB_HSBT_HSBT_M 0x000F // High Speed Timeout Adder
+#define MUSB_HSBT_HSBT_S 0
#ifdef __cplusplus
}
diff --git a/src/tusb_option.h b/src/tusb_option.h
index f2cc284dc..fb0209023 100644
--- a/src/tusb_option.h
+++ b/src/tusb_option.h
@@ -188,6 +188,12 @@
#define OPT_MCU_MCXN9 2300 ///< NXP MCX N9 Series
#define OPT_MCU_MCXA15 2301 ///< NXP MCX A15 Series
+// Analog Devices
+#define OPT_MCU_MAX32690 2400 ///< ADI MAX32690
+#define OPT_MCU_MAX32666 2401 ///< ADI MAX32666/5
+#define OPT_MCU_MAX32650 2402 ///< ADI MAX32650/1/2
+#define OPT_MCU_MAX78002 2403 ///< ADI MAX78002
+
// Check if configured MCU is one of listed
// Apply _TU_CHECK_MCU with || as separator to list of input
#define _TU_CHECK_MCU(_m) (CFG_TUSB_MCU == _m)
diff --git a/test/hil/hil_test.py b/test/hil/hil_test.py
index 486f0d2eb..e5900c616 100644
--- a/test/hil/hil_test.py
+++ b/test/hil/hil_test.py
@@ -173,10 +173,20 @@ echo "Ready for Remote Connections"
with open(f_wch, 'w') as file:
file.write(cfg_content)
- ret = run_cmd(f'openocd_wch -c "adapter serial {board["flasher_sn"]}" -f {f_wch} -c "program {firmware}.elf reset exit"')
+ ret = run_cmd(f'openocd_wch -c "adapter serial {board["flasher_sn"]}" -f {f_wch} '
+ f'-c "program {firmware}.elf reset exit"')
return ret
+def flash_openocd_adi(board, firmware):
+ openocd_adi_script_path = f'{os.getenv("HOME")}/app/openocd_adi/tcl'
+ if not os.path.exists(openocd_adi_script_path):
+ openocd_adi_script_path = '/home/pi/openocd_adi/tcl'
+
+ ret = run_cmd(f'openocd_adi -c "adapter serial {board["flasher_sn"]}" -s {openocd_adi_script_path} '
+ f'{board["flasher_args"]} -c "program {firmware}.elf reset exit"')
+ return ret
+
def flash_wlink_rs(board, firmware):
# wlink use index for probe selection and lacking usb serial support
ret = run_cmd(f'wlink flash {firmware}.elf')
@@ -196,6 +206,11 @@ def flash_esptool(board, firmware):
return ret
+def flash_uniflash(board, firmware):
+ ret = run_cmd(f'dslite.sh {board["flasher_args"]} -f {firmware}.hex')
+ return ret
+
+
# -------------------------------------------------------------
# Tests
# -------------------------------------------------------------
diff --git a/test/hil/rpi.json b/test/hil/rpi.json
index 688ea3822..e90e435d8 100644
--- a/test/hil/rpi.json
+++ b/test/hil/rpi.json
@@ -14,6 +14,13 @@
"flasher_sn": "E6614C311B597D32",
"flasher_args": "-f interface/cmsis-dap.cfg -f target/atsame5x.cfg -c \"adapter speed 5000\""
},
+ {
+ "name": "max32666fthr",
+ "uid": "0C81464124010B20FF0A08CC2C",
+ "flasher": "openocd_adi",
+ "flasher_sn": "042217023bffc88100000000000000000000000097969906",
+ "flasher_args": "-f interface/cmsis-dap.cfg -f target/max32665.cfg"
+ },
{
"name": "lpcxpresso11u37",
"uid": "17121919",
@@ -50,13 +57,6 @@
"flasher": "openocd",
"flasher_sn": "066FFF495087534867063844",
"flasher_args": "-f interface/stlink.cfg -f target/stm32g0x.cfg"
- },
- {
- "name": "nanoch32v203",
- "uid": "CDAB277B0FBC03E339E339E3",
- "flasher": "openocd_wch",
- "flasher_sn": "EBCA8F0670AF",
- "flasher_args": ""
}
],
"boards-skip": [
@@ -68,6 +68,13 @@
"flasher_args": "-device MIMXRT1011xxx5A",
"comment": "not running reliably in bulk with other boards, probably power, flashing etc .."
},
+ {
+ "name": "nanoch32v203",
+ "uid": "CDAB277B0FBC03E339E339E3",
+ "flasher": "openocd_wch",
+ "flasher_sn": "EBCA8F0670AF",
+ "flasher_args": ""
+ },
{
"name": "espressif_s3_devkitm",
"uid": "84F703C084E4",
diff --git a/tools/get_deps.py b/tools/get_deps.py
index b639ed6d6..f141d3d41 100644
--- a/tools/get_deps.py
+++ b/tools/get_deps.py
@@ -24,6 +24,9 @@ deps_optional = {
'hw/mcu/allwinner': ['https://github.com/hathach/allwinner_driver.git',
'8e5e89e8e132c0fd90e72d5422e5d3d68232b756',
'fc100s'],
+ 'hw/mcu/analog/max32' : ['https://github.com/analogdevicesinc/msdk.git',
+ 'b20b398d3e5e2007594e54a74ba3d2a2e50ddd75',
+ 'max32650 max32666 max32690 max78002'],
'hw/mcu/bridgetek/ft9xx/ft90x-sdk': ['https://github.com/BRTSG-FOSS/ft90x-sdk.git',
'91060164afe239fcb394122e8bf9eb24d3194eb1',
'brtmm90x'],