From 745c653a7fceeab6c88578ad3910972582e761af Mon Sep 17 00:00:00 2001 From: Daniel Fekete Date: Fri, 12 May 2017 05:59:45 +0200 Subject: [PATCH] USB MSC: add example code for testing in documentation --- STM32/boards.txt | 14 +- docs/about/index.html | 10 +- docs/add_board/index.html | 10 +- docs/arduino_api/index.html | 10 +- docs/boards/index.html | 10 +- docs/i2c/index.html | 10 +- docs/i2s/index.html | 10 +- docs/index.html | 10 +- docs/libraries/index.html | 10 +- docs/menu_options/index.html | 10 +- docs/mkdocs/search_index.json | 25 +- docs/sdio/index.html | 10 +- docs/sitemap.xml | 38 +-- docs/spi/index.html | 10 +- docs/stm32_hal/index.html | 12 +- docs/test/index.html | 10 +- docs/uart/index.html | 12 +- docs/upload/index.html | 10 +- docs/usb_cdc/index.html | 18 +- docs/usb_msc/index.html | 330 ++++++++++++++++++++++++++ tools/documentation/mkdocs.yml | 5 +- tools/documentation/mkdocs/usb_cdc.md | 2 +- tools/documentation/mkdocs/usb_msc.md | 87 +++++++ 23 files changed, 604 insertions(+), 69 deletions(-) create mode 100644 docs/usb_msc/index.html create mode 100644 tools/documentation/mkdocs/usb_msc.md diff --git a/STM32/boards.txt b/STM32/boards.txt index 7bea44d..e25f232 100644 --- a/STM32/boards.txt +++ b/STM32/boards.txt @@ -66,7 +66,7 @@ MapleMini_F103CB.menu.upload_method.BMPMethod.upload.tool=bmp_upload MapleMini_F103CB.menu.usb.SerialUSB=Serial [Virtual COM port, 24(PA11)/23(PA12) pins] MapleMini_F103CB.menu.usb.SerialUSB.build.extra_flags_usb=-DMENU_USB_SERIAL -MapleMini_F103CB.menu.usb.SerialMSC=Mass storage +MapleMini_F103CB.menu.usb.SerialMSC=Mass storage [testing, see documentation] MapleMini_F103CB.menu.usb.SerialMSC.build.extra_flags_usb=-DMENU_USB_MASS_STORAGE MapleMini_F103CB.menu.usb.Disabled=Disabled, no USB @@ -125,7 +125,7 @@ BluePill.menu.upload_method.BMPMethod.upload.tool=bmp_upload BluePill.menu.usb.SerialUSB=Serial [Virtual COM port, PA11/PA12 pins] BluePill.menu.usb.SerialUSB.build.extra_flags_usb=-DMENU_USB_SERIAL -BluePill.menu.usb.SerialMSC=Mass storage +BluePill.menu.usb.SerialMSC=Mass storage [testing, see documentation] BluePill.menu.usb.SerialMSC.build.extra_flags_usb=-DMENU_USB_MASS_STORAGE BluePill.menu.usb.Disabled=Disabled, no USB @@ -164,7 +164,7 @@ BLACK_F407XX.menu.upload_method.serialMethod.build.extra_flags_serial_auto=-DMEN BLACK_F407XX.menu.usb.SerialUSB=Serial [Virtual COM port, PA11/PA12 pins] BLACK_F407XX.menu.usb.SerialUSB.build.extra_flags_usb=-DMENU_USB_SERIAL -BLACK_F407XX.menu.usb.SerialMSC=Mass storage +BLACK_F407XX.menu.usb.SerialMSC=Mass storage [testing, see documentation] BLACK_F407XX.menu.usb.SerialMSC.build.extra_flags_usb=-DMENU_USB_MASS_STORAGE BLACK_F407XX.menu.usb.Disabled=Disabled, no USB @@ -323,7 +323,7 @@ DISCOVERY_L053C8.menu.upload_method.STLinkMethod.upload.tool=stlink_upload DISCOVERY_L053C8.menu.usb.SerialUSB=Serial [Virtual COM port, PA11/PA12 pins] DISCOVERY_L053C8.menu.usb.SerialUSB.build.extra_flags_usb=-DMENU_USB_SERIAL -DISCOVERY_L053C8.menu.usb.SerialMSC=Mass storage +DISCOVERY_L053C8.menu.usb.SerialMSC=Mass storage [testing, see documentation] DISCOVERY_L053C8.menu.usb.SerialMSC.build.extra_flags_usb=-DMENU_USB_MASS_STORAGE DISCOVERY_L053C8.menu.usb.Disabled=Disabled, no USB @@ -355,7 +355,7 @@ DISCOVERY_F407VG.upload.tool=stlink_upload DISCOVERY_F407VG.menu.usb.SerialUSB=Serial [Virtual COM port] DISCOVERY_F407VG.menu.usb.SerialUSB.build.extra_flags_usb=-DMENU_USB_SERIAL -DISCOVERY_F407VG.menu.usb.SerialMSC=Mass storage +DISCOVERY_F407VG.menu.usb.SerialMSC=Mass storage [testing, see documentation] DISCOVERY_F407VG.menu.usb.SerialMSC.build.extra_flags_usb=-DMENU_USB_MASS_STORAGE DISCOVERY_F407VG.menu.usb.Disabled=Disabled, no USB @@ -389,7 +389,7 @@ DISCOVERY_F429ZI.upload.tool=stlink_upload DISCOVERY_F429ZI.menu.usb.SerialUSB=Serial [Virtual COM port] DISCOVERY_F429ZI.menu.usb.SerialUSB.build.extra_flags_usb=-DMENU_USB_SERIAL -DISCOVERY_F429ZI.menu.usb.SerialMSC=Mass storage +DISCOVERY_F429ZI.menu.usb.SerialMSC=Mass storage [testing, see documentation] DISCOVERY_F429ZI.menu.usb.SerialMSC.build.extra_flags_usb=-DMENU_USB_MASS_STORAGE DISCOVERY_F429ZI.menu.usb.Disabled=Disabled, no USB @@ -429,7 +429,7 @@ DISCOVERY_F746NG.menu.upload_method.STLinkMethod.upload.tool=stlink_upload DISCOVERY_F746NG.menu.usb.SerialUSB=Serial [Virtual COM port, PA11/PA12 pins] DISCOVERY_F746NG.menu.usb.SerialUSB.build.extra_flags_usb=-DMENU_USB_SERIAL -DISCOVERY_F746NG.menu.usb.SerialMSC=Mass storage +DISCOVERY_F746NG.menu.usb.SerialMSC=Mass storage [testing, see documentation] DISCOVERY_F746NG.menu.usb.SerialMSC.build.extra_flags_usb=-DMENU_USB_MASS_STORAGE DISCOVERY_F746NG.menu.usb.Disabled=Disabled, no USB diff --git a/docs/about/index.html b/docs/about/index.html index 7ea8bb8..88ccd55 100644 --- a/docs/about/index.html +++ b/docs/about/index.html @@ -102,13 +102,19 @@
  • - Serial UART + UART Serial
  • - Serial USB + USB Serial +
  • + + + +
  • + USB Mass Storage
  • diff --git a/docs/add_board/index.html b/docs/add_board/index.html index 655aabc..43950b2 100644 --- a/docs/add_board/index.html +++ b/docs/add_board/index.html @@ -102,13 +102,19 @@
  • - Serial UART + UART Serial
  • - Serial USB + USB Serial +
  • + + + +
  • + USB Mass Storage
  • diff --git a/docs/arduino_api/index.html b/docs/arduino_api/index.html index c6b2147..86dcc73 100644 --- a/docs/arduino_api/index.html +++ b/docs/arduino_api/index.html @@ -102,13 +102,19 @@
  • - Serial UART + UART Serial
  • - Serial USB + USB Serial +
  • + + + +
  • + USB Mass Storage
  • diff --git a/docs/boards/index.html b/docs/boards/index.html index 4ab684b..c5ecb4e 100644 --- a/docs/boards/index.html +++ b/docs/boards/index.html @@ -102,13 +102,19 @@
  • - Serial UART + UART Serial
  • - Serial USB + USB Serial +
  • + + + +
  • + USB Mass Storage
  • diff --git a/docs/i2c/index.html b/docs/i2c/index.html index 73134f6..e9faa50 100644 --- a/docs/i2c/index.html +++ b/docs/i2c/index.html @@ -102,13 +102,19 @@
  • - Serial UART + UART Serial
  • - Serial USB + USB Serial +
  • + + + +
  • + USB Mass Storage
  • diff --git a/docs/i2s/index.html b/docs/i2s/index.html index 647ff1d..2238569 100644 --- a/docs/i2s/index.html +++ b/docs/i2s/index.html @@ -102,13 +102,19 @@
  • - Serial UART + UART Serial
  • - Serial USB + USB Serial +
  • + + + +
  • + USB Mass Storage
  • diff --git a/docs/index.html b/docs/index.html index 65bf911..058026e 100644 --- a/docs/index.html +++ b/docs/index.html @@ -102,13 +102,19 @@
  • - Serial UART + UART Serial
  • - Serial USB + USB Serial +
  • + + + +
  • + USB Mass Storage
  • diff --git a/docs/libraries/index.html b/docs/libraries/index.html index e34ce21..9053f5e 100644 --- a/docs/libraries/index.html +++ b/docs/libraries/index.html @@ -102,13 +102,19 @@
  • - Serial UART + UART Serial
  • - Serial USB + USB Serial +
  • + + + +
  • + USB Mass Storage
  • diff --git a/docs/menu_options/index.html b/docs/menu_options/index.html index 6b5feb4..b279fe8 100644 --- a/docs/menu_options/index.html +++ b/docs/menu_options/index.html @@ -102,13 +102,19 @@
  • - Serial UART + UART Serial
  • - Serial USB + USB Serial +
  • + + + +
  • + USB Mass Storage
  • diff --git a/docs/mkdocs/search_index.json b/docs/mkdocs/search_index.json index 191c990..3960a9d 100644 --- a/docs/mkdocs/search_index.json +++ b/docs/mkdocs/search_index.json @@ -463,7 +463,7 @@ { "location": "/uart/", "text": "Serial UART\n\n\nThere are two implementations of Serial communication: UART and USB. \n\n\nThis page describes the UART based.\n\n\nPlease check the \nMenu option\n to see which one is selected.\n\n\nSerialUART1\nis bound to UART1, \nSerialUART2\n to UART2 etc...\n\n\nPlease refer to the \nofficial documentation\n for\nthe description of Serial functions.\n\n\nSerialUARTx.stm32SetRX(uint8_t pin)\n\n\nSet the RX signal to the specified pin. Please check the chip documentation for which pin can be used for RX.\nThis must be called before begin()!\n\n\nSerialUARTx.stm32SetTx(uint8_t pin)\n\n\nSet the TX signal to the specified pin. Please check the chip documentation for which pin can be used for TX.\nThis must be called before begin()!\n\n\n\n\nExample: The following code will echo the received bytes on UART2\n\n\n\n\nvoid setup() {\n SerialUART2.stm32SetRX(Pcd);\n SerialUART2.stm32SetTX(Pab);\n SerualUART2.begin(115200);\n}\nvoid loop() {\n int data = SerialUART2.read();\n if (data != -1) {\n SerialUART2.write(data);\n }\n}", - "title": "Serial UART" + "title": "UART Serial" }, { "location": "/uart/#serial-uart", @@ -482,13 +482,28 @@ }, { "location": "/usb_cdc/", - "text": "Serial UART\n\n\nThere are two implementations of Serial communication: UART and USB. \n\n\nThis page describes the USB based.\n\n\nPlease check the \nMenu option\n to see which one is selected as \nSerial\n.\n\n\nIf the \nUSB menu\n is set to include Serial, SerialUSB is set as a virtual COM port, and can be used just like a regular UART based.\n\n\nTODO explain windows 7 driver\n\n\nPlease refer to the \nofficial documentation\n for\nthe description of Serial functions.", - "title": "Serial USB" + "text": "USB: Serial\n\n\nThere are two implementations of Serial communication: UART and USB. \n\n\nThis page describes the USB based.\n\n\nPlease check the \nMenu option\n to see which one is selected as \nSerial\n.\n\n\nIf the \nUSB menu\n is set to include Serial, SerialUSB is set as a virtual COM port, and can be used just like a regular UART based.\n\n\nTODO explain windows 7 driver\n\n\nPlease refer to the \nofficial documentation\n for\nthe description of Serial functions.", + "title": "USB Serial" }, { - "location": "/usb_cdc/#serial-uart", + "location": "/usb_cdc/#usb-serial", "text": "There are two implementations of Serial communication: UART and USB. This page describes the USB based. Please check the Menu option to see which one is selected as Serial . If the USB menu is set to include Serial, SerialUSB is set as a virtual COM port, and can be used just like a regular UART based. TODO explain windows 7 driver Please refer to the official documentation for\nthe description of Serial functions.", - "title": "Serial UART" + "title": "USB: Serial" + }, + { + "location": "/usb_msc/", + "text": "USB: Mass Storage\n\n\nThis library is in beta, and the API / implementation is for testing only!\n\n\nUntil there is an official API, you can test mass storage with the following code:\n\n\n#include \nmsc/usbd_msc.h\n\n\nconst uint8_t MSC_Inquirydata[] = {\n /* LUN 0 */\n 0x00,\n 0x80,\n 0x02,\n 0x02,\n (STANDARD_INQUIRY_DATA_LEN - 5),\n 0x00,\n 0x00,\n 0x00,\n 'S', 'T', 'M', ' ', ' ', ' ', ' ', ' ', /* Manufacturer : 8 bytes */\n 'P', 'r', 'o', 'd', 'u', 'c', 't', ' ', /* Product : 16 Bytes */\n ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',\n '0', '.', '0' ,'1', /* Version : 4 Bytes */\n};\n\nconst uint16_t blockSize = 512;\nconst uint32_t blockCount = 100;\n\nuint8_t ramdisk[blockSize * blockCount] = {0};\n\nnamespace Testing {\n\n// See UM1734, 6.2.4\n// See usbd_msc.h\nUSBD_StorageTypeDef USBD_DISK_fops = {\n //Init\n [](uint8_t lun) -\n int8_t {\n return USBD_OK;\n },\n\n //GetCapacity\n [](uint8_t lun, uint32_t *block_num, uint16_t *block_size) -\n int8_t {\n *block_num = blockCount;\n *block_size = blockSize;\n return USBD_OK;\n },\n\n //IsReady\n [](uint8_t lun) -\n int8_t {\n return USBD_OK;\n },\n\n //IsWriteProtected\n [](uint8_t lun) -\n int8_t {\n return USBD_OK;\n },\n\n //Read\n [](uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len) -\n int8_t {\n memcpy(buf, ramdisk + blk_addr * blockSize, blk_len * blockSize);\n return USBD_OK;\n },\n\n //Write\n [](uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len) -\n int8_t {\n digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));\n memcpy(ramdisk + blk_addr * blockSize, buf, blk_len * blockSize);\n return USBD_OK;\n },\n\n //GetMaxLun\n []() -\n int8_t {return 0;},\n\n (int8_t *)MSC_Inquirydata\n\n};\n\n}\n\nvoid setup() {\n pinMode(LED_BUILTIN, OUTPUT);\n}\n\nvoid loop() {\n\n}", + "title": "USB Mass Storage" + }, + { + "location": "/usb_msc/#usb-mass-storage", + "text": "", + "title": "USB: Mass Storage" + }, + { + "location": "/usb_msc/#this-library-is-in-beta-and-the-api-implementation-is-for-testing-only", + "text": "Until there is an official API, you can test mass storage with the following code: #include msc/usbd_msc.h \n\nconst uint8_t MSC_Inquirydata[] = {\n /* LUN 0 */\n 0x00,\n 0x80,\n 0x02,\n 0x02,\n (STANDARD_INQUIRY_DATA_LEN - 5),\n 0x00,\n 0x00,\n 0x00,\n 'S', 'T', 'M', ' ', ' ', ' ', ' ', ' ', /* Manufacturer : 8 bytes */\n 'P', 'r', 'o', 'd', 'u', 'c', 't', ' ', /* Product : 16 Bytes */\n ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',\n '0', '.', '0' ,'1', /* Version : 4 Bytes */\n};\n\nconst uint16_t blockSize = 512;\nconst uint32_t blockCount = 100;\n\nuint8_t ramdisk[blockSize * blockCount] = {0};\n\nnamespace Testing {\n\n// See UM1734, 6.2.4\n// See usbd_msc.h\nUSBD_StorageTypeDef USBD_DISK_fops = {\n //Init\n [](uint8_t lun) - int8_t {\n return USBD_OK;\n },\n\n //GetCapacity\n [](uint8_t lun, uint32_t *block_num, uint16_t *block_size) - int8_t {\n *block_num = blockCount;\n *block_size = blockSize;\n return USBD_OK;\n },\n\n //IsReady\n [](uint8_t lun) - int8_t {\n return USBD_OK;\n },\n\n //IsWriteProtected\n [](uint8_t lun) - int8_t {\n return USBD_OK;\n },\n\n //Read\n [](uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len) - int8_t {\n memcpy(buf, ramdisk + blk_addr * blockSize, blk_len * blockSize);\n return USBD_OK;\n },\n\n //Write\n [](uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len) - int8_t {\n digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));\n memcpy(ramdisk + blk_addr * blockSize, buf, blk_len * blockSize);\n return USBD_OK;\n },\n\n //GetMaxLun\n []() - int8_t {return 0;},\n\n (int8_t *)MSC_Inquirydata\n\n};\n\n}\n\nvoid setup() {\n pinMode(LED_BUILTIN, OUTPUT);\n}\n\nvoid loop() {\n\n}", + "title": "This library is in beta, and the API / implementation is for testing only!" }, { "location": "/stm32_hal/", diff --git a/docs/sdio/index.html b/docs/sdio/index.html index 96467c7..6087d8a 100644 --- a/docs/sdio/index.html +++ b/docs/sdio/index.html @@ -102,13 +102,19 @@
  • - Serial UART + UART Serial
  • - Serial USB + USB Serial +
  • + + + +
  • + USB Mass Storage
  • diff --git a/docs/sitemap.xml b/docs/sitemap.xml index c651770..a7b6806 100644 --- a/docs/sitemap.xml +++ b/docs/sitemap.xml @@ -4,7 +4,7 @@ / - 2017-05-06 + 2017-05-12 daily @@ -12,7 +12,7 @@ /upload/ - 2017-05-06 + 2017-05-12 daily @@ -21,55 +21,61 @@ /menu_options/ - 2017-05-06 + 2017-05-12 daily /arduino_api/ - 2017-05-06 + 2017-05-12 daily /spi/ - 2017-05-06 + 2017-05-12 daily /i2c/ - 2017-05-06 + 2017-05-12 daily /i2s/ - 2017-05-06 + 2017-05-12 daily /sdio/ - 2017-05-06 + 2017-05-12 daily /uart/ - 2017-05-06 + 2017-05-12 daily /usb_cdc/ - 2017-05-06 + 2017-05-12 + daily + + + + /usb_msc/ + 2017-05-12 daily /stm32_hal/ - 2017-05-06 + 2017-05-12 daily @@ -78,7 +84,7 @@ /libraries/ - 2017-05-06 + 2017-05-12 daily @@ -87,19 +93,19 @@ /boards/ - 2017-05-06 + 2017-05-12 daily /add_board/ - 2017-05-06 + 2017-05-12 daily /test/ - 2017-05-06 + 2017-05-12 daily @@ -108,7 +114,7 @@ /about/ - 2017-05-06 + 2017-05-12 daily diff --git a/docs/spi/index.html b/docs/spi/index.html index 470b494..d6628a4 100644 --- a/docs/spi/index.html +++ b/docs/spi/index.html @@ -102,13 +102,19 @@
  • - Serial UART + UART Serial
  • - Serial USB + USB Serial +
  • + + + +
  • + USB Mass Storage
  • diff --git a/docs/stm32_hal/index.html b/docs/stm32_hal/index.html index e1d6b80..6bb54e5 100644 --- a/docs/stm32_hal/index.html +++ b/docs/stm32_hal/index.html @@ -102,13 +102,19 @@
  • - Serial UART + UART Serial
  • - Serial USB + USB Serial +
  • + + + +
  • + USB Mass Storage
  • @@ -171,7 +177,7 @@
  • -
  • diff --git a/docs/test/index.html b/docs/test/index.html index 087d7b4..51c912f 100644 --- a/docs/test/index.html +++ b/docs/test/index.html @@ -102,13 +102,19 @@
  • - Serial UART + UART Serial
  • - Serial USB + USB Serial +
  • + + + +
  • + USB Mass Storage
  • diff --git a/docs/uart/index.html b/docs/uart/index.html index 95a1fd6..7a922b6 100644 --- a/docs/uart/index.html +++ b/docs/uart/index.html @@ -8,7 +8,7 @@ - Serial UART - STM32GENERIC + UART Serial - STM32GENERIC @@ -102,13 +102,19 @@
  • - Serial UART + UART Serial
  • - Serial USB + USB Serial +
  • + + + +
  • + USB Mass Storage
  • diff --git a/docs/upload/index.html b/docs/upload/index.html index d121fd3..2ae0932 100644 --- a/docs/upload/index.html +++ b/docs/upload/index.html @@ -102,13 +102,19 @@
  • - Serial UART + UART Serial
  • - Serial USB + USB Serial +
  • + + + +
  • + USB Mass Storage
  • diff --git a/docs/usb_cdc/index.html b/docs/usb_cdc/index.html index b6eafd8..2d0c7e1 100644 --- a/docs/usb_cdc/index.html +++ b/docs/usb_cdc/index.html @@ -8,7 +8,7 @@ - Serial USB - STM32GENERIC + USB Serial - STM32GENERIC @@ -102,13 +102,19 @@
  • - Serial UART + UART Serial
  • - Serial USB + USB Serial +
  • + + + +
  • + USB Mass Storage
  • @@ -176,7 +182,7 @@
  • -
  • @@ -191,7 +197,7 @@