parent
8c88c19cb1
commit
bc2516607e
@ -0,0 +1,37 @@
|
|||||||
|
keyboardio.name=Keyboardio Model 00
|
||||||
|
keyboardio.upload.protocol=avr109
|
||||||
|
keyboardio.upload.maximum_size=28672
|
||||||
|
keyboardio.upload.speed=57600
|
||||||
|
keyboardio.upload.disable_flushing=true
|
||||||
|
keyboardio.bootloader.low_fuses=0xff
|
||||||
|
keyboardio.bootloader.high_fuses=0xd8
|
||||||
|
keyboardio.bootloader.extended_fuses=0xcb
|
||||||
|
keyboardio.bootloader.path=caterina
|
||||||
|
keyboardio.bootloader.file=Caterina-keyboardio.hex
|
||||||
|
keyboardio.bootloader.unlock_bits=0x3F
|
||||||
|
keyboardio.bootloader.lock_bits=0x2F
|
||||||
|
keyboardio.build.mcu=atmega32u4
|
||||||
|
keyboardio.build.f_cpu=16000000L
|
||||||
|
keyboardio.build.vid=0x2341
|
||||||
|
keyboardio.build.pid=0x8037
|
||||||
|
keyboardio.build.core=keyboardio
|
||||||
|
keyboardio.build.variant=model00
|
||||||
|
|
||||||
|
symmetric60.name=Keyboardio Symmetric 60
|
||||||
|
symmetric60.upload.protocol=avr109
|
||||||
|
symmetric60.upload.maximum_size=28672
|
||||||
|
symmetric60.upload.speed=57600
|
||||||
|
symmetric60.upload.disable_flushing=true
|
||||||
|
symmetric60.bootloader.low_fuses=0xff
|
||||||
|
symmetric60.bootloader.high_fuses=0xd8
|
||||||
|
symmetric60.bootloader.extended_fuses=0xcb
|
||||||
|
symmetric60.bootloader.path=caterina
|
||||||
|
symmetric60.bootloader.file=Caterina-symmetric60.hex
|
||||||
|
symmetric60.bootloader.unlock_bits=0x3F
|
||||||
|
symmetric60.bootloader.lock_bits=0x2F
|
||||||
|
symmetric60.build.mcu=atmega32u4
|
||||||
|
symmetric60.build.f_cpu=16000000L
|
||||||
|
symmetric60.build.vid=0x2341
|
||||||
|
symmetric60.build.pid=0x8037
|
||||||
|
symmetric60.build.core=keyboardio
|
||||||
|
symmetric60.build.variant=symmetric60
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
Client.h - Base class that provides Client
|
||||||
|
Copyright (c) 2011 Adrian McEwen. All right reserved.
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef client_h
|
||||||
|
#define client_h
|
||||||
|
#include "Print.h"
|
||||||
|
#include "Stream.h"
|
||||||
|
#include "IPAddress.h"
|
||||||
|
|
||||||
|
class Client : public Stream {
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual int connect(IPAddress ip, uint16_t port) =0;
|
||||||
|
virtual int connect(const char *host, uint16_t port) =0;
|
||||||
|
virtual size_t write(uint8_t) =0;
|
||||||
|
virtual size_t write(const uint8_t *buf, size_t size) =0;
|
||||||
|
virtual int available() = 0;
|
||||||
|
virtual int read() = 0;
|
||||||
|
virtual int read(uint8_t *buf, size_t size) = 0;
|
||||||
|
virtual int peek() = 0;
|
||||||
|
virtual void flush() = 0;
|
||||||
|
virtual void stop() = 0;
|
||||||
|
virtual uint8_t connected() = 0;
|
||||||
|
virtual operator bool() = 0;
|
||||||
|
protected:
|
||||||
|
uint8_t* rawIPAddress(IPAddress& addr) { return addr.raw_address(); };
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,803 @@
|
|||||||
|
|
||||||
|
|
||||||
|
/* Copyright (c) 2011, Peter Barrett
|
||||||
|
**
|
||||||
|
** Sleep/Wakeup/SystemControl support added by Michael Dreher
|
||||||
|
**
|
||||||
|
** Permission to use, copy, modify, and/or distribute this software for
|
||||||
|
** any purpose with or without fee is hereby granted, provided that the
|
||||||
|
** above copyright notice and this permission notice appear in all copies.
|
||||||
|
**
|
||||||
|
** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
|
||||||
|
** WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
|
||||||
|
** WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR
|
||||||
|
** BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
|
||||||
|
** OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||||
|
** WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
||||||
|
** ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||||
|
** SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "USBAPI.h"
|
||||||
|
#include "USBDesc.h"
|
||||||
|
#include "HIDTables.h"
|
||||||
|
|
||||||
|
#if defined(USBCON)
|
||||||
|
#ifdef HID_ENABLED
|
||||||
|
#define HID_MOUSE_ABS_ENABLED
|
||||||
|
//#define RAWHID_ENABLED
|
||||||
|
|
||||||
|
// Singletons for mouse and keyboard
|
||||||
|
|
||||||
|
Mouse_ Mouse;
|
||||||
|
Keyboard_ Keyboard;
|
||||||
|
|
||||||
|
//================================================================================
|
||||||
|
//================================================================================
|
||||||
|
|
||||||
|
// HID report descriptor
|
||||||
|
|
||||||
|
#define LSB(_x) ((_x) & 0xFF)
|
||||||
|
#define MSB(_x) ((_x) >> 8)
|
||||||
|
|
||||||
|
#define RAWHID_USAGE_PAGE 0xFFC0
|
||||||
|
#define RAWHID_USAGE 0x0C00
|
||||||
|
#define RAWHID_TX_SIZE 64
|
||||||
|
#define RAWHID_RX_SIZE 64
|
||||||
|
|
||||||
|
#define HID_REPORTID_KEYBOARD (1)
|
||||||
|
#define HID_REPORTID_MOUSE (2)
|
||||||
|
#define HID_REPORTID_MOUSE_ABS (3)
|
||||||
|
#define HID_REPORTID_SYSTEMCONTROL (4)
|
||||||
|
#define HID_REPORTID_CONSUMERCONTROL (5)
|
||||||
|
#define HID_REPORTID_RAWHID (6)
|
||||||
|
|
||||||
|
#define HID_REPORT_KEYBOARD /* Keyboard */ \
|
||||||
|
0x05, 0x01, /* USAGE_PAGE (Generic Desktop) 47 */ \
|
||||||
|
0x09, 0x06, /* USAGE (Keyboard) */ \
|
||||||
|
0xa1, 0x01, /* COLLECTION (Application) */ \
|
||||||
|
0x85, HID_REPORTID_KEYBOARD, /* REPORT_ID */ \
|
||||||
|
0x05, 0x07, /* USAGE_PAGE (Keyboard) */ \
|
||||||
|
\
|
||||||
|
/* Keyboard Modifiers (shift, alt, ...) */ \
|
||||||
|
0x19, 0xe0, /* USAGE_MINIMUM (Keyboard LeftControl) */ \
|
||||||
|
0x29, 0xe7, /* USAGE_MAXIMUM (Keyboard Right GUI) */ \
|
||||||
|
0x15, 0x00, /* LOGICAL_MINIMUM (0) */ \
|
||||||
|
0x25, 0x01, /* LOGICAL_MAXIMUM (1) */ \
|
||||||
|
0x75, 0x01, /* REPORT_SIZE (1) */ \
|
||||||
|
\
|
||||||
|
0x95, 0x08, /* REPORT_COUNT (8) */ \
|
||||||
|
0x81, 0x02, /* INPUT (Data,Var,Abs) */ \
|
||||||
|
0x95, 0x01, /* REPORT_COUNT (1) */ \
|
||||||
|
0x75, 0x08, /* REPORT_SIZE (8) */ \
|
||||||
|
0x81, 0x03, /* INPUT (Cnst,Var,Abs) */ \
|
||||||
|
\
|
||||||
|
/* Keyboard keys */ \
|
||||||
|
0x95, 0x06, /* REPORT_COUNT (6) */ \
|
||||||
|
0x75, 0x08, /* REPORT_SIZE (8) */ \
|
||||||
|
0x15, 0x00, /* LOGICAL_MINIMUM (0) */ \
|
||||||
|
0x26, 0xDF, 0x00, /* LOGICAL_MAXIMUM (239) */ \
|
||||||
|
0x05, 0x07, /* USAGE_PAGE (Keyboard) */ \
|
||||||
|
0x19, 0x00, /* USAGE_MINIMUM (Reserved (no event indicated)) */ \
|
||||||
|
0x29, 0xDF, /* USAGE_MAXIMUM (Left Control - 1) */ \
|
||||||
|
0x81, 0x00, /* INPUT (Data,Ary,Abs) */ \
|
||||||
|
0xc0 /* END_COLLECTION */
|
||||||
|
|
||||||
|
#define HID_REPORT_MOUSE_ABSOLUTE /* Mouse absolute */ \
|
||||||
|
0x05, 0x01, /* USAGE_PAGE (Generic Desktop) */ \
|
||||||
|
0x09, 0x02, /* USAGE (Mouse) */ \
|
||||||
|
0xa1, 0x01, /* COLLECTION (Application) */ \
|
||||||
|
0x09, 0x01, /* USAGE (Pointer) */ \
|
||||||
|
0xa1, 0x00, /* COLLECTION (Physical) */ \
|
||||||
|
0x85, HID_REPORTID_MOUSE_ABS, /* REPORT_ID */ \
|
||||||
|
0x05, 0x09, /* USAGE_PAGE (Button) */ \
|
||||||
|
0x19, 0x01, /* USAGE_MINIMUM (Button 1) */ \
|
||||||
|
0x29, 0x03, /* USAGE_MAXIMUM (Button 3) */ \
|
||||||
|
0x15, 0x00, /* LOGICAL_MINIMUM (0) */ \
|
||||||
|
0x25, 0x01, /* LOGICAL_MAXIMUM (1) */ \
|
||||||
|
0x95, 0x03, /* REPORT_COUNT (3) */ \
|
||||||
|
0x75, 0x01, /* REPORT_SIZE (1) */ \
|
||||||
|
0x81, 0x02, /* INPUT (Data,Var,Abs) */ \
|
||||||
|
0x95, 0x01, /* REPORT_COUNT (1) */ \
|
||||||
|
0x75, 0x05, /* REPORT_SIZE (5) */ \
|
||||||
|
0x81, 0x03, /* INPUT (Cnst,Var,Abs) */ \
|
||||||
|
0x05, 0x01, /* USAGE_PAGE (Generic Desktop) */ \
|
||||||
|
0x09, 0x30, /* USAGE (X) */ \
|
||||||
|
0x09, 0x31, /* USAGE (Y) */ \
|
||||||
|
0x15, 0x00, /* LOGICAL_MINIMUM (0) */ \
|
||||||
|
0x26, 0xff, 0x7f, /* LOGICAL_MAXIMUM (32767) */ \
|
||||||
|
0x75, 0x10, /* REPORT_SIZE (16) */ \
|
||||||
|
0x95, 0x02, /* REPORT_COUNT (2) */ \
|
||||||
|
0x81, 0x02, /* INPUT (Data,Var,Abs) */ \
|
||||||
|
0xc0, /* END_COLLECTION */ \
|
||||||
|
0xc0 /* END_COLLECTION */
|
||||||
|
|
||||||
|
#define HID_REPORT_MOUSE_RELATIVE /* Mouse relative */ \
|
||||||
|
0x05, 0x01, /* USAGE_PAGE (Generic Desktop) 54 */ \
|
||||||
|
0x09, 0x02, /* USAGE (Mouse) */ \
|
||||||
|
0xa1, 0x01, /* COLLECTION (Application) */ \
|
||||||
|
0x09, 0x01, /* USAGE (Pointer) */ \
|
||||||
|
0xa1, 0x00, /* COLLECTION (Physical) */ \
|
||||||
|
0x85, HID_REPORTID_MOUSE, /* REPORT_ID */ \
|
||||||
|
0x05, 0x09, /* USAGE_PAGE (Button) */ \
|
||||||
|
0x19, 0x01, /* USAGE_MINIMUM (Button 1) */ \
|
||||||
|
0x29, 0x05, /* USAGE_MAXIMUM (Button 5) */ \
|
||||||
|
0x15, 0x00, /* LOGICAL_MINIMUM (0) */ \
|
||||||
|
0x25, 0x01, /* LOGICAL_MAXIMUM (1) */ \
|
||||||
|
0x95, 0x05, /* REPORT_COUNT (5) */ \
|
||||||
|
0x75, 0x01, /* REPORT_SIZE (1) */ \
|
||||||
|
0x81, 0x02, /* INPUT (Data,Var,Abs) */ \
|
||||||
|
0x95, 0x01, /* REPORT_COUNT (1) */ \
|
||||||
|
0x75, 0x03, /* REPORT_SIZE (3) */ \
|
||||||
|
0x81, 0x01, /* INPUT (Cnst,Var,Abs) */ \
|
||||||
|
0x05, 0x01, /* USAGE_PAGE (Generic Desktop) */ \
|
||||||
|
0x09, 0x30, /* USAGE (X) */ \
|
||||||
|
0x09, 0x31, /* USAGE (Y) */ \
|
||||||
|
0x09, 0x38, /* USAGE (Wheel) */ \
|
||||||
|
0x15, 0x81, /* LOGICAL_MINIMUM (-127) */ \
|
||||||
|
0x25, 0x7f, /* LOGICAL_MAXIMUM (127) */ \
|
||||||
|
0x75, 0x08, /* REPORT_SIZE (8) */ \
|
||||||
|
0x95, 0x03, /* REPORT_COUNT (3) */ \
|
||||||
|
0x81, 0x06, /* INPUT (Data,Var,Rel) */ \
|
||||||
|
0xc0, /* END_COLLECTION */ \
|
||||||
|
0xc0 /* END_COLLECTION */
|
||||||
|
|
||||||
|
#define HID_REPORT_SYSTEMCONTROL /* System Control (Power Down, Sleep, Wakeup, ...) */ \
|
||||||
|
0x05, 0x01, /* USAGE_PAGE (Generic Desktop) */ \
|
||||||
|
0x09, 0x80, /* USAGE (System Control) */ \
|
||||||
|
0xa1, 0x01, /* COLLECTION (Application) */ \
|
||||||
|
0x85, HID_REPORTID_SYSTEMCONTROL, /* REPORT_ID */ \
|
||||||
|
0x09, 0x81, /* USAGE (System Power Down) */ \
|
||||||
|
0x09, 0x82, /* USAGE (System Sleep) */ \
|
||||||
|
0x09, 0x83, /* USAGE (System Wakeup) */ \
|
||||||
|
0x09, 0x8E, /* USAGE (System Cold Restart) */ \
|
||||||
|
0x09, 0x8F, /* USAGE (System Warm Restart) */ \
|
||||||
|
0x09, 0xA0, /* USAGE (System Dock) */ \
|
||||||
|
0x09, 0xA1, /* USAGE (System Undock) */ \
|
||||||
|
0x09, 0xA7, /* USAGE (System Speaker Mute) */ \
|
||||||
|
0x09, 0xA8, /* USAGE (System Hibernate) */ \
|
||||||
|
/* although these display usages are not that important, they don't cost */ \
|
||||||
|
/* much more than declaring the otherwise necessary constant fill bits */ \
|
||||||
|
0x09, 0xB0, /* USAGE (System Display Invert) */ \
|
||||||
|
0x09, 0xB1, /* USAGE (System Display Internal) */ \
|
||||||
|
0x09, 0xB2, /* USAGE (System Display External) */ \
|
||||||
|
0x09, 0xB3, /* USAGE (System Display Both) */ \
|
||||||
|
0x09, 0xB4, /* USAGE (System Display Dual) */ \
|
||||||
|
0x09, 0xB5, /* USAGE (System Display Toggle Intern/Extern) */ \
|
||||||
|
0x09, 0xB6, /* USAGE (System Display Swap) */ \
|
||||||
|
0x15, 0x00, /* LOGICAL_MINIMUM (0) */ \
|
||||||
|
0x25, 0x01, /* LOGICAL_MAXIMUM (1) */ \
|
||||||
|
0x75, 0x01, /* REPORT_SIZE (1) */ \
|
||||||
|
0x95, 0x10, /* REPORT_COUNT (16) */ \
|
||||||
|
0x81, 0x02, /* INPUT (Data,Var,Abs) */ \
|
||||||
|
0xc0 /* END_COLLECTION */
|
||||||
|
|
||||||
|
#define HID_REPORT_CONSUMERCONTROL /* Consumer Control (Sound/Media keys) */ \
|
||||||
|
0x05, 0x0c, /* USAGE_PAGE (Consumer Devices) */ \
|
||||||
|
0x09, 0x01, /* USAGE (Consumer Control) */ \
|
||||||
|
0xa1, 0x01, /* COLLECTION (Application) */ \
|
||||||
|
0x85, HID_REPORTID_CONSUMERCONTROL, /* REPORT_ID */ \
|
||||||
|
0x15, 0x00, /* LOGICAL_MINIMUM (0) */ \
|
||||||
|
0x25, 0x01, /* LOGICAL_MAXIMUM (1) */ \
|
||||||
|
0x75, 0x01, /* REPORT_SIZE (1) */ \
|
||||||
|
0x95, 0x08, /* REPORT_COUNT (8) */ \
|
||||||
|
0x09, 0xe2, /* USAGE (Mute) 0x01 */ \
|
||||||
|
0x09, 0xe9, /* USAGE (Volume Up) 0x02 */ \
|
||||||
|
0x09, 0xea, /* USAGE (Volume Down) 0x03 */ \
|
||||||
|
0x09, 0xcd, /* USAGE (Play/Pause) 0x04 */ \
|
||||||
|
0x09, 0xb7, /* USAGE (Stop) 0x05 */ \
|
||||||
|
0x09, 0xb6, /* USAGE (Scan Previous Track) 0x06 */ \
|
||||||
|
0x09, 0xb5, /* USAGE (Scan Next Track) 0x07 */ \
|
||||||
|
0x09, 0xb8, /* USAGE (Eject) 0x08 */ \
|
||||||
|
0x81, 0x02, /* INPUT (Data,Var,Abs) */ \
|
||||||
|
0xc0
|
||||||
|
|
||||||
|
#define HID_REPORT_RAWHID /* RAW HID */ \
|
||||||
|
0x06, LSB(RAWHID_USAGE_PAGE), MSB(RAWHID_USAGE_PAGE), /* 30 */ \
|
||||||
|
0x0A, LSB(RAWHID_USAGE), MSB(RAWHID_USAGE), \
|
||||||
|
\
|
||||||
|
0xA1, 0x01, /* Collection 0x01 */ \
|
||||||
|
0x85, HID_REPORTID_RAWHID, /* REPORT_ID */ \
|
||||||
|
0x75, 0x08, /* report size = 8 bits */ \
|
||||||
|
0x15, 0x00, /* logical minimum = 0 */ \
|
||||||
|
0x26, 0xFF, 0x00, /* logical maximum = 255 */ \
|
||||||
|
\
|
||||||
|
0x95, 64, /* report count TX */ \
|
||||||
|
0x09, 0x01, /* usage */ \
|
||||||
|
0x81, 0x02, /* Input (array) */ \
|
||||||
|
\
|
||||||
|
0x95, 64, /* report count RX */ \
|
||||||
|
0x09, 0x02, /* usage */ \
|
||||||
|
0x91, 0x02, /* Output (array) */ \
|
||||||
|
0xC0 /* end collection */
|
||||||
|
|
||||||
|
extern const u8 _hidReportDescriptor[] PROGMEM;
|
||||||
|
const u8 _hidReportDescriptor[] = {
|
||||||
|
|
||||||
|
HID_REPORT_KEYBOARD,
|
||||||
|
HID_REPORT_MOUSE_RELATIVE,
|
||||||
|
#ifdef HID_MOUSE_ABS_ENABLED
|
||||||
|
HID_REPORT_MOUSE_ABSOLUTE,
|
||||||
|
#endif
|
||||||
|
HID_REPORT_SYSTEMCONTROL,
|
||||||
|
HID_REPORT_CONSUMERCONTROL,
|
||||||
|
#if RAWHID_ENABLED
|
||||||
|
HID_REPORT_RAWHID
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
extern const HIDDescriptor _hidInterface PROGMEM;
|
||||||
|
const HIDDescriptor _hidInterface =
|
||||||
|
{
|
||||||
|
D_INTERFACE(HID_INTERFACE,1,3,0,0),
|
||||||
|
D_HIDREPORT(sizeof(_hidReportDescriptor)),
|
||||||
|
D_ENDPOINT(USB_ENDPOINT_IN (HID_ENDPOINT_INT),USB_ENDPOINT_TYPE_INTERRUPT,0x40,0x01)
|
||||||
|
};
|
||||||
|
|
||||||
|
//================================================================================
|
||||||
|
//================================================================================
|
||||||
|
// Driver
|
||||||
|
|
||||||
|
u8 _hid_protocol = 1;
|
||||||
|
u8 _hid_idle = 1;
|
||||||
|
|
||||||
|
#define WEAK __attribute__ ((weak))
|
||||||
|
|
||||||
|
int WEAK HID_GetInterface(u8* interfaceNum)
|
||||||
|
{
|
||||||
|
interfaceNum[0] += 1; // uses 1
|
||||||
|
return USB_SendControl(TRANSFER_PGM,&_hidInterface,sizeof(_hidInterface));
|
||||||
|
}
|
||||||
|
|
||||||
|
int WEAK HID_GetDescriptor(int /* i */)
|
||||||
|
{
|
||||||
|
return USB_SendControl(TRANSFER_PGM,_hidReportDescriptor,sizeof(_hidReportDescriptor));
|
||||||
|
}
|
||||||
|
|
||||||
|
void WEAK HID_SendReport(u8 id, const void* data, int len)
|
||||||
|
{
|
||||||
|
USB_Send(HID_TX, &id, 1);
|
||||||
|
USB_Send(HID_TX | TRANSFER_RELEASE,data,len);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WEAK HID_Setup(Setup& setup)
|
||||||
|
{
|
||||||
|
u8 r = setup.bRequest;
|
||||||
|
u8 requestType = setup.bmRequestType;
|
||||||
|
if (REQUEST_DEVICETOHOST_CLASS_INTERFACE == requestType)
|
||||||
|
{
|
||||||
|
if (HID_GET_REPORT == r)
|
||||||
|
{
|
||||||
|
//HID_GetReport();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (HID_GET_PROTOCOL == r)
|
||||||
|
{
|
||||||
|
//Send8(_hid_protocol); // TODO
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (REQUEST_HOSTTODEVICE_CLASS_INTERFACE == requestType)
|
||||||
|
{
|
||||||
|
if (HID_SET_PROTOCOL == r)
|
||||||
|
{
|
||||||
|
_hid_protocol = setup.wValueL;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (HID_SET_IDLE == r)
|
||||||
|
{
|
||||||
|
_hid_idle = setup.wValueL;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//================================================================================
|
||||||
|
//================================================================================
|
||||||
|
// Mouse
|
||||||
|
|
||||||
|
Mouse_::Mouse_(void) : _buttons(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Mouse_::begin(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Mouse_::end(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Mouse_::click(uint8_t b)
|
||||||
|
{
|
||||||
|
_buttons = b;
|
||||||
|
move(0,0,0);
|
||||||
|
_buttons = 0;
|
||||||
|
move(0,0,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Mouse_::move(signed char x, signed char y, signed char wheel)
|
||||||
|
{
|
||||||
|
u8 m[4];
|
||||||
|
m[0] = _buttons;
|
||||||
|
m[1] = x;
|
||||||
|
m[2] = y;
|
||||||
|
m[3] = wheel;
|
||||||
|
HID_SendReport(HID_REPORTID_MOUSE,m,sizeof(m));
|
||||||
|
}
|
||||||
|
|
||||||
|
// X and Y have the range of 0 to 32767.
|
||||||
|
// The USB Host will convert them to pixels on the screen.
|
||||||
|
//
|
||||||
|
// x=0,y=0 is top-left corner of the screen
|
||||||
|
// x=32767,y=0 is the top right corner
|
||||||
|
// x=32767,y=32767 is the bottom right corner
|
||||||
|
// x=0,y=32767 is the bottom left corner
|
||||||
|
//
|
||||||
|
// When converting these coordinates to pixels on screen, Mac OS X's
|
||||||
|
// default HID driver maps the inner 85% of the coordinate space to
|
||||||
|
// the screen's physical dimensions. This means that any value between
|
||||||
|
// 0 and 2293 or 30474 and 32767 will move the mouse to the screen
|
||||||
|
// edge on a Mac
|
||||||
|
//
|
||||||
|
// For details, see:
|
||||||
|
// http://lists.apple.com/archives/usb/2011/Jun/msg00032.html
|
||||||
|
|
||||||
|
|
||||||
|
void Mouse_::moveAbsolute(uint16_t x, uint16_t y)
|
||||||
|
{
|
||||||
|
u8 m[5];
|
||||||
|
m[0] = _buttons;
|
||||||
|
m[1] = LSB(x);
|
||||||
|
m[2] = MSB(x);
|
||||||
|
m[3] = LSB(y);
|
||||||
|
m[4] = MSB(y);
|
||||||
|
HID_SendReport(HID_REPORTID_MOUSE_ABS,m,sizeof(m));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Mouse_::buttons(uint8_t b)
|
||||||
|
{
|
||||||
|
if (b != _buttons)
|
||||||
|
{
|
||||||
|
_buttons = b;
|
||||||
|
move(0,0,0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Mouse_::press(uint8_t b)
|
||||||
|
{
|
||||||
|
buttons(_buttons | b);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Mouse_::release(uint8_t b)
|
||||||
|
{
|
||||||
|
buttons(_buttons & ~b);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Mouse_::isPressed(uint8_t b)
|
||||||
|
{
|
||||||
|
if ((b & _buttons) > 0)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//================================================================================
|
||||||
|
//================================================================================
|
||||||
|
// Keyboard
|
||||||
|
|
||||||
|
Keyboard_::Keyboard_(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Keyboard_::begin(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Keyboard_::end(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Keyboard_::sendReport(KeyReport* keys)
|
||||||
|
{
|
||||||
|
HID_SendReport(HID_REPORTID_KEYBOARD,keys,sizeof(*keys));
|
||||||
|
}
|
||||||
|
|
||||||
|
extern
|
||||||
|
const uint8_t _asciimap[128] PROGMEM;
|
||||||
|
|
||||||
|
#define SHIFT 0x80
|
||||||
|
const uint8_t _asciimap[128] =
|
||||||
|
{
|
||||||
|
0x00, // NUL
|
||||||
|
0x00, // SOH
|
||||||
|
0x00, // STX
|
||||||
|
0x00, // ETX
|
||||||
|
0x00, // EOT
|
||||||
|
0x00, // ENQ
|
||||||
|
0x00, // ACK
|
||||||
|
0x00, // BEL
|
||||||
|
0x2a, // BS Backspace
|
||||||
|
0x2b, // TAB Tab
|
||||||
|
0x28, // LF Enter
|
||||||
|
0x00, // VT
|
||||||
|
0x00, // FF
|
||||||
|
0x00, // CR
|
||||||
|
0x00, // SO
|
||||||
|
0x00, // SI
|
||||||
|
0x00, // DEL
|
||||||
|
0x00, // DC1
|
||||||
|
0x00, // DC2
|
||||||
|
0x00, // DC3
|
||||||
|
0x00, // DC4
|
||||||
|
0x00, // NAK
|
||||||
|
0x00, // SYN
|
||||||
|
0x00, // ETB
|
||||||
|
0x00, // CAN
|
||||||
|
0x00, // EM
|
||||||
|
0x00, // SUB
|
||||||
|
0x00, // ESC
|
||||||
|
0x00, // FS
|
||||||
|
0x00, // GS
|
||||||
|
0x00, // RS
|
||||||
|
0x00, // US
|
||||||
|
|
||||||
|
0x2c, // ' '
|
||||||
|
0x1e|SHIFT, // !
|
||||||
|
0x34|SHIFT, // "
|
||||||
|
0x20|SHIFT, // #
|
||||||
|
0x21|SHIFT, // $
|
||||||
|
0x22|SHIFT, // %
|
||||||
|
0x24|SHIFT, // &
|
||||||
|
0x34, // '
|
||||||
|
0x26|SHIFT, // (
|
||||||
|
0x27|SHIFT, // )
|
||||||
|
0x25|SHIFT, // *
|
||||||
|
0x2e|SHIFT, // +
|
||||||
|
0x36, // ,
|
||||||
|
0x2d, // -
|
||||||
|
0x37, // .
|
||||||
|
0x38, // /
|
||||||
|
0x27, // 0
|
||||||
|
0x1e, // 1
|
||||||
|
0x1f, // 2
|
||||||
|
0x20, // 3
|
||||||
|
0x21, // 4
|
||||||
|
0x22, // 5
|
||||||
|
0x23, // 6
|
||||||
|
0x24, // 7
|
||||||
|
0x25, // 8
|
||||||
|
0x26, // 9
|
||||||
|
0x33|SHIFT, // :
|
||||||
|
0x33, // ;
|
||||||
|
0x36|SHIFT, // <
|
||||||
|
0x2e, // =
|
||||||
|
0x37|SHIFT, // >
|
||||||
|
0x38|SHIFT, // ?
|
||||||
|
0x1f|SHIFT, // @
|
||||||
|
0x04|SHIFT, // A
|
||||||
|
0x05|SHIFT, // B
|
||||||
|
0x06|SHIFT, // C
|
||||||
|
0x07|SHIFT, // D
|
||||||
|
0x08|SHIFT, // E
|
||||||
|
0x09|SHIFT, // F
|
||||||
|
0x0a|SHIFT, // G
|
||||||
|
0x0b|SHIFT, // H
|
||||||
|
0x0c|SHIFT, // I
|
||||||
|
0x0d|SHIFT, // J
|
||||||
|
0x0e|SHIFT, // K
|
||||||
|
0x0f|SHIFT, // L
|
||||||
|
0x10|SHIFT, // M
|
||||||
|
0x11|SHIFT, // N
|
||||||
|
0x12|SHIFT, // O
|
||||||
|
0x13|SHIFT, // P
|
||||||
|
0x14|SHIFT, // Q
|
||||||
|
0x15|SHIFT, // R
|
||||||
|
0x16|SHIFT, // S
|
||||||
|
0x17|SHIFT, // T
|
||||||
|
0x18|SHIFT, // U
|
||||||
|
0x19|SHIFT, // V
|
||||||
|
0x1a|SHIFT, // W
|
||||||
|
0x1b|SHIFT, // X
|
||||||
|
0x1c|SHIFT, // Y
|
||||||
|
0x1d|SHIFT, // Z
|
||||||
|
0x2f, // [
|
||||||
|
0x31, // bslash
|
||||||
|
0x30, // ]
|
||||||
|
0x23|SHIFT, // ^
|
||||||
|
0x2d|SHIFT, // _
|
||||||
|
0x35, // `
|
||||||
|
0x04, // a
|
||||||
|
0x05, // b
|
||||||
|
0x06, // c
|
||||||
|
0x07, // d
|
||||||
|
0x08, // e
|
||||||
|
0x09, // f
|
||||||
|
0x0a, // g
|
||||||
|
0x0b, // h
|
||||||
|
0x0c, // i
|
||||||
|
0x0d, // j
|
||||||
|
0x0e, // k
|
||||||
|
0x0f, // l
|
||||||
|
0x10, // m
|
||||||
|
0x11, // n
|
||||||
|
0x12, // o
|
||||||
|
0x13, // p
|
||||||
|
0x14, // q
|
||||||
|
0x15, // r
|
||||||
|
0x16, // s
|
||||||
|
0x17, // t
|
||||||
|
0x18, // u
|
||||||
|
0x19, // v
|
||||||
|
0x1a, // w
|
||||||
|
0x1b, // x
|
||||||
|
0x1c, // y
|
||||||
|
0x1d, // z
|
||||||
|
0x2f|SHIFT, //
|
||||||
|
0x31|SHIFT, // |
|
||||||
|
0x30|SHIFT, // }
|
||||||
|
0x35|SHIFT, // ~
|
||||||
|
0 // DEL
|
||||||
|
};
|
||||||
|
|
||||||
|
uint8_t USBPutChar(uint8_t c);
|
||||||
|
|
||||||
|
|
||||||
|
// pressKeycode() adds the specified key (printing, non-printing, or modifier)
|
||||||
|
// to the persistent key report and sends the report. Because of the way
|
||||||
|
// USB HID works, the host acts like the key remains pressed until we
|
||||||
|
// call releaseKeycode(), releaseAll(), or otherwise clear the report and resend.
|
||||||
|
size_t Keyboard_::pressKeycode(uint8_t k)
|
||||||
|
{
|
||||||
|
if (!addKeycodeToReport(k)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
sendReport(&_keyReport);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t Keyboard_::addKeycodeToReport(uint8_t k)
|
||||||
|
{
|
||||||
|
uint8_t index = 0;
|
||||||
|
uint8_t done = 0;
|
||||||
|
|
||||||
|
if ((k >= HID_KEYBOARD_LEFT_CONTROL) && (k <= HID_KEYBOARD_RIGHT_GUI)) {
|
||||||
|
// it's a modifier key
|
||||||
|
_keyReport.modifiers |= (0x01 << (k - HID_KEYBOARD_LEFT_CONTROL));
|
||||||
|
} else {
|
||||||
|
// it's some other key:
|
||||||
|
// Add k to the key report only if it's not already present
|
||||||
|
// and if there is an empty slot.
|
||||||
|
for (index = 0; index < KEYREPORT_KEYCOUNT; index++) {
|
||||||
|
if (_keyReport.keys[index] != k) { // is k already in list?
|
||||||
|
if (0 == _keyReport.keys[index]) { // have we found an empty slot?
|
||||||
|
_keyReport.keys[index] = k;
|
||||||
|
done = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
done = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// use separate variable to check if slot was found
|
||||||
|
// for style reasons - we do not know how the compiler
|
||||||
|
// handles the for() index when it leaves the loop
|
||||||
|
if (0 == done) {
|
||||||
|
setWriteError();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// press() transforms the given key to the actual keycode and calls
|
||||||
|
// pressKeycode() to actually press this key.
|
||||||
|
//
|
||||||
|
size_t Keyboard_::press(uint8_t k)
|
||||||
|
{
|
||||||
|
if (k >= KEY_RIGHT_GUI + 1) {
|
||||||
|
// it's a non-printing key (not a modifier)
|
||||||
|
k = k - (KEY_RIGHT_GUI + 1);
|
||||||
|
} else {
|
||||||
|
if (k >= KEY_LEFT_CTRL) {
|
||||||
|
// it's a modifier key
|
||||||
|
k = k - KEY_LEFT_CTRL + HID_KEYBOARD_LEFT_CONTROL;
|
||||||
|
} else {
|
||||||
|
k = pgm_read_byte(_asciimap + k);
|
||||||
|
if (k) {
|
||||||
|
if (k & SHIFT) {
|
||||||
|
// it's a capital letter or other character reached with shift
|
||||||
|
// the left shift modifier
|
||||||
|
addKeycodeToReport(HID_KEYBOARD_LEFT_SHIFT);
|
||||||
|
k = k ^ SHIFT;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pressKeycode(k);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// System Control
|
||||||
|
// k is one of the SYSTEM_CONTROL defines which come from the HID usage table "Generic Desktop Page (0x01)"
|
||||||
|
// in "HID Usage Tables" (HUT1_12v2.pdf)
|
||||||
|
size_t Keyboard_::systemControl(uint8_t k)
|
||||||
|
{
|
||||||
|
if(k <= 16)
|
||||||
|
{
|
||||||
|
u16 mask = 0;
|
||||||
|
u8 m[2];
|
||||||
|
|
||||||
|
if(k > 0)
|
||||||
|
{
|
||||||
|
mask = 1 << (k - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
m[0] = LSB(mask);
|
||||||
|
m[1] = MSB(mask);
|
||||||
|
HID_SendReport(HID_REPORTID_SYSTEMCONTROL,m,sizeof(m));
|
||||||
|
|
||||||
|
// these are all OSCs, so send a clear to make it possible to send it again later
|
||||||
|
m[0] = 0;
|
||||||
|
m[1] = 0;
|
||||||
|
HID_SendReport(HID_REPORTID_SYSTEMCONTROL,m,sizeof(m));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setWriteError();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Consumer Control
|
||||||
|
// k is one of the CONSUMER_CONTROL defines which come from the HID usage table "Consumer Devices Page (0x0c)"
|
||||||
|
// in "HID Usage Tables" (HUT1_12v2.pdf)
|
||||||
|
size_t Keyboard_::consumerControl(uint8_t k)
|
||||||
|
{
|
||||||
|
if(k <= 8)
|
||||||
|
{
|
||||||
|
u16 mask = 0;
|
||||||
|
u8 m[2];
|
||||||
|
|
||||||
|
if(k > 0)
|
||||||
|
{
|
||||||
|
mask = 1 << (k - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
m[0] = LSB(mask);
|
||||||
|
m[1] = MSB(mask);
|
||||||
|
HID_SendReport(HID_REPORTID_CONSUMERCONTROL,m,sizeof(m));
|
||||||
|
|
||||||
|
// these are all OSCs, so send a clear to make it possible to send it again later
|
||||||
|
m[0] = 0;
|
||||||
|
m[1] = 0;
|
||||||
|
HID_SendReport(HID_REPORTID_CONSUMERCONTROL,m,sizeof(m));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setWriteError();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// releaseKeycode() takes the specified key out of the persistent key report and
|
||||||
|
// sends the report. This tells the OS the key is no longer pressed and that
|
||||||
|
// it shouldn't be repeated any more.
|
||||||
|
// When send is set to FALSE (= 0) no sendReport() is executed. This comes in
|
||||||
|
// handy when combining key releases (e.g. SHIFT+A).
|
||||||
|
size_t Keyboard_::releaseKeycode(uint8_t k)
|
||||||
|
{
|
||||||
|
if (!removeKeycodeFromReport(k)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
sendReport(&_keyReport);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t Keyboard_::removeKeycodeFromReport(uint8_t k)
|
||||||
|
{
|
||||||
|
uint8_t indexA;
|
||||||
|
uint8_t indexB;
|
||||||
|
uint8_t count;
|
||||||
|
|
||||||
|
if ((k >= HID_KEYBOARD_LEFT_CONTROL) && (k <= HID_KEYBOARD_RIGHT_GUI)) {
|
||||||
|
// it's a modifier key
|
||||||
|
_keyReport.modifiers = _keyReport.modifiers & (~(0x01 << (k - HID_KEYBOARD_LEFT_CONTROL)));
|
||||||
|
} else {
|
||||||
|
// it's some other key:
|
||||||
|
// Test the key report to see if k is present. Clear it if it exists.
|
||||||
|
// Check all positions in case the key is present more than once (which it shouldn't be)
|
||||||
|
for (indexA = 0; indexA < KEYREPORT_KEYCOUNT; indexA++) {
|
||||||
|
if (_keyReport.keys[indexA] == k) {
|
||||||
|
_keyReport.keys[indexA] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// finally rearrange the keys list so that the free (= 0x00) are at the
|
||||||
|
// end of the keys list - some implementations stop for keys at the
|
||||||
|
// first occurence of an 0x00 in the keys list
|
||||||
|
// so (0x00)(0x01)(0x00)(0x03)(0x02)(0x00) becomes
|
||||||
|
// (0x01)(0x03)(0x02)(0x00)(0x00)(0x00)
|
||||||
|
count = 0; // holds the number of zeros we've found
|
||||||
|
indexA = 0;
|
||||||
|
while ((indexA + count) < KEYREPORT_KEYCOUNT) {
|
||||||
|
if (0 == _keyReport.keys[indexA]) {
|
||||||
|
count++; // one more zero
|
||||||
|
for (indexB = indexA; indexB < KEYREPORT_KEYCOUNT-count; indexB++) {
|
||||||
|
_keyReport.keys[indexB] = _keyReport.keys[indexB+1];
|
||||||
|
}
|
||||||
|
_keyReport.keys[KEYREPORT_KEYCOUNT-count] = 0;
|
||||||
|
} else {
|
||||||
|
indexA++; // one more non-zero
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// release() transforms the given key to the actual keycode and calls
|
||||||
|
// releaseKeycode() to actually release this key.
|
||||||
|
//
|
||||||
|
size_t Keyboard_::release(uint8_t k)
|
||||||
|
{
|
||||||
|
uint8_t i;
|
||||||
|
|
||||||
|
if (k >= KEY_RIGHT_GUI + 1) {
|
||||||
|
// it's a non-printing key (not a modifier)
|
||||||
|
k = k - (KEY_RIGHT_GUI + 1);
|
||||||
|
} else {
|
||||||
|
if (k >= KEY_LEFT_CTRL) {
|
||||||
|
// it's a modifier key
|
||||||
|
k = k - KEY_LEFT_CTRL + HID_KEYBOARD_LEFT_CONTROL;
|
||||||
|
} else {
|
||||||
|
k = pgm_read_byte(_asciimap + k);
|
||||||
|
if (k) {
|
||||||
|
if ((k & SHIFT)) {
|
||||||
|
// it's a capital letter or other character reached with shift
|
||||||
|
// the left shift modifier
|
||||||
|
removeKeycodeFromReport(HID_KEYBOARD_LEFT_SHIFT);
|
||||||
|
k = k ^ SHIFT;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
releaseKeycode(k);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Keyboard_::releaseAll(void)
|
||||||
|
{
|
||||||
|
memset(&_keyReport, 0x00, sizeof(_keyReport));
|
||||||
|
sendReport(&_keyReport);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t Keyboard_::write(uint8_t c)
|
||||||
|
{
|
||||||
|
uint8_t p = press(c); // Keydown
|
||||||
|
release(c); // Keyup
|
||||||
|
return p; // just return the result of press() since release() almost always returns 1
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t Keyboard_::writeKeycode(uint8_t c)
|
||||||
|
{
|
||||||
|
uint8_t p = pressKeycode(c); // Keydown
|
||||||
|
releaseKeycode(c); // Keyup
|
||||||
|
return (p); // just return the result of pressKeycode() since release() almost always returns 1
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* if defined(USBCON) */
|
@ -0,0 +1,677 @@
|
|||||||
|
#ifndef __HIDTables__
|
||||||
|
#define HID___HIDTables__
|
||||||
|
|
||||||
|
|
||||||
|
// These mappings were extracted and transcribed from
|
||||||
|
// http://www.usb.org_SLASH_developers_SLASH_devclass_docs_SLASH_Hut1_12v2.pdf
|
||||||
|
//
|
||||||
|
// In most cases, I've preserved the "official" USB Implementers forum
|
||||||
|
// "Usage Name", though I've standardized some abbreviations and spacing
|
||||||
|
// that were inconsistent in the original specification. Non alpha-numeric
|
||||||
|
// characters in symbol names were converted into those characters' names.
|
||||||
|
//
|
||||||
|
// To match Arduino code style, all hid usage names are fully upper case.
|
||||||
|
//
|
||||||
|
// Not every HID usage listed in this file is currently supported by Arduino
|
||||||
|
// In particular, any System Control or Consumer Control entry that doesn't
|
||||||
|
// have a comment indicating that it's "HID type OSC" will require additional
|
||||||
|
// code in the Arduino core to work.
|
||||||
|
//
|
||||||
|
// Non-working usages are listed here in the interest of not having to manually
|
||||||
|
// convert more usage names each and every time our HID stack gets a little bit
|
||||||
|
// better.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// -- Jesse Vincent <jesse@keyboard.io>, January 2014
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// System control mappings
|
||||||
|
|
||||||
|
#define HID_SYSTEM_POWER_DOWN 0x81 // HID type OSC
|
||||||
|
#define HID_SYSTEM_SLEEP 0x82 // HID type OSC
|
||||||
|
#define HID_SYSTEM_WAKE_UP 0x83 // HID type OSC
|
||||||
|
#define HID_SYSTEM_CONTEXT_MENU 0x84 // HID type OSC
|
||||||
|
#define HID_SYSTEM_MAIN_MENU 0x85 // HID type OSC
|
||||||
|
#define HID_SYSTEM_APP_MENU 0x86 // HID type OSC
|
||||||
|
#define HID_SYSTEM_MENU_HELP 0x87 // HID type OSC
|
||||||
|
#define HID_SYSTEM_MENU_EXIT 0x88 // HID type OSC
|
||||||
|
#define HID_SYSTEM_MENU_SELECT 0x89 // HID type OSC
|
||||||
|
#define HID_SYSTEM_MENU_RIGHT 0x8A // HID type RTC
|
||||||
|
#define HID_SYSTEM_MENU_LEFT 0x8B // HID type RTC
|
||||||
|
#define HID_SYSTEM_MENU_UP 0x8C // HID type RTC
|
||||||
|
#define HID_SYSTEM_MENU_DOWN 0x8D // HID type RTC
|
||||||
|
#define HID_SYSTEM_COLD_RESTART 0x8E // HID type OSC
|
||||||
|
#define HID_SYSTEM_WARM_RESTART 0x8F // HID type OSC
|
||||||
|
#define HID_D_PAD_UP 0x90 // HID type OOC
|
||||||
|
#define HID_D_PAD_DOWN 0x91 // HID type OOC
|
||||||
|
#define HID_D_PAD_RIGHT 0x92 // HID type OOC
|
||||||
|
#define HID_D_PAD_LEFT 0x93 // HID type OOC
|
||||||
|
// 0x94-0x9F are reserved
|
||||||
|
#define HID_SYSTEM_DOCK 0xA0 // HID type OSC
|
||||||
|
#define HID_SYSTEM_UNDOCK 0xA1 // HID type OSC
|
||||||
|
#define HID_SYSTEM_SETUP 0xA2 // HID type OSC
|
||||||
|
#define HID_SYSTEM_BREAK 0xA3 // HID type OSC
|
||||||
|
#define HID_SYSTEM_DEBUGGER_BREAK 0xA4 // HID type OSC
|
||||||
|
#define HID_APPLICATION_BREAK 0xA5 // HID type OSC
|
||||||
|
#define HID_APPLICATION_DEBUGGER_BREAK 0xA6 // HID type OSC
|
||||||
|
#define HID_SYSTEM_SPEAKER_MUTE 0xA7 // HID type OSC
|
||||||
|
#define HID_SYSTEM_HIBERNATE 0xA8 // HID type OSC
|
||||||
|
// 0xA9-0xAF are reserved
|
||||||
|
#define HID_SYSTEM_DISPLAY_INVERT 0xB0 // HID type OSC
|
||||||
|
#define HID_SYSTEM_DISPLAY_INTERNAL 0xB1 // HID type OSC
|
||||||
|
#define HID_SYSTEM_DISPLAY_EXTERNAL 0xB2 // HID type OSC
|
||||||
|
#define HID_SYSTEM_DISPLAY_BOTH 0xB3 // HID type OSC
|
||||||
|
#define HID_SYSTEM_DISPLAY_DUAL 0xB4 // HID type OSC
|
||||||
|
#define HID_SYSTEM_DISPLAY_TOGGLE_INT_SLASH_EXT 0xB5 // HID type OSC
|
||||||
|
#define HID_SYSTEM_DISPLAY_SWAP_PRIMARY_SLASH_SECONDARY 0xB6 // HID type OSC
|
||||||
|
#define HID_SYSTEM_DISPLAY_LCD_AUTOSCALE 0xB7 // HID type OSC
|
||||||
|
|
||||||
|
// Keyboard HID mappings
|
||||||
|
|
||||||
|
// Reserved (no_event_indicated) 0x00
|
||||||
|
#define HID_KEYBOARD_ERROR_ROLLOVER 0x01
|
||||||
|
#define HID_KEYBOARD_POST_FAIL 0x02
|
||||||
|
#define HID_KEYBOARD_ERROR_UNDEFINED 0x03
|
||||||
|
#define HID_KEYBOARD_A_AND_A 0x04
|
||||||
|
#define HID_KEYBOARD_B_AND_B 0x05
|
||||||
|
#define HID_KEYBOARD_C_AND_C 0x06
|
||||||
|
#define HID_KEYBOARD_D_AND_D 0x07
|
||||||
|
#define HID_KEYBOARD_E_AND_E 0x08
|
||||||
|
#define HID_KEYBOARD_F_AND_F 0x09
|
||||||
|
#define HID_KEYBOARD_G_AND_G 0x0A
|
||||||
|
#define HID_KEYBOARD_H_AND_H 0x0B
|
||||||
|
#define HID_KEYBOARD_I_AND_I 0x0C
|
||||||
|
#define HID_KEYBOARD_J_AND_J 0x0D
|
||||||
|
#define HID_KEYBOARD_K_AND_K 0x0E
|
||||||
|
#define HID_KEYBOARD_L_AND_L 0x0F
|
||||||
|
#define HID_KEYBOARD_M_AND_M 0x10
|
||||||
|
#define HID_KEYBOARD_N_AND_N 0x11
|
||||||
|
#define HID_KEYBOARD_O_AND_O 0x12
|
||||||
|
#define HID_KEYBOARD_P_AND_P 0x13
|
||||||
|
#define HID_KEYBOARD_Q_AND_Q 0x14
|
||||||
|
#define HID_KEYBOARD_R_AND_R 0x15
|
||||||
|
#define HID_KEYBOARD_S_AND_S 0x16
|
||||||
|
#define HID_KEYBOARD_T_AND_T 0x17
|
||||||
|
#define HID_KEYBOARD_U_AND_U 0x18
|
||||||
|
#define HID_KEYBOARD_V_AND_V 0x19
|
||||||
|
#define HID_KEYBOARD_W_AND_W 0x1A
|
||||||
|
#define HID_KEYBOARD_X_AND_X 0x1B
|
||||||
|
#define HID_KEYBOARD_Y_AND_Y 0x1C
|
||||||
|
#define HID_KEYBOARD_Z_AND_Z 0x1D
|
||||||
|
#define HID_KEYBOARD_1_AND_EXCLAMATION_POINT 0x1E
|
||||||
|
#define HID_KEYBOARD_2_AND_AT 0x1F
|
||||||
|
#define HID_KEYBOARD_3_AND_POUND 0x20
|
||||||
|
#define HID_KEYBOARD_4_AND_DOLLAR 0x21
|
||||||
|
#define HID_KEYBOARD_5_AND_PERCENT 0x22
|
||||||
|
#define HID_KEYBOARD_6_AND_CARAT 0x23
|
||||||
|
#define HID_KEYBOARD_7_AND_AMPERSAND 0x24
|
||||||
|
#define HID_KEYBOARD_8_AND_ASTERISK 0x25
|
||||||
|
#define HID_KEYBOARD_9_AND_LEFT_PAREN 0x26
|
||||||
|
#define HID_KEYBOARD_0_AND_RIGHT_PAREN 0x27
|
||||||
|
#define HID_KEYBOARD_ENTER 0x28 // (MARKED AS ENTER_SLASH_RETURN)
|
||||||
|
#define HID_KEYBOARD_ESCAPE 0x29
|
||||||
|
#define HID_KEYBOARD_DELETE 0x2A // (BACKSPACE)
|
||||||
|
#define HID_KEYBOARD_TAB 0x2B
|
||||||
|
#define HID_KEYBOARD_SPACEBAR 0x2C
|
||||||
|
#define HID_KEYBOARD_MINUS_AND_UNDERSCORE 0x2D // (UNDERSCORE)
|
||||||
|
#define HID_KEYBOARD_EQUALS_AND_PLUS 0x2E
|
||||||
|
#define HID_KEYBOARD_LEFT_BRACKET_AND_LEFT_CURLY_BRACE 0x2F
|
||||||
|
#define HID_KEYBOARD_RIGHT_BRACKET_AND_RIGHT_CURLY_BRACE 0x30
|
||||||
|
#define HID_KEYBOARD_BACKSLASH_AND_PIPE 0x31
|
||||||
|
#define HID_KEYBOARD_NON_US_POUND_AND_TILDE 0x32
|
||||||
|
#define HID_KEYBOARD_SEMICOLON_AND_COLON 0x33
|
||||||
|
#define HID_KEYBOARD_QUOTE_AND_DOUBLEQUOTE 0x34
|
||||||
|
#define HID_KEYBOARD_GRAVE_ACCENT_AND_TILDE 0x35
|
||||||
|
#define HID_KEYBOARD_COMMA_AND_LESS_THAN 0x36
|
||||||
|
#define HID_KEYBOARD_PERIOD_AND_GREATER_THAN 0x37
|
||||||
|
#define HID_KEYBOARD_SLASH_AND_QUESTION_MARK 0x38
|
||||||
|
#define HID_KEYBOARD_CAPS_LOCK 0x39
|
||||||
|
#define HID_KEYBOARD_F1 0x3A
|
||||||
|
#define HID_KEYBOARD_F2 0x3B
|
||||||
|
#define HID_KEYBOARD_F3 0x3C
|
||||||
|
#define HID_KEYBOARD_F4 0x3D
|
||||||
|
#define HID_KEYBOARD_F5 0x3E
|
||||||
|
#define HID_KEYBOARD_F6 0x3F
|
||||||
|
#define HID_KEYBOARD_F7 0x40
|
||||||
|
#define HID_KEYBOARD_F8 0x41
|
||||||
|
#define HID_KEYBOARD_F9 0x42
|
||||||
|
#define HID_KEYBOARD_F10 0x43
|
||||||
|
#define HID_KEYBOARD_F11 0x44
|
||||||
|
#define HID_KEYBOARD_F12 0x45
|
||||||
|
#define HID_KEYBOARD_PRINTSCREEN 0x46
|
||||||
|
#define HID_KEYBOARD_SCROLL_LOCK 0x47
|
||||||
|
#define HID_KEYBOARD_PAUSE 0x48
|
||||||
|
#define HID_KEYBOARD_INSERT 0x49
|
||||||
|
#define HID_KEYBOARD_HOME 0x4A
|
||||||
|
#define HID_KEYBOARD_PAGE_UP 0x4B
|
||||||
|
#define HID_KEYBOARD_DELETE_FORWARD 0x4C
|
||||||
|
#define HID_KEYBOARD_END 0x4D
|
||||||
|
#define HID_KEYBOARD_PAGE_DOWN 0x4E
|
||||||
|
#define HID_KEYBOARD_RIGHTARROW 0x4F
|
||||||
|
#define HID_KEYBOARD_LEFTARROW 0x50
|
||||||
|
#define HID_KEYBOARD_DOWNARROW 0x51
|
||||||
|
#define HID_KEYBOARD_UPARROW 0x52
|
||||||
|
#define HID_KEYPAD_NUM_LOCK_AND_CLEAR 0x53
|
||||||
|
#define HID_KEYPAD_DIVIDE 0x54
|
||||||
|
#define HID_KEYPAD_MULTIPLY 0x55
|
||||||
|
#define HID_KEYPAD_SUBTRACT 0x56
|
||||||
|
#define HID_KEYPAD_ADD 0x57
|
||||||
|
#define HID_KEYPAD_ENTER 0x58
|
||||||
|
#define HID_KEYPAD_1_AND_END 0x59
|
||||||
|
#define HID_KEYPAD_2_AND_DOWN_ARROW 0x5A
|
||||||
|
#define HID_KEYPAD_3_AND_PAGE_DOWN 0x5B
|
||||||
|
#define HID_KEYPAD_4_AND_LEFT_ARROW 0x5C
|
||||||
|
#define HID_KEYPAD_5 0x5D
|
||||||
|
#define HID_KEYPAD_6_AND_RIGHT_ARROW 0x5E
|
||||||
|
#define HID_KEYPAD_7_AND_HOME 0x5F
|
||||||
|
#define HID_KEYPAD_8_AND_UP_ARROW 0x60
|
||||||
|
#define HID_KEYPAD_9_AND_PAGE_UP 0x61
|
||||||
|
#define HID_KEYPAD_0_AND_INSERT 0x62
|
||||||
|
#define HID_KEYPAD_PERIOD_AND_DELETE 0x63
|
||||||
|
#define HID_KEYBOARD_NON_US_BACKSLASH_AND_PIPE 0x64
|
||||||
|
#define HID_KEYBOARD_APPLICATION 0x65
|
||||||
|
#define HID_KEYBOARD_POWER 0x66
|
||||||
|
#define HID_KEYPAD_EQUALS 0x67
|
||||||
|
#define HID_KEYBOARD_F13 0x68
|
||||||
|
#define HID_KEYBOARD_F14 0x69
|
||||||
|
#define HID_KEYBOARD_F15 0x6A
|
||||||
|
#define HID_KEYBOARD_F16 0x6B
|
||||||
|
#define HID_KEYBOARD_F17 0x6C
|
||||||
|
#define HID_KEYBOARD_F18 0x6D
|
||||||
|
#define HID_KEYBOARD_F19 0x6E
|
||||||
|
#define HID_KEYBOARD_F20 0x6F
|
||||||
|
#define HID_KEYBOARD_F21 0x70
|
||||||
|
#define HID_KEYBOARD_F22 0x71
|
||||||
|
#define HID_KEYBOARD_F23 0x72
|
||||||
|
#define HID_KEYBOARD_F24 0x73
|
||||||
|
#define HID_KEYBOARD_EXECUTE 0x74
|
||||||
|
#define HID_KEYBOARD_HELP 0x75
|
||||||
|
#define HID_KEYBOARD_MENU 0x76
|
||||||
|
#define HID_KEYBOARD_SELECT 0x77
|
||||||
|
#define HID_KEYBOARD_STOP 0x78
|
||||||
|
#define HID_KEYBOARD_AGAIN 0x79
|
||||||
|
#define HID_KEYBOARD_UNDO 0x7A
|
||||||
|
#define HID_KEYBOARD_CUT 0x7B
|
||||||
|
#define HID_KEYBOARD_COPY 0x7C
|
||||||
|
#define HID_KEYBOARD_PASTE 0x7D
|
||||||
|
#define HID_KEYBOARD_FIND 0x7E
|
||||||
|
#define HID_KEYBOARD_MUTE 0x7F
|
||||||
|
#define HID_KEYBOARD_VOLUME_UP 0x80
|
||||||
|
#define HID_KEYBOARD_VOLUME_DOWN 0x81
|
||||||
|
#define HID_KEYBOARD_LOCKING_CAPS_LOCK 0x82
|
||||||
|
#define HID_KEYBOARD_LOCKING_NUM_LOCK 0x83
|
||||||
|
#define HID_KEYBOARD_LOCKING_SCROLL_LOCK 0x84
|
||||||
|
#define HID_KEYPAD_COMMA 0x85
|
||||||
|
#define HID_KEYPAD_EQUAL_SIGN 0x86
|
||||||
|
#define HID_KEYBOARD_INTERNATIONAL1 0x87
|
||||||
|
#define HID_KEYBOARD_INTERNATIONAL2 0x88
|
||||||
|
#define HID_KEYBOARD_INTERNATIONAL3 0x89
|
||||||
|
#define HID_KEYBOARD_INTERNATIONAL4 0x8A
|
||||||
|
#define HID_KEYBOARD_INTERNATIONAL5 0x8B
|
||||||
|
#define HID_KEYBOARD_INTERNATIONAL6 0x8C
|
||||||
|
#define HID_KEYBOARD_INTERNATIONAL7 0x8D
|
||||||
|
#define HID_KEYBOARD_INTERNATIONAL8 0x8E
|
||||||
|
#define HID_KEYBOARD_INTERNATIONAL9 0x8F
|
||||||
|
#define HID_KEYBOARD_LANG1 0x90
|
||||||
|
#define HID_KEYBOARD_LANG2 0x91
|
||||||
|
#define HID_KEYBOARD_LANG3 0x92
|
||||||
|
#define HID_KEYBOARD_LANG4 0x93
|
||||||
|
#define HID_KEYBOARD_LANG5 0x94
|
||||||
|
#define HID_KEYBOARD_LANG6 0x95
|
||||||
|
#define HID_KEYBOARD_LANG7 0x96
|
||||||
|
#define HID_KEYBOARD_LANG8 0x97
|
||||||
|
#define HID_KEYBOARD_LANG9 0x98
|
||||||
|
#define HID_KEYBOARD_ALTERNATE_ERASE 0x99
|
||||||
|
#define HID_KEYBOARD_SYSREQ_SLASH_ATTENTION 0x9A
|
||||||
|
#define HID_KEYBOARD_CANCEL 0x9B
|
||||||
|
#define HID_KEYBOARD_CLEAR 0x9C
|
||||||
|
#define HID_KEYBOARD_PRIOR 0x9D
|
||||||
|
#define HID_KEYBOARD_RETURN 0x9E
|
||||||
|
#define HID_KEYBOARD_SEPARATOR 0x9F
|
||||||
|
#define HID_KEYBOARD_OUT 0xA0
|
||||||
|
#define HID_KEYBOARD_OPER 0xA1
|
||||||
|
#define HID_KEYBOARD_CLEAR_SLASH_AGAIN 0xA2
|
||||||
|
#define HID_KEYBOARD_CRSEL_SLASH_PROPS 0xA3
|
||||||
|
#define HID_KEYBOARD_EXSEL 0xA4
|
||||||
|
// Reserved 0xA5-AF
|
||||||
|
#define HID_KEYPAD_00 0xB0
|
||||||
|
#define HID_KEYPAD_000 0xB1
|
||||||
|
#define HID_THOUSANDS_SEPARATOR 0xB2
|
||||||
|
#define HID_DECIMAL_SEPARATOR 0xB3
|
||||||
|
#define HID_CURRENCY_UNIT 0xB4
|
||||||
|
#define HID_CURRENCY_SUBUNIT 0xB5
|
||||||
|
#define HID_KEYPAD_LEFT_PAREN 0xB6
|
||||||
|
#define HID_KEYPAD_RIGHT_PAREN 0xB7
|
||||||
|
#define HID_KEYPAD_LEFT_CURLY_BRACE 0xB8
|
||||||
|
#define HID_KEYPAD_RIGHT_CURLY_BRACE 0xB9
|
||||||
|
#define HID_KEYPAD_TAB 0xBA
|
||||||
|
#define HID_KEYPAD_BACKSPACE 0xBB
|
||||||
|
#define HID_KEYPAD_A 0xBC
|
||||||
|
#define HID_KEYPAD_B 0xBD
|
||||||
|
#define HID_KEYPAD_C 0xBE
|
||||||
|
#define HID_KEYPAD_D 0xBF
|
||||||
|
#define HID_KEYPAD_E 0xC0
|
||||||
|
#define HID_KEYPAD_F 0xC1
|
||||||
|
#define HID_KEYPAD_XOR 0xC2
|
||||||
|
#define HID_KEYPAD_CARAT 0xC3
|
||||||
|
#define HID_KEYPAD_PERCENT 0xC4
|
||||||
|
#define HID_KEYPAD_LESS_THAN 0xC5
|
||||||
|
#define HID_KEYPAD_GREATER_THAN 0xC6
|
||||||
|
#define HID_KEYPAD_AMPERSAND 0xC7
|
||||||
|
#define HID_KEYPAD_DOUBLEAMPERSAND 0xC8
|
||||||
|
#define HID_KEYPAD_PIPE 0xC9
|
||||||
|
#define HID_KEYPAD_DOUBLEPIPE 0xCA
|
||||||
|
#define HID_KEYPAD_COLON 0xCB
|
||||||
|
#define HID_KEYPAD_POUND_SIGN 0xCC
|
||||||
|
#define HID_KEYPAD_SPACE 0xCD
|
||||||
|
#define HID_KEYPAD_AT_SIGN 0xCE
|
||||||
|
#define HID_KEYPAD_EXCLAMATION_POINT 0xCF
|
||||||
|
#define HID_KEYPAD_MEMORY_STORE 0xD0
|
||||||
|
#define HID_KEYPAD_MEMORY_RECALL 0xD1
|
||||||
|
#define HID_KEYPAD_MEMORY_CLEAR 0xD2
|
||||||
|
#define HID_KEYPAD_MEMORY_ADD 0xD3
|
||||||
|
#define HID_KEYPAD_MEMORY_SUBTRACT 0xD4
|
||||||
|
#define HID_KEYPAD_MEMORY_MULTIPLY 0xD5
|
||||||
|
#define HID_KEYPAD_MEMORY_DIVIDE 0xD6
|
||||||
|
#define HID_KEYPAD_PLUS_SLASH_MINUS 0xD7
|
||||||
|
#define HID_KEYPAD_CLEAR 0xD8
|
||||||
|
#define HID_KEYPAD_CLEAR_ENTRY 0xD9
|
||||||
|
#define HID_KEYPAD_BINARY 0xDA
|
||||||
|
#define HID_KEYPAD_OCTAL 0xDB
|
||||||
|
#define HID_KEYPAD_DECIMAL 0xDC
|
||||||
|
#define HID_KEYPAD_HEXADECIMAL 0xDD
|
||||||
|
|
||||||
|
// 0xDE-0xDF - RESERVED
|
||||||
|
#define HID_KEYBOARD_LEFT_CONTROL 0xE0
|
||||||
|
#define HID_KEYBOARD_LEFT_SHIFT 0xE1
|
||||||
|
#define HID_KEYBOARD_LEFT_ALT 0xE2
|
||||||
|
#define HID_KEYBOARD_LEFT_GUI 0xE3
|
||||||
|
#define HID_KEYBOARD_RIGHT_CONTROL 0xE4
|
||||||
|
#define HID_KEYBOARD_RIGHT_SHIFT 0xE5
|
||||||
|
#define HID_KEYBOARD_RIGHT_ALT 0xE6
|
||||||
|
#define HID_KEYBOARD_RIGHT_GUI 0xE7
|
||||||
|
|
||||||
|
|
||||||
|
// Consumer_Page_(0x0C) 0x15
|
||||||
|
#define HID_CONSUMER_NUMERIC_KEY_PAD 0x02 // HID type NARY
|
||||||
|
#define HID_CONSUMER_PROGRAMMABLE_BUTTONS 0x03 // HID type NARY
|
||||||
|
#define HID_CONSUMER_MICROPHONE_CA 0x04
|
||||||
|
#define HID_CONSUMER_HEADPHONE_CA 0x05
|
||||||
|
#define HID_CONSUMER_GRAPHIC_EQUALIZER_CA 0x06
|
||||||
|
// Reserved 0x07-1F
|
||||||
|
#define HID_CONSUMER_PLUS_10 0x20 // HID type OSC
|
||||||
|
#define HID_CONSUMER_PLUS_100 0x21 // HID type OSC
|
||||||
|
#define HID_CONSUMER_AM_SLASH_PM 0x22 // HID type OSC
|
||||||
|
// Reserved 0x23-3F
|
||||||
|
#define HID_CONSUMER_POWER 0x30 // HID type OOC
|
||||||
|
#define HID_CONSUMER_RESET 0x31 // HID type OSC
|
||||||
|
#define HID_CONSUMER_SLEEP 0x32 // HID type OSC
|
||||||
|
#define HID_CONSUMER_SLEEP_AFTER 0x33 // HID type OSC
|
||||||
|
#define HID_CONSUMER_SLEEP_MODE 0x34 // HID type RTC
|
||||||
|
#define HID_CONSUMER_ILLUMINATION 0x35 // HID type OOC
|
||||||
|
#define HID_CONSUMER_FUNCTION_BUTTONS 0x36 // HID type NARY
|
||||||
|
// Reserved 0x37-3F
|
||||||
|
#define HID_CONSUMER_MENU 0x40 // HID type OOC
|
||||||
|
#define HID_CONSUMER_MENU_PICK 0x41 // HID type OSC
|
||||||
|
#define HID_CONSUMER_MENU_UP 0x42 // HID type OSC
|
||||||
|
#define HID_CONSUMER_MENU_DOWN 0x43 // HID type OSC
|
||||||
|
#define HID_CONSUMER_MENU_LEFT 0x44 // HID type OSC
|
||||||
|
#define HID_CONSUMER_MENU_RIGHT 0x45 // HID type OSC
|
||||||
|
#define HID_CONSUMER_MENU_ESCAPE 0x46 // HID type OSC
|
||||||
|
#define HID_CONSUMER_MENU_VALUE_INCREASE 0x47 // HID type OSC
|
||||||
|
#define HID_CONSUMER_MENU_VALUE_DECREASE 0x48 // HID type OSC
|
||||||
|
// Reserved 0x49-5F
|
||||||
|
#define HID_CONSUMER_DATA_ON_SCREEN 0x60 // HID type OOC
|
||||||
|
#define HID_CONSUMER_CLOSED_CAPTION 0x61 // HID type OOC
|
||||||
|
#define HID_CONSUMER_CLOSED_CAPTION_SELECT 0x62 // HID type OSC
|
||||||
|
#define HID_CONSUMER_VCR_SLASH_TV 0x63 // HID type OOC
|
||||||
|
#define HID_CONSUMER_BROADCAST_MODE 0x64 // HID type OSC
|
||||||
|
#define HID_CONSUMER_SNAPSHOT 0x65 // HID type OSC
|
||||||
|
#define HID_CONSUMER_STILL 0x66 // HID type OSC
|
||||||
|
// Reserved 0x67-7F
|
||||||
|
#define HID_CONSUMER_SELECTION 0x80 // HID type NARY
|
||||||
|
#define HID_CONSUMER_ASSIGN_SELECTION 0x81 // HID type OSC
|
||||||
|
#define HID_CONSUMER_MODE_STEP 0x82 // HID type OSC
|
||||||
|
#define HID_CONSUMER_RECALL_LAST 0x83 // HID type OSC
|
||||||
|
#define HID_CONSUMER_ENTER_CHANNEL 0x84 // HID type OSC
|
||||||
|
#define HID_CONSUMER_ORDER_MOVIE 0x85 // HID type OSC
|
||||||
|
#define HID_CONSUMER_CHANNEL 0x86 // HID type LC
|
||||||
|
#define HID_CONSUMER_MEDIA_SELECTION 0x87 // HID type NARY
|
||||||
|
#define HID_CONSUMER_MEDIA_SELECT_COMPUTER 0x88 // HID type SEL
|
||||||
|
#define HID_CONSUMER_MEDIA_SELECT_TV 0x89 // HID type SEL
|
||||||
|
#define HID_CONSUMER_MEDIA_SELECT_WWW 0x8A // HID type SEL
|
||||||
|
#define HID_CONSUMER_MEDIA_SELECT_DVD 0x8B // HID type SEL
|
||||||
|
#define HID_CONSUMER_MEDIA_SELECT_TELEPHONE 0x8C // HID type SEL
|
||||||
|
#define HID_CONSUMER_MEDIA_SELECT_PROGRAM_GUIDE 0x8D // HID type SEL
|
||||||
|
#define HID_CONSUMER_MEDIA_SELECT_VIDEO_PHONE 0x8E // HID type SEL
|
||||||
|
#define HID_CONSUMER_MEDIA_SELECT_GAMES 0x8F // HID type SEL
|
||||||
|
#define HID_CONSUMER_MEDIA_SELECT_MESSAGES 0x90 // HID type SEL
|
||||||
|
#define HID_CONSUMER_MEDIA_SELECT_CD 0x91 // HID type SEL
|
||||||
|
#define HID_CONSUMER_MEDIA_SELECT_VCR 0x92 // HID type SEL
|
||||||
|
#define HID_CONSUMER_MEDIA_SELECT_TUNER 0x93 // HID type SEL
|
||||||
|
#define HID_CONSUMER_QUIT 0x94 // HID type OSC
|
||||||
|
#define HID_CONSUMER_HELP 0x95 // HID type OOC
|
||||||
|
#define HID_CONSUMER_MEDIA_SELECT_TAPE 0x96 // HID type SEL
|
||||||
|
#define HID_CONSUMER_MEDIA_SELECT_CABLE 0x97 // HID type SEL
|
||||||
|
#define HID_CONSUMER_MEDIA_SELECT_SATELLITE 0x98 // HID type SEL
|
||||||
|
#define HID_CONSUMER_MEDIA_SELECT_SECURITY 0x99 // HID type SEL
|
||||||
|
#define HID_CONSUMER_MEDIA_SELECT_HOME 0x9A // HID type SEL
|
||||||
|
#define HID_CONSUMER_MEDIA_SELECT_CALL 0x9B // HID type SEL
|
||||||
|
#define HID_CONSUMER_CHANNEL_INCREMENT 0x9C // HID type OSC
|
||||||
|
#define HID_CONSUMER_CHANNEL_DECREMENT 0x9D // HID type OSC
|
||||||
|
#define HID_CONSUMER_MEDIA_SELECT_SAP 0x9E // HID type SEL
|
||||||
|
// Reserved 0x9F
|
||||||
|
#define HID_CONSUMER_VCR_PLUS 0xA0 // HID type OSC
|
||||||
|
#define HID_CONSUMER_ONCE 0xA1 // HID type OSC
|
||||||
|
#define HID_CONSUMER_DAILY 0xA2 // HID type OSC
|
||||||
|
#define HID_CONSUMER_WEEKLY 0xA3 // HID type OSC
|
||||||
|
#define HID_CONSUMER_MONTHLY 0xA4 // HID type OSC
|
||||||
|
// Reserved 0xA5-AF
|
||||||
|
#define HID_CONSUMER_PLAY 0xB0 // HID type OOC
|
||||||
|
#define HID_CONSUMER_PAUSE 0xB1 // HID type OOC
|
||||||
|
#define HID_CONSUMER_RECORD 0xB2 // HID type OOC
|
||||||
|
#define HID_CONSUMER_FAST_FORWARD 0xB3 // HID type OOC
|
||||||
|
#define HID_CONSUMER_REWIND 0xB4 // HID type OOC
|
||||||
|
#define HID_CONSUMER_SCAN_NEXT_TRACK 0xB5 // HID type OSC
|
||||||
|
#define HID_CONSUMER_SCAN_PREVIOUS_TRACK 0xB6 // HID type OSC
|
||||||
|
#define HID_CONSUMER_STOP 0xB7 // HID type OSC
|
||||||
|
#define HID_CONSUMER_EJECT 0xB8 // HID type OSC
|
||||||
|
#define HID_CONSUMER_RANDOM_PLAY 0xB9 // HID type OOC
|
||||||
|
#define HID_CONSUMER_SELECT_DISC 0xBA // HID type NARY
|
||||||
|
#define HID_CONSUMER_ENTER_DISC_MC 0xBB
|
||||||
|
#define HID_CONSUMER_REPEAT 0xBC // HID type OSC
|
||||||
|
#define HID_CONSUMER_TRACKING 0xBD // HID type LC
|
||||||
|
#define HID_CONSUMER_TRACK_NORMAL 0xBE // HID type OSC
|
||||||
|
#define HID_CONSUMER_SLOW_TRACKING 0xBF // HID type LC
|
||||||
|
#define HID_CONSUMER_FRAME_FORWARD 0xC0 // HID type RTC
|
||||||
|
#define HID_CONSUMER_FRAME_BACK 0xC1 // HID type RTC
|
||||||
|
#define HID_CONSUMER_MARK 0xC2 // HID type OSC
|
||||||
|
#define HID_CONSUMER_CLEAR_MARK 0xC3 // HID type OSC
|
||||||
|
#define HID_CONSUMER_REPEAT_FROM_MARK 0xC4 // HID type OOC
|
||||||
|
#define HID_CONSUMER_RETURN_TO_MARK 0xC5 // HID type OSC
|
||||||
|
#define HID_CONSUMER_SEARCH_MARK_FORWARD 0xC6 // HID type OSC
|
||||||
|
#define HID_CONSUMER_SEARCH_MARK_BACKWARDS 0xC7 // HID type OSC
|
||||||
|
#define HID_CONSUMER_COUNTER_RESET 0xC8 // HID type OSC
|
||||||
|
#define HID_CONSUMER_SHOW_COUNTER 0xC9 // HID type OSC
|
||||||
|
#define HID_CONSUMER_TRACKING_INCREMENT 0xCA // HID type RTC
|
||||||
|
#define HID_CONSUMER_TRACKING_DECREMENT 0xCB // HID type RTC
|
||||||
|
#define HID_CONSUMER_STOP_SLASH_EJECT 0xCC // HID type OSC
|
||||||
|
#define HID_CONSUMER_PLAY_SLASH_PAUSE 0xCD // HID type OSC
|
||||||
|
#define HID_CONSUMER_PLAY_SLASH_SKIP 0xCE // HID type OSC
|
||||||
|
// Reserved 0xCF-DF
|
||||||
|
#define HID_CONSUMER_VOLUME 0xE0 // HID type LC
|
||||||
|
#define HID_CONSUMER_BALANCE 0xE1 // HID type LC
|
||||||
|
#define HID_CONSUMER_MUTE 0xE2 // HID type OOC
|
||||||
|
#define HID_CONSUMER_BASS 0xE3 // HID type LC
|
||||||
|
#define HID_CONSUMER_TREBLE 0xE4 // HID type LC
|
||||||
|
#define HID_CONSUMER_BASS_BOOST 0xE5 // HID type OOC
|
||||||
|
#define HID_CONSUMER_SURROUND_MODE 0xE6 // HID type OSC
|
||||||
|
#define HID_CONSUMER_LOUDNESS 0xE7 // HID type OOC
|
||||||
|
#define HID_CONSUMER_MPX 0xE8 // HID type OOC
|
||||||
|
#define HID_CONSUMER_VOLUME_INCREMENT 0xE9 // HID type RTC
|
||||||
|
#define HID_CONSUMER_VOLUME_DECREMENT 0xEA // HID type RTC
|
||||||
|
// Reserved 0xEB-EF
|
||||||
|
#define HID_CONSUMER_SPEED_SELECT 0xF0 // HID type OSC
|
||||||
|
#define HID_CONSUMER_PLAYBACK_SPEED 0xF1 // HID type NARY
|
||||||
|
#define HID_CONSUMER_STANDARD_PLAY 0xF2 // HID type SEL
|
||||||
|
#define HID_CONSUMER_LONG_PLAY 0xF3 // HID type SEL
|
||||||
|
#define HID_CONSUMER_EXTENDED_PLAY 0xF4 // HID type SEL
|
||||||
|
#define HID_CONSUMER_SLOW 0xF5 // HID type OSC
|
||||||
|
// Reserved 0xF6-FF
|
||||||
|
#define HID_CONSUMER_FAN_ENABLE 0x100 // HID type OOC
|
||||||
|
#define HID_CONSUMER_FAN_SPEED 0x101 // HID type LC
|
||||||
|
#define HID_CONSUMER_LIGHT_ENABLE 0x102 // HID type OOC
|
||||||
|
#define HID_CONSUMER_LIGHT_ILLUMINATION_LEVEL 0x103 // HID type LC
|
||||||
|
#define HID_CONSUMER_CLIMATE_CONTROL_ENABLE 0x104 // HID type OOC
|
||||||
|
#define HID_CONSUMER_ROOM_TEMPERATURE 0x105 // HID type LC
|
||||||
|
#define HID_CONSUMER_SECURITY_ENABLE 0x106 // HID type OOC
|
||||||
|
#define HID_CONSUMER_FIRE_ALARM 0x107 // HID type OSC
|
||||||
|
#define HID_CONSUMER_POLICE_ALARM 0x108 // HID type OSC
|
||||||
|
#define HID_CONSUMER_PROXIMITY 0x109 // HID type LC
|
||||||
|
#define HID_CONSUMER_MOTION 0x10A // HID type OSC
|
||||||
|
#define HID_CONSUMER_DURESS_ALARM 0x10B // HID type OSC
|
||||||
|
#define HID_CONSUMER_HOLDUP_ALARM 0x10C // HID type OSC
|
||||||
|
#define HID_CONSUMER_MEDICAL_ALARM 0x10D // HID type OSC
|
||||||
|
// Reserved 0x10E-14F
|
||||||
|
#define HID_CONSUMER_BALANCE_RIGHT 0x150 // HID type RTC
|
||||||
|
#define HID_CONSUMER_BALANCE_LEFT 0x151 // HID type RTC
|
||||||
|
#define HID_CONSUMER_BASS_INCREMENT 0x152 // HID type RTC
|
||||||
|
#define HID_CONSUMER_BASS_DECREMENT 0x153 // HID type RTC
|
||||||
|
#define HID_CONSUMER_TREBLE_INCREMENT 0x154 // HID type RTC
|
||||||
|
#define HID_CONSUMER_TREBLE_DECREMENT 0x155 // HID type RTC
|
||||||
|
// Reserved 0x156-15F
|
||||||
|
#define HID_CONSUMER_SPEAKER_SYSTEM 0x160 // HID type CL
|
||||||
|
#define HID_CONSUMER_CHANNEL_LEFT 0x161 // HID type CL
|
||||||
|
#define HID_CONSUMER_CHANNEL_RIGHT 0x162 // HID type CL
|
||||||
|
#define HID_CONSUMER_CHANNEL_CENTER 0x163 // HID type CL
|
||||||
|
#define HID_CONSUMER_CHANNEL_FRONT 0x164 // HID type CL
|
||||||
|
#define HID_CONSUMER_CHANNEL_CENTER_FRONT 0x165 // HID type CL
|
||||||
|
#define HID_CONSUMER_CHANNEL_SIDE 0x166 // HID type CL
|
||||||
|
#define HID_CONSUMER_CHANNEL_SURROUND 0x167 // HID type CL
|
||||||
|
#define HID_CONSUMER_CHANNEL_LOW_FREQUENCY_ENHANCEMENT 0x168 // HID type CL
|
||||||
|
#define HID_CONSUMER_CHANNEL_TOP 0x169 // HID type CL
|
||||||
|
#define HID_CONSUMER_CHANNEL_UNKNOWN 0x16A // HID type CL
|
||||||
|
// Reserved 0x16B-16F
|
||||||
|
#define HID_CONSUMER_SUB-CHANNEL 0x170 // HID type LC
|
||||||
|
#define HID_CONSUMER_SUB-CHANNEL_INCREMENT 0x171 // HID type OSC
|
||||||
|
#define HID_CONSUMER_SUB-CHANNEL_DECREMENT 0x172 // HID type OSC
|
||||||
|
#define HID_CONSUMER_ALTERNATE_AUDIO_INCREMENT 0x173 // HID type OSC
|
||||||
|
#define HID_CONSUMER_ALTERNATE_AUDIO_DECREMENT 0x174 // HID type OSC
|
||||||
|
// Reserved 0x175-17F
|
||||||
|
#define HID_CONSUMER_APPLICATION_LAUNCH_BUTTONS 0x180 // HID type NARY
|
||||||
|
#define HID_CONSUMER_AL_LAUNCH_BUTTON_CONFIGURATION_TOOL 0x181 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_PROGRAMMABLE_BUTTON_CONFIGURATION 0x182 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_CONSUMER_CONTROL_CONFIGURATION 0x183 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_WORD_PROCESSOR 0x184 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_TEXT_EDITOR 0x185 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_SPREADSHEET 0x186 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_GRAPHICS_EDITOR 0x187 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_PRESENTATION_APP 0x188 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_DATABASE_APP 0x189 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_EMAIL_READER 0x18A // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_NEWSREADER 0x18B // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_VOICEMAIL 0x18C // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_CONTACTS_SLASH_ADDRESS_BOOK 0x18D // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_CALENDAR_SLASH_SCHEDULE 0x18E // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_TASK_SLASH_PROJECT_MANAGER 0x18F // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_LOG_SLASH_JOURNAL_SLASH_TIMECARD 0x190 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_CHECKBOOK_SLASH_FINANCE 0x191 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_CALCULATOR 0x192 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_A_SLASH_V_CAPTURE_SLASH_PLAYBACK 0x193 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_LOCAL_MACHINE_BROWSER 0x194 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_LAN_SLASH_WAN_BROWSER 0x195 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_INTERNET_BROWSER 0x196 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_REMOTE_NETWORKING_SLASH_ISP_CONNECT 0x197 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_NETWORK_CONFERENCE 0x198 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_NETWORK_CHAT 0x199 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_TELEPHONY_SLASH_DIALER 0x19A // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_LOGON 0x19B // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_LOGOFF 0x19C // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_LOGON_SLASH_LOGOFF 0x19D // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_TERMINAL_LOCK_SLASH_SCREENSAVER 0x19E // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_CONTROL_PANEL 0x19F // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_COMMAND_LINE_PROCESSOR_SLASH_RUN 0x1A0 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_PROCESS_SLASH_TASK_MANAGER 0x1A1 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_SELECT_TASK_SLASH_APPLICATION 0x1A2 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_NEXT_TASK_SLASH_APPLICATION 0x1A3 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_PREVIOUS_TASK_SLASH_APPLICATION 0x1A4 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_PREEMPTIVE_HALT_TASK_SLASH_APPLICATION 0x1A5 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_INTEGRATED_HELP_CENTER 0x1A6 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_DOCUMENTS 0x1A7 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_THESAURUS 0x1A8 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_DICTIONARY 0x1A9 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_DESKTOP 0x1AA // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_SPELL_CHECK 0x1AB // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_GRAMMAR_CHECK 0x1AC // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_WIRELESS_STATUS 0x1AD // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_KEYBOARD_LAYOUT 0x1AE // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_VIRUS_PROTECTION 0x1AF // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_ENCRYPTION 0x1B0 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_SCREEN_SAVER 0x1B1 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_ALARMS 0x1B2 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_CLOCK 0x1B3 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_FILE_BROWSER 0x1B4 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_POWER_STATUS 0x1B5 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_IMAGE_BROWSER 0x1B6 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_AUDIO_BROWSER 0x1B7 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_MOVIE_BROWSER 0x1B8 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_DIGITAL_RIGHTS_MANAGER 0x1B9 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_DIGITAL_WALLET 0x1BA // HID type SEL
|
||||||
|
// _Reserved 0x1BB
|
||||||
|
#define HID_CONSUMER_AL_INSTANT_MESSAGING 0x1BC // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_OEM_FEATURES_SLASH__TIPS_SLASH_TUTORIAL_BROWSER 0x1BD // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_OEM_HELP 0x1BE // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_ONLINE_COMMUNITY 0x1BF // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_ENTERTAINMENT_CONTENT_BROWSER 0x1C0 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_ONLINE_SHOPPING_BROWSER 0x1C1 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_SMARTCARD_INFORMATION_SLASH_HELP 0x1C2 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_MARKET_MONITOR_SLASH_FINANCE_BROWSER 0x1C3 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_CUSTOMIZED_CORPORATE_NEWS_BROWSER 0x1C4 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_ONLINE_ACTIVITY_BROWSER 0x1C5 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_RESEARCH_SLASH_SEARCH_BROWSER 0x1C6 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AL_AUDIO_PLAYER 0x1C7 // HID type SEL
|
||||||
|
// Reserved 0x1C8-1FF
|
||||||
|
#define HID_CONSUMER_GENERIC_GUI_APPLICATION_CONTROLS 0x200 // HID type NARY
|
||||||
|
#define HID_CONSUMER_AC_NEW 0x201 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_OPEN 0x202 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_CLOSE 0x203 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_EXIT 0x204 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_MAXIMIZE 0x205 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_MINIMIZE 0x206 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_SAVE 0x207 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_PRINT 0x208 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_PROPERTIES 0x209 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_UNDO 0x21A // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_COPY 0x21B // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_CUT 0x21C // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_PASTE 0x21D // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_SELECT_ALL 0x21E // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_FIND 0x21F // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_FIND_AND_REPLACE 0x220 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_SEARCH 0x221 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_GO_TO 0x222 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_HOME 0x223 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_BACK 0x224 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_FORWARD 0x225 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_STOP 0x226 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_REFRESH 0x227 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_PREVIOUS_LINK 0x228 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_NEXT_LINK 0x229 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_BOOKMARKS 0x22A // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_HISTORY 0x22B // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_SUBSCRIPTIONS 0x22C // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_ZOOM_IN 0x22D // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_ZOOM_OUT 0x22E // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_ZOOM 0x22F // HID type LC
|
||||||
|
#define HID_CONSUMER_AC_FULL_SCREEN_VIEW 0x230 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_NORMAL_VIEW 0x231 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_VIEW_TOGGLE 0x232 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_SCROLL_UP 0x233 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_SCROLL_DOWN 0x234 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_SCROLL 0x235 // HID type LC
|
||||||
|
#define HID_CONSUMER_AC_PAN_LEFT 0x236 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_PAN_RIGHT 0x237 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_PAN 0x238 // HID type LC
|
||||||
|
#define HID_CONSUMER_AC_NEW_WINDOW 0x239 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_TILE_HORIZONTALLY 0x23A // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_TILE_VERTICALLY 0x23B // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_FORMAT 0x23C // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_EDIT 0x23D // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_BOLD 0x23E // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_ITALICS 0x23F // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_UNDERLINE 0x240 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_STRIKETHROUGH 0x241 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_SUBSCRIPT 0x242 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_SUPERSCRIPT 0x243 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_ALL_CAPS 0x244 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_ROTATE 0x245 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_RESIZE 0x246 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_FLIP_HORIZONTAL 0x247 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_FLIP_VERTICAL 0x248 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_MIRROR_HORIZONTAL 0x249 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_MIRROR_VERTICAL 0x24A // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_FONT_SELECT 0x24B // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_FONT_COLOR 0x24C // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_FONT_SIZE 0x24D // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_JUSTIFY_LEFT 0x24E // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_JUSTIFY_CENTER_H 0x24F // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_JUSTIFY_RIGHT 0x250 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_JUSTIFY_BLOCK_H 0x251 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_JUSTIFY_TOP 0x252 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_JUSTIFY_CENTER_V 0x253 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_JUSTIFY_BOTTOM 0x254 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_JUSTIFY_BLOCK_V 0x255 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_INDENT_DECREASE 0x256 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_INDENT_INCREASE 0x257 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_NUMBERED_LIST 0x258 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_RESTART_NUMBERING 0x259 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_BULLETED_LIST 0x25A // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_PROMOTE 0x25B // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_DEMOTE 0x25C // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_YES 0x25D // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_NO 0x25E // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_CANCEL 0x25F // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_CATALOG 0x260 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_BUY_SLASH_CHECKOUT 0x261 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_ADD_TO_CART 0x262 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_EXPAND 0x263 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_EXPAND_ALL 0x264 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_COLLAPSE 0x265 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_COLLAPSE_ALL 0x266 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_PRINT_PREVIEW 0x267 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_PASTE_SPECIAL 0x268 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_INSERT_MODE 0x269 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_DELETE 0x26A // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_LOCK 0x26B // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_UNLOCK 0x26C // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_PROTECT 0x26D // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_UNPROTECT 0x26E // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_ATTACH_COMMENT 0x26F // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_DELETE_COMMENT 0x270 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_VIEW_COMMENT 0x271 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_SELECT_WORD 0x272 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_SELECT_SENTENCE 0x273 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_SELECT_PARAGRAPH 0x274 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_SELECT_COLUMN 0x275 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_SELECT_ROW 0x276 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_SELECT_TABLE 0x277 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_SELECT_OBJECT 0x278 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_REDO_SLASH_REPEAT 0x279 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_SORT 0x27A // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_SORT_ASCENDING 0x27B // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_SORT_DESCENDING 0x27C // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_FILTER 0x27D // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_SET_CLOCK 0x27E // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_VIEW_CLOCK 0x27F // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_SELECT_TIME_ZONE 0x280 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_EDIT_TIME_ZONES 0x281 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_SET_ALARM 0x282 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_CLEAR_ALARM 0x283 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_SNOOZE_ALARM 0x284 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_RESET_ALARM 0x285 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_SYNCHRONIZE 0x286 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_SEND_SLASH_RECEIVE 0x287 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_SEND_TO 0x288 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_REPLY 0x289 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_REPLY_ALL 0x28A // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_FORWARD_MSG 0x28B // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_SEND 0x28C // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_ATTACH_FILE 0x28D // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_UPLOAD 0x28E // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_DOWNLOAD_(SAVE_TARGET_AS) 0x28F // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_SET_BORDERS 0x290 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_INSERT_ROW 0x291 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_INSERT_COLUMN 0x292 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_INSERT_FILE 0x293 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_INSERT_PICTURE 0x294 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_INSERT_OBJECT 0x295 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_INSERT_SYMBOL 0x296 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_SAVE_AND_CLOSE 0x297 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_RENAME 0x298 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_MERGE 0x299 // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_SPLIT 0x29A // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_DISRIBUTE_HORIZONTALLY 0x29B // HID type SEL
|
||||||
|
#define HID_CONSUMER_AC_DISTRIBUTE_VERTICALLY 0x29C // HID type SEL
|
||||||
|
|
||||||
|
#endif // __HIDTables__
|
@ -0,0 +1,252 @@
|
|||||||
|
/*
|
||||||
|
HardwareSerial.cpp - Hardware serial library for Wiring
|
||||||
|
Copyright (c) 2006 Nicholas Zambetti. All right reserved.
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
Modified 23 November 2006 by David A. Mellis
|
||||||
|
Modified 28 September 2010 by Mark Sproul
|
||||||
|
Modified 14 August 2012 by Alarus
|
||||||
|
Modified 3 December 2013 by Matthijs Kooijman
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include "Arduino.h"
|
||||||
|
|
||||||
|
#include "HardwareSerial.h"
|
||||||
|
#include "HardwareSerial_private.h"
|
||||||
|
|
||||||
|
// this next line disables the entire HardwareSerial.cpp,
|
||||||
|
// this is so I can support Attiny series and any other chip without a uart
|
||||||
|
#if defined(HAVE_HWSERIAL0) || defined(HAVE_HWSERIAL1) || defined(HAVE_HWSERIAL2) || defined(HAVE_HWSERIAL3)
|
||||||
|
|
||||||
|
// SerialEvent functions are weak, so when the user doesn't define them,
|
||||||
|
// the linker just sets their address to 0 (which is checked below).
|
||||||
|
// The Serialx_available is just a wrapper around Serialx.available(),
|
||||||
|
// but we can refer to it weakly so we don't pull in the entire
|
||||||
|
// HardwareSerial instance if the user doesn't also refer to it.
|
||||||
|
#if defined(HAVE_HWSERIAL0)
|
||||||
|
void serialEvent() __attribute__((weak));
|
||||||
|
bool Serial0_available() __attribute__((weak));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(HAVE_HWSERIAL1)
|
||||||
|
void serialEvent1() __attribute__((weak));
|
||||||
|
bool Serial1_available() __attribute__((weak));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(HAVE_HWSERIAL2)
|
||||||
|
void serialEvent2() __attribute__((weak));
|
||||||
|
bool Serial2_available() __attribute__((weak));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(HAVE_HWSERIAL3)
|
||||||
|
void serialEvent3() __attribute__((weak));
|
||||||
|
bool Serial3_available() __attribute__((weak));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void serialEventRun(void)
|
||||||
|
{
|
||||||
|
#if defined(HAVE_HWSERIAL0)
|
||||||
|
if (Serial0_available && serialEvent && Serial0_available()) serialEvent();
|
||||||
|
#endif
|
||||||
|
#if defined(HAVE_HWSERIAL1)
|
||||||
|
if (Serial1_available && serialEvent1 && Serial1_available()) serialEvent1();
|
||||||
|
#endif
|
||||||
|
#if defined(HAVE_HWSERIAL2)
|
||||||
|
if (Serial2_available && serialEvent2 && Serial2_available()) serialEvent2();
|
||||||
|
#endif
|
||||||
|
#if defined(HAVE_HWSERIAL3)
|
||||||
|
if (Serial3_available && serialEvent3 && Serial3_available()) serialEvent3();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
// Actual interrupt handlers //////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void HardwareSerial::_tx_udr_empty_irq(void)
|
||||||
|
{
|
||||||
|
// If interrupts are enabled, there must be more data in the output
|
||||||
|
// buffer. Send the next byte
|
||||||
|
unsigned char c = _tx_buffer[_tx_buffer_tail];
|
||||||
|
_tx_buffer_tail = (_tx_buffer_tail + 1) % SERIAL_TX_BUFFER_SIZE;
|
||||||
|
|
||||||
|
*_udr = c;
|
||||||
|
|
||||||
|
// clear the TXC bit -- "can be cleared by writing a one to its bit
|
||||||
|
// location". This makes sure flush() won't return until the bytes
|
||||||
|
// actually got written
|
||||||
|
sbi(*_ucsra, TXC0);
|
||||||
|
|
||||||
|
if (_tx_buffer_head == _tx_buffer_tail) {
|
||||||
|
// Buffer empty, so disable interrupts
|
||||||
|
cbi(*_ucsrb, UDRIE0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Public Methods //////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void HardwareSerial::begin(unsigned long baud, byte config)
|
||||||
|
{
|
||||||
|
// Try u2x mode first
|
||||||
|
uint16_t baud_setting = (F_CPU / 4 / baud - 1) / 2;
|
||||||
|
*_ucsra = 1 << U2X0;
|
||||||
|
|
||||||
|
// hardcoded exception for 57600 for compatibility with the bootloader
|
||||||
|
// shipped with the Duemilanove and previous boards and the firmware
|
||||||
|
// on the 8U2 on the Uno and Mega 2560. Also, The baud_setting cannot
|
||||||
|
// be > 4095, so switch back to non-u2x mode if the baud rate is too
|
||||||
|
// low.
|
||||||
|
if (((F_CPU == 16000000UL) && (baud == 57600)) || (baud_setting >4095))
|
||||||
|
{
|
||||||
|
*_ucsra = 0;
|
||||||
|
baud_setting = (F_CPU / 8 / baud - 1) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// assign the baud_setting, a.k.a. ubrr (USART Baud Rate Register)
|
||||||
|
*_ubrrh = baud_setting >> 8;
|
||||||
|
*_ubrrl = baud_setting;
|
||||||
|
|
||||||
|
_written = false;
|
||||||
|
|
||||||
|
//set the data bits, parity, and stop bits
|
||||||
|
#if defined(__AVR_ATmega8__)
|
||||||
|
config |= 0x80; // select UCSRC register (shared with UBRRH)
|
||||||
|
#endif
|
||||||
|
*_ucsrc = config;
|
||||||
|
|
||||||
|
sbi(*_ucsrb, RXEN0);
|
||||||
|
sbi(*_ucsrb, TXEN0);
|
||||||
|
sbi(*_ucsrb, RXCIE0);
|
||||||
|
cbi(*_ucsrb, UDRIE0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HardwareSerial::end()
|
||||||
|
{
|
||||||
|
// wait for transmission of outgoing data
|
||||||
|
while (_tx_buffer_head != _tx_buffer_tail)
|
||||||
|
;
|
||||||
|
|
||||||
|
cbi(*_ucsrb, RXEN0);
|
||||||
|
cbi(*_ucsrb, TXEN0);
|
||||||
|
cbi(*_ucsrb, RXCIE0);
|
||||||
|
cbi(*_ucsrb, UDRIE0);
|
||||||
|
|
||||||
|
// clear any received data
|
||||||
|
_rx_buffer_head = _rx_buffer_tail;
|
||||||
|
}
|
||||||
|
|
||||||
|
int HardwareSerial::available(void)
|
||||||
|
{
|
||||||
|
return ((unsigned int)(SERIAL_RX_BUFFER_SIZE + _rx_buffer_head - _rx_buffer_tail)) % SERIAL_RX_BUFFER_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int HardwareSerial::peek(void)
|
||||||
|
{
|
||||||
|
if (_rx_buffer_head == _rx_buffer_tail) {
|
||||||
|
return -1;
|
||||||
|
} else {
|
||||||
|
return _rx_buffer[_rx_buffer_tail];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int HardwareSerial::read(void)
|
||||||
|
{
|
||||||
|
// if the head isn't ahead of the tail, we don't have any characters
|
||||||
|
if (_rx_buffer_head == _rx_buffer_tail) {
|
||||||
|
return -1;
|
||||||
|
} else {
|
||||||
|
unsigned char c = _rx_buffer[_rx_buffer_tail];
|
||||||
|
_rx_buffer_tail = (rx_buffer_index_t)(_rx_buffer_tail + 1) % SERIAL_RX_BUFFER_SIZE;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int HardwareSerial::availableForWrite(void)
|
||||||
|
{
|
||||||
|
#if (SERIAL_TX_BUFFER_SIZE>256)
|
||||||
|
uint8_t oldSREG = SREG;
|
||||||
|
cli();
|
||||||
|
#endif
|
||||||
|
tx_buffer_index_t head = _tx_buffer_head;
|
||||||
|
tx_buffer_index_t tail = _tx_buffer_tail;
|
||||||
|
#if (SERIAL_TX_BUFFER_SIZE>256)
|
||||||
|
SREG = oldSREG;
|
||||||
|
#endif
|
||||||
|
if (head >= tail) return SERIAL_TX_BUFFER_SIZE - 1 - head + tail;
|
||||||
|
return tail - head - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HardwareSerial::flush()
|
||||||
|
{
|
||||||
|
// If we have never written a byte, no need to flush. This special
|
||||||
|
// case is needed since there is no way to force the TXC (transmit
|
||||||
|
// complete) bit to 1 during initialization
|
||||||
|
if (!_written)
|
||||||
|
return;
|
||||||
|
|
||||||
|
while (bit_is_set(*_ucsrb, UDRIE0) || bit_is_clear(*_ucsra, TXC0)) {
|
||||||
|
if (bit_is_clear(SREG, SREG_I) && bit_is_set(*_ucsrb, UDRIE0))
|
||||||
|
// Interrupts are globally disabled, but the DR empty
|
||||||
|
// interrupt should be enabled, so poll the DR empty flag to
|
||||||
|
// prevent deadlock
|
||||||
|
if (bit_is_set(*_ucsra, UDRE0))
|
||||||
|
_tx_udr_empty_irq();
|
||||||
|
}
|
||||||
|
// If we get here, nothing is queued anymore (DRIE is disabled) and
|
||||||
|
// the hardware finished tranmission (TXC is set).
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t HardwareSerial::write(uint8_t c)
|
||||||
|
{
|
||||||
|
// If the buffer and the data register is empty, just write the byte
|
||||||
|
// to the data register and be done. This shortcut helps
|
||||||
|
// significantly improve the effective datarate at high (>
|
||||||
|
// 500kbit/s) bitrates, where interrupt overhead becomes a slowdown.
|
||||||
|
if (_tx_buffer_head == _tx_buffer_tail && bit_is_set(*_ucsra, UDRE0)) {
|
||||||
|
*_udr = c;
|
||||||
|
sbi(*_ucsra, TXC0);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
tx_buffer_index_t i = (_tx_buffer_head + 1) % SERIAL_TX_BUFFER_SIZE;
|
||||||
|
|
||||||
|
// If the output buffer is full, there's nothing for it other than to
|
||||||
|
// wait for the interrupt handler to empty it a bit
|
||||||
|
while (i == _tx_buffer_tail) {
|
||||||
|
if (bit_is_clear(SREG, SREG_I)) {
|
||||||
|
// Interrupts are disabled, so we'll have to poll the data
|
||||||
|
// register empty flag ourselves. If it is set, pretend an
|
||||||
|
// interrupt has happened and call the handler to free up
|
||||||
|
// space for us.
|
||||||
|
if(bit_is_set(*_ucsra, UDRE0))
|
||||||
|
_tx_udr_empty_irq();
|
||||||
|
} else {
|
||||||
|
// nop, the interrupt handler will free up space for us
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_tx_buffer[_tx_buffer_head] = c;
|
||||||
|
_tx_buffer_head = i;
|
||||||
|
|
||||||
|
sbi(*_ucsrb, UDRIE0);
|
||||||
|
_written = true;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif // whole file
|
@ -0,0 +1,79 @@
|
|||||||
|
/*
|
||||||
|
HardwareSerial0.cpp - Hardware serial library for Wiring
|
||||||
|
Copyright (c) 2006 Nicholas Zambetti. All right reserved.
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
Modified 23 November 2006 by David A. Mellis
|
||||||
|
Modified 28 September 2010 by Mark Sproul
|
||||||
|
Modified 14 August 2012 by Alarus
|
||||||
|
Modified 3 December 2013 by Matthijs Kooijman
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Arduino.h"
|
||||||
|
#include "HardwareSerial.h"
|
||||||
|
#include "HardwareSerial_private.h"
|
||||||
|
|
||||||
|
// Each HardwareSerial is defined in its own file, sine the linker pulls
|
||||||
|
// in the entire file when any element inside is used. --gc-sections can
|
||||||
|
// additionally cause unused symbols to be dropped, but ISRs have the
|
||||||
|
// "used" attribute so are never dropped and they keep the
|
||||||
|
// HardwareSerial instance in as well. Putting each instance in its own
|
||||||
|
// file prevents the linker from pulling in any unused instances in the
|
||||||
|
// first place.
|
||||||
|
|
||||||
|
#if defined(HAVE_HWSERIAL0)
|
||||||
|
|
||||||
|
#if defined(USART_RX_vect)
|
||||||
|
ISR(USART_RX_vect)
|
||||||
|
#elif defined(USART0_RX_vect)
|
||||||
|
ISR(USART0_RX_vect)
|
||||||
|
#elif defined(USART_RXC_vect)
|
||||||
|
ISR(USART_RXC_vect) // ATmega8
|
||||||
|
#else
|
||||||
|
#error "Don't know what the Data Received vector is called for Serial"
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
Serial._rx_complete_irq();
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(UART0_UDRE_vect)
|
||||||
|
ISR(UART0_UDRE_vect)
|
||||||
|
#elif defined(UART_UDRE_vect)
|
||||||
|
ISR(UART_UDRE_vect)
|
||||||
|
#elif defined(USART0_UDRE_vect)
|
||||||
|
ISR(USART0_UDRE_vect)
|
||||||
|
#elif defined(USART_UDRE_vect)
|
||||||
|
ISR(USART_UDRE_vect)
|
||||||
|
#else
|
||||||
|
#error "Don't know what the Data Register Empty vector is called for Serial"
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
Serial._tx_udr_empty_irq();
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(UBRRH) && defined(UBRRL)
|
||||||
|
HardwareSerial Serial(&UBRRH, &UBRRL, &UCSRA, &UCSRB, &UCSRC, &UDR);
|
||||||
|
#else
|
||||||
|
HardwareSerial Serial(&UBRR0H, &UBRR0L, &UCSR0A, &UCSR0B, &UCSR0C, &UDR0);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Function that can be weakly referenced by serialEventRun to prevent
|
||||||
|
// pulling in this file if it's not otherwise used.
|
||||||
|
bool Serial0_available() {
|
||||||
|
return Serial.available();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // HAVE_HWSERIAL0
|
@ -0,0 +1,69 @@
|
|||||||
|
/*
|
||||||
|
HardwareSerial1.cpp - Hardware serial library for Wiring
|
||||||
|
Copyright (c) 2006 Nicholas Zambetti. All right reserved.
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
Modified 23 November 2006 by David A. Mellis
|
||||||
|
Modified 28 September 2010 by Mark Sproul
|
||||||
|
Modified 14 August 2012 by Alarus
|
||||||
|
Modified 3 December 2013 by Matthijs Kooijman
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Arduino.h"
|
||||||
|
#include "HardwareSerial.h"
|
||||||
|
#include "HardwareSerial_private.h"
|
||||||
|
|
||||||
|
// Each HardwareSerial is defined in its own file, sine the linker pulls
|
||||||
|
// in the entire file when any element inside is used. --gc-sections can
|
||||||
|
// additionally cause unused symbols to be dropped, but ISRs have the
|
||||||
|
// "used" attribute so are never dropped and they keep the
|
||||||
|
// HardwareSerial instance in as well. Putting each instance in its own
|
||||||
|
// file prevents the linker from pulling in any unused instances in the
|
||||||
|
// first place.
|
||||||
|
|
||||||
|
#if defined(HAVE_HWSERIAL1)
|
||||||
|
|
||||||
|
#if defined(UART1_RX_vect)
|
||||||
|
ISR(UART1_RX_vect)
|
||||||
|
#elif defined(USART1_RX_vect)
|
||||||
|
ISR(USART1_RX_vect)
|
||||||
|
#else
|
||||||
|
#error "Don't know what the Data Register Empty vector is called for Serial1"
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
Serial1._rx_complete_irq();
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(UART1_UDRE_vect)
|
||||||
|
ISR(UART1_UDRE_vect)
|
||||||
|
#elif defined(USART1_UDRE_vect)
|
||||||
|
ISR(USART1_UDRE_vect)
|
||||||
|
#else
|
||||||
|
#error "Don't know what the Data Register Empty vector is called for Serial1"
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
Serial1._tx_udr_empty_irq();
|
||||||
|
}
|
||||||
|
|
||||||
|
HardwareSerial Serial1(&UBRR1H, &UBRR1L, &UCSR1A, &UCSR1B, &UCSR1C, &UDR1);
|
||||||
|
|
||||||
|
// Function that can be weakly referenced by serialEventRun to prevent
|
||||||
|
// pulling in this file if it's not otherwise used.
|
||||||
|
bool Serial1_available() {
|
||||||
|
return Serial1.available();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // HAVE_HWSERIAL1
|
@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
HardwareSerial2.cpp - Hardware serial library for Wiring
|
||||||
|
Copyright (c) 2006 Nicholas Zambetti. All right reserved.
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
Modified 23 November 2006 by David A. Mellis
|
||||||
|
Modified 28 September 2010 by Mark Sproul
|
||||||
|
Modified 14 August 2012 by Alarus
|
||||||
|
Modified 3 December 2013 by Matthijs Kooijman
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Arduino.h"
|
||||||
|
#include "HardwareSerial.h"
|
||||||
|
#include "HardwareSerial_private.h"
|
||||||
|
|
||||||
|
// Each HardwareSerial is defined in its own file, sine the linker pulls
|
||||||
|
// in the entire file when any element inside is used. --gc-sections can
|
||||||
|
// additionally cause unused symbols to be dropped, but ISRs have the
|
||||||
|
// "used" attribute so are never dropped and they keep the
|
||||||
|
// HardwareSerial instance in as well. Putting each instance in its own
|
||||||
|
// file prevents the linker from pulling in any unused instances in the
|
||||||
|
// first place.
|
||||||
|
|
||||||
|
#if defined(HAVE_HWSERIAL2)
|
||||||
|
|
||||||
|
ISR(USART2_RX_vect)
|
||||||
|
{
|
||||||
|
Serial2._rx_complete_irq();
|
||||||
|
}
|
||||||
|
|
||||||
|
ISR(USART2_UDRE_vect)
|
||||||
|
{
|
||||||
|
Serial2._tx_udr_empty_irq();
|
||||||
|
}
|
||||||
|
|
||||||
|
HardwareSerial Serial2(&UBRR2H, &UBRR2L, &UCSR2A, &UCSR2B, &UCSR2C, &UDR2);
|
||||||
|
|
||||||
|
// Function that can be weakly referenced by serialEventRun to prevent
|
||||||
|
// pulling in this file if it's not otherwise used.
|
||||||
|
bool Serial2_available() {
|
||||||
|
return Serial2.available();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // HAVE_HWSERIAL2
|
@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
HardwareSerial3.cpp - Hardware serial library for Wiring
|
||||||
|
Copyright (c) 2006 Nicholas Zambetti. All right reserved.
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
Modified 23 November 2006 by David A. Mellis
|
||||||
|
Modified 28 September 2010 by Mark Sproul
|
||||||
|
Modified 14 August 2012 by Alarus
|
||||||
|
Modified 3 December 2013 by Matthijs Kooijman
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Arduino.h"
|
||||||
|
#include "HardwareSerial.h"
|
||||||
|
#include "HardwareSerial_private.h"
|
||||||
|
|
||||||
|
// Each HardwareSerial is defined in its own file, sine the linker pulls
|
||||||
|
// in the entire file when any element inside is used. --gc-sections can
|
||||||
|
// additionally cause unused symbols to be dropped, but ISRs have the
|
||||||
|
// "used" attribute so are never dropped and they keep the
|
||||||
|
// HardwareSerial instance in as well. Putting each instance in its own
|
||||||
|
// file prevents the linker from pulling in any unused instances in the
|
||||||
|
// first place.
|
||||||
|
|
||||||
|
#if defined(HAVE_HWSERIAL3)
|
||||||
|
|
||||||
|
ISR(USART3_RX_vect)
|
||||||
|
{
|
||||||
|
Serial3._rx_complete_irq();
|
||||||
|
}
|
||||||
|
|
||||||
|
ISR(USART3_UDRE_vect)
|
||||||
|
{
|
||||||
|
Serial3._tx_udr_empty_irq();
|
||||||
|
}
|
||||||
|
|
||||||
|
HardwareSerial Serial3(&UBRR3H, &UBRR3L, &UCSR3A, &UCSR3B, &UCSR3C, &UDR3);
|
||||||
|
|
||||||
|
// Function that can be weakly referenced by serialEventRun to prevent
|
||||||
|
// pulling in this file if it's not otherwise used.
|
||||||
|
bool Serial3_available() {
|
||||||
|
return Serial3.available();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // HAVE_HWSERIAL3
|
@ -0,0 +1,123 @@
|
|||||||
|
/*
|
||||||
|
HardwareSerial_private.h - Hardware serial library for Wiring
|
||||||
|
Copyright (c) 2006 Nicholas Zambetti. All right reserved.
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
Modified 23 November 2006 by David A. Mellis
|
||||||
|
Modified 28 September 2010 by Mark Sproul
|
||||||
|
Modified 14 August 2012 by Alarus
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "wiring_private.h"
|
||||||
|
|
||||||
|
// this next line disables the entire HardwareSerial.cpp,
|
||||||
|
// this is so I can support Attiny series and any other chip without a uart
|
||||||
|
#if defined(HAVE_HWSERIAL0) || defined(HAVE_HWSERIAL1) || defined(HAVE_HWSERIAL2) || defined(HAVE_HWSERIAL3)
|
||||||
|
|
||||||
|
// Ensure that the various bit positions we use are available with a 0
|
||||||
|
// postfix, so we can always use the values for UART0 for all UARTs. The
|
||||||
|
// alternative, passing the various values for each UART to the
|
||||||
|
// HardwareSerial constructor also works, but makes the code bigger and
|
||||||
|
// slower.
|
||||||
|
#if !defined(TXC0)
|
||||||
|
#if defined(TXC)
|
||||||
|
// Some chips like ATmega8 don't have UPE, only PE. The other bits are
|
||||||
|
// named as expected.
|
||||||
|
#if !defined(UPE) && defined(PE)
|
||||||
|
#define UPE PE
|
||||||
|
#endif
|
||||||
|
// On ATmega8, the uart and its bits are not numbered, so there is no TXC0 etc.
|
||||||
|
#define TXC0 TXC
|
||||||
|
#define RXEN0 RXEN
|
||||||
|
#define TXEN0 TXEN
|
||||||
|
#define RXCIE0 RXCIE
|
||||||
|
#define UDRIE0 UDRIE
|
||||||
|
#define U2X0 U2X
|
||||||
|
#define UPE0 UPE
|
||||||
|
#define UDRE0 UDRE
|
||||||
|
#elif defined(TXC1)
|
||||||
|
// Some devices have uart1 but no uart0
|
||||||
|
#define TXC0 TXC1
|
||||||
|
#define RXEN0 RXEN1
|
||||||
|
#define TXEN0 TXEN1
|
||||||
|
#define RXCIE0 RXCIE1
|
||||||
|
#define UDRIE0 UDRIE1
|
||||||
|
#define U2X0 U2X1
|
||||||
|
#define UPE0 UPE1
|
||||||
|
#define UDRE0 UDRE1
|
||||||
|
#else
|
||||||
|
#error No UART found in HardwareSerial.cpp
|
||||||
|
#endif
|
||||||
|
#endif // !defined TXC0
|
||||||
|
|
||||||
|
// Check at compiletime that it is really ok to use the bit positions of
|
||||||
|
// UART0 for the other UARTs as well, in case these values ever get
|
||||||
|
// changed for future hardware.
|
||||||
|
#if defined(TXC1) && (TXC1 != TXC0 || RXEN1 != RXEN0 || RXCIE1 != RXCIE0 || \
|
||||||
|
UDRIE1 != UDRIE0 || U2X1 != U2X0 || UPE1 != UPE0 || \
|
||||||
|
UDRE1 != UDRE0)
|
||||||
|
#error "Not all bit positions for UART1 are the same as for UART0"
|
||||||
|
#endif
|
||||||
|
#if defined(TXC2) && (TXC2 != TXC0 || RXEN2 != RXEN0 || RXCIE2 != RXCIE0 || \
|
||||||
|
UDRIE2 != UDRIE0 || U2X2 != U2X0 || UPE2 != UPE0 || \
|
||||||
|
UDRE2 != UDRE0)
|
||||||
|
#error "Not all bit positions for UART2 are the same as for UART0"
|
||||||
|
#endif
|
||||||
|
#if defined(TXC3) && (TXC3 != TXC0 || RXEN3 != RXEN0 || RXCIE3 != RXCIE0 || \
|
||||||
|
UDRIE3 != UDRIE0 || U3X3 != U3X0 || UPE3 != UPE0 || \
|
||||||
|
UDRE3 != UDRE0)
|
||||||
|
#error "Not all bit positions for UART3 are the same as for UART0"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Constructors ////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
HardwareSerial::HardwareSerial(
|
||||||
|
volatile uint8_t *ubrrh, volatile uint8_t *ubrrl,
|
||||||
|
volatile uint8_t *ucsra, volatile uint8_t *ucsrb,
|
||||||
|
volatile uint8_t *ucsrc, volatile uint8_t *udr) :
|
||||||
|
_ubrrh(ubrrh), _ubrrl(ubrrl),
|
||||||
|
_ucsra(ucsra), _ucsrb(ucsrb), _ucsrc(ucsrc),
|
||||||
|
_udr(udr),
|
||||||
|
_rx_buffer_head(0), _rx_buffer_tail(0),
|
||||||
|
_tx_buffer_head(0), _tx_buffer_tail(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// Actual interrupt handlers //////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void HardwareSerial::_rx_complete_irq(void)
|
||||||
|
{
|
||||||
|
if (bit_is_clear(*_ucsra, UPE0)) {
|
||||||
|
// No Parity error, read byte and store it in the buffer if there is
|
||||||
|
// room
|
||||||
|
unsigned char c = *_udr;
|
||||||
|
rx_buffer_index_t i = (unsigned int)(_rx_buffer_head + 1) % SERIAL_RX_BUFFER_SIZE;
|
||||||
|
|
||||||
|
// if we should be storing the received character into the location
|
||||||
|
// just before the tail (meaning that the head would advance to the
|
||||||
|
// current location of the tail), we're about to overflow the buffer
|
||||||
|
// and so we don't write the character or advance the head.
|
||||||
|
if (i != _rx_buffer_tail) {
|
||||||
|
_rx_buffer[_rx_buffer_head] = c;
|
||||||
|
_rx_buffer_head = i;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Parity error, read byte but discard it
|
||||||
|
*_udr;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // whole file
|
@ -0,0 +1,74 @@
|
|||||||
|
/*
|
||||||
|
IPAddress.cpp - Base class that provides IPAddress
|
||||||
|
Copyright (c) 2011 Adrian McEwen. All right reserved.
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include <IPAddress.h>
|
||||||
|
|
||||||
|
IPAddress::IPAddress()
|
||||||
|
{
|
||||||
|
_address.dword = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
IPAddress::IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet)
|
||||||
|
{
|
||||||
|
_address.bytes[0] = first_octet;
|
||||||
|
_address.bytes[1] = second_octet;
|
||||||
|
_address.bytes[2] = third_octet;
|
||||||
|
_address.bytes[3] = fourth_octet;
|
||||||
|
}
|
||||||
|
|
||||||
|
IPAddress::IPAddress(uint32_t address)
|
||||||
|
{
|
||||||
|
_address.dword = address;
|
||||||
|
}
|
||||||
|
|
||||||
|
IPAddress::IPAddress(const uint8_t *address)
|
||||||
|
{
|
||||||
|
memcpy(_address.bytes, address, sizeof(_address.bytes));
|
||||||
|
}
|
||||||
|
|
||||||
|
IPAddress& IPAddress::operator=(const uint8_t *address)
|
||||||
|
{
|
||||||
|
memcpy(_address.bytes, address, sizeof(_address.bytes));
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
IPAddress& IPAddress::operator=(uint32_t address)
|
||||||
|
{
|
||||||
|
_address.dword = address;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IPAddress::operator==(const uint8_t* addr) const
|
||||||
|
{
|
||||||
|
return memcmp(addr, _address.bytes, sizeof(_address.bytes)) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t IPAddress::printTo(Print& p) const
|
||||||
|
{
|
||||||
|
size_t n = 0;
|
||||||
|
for (int i =0; i < 3; i++)
|
||||||
|
{
|
||||||
|
n += p.print(_address.bytes[i], DEC);
|
||||||
|
n += p.print('.');
|
||||||
|
}
|
||||||
|
n += p.print(_address.bytes[3], DEC);
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,75 @@
|
|||||||
|
/*
|
||||||
|
IPAddress.h - Base class that provides IPAddress
|
||||||
|
Copyright (c) 2011 Adrian McEwen. All right reserved.
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef IPAddress_h
|
||||||
|
#define IPAddress_h
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <Printable.h>
|
||||||
|
|
||||||
|
// A class to make it easier to handle and pass around IP addresses
|
||||||
|
|
||||||
|
class IPAddress : public Printable {
|
||||||
|
private:
|
||||||
|
union {
|
||||||
|
uint8_t bytes[4]; // IPv4 address
|
||||||
|
uint32_t dword;
|
||||||
|
} _address;
|
||||||
|
|
||||||
|
// Access the raw byte array containing the address. Because this returns a pointer
|
||||||
|
// to the internal structure rather than a copy of the address this function should only
|
||||||
|
// be used when you know that the usage of the returned uint8_t* will be transient and not
|
||||||
|
// stored.
|
||||||
|
uint8_t* raw_address() { return _address.bytes; };
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Constructors
|
||||||
|
IPAddress();
|
||||||
|
IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet);
|
||||||
|
IPAddress(uint32_t address);
|
||||||
|
IPAddress(const uint8_t *address);
|
||||||
|
|
||||||
|
// Overloaded cast operator to allow IPAddress objects to be used where a pointer
|
||||||
|
// to a four-byte uint8_t array is expected
|
||||||
|
operator uint32_t() const { return _address.dword; };
|
||||||
|
bool operator==(const IPAddress& addr) const { return _address.dword == addr._address.dword; };
|
||||||
|
bool operator==(const uint8_t* addr) const;
|
||||||
|
|
||||||
|
// Overloaded index operator to allow getting and setting individual octets of the address
|
||||||
|
uint8_t operator[](int index) const { return _address.bytes[index]; };
|
||||||
|
uint8_t& operator[](int index) { return _address.bytes[index]; };
|
||||||
|
|
||||||
|
// Overloaded copy operators to allow initialisation of IPAddress objects from other types
|
||||||
|
IPAddress& operator=(const uint8_t *address);
|
||||||
|
IPAddress& operator=(uint32_t address);
|
||||||
|
|
||||||
|
virtual size_t printTo(Print& p) const;
|
||||||
|
|
||||||
|
friend class EthernetClass;
|
||||||
|
friend class UDP;
|
||||||
|
friend class Client;
|
||||||
|
friend class Server;
|
||||||
|
friend class DhcpClass;
|
||||||
|
friend class DNSClient;
|
||||||
|
};
|
||||||
|
|
||||||
|
const IPAddress INADDR_NONE(0,0,0,0);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
Server.h - Base class that provides Server
|
||||||
|
Copyright (c) 2011 Adrian McEwen. All right reserved.
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef server_h
|
||||||
|
#define server_h
|
||||||
|
|
||||||
|
#include "Print.h"
|
||||||
|
|
||||||
|
class Server : public Print {
|
||||||
|
public:
|
||||||
|
virtual void begin() =0;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
Copyright (c) 2014 Arduino. All right reserved.
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
See the GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
extern "C" void __cxa_pure_virtual(void) __attribute__ ((__noreturn__));
|
||||||
|
extern "C" void __cxa_deleted_virtual(void) __attribute__ ((__noreturn__));
|
||||||
|
|
||||||
|
void __cxa_pure_virtual(void) {
|
||||||
|
// We might want to write some diagnostics to uart in this case
|
||||||
|
//std::terminate();
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
void __cxa_deleted_virtual(void) {
|
||||||
|
// We might want to write some diagnostics to uart in this case
|
||||||
|
//std::terminate();
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
@ -1,3 +1,22 @@
|
|||||||
|
/*
|
||||||
|
binary.h - Definitions for binary constants
|
||||||
|
Copyright (c) 2006 David A. Mellis. All right reserved.
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef Binary_h
|
#ifndef Binary_h
|
||||||
#define Binary_h
|
#define Binary_h
|
||||||
|
|
@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
Copyright (c) 2012 Arduino. All right reserved.
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
See the GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Empty yield() hook.
|
||||||
|
*
|
||||||
|
* This function is intended to be used by library writers to build
|
||||||
|
* libraries or sketches that supports cooperative threads.
|
||||||
|
*
|
||||||
|
* Its defined as a weak symbol and it can be redefined to implement a
|
||||||
|
* real cooperative scheduler.
|
||||||
|
*/
|
||||||
|
static void __empty() {
|
||||||
|
// Empty
|
||||||
|
}
|
||||||
|
void yield(void) __attribute__ ((weak, alias("__empty")));
|
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
main.cpp - Main loop for Arduino sketches
|
||||||
|
Copyright (c) 2005-2013 Arduino Team. All right reserved.
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
//Declared weak in Arduino.h to allow user redefinitions.
|
||||||
|
int atexit(void (*func)()) { return 0; }
|
||||||
|
|
||||||
|
// Weak empty variant initialization function.
|
||||||
|
// May be redefined by variant files.
|
||||||
|
void initVariant() __attribute__((weak));
|
||||||
|
void initVariant() { }
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
init();
|
||||||
|
|
||||||
|
initVariant();
|
||||||
|
|
||||||
|
#if defined(USBCON)
|
||||||
|
USBDevice.attach();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
setup();
|
||||||
|
|
||||||
|
for (;;) {
|
||||||
|
loop();
|
||||||
|
if (serialEventRun) serialEventRun();
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
Copyright (c) 2014 Arduino. All right reserved.
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
See the GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
void *operator new(size_t size) {
|
||||||
|
return malloc(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *operator new[](size_t size) {
|
||||||
|
return malloc(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
void operator delete(void * ptr) {
|
||||||
|
free(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void operator delete[](void * ptr) {
|
||||||
|
free(ptr);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
Copyright (c) 2014 Arduino. All right reserved.
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
See the GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef NEW_H
|
||||||
|
#define NEW_H
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
void * operator new(size_t size);
|
||||||
|
void * operator new[](size_t size);
|
||||||
|
void operator delete(void * ptr);
|
||||||
|
void operator delete[](void * ptr);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1 @@
|
|||||||
|
name=Keyboardio Keyboards
|
@ -0,0 +1,359 @@
|
|||||||
|
/*
|
||||||
|
pins_arduino.h - Pin definition functions for Arduino
|
||||||
|
Part of Arduino - http://www.arduino.cc/
|
||||||
|
|
||||||
|
Copyright (c) 2007 David A. Mellis
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General
|
||||||
|
Public License along with this library; if not, write to the
|
||||||
|
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||||
|
Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
$Id: wiring.h 249 2007-02-03 16:52:51Z mellis $
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef Pins_Arduino_h
|
||||||
|
#define Pins_Arduino_h
|
||||||
|
|
||||||
|
#include <avr/pgmspace.h>
|
||||||
|
|
||||||
|
// Workaround for wrong definitions in "iom32u4.h".
|
||||||
|
// This should be fixed in the AVR toolchain.
|
||||||
|
#undef UHCON
|
||||||
|
#undef UHINT
|
||||||
|
#undef UHIEN
|
||||||
|
#undef UHADDR
|
||||||
|
#undef UHFNUM
|
||||||
|
#undef UHFNUML
|
||||||
|
#undef UHFNUMH
|
||||||
|
#undef UHFLEN
|
||||||
|
#undef UPINRQX
|
||||||
|
#undef UPINTX
|
||||||
|
#undef UPNUM
|
||||||
|
#undef UPRST
|
||||||
|
#undef UPCONX
|
||||||
|
#undef UPCFG0X
|
||||||
|
#undef UPCFG1X
|
||||||
|
#undef UPSTAX
|
||||||
|
#undef UPCFG2X
|
||||||
|
#undef UPIENX
|
||||||
|
#undef UPDATX
|
||||||
|
#undef TCCR2A
|
||||||
|
#undef WGM20
|
||||||
|
#undef WGM21
|
||||||
|
#undef COM2B0
|
||||||
|
#undef COM2B1
|
||||||
|
#undef COM2A0
|
||||||
|
#undef COM2A1
|
||||||
|
#undef TCCR2B
|
||||||
|
#undef CS20
|
||||||
|
#undef CS21
|
||||||
|
#undef CS22
|
||||||
|
#undef WGM22
|
||||||
|
#undef FOC2B
|
||||||
|
#undef FOC2A
|
||||||
|
#undef TCNT2
|
||||||
|
#undef TCNT2_0
|
||||||
|
#undef TCNT2_1
|
||||||
|
#undef TCNT2_2
|
||||||
|
#undef TCNT2_3
|
||||||
|
#undef TCNT2_4
|
||||||
|
#undef TCNT2_5
|
||||||
|
#undef TCNT2_6
|
||||||
|
#undef TCNT2_7
|
||||||
|
#undef OCR2A
|
||||||
|
#undef OCR2_0
|
||||||
|
#undef OCR2_1
|
||||||
|
#undef OCR2_2
|
||||||
|
#undef OCR2_3
|
||||||
|
#undef OCR2_4
|
||||||
|
#undef OCR2_5
|
||||||
|
#undef OCR2_6
|
||||||
|
#undef OCR2_7
|
||||||
|
#undef OCR2B
|
||||||
|
#undef OCR2_0
|
||||||
|
#undef OCR2_1
|
||||||
|
#undef OCR2_2
|
||||||
|
#undef OCR2_3
|
||||||
|
#undef OCR2_4
|
||||||
|
#undef OCR2_5
|
||||||
|
#undef OCR2_6
|
||||||
|
#undef OCR2_7
|
||||||
|
|
||||||
|
#define NUM_DIGITAL_PINS 30
|
||||||
|
#define NUM_ANALOG_INPUTS 12
|
||||||
|
|
||||||
|
#define TXLED0 PORTD &= ~(1<<5)
|
||||||
|
#define TXLED1 PORTD |= (1<<5)
|
||||||
|
#define RXLED0 PORTB &= ~(1<<0)
|
||||||
|
#define RXLED1 PORTB |= (1<<0)
|
||||||
|
#define TX_RX_LED_INIT DDRD |= (1<<5), DDRB |= (1<<0), TXLED0, RXLED0
|
||||||
|
|
||||||
|
#define SDA 2
|
||||||
|
#define SCL 3
|
||||||
|
#define LED_BUILTIN 13
|
||||||
|
|
||||||
|
// Map SPI port to 'new' pins D14..D17
|
||||||
|
#define SS 17
|
||||||
|
#define MOSI 16
|
||||||
|
#define MISO 14
|
||||||
|
#define SCK 15
|
||||||
|
|
||||||
|
// Mapping of analog pins as digital I/O
|
||||||
|
// A6-A11 share with digital pins
|
||||||
|
#define A0 18
|
||||||
|
#define A1 19
|
||||||
|
#define A2 20
|
||||||
|
#define A3 21
|
||||||
|
#define A4 22
|
||||||
|
#define A5 23
|
||||||
|
#define A6 24 // D4
|
||||||
|
#define A7 25 // D6
|
||||||
|
#define A8 26 // D8
|
||||||
|
#define A9 27 // D9
|
||||||
|
#define A10 28 // D10
|
||||||
|
#define A11 29 // D12
|
||||||
|
|
||||||
|
#define digitalPinToPCICR(p) ((((p) >= 8 && (p) <= 11) || ((p) >= 14 && (p) <= 17) || ((p) >= A8 && (p) <= A10)) ? (&PCICR) : ((uint8_t *)0))
|
||||||
|
#define digitalPinToPCICRbit(p) 0
|
||||||
|
#define digitalPinToPCMSK(p) ((((p) >= 8 && (p) <= 11) || ((p) >= 14 && (p) <= 17) || ((p) >= A8 && (p) <= A10)) ? (&PCMSK0) : ((uint8_t *)0))
|
||||||
|
#define digitalPinToPCMSKbit(p) ( ((p) >= 8 && (p) <= 11) ? (p) - 4 : ((p) == 14 ? 3 : ((p) == 15 ? 1 : ((p) == 16 ? 2 : ((p) == 17 ? 0 : (p - A8 + 4))))))
|
||||||
|
|
||||||
|
// __AVR_ATmega32U4__ has an unusual mapping of pins to channels
|
||||||
|
extern const uint8_t PROGMEM analog_pin_to_channel_PGM[];
|
||||||
|
#define analogPinToChannel(P) ( pgm_read_byte( analog_pin_to_channel_PGM + (P) ) )
|
||||||
|
|
||||||
|
#ifdef ARDUINO_MAIN
|
||||||
|
|
||||||
|
// On the Arduino board, digital pins are also used
|
||||||
|
// for the analog output (software PWM). Analog input
|
||||||
|
// pins are a separate set.
|
||||||
|
|
||||||
|
// ATMEL ATMEGA32U4 / ARDUINO LEONARDO
|
||||||
|
//
|
||||||
|
// D0 PD2 RXD1/INT2
|
||||||
|
// D1 PD3 TXD1/INT3
|
||||||
|
// D2 PD1 SDA SDA/INT1
|
||||||
|
// D3# PD0 PWM8/SCL OC0B/SCL/INT0
|
||||||
|
// D4 A6 PD4 ADC8
|
||||||
|
// D5# PC6 ??? OC3A/#OC4A
|
||||||
|
// D6# A7 PD7 FastPWM #OC4D/ADC10
|
||||||
|
// D7 PE6 INT6/AIN0
|
||||||
|
//
|
||||||
|
// D8 A8 PB4 ADC11/PCINT4
|
||||||
|
// D9# A9 PB5 PWM16 OC1A/#OC4B/ADC12/PCINT5
|
||||||
|
// D10# A10 PB6 PWM16 OC1B/0c4B/ADC13/PCINT6
|
||||||
|
// D11# PB7 PWM8/16 0C0A/OC1C/#RTS/PCINT7
|
||||||
|
// D12 A11 PD6 T1/#OC4D/ADC9
|
||||||
|
// D13# PC7 PWM10 CLK0/OC4A
|
||||||
|
//
|
||||||
|
// A0 D18 PF7 ADC7
|
||||||
|
// A1 D19 PF6 ADC6
|
||||||
|
// A2 D20 PF5 ADC5
|
||||||
|
// A3 D21 PF4 ADC4
|
||||||
|
// A4 D22 PF1 ADC1
|
||||||
|
// A5 D23 PF0 ADC0
|
||||||
|
//
|
||||||
|
// New pins D14..D17 to map SPI port to digital pins
|
||||||
|
//
|
||||||
|
// MISO D14 PB3 MISO,PCINT3
|
||||||
|
// SCK D15 PB1 SCK,PCINT1
|
||||||
|
// MOSI D16 PB2 MOSI,PCINT2
|
||||||
|
// SS D17 PB0 RXLED,SS/PCINT0
|
||||||
|
//
|
||||||
|
// TXLED PD5
|
||||||
|
// RXLED PB0
|
||||||
|
// HWB PE2 HWB
|
||||||
|
|
||||||
|
// these arrays map port names (e.g. port B) to the
|
||||||
|
// appropriate addresses for various functions (e.g. reading
|
||||||
|
// and writing)
|
||||||
|
const uint16_t PROGMEM port_to_mode_PGM[] = {
|
||||||
|
NOT_A_PORT,
|
||||||
|
NOT_A_PORT,
|
||||||
|
(uint16_t) &DDRB,
|
||||||
|
(uint16_t) &DDRC,
|
||||||
|
(uint16_t) &DDRD,
|
||||||
|
(uint16_t) &DDRE,
|
||||||
|
(uint16_t) &DDRF,
|
||||||
|
};
|
||||||
|
|
||||||
|
const uint16_t PROGMEM port_to_output_PGM[] = {
|
||||||
|
NOT_A_PORT,
|
||||||
|
NOT_A_PORT,
|
||||||
|
(uint16_t) &PORTB,
|
||||||
|
(uint16_t) &PORTC,
|
||||||
|
(uint16_t) &PORTD,
|
||||||
|
(uint16_t) &PORTE,
|
||||||
|
(uint16_t) &PORTF,
|
||||||
|
};
|
||||||
|
|
||||||
|
const uint16_t PROGMEM port_to_input_PGM[] = {
|
||||||
|
NOT_A_PORT,
|
||||||
|
NOT_A_PORT,
|
||||||
|
(uint16_t) &PINB,
|
||||||
|
(uint16_t) &PINC,
|
||||||
|
(uint16_t) &PIND,
|
||||||
|
(uint16_t) &PINE,
|
||||||
|
(uint16_t) &PINF,
|
||||||
|
};
|
||||||
|
|
||||||
|
const uint8_t PROGMEM digital_pin_to_port_PGM[] = {
|
||||||
|
PD, // D0 - PD2
|
||||||
|
PD, // D1 - PD3
|
||||||
|
PD, // D2 - PD1
|
||||||
|
PD, // D3 - PD0
|
||||||
|
PD, // D4 - PD4
|
||||||
|
PC, // D5 - PC6
|
||||||
|
PD, // D6 - PD7
|
||||||
|
PE, // D7 - PE6
|
||||||
|
|
||||||
|
PB, // D8 - PB4
|
||||||
|
PB, // D9 - PB5
|
||||||
|
PB, // D10 - PB6
|
||||||
|
PB, // D11 - PB7
|
||||||
|
PD, // D12 - PD6
|
||||||
|
PC, // D13 - PC7
|
||||||
|
|
||||||
|
PB, // D14 - MISO - PB3
|
||||||
|
PB, // D15 - SCK - PB1
|
||||||
|
PB, // D16 - MOSI - PB2
|
||||||
|
PB, // D17 - SS - PB0
|
||||||
|
|
||||||
|
PF, // D18 - A0 - PF7
|
||||||
|
PF, // D19 - A1 - PF6
|
||||||
|
PF, // D20 - A2 - PF5
|
||||||
|
PF, // D21 - A3 - PF4
|
||||||
|
PF, // D22 - A4 - PF1
|
||||||
|
PF, // D23 - A5 - PF0
|
||||||
|
|
||||||
|
PD, // D24 / D4 - A6 - PD4
|
||||||
|
PD, // D25 / D6 - A7 - PD7
|
||||||
|
PB, // D26 / D8 - A8 - PB4
|
||||||
|
PB, // D27 / D9 - A9 - PB5
|
||||||
|
PB, // D28 / D10 - A10 - PB6
|
||||||
|
PD, // D29 / D12 - A11 - PD6
|
||||||
|
};
|
||||||
|
|
||||||
|
const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = {
|
||||||
|
_BV(2), // D0 - PD2
|
||||||
|
_BV(3), // D1 - PD3
|
||||||
|
_BV(1), // D2 - PD1
|
||||||
|
_BV(0), // D3 - PD0
|
||||||
|
_BV(4), // D4 - PD4
|
||||||
|
_BV(6), // D5 - PC6
|
||||||
|
_BV(7), // D6 - PD7
|
||||||
|
_BV(6), // D7 - PE6
|
||||||
|
|
||||||
|
_BV(4), // D8 - PB4
|
||||||
|
_BV(5), // D9 - PB5
|
||||||
|
_BV(6), // D10 - PB6
|
||||||
|
_BV(7), // D11 - PB7
|
||||||
|
_BV(6), // D12 - PD6
|
||||||
|
_BV(7), // D13 - PC7
|
||||||
|
|
||||||
|
_BV(3), // D14 - MISO - PB3
|
||||||
|
_BV(1), // D15 - SCK - PB1
|
||||||
|
_BV(2), // D16 - MOSI - PB2
|
||||||
|
_BV(0), // D17 - SS - PB0
|
||||||
|
|
||||||
|
_BV(7), // D18 - A0 - PF7
|
||||||
|
_BV(6), // D19 - A1 - PF6
|
||||||
|
_BV(5), // D20 - A2 - PF5
|
||||||
|
_BV(4), // D21 - A3 - PF4
|
||||||
|
_BV(1), // D22 - A4 - PF1
|
||||||
|
_BV(0), // D23 - A5 - PF0
|
||||||
|
|
||||||
|
_BV(4), // D24 / D4 - A6 - PD4
|
||||||
|
_BV(7), // D25 / D6 - A7 - PD7
|
||||||
|
_BV(4), // D26 / D8 - A8 - PB4
|
||||||
|
_BV(5), // D27 / D9 - A9 - PB5
|
||||||
|
_BV(6), // D28 / D10 - A10 - PB6
|
||||||
|
_BV(6), // D29 / D12 - A11 - PD6
|
||||||
|
};
|
||||||
|
|
||||||
|
const uint8_t PROGMEM digital_pin_to_timer_PGM[] = {
|
||||||
|
NOT_ON_TIMER,
|
||||||
|
NOT_ON_TIMER,
|
||||||
|
NOT_ON_TIMER,
|
||||||
|
TIMER0B, /* 3 */
|
||||||
|
NOT_ON_TIMER,
|
||||||
|
TIMER3A, /* 5 */
|
||||||
|
TIMER4D, /* 6 */
|
||||||
|
NOT_ON_TIMER,
|
||||||
|
|
||||||
|
NOT_ON_TIMER,
|
||||||
|
TIMER1A, /* 9 */
|
||||||
|
TIMER1B, /* 10 */
|
||||||
|
TIMER0A, /* 11 */
|
||||||
|
|
||||||
|
NOT_ON_TIMER,
|
||||||
|
TIMER4A, /* 13 */
|
||||||
|
|
||||||
|
NOT_ON_TIMER,
|
||||||
|
NOT_ON_TIMER,
|
||||||
|
NOT_ON_TIMER,
|
||||||
|
NOT_ON_TIMER,
|
||||||
|
NOT_ON_TIMER,
|
||||||
|
NOT_ON_TIMER,
|
||||||
|
|
||||||
|
NOT_ON_TIMER,
|
||||||
|
NOT_ON_TIMER,
|
||||||
|
NOT_ON_TIMER,
|
||||||
|
NOT_ON_TIMER,
|
||||||
|
NOT_ON_TIMER,
|
||||||
|
NOT_ON_TIMER,
|
||||||
|
NOT_ON_TIMER,
|
||||||
|
NOT_ON_TIMER,
|
||||||
|
NOT_ON_TIMER,
|
||||||
|
NOT_ON_TIMER,
|
||||||
|
};
|
||||||
|
|
||||||
|
const uint8_t PROGMEM analog_pin_to_channel_PGM[] = {
|
||||||
|
7, // A0 PF7 ADC7
|
||||||
|
6, // A1 PF6 ADC6
|
||||||
|
5, // A2 PF5 ADC5
|
||||||
|
4, // A3 PF4 ADC4
|
||||||
|
1, // A4 PF1 ADC1
|
||||||
|
0, // A5 PF0 ADC0
|
||||||
|
8, // A6 D4 PD4 ADC8
|
||||||
|
10, // A7 D6 PD7 ADC10
|
||||||
|
11, // A8 D8 PB4 ADC11
|
||||||
|
12, // A9 D9 PB5 ADC12
|
||||||
|
13, // A10 D10 PB6 ADC13
|
||||||
|
9 // A11 D12 PD6 ADC9
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* ARDUINO_MAIN */
|
||||||
|
|
||||||
|
// These serial port names are intended to allow libraries and architecture-neutral
|
||||||
|
// sketches to automatically default to the correct port name for a particular type
|
||||||
|
// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,
|
||||||
|
// the first hardware serial port whose RX/TX pins are not dedicated to another use.
|
||||||
|
//
|
||||||
|
// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor
|
||||||
|
//
|
||||||
|
// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial
|
||||||
|
//
|
||||||
|
// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library
|
||||||
|
//
|
||||||
|
// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins.
|
||||||
|
//
|
||||||
|
// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX
|
||||||
|
// pins are NOT connected to anything by default.
|
||||||
|
#define SERIAL_PORT_MONITOR Serial
|
||||||
|
#define SERIAL_PORT_USBVIRTUAL Serial
|
||||||
|
#define SERIAL_PORT_HARDWARE Serial1
|
||||||
|
#define SERIAL_PORT_HARDWARE_OPEN Serial1
|
||||||
|
|
||||||
|
#endif /* Pins_Arduino_h */
|
@ -1,18 +0,0 @@
|
|||||||
keyboardio.name=Keyboard.IO Model 00
|
|
||||||
keyboardio.upload.protocol=avr109
|
|
||||||
keyboardio.upload.maximum_size=28672
|
|
||||||
keyboardio.upload.speed=57600
|
|
||||||
keyboardio.upload.disable_flushing=true
|
|
||||||
keyboardio.bootloader.low_fuses=0xff
|
|
||||||
keyboardio.bootloader.high_fuses=0xd8
|
|
||||||
keyboardio.bootloader.extended_fuses=0xcb
|
|
||||||
keyboardio.bootloader.path=caterina
|
|
||||||
keyboardio.bootloader.file=Caterina-keyboardio.hex
|
|
||||||
keyboardio.bootloader.unlock_bits=0x3F
|
|
||||||
keyboardio.bootloader.lock_bits=0x2F
|
|
||||||
keyboardio.build.mcu=atmega32u4
|
|
||||||
keyboardio.build.f_cpu=16000000L
|
|
||||||
keyboardio.build.vid=0x2341
|
|
||||||
keyboardio.build.pid=0x8037
|
|
||||||
keyboardio.build.core=keyboardio
|
|
||||||
keyboardio.build.variant=model00
|
|
@ -1,26 +0,0 @@
|
|||||||
#ifndef client_h
|
|
||||||
#define client_h
|
|
||||||
#include "Print.h"
|
|
||||||
#include "Stream.h"
|
|
||||||
#include "IPAddress.h"
|
|
||||||
|
|
||||||
class Client : public Stream {
|
|
||||||
|
|
||||||
public:
|
|
||||||
virtual int connect(IPAddress ip, uint16_t port) =0;
|
|
||||||
virtual int connect(const char *host, uint16_t port) =0;
|
|
||||||
virtual size_t write(uint8_t) =0;
|
|
||||||
virtual size_t write(const uint8_t *buf, size_t size) =0;
|
|
||||||
virtual int available() = 0;
|
|
||||||
virtual int read() = 0;
|
|
||||||
virtual int read(uint8_t *buf, size_t size) = 0;
|
|
||||||
virtual int peek() = 0;
|
|
||||||
virtual void flush() = 0;
|
|
||||||
virtual void stop() = 0;
|
|
||||||
virtual uint8_t connected() = 0;
|
|
||||||
virtual operator bool() = 0;
|
|
||||||
protected:
|
|
||||||
uint8_t* rawIPAddress(IPAddress& addr) { return addr.raw_address(); };
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,708 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
/* Copyright (c) 2011, Peter Barrett
|
|
||||||
**
|
|
||||||
** Sleep/Wakeup/SystemControl support added by Michael Dreher
|
|
||||||
**
|
|
||||||
** Permission to use, copy, modify, and/or distribute this software for
|
|
||||||
** any purpose with or without fee is hereby granted, provided that the
|
|
||||||
** above copyright notice and this permission notice appear in all copies.
|
|
||||||
**
|
|
||||||
** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
|
|
||||||
** WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
|
|
||||||
** WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR
|
|
||||||
** BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
|
|
||||||
** OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
|
||||||
** WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
|
||||||
** ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
|
||||||
** SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "Platform.h"
|
|
||||||
#include "USBAPI.h"
|
|
||||||
#include "USBDesc.h"
|
|
||||||
|
|
||||||
#if defined(USBCON)
|
|
||||||
#ifdef HID_ENABLED
|
|
||||||
|
|
||||||
//#define RAWHID_ENABLED
|
|
||||||
|
|
||||||
// Singletons for mouse and keyboard
|
|
||||||
|
|
||||||
Mouse_ Mouse;
|
|
||||||
Keyboard_ Keyboard;
|
|
||||||
|
|
||||||
//================================================================================
|
|
||||||
//================================================================================
|
|
||||||
|
|
||||||
// HID report descriptor
|
|
||||||
|
|
||||||
#define LSB(_x) ((_x) & 0xFF)
|
|
||||||
#define MSB(_x) ((_x) >> 8)
|
|
||||||
|
|
||||||
#define RAWHID_USAGE_PAGE 0xFFC0
|
|
||||||
#define RAWHID_USAGE 0x0C00
|
|
||||||
#define RAWHID_TX_SIZE 64
|
|
||||||
#define RAWHID_RX_SIZE 64
|
|
||||||
|
|
||||||
#define HID_REPORTID_MOUSE (1)
|
|
||||||
#define HID_REPORTID_KEYBOARD (2)
|
|
||||||
#define HID_REPORTID_RAWHID (3)
|
|
||||||
#define HID_REPORTID_SYSTEMCONTROL (4)
|
|
||||||
#define HID_REPORTID_MOUSE_ABS (5)
|
|
||||||
#define HID_REPORTID_CONSUMERCONTROL (6)
|
|
||||||
|
|
||||||
extern const u8 _hidReportDescriptor[] PROGMEM;
|
|
||||||
const u8 _hidReportDescriptor[] = {
|
|
||||||
|
|
||||||
// Mouse relative
|
|
||||||
0x05, 0x01, // USAGE_PAGE (Generic Desktop) // 54
|
|
||||||
0x09, 0x02, // USAGE (Mouse)
|
|
||||||
0xa1, 0x01, // COLLECTION (Application)
|
|
||||||
0x09, 0x01, // USAGE (Pointer)
|
|
||||||
0xa1, 0x00, // COLLECTION (Physical)
|
|
||||||
0x85, HID_REPORTID_MOUSE, // REPORT_ID (1)
|
|
||||||
0x05, 0x09, // USAGE_PAGE (Button)
|
|
||||||
0x19, 0x01, // USAGE_MINIMUM (Button 1)
|
|
||||||
0x29, 0x03, // USAGE_MAXIMUM (Button 3)
|
|
||||||
0x15, 0x00, // LOGICAL_MINIMUM (0)
|
|
||||||
0x25, 0x01, // LOGICAL_MAXIMUM (1)
|
|
||||||
0x95, 0x03, // REPORT_COUNT (3)
|
|
||||||
0x75, 0x01, // REPORT_SIZE (1)
|
|
||||||
0x81, 0x02, // INPUT (Data,Var,Abs)
|
|
||||||
0x95, 0x01, // REPORT_COUNT (1)
|
|
||||||
0x75, 0x05, // REPORT_SIZE (5)
|
|
||||||
0x81, 0x03, // INPUT (Cnst,Var,Abs)
|
|
||||||
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
|
|
||||||
0x09, 0x30, // USAGE (X)
|
|
||||||
0x09, 0x31, // USAGE (Y)
|
|
||||||
0x09, 0x38, // USAGE (Wheel)
|
|
||||||
0x15, 0x81, // LOGICAL_MINIMUM (-127)
|
|
||||||
0x25, 0x7f, // LOGICAL_MAXIMUM (127)
|
|
||||||
0x75, 0x08, // REPORT_SIZE (8)
|
|
||||||
0x95, 0x03, // REPORT_COUNT (3)
|
|
||||||
0x81, 0x06, // INPUT (Data,Var,Rel)
|
|
||||||
0xc0, // END_COLLECTION
|
|
||||||
0xc0, // END_COLLECTION
|
|
||||||
#ifdef MOUSE_ABS_ENABLED
|
|
||||||
// Mouse absolute
|
|
||||||
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
|
|
||||||
0x09, 0x02, // USAGE (Mouse)
|
|
||||||
0xa1, 0x01, // COLLECTION (Application)
|
|
||||||
0x09, 0x01, // USAGE (Pointer)
|
|
||||||
0xa1, 0x00, // COLLECTION (Physical)
|
|
||||||
0x85, HID_REPORTID_MOUSE_ABS, // REPORT_ID (5)
|
|
||||||
0x05, 0x09, // USAGE_PAGE (Button)
|
|
||||||
0x19, 0x01, // USAGE_MINIMUM (Button 1)
|
|
||||||
0x29, 0x03, // USAGE_MAXIMUM (Button 3)
|
|
||||||
0x15, 0x00, // LOGICAL_MINIMUM (0)
|
|
||||||
0x25, 0x01, // LOGICAL_MAXIMUM (1)
|
|
||||||
0x95, 0x03, // REPORT_COUNT (3)
|
|
||||||
0x75, 0x01, // REPORT_SIZE (1)
|
|
||||||
0x81, 0x02, // INPUT (Data,Var,Abs)
|
|
||||||
0x95, 0x01, // REPORT_COUNT (1)
|
|
||||||
0x75, 0x05, // REPORT_SIZE (5)
|
|
||||||
0x81, 0x03, // INPUT (Cnst,Var,Abs)
|
|
||||||
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
|
|
||||||
0x09, 0x30, // USAGE (X)
|
|
||||||
0x09, 0x31, // USAGE (Y)
|
|
||||||
0x09, 0x38, // USAGE (Wheel)
|
|
||||||
0x16, 0x00, 0x80, // LOGICAL_MINIMUM (-32768)
|
|
||||||
0x26, 0xff, 0x7f, // LOGICAL_MAXIMUM (32767)
|
|
||||||
0x75, 0x10, // REPORT_SIZE (16)
|
|
||||||
0x95, 0x03, // REPORT_COUNT (3)
|
|
||||||
0x81, 0x02, // INPUT (Data,Var,Abs)
|
|
||||||
0xc0, // END_COLLECTION
|
|
||||||
0xc0, // END_COLLECTION
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Keyboard
|
|
||||||
0x05, 0x01, // USAGE_PAGE (Generic Desktop) // 47
|
|
||||||
0x09, 0x06, // USAGE (Keyboard)
|
|
||||||
0xa1, 0x01, // COLLECTION (Application)
|
|
||||||
0x85, HID_REPORTID_KEYBOARD, // REPORT_ID (2)
|
|
||||||
0x05, 0x07, // USAGE_PAGE (Keyboard)
|
|
||||||
|
|
||||||
// Keyboard Modifiers (shift, alt, ...)
|
|
||||||
0x19, 0xe0, // USAGE_MINIMUM (Keyboard LeftControl)
|
|
||||||
0x29, 0xe7, // USAGE_MAXIMUM (Keyboard Right GUI)
|
|
||||||
0x15, 0x00, // LOGICAL_MINIMUM (0)
|
|
||||||
0x25, 0x01, // LOGICAL_MAXIMUM (1)
|
|
||||||
0x75, 0x01, // REPORT_SIZE (1)
|
|
||||||
|
|
||||||
0x95, 0x08, // REPORT_COUNT (8)
|
|
||||||
0x81, 0x02, // INPUT (Data,Var,Abs)
|
|
||||||
0x95, 0x01, // REPORT_COUNT (1)
|
|
||||||
0x75, 0x08, // REPORT_SIZE (8)
|
|
||||||
0x81, 0x03, // INPUT (Cnst,Var,Abs)
|
|
||||||
|
|
||||||
// Keyboard keys
|
|
||||||
0x95, 0x06, // REPORT_COUNT (6)
|
|
||||||
0x75, 0x08, // REPORT_SIZE (8)
|
|
||||||
0x15, 0x00, // LOGICAL_MINIMUM (0)
|
|
||||||
0x26, 0xDF, 0x00, // LOGICAL_MAXIMUM (239)
|
|
||||||
0x05, 0x07, // USAGE_PAGE (Keyboard)
|
|
||||||
0x19, 0x00, // USAGE_MINIMUM (Reserved (no event indicated))
|
|
||||||
0x29, 0xDF, // USAGE_MAXIMUM (Left Control - 1)
|
|
||||||
0x81, 0x00, // INPUT (Data,Ary,Abs)
|
|
||||||
0xc0, // END_COLLECTION
|
|
||||||
|
|
||||||
// System Control (Power Down, Sleep, Wakeup, ...)
|
|
||||||
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
|
|
||||||
0x09, 0x80, // USAGE (System Control)
|
|
||||||
0xa1, 0x01, // COLLECTION (Application)
|
|
||||||
0x85, HID_REPORTID_SYSTEMCONTROL,// REPORT_ID (4)
|
|
||||||
0x09, 0x81, // USAGE (System Power Down)
|
|
||||||
0x09, 0x82, // USAGE (System Sleep)
|
|
||||||
0x09, 0x83, // USAGE (System Wakeup)
|
|
||||||
0x09, 0x8E, // USAGE (System Cold Restart)
|
|
||||||
0x09, 0x8F, // USAGE (System Warm Restart)
|
|
||||||
0x09, 0xA0, // USAGE (System Dock)
|
|
||||||
0x09, 0xA1, // USAGE (System Undock)
|
|
||||||
0x09, 0xA7, // USAGE (System Speaker Mute)
|
|
||||||
0x09, 0xA8, // USAGE (System Hibernate)
|
|
||||||
// although these display usages are not that important, they don't cost much more than declaring
|
|
||||||
// the otherwise necessary constant fill bits
|
|
||||||
0x09, 0xB0, // USAGE (System Display Invert)
|
|
||||||
0x09, 0xB1, // USAGE (System Display Internal)
|
|
||||||
0x09, 0xB2, // USAGE (System Display External)
|
|
||||||
0x09, 0xB3, // USAGE (System Display Both)
|
|
||||||
0x09, 0xB4, // USAGE (System Display Dual)
|
|
||||||
0x09, 0xB5, // USAGE (System Display Toggle Intern/Extern)
|
|
||||||
0x09, 0xB6, // USAGE (System Display Swap)
|
|
||||||
0x15, 0x00, // LOGICAL_MINIMUM (0)
|
|
||||||
0x25, 0x01, // LOGICAL_MAXIMUM (1)
|
|
||||||
0x75, 0x01, // REPORT_SIZE (1)
|
|
||||||
0x95, 0x10, // REPORT_COUNT (16)
|
|
||||||
0x81, 0x02, // INPUT (Data,Var,Abs)
|
|
||||||
0xc0, // END_COLLECTION
|
|
||||||
|
|
||||||
#if RAWHID_ENABLED
|
|
||||||
// RAW HID
|
|
||||||
0x06, LSB(RAWHID_USAGE_PAGE), MSB(RAWHID_USAGE_PAGE), // 30
|
|
||||||
0x0A, LSB(RAWHID_USAGE), MSB(RAWHID_USAGE),
|
|
||||||
|
|
||||||
0xA1, 0x01, // Collection 0x01
|
|
||||||
0x85, HID_REPORTID_RAWHID, // REPORT_ID (3)
|
|
||||||
0x75, 0x08, // report size = 8 bits
|
|
||||||
0x15, 0x00, // logical minimum = 0
|
|
||||||
0x26, 0xFF, 0x00, // logical maximum = 255
|
|
||||||
|
|
||||||
0x95, 64, // report count TX
|
|
||||||
0x09, 0x01, // usage
|
|
||||||
0x81, 0x02, // Input (array)
|
|
||||||
|
|
||||||
0x95, 64, // report count RX
|
|
||||||
0x09, 0x02, // usage
|
|
||||||
0x91, 0x02, // Output (array)
|
|
||||||
0xC0 // end collection
|
|
||||||
#endif
|
|
||||||
|
|
||||||
0x05, 0x0c, // USAGE_PAGE (Consumer Devices)
|
|
||||||
0x09, 0x01, // USAGE (Consumer Control)
|
|
||||||
0xa1, 0x01, // COLLECTION (Application)
|
|
||||||
0x85, HID_REPORTID_CONSUMERCONTROL, // REPORT_ID (4)
|
|
||||||
0x15, 0x00, // LOGICAL_MINIMUM (0)
|
|
||||||
0x25, 0x01, // LOGICAL_MAXIMUM (1)
|
|
||||||
0x75, 0x01, // REPORT_SIZE (1)
|
|
||||||
0x95, 0x10, // REPORT_COUNT (16)
|
|
||||||
0x09, 0xe2, // USAGE (Mute) 0x01
|
|
||||||
0x09, 0xe9, // USAGE (Volume Up) 0x02
|
|
||||||
0x09, 0xea, // USAGE (Volume Down) 0x03
|
|
||||||
0x09, 0xcd, // USAGE (Play/Pause) 0x04
|
|
||||||
0x09, 0xb7, // USAGE (Stop) 0x05
|
|
||||||
0x09, 0xb6, // USAGE (Scan Previous Track) 0x06
|
|
||||||
0x09, 0xb5, // USAGE (Scan Next Track) 0x07
|
|
||||||
0x0a, 0x8a, 0x01, // USAGE (Mail) 0x08
|
|
||||||
0x0a, 0x92, 0x01, // USAGE (Calculator) 0x09
|
|
||||||
0x0a, 0x21, 0x02, // USAGE (www search) 0x0a
|
|
||||||
0x0a, 0x23, 0x02, // USAGE (www home) 0x0b
|
|
||||||
0x0a, 0x2a, 0x02, // USAGE (www favorites) 0x0c
|
|
||||||
0x0a, 0x27, 0x02, // USAGE (www refresh) 0x0d
|
|
||||||
0x0a, 0x26, 0x02, // USAGE (www stop) 0x0e
|
|
||||||
0x0a, 0x25, 0x02, // USAGE (www forward) 0x0f
|
|
||||||
0x0a, 0x24, 0x02, // USAGE (www back) 0x10
|
|
||||||
0x81, 0x62, // INPUT (Data,Var,Abs,NPrf,Null)
|
|
||||||
0xc0,
|
|
||||||
};
|
|
||||||
|
|
||||||
extern const HIDDescriptor _hidInterface PROGMEM;
|
|
||||||
const HIDDescriptor _hidInterface =
|
|
||||||
{
|
|
||||||
D_INTERFACE(HID_INTERFACE,1,3,0,0),
|
|
||||||
D_HIDREPORT(sizeof(_hidReportDescriptor)),
|
|
||||||
D_ENDPOINT(USB_ENDPOINT_IN (HID_ENDPOINT_INT),USB_ENDPOINT_TYPE_INTERRUPT,0x40,0x01)
|
|
||||||
};
|
|
||||||
|
|
||||||
//================================================================================
|
|
||||||
//================================================================================
|
|
||||||
// Driver
|
|
||||||
|
|
||||||
u8 _hid_protocol = 1;
|
|
||||||
u8 _hid_idle = 1;
|
|
||||||
|
|
||||||
#define WEAK __attribute__ ((weak))
|
|
||||||
|
|
||||||
int WEAK HID_GetInterface(u8* interfaceNum)
|
|
||||||
{
|
|
||||||
interfaceNum[0] += 1; // uses 1
|
|
||||||
return USB_SendControl(TRANSFER_PGM,&_hidInterface,sizeof(_hidInterface));
|
|
||||||
}
|
|
||||||
|
|
||||||
int WEAK HID_GetDescriptor(int i)
|
|
||||||
{
|
|
||||||
return USB_SendControl(TRANSFER_PGM,_hidReportDescriptor,sizeof(_hidReportDescriptor));
|
|
||||||
}
|
|
||||||
|
|
||||||
void WEAK HID_SendReport(u8 id, const void* data, int len)
|
|
||||||
{
|
|
||||||
USB_Send(HID_TX, &id, 1);
|
|
||||||
USB_Send(HID_TX | TRANSFER_RELEASE,data,len);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool WEAK HID_Setup(Setup& setup)
|
|
||||||
{
|
|
||||||
u8 r = setup.bRequest;
|
|
||||||
u8 requestType = setup.bmRequestType;
|
|
||||||
if (REQUEST_DEVICETOHOST_CLASS_INTERFACE == requestType)
|
|
||||||
{
|
|
||||||
if (HID_GET_REPORT == r)
|
|
||||||
{
|
|
||||||
//HID_GetReport();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (HID_GET_PROTOCOL == r)
|
|
||||||
{
|
|
||||||
//Send8(_hid_protocol); // TODO
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (REQUEST_HOSTTODEVICE_CLASS_INTERFACE == requestType)
|
|
||||||
{
|
|
||||||
if (HID_SET_PROTOCOL == r)
|
|
||||||
{
|
|
||||||
_hid_protocol = setup.wValueL;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (HID_SET_IDLE == r)
|
|
||||||
{
|
|
||||||
_hid_idle = setup.wValueL;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//================================================================================
|
|
||||||
//================================================================================
|
|
||||||
// Mouse
|
|
||||||
|
|
||||||
Mouse_::Mouse_(void) : _buttons(0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Mouse_::begin(void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Mouse_::end(void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Mouse_::click(uint8_t b)
|
|
||||||
{
|
|
||||||
_buttons = b;
|
|
||||||
move(0,0,0);
|
|
||||||
_buttons = 0;
|
|
||||||
move(0,0,0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Mouse_::move(signed char x, signed char y, signed char wheel)
|
|
||||||
{
|
|
||||||
u8 m[4];
|
|
||||||
m[0] = _buttons;
|
|
||||||
m[1] = x;
|
|
||||||
m[2] = y;
|
|
||||||
m[3] = wheel;
|
|
||||||
HID_SendReport(HID_REPORTID_MOUSE,m,sizeof(m));
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef MOUSE_ABS_ENABLED
|
|
||||||
// all parameters have the range of -32768 to 32767 and must be scaled to screen pixels
|
|
||||||
// some examples:
|
|
||||||
// x=0,y=0 is the middle of the screen
|
|
||||||
// x=-32768,y=-32768 is the top left corner
|
|
||||||
// x=32767,y=-32768 is the top right corner
|
|
||||||
// x=32767,y=32767 is the bottom right corner
|
|
||||||
// x=-32768,y=32767 is the bottom left corner
|
|
||||||
void Mouse_::moveAbs(int16_t x, int16_t y, int16_t wheel)
|
|
||||||
{
|
|
||||||
u8 m[7];
|
|
||||||
m[0] = _buttons; // TODO: is it a good idea to take over the _buttons from relative report here or should it be left out?
|
|
||||||
m[1] = LSB(x);
|
|
||||||
m[2] = MSB(x);
|
|
||||||
m[3] = LSB(y);
|
|
||||||
m[4] = MSB(y);
|
|
||||||
m[5] = LSB(wheel);
|
|
||||||
m[6] = MSB(wheel);
|
|
||||||
HID_SendReport(HID_REPORTID_MOUSE_ABS,m,sizeof(m));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void Mouse_::buttons(uint8_t b)
|
|
||||||
{
|
|
||||||
if (b != _buttons)
|
|
||||||
{
|
|
||||||
_buttons = b;
|
|
||||||
move(0,0,0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Mouse_::press(uint8_t b)
|
|
||||||
{
|
|
||||||
buttons(_buttons | b);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Mouse_::release(uint8_t b)
|
|
||||||
{
|
|
||||||
buttons(_buttons & ~b);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Mouse_::isPressed(uint8_t b)
|
|
||||||
{
|
|
||||||
if ((b & _buttons) > 0)
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//================================================================================
|
|
||||||
//================================================================================
|
|
||||||
// Keyboard
|
|
||||||
|
|
||||||
Keyboard_::Keyboard_(void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Keyboard_::begin(void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Keyboard_::end(void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Keyboard_::sendReport(KeyReport* keys)
|
|
||||||
{
|
|
||||||
HID_SendReport(HID_REPORTID_KEYBOARD,keys,sizeof(*keys));
|
|
||||||
}
|
|
||||||
|
|
||||||
extern
|
|
||||||
const uint8_t _asciimap[128] PROGMEM;
|
|
||||||
|
|
||||||
#define SHIFT 0x80
|
|
||||||
const uint8_t _asciimap[128] =
|
|
||||||
{
|
|
||||||
0x00, // NUL
|
|
||||||
0x00, // SOH
|
|
||||||
0x00, // STX
|
|
||||||
0x00, // ETX
|
|
||||||
0x00, // EOT
|
|
||||||
0x00, // ENQ
|
|
||||||
0x00, // ACK
|
|
||||||
0x00, // BEL
|
|
||||||
0x2a, // BS Backspace
|
|
||||||
0x2b, // TAB Tab
|
|
||||||
0x28, // LF Enter
|
|
||||||
0x00, // VT
|
|
||||||
0x00, // FF
|
|
||||||
0x00, // CR
|
|
||||||
0x00, // SO
|
|
||||||
0x00, // SI
|
|
||||||
0x00, // DEL
|
|
||||||
0x00, // DC1
|
|
||||||
0x00, // DC2
|
|
||||||
0x00, // DC3
|
|
||||||
0x00, // DC4
|
|
||||||
0x00, // NAK
|
|
||||||
0x00, // SYN
|
|
||||||
0x00, // ETB
|
|
||||||
0x00, // CAN
|
|
||||||
0x00, // EM
|
|
||||||
0x00, // SUB
|
|
||||||
0x00, // ESC
|
|
||||||
0x00, // FS
|
|
||||||
0x00, // GS
|
|
||||||
0x00, // RS
|
|
||||||
0x00, // US
|
|
||||||
|
|
||||||
0x2c, // ' '
|
|
||||||
0x1e|SHIFT, // !
|
|
||||||
0x34|SHIFT, // "
|
|
||||||
0x20|SHIFT, // #
|
|
||||||
0x21|SHIFT, // $
|
|
||||||
0x22|SHIFT, // %
|
|
||||||
0x24|SHIFT, // &
|
|
||||||
0x34, // '
|
|
||||||
0x26|SHIFT, // (
|
|
||||||
0x27|SHIFT, // )
|
|
||||||
0x25|SHIFT, // *
|
|
||||||
0x2e|SHIFT, // +
|
|
||||||
0x36, // ,
|
|
||||||
0x2d, // -
|
|
||||||
0x37, // .
|
|
||||||
0x38, // /
|
|
||||||
0x27, // 0
|
|
||||||
0x1e, // 1
|
|
||||||
0x1f, // 2
|
|
||||||
0x20, // 3
|
|
||||||
0x21, // 4
|
|
||||||
0x22, // 5
|
|
||||||
0x23, // 6
|
|
||||||
0x24, // 7
|
|
||||||
0x25, // 8
|
|
||||||
0x26, // 9
|
|
||||||
0x33|SHIFT, // :
|
|
||||||
0x33, // ;
|
|
||||||
0x36|SHIFT, // <
|
|
||||||
0x2e, // =
|
|
||||||
0x37|SHIFT, // >
|
|
||||||
0x38|SHIFT, // ?
|
|
||||||
0x1f|SHIFT, // @
|
|
||||||
0x04|SHIFT, // A
|
|
||||||
0x05|SHIFT, // B
|
|
||||||
0x06|SHIFT, // C
|
|
||||||
0x07|SHIFT, // D
|
|
||||||
0x08|SHIFT, // E
|
|
||||||
0x09|SHIFT, // F
|
|
||||||
0x0a|SHIFT, // G
|
|
||||||
0x0b|SHIFT, // H
|
|
||||||
0x0c|SHIFT, // I
|
|
||||||
0x0d|SHIFT, // J
|
|
||||||
0x0e|SHIFT, // K
|
|
||||||
0x0f|SHIFT, // L
|
|
||||||
0x10|SHIFT, // M
|
|
||||||
0x11|SHIFT, // N
|
|
||||||
0x12|SHIFT, // O
|
|
||||||
0x13|SHIFT, // P
|
|
||||||
0x14|SHIFT, // Q
|
|
||||||
0x15|SHIFT, // R
|
|
||||||
0x16|SHIFT, // S
|
|
||||||
0x17|SHIFT, // T
|
|
||||||
0x18|SHIFT, // U
|
|
||||||
0x19|SHIFT, // V
|
|
||||||
0x1a|SHIFT, // W
|
|
||||||
0x1b|SHIFT, // X
|
|
||||||
0x1c|SHIFT, // Y
|
|
||||||
0x1d|SHIFT, // Z
|
|
||||||
0x2f, // [
|
|
||||||
0x31, // bslash
|
|
||||||
0x30, // ]
|
|
||||||
0x23|SHIFT, // ^
|
|
||||||
0x2d|SHIFT, // _
|
|
||||||
0x35, // `
|
|
||||||
0x04, // a
|
|
||||||
0x05, // b
|
|
||||||
0x06, // c
|
|
||||||
0x07, // d
|
|
||||||
0x08, // e
|
|
||||||
0x09, // f
|
|
||||||
0x0a, // g
|
|
||||||
0x0b, // h
|
|
||||||
0x0c, // i
|
|
||||||
0x0d, // j
|
|
||||||
0x0e, // k
|
|
||||||
0x0f, // l
|
|
||||||
0x10, // m
|
|
||||||
0x11, // n
|
|
||||||
0x12, // o
|
|
||||||
0x13, // p
|
|
||||||
0x14, // q
|
|
||||||
0x15, // r
|
|
||||||
0x16, // s
|
|
||||||
0x17, // t
|
|
||||||
0x18, // u
|
|
||||||
0x19, // v
|
|
||||||
0x1a, // w
|
|
||||||
0x1b, // x
|
|
||||||
0x1c, // y
|
|
||||||
0x1d, // z
|
|
||||||
0x2f|SHIFT, //
|
|
||||||
0x31|SHIFT, // |
|
|
||||||
0x30|SHIFT, // }
|
|
||||||
0x35|SHIFT, // ~
|
|
||||||
0 // DEL
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t USBPutChar(uint8_t c);
|
|
||||||
|
|
||||||
// press() adds the specified key (printing, non-printing, or modifier)
|
|
||||||
// to the persistent key report and sends the report. Because of the way
|
|
||||||
// USB HID works, the host acts like the key remains pressed until we
|
|
||||||
// call release(), releaseAll(), or otherwise clear the report and resend.
|
|
||||||
size_t Keyboard_::press(uint8_t k)
|
|
||||||
{
|
|
||||||
uint8_t i;
|
|
||||||
if (k >= 136) { // it's a non-printing key (not a modifier)
|
|
||||||
k = k - 136;
|
|
||||||
} else if (k >= 128) { // it's a modifier key
|
|
||||||
_keyReport.modifiers |= (1<<(k-128));
|
|
||||||
k = 0;
|
|
||||||
} else { // it's a printing key
|
|
||||||
k = pgm_read_byte(_asciimap + k);
|
|
||||||
if (!k) {
|
|
||||||
setWriteError();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (k & 0x80) { // it's a capital letter or other character reached with shift
|
|
||||||
_keyReport.modifiers |= 0x02; // the left shift modifier
|
|
||||||
k &= 0x7F;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add k to the key report only if it's not already present
|
|
||||||
// and if there is an empty slot.
|
|
||||||
if (_keyReport.keys[0] != k && _keyReport.keys[1] != k &&
|
|
||||||
_keyReport.keys[2] != k && _keyReport.keys[3] != k &&
|
|
||||||
_keyReport.keys[4] != k && _keyReport.keys[5] != k) {
|
|
||||||
|
|
||||||
for (i=0; i<6; i++) {
|
|
||||||
if (_keyReport.keys[i] == 0x00) {
|
|
||||||
_keyReport.keys[i] = k;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (i == 6) {
|
|
||||||
setWriteError();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sendReport(&_keyReport);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// System Control
|
|
||||||
// k is one of the SYSTEM_CONTROL defines which come from the HID usage table "Generic Desktop Page (0x01)"
|
|
||||||
// in "HID Usage Tables" (HUT1_12v2.pdf)
|
|
||||||
size_t Keyboard_::systemControl(uint8_t k)
|
|
||||||
{
|
|
||||||
if(k <= 16)
|
|
||||||
{
|
|
||||||
u16 mask = 0;
|
|
||||||
u8 m[2];
|
|
||||||
|
|
||||||
if(k > 0)
|
|
||||||
{
|
|
||||||
mask = 1 << (k - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
m[0] = LSB(mask);
|
|
||||||
m[1] = MSB(mask);
|
|
||||||
HID_SendReport(HID_REPORTID_SYSTEMCONTROL,m,sizeof(m));
|
|
||||||
|
|
||||||
// these are all OSCs, so send a clear to make it possible to send it again later
|
|
||||||
m[0] = 0;
|
|
||||||
m[1] = 0;
|
|
||||||
HID_SendReport(HID_REPORTID_SYSTEMCONTROL,m,sizeof(m));
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
setWriteError();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Consumer Control
|
|
||||||
// k is one of the CONSUMER_CONTROL defines which come from the HID usage table "Consumer Devices Page (0x0c)"
|
|
||||||
// in "HID Usage Tables" (HUT1_12v2.pdf)
|
|
||||||
size_t Keyboard_::consumerControl(uint8_t k)
|
|
||||||
{
|
|
||||||
if(k <= 16)
|
|
||||||
{
|
|
||||||
u16 mask = 0;
|
|
||||||
u8 m[2];
|
|
||||||
|
|
||||||
if(k > 0)
|
|
||||||
{
|
|
||||||
mask = 1 << (k - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
m[0] = LSB(mask);
|
|
||||||
m[1] = MSB(mask);
|
|
||||||
HID_SendReport(HID_REPORTID_CONSUMERCONTROL,m,sizeof(m));
|
|
||||||
|
|
||||||
// these are all OSCs, so send a clear to make it possible to send it again later
|
|
||||||
m[0] = 0;
|
|
||||||
m[1] = 0;
|
|
||||||
HID_SendReport(HID_REPORTID_CONSUMERCONTROL,m,sizeof(m));
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
setWriteError();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// release() takes the specified key out of the persistent key report and
|
|
||||||
// sends the report. This tells the OS the key is no longer pressed and that
|
|
||||||
// it shouldn't be repeated any more.
|
|
||||||
size_t Keyboard_::release(uint8_t k)
|
|
||||||
{
|
|
||||||
uint8_t i;
|
|
||||||
if (k >= 136) { // it's a non-printing key (not a modifier)
|
|
||||||
k = k - 136;
|
|
||||||
} else if (k >= 128) { // it's a modifier key
|
|
||||||
_keyReport.modifiers &= ~(1<<(k-128));
|
|
||||||
k = 0;
|
|
||||||
} else { // it's a printing key
|
|
||||||
k = pgm_read_byte(_asciimap + k);
|
|
||||||
if (!k) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (k & 0x80) { // it's a capital letter or other character reached with shift
|
|
||||||
_keyReport.modifiers &= ~(0x02); // the left shift modifier
|
|
||||||
k &= 0x7F;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test the key report to see if k is present. Clear it if it exists.
|
|
||||||
// Check all positions in case the key is present more than once (which it shouldn't be)
|
|
||||||
for (i=0; i<6; i++) {
|
|
||||||
if (0 != k && _keyReport.keys[i] == k) {
|
|
||||||
_keyReport.keys[i] = 0x00;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sendReport(&_keyReport);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Keyboard_::releaseAll(void)
|
|
||||||
{
|
|
||||||
_keyReport.keys[0] = 0;
|
|
||||||
_keyReport.keys[1] = 0;
|
|
||||||
_keyReport.keys[2] = 0;
|
|
||||||
_keyReport.keys[3] = 0;
|
|
||||||
_keyReport.keys[4] = 0;
|
|
||||||
_keyReport.keys[5] = 0;
|
|
||||||
_keyReport.modifiers = 0;
|
|
||||||
sendReport(&_keyReport);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t Keyboard_::write(uint8_t c)
|
|
||||||
{
|
|
||||||
uint8_t p = press(c); // Keydown
|
|
||||||
uint8_t r = release(c); // Keyup
|
|
||||||
return (p); // just return the result of press() since release() almost always returns 1
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* if defined(USBCON) */
|
|
@ -1,508 +0,0 @@
|
|||||||
/*
|
|
||||||
HardwareSerial.cpp - Hardware serial library for Wiring
|
|
||||||
Copyright (c) 2006 Nicholas Zambetti. All right reserved.
|
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This library is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with this library; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
|
|
||||||
Modified 23 November 2006 by David A. Mellis
|
|
||||||
Modified 28 September 2010 by Mark Sproul
|
|
||||||
Modified 14 August 2012 by Alarus
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <inttypes.h>
|
|
||||||
#include "Arduino.h"
|
|
||||||
#include "wiring_private.h"
|
|
||||||
|
|
||||||
// this next line disables the entire HardwareSerial.cpp,
|
|
||||||
// this is so I can support Attiny series and any other chip without a uart
|
|
||||||
#if defined(UBRRH) || defined(UBRR0H) || defined(UBRR1H) || defined(UBRR2H) || defined(UBRR3H)
|
|
||||||
|
|
||||||
#include "HardwareSerial.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* on ATmega8, the uart and its bits are not numbered, so there is no "TXC0"
|
|
||||||
* definition.
|
|
||||||
*/
|
|
||||||
#if !defined(TXC0)
|
|
||||||
#if defined(TXC)
|
|
||||||
#define TXC0 TXC
|
|
||||||
#elif defined(TXC1)
|
|
||||||
// Some devices have uart1 but no uart0
|
|
||||||
#define TXC0 TXC1
|
|
||||||
#else
|
|
||||||
#error TXC0 not definable in HardwareSerial.h
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Define constants and variables for buffering incoming serial data. We're
|
|
||||||
// using a ring buffer (I think), in which head is the index of the location
|
|
||||||
// to which to write the next incoming character and tail is the index of the
|
|
||||||
// location from which to read.
|
|
||||||
#if (RAMEND < 1000)
|
|
||||||
#define SERIAL_BUFFER_SIZE 16
|
|
||||||
#else
|
|
||||||
#define SERIAL_BUFFER_SIZE 64
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct ring_buffer
|
|
||||||
{
|
|
||||||
unsigned char buffer[SERIAL_BUFFER_SIZE];
|
|
||||||
volatile unsigned int head;
|
|
||||||
volatile unsigned int tail;
|
|
||||||
};
|
|
||||||
|
|
||||||
#if defined(USBCON)
|
|
||||||
ring_buffer rx_buffer = { { 0 }, 0, 0};
|
|
||||||
ring_buffer tx_buffer = { { 0 }, 0, 0};
|
|
||||||
#endif
|
|
||||||
#if defined(UBRRH) || defined(UBRR0H)
|
|
||||||
ring_buffer rx_buffer = { { 0 }, 0, 0 };
|
|
||||||
ring_buffer tx_buffer = { { 0 }, 0, 0 };
|
|
||||||
#endif
|
|
||||||
#if defined(UBRR1H)
|
|
||||||
ring_buffer rx_buffer1 = { { 0 }, 0, 0 };
|
|
||||||
ring_buffer tx_buffer1 = { { 0 }, 0, 0 };
|
|
||||||
#endif
|
|
||||||
#if defined(UBRR2H)
|
|
||||||
ring_buffer rx_buffer2 = { { 0 }, 0, 0 };
|
|
||||||
ring_buffer tx_buffer2 = { { 0 }, 0, 0 };
|
|
||||||
#endif
|
|
||||||
#if defined(UBRR3H)
|
|
||||||
ring_buffer rx_buffer3 = { { 0 }, 0, 0 };
|
|
||||||
ring_buffer tx_buffer3 = { { 0 }, 0, 0 };
|
|
||||||
#endif
|
|
||||||
|
|
||||||
inline void store_char(unsigned char c, ring_buffer *buffer)
|
|
||||||
{
|
|
||||||
int i = (unsigned int)(buffer->head + 1) % SERIAL_BUFFER_SIZE;
|
|
||||||
|
|
||||||
// if we should be storing the received character into the location
|
|
||||||
// just before the tail (meaning that the head would advance to the
|
|
||||||
// current location of the tail), we're about to overflow the buffer
|
|
||||||
// and so we don't write the character or advance the head.
|
|
||||||
if (i != buffer->tail) {
|
|
||||||
buffer->buffer[buffer->head] = c;
|
|
||||||
buffer->head = i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#if !defined(USART0_RX_vect) && defined(USART1_RX_vect)
|
|
||||||
// do nothing - on the 32u4 the first USART is USART1
|
|
||||||
#else
|
|
||||||
#if !defined(USART_RX_vect) && !defined(USART0_RX_vect) && \
|
|
||||||
!defined(USART_RXC_vect)
|
|
||||||
#error "Don't know what the Data Received vector is called for the first UART"
|
|
||||||
#else
|
|
||||||
void serialEvent() __attribute__((weak));
|
|
||||||
void serialEvent() {}
|
|
||||||
#define serialEvent_implemented
|
|
||||||
#if defined(USART_RX_vect)
|
|
||||||
ISR(USART_RX_vect)
|
|
||||||
#elif defined(USART0_RX_vect)
|
|
||||||
ISR(USART0_RX_vect)
|
|
||||||
#elif defined(USART_RXC_vect)
|
|
||||||
ISR(USART_RXC_vect) // ATmega8
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
#if defined(UDR0)
|
|
||||||
if (bit_is_clear(UCSR0A, UPE0)) {
|
|
||||||
unsigned char c = UDR0;
|
|
||||||
store_char(c, &rx_buffer);
|
|
||||||
} else {
|
|
||||||
unsigned char c = UDR0;
|
|
||||||
};
|
|
||||||
#elif defined(UDR)
|
|
||||||
if (bit_is_clear(UCSRA, PE)) {
|
|
||||||
unsigned char c = UDR;
|
|
||||||
store_char(c, &rx_buffer);
|
|
||||||
} else {
|
|
||||||
unsigned char c = UDR;
|
|
||||||
};
|
|
||||||
#else
|
|
||||||
#error UDR not defined
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(USART1_RX_vect)
|
|
||||||
void serialEvent1() __attribute__((weak));
|
|
||||||
void serialEvent1() {}
|
|
||||||
#define serialEvent1_implemented
|
|
||||||
ISR(USART1_RX_vect)
|
|
||||||
{
|
|
||||||
if (bit_is_clear(UCSR1A, UPE1)) {
|
|
||||||
unsigned char c = UDR1;
|
|
||||||
store_char(c, &rx_buffer1);
|
|
||||||
} else {
|
|
||||||
unsigned char c = UDR1;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(USART2_RX_vect) && defined(UDR2)
|
|
||||||
void serialEvent2() __attribute__((weak));
|
|
||||||
void serialEvent2() {}
|
|
||||||
#define serialEvent2_implemented
|
|
||||||
ISR(USART2_RX_vect)
|
|
||||||
{
|
|
||||||
if (bit_is_clear(UCSR2A, UPE2)) {
|
|
||||||
unsigned char c = UDR2;
|
|
||||||
store_char(c, &rx_buffer2);
|
|
||||||
} else {
|
|
||||||
unsigned char c = UDR2;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(USART3_RX_vect) && defined(UDR3)
|
|
||||||
void serialEvent3() __attribute__((weak));
|
|
||||||
void serialEvent3() {}
|
|
||||||
#define serialEvent3_implemented
|
|
||||||
ISR(USART3_RX_vect)
|
|
||||||
{
|
|
||||||
if (bit_is_clear(UCSR3A, UPE3)) {
|
|
||||||
unsigned char c = UDR3;
|
|
||||||
store_char(c, &rx_buffer3);
|
|
||||||
} else {
|
|
||||||
unsigned char c = UDR3;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void serialEventRun(void)
|
|
||||||
{
|
|
||||||
#ifdef serialEvent_implemented
|
|
||||||
if (Serial.available()) serialEvent();
|
|
||||||
#endif
|
|
||||||
#ifdef serialEvent1_implemented
|
|
||||||
if (Serial1.available()) serialEvent1();
|
|
||||||
#endif
|
|
||||||
#ifdef serialEvent2_implemented
|
|
||||||
if (Serial2.available()) serialEvent2();
|
|
||||||
#endif
|
|
||||||
#ifdef serialEvent3_implemented
|
|
||||||
if (Serial3.available()) serialEvent3();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#if !defined(USART0_UDRE_vect) && defined(USART1_UDRE_vect)
|
|
||||||
// do nothing - on the 32u4 the first USART is USART1
|
|
||||||
#else
|
|
||||||
#if !defined(UART0_UDRE_vect) && !defined(UART_UDRE_vect) && !defined(USART0_UDRE_vect) && !defined(USART_UDRE_vect)
|
|
||||||
#error "Don't know what the Data Register Empty vector is called for the first UART"
|
|
||||||
#else
|
|
||||||
#if defined(UART0_UDRE_vect)
|
|
||||||
ISR(UART0_UDRE_vect)
|
|
||||||
#elif defined(UART_UDRE_vect)
|
|
||||||
ISR(UART_UDRE_vect)
|
|
||||||
#elif defined(USART0_UDRE_vect)
|
|
||||||
ISR(USART0_UDRE_vect)
|
|
||||||
#elif defined(USART_UDRE_vect)
|
|
||||||
ISR(USART_UDRE_vect)
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
if (tx_buffer.head == tx_buffer.tail) {
|
|
||||||
// Buffer empty, so disable interrupts
|
|
||||||
#if defined(UCSR0B)
|
|
||||||
cbi(UCSR0B, UDRIE0);
|
|
||||||
#else
|
|
||||||
cbi(UCSRB, UDRIE);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// There is more data in the output buffer. Send the next byte
|
|
||||||
unsigned char c = tx_buffer.buffer[tx_buffer.tail];
|
|
||||||
tx_buffer.tail = (tx_buffer.tail + 1) % SERIAL_BUFFER_SIZE;
|
|
||||||
|
|
||||||
#if defined(UDR0)
|
|
||||||
UDR0 = c;
|
|
||||||
#elif defined(UDR)
|
|
||||||
UDR = c;
|
|
||||||
#else
|
|
||||||
#error UDR not defined
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef USART1_UDRE_vect
|
|
||||||
ISR(USART1_UDRE_vect)
|
|
||||||
{
|
|
||||||
if (tx_buffer1.head == tx_buffer1.tail) {
|
|
||||||
// Buffer empty, so disable interrupts
|
|
||||||
cbi(UCSR1B, UDRIE1);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// There is more data in the output buffer. Send the next byte
|
|
||||||
unsigned char c = tx_buffer1.buffer[tx_buffer1.tail];
|
|
||||||
tx_buffer1.tail = (tx_buffer1.tail + 1) % SERIAL_BUFFER_SIZE;
|
|
||||||
|
|
||||||
UDR1 = c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef USART2_UDRE_vect
|
|
||||||
ISR(USART2_UDRE_vect)
|
|
||||||
{
|
|
||||||
if (tx_buffer2.head == tx_buffer2.tail) {
|
|
||||||
// Buffer empty, so disable interrupts
|
|
||||||
cbi(UCSR2B, UDRIE2);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// There is more data in the output buffer. Send the next byte
|
|
||||||
unsigned char c = tx_buffer2.buffer[tx_buffer2.tail];
|
|
||||||
tx_buffer2.tail = (tx_buffer2.tail + 1) % SERIAL_BUFFER_SIZE;
|
|
||||||
|
|
||||||
UDR2 = c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef USART3_UDRE_vect
|
|
||||||
ISR(USART3_UDRE_vect)
|
|
||||||
{
|
|
||||||
if (tx_buffer3.head == tx_buffer3.tail) {
|
|
||||||
// Buffer empty, so disable interrupts
|
|
||||||
cbi(UCSR3B, UDRIE3);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// There is more data in the output buffer. Send the next byte
|
|
||||||
unsigned char c = tx_buffer3.buffer[tx_buffer3.tail];
|
|
||||||
tx_buffer3.tail = (tx_buffer3.tail + 1) % SERIAL_BUFFER_SIZE;
|
|
||||||
|
|
||||||
UDR3 = c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
// Constructors ////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
HardwareSerial::HardwareSerial(ring_buffer *rx_buffer, ring_buffer *tx_buffer,
|
|
||||||
volatile uint8_t *ubrrh, volatile uint8_t *ubrrl,
|
|
||||||
volatile uint8_t *ucsra, volatile uint8_t *ucsrb,
|
|
||||||
volatile uint8_t *ucsrc, volatile uint8_t *udr,
|
|
||||||
uint8_t rxen, uint8_t txen, uint8_t rxcie, uint8_t udrie, uint8_t u2x)
|
|
||||||
{
|
|
||||||
_rx_buffer = rx_buffer;
|
|
||||||
_tx_buffer = tx_buffer;
|
|
||||||
_ubrrh = ubrrh;
|
|
||||||
_ubrrl = ubrrl;
|
|
||||||
_ucsra = ucsra;
|
|
||||||
_ucsrb = ucsrb;
|
|
||||||
_ucsrc = ucsrc;
|
|
||||||
_udr = udr;
|
|
||||||
_rxen = rxen;
|
|
||||||
_txen = txen;
|
|
||||||
_rxcie = rxcie;
|
|
||||||
_udrie = udrie;
|
|
||||||
_u2x = u2x;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Public Methods //////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
void HardwareSerial::begin(unsigned long baud)
|
|
||||||
{
|
|
||||||
uint16_t baud_setting;
|
|
||||||
bool use_u2x = true;
|
|
||||||
|
|
||||||
#if F_CPU == 16000000UL
|
|
||||||
// hardcoded exception for compatibility with the bootloader shipped
|
|
||||||
// with the Duemilanove and previous boards and the firmware on the 8U2
|
|
||||||
// on the Uno and Mega 2560.
|
|
||||||
if (baud == 57600) {
|
|
||||||
use_u2x = false;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
try_again:
|
|
||||||
|
|
||||||
if (use_u2x) {
|
|
||||||
*_ucsra = 1 << _u2x;
|
|
||||||
baud_setting = (F_CPU / 4 / baud - 1) / 2;
|
|
||||||
} else {
|
|
||||||
*_ucsra = 0;
|
|
||||||
baud_setting = (F_CPU / 8 / baud - 1) / 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((baud_setting > 4095) && use_u2x)
|
|
||||||
{
|
|
||||||
use_u2x = false;
|
|
||||||
goto try_again;
|
|
||||||
}
|
|
||||||
|
|
||||||
// assign the baud_setting, a.k.a. ubbr (USART Baud Rate Register)
|
|
||||||
*_ubrrh = baud_setting >> 8;
|
|
||||||
*_ubrrl = baud_setting;
|
|
||||||
|
|
||||||
transmitting = false;
|
|
||||||
|
|
||||||
sbi(*_ucsrb, _rxen);
|
|
||||||
sbi(*_ucsrb, _txen);
|
|
||||||
sbi(*_ucsrb, _rxcie);
|
|
||||||
cbi(*_ucsrb, _udrie);
|
|
||||||
}
|
|
||||||
|
|
||||||
void HardwareSerial::begin(unsigned long baud, byte config)
|
|
||||||
{
|
|
||||||
uint16_t baud_setting;
|
|
||||||
uint8_t current_config;
|
|
||||||
bool use_u2x = true;
|
|
||||||
|
|
||||||
#if F_CPU == 16000000UL
|
|
||||||
// hardcoded exception for compatibility with the bootloader shipped
|
|
||||||
// with the Duemilanove and previous boards and the firmware on the 8U2
|
|
||||||
// on the Uno and Mega 2560.
|
|
||||||
if (baud == 57600) {
|
|
||||||
use_u2x = false;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
try_again:
|
|
||||||
|
|
||||||
if (use_u2x) {
|
|
||||||
*_ucsra = 1 << _u2x;
|
|
||||||
baud_setting = (F_CPU / 4 / baud - 1) / 2;
|
|
||||||
} else {
|
|
||||||
*_ucsra = 0;
|
|
||||||
baud_setting = (F_CPU / 8 / baud - 1) / 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((baud_setting > 4095) && use_u2x)
|
|
||||||
{
|
|
||||||
use_u2x = false;
|
|
||||||
goto try_again;
|
|
||||||
}
|
|
||||||
|
|
||||||
// assign the baud_setting, a.k.a. ubbr (USART Baud Rate Register)
|
|
||||||
*_ubrrh = baud_setting >> 8;
|
|
||||||
*_ubrrl = baud_setting;
|
|
||||||
|
|
||||||
//set the data bits, parity, and stop bits
|
|
||||||
#if defined(__AVR_ATmega8__)
|
|
||||||
config |= 0x80; // select UCSRC register (shared with UBRRH)
|
|
||||||
#endif
|
|
||||||
*_ucsrc = config;
|
|
||||||
|
|
||||||
sbi(*_ucsrb, _rxen);
|
|
||||||
sbi(*_ucsrb, _txen);
|
|
||||||
sbi(*_ucsrb, _rxcie);
|
|
||||||
cbi(*_ucsrb, _udrie);
|
|
||||||
}
|
|
||||||
|
|
||||||
void HardwareSerial::end()
|
|
||||||
{
|
|
||||||
// wait for transmission of outgoing data
|
|
||||||
while (_tx_buffer->head != _tx_buffer->tail)
|
|
||||||
;
|
|
||||||
|
|
||||||
cbi(*_ucsrb, _rxen);
|
|
||||||
cbi(*_ucsrb, _txen);
|
|
||||||
cbi(*_ucsrb, _rxcie);
|
|
||||||
cbi(*_ucsrb, _udrie);
|
|
||||||
|
|
||||||
// clear any received data
|
|
||||||
_rx_buffer->head = _rx_buffer->tail;
|
|
||||||
}
|
|
||||||
|
|
||||||
int HardwareSerial::available(void)
|
|
||||||
{
|
|
||||||
return (unsigned int)(SERIAL_BUFFER_SIZE + _rx_buffer->head - _rx_buffer->tail) % SERIAL_BUFFER_SIZE;
|
|
||||||
}
|
|
||||||
|
|
||||||
int HardwareSerial::peek(void)
|
|
||||||
{
|
|
||||||
if (_rx_buffer->head == _rx_buffer->tail) {
|
|
||||||
return -1;
|
|
||||||
} else {
|
|
||||||
return _rx_buffer->buffer[_rx_buffer->tail];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int HardwareSerial::read(void)
|
|
||||||
{
|
|
||||||
// if the head isn't ahead of the tail, we don't have any characters
|
|
||||||
if (_rx_buffer->head == _rx_buffer->tail) {
|
|
||||||
return -1;
|
|
||||||
} else {
|
|
||||||
unsigned char c = _rx_buffer->buffer[_rx_buffer->tail];
|
|
||||||
_rx_buffer->tail = (unsigned int)(_rx_buffer->tail + 1) % SERIAL_BUFFER_SIZE;
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void HardwareSerial::flush()
|
|
||||||
{
|
|
||||||
// UDR is kept full while the buffer is not empty, so TXC triggers when EMPTY && SENT
|
|
||||||
while (transmitting && ! (*_ucsra & _BV(TXC0)));
|
|
||||||
transmitting = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t HardwareSerial::write(uint8_t c)
|
|
||||||
{
|
|
||||||
int i = (_tx_buffer->head + 1) % SERIAL_BUFFER_SIZE;
|
|
||||||
|
|
||||||
// If the output buffer is full, there's nothing for it other than to
|
|
||||||
// wait for the interrupt handler to empty it a bit
|
|
||||||
// ???: return 0 here instead?
|
|
||||||
while (i == _tx_buffer->tail)
|
|
||||||
;
|
|
||||||
|
|
||||||
_tx_buffer->buffer[_tx_buffer->head] = c;
|
|
||||||
_tx_buffer->head = i;
|
|
||||||
|
|
||||||
sbi(*_ucsrb, _udrie);
|
|
||||||
// clear the TXC bit -- "can be cleared by writing a one to its bit location"
|
|
||||||
transmitting = true;
|
|
||||||
sbi(*_ucsra, TXC0);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
HardwareSerial::operator bool() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Preinstantiate Objects //////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#if defined(UBRRH) && defined(UBRRL)
|
|
||||||
HardwareSerial Serial(&rx_buffer, &tx_buffer, &UBRRH, &UBRRL, &UCSRA, &UCSRB, &UCSRC, &UDR, RXEN, TXEN, RXCIE, UDRIE, U2X);
|
|
||||||
#elif defined(UBRR0H) && defined(UBRR0L)
|
|
||||||
HardwareSerial Serial(&rx_buffer, &tx_buffer, &UBRR0H, &UBRR0L, &UCSR0A, &UCSR0B, &UCSR0C, &UDR0, RXEN0, TXEN0, RXCIE0, UDRIE0, U2X0);
|
|
||||||
#elif defined(USBCON)
|
|
||||||
// do nothing - Serial object and buffers are initialized in CDC code
|
|
||||||
#else
|
|
||||||
#error no serial port defined (port 0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(UBRR1H)
|
|
||||||
HardwareSerial Serial1(&rx_buffer1, &tx_buffer1, &UBRR1H, &UBRR1L, &UCSR1A, &UCSR1B, &UCSR1C, &UDR1, RXEN1, TXEN1, RXCIE1, UDRIE1, U2X1);
|
|
||||||
#endif
|
|
||||||
#if defined(UBRR2H)
|
|
||||||
HardwareSerial Serial2(&rx_buffer2, &tx_buffer2, &UBRR2H, &UBRR2L, &UCSR2A, &UCSR2B, &UCSR2C, &UDR2, RXEN2, TXEN2, RXCIE2, UDRIE2, U2X2);
|
|
||||||
#endif
|
|
||||||
#if defined(UBRR3H)
|
|
||||||
HardwareSerial Serial3(&rx_buffer3, &tx_buffer3, &UBRR3H, &UBRR3L, &UCSR3A, &UCSR3B, &UCSR3C, &UDR3, RXEN3, TXEN3, RXCIE3, UDRIE3, U2X3);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // whole file
|
|
||||||
|
|
@ -1,56 +0,0 @@
|
|||||||
|
|
||||||
#include <Arduino.h>
|
|
||||||
#include <IPAddress.h>
|
|
||||||
|
|
||||||
IPAddress::IPAddress()
|
|
||||||
{
|
|
||||||
memset(_address, 0, sizeof(_address));
|
|
||||||
}
|
|
||||||
|
|
||||||
IPAddress::IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet)
|
|
||||||
{
|
|
||||||
_address[0] = first_octet;
|
|
||||||
_address[1] = second_octet;
|
|
||||||
_address[2] = third_octet;
|
|
||||||
_address[3] = fourth_octet;
|
|
||||||
}
|
|
||||||
|
|
||||||
IPAddress::IPAddress(uint32_t address)
|
|
||||||
{
|
|
||||||
memcpy(_address, &address, sizeof(_address));
|
|
||||||
}
|
|
||||||
|
|
||||||
IPAddress::IPAddress(const uint8_t *address)
|
|
||||||
{
|
|
||||||
memcpy(_address, address, sizeof(_address));
|
|
||||||
}
|
|
||||||
|
|
||||||
IPAddress& IPAddress::operator=(const uint8_t *address)
|
|
||||||
{
|
|
||||||
memcpy(_address, address, sizeof(_address));
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
IPAddress& IPAddress::operator=(uint32_t address)
|
|
||||||
{
|
|
||||||
memcpy(_address, (const uint8_t *)&address, sizeof(_address));
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IPAddress::operator==(const uint8_t* addr)
|
|
||||||
{
|
|
||||||
return memcmp(addr, _address, sizeof(_address)) == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t IPAddress::printTo(Print& p) const
|
|
||||||
{
|
|
||||||
size_t n = 0;
|
|
||||||
for (int i =0; i < 3; i++)
|
|
||||||
{
|
|
||||||
n += p.print(_address[i], DEC);
|
|
||||||
n += p.print('.');
|
|
||||||
}
|
|
||||||
n += p.print(_address[3], DEC);
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
|
|
@ -1,76 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* MIT License:
|
|
||||||
* Copyright (c) 2011 Adrian McEwen
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*
|
|
||||||
* adrianm@mcqn.com 1/1/2011
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef IPAddress_h
|
|
||||||
#define IPAddress_h
|
|
||||||
|
|
||||||
#include <Printable.h>
|
|
||||||
|
|
||||||
// A class to make it easier to handle and pass around IP addresses
|
|
||||||
|
|
||||||
class IPAddress : public Printable {
|
|
||||||
private:
|
|
||||||
uint8_t _address[4]; // IPv4 address
|
|
||||||
// Access the raw byte array containing the address. Because this returns a pointer
|
|
||||||
// to the internal structure rather than a copy of the address this function should only
|
|
||||||
// be used when you know that the usage of the returned uint8_t* will be transient and not
|
|
||||||
// stored.
|
|
||||||
uint8_t* raw_address() { return _address; };
|
|
||||||
|
|
||||||
public:
|
|
||||||
// Constructors
|
|
||||||
IPAddress();
|
|
||||||
IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet);
|
|
||||||
IPAddress(uint32_t address);
|
|
||||||
IPAddress(const uint8_t *address);
|
|
||||||
|
|
||||||
// Overloaded cast operator to allow IPAddress objects to be used where a pointer
|
|
||||||
// to a four-byte uint8_t array is expected
|
|
||||||
operator uint32_t() { return *((uint32_t*)_address); };
|
|
||||||
bool operator==(const IPAddress& addr) { return (*((uint32_t*)_address)) == (*((uint32_t*)addr._address)); };
|
|
||||||
bool operator==(const uint8_t* addr);
|
|
||||||
|
|
||||||
// Overloaded index operator to allow getting and setting individual octets of the address
|
|
||||||
uint8_t operator[](int index) const { return _address[index]; };
|
|
||||||
uint8_t& operator[](int index) { return _address[index]; };
|
|
||||||
|
|
||||||
// Overloaded copy operators to allow initialisation of IPAddress objects from other types
|
|
||||||
IPAddress& operator=(const uint8_t *address);
|
|
||||||
IPAddress& operator=(uint32_t address);
|
|
||||||
|
|
||||||
virtual size_t printTo(Print& p) const;
|
|
||||||
|
|
||||||
friend class EthernetClass;
|
|
||||||
friend class UDP;
|
|
||||||
friend class Client;
|
|
||||||
friend class Server;
|
|
||||||
friend class DhcpClass;
|
|
||||||
friend class DNSClient;
|
|
||||||
};
|
|
||||||
|
|
||||||
const IPAddress INADDR_NONE(0,0,0,0);
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,23 +0,0 @@
|
|||||||
|
|
||||||
#ifndef __PLATFORM_H__
|
|
||||||
#define __PLATFORM_H__
|
|
||||||
|
|
||||||
#include <inttypes.h>
|
|
||||||
#include <avr/pgmspace.h>
|
|
||||||
#include <avr/eeprom.h>
|
|
||||||
#include <avr/interrupt.h>
|
|
||||||
#include <util/delay.h>
|
|
||||||
|
|
||||||
typedef unsigned char u8;
|
|
||||||
typedef unsigned short u16;
|
|
||||||
typedef unsigned long u32;
|
|
||||||
|
|
||||||
#include "Arduino.h"
|
|
||||||
|
|
||||||
#if defined(USBCON)
|
|
||||||
#include "USBDesc.h"
|
|
||||||
#include "USBCore.h"
|
|
||||||
#include "USBAPI.h"
|
|
||||||
#endif /* if defined(USBCON) */
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,9 +0,0 @@
|
|||||||
#ifndef server_h
|
|
||||||
#define server_h
|
|
||||||
|
|
||||||
class Server : public Print {
|
|
||||||
public:
|
|
||||||
virtual void begin() =0;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,267 +0,0 @@
|
|||||||
/* Copyright (c) 2002, 2004, 2010 Joerg Wunsch
|
|
||||||
Copyright (c) 2010 Gerben van den Broeke
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright
|
|
||||||
notice, this list of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright
|
|
||||||
notice, this list of conditions and the following disclaimer in
|
|
||||||
the documentation and/or other materials provided with the
|
|
||||||
distribution.
|
|
||||||
|
|
||||||
* Neither the name of the copyright holders nor the names of
|
|
||||||
contributors may be used to endorse or promote products derived
|
|
||||||
from this software without specific prior written permission.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
||||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
||||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
||||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
||||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
||||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
||||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/* $Id: malloc.c 2149 2010-06-09 20:45:37Z joerg_wunsch $ */
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include "sectionname.h"
|
|
||||||
#include "stdlib_private.h"
|
|
||||||
|
|
||||||
#include <avr/io.h>
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Exported interface:
|
|
||||||
*
|
|
||||||
* When extending the data segment, the allocator will not try to go
|
|
||||||
* beyond the current stack limit, decreased by __malloc_margin bytes.
|
|
||||||
* Thus, all possible stack frames of interrupt routines that could
|
|
||||||
* interrupt the current function, plus all further nested function
|
|
||||||
* calls must not require more stack space, or they'll risk to collide
|
|
||||||
* with the data segment.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* May be changed by the user only before the first malloc() call. */
|
|
||||||
|
|
||||||
size_t __malloc_margin = 128;
|
|
||||||
char *__malloc_heap_start = &__heap_start;
|
|
||||||
char *__malloc_heap_end = &__heap_end;
|
|
||||||
|
|
||||||
char *__brkval;
|
|
||||||
struct __freelist *__flp;
|
|
||||||
|
|
||||||
ATTRIBUTE_CLIB_SECTION
|
|
||||||
void *
|
|
||||||
malloc(size_t len)
|
|
||||||
{
|
|
||||||
struct __freelist *fp1, *fp2, *sfp1, *sfp2;
|
|
||||||
char *cp;
|
|
||||||
size_t s, avail;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Our minimum chunk size is the size of a pointer (plus the
|
|
||||||
* size of the "sz" field, but we don't need to account for
|
|
||||||
* this), otherwise we could not possibly fit a freelist entry
|
|
||||||
* into the chunk later.
|
|
||||||
*/
|
|
||||||
if (len < sizeof(struct __freelist) - sizeof(size_t))
|
|
||||||
len = sizeof(struct __freelist) - sizeof(size_t);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* First, walk the free list and try finding a chunk that
|
|
||||||
* would match exactly. If we found one, we are done. While
|
|
||||||
* walking, note down the smallest chunk we found that would
|
|
||||||
* still fit the request -- we need it for step 2.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
for (s = 0, fp1 = __flp, fp2 = 0;
|
|
||||||
fp1;
|
|
||||||
fp2 = fp1, fp1 = fp1->nx) {
|
|
||||||
if (fp1->sz < len)
|
|
||||||
continue;
|
|
||||||
if (fp1->sz == len) {
|
|
||||||
/*
|
|
||||||
* Found it. Disconnect the chunk from the
|
|
||||||
* freelist, and return it.
|
|
||||||
*/
|
|
||||||
if (fp2)
|
|
||||||
fp2->nx = fp1->nx;
|
|
||||||
else
|
|
||||||
__flp = fp1->nx;
|
|
||||||
return &(fp1->nx);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (s == 0 || fp1->sz < s) {
|
|
||||||
/* this is the smallest chunk found so far */
|
|
||||||
s = fp1->sz;
|
|
||||||
sfp1 = fp1;
|
|
||||||
sfp2 = fp2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* Step 2: If we found a chunk on the freelist that would fit
|
|
||||||
* (but was too large), look it up again and use it, since it
|
|
||||||
* is our closest match now. Since the freelist entry needs
|
|
||||||
* to be split into two entries then, watch out that the
|
|
||||||
* difference between the requested size and the size of the
|
|
||||||
* chunk found is large enough for another freelist entry; if
|
|
||||||
* not, just enlarge the request size to what we have found,
|
|
||||||
* and use the entire chunk.
|
|
||||||
*/
|
|
||||||
if (s) {
|
|
||||||
if (s - len < sizeof(struct __freelist)) {
|
|
||||||
/* Disconnect it from freelist and return it. */
|
|
||||||
if (sfp2)
|
|
||||||
sfp2->nx = sfp1->nx;
|
|
||||||
else
|
|
||||||
__flp = sfp1->nx;
|
|
||||||
return &(sfp1->nx);
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* Split them up. Note that we leave the first part
|
|
||||||
* as the new (smaller) freelist entry, and return the
|
|
||||||
* upper portion to the caller. This saves us the
|
|
||||||
* work to fix up the freelist chain; we just need to
|
|
||||||
* fixup the size of the current entry, and note down
|
|
||||||
* the size of the new chunk before returning it to
|
|
||||||
* the caller.
|
|
||||||
*/
|
|
||||||
cp = (char *)sfp1;
|
|
||||||
s -= len;
|
|
||||||
cp += s;
|
|
||||||
sfp2 = (struct __freelist *)cp;
|
|
||||||
sfp2->sz = len;
|
|
||||||
sfp1->sz = s - sizeof(size_t);
|
|
||||||
return &(sfp2->nx);
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* Step 3: If the request could not be satisfied from a
|
|
||||||
* freelist entry, just prepare a new chunk. This means we
|
|
||||||
* need to obtain more memory first. The largest address just
|
|
||||||
* not allocated so far is remembered in the brkval variable.
|
|
||||||
* Under Unix, the "break value" was the end of the data
|
|
||||||
* segment as dynamically requested from the operating system.
|
|
||||||
* Since we don't have an operating system, just make sure
|
|
||||||
* that we don't collide with the stack.
|
|
||||||
*/
|
|
||||||
if (__brkval == 0)
|
|
||||||
__brkval = __malloc_heap_start;
|
|
||||||
cp = __malloc_heap_end;
|
|
||||||
if (cp == 0)
|
|
||||||
cp = STACK_POINTER() - __malloc_margin;
|
|
||||||
if (cp <= __brkval)
|
|
||||||
/*
|
|
||||||
* Memory exhausted.
|
|
||||||
*/
|
|
||||||
return 0;
|
|
||||||
avail = cp - __brkval;
|
|
||||||
/*
|
|
||||||
* Both tests below are needed to catch the case len >= 0xfffe.
|
|
||||||
*/
|
|
||||||
if (avail >= len && avail >= len + sizeof(size_t)) {
|
|
||||||
fp1 = (struct __freelist *)__brkval;
|
|
||||||
__brkval += len + sizeof(size_t);
|
|
||||||
fp1->sz = len;
|
|
||||||
return &(fp1->nx);
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* Step 4: There's no help, just fail. :-/
|
|
||||||
*/
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ATTRIBUTE_CLIB_SECTION
|
|
||||||
void
|
|
||||||
free(void *p)
|
|
||||||
{
|
|
||||||
struct __freelist *fp1, *fp2, *fpnew;
|
|
||||||
char *cp1, *cp2, *cpnew;
|
|
||||||
|
|
||||||
/* ISO C says free(NULL) must be a no-op */
|
|
||||||
if (p == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
cpnew = p;
|
|
||||||
cpnew -= sizeof(size_t);
|
|
||||||
fpnew = (struct __freelist *)cpnew;
|
|
||||||
fpnew->nx = 0;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Trivial case first: if there's no freelist yet, our entry
|
|
||||||
* will be the only one on it. If this is the last entry, we
|
|
||||||
* can reduce __brkval instead.
|
|
||||||
*/
|
|
||||||
if (__flp == 0) {
|
|
||||||
if ((char *)p + fpnew->sz == __brkval)
|
|
||||||
__brkval = cpnew;
|
|
||||||
else
|
|
||||||
__flp = fpnew;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Now, find the position where our new entry belongs onto the
|
|
||||||
* freelist. Try to aggregate the chunk with adjacent chunks
|
|
||||||
* if possible.
|
|
||||||
*/
|
|
||||||
for (fp1 = __flp, fp2 = 0;
|
|
||||||
fp1;
|
|
||||||
fp2 = fp1, fp1 = fp1->nx) {
|
|
||||||
if (fp1 < fpnew)
|
|
||||||
continue;
|
|
||||||
cp1 = (char *)fp1;
|
|
||||||
fpnew->nx = fp1;
|
|
||||||
if ((char *)&(fpnew->nx) + fpnew->sz == cp1) {
|
|
||||||
/* upper chunk adjacent, assimilate it */
|
|
||||||
fpnew->sz += fp1->sz + sizeof(size_t);
|
|
||||||
fpnew->nx = fp1->nx;
|
|
||||||
}
|
|
||||||
if (fp2 == 0) {
|
|
||||||
/* new head of freelist */
|
|
||||||
__flp = fpnew;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* Note that we get here either if we hit the "break" above,
|
|
||||||
* or if we fell off the end of the loop. The latter means
|
|
||||||
* we've got a new topmost chunk. Either way, try aggregating
|
|
||||||
* with the lower chunk if possible.
|
|
||||||
*/
|
|
||||||
fp2->nx = fpnew;
|
|
||||||
cp2 = (char *)&(fp2->nx);
|
|
||||||
if (cp2 + fp2->sz == cpnew) {
|
|
||||||
/* lower junk adjacent, merge */
|
|
||||||
fp2->sz += fpnew->sz + sizeof(size_t);
|
|
||||||
fp2->nx = fpnew->nx;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* If there's a new topmost chunk, lower __brkval instead.
|
|
||||||
*/
|
|
||||||
for (fp1 = __flp, fp2 = 0;
|
|
||||||
fp1->nx != 0;
|
|
||||||
fp2 = fp1, fp1 = fp1->nx)
|
|
||||||
/* advance to entry just before end of list */;
|
|
||||||
cp2 = (char *)&(fp1->nx);
|
|
||||||
if (cp2 + fp1->sz == __brkval) {
|
|
||||||
if (fp2 == NULL)
|
|
||||||
/* Freelist is empty now. */
|
|
||||||
__flp = NULL;
|
|
||||||
else
|
|
||||||
fp2->nx = NULL;
|
|
||||||
__brkval = cp2 - sizeof(size_t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,150 +0,0 @@
|
|||||||
/* Copyright (c) 2004, 2010 Joerg Wunsch
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright
|
|
||||||
notice, this list of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright
|
|
||||||
notice, this list of conditions and the following disclaimer in
|
|
||||||
the documentation and/or other materials provided with the
|
|
||||||
distribution.
|
|
||||||
|
|
||||||
* Neither the name of the copyright holders nor the names of
|
|
||||||
contributors may be used to endorse or promote products derived
|
|
||||||
from this software without specific prior written permission.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
||||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
||||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
||||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
||||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
||||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
||||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
/* $Id: realloc.c 2127 2010-06-07 14:49:37Z joerg_wunsch $ */
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include "sectionname.h"
|
|
||||||
#include "stdlib_private.h"
|
|
||||||
|
|
||||||
#include <avr/io.h>
|
|
||||||
|
|
||||||
ATTRIBUTE_CLIB_SECTION
|
|
||||||
void *
|
|
||||||
realloc(void *ptr, size_t len)
|
|
||||||
{
|
|
||||||
struct __freelist *fp1, *fp2, *fp3, *ofp3;
|
|
||||||
char *cp, *cp1;
|
|
||||||
void *memp;
|
|
||||||
size_t s, incr;
|
|
||||||
|
|
||||||
/* Trivial case, required by C standard. */
|
|
||||||
if (ptr == 0)
|
|
||||||
return malloc(len);
|
|
||||||
|
|
||||||
cp1 = (char *)ptr;
|
|
||||||
cp1 -= sizeof(size_t);
|
|
||||||
fp1 = (struct __freelist *)cp1;
|
|
||||||
|
|
||||||
cp = (char *)ptr + len; /* new next pointer */
|
|
||||||
if (cp < cp1)
|
|
||||||
/* Pointer wrapped across top of RAM, fail. */
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* See whether we are growing or shrinking. When shrinking,
|
|
||||||
* we split off a chunk for the released portion, and call
|
|
||||||
* free() on it. Therefore, we can only shrink if the new
|
|
||||||
* size is at least sizeof(struct __freelist) smaller than the
|
|
||||||
* previous size.
|
|
||||||
*/
|
|
||||||
if (len <= fp1->sz) {
|
|
||||||
/* The first test catches a possible unsigned int
|
|
||||||
* rollover condition. */
|
|
||||||
if (fp1->sz <= sizeof(struct __freelist) ||
|
|
||||||
len > fp1->sz - sizeof(struct __freelist))
|
|
||||||
return ptr;
|
|
||||||
fp2 = (struct __freelist *)cp;
|
|
||||||
fp2->sz = fp1->sz - len - sizeof(size_t);
|
|
||||||
fp1->sz = len;
|
|
||||||
free(&(fp2->nx));
|
|
||||||
return ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If we get here, we are growing. First, see whether there
|
|
||||||
* is space in the free list on top of our current chunk.
|
|
||||||
*/
|
|
||||||
incr = len - fp1->sz;
|
|
||||||
cp = (char *)ptr + fp1->sz;
|
|
||||||
fp2 = (struct __freelist *)cp;
|
|
||||||
for (s = 0, ofp3 = 0, fp3 = __flp;
|
|
||||||
fp3;
|
|
||||||
ofp3 = fp3, fp3 = fp3->nx) {
|
|
||||||
if (fp3 == fp2 && fp3->sz + sizeof(size_t) >= incr) {
|
|
||||||
/* found something that fits */
|
|
||||||
if (fp3->sz + sizeof(size_t) - incr > sizeof(struct __freelist)) {
|
|
||||||
/* split off a new freelist entry */
|
|
||||||
cp = (char *)ptr + len;
|
|
||||||
fp2 = (struct __freelist *)cp;
|
|
||||||
fp2->nx = fp3->nx;
|
|
||||||
fp2->sz = fp3->sz - incr;
|
|
||||||
fp1->sz = len;
|
|
||||||
} else {
|
|
||||||
/* it just fits, so use it entirely */
|
|
||||||
fp1->sz += fp3->sz + sizeof(size_t);
|
|
||||||
fp2 = fp3->nx;
|
|
||||||
}
|
|
||||||
if (ofp3)
|
|
||||||
ofp3->nx = fp2;
|
|
||||||
else
|
|
||||||
__flp = fp2;
|
|
||||||
return ptr;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* Find the largest chunk on the freelist while
|
|
||||||
* walking it.
|
|
||||||
*/
|
|
||||||
if (fp3->sz > s)
|
|
||||||
s = fp3->sz;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* If we are the topmost chunk in memory, and there was no
|
|
||||||
* large enough chunk on the freelist that could be re-used
|
|
||||||
* (by a call to malloc() below), quickly extend the
|
|
||||||
* allocation area if possible, without need to copy the old
|
|
||||||
* data.
|
|
||||||
*/
|
|
||||||
if (__brkval == (char *)ptr + fp1->sz && len > s) {
|
|
||||||
cp1 = __malloc_heap_end;
|
|
||||||
cp = (char *)ptr + len;
|
|
||||||
if (cp1 == 0)
|
|
||||||
cp1 = STACK_POINTER() - __malloc_margin;
|
|
||||||
if (cp < cp1) {
|
|
||||||
__brkval = cp;
|
|
||||||
fp1->sz = len;
|
|
||||||
return ptr;
|
|
||||||
}
|
|
||||||
/* If that failed, we are out of luck. */
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Call malloc() for a new chunk, then copy over the data, and
|
|
||||||
* release the old region.
|
|
||||||
*/
|
|
||||||
if ((memp = malloc(len)) == 0)
|
|
||||||
return 0;
|
|
||||||
memcpy(memp, ptr, fp1->sz);
|
|
||||||
free(ptr);
|
|
||||||
return memp;
|
|
||||||
}
|
|
||||||
|
|
@ -1,49 +0,0 @@
|
|||||||
/* Copyright (c) 2009 Atmel Corporation
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright
|
|
||||||
notice, this list of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright
|
|
||||||
notice, this list of conditions and the following disclaimer in
|
|
||||||
the documentation and/or other materials provided with the
|
|
||||||
distribution.
|
|
||||||
|
|
||||||
* Neither the name of the copyright holders nor the names of
|
|
||||||
contributors may be used to endorse or promote products derived
|
|
||||||
from this software without specific prior written permission.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
||||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
||||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
||||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
||||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
||||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
||||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __SECTIONNAME_H__
|
|
||||||
#define __SECTIONNAME_H__
|
|
||||||
|
|
||||||
/* Put all avr-libc functions in a common, unique sub-section name under .text. */
|
|
||||||
|
|
||||||
#define CLIB_SECTION .text.avr-libc
|
|
||||||
#define MLIB_SECTION .text.avr-libc.fplib
|
|
||||||
|
|
||||||
#define STR(x) _STR(x)
|
|
||||||
#define _STR(x) #x
|
|
||||||
|
|
||||||
#define ATTRIBUTE_CLIB_SECTION __attribute__ ((section (STR(CLIB_SECTION))))
|
|
||||||
#define ATTRIBUTE_MLIB_SECTION __attribute__ ((section (STR(MLIB_SECTION))))
|
|
||||||
|
|
||||||
#define ASSEMBLY_CLIB_SECTION .section CLIB_SECTION, "ax", @progbits
|
|
||||||
#define ASSEMBLY_MLIB_SECTION .section MLIB_SECTION, "ax", @progbits
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,58 +0,0 @@
|
|||||||
/* Copyright (c) 2004, Joerg Wunsch
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright
|
|
||||||
notice, this list of conditions and the following disclaimer.
|
|
||||||
* Redistributions in binary form must reproduce the above copyright
|
|
||||||
notice, this list of conditions and the following disclaimer in
|
|
||||||
the documentation and/or other materials provided with the
|
|
||||||
distribution.
|
|
||||||
* Neither the name of the copyright holders nor the names of
|
|
||||||
contributors may be used to endorse or promote products derived
|
|
||||||
from this software without specific prior written permission.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
||||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
||||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
||||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
||||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
||||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
||||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* $Id: stdlib_private.h 1657 2008-03-24 17:11:08Z arcanum $ */
|
|
||||||
|
|
||||||
#include <inttypes.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <avr/io.h>
|
|
||||||
|
|
||||||
#if !defined(__DOXYGEN__)
|
|
||||||
|
|
||||||
struct __freelist {
|
|
||||||
size_t sz;
|
|
||||||
struct __freelist *nx;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
extern char *__brkval; /* first location not yet allocated */
|
|
||||||
extern struct __freelist *__flp; /* freelist pointer (head of freelist) */
|
|
||||||
extern size_t __malloc_margin; /* user-changeable before the first malloc() */
|
|
||||||
extern char *__malloc_heap_start;
|
|
||||||
extern char *__malloc_heap_end;
|
|
||||||
|
|
||||||
extern char __heap_start;
|
|
||||||
extern char __heap_end;
|
|
||||||
|
|
||||||
/* Needed for definition of AVR_STACK_POINTER_REG. */
|
|
||||||
#include <avr/io.h>
|
|
||||||
|
|
||||||
#define STACK_POINTER() ((char *)AVR_STACK_POINTER_REG)
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
|||||||
#include <Arduino.h>
|
|
||||||
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
init();
|
|
||||||
|
|
||||||
#if defined(USBCON)
|
|
||||||
USBDevice.attach();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
setup();
|
|
||||||
|
|
||||||
for (;;) {
|
|
||||||
loop();
|
|
||||||
if (serialEventRun) serialEventRun();
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
@ -1,28 +0,0 @@
|
|||||||
#include <new.h>
|
|
||||||
|
|
||||||
void * operator new(size_t size)
|
|
||||||
{
|
|
||||||
return malloc(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
void * operator new[](size_t size)
|
|
||||||
{
|
|
||||||
return malloc(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
void operator delete(void * ptr)
|
|
||||||
{
|
|
||||||
free(ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void operator delete[](void * ptr)
|
|
||||||
{
|
|
||||||
free(ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
int __cxa_guard_acquire(__guard *g) {return !*(char *)(g);};
|
|
||||||
void __cxa_guard_release (__guard *g) {*(char *)g = 1;};
|
|
||||||
void __cxa_guard_abort (__guard *) {};
|
|
||||||
|
|
||||||
void __cxa_pure_virtual(void) {};
|
|
||||||
|
|
@ -1,24 +0,0 @@
|
|||||||
/* Header to define new/delete operators as they aren't provided by avr-gcc by default
|
|
||||||
Taken from http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=59453
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef NEW_H
|
|
||||||
#define NEW_H
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
void * operator new(size_t size);
|
|
||||||
void * operator new[](size_t size);
|
|
||||||
void operator delete(void * ptr);
|
|
||||||
void operator delete[](void * ptr);
|
|
||||||
|
|
||||||
__extension__ typedef int __guard __attribute__((mode (__DI__)));
|
|
||||||
|
|
||||||
extern "C" int __cxa_guard_acquire(__guard *);
|
|
||||||
extern "C" void __cxa_guard_release (__guard *);
|
|
||||||
extern "C" void __cxa_guard_abort (__guard *);
|
|
||||||
|
|
||||||
extern "C" void __cxa_pure_virtual(void);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,201 +0,0 @@
|
|||||||
0105 arduino
|
|
||||||
|
|
||||||
Fix Linux make.sh, etc. scripts
|
|
||||||
Test on Linux.
|
|
||||||
|
|
||||||
AVR
|
|
||||||
|
|
||||||
Ethernet library:
|
|
||||||
- integrate DHCP support
|
|
||||||
- client.connect() returns 0 when connection is successful? http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1238295170
|
|
||||||
- call Server.begin() from Ethernet.begin() instead of in user's sketch?
|
|
||||||
- add method for receiving notification of new client connections to a server
|
|
||||||
- add method for receiving notification of data written to a client
|
|
||||||
- add method for receiving notification of client disconnections
|
|
||||||
Incorporate mikalhart's new SoftwareSerial library.
|
|
||||||
Consider making abs() not a macro. See: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1234908504
|
|
||||||
Improve shiftOut() performance: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1216659239/0
|
|
||||||
Add String library.
|
|
||||||
Add Encoder library.
|
|
||||||
Bootloader:
|
|
||||||
- disable watch dog timer
|
|
||||||
- fix eeprom writing: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1202157667/15
|
|
||||||
Support pin change interrupts.
|
|
||||||
Switch pwm output on pins 5 and 6 to phase-correct mode, if possible.
|
|
||||||
Add parameter to shiftOut() for specifying a number of bits.
|
|
||||||
Add parameter to Serial.print[ln](x, BIN) for specifying number of bits.
|
|
||||||
Support PROGMEM strings in Serial.print(): http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1227919972
|
|
||||||
Should Serial.print(b) send the ASCII digits of the byte?
|
|
||||||
Add weak attribute to signal handlers: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1203798214
|
|
||||||
Floating point support in the map() function.
|
|
||||||
Fix delayMicroseconds(0).
|
|
||||||
Add sleep function(s).
|
|
||||||
Add SPI library.
|
|
||||||
Add OneWire library.
|
|
||||||
Add pulseOut(), etc. functions from Wiring.
|
|
||||||
Switch to ServoTimer2 library? http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1222201226/0#5
|
|
||||||
Add ContinuousServo class that inherits from Servo?
|
|
||||||
LiquidCrystal library:
|
|
||||||
- support going to the next line with println().
|
|
||||||
Supporting EEMEM directive by changing compiler command line: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1202157667
|
|
||||||
Include Arduino as AVR-ISP sketch in hardware/firmwares.
|
|
||||||
Move type definitions into WConstants.h.
|
|
||||||
Change core and libraries to use Arduino types (e.g. byte, boolean).
|
|
||||||
|
|
||||||
COMPUTER
|
|
||||||
|
|
||||||
Clear serial monitor button when the serial monitor opens.
|
|
||||||
Disable checking for updates.
|
|
||||||
Test the upload.using parameter to upload with a programmer.
|
|
||||||
Add keyboard shortcut for opening the serial monitor.
|
|
||||||
Escape characters with copy as html.
|
|
||||||
Support libraries in the SKETCH/code folder?
|
|
||||||
Test bootloader burning w/ an AVRISP.
|
|
||||||
Enable verbose output if shift (or alt?) is held down when pressing run or upload.
|
|
||||||
Add support for third-party boards in the user's sketchbook folder.
|
|
||||||
Add support for third-party cores in the user's sketchbook folder.
|
|
||||||
Re-enable (and fix) the Commander.
|
|
||||||
Move selection of Linux look and feel from Base.java to arduino.sh script.
|
|
||||||
Check RAM usage of sketches: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1224729260/0#0
|
|
||||||
Improve preprocessing of sketches:
|
|
||||||
- Better determine which header files are included (not commented out).
|
|
||||||
- Remember the original locations of function prototypes to highlight the correct line on error.
|
|
||||||
Multiple sketch windows.
|
|
||||||
Avoid library conflicts by only linking in the library whose name matches that of the #included header file.
|
|
||||||
Easier library discovery and installation ("Add library..." menu item).
|
|
||||||
Easier board installation ("Add board..." menu item)
|
|
||||||
Comprehensive board management:
|
|
||||||
- Enabled and disabled boards.
|
|
||||||
- Dialog for enabling, disabling, adding, deleting, and possibly editing boards.
|
|
||||||
- Board descriptions (e.g. explaining differences between boards).
|
|
||||||
Allow for libraries in <SKETCHBOOK>/libraries.
|
|
||||||
Allow for boards in <SKETCHBOOK>/boards.
|
|
||||||
Divide boards.txt into multiple text files.
|
|
||||||
Allow for core in <SKETCHBOOK>/cores.
|
|
||||||
Clean up Library and LibraryManager.
|
|
||||||
Compile libraries dynamically (with compilation of sketch and core files).
|
|
||||||
Library builds should respect build.verbose.
|
|
||||||
Detect dependencies between libraries.
|
|
||||||
Byte-based serial monitor.
|
|
||||||
Line termination options in the serial monitor.
|
|
||||||
Clear character should clear serial monitor.
|
|
||||||
Incorporate serial-net proxy.
|
|
||||||
Changing font size should change serial monitor font size.
|
|
||||||
Deal with shorter screens (e.g. ASUS EEPC).
|
|
||||||
Investigate method for auto-detecting serial port on Windows (javax.usb?)
|
|
||||||
- http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1225226642
|
|
||||||
Guess serial port on the Mac and Linux.
|
|
||||||
Automatic detection of baud rate for serial monitor (based on the call to Serial.begin() in the current sketch).
|
|
||||||
Improve, generally, the upload experience (e.g. faster program start after upload, keep-alive messages to bootloader from IDE, shorter bootloader timeout if possible, progress bar)
|
|
||||||
Allow uploading of .hex files.
|
|
||||||
Allow for arbitrary compilation command line arguments.
|
|
||||||
Find in reference should give same message for missing page as for missing page association.
|
|
||||||
Test find in reference on libraries.
|
|
||||||
Change background color while using external editor: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1229567785
|
|
||||||
|
|
||||||
Compiler.java
|
|
||||||
- Eliminate the need to pass a Target into the compiler by having the Compiler determine the current target (by checking the preferences directly)?
|
|
||||||
- Delete the unneeded static functions (for classpath translation, etc.) from the bottom of the file.
|
|
||||||
|
|
||||||
Sketch.java
|
|
||||||
- add system-wide include path in preprocess()?
|
|
||||||
- should find libraries in the code/ sub-folder of the sketch folder
|
|
||||||
- do sketches really need to get built in the applet/ sub-folder when uploading?
|
|
||||||
|
|
||||||
PreProcessor.java
|
|
||||||
- split write() into writeHeader() and write() as in Processing?
|
|
||||||
- add getExtraImports() function instead of having Sketch grab them directly.
|
|
||||||
|
|
||||||
Base.java
|
|
||||||
- add keywords from libraries to the syntax coloring
|
|
||||||
|
|
||||||
Editor.java
|
|
||||||
- allow the Board and Serial port to differ across editor windows. This will require creating a separate instance of the menu for each window, and passing the selections into the sketch when compiling or uploading.
|
|
||||||
- send the current board and serial port selections to the sketch (which will forward them to the compiler) when compiling or uploading (this should eliminate the need for the Target class, since the compiler will be able to find the target path and its source files itself)
|
|
||||||
- remove references to the Runner and runtime
|
|
||||||
|
|
||||||
DEVELOPMENT
|
|
||||||
|
|
||||||
Revise the icon.
|
|
||||||
Don't recompile the Processing core if the work/ directory exists.
|
|
||||||
RXTX version patched to not hang with bluetooth serial ports: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1237179908
|
|
||||||
Add licenses for included open source libraries: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1234595391
|
|
||||||
Make run.bat not open a command line window: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1223883872
|
|
||||||
Update version of the FTDI drivers (Windows).
|
|
||||||
Remove AVR ISP and giveio drivers (Windows).
|
|
||||||
Include the executable installer for the FTDI drivers (Windows).
|
|
||||||
Revise fetch.sh to look for version specific pages (names suffixed with, e.g., "-0007")
|
|
||||||
Move to ant for build process.
|
|
||||||
|
|
||||||
DOCUMENTATION / SITE CONFIGURATION
|
|
||||||
|
|
||||||
Multi-language plugin.
|
|
||||||
Work on opening up website to public editing.
|
|
||||||
Create form for submitting workshops.
|
|
||||||
Create form for submitting projects.
|
|
||||||
|
|
||||||
DOCUMENTATION / META
|
|
||||||
|
|
||||||
Create community section of site.
|
|
||||||
List of examples we'd like to have.
|
|
||||||
Style guide for examples, references, and foundations.
|
|
||||||
Add a Nordic board to the forum.
|
|
||||||
Add a German board to the forum.
|
|
||||||
|
|
||||||
DOCUMENTATION / NAVIGATION
|
|
||||||
|
|
||||||
Create About section.
|
|
||||||
Remove Board page.
|
|
||||||
Move Environment into the Reference section (which should be renamed Programming).
|
|
||||||
|
|
||||||
DOCUMENTATION / FOUNDATIONS
|
|
||||||
|
|
||||||
Better documentation of the Arduino BT.
|
|
||||||
Tutorial about serial communication.
|
|
||||||
|
|
||||||
DOCUMENTATION / REFERENCE
|
|
||||||
|
|
||||||
Remove parameters from the function links on the reference page.
|
|
||||||
Document Matrix and Sprite libraries on the Arduino site.
|
|
||||||
Document Wire.endTransmission() return values: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1228240199
|
|
||||||
|
|
||||||
DOCUMENTATION / EXAMPLES
|
|
||||||
|
|
||||||
Photos:
|
|
||||||
- Loop
|
|
||||||
- Analog Input (potentiometer and LDR on analog input 0)
|
|
||||||
Consistency:
|
|
||||||
- ledpin vs. ledPin
|
|
||||||
- value vs. val
|
|
||||||
Add a Brightness example where an analog input controls the analog output.
|
|
||||||
Graph example should use an intermediate variable.
|
|
||||||
Button example says pin 7 but uses pin 2.
|
|
||||||
Split Loop example in two (one that does loops, another that does arrays).
|
|
||||||
Add LiquidCrystal library examples.
|
|
||||||
Add Ethernet library examples.
|
|
||||||
Add Wire library examples.
|
|
||||||
Add examples using specific hardware (simple analog sensors, optocouplers, etc.)
|
|
||||||
Examples should demonstrate use of functions.
|
|
||||||
Add I2C EEPROM example using Wire library.
|
|
||||||
Update pictures to use Arduino Diecimila.
|
|
||||||
Create diagrams and schematics for the examples.
|
|
||||||
|
|
||||||
DOCUMENTATION / GETTING STARTED
|
|
||||||
|
|
||||||
Arduino feature list (in Getting Started > Introduction).
|
|
||||||
Main "getting started" link should automatically load page for the user's operating system.
|
|
||||||
Consider deleting many of the pictures in the howto's as they just make it harder to see the instructions without adding much (e.g. the pictures of files in folders).
|
|
||||||
Tell people not to put the board on a Powerbook.
|
|
||||||
People don't know what a jumper is.
|
|
||||||
Add picture of the RX/TX LEDs flashing.
|
|
||||||
Show a picture of the LED flashing.
|
|
||||||
|
|
||||||
DOCUMENTATION / TROUBLESHOOTING
|
|
||||||
|
|
||||||
Add explanation of how to work around auto-reset.
|
|
||||||
|
|
||||||
DOCUMENTATION / HACKING
|
|
||||||
|
|
||||||
Burning bootloader without an AVRISP: http://www.geocities.jp/arduino_diecimila/bootloader/index_en.html
|
|
||||||
Documentation for moving from Arduino to custom PCBs.
|
|
||||||
Write advanced library tutorial.
|
|
Loading…
Reference in new issue