This program plays QuickTime movies on GR-Peach
Dependencies: AsciiFont GR-PEACH_video GraphicsFramework LCD_shield_config R_BSP TLV320_RBSP mbed-rtos mbed
Requirements
- GR-Peach
- GR-Peach Audio Camera Shield or I²S compatible audio DAC
- GR-Peach LCD Shield
- USB memory stick
How to play movie files
- Encode movie files
encode movies with ffmpeg
$ ffmpeg -i <input -ar 44100 -acodec pcm_s16le -s 480x270 -vcodec mjpeg -q:v 3 -movflags faststart -threads 4 -vf fps=30 <output>.mov
- Copy movies to the root directory of USB memory
- Build and upload this program
- Run it
USBHost/USBHostMSD/USBHostMSD.h@1:3e638b9e91cd, 2017-03-12 (annotated)
- Committer:
- mtkrtk
- Date:
- Sun Mar 12 02:01:46 2017 +0000
- Revision:
- 1:3e638b9e91cd
- Parent:
- 0:d0f130e27d32
fixed lcd contrast pin
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mtkrtk | 0:d0f130e27d32 | 1 | /* mbed USBHost Library |
mtkrtk | 0:d0f130e27d32 | 2 | * Copyright (c) 2006-2013 ARM Limited |
mtkrtk | 0:d0f130e27d32 | 3 | * |
mtkrtk | 0:d0f130e27d32 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
mtkrtk | 0:d0f130e27d32 | 5 | * you may not use this file except in compliance with the License. |
mtkrtk | 0:d0f130e27d32 | 6 | * You may obtain a copy of the License at |
mtkrtk | 0:d0f130e27d32 | 7 | * |
mtkrtk | 0:d0f130e27d32 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
mtkrtk | 0:d0f130e27d32 | 9 | * |
mtkrtk | 0:d0f130e27d32 | 10 | * Unless required by applicable law or agreed to in writing, software |
mtkrtk | 0:d0f130e27d32 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
mtkrtk | 0:d0f130e27d32 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
mtkrtk | 0:d0f130e27d32 | 13 | * See the License for the specific language governing permissions and |
mtkrtk | 0:d0f130e27d32 | 14 | * limitations under the License. |
mtkrtk | 0:d0f130e27d32 | 15 | */ |
mtkrtk | 0:d0f130e27d32 | 16 | |
mtkrtk | 0:d0f130e27d32 | 17 | #ifndef USBHOSTMSD_H |
mtkrtk | 0:d0f130e27d32 | 18 | #define USBHOSTMSD_H |
mtkrtk | 0:d0f130e27d32 | 19 | |
mtkrtk | 0:d0f130e27d32 | 20 | #include "USBHostConf.h" |
mtkrtk | 0:d0f130e27d32 | 21 | |
mtkrtk | 0:d0f130e27d32 | 22 | #if USBHOST_MSD |
mtkrtk | 0:d0f130e27d32 | 23 | |
mtkrtk | 0:d0f130e27d32 | 24 | #include "USBHost.h" |
mtkrtk | 0:d0f130e27d32 | 25 | #include "FATFileSystem.h" |
mtkrtk | 0:d0f130e27d32 | 26 | |
mtkrtk | 0:d0f130e27d32 | 27 | /** |
mtkrtk | 0:d0f130e27d32 | 28 | * A class to communicate a USB flash disk |
mtkrtk | 0:d0f130e27d32 | 29 | */ |
mtkrtk | 0:d0f130e27d32 | 30 | class USBHostMSD : public IUSBEnumerator, public FATFileSystem { |
mtkrtk | 0:d0f130e27d32 | 31 | public: |
mtkrtk | 0:d0f130e27d32 | 32 | /** |
mtkrtk | 0:d0f130e27d32 | 33 | * Constructor |
mtkrtk | 0:d0f130e27d32 | 34 | * |
mtkrtk | 0:d0f130e27d32 | 35 | * @param rootdir mount name |
mtkrtk | 0:d0f130e27d32 | 36 | */ |
mtkrtk | 0:d0f130e27d32 | 37 | USBHostMSD(const char * rootdir); |
mtkrtk | 0:d0f130e27d32 | 38 | |
mtkrtk | 0:d0f130e27d32 | 39 | /** |
mtkrtk | 0:d0f130e27d32 | 40 | * Check if a MSD device is connected |
mtkrtk | 0:d0f130e27d32 | 41 | * |
mtkrtk | 0:d0f130e27d32 | 42 | * @return true if a MSD device is connected |
mtkrtk | 0:d0f130e27d32 | 43 | */ |
mtkrtk | 0:d0f130e27d32 | 44 | bool connected(); |
mtkrtk | 0:d0f130e27d32 | 45 | |
mtkrtk | 0:d0f130e27d32 | 46 | /** |
mtkrtk | 0:d0f130e27d32 | 47 | * Try to connect to a MSD device |
mtkrtk | 0:d0f130e27d32 | 48 | * |
mtkrtk | 0:d0f130e27d32 | 49 | * @return true if connection was successful |
mtkrtk | 0:d0f130e27d32 | 50 | */ |
mtkrtk | 0:d0f130e27d32 | 51 | bool connect(); |
mtkrtk | 0:d0f130e27d32 | 52 | |
mtkrtk | 0:d0f130e27d32 | 53 | protected: |
mtkrtk | 0:d0f130e27d32 | 54 | //From IUSBEnumerator |
mtkrtk | 0:d0f130e27d32 | 55 | virtual void setVidPid(uint16_t vid, uint16_t pid); |
mtkrtk | 0:d0f130e27d32 | 56 | virtual bool parseInterface(uint8_t intf_nb, uint8_t intf_class, uint8_t intf_subclass, uint8_t intf_protocol); //Must return true if the interface should be parsed |
mtkrtk | 0:d0f130e27d32 | 57 | virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used |
mtkrtk | 0:d0f130e27d32 | 58 | |
mtkrtk | 0:d0f130e27d32 | 59 | // From FATFileSystem |
mtkrtk | 0:d0f130e27d32 | 60 | virtual int disk_initialize(); |
mtkrtk | 0:d0f130e27d32 | 61 | virtual int disk_status() {return 0;}; |
mtkrtk | 0:d0f130e27d32 | 62 | virtual int disk_read(uint8_t* buffer, uint32_t sector, uint32_t count); |
mtkrtk | 0:d0f130e27d32 | 63 | virtual int disk_write(const uint8_t* buffer, uint32_t sector, uint32_t count); |
mtkrtk | 0:d0f130e27d32 | 64 | virtual int disk_sync() {return 0;}; |
mtkrtk | 0:d0f130e27d32 | 65 | virtual uint32_t disk_sectors(); |
mtkrtk | 0:d0f130e27d32 | 66 | |
mtkrtk | 0:d0f130e27d32 | 67 | private: |
mtkrtk | 0:d0f130e27d32 | 68 | USBHost * host; |
mtkrtk | 0:d0f130e27d32 | 69 | USBDeviceConnected * dev; |
mtkrtk | 0:d0f130e27d32 | 70 | bool dev_connected; |
mtkrtk | 0:d0f130e27d32 | 71 | USBEndpoint * bulk_in; |
mtkrtk | 0:d0f130e27d32 | 72 | USBEndpoint * bulk_out; |
mtkrtk | 0:d0f130e27d32 | 73 | uint8_t nb_ep; |
mtkrtk | 0:d0f130e27d32 | 74 | |
mtkrtk | 0:d0f130e27d32 | 75 | // Bulk-only CBW |
mtkrtk | 0:d0f130e27d32 | 76 | typedef struct { |
mtkrtk | 0:d0f130e27d32 | 77 | uint32_t Signature; |
mtkrtk | 0:d0f130e27d32 | 78 | uint32_t Tag; |
mtkrtk | 0:d0f130e27d32 | 79 | uint32_t DataLength; |
mtkrtk | 0:d0f130e27d32 | 80 | uint8_t Flags; |
mtkrtk | 0:d0f130e27d32 | 81 | uint8_t LUN; |
mtkrtk | 0:d0f130e27d32 | 82 | uint8_t CBLength; |
mtkrtk | 0:d0f130e27d32 | 83 | uint8_t CB[16]; |
mtkrtk | 0:d0f130e27d32 | 84 | } PACKED CBW; |
mtkrtk | 0:d0f130e27d32 | 85 | |
mtkrtk | 0:d0f130e27d32 | 86 | // Bulk-only CSW |
mtkrtk | 0:d0f130e27d32 | 87 | typedef struct { |
mtkrtk | 0:d0f130e27d32 | 88 | uint32_t Signature; |
mtkrtk | 0:d0f130e27d32 | 89 | uint32_t Tag; |
mtkrtk | 0:d0f130e27d32 | 90 | uint32_t DataResidue; |
mtkrtk | 0:d0f130e27d32 | 91 | uint8_t Status; |
mtkrtk | 0:d0f130e27d32 | 92 | } PACKED CSW; |
mtkrtk | 0:d0f130e27d32 | 93 | |
mtkrtk | 0:d0f130e27d32 | 94 | CBW cbw; |
mtkrtk | 0:d0f130e27d32 | 95 | CSW csw; |
mtkrtk | 0:d0f130e27d32 | 96 | |
mtkrtk | 0:d0f130e27d32 | 97 | int SCSITransfer(uint8_t * cmd, uint8_t cmd_len, int flags, uint8_t * data, uint32_t transfer_len); |
mtkrtk | 0:d0f130e27d32 | 98 | int testUnitReady(); |
mtkrtk | 0:d0f130e27d32 | 99 | int readCapacity(); |
mtkrtk | 0:d0f130e27d32 | 100 | int inquiry(uint8_t lun, uint8_t page_code); |
mtkrtk | 0:d0f130e27d32 | 101 | int SCSIRequestSense(); |
mtkrtk | 0:d0f130e27d32 | 102 | int dataTransfer(uint8_t * buf, uint32_t block, uint8_t nbBlock, int direction); |
mtkrtk | 0:d0f130e27d32 | 103 | int checkResult(uint8_t res, USBEndpoint * ep); |
mtkrtk | 0:d0f130e27d32 | 104 | int getMaxLun(); |
mtkrtk | 0:d0f130e27d32 | 105 | |
mtkrtk | 0:d0f130e27d32 | 106 | int blockSize; |
mtkrtk | 0:d0f130e27d32 | 107 | uint32_t blockCount; |
mtkrtk | 0:d0f130e27d32 | 108 | |
mtkrtk | 0:d0f130e27d32 | 109 | int msd_intf; |
mtkrtk | 0:d0f130e27d32 | 110 | bool msd_device_found; |
mtkrtk | 0:d0f130e27d32 | 111 | bool disk_init; |
mtkrtk | 0:d0f130e27d32 | 112 | |
mtkrtk | 0:d0f130e27d32 | 113 | void init(); |
mtkrtk | 0:d0f130e27d32 | 114 | |
mtkrtk | 0:d0f130e27d32 | 115 | }; |
mtkrtk | 0:d0f130e27d32 | 116 | |
mtkrtk | 0:d0f130e27d32 | 117 | #endif |
mtkrtk | 0:d0f130e27d32 | 118 | |
mtkrtk | 0:d0f130e27d32 | 119 | #endif |
mtkrtk | 0:d0f130e27d32 | 120 |