Merge branch 'master' of github.com:felis/USB_Host_Shield_2.0 into xxxajk

This commit is contained in:
Andrew J. Kroll 2014-08-04 06:14:41 -04:00
commit 30651a21bc
18 changed files with 686 additions and 189 deletions

View file

@ -464,6 +464,7 @@ void BTD::HCI_event_task() {
disc_bdaddr[j] = hcibuf[j + 3 + 6 * i];
hci_set_flag(HCI_FLAG_DEVICE_FOUND);
break;
}
#ifdef EXTRADEBUG
else {

View file

@ -58,7 +58,6 @@ protected:
/** @name BTHID implementation */
/**
* Used to parse Bluetooth HID data.
* @param bthid Pointer to the BTHID class.
* @param len The length of the incoming data.
* @param buf Pointer to the data buffer.
*/

View file

@ -112,6 +112,18 @@ protected:
};
/**@}*/
/** @name USBDeviceConfig implementation */
/**
* Used by the USB core to check what this driver support.
* @param vid The device's VID.
* @param pid The device's PID.
* @return Returns true if the device's VID and PID matches this driver.
*/
virtual boolean VIDPIDOK(uint16_t vid, uint16_t pid) {
return (vid == PS4_VID && pid == PS4_PID);
};
/**@}*/
private:
void (*pFuncOnInit)(void); // Pointer to function called in onInit()
};

82
PSBuzz.cpp Normal file
View file

@ -0,0 +1,82 @@
/* Copyright (C) 2014 Kristian Lauszus, TKJ Electronics. All rights reserved.
This software may be distributed and modified under the terms of the GNU
General Public License version 2 (GPL2) as published by the Free Software
Foundation and appearing in the file GPL2.TXT included in the packaging of
this file. Please note that GPL2 Section 2[b] requires that all works based
on this software must also be made publicly available under the terms of
the GPL2 ("Copyleft").
Contact information
-------------------
Kristian Lauszus, TKJ Electronics
Web : http://www.tkjelectronics.com
e-mail : kristianl@tkjelectronics.com
*/
#include "PSBuzz.h"
// To enable serial debugging see "settings.h"
//#define PRINTREPORT // Uncomment to print the report send by the PS Buzz Controllers
void PSBuzz::ParseHIDData(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf) {
if (HIDUniversal::VID == PSBUZZ_VID && HIDUniversal::PID == PSBUZZ_PID && len > 0 && buf) {
#ifdef PRINTREPORT
Notify(PSTR("\r\n"), 0x80);
for (uint8_t i = 0; i < len; i++) {
D_PrintHex<uint8_t > (buf[i], 0x80);
Notify(PSTR(" "), 0x80);
}
#endif
memcpy(&psbuzzButtons, buf + 2, min(len - 2, sizeof(psbuzzButtons)));
if (psbuzzButtons.val != oldButtonState.val) { // Check if anything has changed
buttonClickState.val = psbuzzButtons.val & ~oldButtonState.val; // Update click state variable
oldButtonState.val = psbuzzButtons.val;
}
}
};
uint8_t PSBuzz::OnInitSuccessful() {
if (HIDUniversal::VID == PSBUZZ_VID && HIDUniversal::PID == PSBUZZ_PID) {
Reset();
if (pFuncOnInit)
pFuncOnInit(); // Call the user function
else
setLedOnAll(); // Turn the LED on, on all four controllers
};
return 0;
};
bool PSBuzz::getButtonPress(ButtonEnum b, uint8_t controller) {
return psbuzzButtons.val & (1UL << (b + 5 * controller)); // Each controller uses 5 bits, so the value is shifted 5 for each controller
};
bool PSBuzz::getButtonClick(ButtonEnum b, uint8_t controller) {
uint32_t mask = (1UL << (b + 5 * controller)); // Each controller uses 5 bits, so the value is shifted 5 for each controller
bool click = buttonClickState.val & mask;
buttonClickState.val &= ~mask; // Clear "click" event
return click;
};
// Source: http://www.developerfusion.com/article/84338/making-usb-c-friendly/ and https://github.com/torvalds/linux/blob/master/drivers/hid/hid-sony.c
void PSBuzz::setLedRaw(bool value, uint8_t controller) {
ledState[controller] = value; // Save value for next time it is called
uint8_t buf[7];
buf[0] = 0x00;
buf[1] = ledState[0] ? 0xFF : 0x00;
buf[2] = ledState[1] ? 0xFF : 0x00;
buf[3] = ledState[2] ? 0xFF : 0x00;
buf[4] = ledState[3] ? 0xFF : 0x00;
buf[5] = 0x00;
buf[6] = 0x00;
PSBuzz_Command(buf, sizeof(buf));
};
void PSBuzz::PSBuzz_Command(uint8_t *data, uint16_t nbytes) {
// bmRequest = Host to device (0x00) | Class (0x20) | Interface (0x01) = 0x21, bRequest = Set Report (0x09), Report ID (0x00), Report Type (Output 0x02), interface (0x00), datalength, datalength, data)
pUsb->ctrlReq(bAddress, epInfo[0].epAddr, bmREQ_HIDOUT, HID_REQUEST_SET_REPORT, 0x00, 0x02, 0x00, nbytes, nbytes, data, NULL);
};

185
PSBuzz.h Normal file
View file

@ -0,0 +1,185 @@
/* Copyright (C) 2014 Kristian Lauszus, TKJ Electronics. All rights reserved.
This software may be distributed and modified under the terms of the GNU
General Public License version 2 (GPL2) as published by the Free Software
Foundation and appearing in the file GPL2.TXT included in the packaging of
this file. Please note that GPL2 Section 2[b] requires that all works based
on this software must also be made publicly available under the terms of
the GPL2 ("Copyleft").
Contact information
-------------------
Kristian Lauszus, TKJ Electronics
Web : http://www.tkjelectronics.com
e-mail : kristianl@tkjelectronics.com
*/
#ifndef _psbuzz_h_
#define _psbuzz_h_
#include "hiduniversal.h"
#include "controllerEnums.h"
#define PSBUZZ_VID 0x054C // Sony Corporation
#define PSBUZZ_PID 0x1000 // PS Buzz Controller
/** Struct used to easily read the different buttons on the controllers */
union PSBUZZButtons {
struct {
uint8_t red : 1;
uint8_t yellow : 1;
uint8_t green : 1;
uint8_t orange : 1;
uint8_t blue : 1;
} __attribute__((packed)) btn[4];
uint32_t val : 20;
} __attribute__((packed));
/**
* This class implements support for the PS Buzz controllers via USB.
* It uses the HIDUniversal class for all the USB communication.
*/
class PSBuzz : public HIDUniversal {
public:
/**
* Constructor for the PSBuzz class.
* @param p Pointer to the USB class instance.
*/
PSBuzz(USB *p) :
HIDUniversal(p) {
Reset();
};
/**
* Used to check if a PS Buzz controller is connected.
* @return Returns true if it is connected.
*/
bool connected() {
return HIDUniversal::isReady() && HIDUniversal::VID == PSBUZZ_VID && HIDUniversal::PID == PSBUZZ_PID;
};
/**
* Used to call your own function when the device is successfully initialized.
* @param funcOnInit Function to call.
*/
void attachOnInit(void (*funcOnInit)(void)) {
pFuncOnInit = funcOnInit;
};
/** @name PS Buzzer Controller functions */
/**
* getButtonPress(ButtonEnum b) will return true as long as the button is held down.
*
* While getButtonClick(ButtonEnum b) will only return it once.
*
* So you instance if you need to increase a variable once you would use getButtonClick(ButtonEnum b),
* but if you need to drive a robot forward you would use getButtonPress(ButtonEnum b).
* @param b ::ButtonEnum to read.
* @param controller The controller to read from. Default to 0.
* @return getButtonPress(ButtonEnum b) will return a true as long as a button is held down, while getButtonClick(ButtonEnum b) will return true once for each button press.
*/
bool getButtonPress(ButtonEnum b, uint8_t controller = 0);
bool getButtonClick(ButtonEnum b, uint8_t controller = 0);
/**@}*/
/** @name PS Buzzer Controller functions */
/**
* Set LED value without using ::LEDEnum.
* @param value See: ::LEDEnum.
*/
/**
* Set LED values directly.
* @param value Used to set whenever the LED should be on or off
* @param controller The controller to control. Defaults to 0.
*/
void setLedRaw(bool value, uint8_t controller = 0);
/** Turn all LEDs off. */
void setLedOffAll() {
for (uint8_t i = 1; i < 4; i++) // Skip first as it will be set in setLedRaw
ledState[i] = false; // Just an easy way to set all four off at the same time
setLedRaw(false); // Turn the LED off, on all four controllers
};
/**
* Turn the LED off on a specific controller.
* @param controller The controller to turn off. Defaults to 0.
*/
void setLedOff(uint8_t controller = 0) {
setLedRaw(false, controller);
};
/** Turn all LEDs on. */
void setLedOnAll() {
for (uint8_t i = 1; i < 4; i++) // Skip first as it will be set in setLedRaw
ledState[i] = true; // Just an easy way to set all four off at the same time
setLedRaw(true); // Turn the LED on, on all four controllers
};
/**
* Turn the LED on on a specific controller.
* @param controller The controller to turn off. Defaults to 0.
*/
void setLedOn(uint8_t controller = 0) {
setLedRaw(true, controller);
};
/**
* Toggle the LED on a specific controller.
* @param controller The controller to turn off. Defaults to 0.
*/
void setLedToggle(uint8_t controller = 0) {
setLedRaw(!ledState[controller], controller);
};
/**@}*/
protected:
/** @name HIDUniversal implementation */
/**
* Used to parse USB HID data.
* @param hid Pointer to the HID class.
* @param is_rpt_id Only used for Hubs.
* @param len The length of the incoming data.
* @param buf Pointer to the data buffer.
*/
virtual void ParseHIDData(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf);
/**
* Called when a device is successfully initialized.
* Use attachOnInit(void (*funcOnInit)(void)) to call your own function.
* This is useful for instance if you want to set the LEDs in a specific way.
*/
virtual uint8_t OnInitSuccessful();
/**@}*/
/** Used to reset the different buffers to their default values */
void Reset() {
psbuzzButtons.val = 0;
oldButtonState.val = 0;
buttonClickState.val = 0;
for (uint8_t i = 0; i < sizeof(ledState); i++)
ledState[i] = 0;
};
/** @name USBDeviceConfig implementation */
/**
* Used by the USB core to check what this driver support.
* @param vid The device's VID.
* @param pid The device's PID.
* @return Returns true if the device's VID and PID matches this driver.
*/
virtual boolean VIDPIDOK(uint16_t vid, uint16_t pid) {
return (vid == PSBUZZ_VID && pid == PSBUZZ_PID);
};
/**@}*/
private:
void (*pFuncOnInit)(void); // Pointer to function called in onInit()
void PSBuzz_Command(uint8_t *data, uint16_t nbytes);
PSBUZZButtons psbuzzButtons, oldButtonState, buttonClickState;
bool ledState[4];
};
#endif

View file

@ -22,10 +22,30 @@ For more information about the hardware see the [Hardware Manual](http://www.cir
* __Alexei Glushchenko, Circuits@Home__ - <alex-gl@mail.ru>
* Developers of the USB Core, HID, FTDI, ADK, ACM, and PL2303 libraries
* __Kristian Lauszus, TKJ Electronics__ - <kristianl@tkjelectronics.com>
* Developer of the [BTD](#bluetooth-libraries), [BTHID](#bthid-library), [SPP](#spp-library), [PS4](#ps4-library), [PS3](#ps3-library), [Wii](#wii-library), and [Xbox](#xbox-library) libraries
* Developer of the [BTD](#bluetooth-libraries), [BTHID](#bthid-library), [SPP](#spp-library), [PS4](#ps4-library), [PS3](#ps3-library), [Wii](#wii-library), [Xbox](#xbox-library), and [PSBuzz](#ps-buzz-library) libraries
* __Andrew Kroll__ - <xxxajk@gmail.com>
* Major contributor to mass storage code
# Table of Contents
* [How to include the library](#how-to-include-the-library)
* [How to use the library](#how-to-use-the-library)
* [Documentation](#documentation)
* [Enable debugging](#enable-debugging)
* [Boards](#boards)
* [Bluetooth libraries](#bluetooth-libraries)
* [BTHID library](#bthid-library)
* [SPP library](#spp-library)
* [PS4 Library](#ps4-library)
* [PS3 Library](#ps3-library)
* [Xbox Libraries](#xbox-libraries)
* [Xbox library](#xbox-library)
* [Xbox 360 Library](#xbox-360-library)
* [Wii library](#wii-library)
* [PS Buzz Library](#ps-buzz-library)
* [Interface modifications](#interface-modifications)
* [FAQ](#faq)
# How to include the library
First download the library by clicking on the following link: <https://github.com/felis/USB_Host_Shield_2.0/archive/master.zip>.
@ -240,6 +260,39 @@ All the information about the Wii controllers are from these sites:
* <http://wiibrew.org/wiki/Wiimote/Extension_Controllers/Wii_Motion_Plus>
* The old library created by _Tomoyuki Tanaka_: <https://github.com/moyuchin/WiiRemote_on_Arduino> also helped a lot.
### [PS Buzz Library](PSBuzz.cpp)
This library implements support for the Playstation Buzz controllers via USB.
It is essentially just a wrapper around the [HIDUniversal](hiduniversal.cpp) which takes care of the initializing and reading of the controllers. The [PSBuzz](PSBuzz.cpp) class simply inherits this and parses the data, so it is easy for users to read the buttons and turn the big red button on the controllers on and off.
The example [PSBuzz.ino](examples/PSBuzz/PSBuzz.ino) shows how one can do this with just a few lines of code.
More information about the controller can be found at the following sites:
* http://www.developerfusion.com/article/84338/making-usb-c-friendly/
* https://github.com/torvalds/linux/blob/master/drivers/hid/hid-sony.c
# Interface modifications
The shield is using SPI for communicating with the MAX3421E USB host controller. It uses the SCK, MISO and MOSI pins via the ICSP on your board.
Furthermore it uses one pin as SS and one INT pin. These are by default located on pin 10 and 9 respectively. They can easily be reconfigured in case you need to use them for something else by cutting the jumper on the shield and then solder a wire from the pad to the new pin.
After that you need modify the following entry in [UsbCore.h](UsbCore.h):
```C++
typedef MAX3421e<P10, P9> MAX3421E;
```
For instance if you have rerouted SS to pin 7 it should read:
```C++
typedef MAX3421e<P7, P9> MAX3421E;
```
See the "Interface modifications" section in the [hardware manual](https://www.circuitsathome.com/usb-host-shield-hardware-manual) for more information.
# FAQ
> When I plug my device into the USB connector nothing happens?

155
SPP.cpp
View file

@ -538,15 +538,15 @@ void SPP::serviceNotSupported(uint8_t transactionIDHigh, uint8_t transactionIDLo
l2capoutbuf[0] = SDP_SERVICE_SEARCH_ATTRIBUTE_RESPONSE_PDU;
l2capoutbuf[1] = transactionIDHigh;
l2capoutbuf[2] = transactionIDLow;
l2capoutbuf[3] = 0x00; // Parameter Length
l2capoutbuf[4] = 0x05; // Parameter Length
l2capoutbuf[5] = 0x00; // AttributeListsByteCount
l2capoutbuf[6] = 0x02; // AttributeListsByteCount
l2capoutbuf[3] = 0x00; // MSB Parameter Length
l2capoutbuf[4] = 0x05; // LSB Parameter Length = 5
l2capoutbuf[5] = 0x00; // MSB AttributeListsByteCount
l2capoutbuf[6] = 0x02; // LSB AttributeListsByteCount = 2
/* Attribute ID/Value Sequence: */
l2capoutbuf[7] = 0x35;
l2capoutbuf[8] = 0x00;
l2capoutbuf[9] = 0x00;
l2capoutbuf[7] = 0x35; // Data element sequence - length in next byte
l2capoutbuf[8] = 0x00; // Length = 0
l2capoutbuf[9] = 0x00; // No continuation state
SDP_Command(l2capoutbuf, 10);
}
@ -555,56 +555,60 @@ void SPP::serialPortResponse1(uint8_t transactionIDHigh, uint8_t transactionIDLo
l2capoutbuf[0] = SDP_SERVICE_SEARCH_ATTRIBUTE_RESPONSE_PDU;
l2capoutbuf[1] = transactionIDHigh;
l2capoutbuf[2] = transactionIDLow;
l2capoutbuf[3] = 0x00; // Parameter Length
l2capoutbuf[4] = 0x2B; // Parameter Length
l2capoutbuf[5] = 0x00; // AttributeListsByteCount
l2capoutbuf[6] = 0x26; // AttributeListsByteCount
l2capoutbuf[3] = 0x00; // MSB Parameter Length
l2capoutbuf[4] = 0x2B; // LSB Parameter Length = 43
l2capoutbuf[5] = 0x00; // MSB AttributeListsByteCount
l2capoutbuf[6] = 0x26; // LSB AttributeListsByteCount = 38
/* Attribute ID/Value Sequence: */
l2capoutbuf[7] = 0x36;
l2capoutbuf[8] = 0x00;
l2capoutbuf[9] = 0x3C;
l2capoutbuf[10] = 0x36;
l2capoutbuf[11] = 0x00;
l2capoutbuf[7] = 0x36; // Data element sequence - length in next two bytes
l2capoutbuf[8] = 0x00; // MSB Length
l2capoutbuf[9] = 0x3C; // LSB Length = 60
l2capoutbuf[12] = 0x39;
l2capoutbuf[13] = 0x09;
l2capoutbuf[14] = 0x00;
l2capoutbuf[15] = 0x00;
l2capoutbuf[16] = 0x0A;
l2capoutbuf[17] = 0x00;
l2capoutbuf[10] = 0x36; // Data element sequence - length in next two bytes
l2capoutbuf[11] = 0x00; // MSB Length
l2capoutbuf[12] = 0x39; // LSB Length = 57
l2capoutbuf[13] = 0x09; // Unsigned Integer - length 2 bytes
l2capoutbuf[14] = 0x00; // MSB ServiceRecordHandle
l2capoutbuf[15] = 0x00; // LSB ServiceRecordHandle
l2capoutbuf[16] = 0x0A; // Unsigned int - length 4 bytes
l2capoutbuf[17] = 0x00; // ServiceRecordHandle value - TODO: Is this related to HCI_Handle?
l2capoutbuf[18] = 0x01;
l2capoutbuf[19] = 0x00;
l2capoutbuf[20] = 0x06;
l2capoutbuf[21] = 0x09;
l2capoutbuf[22] = 0x00;
l2capoutbuf[23] = 0x01;
l2capoutbuf[24] = 0x35;
l2capoutbuf[25] = 0x03;
l2capoutbuf[26] = 0x19;
l2capoutbuf[27] = 0x11;
l2capoutbuf[28] = 0x01;
l2capoutbuf[29] = 0x09;
l2capoutbuf[30] = 0x00;
l2capoutbuf[31] = 0x04;
l2capoutbuf[32] = 0x35;
l2capoutbuf[33] = 0x0C;
l2capoutbuf[34] = 0x35;
l2capoutbuf[35] = 0x03;
l2capoutbuf[36] = 0x19;
l2capoutbuf[37] = 0x01;
l2capoutbuf[38] = 0x00;
l2capoutbuf[39] = 0x35;
l2capoutbuf[40] = 0x05;
l2capoutbuf[41] = 0x19;
l2capoutbuf[42] = 0x00;
l2capoutbuf[43] = 0x03;
l2capoutbuf[21] = 0x09; // Unsigned Integer - length 2 bytes
l2capoutbuf[22] = 0x00; // MSB ServiceClassIDList
l2capoutbuf[23] = 0x01; // LSB ServiceClassIDList
l2capoutbuf[24] = 0x35; // Data element sequence - length in next byte
l2capoutbuf[25] = 0x03; // Length = 3
l2capoutbuf[26] = 0x19; // UUID (universally unique identifier) - length = 2 bytes
l2capoutbuf[27] = 0x11; // MSB SerialPort
l2capoutbuf[28] = 0x01; // LSB SerialPort
l2capoutbuf[44] = 0x08;
l2capoutbuf[45] = 0x02; // Two extra bytes
l2capoutbuf[46] = 0x00; // 25 (0x19) more bytes to come
l2capoutbuf[47] = 0x19;
l2capoutbuf[29] = 0x09; // Unsigned Integer - length 2 bytes
l2capoutbuf[30] = 0x00; // MSB ProtocolDescriptorList
l2capoutbuf[31] = 0x04; // LSB ProtocolDescriptorList
l2capoutbuf[32] = 0x35; // Data element sequence - length in next byte
l2capoutbuf[33] = 0x0C; // Length = 12
l2capoutbuf[34] = 0x35; // Data element sequence - length in next byte
l2capoutbuf[35] = 0x03; // Length = 3
l2capoutbuf[36] = 0x19; // UUID (universally unique identifier) - length = 2 bytes
l2capoutbuf[37] = 0x01; // MSB L2CAP
l2capoutbuf[38] = 0x00; // LSB L2CAP
l2capoutbuf[39] = 0x35; // Data element sequence - length in next byte
l2capoutbuf[40] = 0x05; // Length = 5
l2capoutbuf[41] = 0x19; // UUID (universally unique identifier) - length = 2 bytes
l2capoutbuf[42] = 0x00; // MSB RFCOMM
l2capoutbuf[43] = 0x03; // LSB RFCOMM
l2capoutbuf[44] = 0x08; // Unsigned Integer - length 1 byte
l2capoutbuf[45] = 0x02; // ContinuationState - Two more bytes
l2capoutbuf[46] = 0x00; // MSB length
l2capoutbuf[47] = 0x19; // LSB length = 25 more bytes to come
SDP_Command(l2capoutbuf, 48);
}
@ -613,40 +617,49 @@ void SPP::serialPortResponse2(uint8_t transactionIDHigh, uint8_t transactionIDLo
l2capoutbuf[0] = SDP_SERVICE_SEARCH_ATTRIBUTE_RESPONSE_PDU;
l2capoutbuf[1] = transactionIDHigh;
l2capoutbuf[2] = transactionIDLow;
l2capoutbuf[3] = 0x00; // Parameter Length
l2capoutbuf[4] = 0x1C; // Parameter Length
l2capoutbuf[5] = 0x00; // AttributeListsByteCount
l2capoutbuf[6] = 0x19; // AttributeListsByteCount
l2capoutbuf[3] = 0x00; // MSB Parameter Length
l2capoutbuf[4] = 0x1C; // LSB Parameter Length = 28
l2capoutbuf[5] = 0x00; // MSB AttributeListsByteCount
l2capoutbuf[6] = 0x19; // LSB AttributeListsByteCount = 25
/* Attribute ID/Value Sequence: */
l2capoutbuf[7] = 0x01;
l2capoutbuf[8] = 0x09;
l2capoutbuf[9] = 0x00;
l2capoutbuf[10] = 0x06;
l2capoutbuf[11] = 0x35;
l2capoutbuf[7] = 0x01; // Channel 1 - TODO: Try different values, so multiple servers can be used at once
l2capoutbuf[12] = 0x09;
l2capoutbuf[13] = 0x09;
l2capoutbuf[14] = 0x65;
l2capoutbuf[15] = 0x6E;
l2capoutbuf[16] = 0x09;
l2capoutbuf[17] = 0x00;
l2capoutbuf[18] = 0x6A;
l2capoutbuf[19] = 0x09;
l2capoutbuf[8] = 0x09; // Unsigned Integer - length 2 bytes
l2capoutbuf[9] = 0x00; // MSB LanguageBaseAttributeIDList
l2capoutbuf[10] = 0x06; // LSB LanguageBaseAttributeIDList
l2capoutbuf[11] = 0x35; // Data element sequence - length in next byte
l2capoutbuf[12] = 0x09; // Length = 9
// Identifier representing the natural language = en = English - see: "ISO 639:1988"
l2capoutbuf[13] = 0x09; // Unsigned Integer - length 2 bytes
l2capoutbuf[14] = 0x65; // 'e'
l2capoutbuf[15] = 0x6E; // 'n'
// "The second element of each triplet contains an identifier that specifies a character encoding used for the language"
// Encoding is set to 106 (UTF-8) - see: http://www.iana.org/assignments/character-sets/character-sets.xhtml
l2capoutbuf[16] = 0x09; // Unsigned Integer - length 2 bytes
l2capoutbuf[17] = 0x00; // MSB of character encoding
l2capoutbuf[18] = 0x6A; // LSB of character encoding (106)
// Attribute ID that serves as the base attribute ID for the natural language in the service record
// "To facilitate the retrieval of human-readable universal attributes in a principal language, the base attribute ID value for the primary language supported by a service record shall be 0x0100"
l2capoutbuf[19] = 0x09; // Unsigned Integer - length 2 bytes
l2capoutbuf[20] = 0x01;
l2capoutbuf[21] = 0x00;
l2capoutbuf[22] = 0x09;
l2capoutbuf[23] = 0x01;
l2capoutbuf[24] = 0x00;
l2capoutbuf[25] = 0x25;
l2capoutbuf[22] = 0x09; // Unsigned Integer - length 2 bytes
l2capoutbuf[23] = 0x01; // MSB ServiceDescription
l2capoutbuf[24] = 0x00; // LSB ServiceDescription
l2capoutbuf[25] = 0x25; // Text string - length in next byte
l2capoutbuf[26] = 0x05; // Name length
l2capoutbuf[27] = 'T';
l2capoutbuf[28] = 'K';
l2capoutbuf[29] = 'J';
l2capoutbuf[30] = 'S';
l2capoutbuf[31] = 'P';
l2capoutbuf[32] = 0x00; // No more data
l2capoutbuf[32] = 0x00; // No continuation state
SDP_Command(l2capoutbuf, 33);
}

View file

@ -861,11 +861,87 @@ public: \
} \
};
MAKE_PIN(P9, PIOC, PIO_PC21); // INT
MAKE_PIN(P10, PIOC, PIO_PC29); // SS
// See: http://arduino.cc/en/Hacking/PinMappingSAM3X and variant.cpp
MAKE_PIN(P0, PIOA, PIO_PA8);
MAKE_PIN(P1, PIOA, PIO_PA9);
MAKE_PIN(P2, PIOB, PIO_PB25);
MAKE_PIN(P3, PIOC, PIO_PC28);
MAKE_PIN(P4, PIOC, PIO_PC26);
MAKE_PIN(P5, PIOC, PIO_PC25);
MAKE_PIN(P6, PIOC, PIO_PC24);
MAKE_PIN(P7, PIOC, PIO_PC23);
MAKE_PIN(P8, PIOC, PIO_PC22);
MAKE_PIN(P9, PIOC, PIO_PC21);
MAKE_PIN(P10, PIOC, PIO_PC29);
MAKE_PIN(P11, PIOD, PIO_PD7);
MAKE_PIN(P12, PIOD, PIO_PD8);
MAKE_PIN(P13, PIOB, PIO_PB27);
MAKE_PIN(P14, PIOD, PIO_PD4);
MAKE_PIN(P15, PIOD, PIO_PD5);
MAKE_PIN(P16, PIOA, PIO_PA13);
MAKE_PIN(P17, PIOA, PIO_PA12);
MAKE_PIN(P18, PIOA, PIO_PA11);
MAKE_PIN(P19, PIOA, PIO_PA10);
MAKE_PIN(P20, PIOB, PIO_PB12);
MAKE_PIN(P21, PIOB, PIO_PB13);
MAKE_PIN(P22, PIOB, PIO_PB26);
MAKE_PIN(P23, PIOA, PIO_PA14);
MAKE_PIN(P24, PIOA, PIO_PA15);
MAKE_PIN(P25, PIOD, PIO_PD0);
MAKE_PIN(P26, PIOD, PIO_PD1);
MAKE_PIN(P27, PIOD, PIO_PD2);
MAKE_PIN(P28, PIOD, PIO_PD3);
MAKE_PIN(P29, PIOD, PIO_PD6);
MAKE_PIN(P30, PIOD, PIO_PD9);
MAKE_PIN(P31, PIOA, PIO_PA7);
MAKE_PIN(P32, PIOD, PIO_PD10);
MAKE_PIN(P33, PIOC, PIO_PC1);
MAKE_PIN(P34, PIOC, PIO_PC2);
MAKE_PIN(P35, PIOC, PIO_PC3);
MAKE_PIN(P36, PIOC, PIO_PC4);
MAKE_PIN(P37, PIOC, PIO_PC5);
MAKE_PIN(P38, PIOC, PIO_PC6);
MAKE_PIN(P39, PIOC, PIO_PC7);
MAKE_PIN(P40, PIOC, PIO_PC8);
MAKE_PIN(P41, PIOC, PIO_PC9);
MAKE_PIN(P42, PIOA, PIO_PA19);
MAKE_PIN(P43, PIOA, PIO_PA20);
MAKE_PIN(P44, PIOC, PIO_PC19);
MAKE_PIN(P45, PIOC, PIO_PC18);
MAKE_PIN(P46, PIOC, PIO_PC17);
MAKE_PIN(P47, PIOC, PIO_PC16);
MAKE_PIN(P48, PIOC, PIO_PC15);
MAKE_PIN(P49, PIOC, PIO_PC14);
MAKE_PIN(P50, PIOC, PIO_PC13);
MAKE_PIN(P51, PIOC, PIO_PC12);
MAKE_PIN(P52, PIOB, PIO_PB21);
MAKE_PIN(P53, PIOB, PIO_PB14);
MAKE_PIN(P54, PIOA, PIO_PA16);
MAKE_PIN(P55, PIOA, PIO_PA24);
MAKE_PIN(P56, PIOA, PIO_PA23);
MAKE_PIN(P57, PIOA, PIO_PA22);
MAKE_PIN(P58, PIOA, PIO_PA6);
MAKE_PIN(P59, PIOA, PIO_PA4);
MAKE_PIN(P60, PIOA, PIO_PA3);
MAKE_PIN(P61, PIOA, PIO_PA2);
MAKE_PIN(P62, PIOB, PIO_PB17);
MAKE_PIN(P63, PIOB, PIO_PB18);
MAKE_PIN(P64, PIOB, PIO_PB19);
MAKE_PIN(P65, PIOB, PIO_PB20);
MAKE_PIN(P66, PIOB, PIO_PB15);
MAKE_PIN(P67, PIOB, PIO_PB16);
MAKE_PIN(P68, PIOA, PIO_PA1);
MAKE_PIN(P69, PIOA, PIO_PA0);
MAKE_PIN(P70, PIOA, PIO_PA17);
MAKE_PIN(P71, PIOA, PIO_PA18);
MAKE_PIN(P72, PIOC, PIO_PC30);
MAKE_PIN(P73, PIOA, PIO_PA21);
MAKE_PIN(P74, PIOA, PIO_PA25); // MISO
MAKE_PIN(P75, PIOA, PIO_PA26); // MOSI
MAKE_PIN(P76, PIOA, PIO_PA27); // CLK
MAKE_PIN(P77, PIOA, PIO_PA28);
MAKE_PIN(P78, PIOB, PIO_PB23); // Unconnected
#undef MAKE_PIN

View file

@ -137,6 +137,14 @@ enum ButtonEnum {
BLACK = 8, // Available on the original Xbox controller
WHITE = 9, // Available on the original Xbox controller
/**@}*/
/** PS Buzz controllers */
RED = 0,
YELLOW = 1,
GREEN = 2,
ORANGE = 3,
BLUE = 4,
/**@}*/
};
/** Joysticks on the PS3 and Xbox controllers. */

View file

@ -6,7 +6,7 @@
#include <SPP.h>
#include <usbhub.h>
// Satisfy IDE, which only needs to see the include statment in the ino.
// Satisfy IDE, which only needs to see the include statement in the ino.
#ifdef dobogusinclude
#include <spi4teensy3.h>
#endif
@ -15,10 +15,11 @@ USB Usb;
//USBHub Hub1(&Usb); // Some dongles have a hub inside
BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so
SPP *SerialBT[2]; // We will use this pointer to store the two instance, you can easily make it larger if you like, but it will use a lot of RAM!
const uint8_t length = sizeof(SerialBT) / sizeof(SerialBT[0]); // Get the lenght of the array
const uint8_t length = 2; // Set the number of instances here
SPP *SerialBT[length]; // We will use this pointer to store the instances, you can easily make it larger if you like, but it will use a lot of RAM!
boolean firstMessage[length] = { true }; // Set all to true
uint8_t buffer[50];
void setup() {
for (uint8_t i = 0; i < length; i++)
@ -28,10 +29,11 @@ void setup() {
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
if (Usb.Init() == -1) {
Serial.print(F("\r\nOSC did not start"));
while (1); //halt
while (1); // Halt
}
Serial.print(F("\r\nSPP Bluetooth Library Started"));
}
void loop() {
Usb.Task(); // The SPP data is actually not send until this is called, one could call SerialBT.send() directly as well
@ -47,22 +49,15 @@ void loop() {
else
firstMessage[i] = true;
}
// Set the connection you want to send to using the first character
// For instance "0Hello World" would send "Hello World" to connection 0
if (Serial.available()) {
delay(10); // Wait for the rest of the data to arrive
uint8_t i = 0;
while (Serial.available() && i < sizeof(buffer)) // Read the data
buffer[i++] = Serial.read();
/*
Set the connection you want to send to using the first character
For instace "0Hello World" would send "Hello World" to connection 0
*/
uint8_t id = buffer[0] - '0'; // Convert from ASCII
if (id < length && i > 1) { // And then compare to length and make sure there is any text
if (SerialBT[id]->connected) { // Check if a device is actually connected
for (uint8_t i2 = 0; i2 < i - 1; i2++) // Don't include the first character
buffer[i2] = buffer[i2 + 1];
SerialBT[id]->write(buffer, i - 1); // Send the data
}
uint8_t id = Serial.read() - '0'; // Convert from ASCII
if (id < length && SerialBT[id]->connected) { // Make sure that the id is valid and make sure that a device is actually connected
while (Serial.available()) // Check if data is available
SerialBT[id]->write(Serial.read()); // Send the data
}
}
}

View file

@ -0,0 +1,46 @@
/*
Example sketch for the Playstation Buzz library - developed by Kristian Lauszus
For more information visit my blog: http://blog.tkjelectronics.dk/ or
send me an e-mail: kristianl@tkjelectronics.com
*/
#include <PSBuzz.h>
// Satisfy IDE, which only needs to see the include statment in the ino.
#ifdef dobogusinclude
#include <spi4teensy3.h>
#endif
USB Usb;
PSBuzz Buzz(&Usb);
void setup() {
Serial.begin(115200);
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
if (Usb.Init() == -1) {
Serial.print(F("\r\nOSC did not start"));
while (1); // Halt
}
Serial.println(F("\r\nPS Buzz Library Started"));
}
void loop() {
Usb.Task();
if (Buzz.connected()) {
for (uint8_t i = 0; i < 4; i++) {
if (Buzz.getButtonClick(RED, i)) {
Buzz.setLedToggle(i); // Toggle the LED
Serial.println(F("RED"));
}
if (Buzz.getButtonClick(YELLOW, i))
Serial.println(F("YELLOW"));
if (Buzz.getButtonClick(GREEN, i))
Serial.println(F("GREEN"));
if (Buzz.getButtonClick(ORANGE, i))
Serial.println(F("ORANGE"));
if (Buzz.getButtonClick(BLUE, i))
Serial.println(F("BLUE"));
}
}
}

@ -1 +1 @@
Subproject commit d35bb955e3818f0c14e47c8a1998003da8dc1b5a
Subproject commit 7ada91a90027ccb7558b74087fb68d3940ecf64d

View file

@ -9,6 +9,10 @@
BOARD = mega
PROGRAMMER = arduino
#BOARD = teensypp2
#BOARD = teensy3
#BOARD = teensy31
# set your Arduino tty port here
PORT = /dev/ttyUSB0

@ -1 +1 @@
Subproject commit 7fd6a306ca53d08bf53b2bbfc1b80eb056f2c55b
Subproject commit b119b97e1484a08aebcf24e070113d78c82fb023

@ -1 +1 @@
Subproject commit 0b8e3076b5a072251e01cfc6e6333b364d4e71e7
Subproject commit 72b5bf467a1c2479ba7354ee4d864e382c167425

174
examples/testusbhostFAT/testusbhostFAT.ino Normal file → Executable file
View file

@ -19,35 +19,39 @@
*
*/
/////////////////////////////////////////////////////////////
// Please Note: //
// This section is for info with the Arduino IDE ONLY. //
// Unfortunately due to short sightedness of the Arduino //
// code team, that you must set the following in the //
// respective libraries. //
// Changing them here will have _NO_ effect! //
/////////////////////////////////////////////////////////////
// Uncomment to enable debugging
//#define DEBUG_USB_HOST
// This is where stderr/USB debugging goes to
//#define USB_HOST_SERIAL Serial3
// If you have external memory, setting this to 0 enables FAT table caches.
// The 0 setting is recommended only if you have external memory.
//#define _FS_TINY 1
//#define _USE_LFN 3
//#define EXT_RAM_STACK 1
//#define EXT_RAM_HEAP 1
//#define _MAX_SS 512
/////////////////////////////////////////////////////////////
// End of Arduino IDE specific information //
/////////////////////////////////////////////////////////////
// You can set this to 0 if you are not using a USB hub.
// It will save a little bit of flash and RAM.
// Set to 1 if you want to use a hub.
#define WANT_HUB_TEST 0
/////////////////////////////////////////////////////////////
// Please Note: This section is for Arduino IDE ONLY. //
// Use of Make creates a flash image that is 3.3KB smaller //
/////////////////////////////////////////////////////////////
#ifndef USING_MAKEFILE
// Uncomment to enable debugging
//#define DEBUG_USB_HOST
// This is where stderr/USB debugging goes to
#define USB_HOST_SERIAL Serial3
// If you have external memory, setting this to 0 enables FAT table caches.
// The 0 setting is recommended only if you have external memory.
#define _FS_TINY 1
// These you can safely leave alone.
#define _USE_LFN 3
#define EXT_RAM_STACK 1
#define EXT_RAM_HEAP 1
#define _MAX_SS 512
#endif
/////////////////////////////////////////////////////////////
// End of Arduino IDE specific hacks //
/////////////////////////////////////////////////////////////
#if defined(AVR)
#if defined(__AVR__)
#include <xmem.h>
#else
#include <spi4teensy3.h>
@ -63,7 +67,7 @@
#include <Wire.h>
#include <RTClib.h>
#include <stdio.h>
#if defined(AVR)
#if defined(__AVR__)
static FILE tty_stdio;
static FILE tty_stderr;
volatile uint32_t LEDnext_time; // fade timeout
@ -100,7 +104,7 @@ static storage_t sto[_VOLUMES];
#define mbxs 128
static uint8_t My_Buff_x[mbxs]; /* File read buffer */
#if defined(AVR)
#if defined(__AVR__)
#define prescale1 ((1 << WGM12) | (1 << CS10))
#define prescale8 ((1 << WGM12) | (1 << CS11))
@ -184,7 +188,7 @@ void setup() {
// minimum 0x00, maximum 0xff
UsbDEBUGlvl = 0x51;
#if defined(AVR)
#if !defined(CORE_TEENSY) && defined(__AVR__)
// make LED pin as an output:
pinMode(LED_BUILTIN, OUTPUT);
pinMode(2, OUTPUT);
@ -198,6 +202,18 @@ void setup() {
serr = true;
}
// Blink LED
delay(500);
analogWrite(LED_BUILTIN, 255);
delay(500);
analogWrite(LED_BUILTIN, 0);
delay(500);
#else
while(!Serial);
Serial.begin(115200); // On the Teensy 3.x we get a delay at least!
#endif
#if defined(__AVR__)
// Set up stdio/stderr
tty_stdio.put = tty_std_putc;
tty_stdio.get = tty_std_getc;
@ -212,17 +228,7 @@ void setup() {
stdout = &tty_stdio;
stdin = &tty_stdio;
stderr = &tty_stderr;
// Blink LED
delay(500);
analogWrite(LED_BUILTIN, 255);
delay(500);
analogWrite(LED_BUILTIN, 0);
delay(500);
#else
while(!Serial);
#endif
printf_P(PSTR("\r\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nStart\r\n"));
printf_P(PSTR("Current UsbDEBUGlvl %02x\r\n"), UsbDEBUGlvl);
printf_P(PSTR("'+' and '-' increase/decrease by 0x01\r\n"));
@ -247,8 +253,8 @@ void setup() {
#endif
"\r\n"));
}
#if defined(AVR)
#if !defined(CORE_TEENSY) && defined(__AVR__)
analogWrite(LED_BUILTIN, 255);
delay(500);
analogWrite(LED_BUILTIN, 0);
@ -263,7 +269,7 @@ void setup() {
delay(500);
LEDnext_time = millis() + 1;
#ifdef EXT_RAM
#if EXT_RAM
printf_P(PSTR("Total EXT RAM banks %i\r\n"), xmem::getTotalBanks());
#endif
printf_P(PSTR("Available heap: %u Bytes\r\n"), freeHeap());
@ -276,20 +282,20 @@ void setup() {
#if WANT_HUB_TEST
for(int i = 0; i < MAX_HUBS; i++) {
Hubs[i] = new USBHub(&Usb);
#if defined(AVR)
#if defined(__AVR__)
printf_P(PSTR("Available heap: %u Bytes\r\n"), freeHeap());
#endif
}
#endif
// Initialize generic storage. This must be done before USB starts.
InitStorage();
Init_Generic_Storage();
while(Usb.Init(1000) == -1) {
printf_P(PSTR("No USB HOST Shield?\r\n"));
Notify(PSTR("OSC did not start."), 0x40);
}
#if defined(AVR)
#if !defined(CORE_TEENSY) && defined(__AVR__)
cli();
TCCR3A = 0;
TCCR3B = 0;
@ -300,32 +306,10 @@ void setup() {
sei();
HEAPnext_time = millis() + 10000;
#else
#if 0
//
// On the teensy 3 we can raise the speed of SPI here.
//
// Default seen is 0xB8011001.
//
uint32_t ctar = SPI0_CTAR0;
//printf("SPI_CTAR0 = %8.8X\r\n", ctar);
ctar &= 0x7FFCFFF0; // 1/4 fSYS, 12.5Mhz
//printf("SPI_CTAR0 = %8.8X\r\n", ctar);
ctar |= 0x80000000; // 1/2 fSYS 25Mhz
//printf("SPI_CTAR0 = %8.8X\r\n", ctar);
uint32_t mcr = SPI0_MCR;
if(mcr & SPI_MCR_MDIS) {
SPI0_CTAR0 = ctar;
} else {
SPI0_MCR = mcr | SPI_MCR_MDIS | SPI_MCR_HALT;
SPI0_CTAR0 = ctar;
SPI0_MCR = mcr;
}
#endif
#if defined(__AVR__)
HEAPnext_time = millis() + 10000;
#endif
}
void serialEvent() {
@ -367,10 +351,11 @@ void serialEvent() {
}
}
#if defined(AVR)
#if !defined(CORE_TEENSY) && defined(__AVR__)
// ALL teensy versions LACK PWM ON LED
ISR(TIMER3_COMPA_vect) {
if(millis() >= LEDnext_time) {
if((long)(millis() - LEDnext_time) >= 0L) {
LEDnext_time = millis() + 30;
// set the brightness of LED
@ -404,22 +389,23 @@ void die(FRESULT rc) {
void loop() {
FIL My_File_Object_x; /* File object */
#if defined(AVR)
#if defined(__AVR__)
// Print a heap status report about every 10 seconds.
if(millis() >= HEAPnext_time) {
if((long)(millis() - HEAPnext_time) >= 0L) {
if(UsbDEBUGlvl > 0x50) {
printf_P(PSTR("Available heap: %u Bytes\r\n"), freeHeap());
}
HEAPnext_time = millis() + 10000;
}
TCCR3B = 0;
#else
// Arm suffers here, oh well...
#endif
#if defined(CORE_TEENSY)
// Teensy suffers here, oh well...
serialEvent();
#endif
// Horrid! This sort of thing really belongs in an ISR, not here!
// We also will be needing to test each hub port, we don't do this yet!
if(!change && !usbon && millis() >= usbon_time) {
if(!change && !usbon && (long)(millis() - usbon_time) >= 0L) {
change = true;
usbon = true;
}
@ -439,13 +425,13 @@ void loop() {
if(current_state != last_state) {
if(UsbDEBUGlvl > 0x50)
printf_P(PSTR("USB state = %x\r\n"), current_state);
#if defined(AVR)
#if !defined(CORE_TEENSY) && defined(__AVR__)
if(current_state == USB_STATE_RUNNING) {
fadeAmount = 30;
}
#endif
if(current_state == USB_DETACHED_SUBSTATE_WAIT_FOR_DEVICE) {
#if defined(AVR)
#if !defined(CORE_TEENSY) && defined(__AVR__)
fadeAmount = 80;
#endif
partsready = false;
@ -468,23 +454,24 @@ void loop() {
}
// This is horrible, and needs to be moved elsewhere!
for(int B = 0; B < MAX_USB_MS_DRIVERS; B++) {
if(!partsready && (Bulk[B]->GetAddress() != NULL)) {
if(!partsready && (UHS_USB_BulkOnly[B]->GetAddress() != NULL)) {
// Build a list.
int ML = Bulk[B]->GetbMaxLUN();
int ML = UHS_USB_BulkOnly[B]->GetbMaxLUN();
//printf("MAXLUN = %i\r\n", ML);
ML++;
for(int i = 0; i < ML; i++) {
if(Bulk[B]->LUNIsGood(i)) {
if(UHS_USB_BulkOnly[B]->LUNIsGood(i)) {
partsready = true;
((pvt_t *)(sto[i].private_data))->lun = i;
((pvt_t *)(sto[i].private_data))->B = B;
sto[i].Reads = *PReads;
sto[i].Writes = *PWrites;
sto[i].Status = *PStatus;
sto[i].Reads = *UHS_USB_BulkOnly_Read;
sto[i].Writes = *UHS_USB_BulkOnly_Write;
sto[i].Status = *UHS_USB_BulkOnly_Status;
sto[i].Initialize = *UHS_USB_BulkOnly_Initialize;
sto[i].Commit = *UHS_USB_BulkOnly_Commit;
sto[i].TotalSectors = Bulk[B]->GetCapacity(i);
sto[i].SectorSize = Bulk[B]->GetSectorSize(i);
sto[i].TotalSectors = UHS_USB_BulkOnly[B]->GetCapacity(i);
sto[i].SectorSize = UHS_USB_BulkOnly[B]->GetSectorSize(i);
printf_P(PSTR("LUN:\t\t%u\r\n"), i);
printf_P(PSTR("Total Sectors:\t%08lx\t%lu\r\n"), sto[i].TotalSectors, sto[i].TotalSectors);
printf_P(PSTR("Sector Size:\t%04x\t\t%u\r\n"), sto[i].SectorSize, sto[i].SectorSize);
@ -522,10 +509,9 @@ void loop() {
}
delete PT;
} else {
sto[i].Read = NULL;
sto[i].Write = NULL;
sto[i].Writes = NULL;
sto[i].Reads = NULL;
sto[i].Initialize = NULL;
sto[i].TotalSectors = 0UL;
sto[i].SectorSize = 0;
}
@ -538,9 +524,9 @@ void loop() {
if(Fats[0] != NULL) {
struct Pvt * p;
p = ((struct Pvt *)(Fats[0]->storage->private_data));
if(!Bulk[p->B]->LUNIsGood(p->lun)) {
if(!UHS_USB_BulkOnly[p->B]->LUNIsGood(p->lun)) {
// media change
#if defined(AVR)
#if !defined(CORE_TEENSY) && defined(__AVR__)
fadeAmount = 80;
#endif
partsready = false;
@ -559,12 +545,15 @@ void loop() {
if(fatready) {
FRESULT rc; /* Result code */
UINT bw, br, i;
if(!notified) {
#if defined(AVR)
#if !defined(CORE_TEENSY) && defined(__AVR__)
fadeAmount = 5;
#endif
notified = true;
FATFS *fs = NULL;
for(int zz = 0; zz < _VOLUMES; zz++) {
if(Fats[zz]->volmap == 0) fs = Fats[zz]->ffs;
}
printf_P(PSTR("\r\nOpen an existing file (message.txt).\r\n"));
rc = f_open(&My_File_Object_x, "0:/MESSAGE.TXT", FA_READ);
if(rc) printf_P(PSTR("Error %i, message.txt not found.\r\n"), rc);
@ -625,7 +614,7 @@ outdir:{
}
printf_P(PSTR("\r\nDirectory listing...\r\n"));
#if defined(AVR)
#if defined(__AVR__)
printf_P(PSTR("Available heap: %u Bytes\r\n"), freeHeap());
#endif
for(;;) {
@ -676,12 +665,18 @@ outdir:{
}
out:
if(rc) die(rc);
DISK_IOCTL(fs->drv, CTRL_COMMIT, 0);
printf_P(PSTR("\r\nTest completed.\r\n"));
}
if(runtest) {
ULONG ii, wt, rt, start, end;
FATFS *fs = NULL;
for(int zz = 0; zz < _VOLUMES; zz++) {
if(Fats[zz]->volmap == 0) fs = Fats[zz]->ffs;
}
runtest = false;
f_unlink("0:/10MB.bin");
printf_P(PSTR("\r\nCreate a new 10MB test file (10MB.bin).\r\n"));
@ -717,6 +712,7 @@ out:
printf_P(PSTR("Time to read 10485760 bytes: %lu ms (%lu sec)\r\nDelete test file\r\n"), rt, (500 + rt) / 1000UL);
failed:
if(rc) die(rc);
DISK_IOCTL(fs->drv, CTRL_COMMIT, 0);
printf_P(PSTR("10MB timing test finished.\r\n"));
}
}

View file

@ -398,7 +398,7 @@ uint8_t HIDUniversal::Poll() {
if(identical)
return 0;
#if 1
#if 0
Notify(PSTR("\r\nBuf: "), 0x80);
for(uint8_t i = 0; i < read; i++) {

View file

@ -318,7 +318,7 @@ getIRy4 KEYWORD2
getIRs4 KEYWORD2
####################################################
# Syntax Coloring Map For RFCOMM/SPP Library
# Syntax Coloring Map For BTHID Library
####################################################
####################################################
@ -331,4 +331,31 @@ BTHID KEYWORD1
# Methods and Functions (KEYWORD2)
####################################################
SetReportParser KEYWORD2
setProtocolMode KEYWORD2
setProtocolMode KEYWORD2
####################################################
# Syntax Coloring Map For PS Buzz Library
####################################################
####################################################
# Datatypes (KEYWORD1)
####################################################
PSBuzz KEYWORD1
####################################################
# Methods and Functions (KEYWORD2)
####################################################
setLedOnAll KEYWORD2
setLedOffAll KEYWORD2
####################################################
# Constants and enums (LITERAL1)
####################################################
RED LITERAL1
YELLOW LITERAL1
GREEN LITERAL1
ORANGE LITERAL1
BLUE LITERAL1