diff --git a/epicardium/cdcacm.c b/epicardium/cdcacm.c index cead3780e96b47308e96887f1a18fd8990fc8082..5a023fedee93fc0013ad83e0f762725426504b65 100644 --- a/epicardium/cdcacm.c +++ b/epicardium/cdcacm.c @@ -44,8 +44,11 @@ * */ +#include "cdcacm.h" + #include <stdio.h> #include <stddef.h> + #include "mxc_config.h" #include "mxc_sys.h" #include "mxc_delay.h" @@ -55,9 +58,12 @@ #include "usb_event.h" #include "enumerate.h" #include "cdc_acm.h" +#include "msc.h" + #include "descriptors.h" #include "modules/log.h" +#include "modules/filesystem.h" #include <errno.h> /***** Definitions *****/ @@ -83,7 +89,7 @@ static int event_callback(maxusb_event_t evt, void *data); static void usb_app_sleep(void); static void usb_app_wakeup(void); static int usb_read_callback(void); -//static void echo_usb(void); +static void deconfigure(void); /***** File Scope Variables *****/ @@ -98,16 +104,28 @@ static const acm_cfg_t acm_cfg = { }; static volatile int usb_read_complete; +static volatile bool initialized = false; +static const msc_cfg_t* s_msc_cfg = NULL; + int usb_startup_cb() { const sys_cfg_usbhs_t sys_usbhs_cfg = NULL; + LOG_INFO("usb", "SYS_USBHS_Init"); return SYS_USBHS_Init(&sys_usbhs_cfg); } int usb_shutdown_cb() { - return SYS_USBHS_Shutdown(); + LOG_INFO("usb", "SYS_USBHS_Shutdown"); + SYS_USBHS_Shutdown(); + SYS_Reset_Periph(SYS_RESET_USB); + if (s_msc_cfg) { + LOG_INFO("usb", "re-attaching FLASH"); + fatfs_attach(); + s_msc_cfg = NULL; + } + return 0; } /* User-supplied function to delay usec micro-seconds */ @@ -117,10 +135,21 @@ void delay_us(unsigned int usec) mxc_delay(usec); } - /******************************************************************************/ -int cdcacm_init(void) +int epc_usb_init(uint16_t interfaces) { + if (initialized) { + //NVIC_DisableIRQ(USB_IRQn); //yes? no? + + usb_disconnect(); + deconfigure(); + //usb_app_sleep(); + usb_shutdown(); + initialized = false; + } + if (interfaces == 0) { + return 0; + } maxusb_cfg_options_t usb_opts; /* Initialize state */ @@ -143,16 +172,28 @@ int cdcacm_init(void) /* Initialize the enumeration module */ if (enum_init() != 0) { + usb_shutdown(); LOG_ERR("cdcacm", "enum_init() failed"); return -EIO; } /* Register enumeration data */ - enum_register_descriptor(ENUM_DESC_DEVICE, (uint8_t*)&device_descriptor, 0); + if (interfaces & USB_IFACE_STORAGE) { + config_descriptor.config_descriptor.wTotalLength = sizeof(config_descriptor); + config_descriptor.config_descriptor.bNumInterfaces = 3; + } else { + config_descriptor.config_descriptor.wTotalLength = offsetof(struct config_descriptor_s, msc_interface_descriptor); + config_descriptor.config_descriptor.bNumInterfaces = 2; + } + enum_register_descriptor(ENUM_DESC_DEVICE, (uint8_t*)&composite_device_descriptor, 0); enum_register_descriptor(ENUM_DESC_CONFIG, (uint8_t*)&config_descriptor, 0); enum_register_descriptor(ENUM_DESC_STRING, lang_id_desc, 0); enum_register_descriptor(ENUM_DESC_STRING, mfg_id_desc, 1); enum_register_descriptor(ENUM_DESC_STRING, prod_id_desc, 2); + //used in composite but not in cdc (see iSerialNumber) + enum_register_descriptor(ENUM_DESC_STRING, serial_id_desc, 3); + enum_register_descriptor(ENUM_DESC_STRING, cdcacm_func_desc, 4); + enum_register_descriptor(ENUM_DESC_STRING, msc_func_desc, 5); /* Handle configuration */ enum_register_callback(ENUM_SETCONFIG, setconfig_callback, NULL); @@ -163,10 +204,53 @@ int cdcacm_init(void) /* Initialize the class driver */ if (acm_init(&config_descriptor.comm_interface_descriptor) != 0) { + enum_clearconfig(); + usb_shutdown(); LOG_ERR("cdcacm", "acm_init() failed"); return -EIO; } + if (interfaces & USB_IFACE_STORAGE) { + /* Initialize the class driver */ + static const msc_idstrings_t ids = { + "CCC", /* Vendor string. Maximum of 8 bytes */ + "card10", /* Product string. Maximum of 16 bytes */ + "1.0" /* Version string. Maximum of 4 bytes */ + }; + + /* This EP assignment must match the Configuration Descriptor */ + static const msc_cfg_t msc_cfg = { + 4, /* EP OUT */ + MXC_USBHS_MAX_PACKET, /* OUT max packet size */ + 5, /* EP IN */ + MXC_USBHS_MAX_PACKET, /* IN max packet size */ + }; + s_msc_cfg = &msc_cfg; + LOG_INFO("usb", "detaching FLASH"); + fatfs_detach(); + + + /* Functions to control "disk" memory. See msc.h for definitions. */ + int mscmem_init(void); + int mscmem_start(void); + int mscmem_stop(void); + uint32_t mscmem_size(void); + int mscmem_read(uint32_t lba, uint8_t* buffer); + int mscmem_write(uint32_t lba, uint8_t* buffer); + int mscmem_ready(void); + + static const msc_mem_t mem = { + mscmem_init, mscmem_start, mscmem_stop, mscmem_ready, + mscmem_size, mscmem_read, mscmem_write, + }; + if (msc_init(&config_descriptor.msc_interface_descriptor, &ids, &mem) != 0) { + LOG_ERR("msc", "msc_init() failed\n"); + return -EIO; + } + } else { + s_msc_cfg = NULL; + } + /* Register callbacks */ usb_event_enable(MAXUSB_EVENT_NOVBUS, event_callback, NULL); usb_event_enable(MAXUSB_EVENT_VBUS, event_callback, NULL); @@ -179,6 +263,8 @@ int cdcacm_init(void) NVIC_SetPriority(USB_IRQn, 6); NVIC_EnableIRQ(USB_IRQn); + initialized = true; + return 0; } @@ -240,14 +326,27 @@ static void echo_usb(void) } } #endif + +#include "mx25lba.h" + + /******************************************************************************/ static int setconfig_callback(usb_setup_pkt *sud, void *cbdata) { + LOG_INFO("usb", "setconfig %d \n", (int)sud->wValue); /* Confirm the configuration value */ if (sud->wValue == config_descriptor.config_descriptor.bConfigurationValue) { configured = 1; MXC_SETBIT(&event_flags, EVENT_ENUM_COMP); - return acm_configure(&acm_cfg); /* Configure the device class */ + int acm_rc = acm_configure(&acm_cfg); + if (acm_rc) { + LOG_ERR("usb", "acm_configure failed: %d\n", acm_rc); + } + int msc_rc = s_msc_cfg ? msc_configure(s_msc_cfg) : 0; + if (msc_rc) { + LOG_ERR("usb", "msc_configure failed: %d\n", msc_rc); + } + return acm_rc || msc_rc; } else if (sud->wValue == 0) { configured = 0; return acm_deconfigure(); @@ -296,21 +395,29 @@ static void usb_app_wakeup(void) suspended = 0; } +static void deconfigure(void) { + enum_clearconfig(); + acm_deconfigure(); + if (s_msc_cfg) { + msc_deconfigure(); + } + configured = 0; +} /******************************************************************************/ static int event_callback(maxusb_event_t evt, void *data) { /* Set event flag */ MXC_SETBIT(&event_flags, evt); + LOG_INFO("usb", "event %d\n", evt); + switch (evt) { case MAXUSB_EVENT_NOVBUS: usb_event_disable(MAXUSB_EVENT_BRST); usb_event_disable(MAXUSB_EVENT_SUSP); usb_event_disable(MAXUSB_EVENT_DPACT); usb_disconnect(); - configured = 0; - enum_clearconfig(); - acm_deconfigure(); + deconfigure(); usb_app_sleep(); break; case MAXUSB_EVENT_VBUS: @@ -323,9 +430,7 @@ static int event_callback(maxusb_event_t evt, void *data) break; case MAXUSB_EVENT_BRST: usb_app_wakeup(); - enum_clearconfig(); - acm_deconfigure(); - configured = 0; + deconfigure(); suspended = 0; break; case MAXUSB_EVENT_SUSP: @@ -372,3 +477,59 @@ void SysTick_Handler(void) mxc_delay_handler(); } #endif /* 0 */ + +static int dirty = 0; +/******************************************************************************/ +int mscmem_init() +{ + return mx25_init(); +} +/******************************************************************************/ +uint32_t mscmem_size(void) +{ + return mx25_size(); +} + +/******************************************************************************/ +int mscmem_read(uint32_t lba, uint8_t *buffer) +{ + return mx25_read(lba, buffer); +} + +/******************************************************************************/ +int mscmem_write(uint32_t lba, uint8_t *buffer) +{ + if (dirty == 0) { + //bootloader_dirty(); + } + dirty = 2; + return mx25_write(lba, buffer); +} + +/******************************************************************************/ +int mscmem_start() +{ + return mx25_start(); +} + +/******************************************************************************/ +int mscmem_stop() +{ + int ret = mx25_stop(); + //bootloader_stop(); + return ret; +} + +/******************************************************************************/ +int mscmem_ready() +{ + if (dirty) { + dirty--; + if (dirty == 0) { + printf("sync\n"); + mx25_sync(); + //bootloader_clean(); + } + } + return mx25_ready(); +} diff --git a/epicardium/cdcacm.h b/epicardium/cdcacm.h index 1c25d75027cebffd593f32364ebab7eec65fa7e6..2f07db7c125da1cf14e95bf60ca251865552ccd9 100644 --- a/epicardium/cdcacm.h +++ b/epicardium/cdcacm.h @@ -1,8 +1,16 @@ #ifndef CDCACM_H #define CDCACM_H #include <stdint.h> +#include <stdbool.h> -int cdcacm_init(void); +#define USB_IFACE_CDCACM 0x0001 +#define USB_IFACE_STORAGE 0x0002 +#define USB_IFACE_ALL 0xffff +#define USB_IFACE_NONE 0x0000 + +int epc_usb_init(uint16_t interfaces); + +void cdcacm_deinit(void); int cdcacm_num_read_avail(void); uint8_t cdcacm_read(void); void cdcacm_write(uint8_t *data, int len); diff --git a/epicardium/descriptors.h b/epicardium/descriptors.h index c081c4010e65c7c86980ad94a096a81febb69f61..44ef924c8921dedb6003bda928a7b99c6b5776b3 100644 --- a/epicardium/descriptors.h +++ b/epicardium/descriptors.h @@ -40,8 +40,27 @@ #include <stdint.h> #include "usb.h" -#include "hid_kbd.h" +#define EPICARDIUM_USBSTORAGE + +#ifdef EPICARDIUM_USBSTORAGE +usb_device_descriptor_t __attribute__((aligned(4))) composite_device_descriptor = { + .bLength = 0x12, + .bDescriptorType = 0x01, /* Device */ + .bcdUSB = 0x0110, /* USB spec rev (BCD) */ + .bDeviceClass = 0x00, /* code specified by interface descriptors */ + .bDeviceSubClass = 0x00, /* code specified by interface descriptors */ + .bDeviceProtocol = 0x00, /* code specified by interface descriptors */ + .bMaxPacketSize = 0x40, /* 64 bytes */ + .idVendor = 0x0B6A, /* (Maxim Integrated) */ + .idProduct = 0x003D, + .bcdDevice = 0x0100, + .iManufacturer = 0x01, + .iProduct = 0x02, + .iSerialNumber = 0x03, + .bNumConfigurations = 0x01 +}; +#else usb_device_descriptor_t __attribute__((aligned(4))) device_descriptor = { 0x12, /* bLength = 18 */ 0x01, /* bDescriptorType = Device */ @@ -59,27 +78,43 @@ usb_device_descriptor_t __attribute__((aligned(4))) device_descriptor = { 0x01 /* bNumConfigurations */ }; +#endif//EPICARDIUM_USBSTORAGE + __attribute__((aligned(4))) -struct __attribute__((packed)) { +struct config_descriptor_s { usb_configuration_descriptor_t config_descriptor; + /* Interface #1 Comm Interface */ usb_interface_descriptor_t comm_interface_descriptor; uint8_t header_functional_descriptor[5]; uint8_t call_management_descriptor[5]; uint8_t acm_functional_descriptor[4]; uint8_t union_functional_descriptor[5]; usb_endpoint_descriptor_t endpoint_descriptor_3; + /* Interface #2 Data Interface */ usb_interface_descriptor_t data_interface_descriptor; usb_endpoint_descriptor_t endpoint_descriptor_1; usb_endpoint_descriptor_t endpoint_descriptor_2; -} config_descriptor = + /* Interface #3 Mass Storage Device */ + usb_interface_descriptor_t msc_interface_descriptor; + usb_endpoint_descriptor_t endpoint_descriptor_4; + usb_endpoint_descriptor_t endpoint_descriptor_5; +} __attribute__((packed)) config_descriptor = { { 0x09, /* bLength = 9 */ 0x02, /* bDescriptorType = Config (2) */ - 0x0043, /* wTotalLength(L/H) */ + sizeof(config_descriptor), +#ifdef EPICARDIUM_USBSTORAGE + 0x03, +#else 0x02, /* bNumInterfaces */ +#endif// EPICARDIUM_USBSTORAGE 0x01, /* bConfigValue */ +#ifdef EPICARDIUM_USBSTORAGE + 0x02, /* iConfiguration */ +#else 0x00, /* iConfiguration */ +#endif// EPICARDIUM_USBSTORAGE 0xE0, /* bmAttributes (self-powered, remote wakeup) */ 0x01, /* MaxPower is 2ma (units are 2ma/bit) */ }, @@ -128,7 +163,7 @@ struct __attribute__((packed)) { 0x0040, /* wMaxPacketSize */ 0xff, /* bInterval (milliseconds) */ }, - { /* Second Interface Descriptor For Data Interface */ + { /* Interface #2 Descriptor For Data Interface */ 0x09, /* bLength */ 0x04, /* bDescriptorType (Interface) */ 0x01, /* bInterfaceNumber */ @@ -137,7 +172,7 @@ struct __attribute__((packed)) { 0x0a, /* bInterfaceClass = Data Interface (10) */ 0x00, /* bInterfaceSubClass = none (0) */ 0x00, /* bInterfaceProtocol = No class specific protocol (0) */ - 0x00, /* biInterface = No Text String (0) */ + 0x00, /* biInterface = No Text String (0) (SWYM: biInterface? string? wat?)*/ }, { /* OUT Endpoint 1 (Descriptor #2) */ 0x07, /* bLength */ @@ -154,7 +189,35 @@ struct __attribute__((packed)) { 0x02, /* bmAttributes (bulk) */ 0x0040, /* wMaxPacketSize */ 0x00 /* bInterval (N/A) */ - } + }, + /********** Interface #3 : Mass Storage Device **********/ + { /* Second Interface Descriptor For MSC Interface */ + 0x09, /* bLength = 9 */ + 0x04, /* bDescriptorType = Interface (4) */ + 0x02, /* bInterfaceNumber */ + 0x00, /* bAlternateSetting */ + 0x02, /* bNumEndpoints (one for IN one for OUT) */ + 0x08, /* bInterfaceClass = Mass Storage (8) */ + 0x06, /* bInterfaceSubClass = SCSI Transparent Command Set */ + 0x50, /* bInterfaceProtocol = Bulk-Only Transport */ + 0x05, /* iInterface */ + }, + { /* OUT Endpoint 1 (Descriptor #4) */ + 0x07, /* bLength */ + 0x05, /* bDescriptorType (Endpoint) */ + 0x04, /* bEndpointAddress (EP4-OUT) */ + 0x02, /* bmAttributes (bulk) */ + 0x0040, /* wMaxPacketSize */ + 0x00, /* bInterval (N/A) */ + }, + { /* IN Endpoint 2 (Descriptor #5) */ + 0x07, /* bLength */ + 0x05, /* bDescriptorType (Endpoint) */ + 0x85, /* bEndpointAddress (EP5-IN) */ + 0x02, /* bmAttributes (bulk) */ + 0x0040, /* wMaxPacketSize */ + 0x00 /* bInterval (N/A) */ + }, }; __attribute__((aligned(4))) @@ -165,7 +228,7 @@ uint8_t lang_id_desc[] = { }; __attribute__((aligned(4))) -uint8_t mfg_id_desc[] = { +uint8_t mfg_id_desc[0x22] = { 0x22, /* bLength */ 0x03, /* bDescriptorType */ 'M', 0, @@ -187,7 +250,25 @@ uint8_t mfg_id_desc[] = { }; __attribute__((aligned(4))) -uint8_t prod_id_desc[] = { +uint8_t prod_id_desc[0x1a] = { + 0x1a, /* bLength */ + 0x03, /* bDescriptorType */ + 'c', 0, + 'a', 0, + 'r', 0, + 'd', 0, + '1', 0, + '0', 0, + ' ', 0, + 'b', 0, + 'a', 0, + 'd', 0, + 'g', 0, + 'e', 0, +}; + +__attribute__((aligned(4))) +uint8_t cdcacm_func_desc[0x22] = { 0x22, /* bLength */ 0x03, /* bDescriptorType */ 'M', 0, @@ -210,7 +291,7 @@ uint8_t prod_id_desc[] = { /* Not currently used (see device descriptor), but could be enabled if desired */ __attribute__((aligned(4))) -uint8_t serial_id_desc[] = { +uint8_t serial_id_desc[0x14] = { 0x14, /* bLength */ 0x03, /* bDescriptorType */ '0', 0, @@ -224,4 +305,39 @@ uint8_t serial_id_desc[] = { '1', 0 }; +__attribute__((aligned(4))) +uint8_t msc_func_desc[0x3A] = { + 0x3A, /* bLength */ + 0x03, /* bDescriptorType */ + 'M', 0, + 'A', 0, + 'X', 0, + '3', 0, + '2', 0, + '6', 0, + '6', 0, + '5', 0, + ' ', 0, + 'M', 0, + 'a', 0, + 's', 0, + 's', 0, + ' ', 0, + 'S', 0, + 't', 0, + 'o', 0, + 'r', 0, + 'a', 0, + 'g', 0, + 'e', 0, + ' ', 0, + 'D', 0, + 'e', 0, + 'v', 0, + 'i', 0, + 'c', 0, + 'e', 0, +}; + + #endif /* _DESCRIPTORS_H_ */ diff --git a/epicardium/epicardium.h b/epicardium/epicardium.h index 639ab268176189e2a555dcd07ab9b1f6b2d38532..7eb3c10cbc48070970e1cc4ad949749a70e99300 100644 --- a/epicardium/epicardium.h +++ b/epicardium/epicardium.h @@ -67,6 +67,11 @@ typedef unsigned int size_t; #define API_LIGHT_SENSOR_RUN 0x80 #define API_LIGHT_SENSOR_GET 0x81 #define API_LIGHT_SENSOR_STOP 0x82 + +#define API_USB_SHUTDOWN 0x90 +#define API_USB_STORAGE 0x91 +#define API_USB_CDCACM 0x92 + /* clang-format on */ typedef uint32_t api_int_id_t; @@ -697,4 +702,9 @@ API(API_RTC_SCHEDULE_ALARM, int epic_rtc_schedule_alarm(uint32_t timestamp)); */ API_ISR(EPIC_INT_RTC_ALARM, epic_isr_rtc_alarm); + +API(API_USB_SHUTDOWN, void epic_usb_shutdown(void)); +API(API_USB_STORAGE, void epic_usb_storage(void)); +API(API_USB_CDCACM, void epic_usb_cdcacm(void)); + #endif /* _EPICARDIUM_H */ diff --git a/epicardium/main.c b/epicardium/main.c index 50e9438cb3a11c87d58ded7d2fc5eaee650ad961..2994eaa7bc8b02bde9cb9961bbac66dd9be8d9e3 100644 --- a/epicardium/main.c +++ b/epicardium/main.c @@ -54,7 +54,7 @@ int main(void) /* TODO: Move this to its own function */ SCB->SCR |= SCB_SCR_SEVONPEND_Msk; - if (cdcacm_init() < 0) { + if (epc_usb_init(USB_IFACE_CDCACM) < 0) { LOG_ERR("startup", "USB-Serial unavailable"); } diff --git a/epicardium/modules/filesystem_fat.c b/epicardium/modules/filesystem_fat.c index 7c2d23504d782558b78c89057c918293efae14c5..fae1063a618c305f69464dc3756ce4f7b27a9c27 100644 --- a/epicardium/modules/filesystem_fat.c +++ b/epicardium/modules/filesystem_fat.c @@ -51,7 +51,7 @@ struct FatObject { struct EpicFileSystem { struct FatObject pool[EPIC_FAT_MAX_OPENED]; uint32_t generationCount; - bool initialized; + bool attached; FATFS FatFs; }; @@ -123,11 +123,11 @@ int fatfs_attach() int rc = 0; if (globalLockAccquire()) { EpicFileSystem *fs = &s_globalFileSystem; - if (!fs->initialized) { + if (!fs->attached) { ff_res = f_mount(&fs->FatFs, "/", 0); if (ff_res == FR_OK) { - fs->initialized = true; - SSLOG_INFO("FatFs mounted\n"); + fs->attached = true; + SSLOG_INFO("attached\n"); } else { SSLOG_ERR( "f_mount error %s\n", @@ -161,9 +161,9 @@ void fatfs_detach() ); } - fs->initialized = false; + fs->attached = false; disk_deinitialize(); - SSLOG_INFO("de-initialized\n"); + SSLOG_INFO("detached\n"); epic_fs_unlock_global(fs); } } @@ -193,7 +193,7 @@ bool epic_fs_lock_global(EpicFileSystem **fs, int *rc) *rc = -EBUSY; return false; } - if (!s_globalFileSystem.initialized) { + if (!s_globalFileSystem.attached) { globalLockRelease(); *rc = -ENODEV; return false; diff --git a/epicardium/modules/meson.build b/epicardium/modules/meson.build index 29aa39536f25454ab867a18c4867185aa08a9384..9bdf3bd0a48977239da3d886d89fc6172b304e44 100644 --- a/epicardium/modules/meson.build +++ b/epicardium/modules/meson.build @@ -9,5 +9,6 @@ module_sources = files( 'stream.c', 'vibra.c', 'light_sensor.c', - 'rtc.c' + 'rtc.c', + 'usb.c' ) diff --git a/epicardium/modules/usb.c b/epicardium/modules/usb.c new file mode 100644 index 0000000000000000000000000000000000000000..c7996adcd82cb6a5456859191068bef2d0e3ec9f --- /dev/null +++ b/epicardium/modules/usb.c @@ -0,0 +1,14 @@ +#include "epicardium.h" +#include "cdcacm.h" + +void epic_usb_shutdown(void) { + epc_usb_init(USB_IFACE_NONE); +} + +void epic_usb_storage(void) { + epc_usb_init(USB_IFACE_CDCACM | USB_IFACE_STORAGE); +} + +void epic_usb_cdcacm(void) { + epc_usb_init(USB_IFACE_CDCACM); +} diff --git a/lib/sdk/Applications/EvKitExamples/USB_CompositeDevice/descriptors.h b/lib/sdk/Applications/EvKitExamples/USB_CompositeDevice/descriptors.h index 7e3e2189efa253c54238632ea3a5c1d70b235461..0cbbede9b615dc7fcb80ba3446f7d6b211efb738 100644 --- a/lib/sdk/Applications/EvKitExamples/USB_CompositeDevice/descriptors.h +++ b/lib/sdk/Applications/EvKitExamples/USB_CompositeDevice/descriptors.h @@ -40,7 +40,7 @@ #include <stdint.h> #include "usb.h" -#include "hid_kbd.h" +//#include "hid_kbd.h" usb_device_descriptor_t __attribute__((aligned(4))) composite_device_descriptor = { 0x12, /* bLength */ @@ -143,6 +143,8 @@ composite_config_descriptor = { }, }; +_Static_assert(sizeof(config_descriptor) == 57, ""); + __attribute__((aligned(4))) uint8_t report_descriptor[] = { 0x05, 0x01, /* Usage Page (generic desktop) */ diff --git a/lib/sdk/Applications/EvKitExamples/USB_CompositeDevice/main.c b/lib/sdk/Applications/EvKitExamples/USB_CompositeDevice/main.c index b3bdab9d3da282d4a5c373fa437be270eb10805d..59a452870bde43579b90c1d5c1ccbdbd1d1a7c8c 100644 --- a/lib/sdk/Applications/EvKitExamples/USB_CompositeDevice/main.c +++ b/lib/sdk/Applications/EvKitExamples/USB_CompositeDevice/main.c @@ -39,14 +39,18 @@ #include "mxc_config.h" #include "mxc_sys.h" #include "mxc_delay.h" -#include "board.h" -#include "led.h" -#include "pb.h" +//#include "board.h" +//#include "led.h" +//#include "pb.h" +typedef uint8_t u_int8_t; +typedef uint16_t u_int16_t; +typedef uint32_t u_int32_t; +#define PATH_MAX 128 #include "usb.h" -#include "usb_event.h" -#include "enumerate.h" -#include "hid_kbd.h" -#include "msc.h" +//#include "usb_event.h" +//#include "enumerate.h" +//#include "hid_kbd.h" +//#include "msc.h" #include "descriptors.h" #include "mscmem.h" diff --git a/pycardium/meson.build b/pycardium/meson.build index 1cbe83559afde41f5313760f1f08613d3a842c62..808713844b0ac4318fa1d7f47981457e9ca8b1d2 100644 --- a/pycardium/meson.build +++ b/pycardium/meson.build @@ -9,6 +9,7 @@ modsrc = files( 'modules/light_sensor.c', 'modules/fat_file.c', 'modules/fat_reader_import.c', + 'modules/usb.c', ) ################################# diff --git a/pycardium/modules/fat_file.c b/pycardium/modules/fat_file.c index baf3fcb6494e955148100280547ab190b5e7ba98..3820f038f79c3edbae37b7cee28cfe9f28aa04ae 100644 --- a/pycardium/modules/fat_file.c +++ b/pycardium/modules/fat_file.c @@ -4,11 +4,11 @@ #include <stdio.h> +#include "py/mpconfig.h" #include "py/runtime.h" #include "py/builtin.h" #include "py/stream.h" #include "py/mperrno.h" -#include "py/obj.h" #include "epicardium.h" diff --git a/pycardium/modules/qstrdefs.h b/pycardium/modules/qstrdefs.h index 34c95142a2b02a7a2a527129825b47312e0306c7..ea5e4d8f3faa340194a9a1c6367a7471cc5a90f7 100644 --- a/pycardium/modules/qstrdefs.h +++ b/pycardium/modules/qstrdefs.h @@ -73,7 +73,8 @@ Q(tell) Q(TextIOWrapper) Q(write) -/* card10 */ -Q(card10) -Q(usbstorage) -Q(reset) +/* usb */ +Q(usb) +Q(shutdown) +Q(storage) +Q(cdcacm)