max32630fthr quad spi , unexpected spi behavior

Committer:
boonshen
Date:
Tue Mar 13 21:12:00 2018 +0000
Revision:
0:a35c40f49345
MAX32630FTHR QuadSPI test

Who changed what in which revision?

UserRevisionLine numberNew contents of line
boonshen 0:a35c40f49345 1 /* Copyright (c) 2010-2011 mbed.org, MIT License
boonshen 0:a35c40f49345 2 *
boonshen 0:a35c40f49345 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
boonshen 0:a35c40f49345 4 * and associated documentation files (the "Software"), to deal in the Software without
boonshen 0:a35c40f49345 5 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
boonshen 0:a35c40f49345 6 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
boonshen 0:a35c40f49345 7 * Software is furnished to do so, subject to the following conditions:
boonshen 0:a35c40f49345 8 *
boonshen 0:a35c40f49345 9 * The above copyright notice and this permission notice shall be included in all copies or
boonshen 0:a35c40f49345 10 * substantial portions of the Software.
boonshen 0:a35c40f49345 11 *
boonshen 0:a35c40f49345 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
boonshen 0:a35c40f49345 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
boonshen 0:a35c40f49345 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
boonshen 0:a35c40f49345 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
boonshen 0:a35c40f49345 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
boonshen 0:a35c40f49345 17 */
boonshen 0:a35c40f49345 18
boonshen 0:a35c40f49345 19 #ifndef USB_HID_H
boonshen 0:a35c40f49345 20 #define USB_HID_H
boonshen 0:a35c40f49345 21
boonshen 0:a35c40f49345 22 /* These headers are included for child class. */
boonshen 0:a35c40f49345 23 #include "USBEndpoints.h"
boonshen 0:a35c40f49345 24 #include "USBDescriptor.h"
boonshen 0:a35c40f49345 25 #include "USBDevice_Types.h"
boonshen 0:a35c40f49345 26
boonshen 0:a35c40f49345 27 #include "USBHID_Types.h"
boonshen 0:a35c40f49345 28 #include "USBDevice.h"
boonshen 0:a35c40f49345 29
boonshen 0:a35c40f49345 30
boonshen 0:a35c40f49345 31 /**
boonshen 0:a35c40f49345 32 * USBHID example
boonshen 0:a35c40f49345 33 * @code
boonshen 0:a35c40f49345 34 * #include "mbed.h"
boonshen 0:a35c40f49345 35 * #include "USBHID.h"
boonshen 0:a35c40f49345 36 *
boonshen 0:a35c40f49345 37 * USBHID hid;
boonshen 0:a35c40f49345 38 * HID_REPORT recv;
boonshen 0:a35c40f49345 39 * BusOut leds(LED1,LED2,LED3,LED4);
boonshen 0:a35c40f49345 40 *
boonshen 0:a35c40f49345 41 * int main(void) {
boonshen 0:a35c40f49345 42 * while (1) {
boonshen 0:a35c40f49345 43 * hid.read(&recv);
boonshen 0:a35c40f49345 44 * leds = recv.data[0];
boonshen 0:a35c40f49345 45 * }
boonshen 0:a35c40f49345 46 * }
boonshen 0:a35c40f49345 47 * @endcode
boonshen 0:a35c40f49345 48 */
boonshen 0:a35c40f49345 49
boonshen 0:a35c40f49345 50 class USBHID: public USBDevice {
boonshen 0:a35c40f49345 51 public:
boonshen 0:a35c40f49345 52
boonshen 0:a35c40f49345 53 /**
boonshen 0:a35c40f49345 54 * Constructor
boonshen 0:a35c40f49345 55 *
boonshen 0:a35c40f49345 56 * @param output_report_length Maximum length of a sent report (up to 64 bytes) (default: 64 bytes)
boonshen 0:a35c40f49345 57 * @param input_report_length Maximum length of a received report (up to 64 bytes) (default: 64 bytes)
boonshen 0:a35c40f49345 58 * @param vendor_id Your vendor_id
boonshen 0:a35c40f49345 59 * @param product_id Your product_id
boonshen 0:a35c40f49345 60 * @param product_release Your preoduct_release
boonshen 0:a35c40f49345 61 * @param connect Connect the device
boonshen 0:a35c40f49345 62 */
boonshen 0:a35c40f49345 63 USBHID(uint8_t output_report_length = 64, uint8_t input_report_length = 64, uint16_t vendor_id = 0x1234, uint16_t product_id = 0x0006, uint16_t product_release = 0x0001, bool connect = true);
boonshen 0:a35c40f49345 64
boonshen 0:a35c40f49345 65
boonshen 0:a35c40f49345 66 /**
boonshen 0:a35c40f49345 67 * Send a Report. warning: blocking
boonshen 0:a35c40f49345 68 *
boonshen 0:a35c40f49345 69 * @param report Report which will be sent (a report is defined by all data and the length)
boonshen 0:a35c40f49345 70 * @returns true if successful
boonshen 0:a35c40f49345 71 */
boonshen 0:a35c40f49345 72 bool send(HID_REPORT *report);
boonshen 0:a35c40f49345 73
boonshen 0:a35c40f49345 74
boonshen 0:a35c40f49345 75 /**
boonshen 0:a35c40f49345 76 * Send a Report. warning: non blocking
boonshen 0:a35c40f49345 77 *
boonshen 0:a35c40f49345 78 * @param report Report which will be sent (a report is defined by all data and the length)
boonshen 0:a35c40f49345 79 * @returns true if successful
boonshen 0:a35c40f49345 80 */
boonshen 0:a35c40f49345 81 bool sendNB(HID_REPORT *report);
boonshen 0:a35c40f49345 82
boonshen 0:a35c40f49345 83 /**
boonshen 0:a35c40f49345 84 * Read a report: blocking
boonshen 0:a35c40f49345 85 *
boonshen 0:a35c40f49345 86 * @param report pointer to the report to fill
boonshen 0:a35c40f49345 87 * @returns true if successful
boonshen 0:a35c40f49345 88 */
boonshen 0:a35c40f49345 89 bool read(HID_REPORT * report);
boonshen 0:a35c40f49345 90
boonshen 0:a35c40f49345 91 /**
boonshen 0:a35c40f49345 92 * Read a report: non blocking
boonshen 0:a35c40f49345 93 *
boonshen 0:a35c40f49345 94 * @param report pointer to the report to fill
boonshen 0:a35c40f49345 95 * @returns true if successful
boonshen 0:a35c40f49345 96 */
boonshen 0:a35c40f49345 97 bool readNB(HID_REPORT * report);
boonshen 0:a35c40f49345 98
boonshen 0:a35c40f49345 99 protected:
boonshen 0:a35c40f49345 100 uint16_t reportLength;
boonshen 0:a35c40f49345 101
boonshen 0:a35c40f49345 102 /*
boonshen 0:a35c40f49345 103 * Get the Report descriptor
boonshen 0:a35c40f49345 104 *
boonshen 0:a35c40f49345 105 * @returns pointer to the report descriptor
boonshen 0:a35c40f49345 106 */
boonshen 0:a35c40f49345 107 virtual uint8_t * reportDesc();
boonshen 0:a35c40f49345 108
boonshen 0:a35c40f49345 109 /*
boonshen 0:a35c40f49345 110 * Get the length of the report descriptor
boonshen 0:a35c40f49345 111 *
boonshen 0:a35c40f49345 112 * @returns the length of the report descriptor
boonshen 0:a35c40f49345 113 */
boonshen 0:a35c40f49345 114 virtual uint16_t reportDescLength();
boonshen 0:a35c40f49345 115
boonshen 0:a35c40f49345 116 /*
boonshen 0:a35c40f49345 117 * Get string product descriptor
boonshen 0:a35c40f49345 118 *
boonshen 0:a35c40f49345 119 * @returns pointer to the string product descriptor
boonshen 0:a35c40f49345 120 */
boonshen 0:a35c40f49345 121 virtual uint8_t * stringIproductDesc();
boonshen 0:a35c40f49345 122
boonshen 0:a35c40f49345 123 /*
boonshen 0:a35c40f49345 124 * Get string interface descriptor
boonshen 0:a35c40f49345 125 *
boonshen 0:a35c40f49345 126 * @returns pointer to the string interface descriptor
boonshen 0:a35c40f49345 127 */
boonshen 0:a35c40f49345 128 virtual uint8_t * stringIinterfaceDesc();
boonshen 0:a35c40f49345 129
boonshen 0:a35c40f49345 130 /*
boonshen 0:a35c40f49345 131 * Get configuration descriptor
boonshen 0:a35c40f49345 132 *
boonshen 0:a35c40f49345 133 * @returns pointer to the configuration descriptor
boonshen 0:a35c40f49345 134 */
boonshen 0:a35c40f49345 135 virtual uint8_t * configurationDesc();
boonshen 0:a35c40f49345 136
boonshen 0:a35c40f49345 137
boonshen 0:a35c40f49345 138 /*
boonshen 0:a35c40f49345 139 * HID Report received by SET_REPORT request. Warning: Called in ISR context
boonshen 0:a35c40f49345 140 * First byte of data will be the report ID
boonshen 0:a35c40f49345 141 *
boonshen 0:a35c40f49345 142 * @param report Data and length received
boonshen 0:a35c40f49345 143 */
boonshen 0:a35c40f49345 144 virtual void HID_callbackSetReport(HID_REPORT *report){};
boonshen 0:a35c40f49345 145
boonshen 0:a35c40f49345 146
boonshen 0:a35c40f49345 147 /*
boonshen 0:a35c40f49345 148 * Called by USBDevice on Endpoint0 request. Warning: Called in ISR context
boonshen 0:a35c40f49345 149 * This is used to handle extensions to standard requests
boonshen 0:a35c40f49345 150 * and class specific requests
boonshen 0:a35c40f49345 151 *
boonshen 0:a35c40f49345 152 * @returns true if class handles this request
boonshen 0:a35c40f49345 153 */
boonshen 0:a35c40f49345 154 virtual bool USBCallback_request();
boonshen 0:a35c40f49345 155
boonshen 0:a35c40f49345 156
boonshen 0:a35c40f49345 157 /*
boonshen 0:a35c40f49345 158 * Called by USBDevice layer. Set configuration of the device.
boonshen 0:a35c40f49345 159 * For instance, you can add all endpoints that you need on this function.
boonshen 0:a35c40f49345 160 *
boonshen 0:a35c40f49345 161 * @param configuration Number of the configuration
boonshen 0:a35c40f49345 162 * @returns true if class handles this request
boonshen 0:a35c40f49345 163 */
boonshen 0:a35c40f49345 164 virtual bool USBCallback_setConfiguration(uint8_t configuration);
boonshen 0:a35c40f49345 165
boonshen 0:a35c40f49345 166 private:
boonshen 0:a35c40f49345 167 HID_REPORT outputReport;
boonshen 0:a35c40f49345 168 uint8_t output_length;
boonshen 0:a35c40f49345 169 uint8_t input_length;
boonshen 0:a35c40f49345 170 };
boonshen 0:a35c40f49345 171
boonshen 0:a35c40f49345 172 #endif