{"id":16173244,"url":"https://github.com/joeferner/maple-usbmassstorage","last_synced_at":"2025-03-19T00:30:48.452Z","repository":{"id":6359583,"uuid":"7596629","full_name":"joeferner/maple-usbMassStorage","owner":"joeferner","description":"Maple ARM USB Mass Storage Library","archived":false,"fork":false,"pushed_at":"2018-01-30T19:51:38.000Z","size":26,"stargazers_count":7,"open_issues_count":1,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-17T01:11:54.824Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/joeferner.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-01-14T01:32:05.000Z","updated_at":"2022-05-10T15:21:20.000Z","dependencies_parsed_at":"2022-09-02T21:50:57.855Z","dependency_job_id":null,"html_url":"https://github.com/joeferner/maple-usbMassStorage","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joeferner%2Fmaple-usbMassStorage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joeferner%2Fmaple-usbMassStorage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joeferner%2Fmaple-usbMassStorage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joeferner%2Fmaple-usbMassStorage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joeferner","download_url":"https://codeload.github.com/joeferner/maple-usbMassStorage/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244331647,"owners_count":20435970,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-10T04:07:35.320Z","updated_at":"2025-03-19T00:30:48.110Z","avatar_url":"https://github.com/joeferner.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WARNING: I am no longer maintaining this software. The code is here for historical reasons and hopefully it will help someone.\n\n# maple-usbMassStorage\n\nDriver to allow [LeafLabs maple](http://leaflabs.com/devices/maple/) act as a USB mass storage device.\n\n# API\n\n* [USBMassStorage.begin()](#USBMassStorage_begin)\n* [USBMassStorage.loop()](#USBMassStorage_loop)\n* [MAL_massBlockCount[2] : uint32_t](#massBlockCount)\n* [MAL_massBlockSize[2] : uint32_t](#massBlockSize)\n* [usb_mass_mal_init(uint8_t lun) : uint16_t](#usb_mass_mal_init)\n* [usb_mass_mal_get_status(uint8_t lun) : uint16_t](#usb_mass_mal_get_status)\n* [usb_mass_mal_write_memory(uint8_t lun, uint32_t memoryOffset, uint8_t *writebuff, uint16_t transferLength) : uint16_t](#usb_mass_mal_write_memory)\n* [usb_mass_mal_read_memory(uint8_t lun, uint32_t memoryOffset, uint8_t *readbuff, uint16_t transferLength) : uint16_t](#usb_mass_mal_read_memory)\n* [usb_mass_mal_format() : void](#usb_mass_mal_format)\n\n# API Details\n\n\u003ca name=\"USBMassStorage_begin\" /\u003e\n**USBMassStorage.begin()**\n\nStarts the USB mass storage driver. After calling this method the computer should now detect the Maple as a USB mass\nstorage device.\n\n\u003ca name=\"USBMassStorage_loop\" /\u003e\n**USBMassStorage.loop()**\n\nAllows the USB mass storage driver to process incoming requests. Call this method in your main loop.\n\nEven though the STM32 USB causes interrupts which could be used to process this data. Typically interrupts should be\nkept short. The other side effect is that certain libraries do not work inside the interrupt handlers (such as sdfat).\nUsing the loop function solves these problems by moving most of the logic into non-interrupt code.\n\n__Example__\n\n```\nvoid loop() {\n  USBMassStorage.loop();\n}\n```\n\n\u003ca name=\"massBlockCount\" /\u003e\n**MAL_massBlockCount[2] : uint32_t**\n\nThe block count of the two SCSI LUNs. This should be initialized before [USBMassStorage.begin()](#USBMassStorage_begin).\n\n__Example__\n\n```\nuint32_t MAL_massBlockCount[2];\nuint32_t MAL_massBlockSize[2];\n\nvoid setup() {\n  MAL_massBlockCount[0] = 100;\n  MAL_massBlockCount[1] = 0;\n  MAL_massBlockSize[0] = 512;\n  MAL_massBlockSize[1] = 0;\n\n  USBMassStorage.begin();\n}\n```\n\n\u003ca name=\"massBlockSize\" /\u003e\n**MAL_massBlockSize[2] : uint32_t**\n\nThe block size of the two SCSI LUNs. This should be initialized before [USBMassStorage.begin()](#USBMassStorage_begin).\nFor SDCards you should initialize it to 512.\n\n\u003ca name=\"usb_mass_mal_init\" /\u003e\n**usb_mass_mal_init(uint8_t lun) : uint16_t**\n\nCalled by the USB mass storage driver after the host has requested the device.\n\n__Arguments__\n\n * lun - the LUN number being initialized. This can be 0 or 1. Typically just 0.\n\n__Return__\n\n0 for success. 1 for failure.\n\n\u003ca name=\"usb_mass_mal_get_status\" /\u003e\n**usb_mass_mal_get_status(uint8_t lun) : uint16_t**\n\nGets the status of the given LUN.\n\n__Arguments__\n\n * lun - the lun number to get status for. This can be 0 or 1. Typically just 0.\n\n__Return__\n\n0 for success. 1 for failure.\n\n\u003ca name=\"usb_mass_mal_write_memory\" /\u003e\n**usb_mass_mal_write_memory(uint8_t lun, uint32_t memoryOffset, uint8_t *writebuff, uint16_t transferLength) : uint16_t**\n\nCalled when data should be written to storage.\n\n__Arguments__\n\n * lun - the lun number to write to. This can be 0 or 1. Typically just 0.\n * memoryOffset - Address in bytes to write to.\n * writebuff - A buffer containing the data to write. This buffer should not be relied on after this function returns as\n               it may be reused.\n * transferLength - The number of bytes to write.\n\n__Return__\n\nUSB_MASS_MAL_SUCCESS for success. USB_MASS_MAL_FAIL for failure.\n\n__Example__\n\n```\nextern \"C\" uint16_t usb_mass_mal_write_memory(uint8_t lun, uint32_t memoryOffset, uint8_t *writebuff, uint16_t transferLength) {\n  uint32_t block = memoryOffset / 512;\n  if (lun != 0) {\n    return USB_MASS_MAL_FAIL;\n  }\n  if (sdcard.writeBlock(block, writebuff)) {\n    return USB_MASS_MAL_SUCCESS;\n  }\n  return USB_MASS_MAL_FAIL;\n}\n```\n\n\u003ca name=\"usb_mass_mal_read_memory\" /\u003e\n**usb_mass_mal_read_memory(uint8_t lun, uint32_t memoryOffset, uint8_t *readbuff, uint16_t transferLength) : uint16_t**\n\nCalled when data should be read from storage.\n\n__Arguments__\n\n * lun - the lun number to write to. This can be 0 or 1. Typically just 0.\n * memoryOffset - Address in bytes to read from.\n * readbuff - A buffer in which the data should be read into.\n * transferLength - The number of bytes to read.\n\n__Return__\n\nUSB_MASS_MAL_SUCCESS for success. USB_MASS_MAL_FAIL for failure.\n\n__Example__\n\n```\nextern \"C\" uint16_t usb_mass_mal_read_memory(uint8_t lun, uint32_t memoryOffset, uint8_t *readbuff, uint16_t transferLength) {\n  if (lun != 0) {\n    return USB_MASS_MAL_FAIL;\n  }\n  if (sdcard.readBlock(memoryOffset / 512, readbuff)) {\n    return USB_MASS_MAL_SUCCESS;\n  }\n  return USB_MASS_MAL_FAIL;\n}\n```\n\n\u003ca name=\"usb_mass_mal_format\" /\u003e\n**usb_mass_mal_format() : void**\n\nCalled to format the device.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoeferner%2Fmaple-usbmassstorage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoeferner%2Fmaple-usbmassstorage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoeferner%2Fmaple-usbmassstorage/lists"}