├── .github └── workflows │ └── ci.yml ├── LICENSE ├── README.md ├── boards.txt ├── bootloaders ├── caterina-Arduino_Robot │ ├── Caterina-Robot-Control.hex │ ├── Caterina-Robot-Motor.hex │ ├── Caterina-Robot.txt │ ├── Caterina.c │ ├── Caterina.h │ ├── Descriptors.c │ ├── Descriptors.h │ ├── Makefile │ └── README.md ├── caterina-LilyPadUSB │ ├── Caterina-LilyPadUSB.hex │ ├── Caterina.c │ ├── Caterina.h │ ├── Descriptors.c │ ├── Descriptors.h │ ├── Makefile │ └── Readme.txt └── caterina │ ├── Caterina-Circuitplay32u4.hex │ ├── Caterina-Esplora.hex │ ├── Caterina-Esplora.txt │ ├── Caterina-Industrial101.hex │ ├── Caterina-Leonardo.hex │ ├── Caterina-Leonardo.txt │ ├── Caterina-LeonardoEthernet.hex │ ├── Caterina-LininoOne.hex │ ├── Caterina-Micro.hex │ ├── Caterina-Micro.txt │ ├── Caterina-Yun-noblink.hex │ ├── Caterina-Yun.hex │ ├── Caterina-YunMini.hex │ ├── Caterina.c │ ├── Caterina.h │ ├── Descriptors.c │ ├── Descriptors.h │ ├── Esplora-prod-firmware-2012-12-10.hex │ ├── Esplora-prod-firmware-2012-12-10.txt │ ├── Leonardo-prod-firmware-2012-04-26.hex │ ├── Leonardo-prod-firmware-2012-04-26.txt │ ├── Leonardo-prod-firmware-2012-12-10.hex │ ├── Leonardo-prod-firmware-2012-12-10.txt │ ├── Makefile │ ├── Micro-prod-firmware-2012-11-23.hex │ ├── Micro-prod-firmware-2012-11-23.txt │ ├── Micro-prod-firmware-2012-12-10.hex │ └── Micro-prod-firmware-2012-12-10.txt ├── cores └── arduino │ ├── Arduino.h │ ├── CDC.cpp │ ├── Client.h │ ├── HardwareSerial.cpp │ ├── HardwareSerial.h │ ├── HardwareSerial0.cpp │ ├── HardwareSerial1.cpp │ ├── HardwareSerial2.cpp │ ├── HardwareSerial3.cpp │ ├── HardwareSerial_private.h │ ├── IPAddress.cpp │ ├── IPAddress.h │ ├── PluggableUSB.cpp │ ├── PluggableUSB.h │ ├── Print.cpp │ ├── Print.h │ ├── Printable.h │ ├── Server.h │ ├── Stream.cpp │ ├── Stream.h │ ├── Tone.cpp │ ├── USBAPI.h │ ├── USBCore.cpp │ ├── USBCore.h │ ├── USBDesc.h │ ├── Udp.h │ ├── WCharacter.h │ ├── WInterrupts.c │ ├── WMath.cpp │ ├── WString.cpp │ ├── WString.h │ ├── abi.cpp │ ├── binary.h │ ├── hooks.c │ ├── main.cpp │ ├── new │ ├── new.cpp │ ├── new.h │ ├── wiring.c │ ├── wiring_analog.c │ ├── wiring_digital.c │ ├── wiring_private.h │ ├── wiring_pulse.S │ ├── wiring_pulse.c │ ├── wiring_shift.c │ └── xinput │ ├── USB_XInput_API.cpp │ ├── USB_XInput_API.h │ ├── USB_XInput_Descriptors.cpp │ └── USB_XInput_Descriptors.h ├── drivers ├── AdafruitCircuitPlayground.cat ├── AdafruitCircuitPlayground.inf ├── FTDI USB Drivers │ ├── Static │ │ ├── amd64 │ │ │ └── ftd2xx.lib │ │ └── i386 │ │ │ └── ftd2xx.lib │ ├── amd64 │ │ ├── ftbusui.dll │ │ ├── ftcserco.dll │ │ ├── ftd2xx.lib │ │ ├── ftd2xx64.dll │ │ ├── ftdibus.sys │ │ ├── ftlang.dll │ │ ├── ftser2k.sys │ │ └── ftserui2.dll │ ├── ftd2xx.h │ ├── ftdibus.cat │ ├── ftdibus.inf │ ├── ftdiport.cat │ ├── ftdiport.inf │ └── i386 │ │ ├── ftbusui.dll │ │ ├── ftcserco.dll │ │ ├── ftd2xx.dll │ │ ├── ftd2xx.lib │ │ ├── ftdibus.sys │ │ ├── ftlang.dll │ │ ├── ftser2k.sys │ │ └── ftserui2.dll ├── arduino-org.cat ├── arduino-org.inf ├── arduino.cat ├── arduino.inf ├── dpinst-amd64.exe ├── dpinst-x86.exe ├── gemma │ ├── amd64 │ │ ├── libusb0.dll │ │ └── libusb0.sys │ ├── arduino_gemma.cat │ ├── arduino_gemma.inf │ ├── ia64 │ │ ├── libusb0.dll │ │ └── libusb0.sys │ ├── license │ │ └── libusb0 │ │ │ └── installer_license.txt │ └── x86 │ │ ├── libusb0.sys │ │ └── libusb0_x86.dll ├── genuino.cat ├── genuino.inf ├── linino-boards_amd64.cat ├── linino-boards_x86.cat └── linino.inf ├── libraries ├── EEPROM │ ├── README.md │ ├── examples │ │ ├── eeprom_clear │ │ │ └── eeprom_clear.ino │ │ ├── eeprom_crc │ │ │ └── eeprom_crc.ino │ │ ├── eeprom_get │ │ │ └── eeprom_get.ino │ │ ├── eeprom_iteration │ │ │ └── eeprom_iteration.ino │ │ ├── eeprom_put │ │ │ └── eeprom_put.ino │ │ ├── eeprom_read │ │ │ └── eeprom_read.ino │ │ ├── eeprom_update │ │ │ └── eeprom_update.ino │ │ └── eeprom_write │ │ │ └── eeprom_write.ino │ ├── keywords.txt │ ├── library.properties │ └── src │ │ └── EEPROM.h ├── SPI │ ├── examples │ │ ├── BarometricPressureSensor │ │ │ └── BarometricPressureSensor.ino │ │ └── DigitalPotControl │ │ │ └── DigitalPotControl.ino │ ├── keywords.txt │ ├── library.properties │ └── src │ │ ├── SPI.cpp │ │ └── SPI.h ├── SoftwareSerial │ ├── examples │ │ ├── SoftwareSerialExample │ │ │ └── SoftwareSerialExample.ino │ │ └── TwoPortReceive │ │ │ └── TwoPortReceive.ino │ ├── keywords.txt │ ├── library.properties │ └── src │ │ ├── SoftwareSerial.cpp │ │ └── SoftwareSerial.h └── Wire │ ├── examples │ ├── SFRRanger_reader │ │ └── SFRRanger_reader.ino │ ├── digital_potentiometer │ │ └── digital_potentiometer.ino │ ├── i2c_scanner │ │ └── i2c_scanner.ino │ ├── master_reader │ │ └── master_reader.ino │ ├── master_writer │ │ └── master_writer.ino │ ├── slave_receiver │ │ └── slave_receiver.ino │ └── slave_sender │ │ └── slave_sender.ino │ ├── keywords.txt │ ├── library.properties │ └── src │ ├── Wire.cpp │ ├── Wire.h │ └── utility │ ├── twi.c │ └── twi.h ├── platform.txt ├── post_install.bat └── variants ├── circuitplay32u4 └── pins_arduino.h ├── leonardo └── pins_arduino.h ├── micro └── pins_arduino.h ├── robot_control └── pins_arduino.h ├── robot_motor └── pins_arduino.h └── yun └── pins_arduino.h /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: build 2 | 3 | on: [push, pull_request, workflow_dispatch] 4 | 5 | env: 6 | IDE_VERSION: 1.8.19 7 | IDE_LOCATION: /usr/local/share/arduino 8 | 9 | jobs: 10 | build: 11 | runs-on: ubuntu-latest 12 | 13 | strategy: 14 | matrix: 15 | compilation: ['Blank Sketch', 'USB API Demo', 'XInput Library'] 16 | include: 17 | - compilation: 'Blank Sketch' 18 | sketch: "$IDE_LOCATION/examples/01.Basics/BareMinimum/BareMinimum.ino" 19 | - compilation: 'USB API Demo' 20 | sketch: "$IDE_LOCATION/libraries/ArduinoXInput/extras/API-Demo/API-Demo.ino" 21 | - compilation: 'XInput Library' 22 | sketch: "$IDE_LOCATION/libraries/ArduinoXInput/examples/GamepadPins/GamepadPins.ino" 23 | 24 | steps: 25 | - name: Checkout 26 | uses: actions/checkout@v2 27 | 28 | - name: Install Arduino IDE 29 | run: | 30 | wget http://downloads.arduino.cc/arduino-$IDE_VERSION-linux64.tar.xz 31 | tar xf arduino-$IDE_VERSION-linux64.tar.xz 32 | sudo mv arduino-$IDE_VERSION /usr/local/share/arduino 33 | sudo ln -s /usr/local/share/arduino/arduino /usr/local/bin/arduino 34 | rm arduino-$IDE_VERSION-linux64.tar.xz 35 | 36 | - name: Move XInput AVR Boards Files 37 | run: | 38 | mkdir $IDE_LOCATION/hardware/xinput 39 | ln -s $PWD $IDE_LOCATION/hardware/xinput/avr 40 | 41 | - name: Install XInput Library 42 | if: contains(matrix.sketch, 'ArduinoXInput') 43 | run: | 44 | git clone https://github.com/dmadison/ArduinoXInput.git; 45 | sudo mv ArduinoXInput $IDE_LOCATION/libraries; 46 | 47 | - name: Build All Boards 48 | run: | 49 | buildSketch() { 50 | echo -e "\nBuilding sketch ${{ matrix.sketch }} for $BOARD"; 51 | arduino --verify --board $BOARD ${{ matrix.sketch }}; 52 | } 53 | 54 | BOARD=xinput:avr:yun; buildSketch; 55 | BOARD=xinput:avr:leonardo; buildSketch; 56 | BOARD=xinput:avr:leonardoeth; buildSketch; 57 | BOARD=xinput:avr:micro; buildSketch; 58 | BOARD=xinput:avr:esplora; buildSketch; 59 | BOARD=xinput:avr:LilyPadUSB; buildSketch 60 | BOARD=xinput:avr:robotControl; buildSketch; 61 | BOARD=xinput:avr:robotMotor; buildSketch; 62 | BOARD=xinput:avr:circuitplay32u4cat; buildSketch; 63 | BOARD=xinput:avr:yunmini; buildSketch; 64 | BOARD=xinput:avr:chiwawa; buildSketch; 65 | BOARD=xinput:avr:one; buildSketch; 66 | -------------------------------------------------------------------------------- /bootloaders/caterina-Arduino_Robot/Caterina-Robot.txt: -------------------------------------------------------------------------------- 1 | Builds against LUFA version 111009 2 | make version 3.81 3 | avrdude version 5.11 4 | 5 | All AVR tools except avrdude were installed by CrossPack 20100115: 6 | avr-gcc version 4.3.3 (GCC) 7 | Thread model: single 8 | Configured with: ../configure —prefix=/usr/local/CrossPack-AVR-20100115 —disable-dependency-tracking —disable-nls —disable-werror —target=avr —enable-languages=c,c++ —disable-nls —disable-libssp —with-dwarf2 9 | avr-libc version 1.6.7 10 | binutils version 2.19 11 | 12 | -------------------------------------------------------------------------------- /bootloaders/caterina-Arduino_Robot/Caterina.h: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2011. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.lufa-lib.org 7 | */ 8 | 9 | /* 10 | Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /** \file 32 | * 33 | * Header file for BootloaderCDC.c. 34 | */ 35 | 36 | #ifndef _CDC_H_ 37 | #define _CDC_H_ 38 | 39 | /* Includes: */ 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | 48 | #include "Descriptors.h" 49 | 50 | #include 51 | /* Macros: */ 52 | /** Version major of the CDC bootloader. */ 53 | #define BOOTLOADER_VERSION_MAJOR 0x01 54 | 55 | /** Version minor of the CDC bootloader. */ 56 | #define BOOTLOADER_VERSION_MINOR 0x00 57 | 58 | /** Hardware version major of the CDC bootloader. */ 59 | #define BOOTLOADER_HWVERSION_MAJOR 0x01 60 | 61 | /** Hardware version minor of the CDC bootloader. */ 62 | #define BOOTLOADER_HWVERSION_MINOR 0x00 63 | 64 | /** Eight character bootloader firmware identifier reported to the host when requested */ 65 | #define SOFTWARE_IDENTIFIER "CATERINA" 66 | 67 | #define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n)) 68 | #define LED_SETUP() DDRC |= (1<<7); DDRB |= (1<<0); DDRD |= (1<<5); 69 | #define L_LED_OFF() PORTC &= ~(1<<7) 70 | #define L_LED_ON() PORTC |= (1<<7) 71 | #define L_LED_TOGGLE() PORTC ^= (1<<7) 72 | #if DEVICE_PID == 0x0037 // polarity of the RX and TX LEDs is reversed on the Micro 73 | #define TX_LED_OFF() PORTD &= ~(1<<5) 74 | #define TX_LED_ON() PORTD |= (1<<5) 75 | #define RX_LED_OFF() PORTB &= ~(1<<0) 76 | #define RX_LED_ON() PORTB |= (1<<0) 77 | #else 78 | #define TX_LED_OFF() PORTD |= (1<<5) 79 | #define TX_LED_ON() PORTD &= ~(1<<5) 80 | #define RX_LED_OFF() PORTB |= (1<<0) 81 | #define RX_LED_ON() PORTB &= ~(1<<0) 82 | #endif 83 | 84 | /* Type Defines: */ 85 | /** Type define for a non-returning pointer to the start of the loaded application in flash memory. */ 86 | typedef void (*AppPtr_t)(void) ATTR_NO_RETURN; 87 | 88 | /* Function Prototypes: */ 89 | void StartSketch(void); 90 | void LEDPulse(void); 91 | 92 | void CDC_Task(void); 93 | void SetupHardware(void); 94 | 95 | void EVENT_USB_Device_ConfigurationChanged(void); 96 | 97 | #if defined(INCLUDE_FROM_CATERINA_C) || defined(__DOXYGEN__) 98 | #if !defined(NO_BLOCK_SUPPORT) 99 | static void ReadWriteMemoryBlock(const uint8_t Command); 100 | #endif 101 | static uint8_t FetchNextCommandByte(void); 102 | static void WriteNextResponseByte(const uint8_t Response); 103 | #endif 104 | 105 | #endif 106 | 107 | -------------------------------------------------------------------------------- /bootloaders/caterina-Arduino_Robot/Descriptors.h: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2011. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.lufa-lib.org 7 | */ 8 | 9 | /* 10 | Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /** \file 32 | * 33 | * Header file for Descriptors.c. 34 | */ 35 | 36 | #ifndef _DESCRIPTORS_H_ 37 | #define _DESCRIPTORS_H_ 38 | 39 | /* Includes: */ 40 | #include 41 | 42 | /* Macros: */ 43 | #if defined(__AVR_AT90USB1287__) 44 | #define AVR_SIGNATURE_1 0x1E 45 | #define AVR_SIGNATURE_2 0x97 46 | #define AVR_SIGNATURE_3 0x82 47 | #elif defined(__AVR_AT90USB647__) 48 | #define AVR_SIGNATURE_1 0x1E 49 | #define AVR_SIGNATURE_2 0x96 50 | #define AVR_SIGNATURE_3 0x82 51 | #elif defined(__AVR_AT90USB1286__) 52 | #define AVR_SIGNATURE_1 0x1E 53 | #define AVR_SIGNATURE_2 0x97 54 | #define AVR_SIGNATURE_3 0x82 55 | #elif defined(__AVR_AT90USB646__) 56 | #define AVR_SIGNATURE_1 0x1E 57 | #define AVR_SIGNATURE_2 0x96 58 | #define AVR_SIGNATURE_3 0x82 59 | #elif defined(__AVR_ATmega32U6__) 60 | #define AVR_SIGNATURE_1 0x1E 61 | #define AVR_SIGNATURE_2 0x95 62 | #define AVR_SIGNATURE_3 0x88 63 | #elif defined(__AVR_ATmega32U4__) 64 | #define AVR_SIGNATURE_1 0x1E 65 | #define AVR_SIGNATURE_2 0x95 66 | #define AVR_SIGNATURE_3 0x87 67 | #elif defined(__AVR_ATmega16U4__) 68 | #define AVR_SIGNATURE_1 0x1E 69 | #define AVR_SIGNATURE_2 0x94 70 | #define AVR_SIGNATURE_3 0x88 71 | #elif defined(__AVR_ATmega32U2__) 72 | #define AVR_SIGNATURE_1 0x1E 73 | #define AVR_SIGNATURE_2 0x95 74 | #define AVR_SIGNATURE_3 0x8A 75 | #elif defined(__AVR_ATmega16U2__) 76 | #define AVR_SIGNATURE_1 0x1E 77 | #define AVR_SIGNATURE_2 0x94 78 | #define AVR_SIGNATURE_3 0x89 79 | #elif defined(__AVR_AT90USB162__) 80 | #define AVR_SIGNATURE_1 0x1E 81 | #define AVR_SIGNATURE_2 0x94 82 | #define AVR_SIGNATURE_3 0x82 83 | #elif defined(__AVR_ATmega8U2__) 84 | #define AVR_SIGNATURE_1 0x1E 85 | #define AVR_SIGNATURE_2 0x93 86 | #define AVR_SIGNATURE_3 0x89 87 | #elif defined(__AVR_AT90USB82__) 88 | #define AVR_SIGNATURE_1 0x1E 89 | #define AVR_SIGNATURE_2 0x94 90 | #define AVR_SIGNATURE_3 0x82 91 | #else 92 | #error The selected AVR part is not currently supported by this bootloader. 93 | #endif 94 | 95 | /** Endpoint number for the CDC control interface event notification endpoint. */ 96 | #define CDC_NOTIFICATION_EPNUM 2 97 | 98 | /** Endpoint number for the CDC data interface TX (data IN) endpoint. */ 99 | #define CDC_TX_EPNUM 3 100 | 101 | /** Endpoint number for the CDC data interface RX (data OUT) endpoint. */ 102 | #define CDC_RX_EPNUM 4 103 | 104 | /** Size of the CDC data interface TX and RX data endpoint banks, in bytes. */ 105 | #define CDC_TXRX_EPSIZE 16 106 | 107 | /** Size of the CDC control interface notification endpoint bank, in bytes. */ 108 | #define CDC_NOTIFICATION_EPSIZE 8 109 | 110 | /* Type Defines: */ 111 | /** Type define for the device configuration descriptor structure. This must be defined in the 112 | * application code, as the configuration descriptor contains several sub-descriptors which 113 | * vary between devices, and which describe the device's usage to the host. 114 | */ 115 | typedef struct 116 | { 117 | USB_Descriptor_Configuration_Header_t Config; 118 | 119 | // CDC Control Interface 120 | USB_Descriptor_Interface_t CDC_CCI_Interface; 121 | USB_CDC_Descriptor_FunctionalHeader_t CDC_Functional_Header; 122 | USB_CDC_Descriptor_FunctionalACM_t CDC_Functional_ACM; 123 | USB_CDC_Descriptor_FunctionalUnion_t CDC_Functional_Union; 124 | USB_Descriptor_Endpoint_t CDC_NotificationEndpoint; 125 | 126 | // CDC Data Interface 127 | USB_Descriptor_Interface_t CDC_DCI_Interface; 128 | USB_Descriptor_Endpoint_t CDC_DataOutEndpoint; 129 | USB_Descriptor_Endpoint_t CDC_DataInEndpoint; 130 | } USB_Descriptor_Configuration_t; 131 | 132 | /* Function Prototypes: */ 133 | uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, 134 | const uint8_t wIndex, 135 | const void** const DescriptorAddress) 136 | ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3); 137 | 138 | #endif 139 | 140 | -------------------------------------------------------------------------------- /bootloaders/caterina-Arduino_Robot/Makefile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmadison/ArduinoXInput_AVR/585e49e863ccc73083863d421d1e513ce69b9900/bootloaders/caterina-Arduino_Robot/Makefile -------------------------------------------------------------------------------- /bootloaders/caterina-Arduino_Robot/README.md: -------------------------------------------------------------------------------- 1 | Building the bootloader for the Arduino Robot 2 | ============================================= 3 | 4 | The Arduino Robot has two boards featuring the atmega32U4 processor from Atmel. Each one of them is identified as a different board at the USB level and has a different bootloader. 5 | 6 | The Arduino Robot Control board has the USB identifier 0x0038. This is the value configured by default in the Makefile. 7 | 8 | The Arduino Robot Motor board has the USB identifier 0x0039. If you want to compile/upload this version of the bootloader, you will have to edit the Makefile, comment away the like dedicated to the PID and uncomment the one that configures such variable accordingly. 9 | 10 | The general conditions for using these bootloaders require downloading a specific version of LUFA as explained here: 11 | 12 | 1. Download the LUFA-111009 file (http://fourwalledcubicle.com/blog/2011/10/lufa-111009-released/). 13 | 2. Extract that file directly to the Caterina-Arduino_Robot bootloader directory. 14 | 3. Open a command prompt in the Caterina-Arduino_Robot bootloader directory. 15 | 4. Type 'make'. 16 | 5. Enjoy! 17 | 18 | Programming the bootloader for one of the Arduino Robot boards 19 | 1. Open a command prompt in the Caterina-Arduino_Robot folder. 20 | 2. Connect your programmer- use a 2x3 .1" header, pressed against the programming vias. 21 | 3. Edit the make file for it to include the right programmer (e.g. in my lab I have AVRMKII and USBTINY ISP) 22 | 4. Type 'make program' into the command prompt. 23 | 24 | Differences between this bootoloader and the standard one for Leonardo boards 25 | ============================================================================= 26 | 27 | This bootloader is different from the one on the standard Leonardo boards. To enter the bootloader, you need to double click the reset button. You need to click twice in less that 3/4 of a second (easy uh?). This bootloader, designed in the first place for the LilypadUSB, seems to be optimal for situations when users are e.g. using their robots in soccer competitions where they make direct manipulation of the board as it runs. 28 | -------------------------------------------------------------------------------- /bootloaders/caterina-LilyPadUSB/Caterina.h: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2011. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.lufa-lib.org 7 | */ 8 | 9 | /* 10 | Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /** \file 32 | * 33 | * Header file for BootloaderCDC.c. 34 | */ 35 | 36 | #ifndef _CDC_H_ 37 | #define _CDC_H_ 38 | 39 | /* Includes: */ 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | 48 | #include "Descriptors.h" 49 | 50 | #include 51 | /* Macros: */ 52 | /** Version major of the CDC bootloader. */ 53 | #define BOOTLOADER_VERSION_MAJOR 0x01 54 | 55 | /** Version minor of the CDC bootloader. */ 56 | #define BOOTLOADER_VERSION_MINOR 0x00 57 | 58 | /** Hardware version major of the CDC bootloader. */ 59 | #define BOOTLOADER_HWVERSION_MAJOR 0x01 60 | 61 | /** Hardware version minor of the CDC bootloader. */ 62 | #define BOOTLOADER_HWVERSION_MINOR 0x00 63 | 64 | /** Eight character bootloader firmware identifier reported to the host when requested */ 65 | #define SOFTWARE_IDENTIFIER "CATERINA" 66 | 67 | #define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n)) 68 | #define LED_SETUP() DDRC |= (1<<7); DDRB |= (1<<0); DDRD |= (1<<5); 69 | #define L_LED_OFF() PORTC &= ~(1<<7) 70 | #define L_LED_ON() PORTC |= (1<<7) 71 | #define L_LED_TOGGLE() PORTC ^= (1<<7) 72 | #define TX_LED_OFF() PORTD |= (1<<5) 73 | #define TX_LED_ON() PORTD &= ~(1<<5) 74 | #define RX_LED_OFF() PORTB |= (1<<0) 75 | #define RX_LED_ON() PORTB &= ~(1<<0) 76 | 77 | /* Type Defines: */ 78 | /** Type define for a non-returning pointer to the start of the loaded application in flash memory. */ 79 | typedef void (*AppPtr_t)(void) ATTR_NO_RETURN; 80 | 81 | /* Function Prototypes: */ 82 | void StartSketch(void); 83 | void LEDPulse(void); 84 | 85 | void CDC_Task(void); 86 | void SetupHardware(void); 87 | 88 | void EVENT_USB_Device_ConfigurationChanged(void); 89 | 90 | #if defined(INCLUDE_FROM_CATERINA_C) || defined(__DOXYGEN__) 91 | #if !defined(NO_BLOCK_SUPPORT) 92 | static void ReadWriteMemoryBlock(const uint8_t Command); 93 | #endif 94 | static uint8_t FetchNextCommandByte(void); 95 | static void WriteNextResponseByte(const uint8_t Response); 96 | #endif 97 | 98 | #endif 99 | 100 | -------------------------------------------------------------------------------- /bootloaders/caterina-LilyPadUSB/Descriptors.h: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2011. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.lufa-lib.org 7 | */ 8 | 9 | /* 10 | Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /** \file 32 | * 33 | * Header file for Descriptors.c. 34 | */ 35 | 36 | #ifndef _DESCRIPTORS_H_ 37 | #define _DESCRIPTORS_H_ 38 | 39 | /* Includes: */ 40 | #include 41 | 42 | /* Macros: */ 43 | #if defined(__AVR_AT90USB1287__) 44 | #define AVR_SIGNATURE_1 0x1E 45 | #define AVR_SIGNATURE_2 0x97 46 | #define AVR_SIGNATURE_3 0x82 47 | #elif defined(__AVR_AT90USB647__) 48 | #define AVR_SIGNATURE_1 0x1E 49 | #define AVR_SIGNATURE_2 0x96 50 | #define AVR_SIGNATURE_3 0x82 51 | #elif defined(__AVR_AT90USB1286__) 52 | #define AVR_SIGNATURE_1 0x1E 53 | #define AVR_SIGNATURE_2 0x97 54 | #define AVR_SIGNATURE_3 0x82 55 | #elif defined(__AVR_AT90USB646__) 56 | #define AVR_SIGNATURE_1 0x1E 57 | #define AVR_SIGNATURE_2 0x96 58 | #define AVR_SIGNATURE_3 0x82 59 | #elif defined(__AVR_ATmega32U6__) 60 | #define AVR_SIGNATURE_1 0x1E 61 | #define AVR_SIGNATURE_2 0x95 62 | #define AVR_SIGNATURE_3 0x88 63 | #elif defined(__AVR_ATmega32U4__) 64 | #define AVR_SIGNATURE_1 0x1E 65 | #define AVR_SIGNATURE_2 0x95 66 | #define AVR_SIGNATURE_3 0x87 67 | #elif defined(__AVR_ATmega16U4__) 68 | #define AVR_SIGNATURE_1 0x1E 69 | #define AVR_SIGNATURE_2 0x94 70 | #define AVR_SIGNATURE_3 0x88 71 | #elif defined(__AVR_ATmega32U2__) 72 | #define AVR_SIGNATURE_1 0x1E 73 | #define AVR_SIGNATURE_2 0x95 74 | #define AVR_SIGNATURE_3 0x8A 75 | #elif defined(__AVR_ATmega16U2__) 76 | #define AVR_SIGNATURE_1 0x1E 77 | #define AVR_SIGNATURE_2 0x94 78 | #define AVR_SIGNATURE_3 0x89 79 | #elif defined(__AVR_AT90USB162__) 80 | #define AVR_SIGNATURE_1 0x1E 81 | #define AVR_SIGNATURE_2 0x94 82 | #define AVR_SIGNATURE_3 0x82 83 | #elif defined(__AVR_ATmega8U2__) 84 | #define AVR_SIGNATURE_1 0x1E 85 | #define AVR_SIGNATURE_2 0x93 86 | #define AVR_SIGNATURE_3 0x89 87 | #elif defined(__AVR_AT90USB82__) 88 | #define AVR_SIGNATURE_1 0x1E 89 | #define AVR_SIGNATURE_2 0x94 90 | #define AVR_SIGNATURE_3 0x82 91 | #else 92 | #error The selected AVR part is not currently supported by this bootloader. 93 | #endif 94 | 95 | /** Endpoint number for the CDC control interface event notification endpoint. */ 96 | #define CDC_NOTIFICATION_EPNUM 2 97 | 98 | /** Endpoint number for the CDC data interface TX (data IN) endpoint. */ 99 | #define CDC_TX_EPNUM 3 100 | 101 | /** Endpoint number for the CDC data interface RX (data OUT) endpoint. */ 102 | #define CDC_RX_EPNUM 4 103 | 104 | /** Size of the CDC data interface TX and RX data endpoint banks, in bytes. */ 105 | #define CDC_TXRX_EPSIZE 16 106 | 107 | /** Size of the CDC control interface notification endpoint bank, in bytes. */ 108 | #define CDC_NOTIFICATION_EPSIZE 8 109 | 110 | /* Type Defines: */ 111 | /** Type define for the device configuration descriptor structure. This must be defined in the 112 | * application code, as the configuration descriptor contains several sub-descriptors which 113 | * vary between devices, and which describe the device's usage to the host. 114 | */ 115 | typedef struct 116 | { 117 | USB_Descriptor_Configuration_Header_t Config; 118 | 119 | // CDC Control Interface 120 | USB_Descriptor_Interface_t CDC_CCI_Interface; 121 | USB_CDC_Descriptor_FunctionalHeader_t CDC_Functional_Header; 122 | USB_CDC_Descriptor_FunctionalACM_t CDC_Functional_ACM; 123 | USB_CDC_Descriptor_FunctionalUnion_t CDC_Functional_Union; 124 | USB_Descriptor_Endpoint_t CDC_NotificationEndpoint; 125 | 126 | // CDC Data Interface 127 | USB_Descriptor_Interface_t CDC_DCI_Interface; 128 | USB_Descriptor_Endpoint_t CDC_DataOutEndpoint; 129 | USB_Descriptor_Endpoint_t CDC_DataInEndpoint; 130 | } USB_Descriptor_Configuration_t; 131 | 132 | /* Function Prototypes: */ 133 | uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, 134 | const uint8_t wIndex, 135 | const void** const DescriptorAddress) 136 | ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3); 137 | 138 | #endif 139 | 140 | -------------------------------------------------------------------------------- /bootloaders/caterina-LilyPadUSB/Makefile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmadison/ArduinoXInput_AVR/585e49e863ccc73083863d421d1e513ce69b9900/bootloaders/caterina-LilyPadUSB/Makefile -------------------------------------------------------------------------------- /bootloaders/caterina-LilyPadUSB/Readme.txt: -------------------------------------------------------------------------------- 1 | Building the bootloader for the LilyPadUSB 2 | 1. Download the LUFA-111009 file (http://fourwalledcubicle.com/blog/2011/10/lufa-111009-released/). 3 | 2. Extract that file directly to the Caterina-LilyPadUSB bootloader directory. 4 | 3. Open a command prompt in the Caterina-LilyPadUSB bootloader directory. 5 | 4. Type 'make'. 6 | 5. Enjoy! 7 | 8 | Programming the bootloader for the LilyPadUSB 9 | 1. Open a command prompt in the Caterina-LilyPadUSB folder. 10 | 2. Connect your programmer- use a 2x3 .1" header, pressed against the programming vias. 11 | 3. Type 'make program' into the command prompt. -------------------------------------------------------------------------------- /bootloaders/caterina/Caterina-Esplora.txt: -------------------------------------------------------------------------------- 1 | LUFA: 111009 2 | make: 3.81 3 | avrdude: 5.11.1 4 | avr-libc: 1.6.7 5 | binutils-avr: 2.19 6 | gcc-avr 4.3.3 7 | -------------------------------------------------------------------------------- /bootloaders/caterina/Caterina-Leonardo.txt: -------------------------------------------------------------------------------- 1 | Builds against LUFA version 111009 2 | make version 3.81 3 | avrdude version 5.11 4 | 5 | All AVR tools except avrdude were installed by CrossPack 20100115: 6 | avr-gcc version 4.3.3 (GCC) 7 | Thread model: single 8 | Configured with: ../configure —prefix=/usr/local/CrossPack-AVR-20100115 —disable-dependency-tracking —disable-nls —disable-werror —target=avr —enable-languages=c,c++ —disable-nls —disable-libssp —with-dwarf2 9 | avr-libc version 1.6.7 10 | binutils version 2.19 11 | 12 | -------------------------------------------------------------------------------- /bootloaders/caterina/Caterina-Micro.txt: -------------------------------------------------------------------------------- 1 | Builds against LUFA version 111009 2 | make version 3.81 3 | avrdude version 5.11 4 | 5 | All AVR tools except avrdude were installed by CrossPack 20100115: 6 | avr-gcc version 4.3.3 (GCC) 7 | Thread model: single 8 | Configured with: ../configure —prefix=/usr/local/CrossPack-AVR-20100115 —disable-dependency-tracking —disable-nls —disable-werror —target=avr —enable-languages=c,c++ —disable-nls —disable-libssp —with-dwarf2 9 | avr-libc version 1.6.7 10 | binutils version 2.19 11 | 12 | -------------------------------------------------------------------------------- /bootloaders/caterina/Caterina.h: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2011. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.lufa-lib.org 7 | */ 8 | 9 | /* 10 | Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /** \file 32 | * 33 | * Header file for BootloaderCDC.c. 34 | */ 35 | 36 | #ifndef _CDC_H_ 37 | #define _CDC_H_ 38 | 39 | /* Includes: */ 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | 48 | #include "Descriptors.h" 49 | 50 | #include 51 | /* Macros: */ 52 | /** Version major of the CDC bootloader. */ 53 | #define BOOTLOADER_VERSION_MAJOR 0x01 54 | 55 | /** Version minor of the CDC bootloader. */ 56 | #define BOOTLOADER_VERSION_MINOR 0x00 57 | 58 | /** Hardware version major of the CDC bootloader. */ 59 | #define BOOTLOADER_HWVERSION_MAJOR 0x01 60 | 61 | /** Hardware version minor of the CDC bootloader. */ 62 | #define BOOTLOADER_HWVERSION_MINOR 0x00 63 | 64 | /** Eight character bootloader firmware identifier reported to the host when requested */ 65 | #define SOFTWARE_IDENTIFIER "CATERINA" 66 | 67 | #define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n)) 68 | #define LED_SETUP() DDRC |= (1<<7); DDRB |= (1<<0); DDRD |= (1<<5); 69 | #define L_LED_OFF() PORTC &= ~(1<<7) 70 | #define L_LED_ON() PORTC |= (1<<7) 71 | #define L_LED_TOGGLE() PORTC ^= (1<<7) 72 | #if DEVICE_PID == 0x0037 // polarity of the RX and TX LEDs is reversed on the Micro 73 | #define TX_LED_OFF() PORTD &= ~(1<<5) 74 | #define TX_LED_ON() PORTD |= (1<<5) 75 | #define RX_LED_OFF() PORTB &= ~(1<<0) 76 | #define RX_LED_ON() PORTB |= (1<<0) 77 | #else 78 | #define TX_LED_OFF() PORTD |= (1<<5) 79 | #define TX_LED_ON() PORTD &= ~(1<<5) 80 | #define RX_LED_OFF() PORTB |= (1<<0) 81 | #define RX_LED_ON() PORTB &= ~(1<<0) 82 | #endif 83 | 84 | /* Type Defines: */ 85 | /** Type define for a non-returning pointer to the start of the loaded application in flash memory. */ 86 | typedef void (*AppPtr_t)(void) ATTR_NO_RETURN; 87 | 88 | /* Function Prototypes: */ 89 | void StartSketch(void); 90 | void LEDPulse(void); 91 | 92 | void CDC_Task(void); 93 | void SetupHardware(void); 94 | 95 | void EVENT_USB_Device_ConfigurationChanged(void); 96 | 97 | #if defined(INCLUDE_FROM_CATERINA_C) || defined(__DOXYGEN__) 98 | #if !defined(NO_BLOCK_SUPPORT) 99 | static void ReadWriteMemoryBlock(const uint8_t Command); 100 | #endif 101 | static uint8_t FetchNextCommandByte(void); 102 | static void WriteNextResponseByte(const uint8_t Response); 103 | #endif 104 | 105 | #endif 106 | 107 | -------------------------------------------------------------------------------- /bootloaders/caterina/Descriptors.h: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2011. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.lufa-lib.org 7 | */ 8 | 9 | /* 10 | Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /** \file 32 | * 33 | * Header file for Descriptors.c. 34 | */ 35 | 36 | #ifndef _DESCRIPTORS_H_ 37 | #define _DESCRIPTORS_H_ 38 | 39 | /* Includes: */ 40 | #include 41 | 42 | /* Macros: */ 43 | #if defined(__AVR_AT90USB1287__) 44 | #define AVR_SIGNATURE_1 0x1E 45 | #define AVR_SIGNATURE_2 0x97 46 | #define AVR_SIGNATURE_3 0x82 47 | #elif defined(__AVR_AT90USB647__) 48 | #define AVR_SIGNATURE_1 0x1E 49 | #define AVR_SIGNATURE_2 0x96 50 | #define AVR_SIGNATURE_3 0x82 51 | #elif defined(__AVR_AT90USB1286__) 52 | #define AVR_SIGNATURE_1 0x1E 53 | #define AVR_SIGNATURE_2 0x97 54 | #define AVR_SIGNATURE_3 0x82 55 | #elif defined(__AVR_AT90USB646__) 56 | #define AVR_SIGNATURE_1 0x1E 57 | #define AVR_SIGNATURE_2 0x96 58 | #define AVR_SIGNATURE_3 0x82 59 | #elif defined(__AVR_ATmega32U6__) 60 | #define AVR_SIGNATURE_1 0x1E 61 | #define AVR_SIGNATURE_2 0x95 62 | #define AVR_SIGNATURE_3 0x88 63 | #elif defined(__AVR_ATmega32U4__) 64 | #define AVR_SIGNATURE_1 0x1E 65 | #define AVR_SIGNATURE_2 0x95 66 | #define AVR_SIGNATURE_3 0x87 67 | #elif defined(__AVR_ATmega16U4__) 68 | #define AVR_SIGNATURE_1 0x1E 69 | #define AVR_SIGNATURE_2 0x94 70 | #define AVR_SIGNATURE_3 0x88 71 | #elif defined(__AVR_ATmega32U2__) 72 | #define AVR_SIGNATURE_1 0x1E 73 | #define AVR_SIGNATURE_2 0x95 74 | #define AVR_SIGNATURE_3 0x8A 75 | #elif defined(__AVR_ATmega16U2__) 76 | #define AVR_SIGNATURE_1 0x1E 77 | #define AVR_SIGNATURE_2 0x94 78 | #define AVR_SIGNATURE_3 0x89 79 | #elif defined(__AVR_AT90USB162__) 80 | #define AVR_SIGNATURE_1 0x1E 81 | #define AVR_SIGNATURE_2 0x94 82 | #define AVR_SIGNATURE_3 0x82 83 | #elif defined(__AVR_ATmega8U2__) 84 | #define AVR_SIGNATURE_1 0x1E 85 | #define AVR_SIGNATURE_2 0x93 86 | #define AVR_SIGNATURE_3 0x89 87 | #elif defined(__AVR_AT90USB82__) 88 | #define AVR_SIGNATURE_1 0x1E 89 | #define AVR_SIGNATURE_2 0x94 90 | #define AVR_SIGNATURE_3 0x82 91 | #else 92 | #error The selected AVR part is not currently supported by this bootloader. 93 | #endif 94 | 95 | /** Endpoint number for the CDC control interface event notification endpoint. */ 96 | #define CDC_NOTIFICATION_EPNUM 2 97 | 98 | /** Endpoint number for the CDC data interface TX (data IN) endpoint. */ 99 | #define CDC_TX_EPNUM 3 100 | 101 | /** Endpoint number for the CDC data interface RX (data OUT) endpoint. */ 102 | #define CDC_RX_EPNUM 4 103 | 104 | /** Size of the CDC data interface TX and RX data endpoint banks, in bytes. */ 105 | #define CDC_TXRX_EPSIZE 16 106 | 107 | /** Size of the CDC control interface notification endpoint bank, in bytes. */ 108 | #define CDC_NOTIFICATION_EPSIZE 8 109 | 110 | /* Type Defines: */ 111 | /** Type define for the device configuration descriptor structure. This must be defined in the 112 | * application code, as the configuration descriptor contains several sub-descriptors which 113 | * vary between devices, and which describe the device's usage to the host. 114 | */ 115 | typedef struct 116 | { 117 | USB_Descriptor_Configuration_Header_t Config; 118 | 119 | // CDC Control Interface 120 | USB_Descriptor_Interface_t CDC_CCI_Interface; 121 | USB_CDC_Descriptor_FunctionalHeader_t CDC_Functional_Header; 122 | USB_CDC_Descriptor_FunctionalACM_t CDC_Functional_ACM; 123 | USB_CDC_Descriptor_FunctionalUnion_t CDC_Functional_Union; 124 | USB_Descriptor_Endpoint_t CDC_NotificationEndpoint; 125 | 126 | // CDC Data Interface 127 | USB_Descriptor_Interface_t CDC_DCI_Interface; 128 | USB_Descriptor_Endpoint_t CDC_DataOutEndpoint; 129 | USB_Descriptor_Endpoint_t CDC_DataInEndpoint; 130 | } USB_Descriptor_Configuration_t; 131 | 132 | /* Function Prototypes: */ 133 | uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, 134 | const uint8_t wIndex, 135 | const void** const DescriptorAddress) 136 | ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3); 137 | 138 | #endif 139 | 140 | -------------------------------------------------------------------------------- /bootloaders/caterina/Esplora-prod-firmware-2012-12-10.txt: -------------------------------------------------------------------------------- 1 | LUFA: 111009 2 | make: 3.81 3 | avrdude: 5.11.1 4 | avr-libc: 1.6.7 5 | binutils-avr: 2.19 6 | gcc-avr 4.3.3 7 | -------------------------------------------------------------------------------- /bootloaders/caterina/Leonardo-prod-firmware-2012-04-26.txt: -------------------------------------------------------------------------------- 1 | Builds against LUFA version 111009 2 | make version 3.81 3 | avrdude version 5.11 4 | 5 | All AVR tools except avrdude were installed by CrossPack 20100115: 6 | avr-gcc version 4.3.3 (GCC) 7 | Thread model: single 8 | Configured with: ../configure —prefix=/usr/local/CrossPack-AVR-20100115 —disable-dependency-tracking —disable-nls —disable-werror —target=avr —enable-languages=c,c++ —disable-nls —disable-libssp —with-dwarf2 9 | avr-libc version 1.6.7 10 | binutils version 2.19 11 | 12 | -------------------------------------------------------------------------------- /bootloaders/caterina/Leonardo-prod-firmware-2012-12-10.txt: -------------------------------------------------------------------------------- 1 | Builds against LUFA version 111009 2 | make version 3.81 3 | avrdude version 5.11 4 | 5 | All AVR tools except avrdude were installed by CrossPack 20100115: 6 | avr-gcc version 4.3.3 (GCC) 7 | Thread model: single 8 | Configured with: ../configure —prefix=/usr/local/CrossPack-AVR-20100115 —disable-dependency-tracking —disable-nls —disable-werror —target=avr —enable-languages=c,c++ —disable-nls —disable-libssp —with-dwarf2 9 | avr-libc version 1.6.7 10 | binutils version 2.19 11 | 12 | -------------------------------------------------------------------------------- /bootloaders/caterina/Makefile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmadison/ArduinoXInput_AVR/585e49e863ccc73083863d421d1e513ce69b9900/bootloaders/caterina/Makefile -------------------------------------------------------------------------------- /bootloaders/caterina/Micro-prod-firmware-2012-11-23.txt: -------------------------------------------------------------------------------- 1 | Builds against LUFA version 111009 2 | make version 3.81 3 | avrdude version 5.11 4 | 5 | All AVR tools except avrdude were installed by CrossPack 20100115: 6 | avr-gcc version 4.3.3 (GCC) 7 | Thread model: single 8 | Configured with: ../configure —prefix=/usr/local/CrossPack-AVR-20100115 —disable-dependency-tracking —disable-nls —disable-werror —target=avr —enable-languages=c,c++ —disable-nls —disable-libssp —with-dwarf2 9 | avr-libc version 1.6.7 10 | binutils version 2.19 11 | 12 | -------------------------------------------------------------------------------- /bootloaders/caterina/Micro-prod-firmware-2012-12-10.txt: -------------------------------------------------------------------------------- 1 | Builds against LUFA version 111009 2 | make version 3.81 3 | avrdude version 5.11 4 | 5 | All AVR tools except avrdude were installed by CrossPack 20100115: 6 | avr-gcc version 4.3.3 (GCC) 7 | Thread model: single 8 | Configured with: ../configure —prefix=/usr/local/CrossPack-AVR-20100115 —disable-dependency-tracking —disable-nls —disable-werror —target=avr —enable-languages=c,c++ —disable-nls —disable-libssp —with-dwarf2 9 | avr-libc version 1.6.7 10 | binutils version 2.19 11 | 12 | -------------------------------------------------------------------------------- /cores/arduino/CDC.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | /* Copyright (c) 2011, Peter Barrett 4 | ** 5 | ** Permission to use, copy, modify, and/or distribute this software for 6 | ** any purpose with or without fee is hereby granted, provided that the 7 | ** above copyright notice and this permission notice appear in all copies. 8 | ** 9 | ** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 10 | ** WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 11 | ** WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR 12 | ** BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES 13 | ** OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 14 | ** WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 15 | ** ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 16 | ** SOFTWARE. 17 | */ 18 | 19 | #include "USBAPI.h" 20 | 21 | #if defined(USBCON) 22 | 23 | Serial_ Serial; 24 | 25 | #endif /* if defined(USBCON) */ 26 | -------------------------------------------------------------------------------- /cores/arduino/Client.h: -------------------------------------------------------------------------------- 1 | /* 2 | Client.h - Base class that provides Client 3 | Copyright (c) 2011 Adrian McEwen. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef client_h 21 | #define client_h 22 | #include "Print.h" 23 | #include "Stream.h" 24 | #include "IPAddress.h" 25 | 26 | class Client : public Stream { 27 | 28 | public: 29 | virtual int connect(IPAddress ip, uint16_t port) =0; 30 | virtual int connect(const char *host, uint16_t port) =0; 31 | virtual size_t write(uint8_t) =0; 32 | virtual size_t write(const uint8_t *buf, size_t size) =0; 33 | virtual int available() = 0; 34 | virtual int read() = 0; 35 | virtual int read(uint8_t *buf, size_t size) = 0; 36 | virtual int peek() = 0; 37 | virtual void flush() = 0; 38 | virtual void stop() = 0; 39 | virtual uint8_t connected() = 0; 40 | virtual operator bool() = 0; 41 | protected: 42 | uint8_t* rawIPAddress(IPAddress& addr) { return addr.raw_address(); }; 43 | }; 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /cores/arduino/HardwareSerial.h: -------------------------------------------------------------------------------- 1 | /* 2 | HardwareSerial.h - Hardware serial library for Wiring 3 | Copyright (c) 2006 Nicholas Zambetti. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Modified 28 September 2010 by Mark Sproul 20 | Modified 14 August 2012 by Alarus 21 | Modified 3 December 2013 by Matthijs Kooijman 22 | */ 23 | 24 | #ifndef HardwareSerial_h 25 | #define HardwareSerial_h 26 | 27 | #include 28 | 29 | #include "Stream.h" 30 | 31 | // Define constants and variables for buffering incoming serial data. We're 32 | // using a ring buffer (I think), in which head is the index of the location 33 | // to which to write the next incoming character and tail is the index of the 34 | // location from which to read. 35 | // NOTE: a "power of 2" buffer size is recommended to dramatically 36 | // optimize all the modulo operations for ring buffers. 37 | // WARNING: When buffer sizes are increased to > 256, the buffer index 38 | // variables are automatically increased in size, but the extra 39 | // atomicity guards needed for that are not implemented. This will 40 | // often work, but occasionally a race condition can occur that makes 41 | // Serial behave erratically. See https://github.com/arduino/Arduino/issues/2405 42 | #if !defined(SERIAL_TX_BUFFER_SIZE) 43 | #if ((RAMEND - RAMSTART) < 1023) 44 | #define SERIAL_TX_BUFFER_SIZE 16 45 | #else 46 | #define SERIAL_TX_BUFFER_SIZE 64 47 | #endif 48 | #endif 49 | #if !defined(SERIAL_RX_BUFFER_SIZE) 50 | #if ((RAMEND - RAMSTART) < 1023) 51 | #define SERIAL_RX_BUFFER_SIZE 16 52 | #else 53 | #define SERIAL_RX_BUFFER_SIZE 64 54 | #endif 55 | #endif 56 | #if (SERIAL_TX_BUFFER_SIZE>256) 57 | typedef uint16_t tx_buffer_index_t; 58 | #else 59 | typedef uint8_t tx_buffer_index_t; 60 | #endif 61 | #if (SERIAL_RX_BUFFER_SIZE>256) 62 | typedef uint16_t rx_buffer_index_t; 63 | #else 64 | typedef uint8_t rx_buffer_index_t; 65 | #endif 66 | 67 | // Define config for Serial.begin(baud, config); 68 | #define SERIAL_5N1 0x00 69 | #define SERIAL_6N1 0x02 70 | #define SERIAL_7N1 0x04 71 | #define SERIAL_8N1 0x06 72 | #define SERIAL_5N2 0x08 73 | #define SERIAL_6N2 0x0A 74 | #define SERIAL_7N2 0x0C 75 | #define SERIAL_8N2 0x0E 76 | #define SERIAL_5E1 0x20 77 | #define SERIAL_6E1 0x22 78 | #define SERIAL_7E1 0x24 79 | #define SERIAL_8E1 0x26 80 | #define SERIAL_5E2 0x28 81 | #define SERIAL_6E2 0x2A 82 | #define SERIAL_7E2 0x2C 83 | #define SERIAL_8E2 0x2E 84 | #define SERIAL_5O1 0x30 85 | #define SERIAL_6O1 0x32 86 | #define SERIAL_7O1 0x34 87 | #define SERIAL_8O1 0x36 88 | #define SERIAL_5O2 0x38 89 | #define SERIAL_6O2 0x3A 90 | #define SERIAL_7O2 0x3C 91 | #define SERIAL_8O2 0x3E 92 | 93 | class HardwareSerial : public Stream 94 | { 95 | protected: 96 | volatile uint8_t * const _ubrrh; 97 | volatile uint8_t * const _ubrrl; 98 | volatile uint8_t * const _ucsra; 99 | volatile uint8_t * const _ucsrb; 100 | volatile uint8_t * const _ucsrc; 101 | volatile uint8_t * const _udr; 102 | // Has any byte been written to the UART since begin() 103 | bool _written; 104 | 105 | volatile rx_buffer_index_t _rx_buffer_head; 106 | volatile rx_buffer_index_t _rx_buffer_tail; 107 | volatile tx_buffer_index_t _tx_buffer_head; 108 | volatile tx_buffer_index_t _tx_buffer_tail; 109 | 110 | // Don't put any members after these buffers, since only the first 111 | // 32 bytes of this struct can be accessed quickly using the ldd 112 | // instruction. 113 | unsigned char _rx_buffer[SERIAL_RX_BUFFER_SIZE]; 114 | unsigned char _tx_buffer[SERIAL_TX_BUFFER_SIZE]; 115 | 116 | public: 117 | inline HardwareSerial( 118 | volatile uint8_t *ubrrh, volatile uint8_t *ubrrl, 119 | volatile uint8_t *ucsra, volatile uint8_t *ucsrb, 120 | volatile uint8_t *ucsrc, volatile uint8_t *udr); 121 | void begin(unsigned long baud) { begin(baud, SERIAL_8N1); } 122 | void begin(unsigned long, uint8_t); 123 | void end(); 124 | virtual int available(void); 125 | virtual int peek(void); 126 | virtual int read(void); 127 | virtual int availableForWrite(void); 128 | virtual void flush(void); 129 | virtual size_t write(uint8_t); 130 | inline size_t write(unsigned long n) { return write((uint8_t)n); } 131 | inline size_t write(long n) { return write((uint8_t)n); } 132 | inline size_t write(unsigned int n) { return write((uint8_t)n); } 133 | inline size_t write(int n) { return write((uint8_t)n); } 134 | using Print::write; // pull in write(str) and write(buf, size) from Print 135 | operator bool() { return true; } 136 | 137 | // Interrupt handlers - Not intended to be called externally 138 | inline void _rx_complete_irq(void); 139 | void _tx_udr_empty_irq(void); 140 | }; 141 | 142 | #if defined(UBRRH) || defined(UBRR0H) 143 | extern HardwareSerial Serial; 144 | #define HAVE_HWSERIAL0 145 | #endif 146 | #if defined(UBRR1H) 147 | extern HardwareSerial Serial1; 148 | #define HAVE_HWSERIAL1 149 | #endif 150 | #if defined(UBRR2H) 151 | extern HardwareSerial Serial2; 152 | #define HAVE_HWSERIAL2 153 | #endif 154 | #if defined(UBRR3H) 155 | extern HardwareSerial Serial3; 156 | #define HAVE_HWSERIAL3 157 | #endif 158 | 159 | extern void serialEventRun(void) __attribute__((weak)); 160 | 161 | #endif 162 | -------------------------------------------------------------------------------- /cores/arduino/HardwareSerial0.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | HardwareSerial0.cpp - Hardware serial library for Wiring 3 | Copyright (c) 2006 Nicholas Zambetti. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Modified 23 November 2006 by David A. Mellis 20 | Modified 28 September 2010 by Mark Sproul 21 | Modified 14 August 2012 by Alarus 22 | Modified 3 December 2013 by Matthijs Kooijman 23 | */ 24 | 25 | #include "Arduino.h" 26 | #include "HardwareSerial.h" 27 | #include "HardwareSerial_private.h" 28 | 29 | // Each HardwareSerial is defined in its own file, since the linker pulls 30 | // in the entire file when any element inside is used. --gc-sections can 31 | // additionally cause unused symbols to be dropped, but ISRs have the 32 | // "used" attribute so are never dropped and they keep the 33 | // HardwareSerial instance in as well. Putting each instance in its own 34 | // file prevents the linker from pulling in any unused instances in the 35 | // first place. 36 | 37 | #if defined(HAVE_HWSERIAL0) 38 | 39 | #if defined(USART_RX_vect) 40 | ISR(USART_RX_vect) 41 | #elif defined(USART0_RX_vect) 42 | ISR(USART0_RX_vect) 43 | #elif defined(USART_RXC_vect) 44 | ISR(USART_RXC_vect) // ATmega8 45 | #else 46 | #error "Don't know what the Data Received vector is called for Serial" 47 | #endif 48 | { 49 | Serial._rx_complete_irq(); 50 | } 51 | 52 | #if defined(UART0_UDRE_vect) 53 | ISR(UART0_UDRE_vect) 54 | #elif defined(UART_UDRE_vect) 55 | ISR(UART_UDRE_vect) 56 | #elif defined(USART0_UDRE_vect) 57 | ISR(USART0_UDRE_vect) 58 | #elif defined(USART_UDRE_vect) 59 | ISR(USART_UDRE_vect) 60 | #else 61 | #error "Don't know what the Data Register Empty vector is called for Serial" 62 | #endif 63 | { 64 | Serial._tx_udr_empty_irq(); 65 | } 66 | 67 | #if defined(UBRRH) && defined(UBRRL) 68 | HardwareSerial Serial(&UBRRH, &UBRRL, &UCSRA, &UCSRB, &UCSRC, &UDR); 69 | #else 70 | HardwareSerial Serial(&UBRR0H, &UBRR0L, &UCSR0A, &UCSR0B, &UCSR0C, &UDR0); 71 | #endif 72 | 73 | // Function that can be weakly referenced by serialEventRun to prevent 74 | // pulling in this file if it's not otherwise used. 75 | bool Serial0_available() { 76 | return Serial.available(); 77 | } 78 | 79 | #endif // HAVE_HWSERIAL0 80 | -------------------------------------------------------------------------------- /cores/arduino/HardwareSerial1.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | HardwareSerial1.cpp - Hardware serial library for Wiring 3 | Copyright (c) 2006 Nicholas Zambetti. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Modified 23 November 2006 by David A. Mellis 20 | Modified 28 September 2010 by Mark Sproul 21 | Modified 14 August 2012 by Alarus 22 | Modified 3 December 2013 by Matthijs Kooijman 23 | */ 24 | 25 | #include "Arduino.h" 26 | #include "HardwareSerial.h" 27 | #include "HardwareSerial_private.h" 28 | 29 | // Each HardwareSerial is defined in its own file, since the linker pulls 30 | // in the entire file when any element inside is used. --gc-sections can 31 | // additionally cause unused symbols to be dropped, but ISRs have the 32 | // "used" attribute so are never dropped and they keep the 33 | // HardwareSerial instance in as well. Putting each instance in its own 34 | // file prevents the linker from pulling in any unused instances in the 35 | // first place. 36 | 37 | #if defined(HAVE_HWSERIAL1) 38 | 39 | #if defined(UART1_RX_vect) 40 | ISR(UART1_RX_vect) 41 | #elif defined(USART1_RX_vect) 42 | ISR(USART1_RX_vect) 43 | #else 44 | #error "Don't know what the Data Register Empty vector is called for Serial1" 45 | #endif 46 | { 47 | Serial1._rx_complete_irq(); 48 | } 49 | 50 | #if defined(UART1_UDRE_vect) 51 | ISR(UART1_UDRE_vect) 52 | #elif defined(USART1_UDRE_vect) 53 | ISR(USART1_UDRE_vect) 54 | #else 55 | #error "Don't know what the Data Register Empty vector is called for Serial1" 56 | #endif 57 | { 58 | Serial1._tx_udr_empty_irq(); 59 | } 60 | 61 | HardwareSerial Serial1(&UBRR1H, &UBRR1L, &UCSR1A, &UCSR1B, &UCSR1C, &UDR1); 62 | 63 | // Function that can be weakly referenced by serialEventRun to prevent 64 | // pulling in this file if it's not otherwise used. 65 | bool Serial1_available() { 66 | return Serial1.available(); 67 | } 68 | 69 | #endif // HAVE_HWSERIAL1 70 | -------------------------------------------------------------------------------- /cores/arduino/HardwareSerial2.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | HardwareSerial2.cpp - Hardware serial library for Wiring 3 | Copyright (c) 2006 Nicholas Zambetti. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Modified 23 November 2006 by David A. Mellis 20 | Modified 28 September 2010 by Mark Sproul 21 | Modified 14 August 2012 by Alarus 22 | Modified 3 December 2013 by Matthijs Kooijman 23 | */ 24 | 25 | #include "Arduino.h" 26 | #include "HardwareSerial.h" 27 | #include "HardwareSerial_private.h" 28 | 29 | // Each HardwareSerial is defined in its own file, since the linker pulls 30 | // in the entire file when any element inside is used. --gc-sections can 31 | // additionally cause unused symbols to be dropped, but ISRs have the 32 | // "used" attribute so are never dropped and they keep the 33 | // HardwareSerial instance in as well. Putting each instance in its own 34 | // file prevents the linker from pulling in any unused instances in the 35 | // first place. 36 | 37 | #if defined(HAVE_HWSERIAL2) 38 | 39 | ISR(USART2_RX_vect) 40 | { 41 | Serial2._rx_complete_irq(); 42 | } 43 | 44 | ISR(USART2_UDRE_vect) 45 | { 46 | Serial2._tx_udr_empty_irq(); 47 | } 48 | 49 | HardwareSerial Serial2(&UBRR2H, &UBRR2L, &UCSR2A, &UCSR2B, &UCSR2C, &UDR2); 50 | 51 | // Function that can be weakly referenced by serialEventRun to prevent 52 | // pulling in this file if it's not otherwise used. 53 | bool Serial2_available() { 54 | return Serial2.available(); 55 | } 56 | 57 | #endif // HAVE_HWSERIAL2 58 | -------------------------------------------------------------------------------- /cores/arduino/HardwareSerial3.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | HardwareSerial3.cpp - Hardware serial library for Wiring 3 | Copyright (c) 2006 Nicholas Zambetti. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Modified 23 November 2006 by David A. Mellis 20 | Modified 28 September 2010 by Mark Sproul 21 | Modified 14 August 2012 by Alarus 22 | Modified 3 December 2013 by Matthijs Kooijman 23 | */ 24 | 25 | #include "Arduino.h" 26 | #include "HardwareSerial.h" 27 | #include "HardwareSerial_private.h" 28 | 29 | // Each HardwareSerial is defined in its own file, since the linker pulls 30 | // in the entire file when any element inside is used. --gc-sections can 31 | // additionally cause unused symbols to be dropped, but ISRs have the 32 | // "used" attribute so are never dropped and they keep the 33 | // HardwareSerial instance in as well. Putting each instance in its own 34 | // file prevents the linker from pulling in any unused instances in the 35 | // first place. 36 | 37 | #if defined(HAVE_HWSERIAL3) 38 | 39 | ISR(USART3_RX_vect) 40 | { 41 | Serial3._rx_complete_irq(); 42 | } 43 | 44 | ISR(USART3_UDRE_vect) 45 | { 46 | Serial3._tx_udr_empty_irq(); 47 | } 48 | 49 | HardwareSerial Serial3(&UBRR3H, &UBRR3L, &UCSR3A, &UCSR3B, &UCSR3C, &UDR3); 50 | 51 | // Function that can be weakly referenced by serialEventRun to prevent 52 | // pulling in this file if it's not otherwise used. 53 | bool Serial3_available() { 54 | return Serial3.available(); 55 | } 56 | 57 | #endif // HAVE_HWSERIAL3 58 | -------------------------------------------------------------------------------- /cores/arduino/HardwareSerial_private.h: -------------------------------------------------------------------------------- 1 | /* 2 | HardwareSerial_private.h - Hardware serial library for Wiring 3 | Copyright (c) 2006 Nicholas Zambetti. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Modified 23 November 2006 by David A. Mellis 20 | Modified 28 September 2010 by Mark Sproul 21 | Modified 14 August 2012 by Alarus 22 | */ 23 | 24 | #include "wiring_private.h" 25 | 26 | // this next line disables the entire HardwareSerial.cpp, 27 | // this is so I can support Attiny series and any other chip without a uart 28 | #if defined(HAVE_HWSERIAL0) || defined(HAVE_HWSERIAL1) || defined(HAVE_HWSERIAL2) || defined(HAVE_HWSERIAL3) 29 | 30 | // Ensure that the various bit positions we use are available with a 0 31 | // postfix, so we can always use the values for UART0 for all UARTs. The 32 | // alternative, passing the various values for each UART to the 33 | // HardwareSerial constructor also works, but makes the code bigger and 34 | // slower. 35 | #if !defined(TXC0) 36 | #if defined(TXC) 37 | // Some chips like ATmega8 don't have UPE, only PE. The other bits are 38 | // named as expected. 39 | #if !defined(UPE) && defined(PE) 40 | #define UPE PE 41 | #endif 42 | // On ATmega8, the uart and its bits are not numbered, so there is no TXC0 etc. 43 | #define TXC0 TXC 44 | #define RXEN0 RXEN 45 | #define TXEN0 TXEN 46 | #define RXCIE0 RXCIE 47 | #define UDRIE0 UDRIE 48 | #define U2X0 U2X 49 | #define UPE0 UPE 50 | #define UDRE0 UDRE 51 | #elif defined(TXC1) 52 | // Some devices have uart1 but no uart0 53 | #define TXC0 TXC1 54 | #define RXEN0 RXEN1 55 | #define TXEN0 TXEN1 56 | #define RXCIE0 RXCIE1 57 | #define UDRIE0 UDRIE1 58 | #define U2X0 U2X1 59 | #define UPE0 UPE1 60 | #define UDRE0 UDRE1 61 | #else 62 | #error No UART found in HardwareSerial.cpp 63 | #endif 64 | #endif // !defined TXC0 65 | 66 | // Check at compile time that it is really ok to use the bit positions of 67 | // UART0 for the other UARTs as well, in case these values ever get 68 | // changed for future hardware. 69 | #if defined(TXC1) && (TXC1 != TXC0 || RXEN1 != RXEN0 || RXCIE1 != RXCIE0 || \ 70 | UDRIE1 != UDRIE0 || U2X1 != U2X0 || UPE1 != UPE0 || \ 71 | UDRE1 != UDRE0) 72 | #error "Not all bit positions for UART1 are the same as for UART0" 73 | #endif 74 | #if defined(TXC2) && (TXC2 != TXC0 || RXEN2 != RXEN0 || RXCIE2 != RXCIE0 || \ 75 | UDRIE2 != UDRIE0 || U2X2 != U2X0 || UPE2 != UPE0 || \ 76 | UDRE2 != UDRE0) 77 | #error "Not all bit positions for UART2 are the same as for UART0" 78 | #endif 79 | #if defined(TXC3) && (TXC3 != TXC0 || RXEN3 != RXEN0 || RXCIE3 != RXCIE0 || \ 80 | UDRIE3 != UDRIE0 || U3X3 != U3X0 || UPE3 != UPE0 || \ 81 | UDRE3 != UDRE0) 82 | #error "Not all bit positions for UART3 are the same as for UART0" 83 | #endif 84 | 85 | // Constructors //////////////////////////////////////////////////////////////// 86 | 87 | HardwareSerial::HardwareSerial( 88 | volatile uint8_t *ubrrh, volatile uint8_t *ubrrl, 89 | volatile uint8_t *ucsra, volatile uint8_t *ucsrb, 90 | volatile uint8_t *ucsrc, volatile uint8_t *udr) : 91 | _ubrrh(ubrrh), _ubrrl(ubrrl), 92 | _ucsra(ucsra), _ucsrb(ucsrb), _ucsrc(ucsrc), 93 | _udr(udr), 94 | _rx_buffer_head(0), _rx_buffer_tail(0), 95 | _tx_buffer_head(0), _tx_buffer_tail(0) 96 | { 97 | } 98 | 99 | // Actual interrupt handlers ////////////////////////////////////////////////////////////// 100 | 101 | void HardwareSerial::_rx_complete_irq(void) 102 | { 103 | if (bit_is_clear(*_ucsra, UPE0)) { 104 | // No Parity error, read byte and store it in the buffer if there is 105 | // room 106 | unsigned char c = *_udr; 107 | rx_buffer_index_t i = (unsigned int)(_rx_buffer_head + 1) % SERIAL_RX_BUFFER_SIZE; 108 | 109 | // if we should be storing the received character into the location 110 | // just before the tail (meaning that the head would advance to the 111 | // current location of the tail), we're about to overflow the buffer 112 | // and so we don't write the character or advance the head. 113 | if (i != _rx_buffer_tail) { 114 | _rx_buffer[_rx_buffer_head] = c; 115 | _rx_buffer_head = i; 116 | } 117 | } else { 118 | // Parity error, read byte but discard it 119 | *_udr; 120 | }; 121 | } 122 | 123 | #endif // whole file 124 | -------------------------------------------------------------------------------- /cores/arduino/IPAddress.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | IPAddress.cpp - Base class that provides IPAddress 3 | Copyright (c) 2011 Adrian McEwen. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #include 21 | #include 22 | 23 | IPAddress::IPAddress() 24 | { 25 | _address.dword = 0; 26 | } 27 | 28 | IPAddress::IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet) 29 | { 30 | _address.bytes[0] = first_octet; 31 | _address.bytes[1] = second_octet; 32 | _address.bytes[2] = third_octet; 33 | _address.bytes[3] = fourth_octet; 34 | } 35 | 36 | IPAddress::IPAddress(uint32_t address) 37 | { 38 | _address.dword = address; 39 | } 40 | 41 | IPAddress::IPAddress(const uint8_t *address) 42 | { 43 | memcpy(_address.bytes, address, sizeof(_address.bytes)); 44 | } 45 | 46 | bool IPAddress::fromString(const char *address) 47 | { 48 | uint16_t acc = 0; // Accumulator 49 | uint8_t dots = 0; 50 | 51 | while (*address) 52 | { 53 | char c = *address++; 54 | if (c >= '0' && c <= '9') 55 | { 56 | acc = acc * 10 + (c - '0'); 57 | if (acc > 255) { 58 | // Value out of [0..255] range 59 | return false; 60 | } 61 | } 62 | else if (c == '.') 63 | { 64 | if (dots == 3) { 65 | // Too much dots (there must be 3 dots) 66 | return false; 67 | } 68 | _address.bytes[dots++] = acc; 69 | acc = 0; 70 | } 71 | else 72 | { 73 | // Invalid char 74 | return false; 75 | } 76 | } 77 | 78 | if (dots != 3) { 79 | // Too few dots (there must be 3 dots) 80 | return false; 81 | } 82 | _address.bytes[3] = acc; 83 | return true; 84 | } 85 | 86 | IPAddress& IPAddress::operator=(const uint8_t *address) 87 | { 88 | memcpy(_address.bytes, address, sizeof(_address.bytes)); 89 | return *this; 90 | } 91 | 92 | IPAddress& IPAddress::operator=(uint32_t address) 93 | { 94 | _address.dword = address; 95 | return *this; 96 | } 97 | 98 | bool IPAddress::operator==(const uint8_t* addr) const 99 | { 100 | return memcmp(addr, _address.bytes, sizeof(_address.bytes)) == 0; 101 | } 102 | 103 | size_t IPAddress::printTo(Print& p) const 104 | { 105 | size_t n = 0; 106 | for (int i =0; i < 3; i++) 107 | { 108 | n += p.print(_address.bytes[i], DEC); 109 | n += p.print('.'); 110 | } 111 | n += p.print(_address.bytes[3], DEC); 112 | return n; 113 | } 114 | 115 | -------------------------------------------------------------------------------- /cores/arduino/IPAddress.h: -------------------------------------------------------------------------------- 1 | /* 2 | IPAddress.h - Base class that provides IPAddress 3 | Copyright (c) 2011 Adrian McEwen. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef IPAddress_h 21 | #define IPAddress_h 22 | 23 | #include 24 | #include "Printable.h" 25 | #include "WString.h" 26 | 27 | // A class to make it easier to handle and pass around IP addresses 28 | 29 | class IPAddress : public Printable { 30 | private: 31 | union { 32 | uint8_t bytes[4]; // IPv4 address 33 | uint32_t dword; 34 | } _address; 35 | 36 | // Access the raw byte array containing the address. Because this returns a pointer 37 | // to the internal structure rather than a copy of the address this function should only 38 | // be used when you know that the usage of the returned uint8_t* will be transient and not 39 | // stored. 40 | uint8_t* raw_address() { return _address.bytes; }; 41 | 42 | public: 43 | // Constructors 44 | IPAddress(); 45 | IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet); 46 | IPAddress(uint32_t address); 47 | IPAddress(const uint8_t *address); 48 | 49 | bool fromString(const char *address); 50 | bool fromString(const String &address) { return fromString(address.c_str()); } 51 | 52 | // Overloaded cast operator to allow IPAddress objects to be used where a pointer 53 | // to a four-byte uint8_t array is expected 54 | operator uint32_t() const { return _address.dword; }; 55 | bool operator==(const IPAddress& addr) const { return _address.dword == addr._address.dword; }; 56 | bool operator==(const uint8_t* addr) const; 57 | 58 | // Overloaded index operator to allow getting and setting individual octets of the address 59 | uint8_t operator[](int index) const { return _address.bytes[index]; }; 60 | uint8_t& operator[](int index) { return _address.bytes[index]; }; 61 | 62 | // Overloaded copy operators to allow initialisation of IPAddress objects from other types 63 | IPAddress& operator=(const uint8_t *address); 64 | IPAddress& operator=(uint32_t address); 65 | 66 | virtual size_t printTo(Print& p) const; 67 | 68 | friend class EthernetClass; 69 | friend class UDP; 70 | friend class Client; 71 | friend class Server; 72 | friend class DhcpClass; 73 | friend class DNSClient; 74 | }; 75 | 76 | const IPAddress INADDR_NONE(0,0,0,0); 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /cores/arduino/PluggableUSB.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | PluggableUSB.cpp 3 | Copyright (c) 2015 Arduino LLC 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #include "USBAPI.h" 21 | #include "PluggableUSB.h" 22 | 23 | #if defined(USBCON) 24 | #ifdef PLUGGABLE_USB_ENABLED 25 | 26 | extern uint8_t _initEndpoints[]; 27 | 28 | int PluggableUSB_::getInterface(uint8_t* interfaceCount) 29 | { 30 | int sent = 0; 31 | PluggableUSBModule* node; 32 | for (node = rootNode; node; node = node->next) { 33 | int res = node->getInterface(interfaceCount); 34 | if (res < 0) 35 | return -1; 36 | sent += res; 37 | } 38 | return sent; 39 | } 40 | 41 | int PluggableUSB_::getDescriptor(USBSetup& setup) 42 | { 43 | PluggableUSBModule* node; 44 | for (node = rootNode; node; node = node->next) { 45 | int ret = node->getDescriptor(setup); 46 | // ret!=0 -> request has been processed 47 | if (ret) 48 | return ret; 49 | } 50 | return 0; 51 | } 52 | 53 | void PluggableUSB_::getShortName(char *iSerialNum) 54 | { 55 | PluggableUSBModule* node; 56 | for (node = rootNode; node; node = node->next) { 57 | iSerialNum += node->getShortName(iSerialNum); 58 | } 59 | *iSerialNum = 0; 60 | } 61 | 62 | bool PluggableUSB_::setup(USBSetup& setup) 63 | { 64 | PluggableUSBModule* node; 65 | for (node = rootNode; node; node = node->next) { 66 | if (node->setup(setup)) { 67 | return true; 68 | } 69 | } 70 | return false; 71 | } 72 | 73 | bool PluggableUSB_::plug(PluggableUSBModule *node) 74 | { 75 | if ((lastEp + node->numEndpoints) > USB_ENDPOINTS) { 76 | return false; 77 | } 78 | 79 | if (!rootNode) { 80 | rootNode = node; 81 | } else { 82 | PluggableUSBModule *current = rootNode; 83 | while (current->next) { 84 | current = current->next; 85 | } 86 | current->next = node; 87 | } 88 | 89 | node->pluggedInterface = lastIf; 90 | node->pluggedEndpoint = lastEp; 91 | lastIf += node->numInterfaces; 92 | for (uint8_t i = 0; i < node->numEndpoints; i++) { 93 | _initEndpoints[lastEp] = node->endpointType[i]; 94 | lastEp++; 95 | } 96 | return true; 97 | // restart USB layer??? 98 | } 99 | 100 | PluggableUSB_& PluggableUSB() 101 | { 102 | static PluggableUSB_ obj; 103 | return obj; 104 | } 105 | 106 | PluggableUSB_::PluggableUSB_() : lastIf(CDC_ACM_INTERFACE + CDC_INTERFACE_COUNT), 107 | lastEp(CDC_FIRST_ENDPOINT + CDC_ENPOINT_COUNT), 108 | rootNode(NULL) 109 | { 110 | // Empty 111 | } 112 | 113 | #endif 114 | 115 | #endif /* if defined(USBCON) */ 116 | -------------------------------------------------------------------------------- /cores/arduino/PluggableUSB.h: -------------------------------------------------------------------------------- 1 | /* 2 | PluggableUSB.h 3 | Copyright (c) 2015 Arduino LLC 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef PUSB_h 21 | #define PUSB_h 22 | 23 | #include "USBAPI.h" 24 | #include 25 | 26 | #if defined(USBCON) 27 | 28 | class PluggableUSBModule { 29 | public: 30 | PluggableUSBModule(uint8_t numEps, uint8_t numIfs, uint8_t *epType) : 31 | numEndpoints(numEps), numInterfaces(numIfs), endpointType(epType) 32 | { } 33 | 34 | protected: 35 | virtual bool setup(USBSetup& setup) = 0; 36 | virtual int getInterface(uint8_t* interfaceCount) = 0; 37 | virtual int getDescriptor(USBSetup& setup) = 0; 38 | virtual uint8_t getShortName(char *name) { name[0] = 'A'+pluggedInterface; return 1; } 39 | 40 | uint8_t pluggedInterface; 41 | uint8_t pluggedEndpoint; 42 | 43 | const uint8_t numEndpoints; 44 | const uint8_t numInterfaces; 45 | const uint8_t *endpointType; 46 | 47 | PluggableUSBModule *next = NULL; 48 | 49 | friend class PluggableUSB_; 50 | }; 51 | 52 | class PluggableUSB_ { 53 | public: 54 | PluggableUSB_(); 55 | bool plug(PluggableUSBModule *node); 56 | int getInterface(uint8_t* interfaceCount); 57 | int getDescriptor(USBSetup& setup); 58 | bool setup(USBSetup& setup); 59 | void getShortName(char *iSerialNum); 60 | 61 | private: 62 | uint8_t lastIf; 63 | uint8_t lastEp; 64 | PluggableUSBModule* rootNode; 65 | }; 66 | 67 | // Replacement for global singleton. 68 | // This function prevents static-initialization-order-fiasco 69 | // https://isocpp.org/wiki/faq/ctors#static-init-order-on-first-use 70 | PluggableUSB_& PluggableUSB(); 71 | 72 | #endif 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /cores/arduino/Print.h: -------------------------------------------------------------------------------- 1 | /* 2 | Print.h - Base class that provides print() and println() 3 | Copyright (c) 2008 David A. Mellis. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef Print_h 21 | #define Print_h 22 | 23 | #include 24 | #include // for size_t 25 | 26 | #include "WString.h" 27 | #include "Printable.h" 28 | 29 | #define DEC 10 30 | #define HEX 16 31 | #define OCT 8 32 | #ifdef BIN // Prevent warnings if BIN is previously defined in "iotnx4.h" or similar 33 | #undef BIN 34 | #endif 35 | #define BIN 2 36 | 37 | class Print 38 | { 39 | private: 40 | int write_error; 41 | size_t printNumber(unsigned long, uint8_t); 42 | size_t printFloat(double, uint8_t); 43 | protected: 44 | void setWriteError(int err = 1) { write_error = err; } 45 | public: 46 | Print() : write_error(0) {} 47 | 48 | int getWriteError() { return write_error; } 49 | void clearWriteError() { setWriteError(0); } 50 | 51 | virtual size_t write(uint8_t) = 0; 52 | size_t write(const char *str) { 53 | if (str == NULL) return 0; 54 | return write((const uint8_t *)str, strlen(str)); 55 | } 56 | virtual size_t write(const uint8_t *buffer, size_t size); 57 | size_t write(const char *buffer, size_t size) { 58 | return write((const uint8_t *)buffer, size); 59 | } 60 | 61 | // default to zero, meaning "a single write may block" 62 | // should be overridden by subclasses with buffering 63 | virtual int availableForWrite() { return 0; } 64 | 65 | size_t print(const __FlashStringHelper *); 66 | size_t print(const String &); 67 | size_t print(const char[]); 68 | size_t print(char); 69 | size_t print(unsigned char, int = DEC); 70 | size_t print(int, int = DEC); 71 | size_t print(unsigned int, int = DEC); 72 | size_t print(long, int = DEC); 73 | size_t print(unsigned long, int = DEC); 74 | size_t print(double, int = 2); 75 | size_t print(const Printable&); 76 | 77 | size_t println(const __FlashStringHelper *); 78 | size_t println(const String &s); 79 | size_t println(const char[]); 80 | size_t println(char); 81 | size_t println(unsigned char, int = DEC); 82 | size_t println(int, int = DEC); 83 | size_t println(unsigned int, int = DEC); 84 | size_t println(long, int = DEC); 85 | size_t println(unsigned long, int = DEC); 86 | size_t println(double, int = 2); 87 | size_t println(const Printable&); 88 | size_t println(void); 89 | 90 | virtual void flush() { /* Empty implementation for backward compatibility */ } 91 | }; 92 | 93 | #endif 94 | -------------------------------------------------------------------------------- /cores/arduino/Printable.h: -------------------------------------------------------------------------------- 1 | /* 2 | Printable.h - Interface class that allows printing of complex types 3 | Copyright (c) 2011 Adrian McEwen. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef Printable_h 21 | #define Printable_h 22 | 23 | #include 24 | 25 | class Print; 26 | 27 | /** The Printable class provides a way for new classes to allow themselves to be printed. 28 | By deriving from Printable and implementing the printTo method, it will then be possible 29 | for users to print out instances of this class by passing them into the usual 30 | Print::print and Print::println methods. 31 | */ 32 | 33 | class Printable 34 | { 35 | public: 36 | virtual size_t printTo(Print& p) const = 0; 37 | }; 38 | 39 | #endif 40 | 41 | -------------------------------------------------------------------------------- /cores/arduino/Server.h: -------------------------------------------------------------------------------- 1 | /* 2 | Server.h - Base class that provides Server 3 | Copyright (c) 2011 Adrian McEwen. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef server_h 21 | #define server_h 22 | 23 | #include "Print.h" 24 | 25 | class Server : public Print { 26 | public: 27 | virtual void begin() =0; 28 | }; 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /cores/arduino/USBDesc.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011, Peter Barrett 3 | Copyright (c) 2015, Arduino LLC 4 | 5 | Permission to use, copy, modify, and/or distribute this software for 6 | any purpose with or without fee is hereby granted, provided that the 7 | above copyright notice and this permission notice appear in all copies. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 10 | WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 11 | WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR 12 | BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES 13 | OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 14 | WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 15 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 16 | SOFTWARE. 17 | */ 18 | 19 | // #define PLUGGABLE_USB_ENABLED // Not compatible with XInput 20 | 21 | #if defined(EPRST6) 22 | #define USB_ENDPOINTS 7 // AtMegaxxU4 23 | #else 24 | #define USB_ENDPOINTS 5 // AtMegaxxU2 25 | #endif 26 | 27 | #define IMANUFACTURER 1 28 | #define IPRODUCT 2 29 | #define ISERIAL 3 -------------------------------------------------------------------------------- /cores/arduino/Udp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Udp.cpp: Library to send/receive UDP packets. 3 | * 4 | * NOTE: UDP is fast, but has some important limitations (thanks to Warren Gray for mentioning these) 5 | * 1) UDP does not guarantee the order in which assembled UDP packets are received. This 6 | * might not happen often in practice, but in larger network topologies, a UDP 7 | * packet can be received out of sequence. 8 | * 2) UDP does not guard against lost packets - so packets *can* disappear without the sender being 9 | * aware of it. Again, this may not be a concern in practice on small local networks. 10 | * For more information, see http://www.cafeaulait.org/course/week12/35.html 11 | * 12 | * MIT License: 13 | * Copyright (c) 2008 Bjoern Hartmann 14 | * Permission is hereby granted, free of charge, to any person obtaining a copy 15 | * of this software and associated documentation files (the "Software"), to deal 16 | * in the Software without restriction, including without limitation the rights 17 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 18 | * copies of the Software, and to permit persons to whom the Software is 19 | * furnished to do so, subject to the following conditions: 20 | * 21 | * The above copyright notice and this permission notice shall be included in 22 | * all copies or substantial portions of the Software. 23 | * 24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 27 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 28 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 29 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 30 | * THE SOFTWARE. 31 | * 32 | * bjoern@cs.stanford.edu 12/30/2008 33 | */ 34 | 35 | #ifndef udp_h 36 | #define udp_h 37 | 38 | #include 39 | #include 40 | 41 | class UDP : public Stream { 42 | 43 | public: 44 | virtual uint8_t begin(uint16_t) =0; // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use 45 | virtual uint8_t beginMulticast(IPAddress, uint16_t) { return 0; } // initialize, start listening on specified multicast IP address and port. Returns 1 if successful, 0 on failure 46 | virtual void stop() =0; // Finish with the UDP socket 47 | 48 | // Sending UDP packets 49 | 50 | // Start building up a packet to send to the remote host specific in ip and port 51 | // Returns 1 if successful, 0 if there was a problem with the supplied IP address or port 52 | virtual int beginPacket(IPAddress ip, uint16_t port) =0; 53 | // Start building up a packet to send to the remote host specific in host and port 54 | // Returns 1 if successful, 0 if there was a problem resolving the hostname or port 55 | virtual int beginPacket(const char *host, uint16_t port) =0; 56 | // Finish off this packet and send it 57 | // Returns 1 if the packet was sent successfully, 0 if there was an error 58 | virtual int endPacket() =0; 59 | // Write a single byte into the packet 60 | virtual size_t write(uint8_t) =0; 61 | // Write size bytes from buffer into the packet 62 | virtual size_t write(const uint8_t *buffer, size_t size) =0; 63 | 64 | // Start processing the next available incoming packet 65 | // Returns the size of the packet in bytes, or 0 if no packets are available 66 | virtual int parsePacket() =0; 67 | // Number of bytes remaining in the current packet 68 | virtual int available() =0; 69 | // Read a single byte from the current packet 70 | virtual int read() =0; 71 | // Read up to len bytes from the current packet and place them into buffer 72 | // Returns the number of bytes read, or 0 if none are available 73 | virtual int read(unsigned char* buffer, size_t len) =0; 74 | // Read up to len characters from the current packet and place them into buffer 75 | // Returns the number of characters read, or 0 if none are available 76 | virtual int read(char* buffer, size_t len) =0; 77 | // Return the next byte from the current packet without moving on to the next byte 78 | virtual int peek() =0; 79 | virtual void flush() =0; // Finish reading the current packet 80 | 81 | // Return the IP address of the host who sent the current incoming packet 82 | virtual IPAddress remoteIP() =0; 83 | // Return the port of the host who sent the current incoming packet 84 | virtual uint16_t remotePort() =0; 85 | protected: 86 | uint8_t* rawIPAddress(IPAddress& addr) { return addr.raw_address(); }; 87 | }; 88 | 89 | #endif 90 | -------------------------------------------------------------------------------- /cores/arduino/WCharacter.h: -------------------------------------------------------------------------------- 1 | /* 2 | WCharacter.h - Character utility functions for Wiring & Arduino 3 | Copyright (c) 2010 Hernando Barragan. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef Character_h 21 | #define Character_h 22 | 23 | #include 24 | 25 | // WCharacter.h prototypes 26 | inline boolean isAlphaNumeric(int c) __attribute__((always_inline)); 27 | inline boolean isAlpha(int c) __attribute__((always_inline)); 28 | inline boolean isAscii(int c) __attribute__((always_inline)); 29 | inline boolean isWhitespace(int c) __attribute__((always_inline)); 30 | inline boolean isControl(int c) __attribute__((always_inline)); 31 | inline boolean isDigit(int c) __attribute__((always_inline)); 32 | inline boolean isGraph(int c) __attribute__((always_inline)); 33 | inline boolean isLowerCase(int c) __attribute__((always_inline)); 34 | inline boolean isPrintable(int c) __attribute__((always_inline)); 35 | inline boolean isPunct(int c) __attribute__((always_inline)); 36 | inline boolean isSpace(int c) __attribute__((always_inline)); 37 | inline boolean isUpperCase(int c) __attribute__((always_inline)); 38 | inline boolean isHexadecimalDigit(int c) __attribute__((always_inline)); 39 | inline int toAscii(int c) __attribute__((always_inline)); 40 | inline int toLowerCase(int c) __attribute__((always_inline)); 41 | inline int toUpperCase(int c)__attribute__((always_inline)); 42 | 43 | 44 | // Checks for an alphanumeric character. 45 | // It is equivalent to (isalpha(c) || isdigit(c)). 46 | inline boolean isAlphaNumeric(int c) 47 | { 48 | return ( isalnum(c) == 0 ? false : true); 49 | } 50 | 51 | 52 | // Checks for an alphabetic character. 53 | // It is equivalent to (isupper(c) || islower(c)). 54 | inline boolean isAlpha(int c) 55 | { 56 | return ( isalpha(c) == 0 ? false : true); 57 | } 58 | 59 | 60 | // Checks whether c is a 7-bit unsigned char value 61 | // that fits into the ASCII character set. 62 | inline boolean isAscii(int c) 63 | { 64 | return ( isascii (c) == 0 ? false : true); 65 | } 66 | 67 | 68 | // Checks for a blank character, that is, a space or a tab. 69 | inline boolean isWhitespace(int c) 70 | { 71 | return ( isblank (c) == 0 ? false : true); 72 | } 73 | 74 | 75 | // Checks for a control character. 76 | inline boolean isControl(int c) 77 | { 78 | return ( iscntrl (c) == 0 ? false : true); 79 | } 80 | 81 | 82 | // Checks for a digit (0 through 9). 83 | inline boolean isDigit(int c) 84 | { 85 | return ( isdigit (c) == 0 ? false : true); 86 | } 87 | 88 | 89 | // Checks for any printable character except space. 90 | inline boolean isGraph(int c) 91 | { 92 | return ( isgraph (c) == 0 ? false : true); 93 | } 94 | 95 | 96 | // Checks for a lower-case character. 97 | inline boolean isLowerCase(int c) 98 | { 99 | return (islower (c) == 0 ? false : true); 100 | } 101 | 102 | 103 | // Checks for any printable character including space. 104 | inline boolean isPrintable(int c) 105 | { 106 | return ( isprint (c) == 0 ? false : true); 107 | } 108 | 109 | 110 | // Checks for any printable character which is not a space 111 | // or an alphanumeric character. 112 | inline boolean isPunct(int c) 113 | { 114 | return ( ispunct (c) == 0 ? false : true); 115 | } 116 | 117 | 118 | // Checks for white-space characters. For the avr-libc library, 119 | // these are: space, formfeed ('\f'), newline ('\n'), carriage 120 | // return ('\r'), horizontal tab ('\t'), and vertical tab ('\v'). 121 | inline boolean isSpace(int c) 122 | { 123 | return ( isspace (c) == 0 ? false : true); 124 | } 125 | 126 | 127 | // Checks for an uppercase letter. 128 | inline boolean isUpperCase(int c) 129 | { 130 | return ( isupper (c) == 0 ? false : true); 131 | } 132 | 133 | 134 | // Checks for a hexadecimal digits, i.e. one of 0 1 2 3 4 5 6 7 135 | // 8 9 a b c d e f A B C D E F. 136 | inline boolean isHexadecimalDigit(int c) 137 | { 138 | return ( isxdigit (c) == 0 ? false : true); 139 | } 140 | 141 | 142 | // Converts c to a 7-bit unsigned char value that fits into the 143 | // ASCII character set, by clearing the high-order bits. 144 | inline int toAscii(int c) 145 | { 146 | return toascii (c); 147 | } 148 | 149 | 150 | // Warning: 151 | // Many people will be unhappy if you use this function. 152 | // This function will convert accented letters into random 153 | // characters. 154 | 155 | // Converts the letter c to lower case, if possible. 156 | inline int toLowerCase(int c) 157 | { 158 | return tolower (c); 159 | } 160 | 161 | 162 | // Converts the letter c to upper case, if possible. 163 | inline int toUpperCase(int c) 164 | { 165 | return toupper (c); 166 | } 167 | 168 | #endif -------------------------------------------------------------------------------- /cores/arduino/WMath.cpp: -------------------------------------------------------------------------------- 1 | /* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ 2 | 3 | /* 4 | Part of the Wiring project - http://wiring.org.co 5 | Copyright (c) 2004-06 Hernando Barragan 6 | Modified 13 August 2006, David A. Mellis for Arduino - http://www.arduino.cc/ 7 | 8 | This library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU Lesser General Public 10 | License as published by the Free Software Foundation; either 11 | version 2.1 of the License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General 19 | Public License along with this library; if not, write to the 20 | Free Software Foundation, Inc., 59 Temple Place, Suite 330, 21 | Boston, MA 02111-1307 USA 22 | */ 23 | 24 | extern "C" { 25 | #include "stdlib.h" 26 | } 27 | 28 | void randomSeed(unsigned long seed) 29 | { 30 | if (seed != 0) { 31 | srandom(seed); 32 | } 33 | } 34 | 35 | long random(long howbig) 36 | { 37 | if (howbig == 0) { 38 | return 0; 39 | } 40 | return random() % howbig; 41 | } 42 | 43 | long random(long howsmall, long howbig) 44 | { 45 | if (howsmall >= howbig) { 46 | return howsmall; 47 | } 48 | long diff = howbig - howsmall; 49 | return random(diff) + howsmall; 50 | } 51 | 52 | long map(long x, long in_min, long in_max, long out_min, long out_max) 53 | { 54 | return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; 55 | } 56 | 57 | unsigned int makeWord(unsigned int w) { return w; } 58 | unsigned int makeWord(unsigned char h, unsigned char l) { return (h << 8) | l; } 59 | -------------------------------------------------------------------------------- /cores/arduino/abi.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014 Arduino. All right reserved. 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | See the GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | #include 20 | 21 | extern "C" void __cxa_pure_virtual(void) __attribute__ ((__noreturn__)); 22 | extern "C" void __cxa_deleted_virtual(void) __attribute__ ((__noreturn__)); 23 | 24 | namespace std { 25 | [[gnu::weak, noreturn]] void terminate() { 26 | abort(); 27 | } 28 | } 29 | 30 | void __cxa_pure_virtual(void) { 31 | std::terminate(); 32 | } 33 | 34 | void __cxa_deleted_virtual(void) { 35 | std::terminate(); 36 | } 37 | -------------------------------------------------------------------------------- /cores/arduino/hooks.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012 Arduino. All right reserved. 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | See the GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | /** 20 | * Empty yield() hook. 21 | * 22 | * This function is intended to be used by library writers to build 23 | * libraries or sketches that supports cooperative threads. 24 | * 25 | * Its defined as a weak symbol and it can be redefined to implement a 26 | * real cooperative scheduler. 27 | */ 28 | static void __empty() { 29 | // Empty 30 | } 31 | void yield(void) __attribute__ ((weak, alias("__empty"))); 32 | -------------------------------------------------------------------------------- /cores/arduino/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | main.cpp - Main loop for Arduino sketches 3 | Copyright (c) 2005-2013 Arduino Team. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #include 21 | 22 | // Declared weak in Arduino.h to allow user redefinitions. 23 | int atexit(void (* /*func*/ )()) { return 0; } 24 | 25 | // Weak empty variant initialization function. 26 | // May be redefined by variant files. 27 | void initVariant() __attribute__((weak)); 28 | void initVariant() { } 29 | 30 | void setupUSB() __attribute__((weak)); 31 | void setupUSB() { } 32 | 33 | int main(void) 34 | { 35 | init(); 36 | 37 | initVariant(); 38 | 39 | #if defined(USBCON) 40 | USBDevice.attach(); 41 | #endif 42 | 43 | setup(); 44 | 45 | for (;;) { 46 | loop(); 47 | if (serialEventRun) serialEventRun(); 48 | } 49 | 50 | return 0; 51 | } 52 | 53 | -------------------------------------------------------------------------------- /cores/arduino/new: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014 Arduino. All right reserved. 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | See the GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | #ifndef NEW_H 20 | #define NEW_H 21 | 22 | #include 23 | 24 | namespace std { 25 | struct nothrow_t {}; 26 | extern const nothrow_t nothrow; 27 | 28 | // These are not actually implemented, to prevent overhead and 29 | // complexity. They are still declared to allow implementing 30 | // them in user code if needed. 31 | typedef void (*new_handler)(); 32 | new_handler set_new_handler(new_handler new_p) noexcept; 33 | new_handler get_new_handler() noexcept; 34 | 35 | // This is normally declared in various headers that we do not have 36 | // available, so just define it here. We could also use ::size_t 37 | // below, but then anyone including can no longer assume 38 | // std::size_t is available. 39 | using size_t = ::size_t; 40 | } // namespace std 41 | 42 | [[gnu::weak]] void * operator new(std::size_t size); 43 | [[gnu::weak]] void * operator new[](std::size_t size); 44 | 45 | [[gnu::weak]] void * operator new(std::size_t size, const std::nothrow_t tag) noexcept; 46 | [[gnu::weak]] void * operator new[](std::size_t size, const std::nothrow_t& tag) noexcept; 47 | 48 | void * operator new(std::size_t size, void *place) noexcept; 49 | void * operator new[](std::size_t size, void *place) noexcept; 50 | 51 | [[gnu::weak]] void operator delete(void * ptr) noexcept; 52 | [[gnu::weak]] void operator delete[](void * ptr) noexcept; 53 | 54 | #if __cplusplus >= 201402L 55 | [[gnu::weak]] void operator delete(void* ptr, std::size_t size) noexcept; 56 | [[gnu::weak]] void operator delete[](void * ptr, std::size_t size) noexcept; 57 | #endif // __cplusplus >= 201402L 58 | 59 | [[gnu::weak]] void operator delete(void* ptr, const std::nothrow_t& tag) noexcept; 60 | [[gnu::weak]] void operator delete[](void* ptr, const std::nothrow_t& tag) noexcept; 61 | 62 | void operator delete(void* ptr, void* place) noexcept; 63 | void operator delete[](void* ptr, void* place) noexcept; 64 | 65 | #endif 66 | 67 | -------------------------------------------------------------------------------- /cores/arduino/new.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014 Arduino. All right reserved. 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | See the GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | #include "new.h" 20 | 21 | // The C++ spec dictates that allocation failure should cause the 22 | // (non-nothrow version of the) operator new to throw an exception. 23 | // Since we expect to have exceptions disabled, it would be more 24 | // appropriate (and probably standards-compliant) to terminate instead. 25 | // Historically failure causes null to be returned, but this define 26 | // allows switching to more robust terminating behaviour (that might 27 | // become the default at some point in the future). Note that any code 28 | // that wants null to be returned can (and should) use the nothrow 29 | // versions of the new statement anyway and is unaffected by this. 30 | // #define NEW_TERMINATES_ON_FAILURE 31 | 32 | namespace std { 33 | // Defined in abi.cpp 34 | void terminate(); 35 | 36 | const nothrow_t nothrow; 37 | } 38 | 39 | static void * new_helper(std::size_t size) { 40 | // Even zero-sized allocations should return a unique pointer, but 41 | // malloc does not guarantee this 42 | if (size == 0) 43 | size = 1; 44 | return malloc(size); 45 | } 46 | 47 | void * operator new(std::size_t size) { 48 | void *res = new_helper(size); 49 | #if defined(NEW_TERMINATES_ON_FAILURE) 50 | if (!res) 51 | std::terminate(); 52 | #endif 53 | return res; 54 | } 55 | void * operator new[](std::size_t size) { 56 | return operator new(size); 57 | } 58 | 59 | void * operator new(std::size_t size, const std::nothrow_t tag) noexcept { 60 | #if defined(NEW_TERMINATES_ON_FAILURE) 61 | // Cannot call throwing operator new as standard suggests, so call 62 | // new_helper directly then 63 | return new_helper(size); 64 | #else 65 | return operator new(size); 66 | #endif 67 | } 68 | void * operator new[](std::size_t size, const std::nothrow_t& tag) noexcept { 69 | #if defined(NEW_TERMINATES_ON_FAILURE) 70 | // Cannot call throwing operator new[] as standard suggests, so call 71 | // malloc directly then 72 | return new_helper(size); 73 | #else 74 | return operator new[](size); 75 | #endif 76 | } 77 | 78 | void * operator new(std::size_t size, void *place) noexcept { 79 | // Nothing to do 80 | (void)size; // unused 81 | return place; 82 | } 83 | void * operator new[](std::size_t size, void *place) noexcept { 84 | return operator new(size, place); 85 | } 86 | 87 | void operator delete(void * ptr) noexcept { 88 | free(ptr); 89 | } 90 | void operator delete[](void * ptr) noexcept { 91 | operator delete(ptr); 92 | } 93 | 94 | #if __cplusplus >= 201402L 95 | void operator delete(void* ptr, std::size_t size) noexcept { 96 | operator delete(ptr); 97 | } 98 | void operator delete[](void * ptr, std::size_t size) noexcept { 99 | operator delete[](ptr); 100 | } 101 | #endif // __cplusplus >= 201402L 102 | 103 | void operator delete(void* ptr, const std::nothrow_t& tag) noexcept { 104 | operator delete(ptr); 105 | } 106 | void operator delete[](void* ptr, const std::nothrow_t& tag) noexcept { 107 | operator delete[](ptr); 108 | } 109 | 110 | void operator delete(void* ptr, void* place) noexcept { 111 | (void)ptr; (void)place; // unused 112 | // Nothing to do 113 | } 114 | void operator delete[](void* ptr, void* place) noexcept { 115 | (void)ptr; (void)place; // unused 116 | // Nothing to do 117 | } 118 | -------------------------------------------------------------------------------- /cores/arduino/new.h: -------------------------------------------------------------------------------- 1 | // This file originally used a non-standard name for this Arduino core 2 | // only, so still expose the old new.h name for compatibility. 3 | #include "new" 4 | -------------------------------------------------------------------------------- /cores/arduino/wiring_digital.c: -------------------------------------------------------------------------------- 1 | /* 2 | wiring_digital.c - digital input and output functions 3 | Part of Arduino - http://www.arduino.cc/ 4 | 5 | Copyright (c) 2005-2006 David A. Mellis 6 | 7 | This library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public 9 | License as published by the Free Software Foundation; either 10 | version 2.1 of the License, or (at your option) any later version. 11 | 12 | This library is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General 18 | Public License along with this library; if not, write to the 19 | Free Software Foundation, Inc., 59 Temple Place, Suite 330, 20 | Boston, MA 02111-1307 USA 21 | 22 | Modified 28 September 2010 by Mark Sproul 23 | */ 24 | 25 | #define ARDUINO_MAIN 26 | #include "wiring_private.h" 27 | #include "pins_arduino.h" 28 | 29 | void pinMode(uint8_t pin, uint8_t mode) 30 | { 31 | uint8_t bit = digitalPinToBitMask(pin); 32 | uint8_t port = digitalPinToPort(pin); 33 | volatile uint8_t *reg, *out; 34 | 35 | if (port == NOT_A_PIN) return; 36 | 37 | // JWS: can I let the optimizer do this? 38 | reg = portModeRegister(port); 39 | out = portOutputRegister(port); 40 | 41 | if (mode == INPUT) { 42 | uint8_t oldSREG = SREG; 43 | cli(); 44 | *reg &= ~bit; 45 | *out &= ~bit; 46 | SREG = oldSREG; 47 | } else if (mode == INPUT_PULLUP) { 48 | uint8_t oldSREG = SREG; 49 | cli(); 50 | *reg &= ~bit; 51 | *out |= bit; 52 | SREG = oldSREG; 53 | } else { 54 | uint8_t oldSREG = SREG; 55 | cli(); 56 | *reg |= bit; 57 | SREG = oldSREG; 58 | } 59 | } 60 | 61 | // Forcing this inline keeps the callers from having to push their own stuff 62 | // on the stack. It is a good performance win and only takes 1 more byte per 63 | // user than calling. (It will take more bytes on the 168.) 64 | // 65 | // But shouldn't this be moved into pinMode? Seems silly to check and do on 66 | // each digitalread or write. 67 | // 68 | // Mark Sproul: 69 | // - Removed inline. Save 170 bytes on atmega1280 70 | // - changed to a switch statement; added 32 bytes but much easier to read and maintain. 71 | // - Added more #ifdefs, now compiles for atmega645 72 | // 73 | //static inline void turnOffPWM(uint8_t timer) __attribute__ ((always_inline)); 74 | //static inline void turnOffPWM(uint8_t timer) 75 | static void turnOffPWM(uint8_t timer) 76 | { 77 | switch (timer) 78 | { 79 | #if defined(TCCR1A) && defined(COM1A1) 80 | case TIMER1A: cbi(TCCR1A, COM1A1); break; 81 | #endif 82 | #if defined(TCCR1A) && defined(COM1B1) 83 | case TIMER1B: cbi(TCCR1A, COM1B1); break; 84 | #endif 85 | #if defined(TCCR1A) && defined(COM1C1) 86 | case TIMER1C: cbi(TCCR1A, COM1C1); break; 87 | #endif 88 | 89 | #if defined(TCCR2) && defined(COM21) 90 | case TIMER2: cbi(TCCR2, COM21); break; 91 | #endif 92 | 93 | #if defined(TCCR0A) && defined(COM0A1) 94 | case TIMER0A: cbi(TCCR0A, COM0A1); break; 95 | #endif 96 | 97 | #if defined(TCCR0A) && defined(COM0B1) 98 | case TIMER0B: cbi(TCCR0A, COM0B1); break; 99 | #endif 100 | #if defined(TCCR2A) && defined(COM2A1) 101 | case TIMER2A: cbi(TCCR2A, COM2A1); break; 102 | #endif 103 | #if defined(TCCR2A) && defined(COM2B1) 104 | case TIMER2B: cbi(TCCR2A, COM2B1); break; 105 | #endif 106 | 107 | #if defined(TCCR3A) && defined(COM3A1) 108 | case TIMER3A: cbi(TCCR3A, COM3A1); break; 109 | #endif 110 | #if defined(TCCR3A) && defined(COM3B1) 111 | case TIMER3B: cbi(TCCR3A, COM3B1); break; 112 | #endif 113 | #if defined(TCCR3A) && defined(COM3C1) 114 | case TIMER3C: cbi(TCCR3A, COM3C1); break; 115 | #endif 116 | 117 | #if defined(TCCR4A) && defined(COM4A1) 118 | case TIMER4A: cbi(TCCR4A, COM4A1); break; 119 | #endif 120 | #if defined(TCCR4A) && defined(COM4B1) 121 | case TIMER4B: cbi(TCCR4A, COM4B1); break; 122 | #endif 123 | #if defined(TCCR4A) && defined(COM4C1) 124 | case TIMER4C: cbi(TCCR4A, COM4C1); break; 125 | #endif 126 | #if defined(TCCR4C) && defined(COM4D1) 127 | case TIMER4D: cbi(TCCR4C, COM4D1); break; 128 | #endif 129 | 130 | #if defined(TCCR5A) 131 | case TIMER5A: cbi(TCCR5A, COM5A1); break; 132 | case TIMER5B: cbi(TCCR5A, COM5B1); break; 133 | case TIMER5C: cbi(TCCR5A, COM5C1); break; 134 | #endif 135 | } 136 | } 137 | 138 | void digitalWrite(uint8_t pin, uint8_t val) 139 | { 140 | uint8_t timer = digitalPinToTimer(pin); 141 | uint8_t bit = digitalPinToBitMask(pin); 142 | uint8_t port = digitalPinToPort(pin); 143 | volatile uint8_t *out; 144 | 145 | if (port == NOT_A_PIN) return; 146 | 147 | // If the pin that support PWM output, we need to turn it off 148 | // before doing a digital write. 149 | if (timer != NOT_ON_TIMER) turnOffPWM(timer); 150 | 151 | out = portOutputRegister(port); 152 | 153 | uint8_t oldSREG = SREG; 154 | cli(); 155 | 156 | if (val == LOW) { 157 | *out &= ~bit; 158 | } else { 159 | *out |= bit; 160 | } 161 | 162 | SREG = oldSREG; 163 | } 164 | 165 | int digitalRead(uint8_t pin) 166 | { 167 | uint8_t timer = digitalPinToTimer(pin); 168 | uint8_t bit = digitalPinToBitMask(pin); 169 | uint8_t port = digitalPinToPort(pin); 170 | 171 | if (port == NOT_A_PIN) return LOW; 172 | 173 | // If the pin that support PWM output, we need to turn it off 174 | // before getting a digital reading. 175 | if (timer != NOT_ON_TIMER) turnOffPWM(timer); 176 | 177 | if (*portInputRegister(port) & bit) return HIGH; 178 | return LOW; 179 | } 180 | -------------------------------------------------------------------------------- /cores/arduino/wiring_private.h: -------------------------------------------------------------------------------- 1 | /* 2 | wiring_private.h - Internal header file. 3 | Part of Arduino - http://www.arduino.cc/ 4 | 5 | Copyright (c) 2005-2006 David A. Mellis 6 | 7 | This library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public 9 | License as published by the Free Software Foundation; either 10 | version 2.1 of the License, or (at your option) any later version. 11 | 12 | This library is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General 18 | Public License along with this library; if not, write to the 19 | Free Software Foundation, Inc., 59 Temple Place, Suite 330, 20 | Boston, MA 02111-1307 USA 21 | */ 22 | 23 | #ifndef WiringPrivate_h 24 | #define WiringPrivate_h 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #include "Arduino.h" 32 | 33 | #ifdef __cplusplus 34 | extern "C"{ 35 | #endif 36 | 37 | #ifndef cbi 38 | #define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit)) 39 | #endif 40 | #ifndef sbi 41 | #define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit)) 42 | #endif 43 | 44 | uint32_t countPulseASM(volatile uint8_t *port, uint8_t bit, uint8_t stateMask, unsigned long maxloops); 45 | 46 | #define EXTERNAL_INT_0 0 47 | #define EXTERNAL_INT_1 1 48 | #define EXTERNAL_INT_2 2 49 | #define EXTERNAL_INT_3 3 50 | #define EXTERNAL_INT_4 4 51 | #define EXTERNAL_INT_5 5 52 | #define EXTERNAL_INT_6 6 53 | #define EXTERNAL_INT_7 7 54 | 55 | #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega128RFA1__) || defined(__AVR_ATmega256RFR2__) || \ 56 | defined(__AVR_AT90USB82__) || defined(__AVR_AT90USB162__) || defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega8U2__) 57 | #define EXTERNAL_NUM_INTERRUPTS 8 58 | #elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega644__) || defined(__AVR_ATmega644A__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) 59 | #define EXTERNAL_NUM_INTERRUPTS 3 60 | #elif defined(__AVR_ATmega32U4__) 61 | #define EXTERNAL_NUM_INTERRUPTS 5 62 | #else 63 | #define EXTERNAL_NUM_INTERRUPTS 2 64 | #endif 65 | 66 | typedef void (*voidFuncPtr)(void); 67 | 68 | #ifdef __cplusplus 69 | } // extern "C" 70 | #endif 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /cores/arduino/wiring_pulse.c: -------------------------------------------------------------------------------- 1 | /* 2 | wiring_pulse.c - pulseIn() function 3 | Part of Arduino - http://www.arduino.cc/ 4 | 5 | Copyright (c) 2005-2006 David A. Mellis 6 | 7 | This library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public 9 | License as published by the Free Software Foundation; either 10 | version 2.1 of the License, or (at your option) any later version. 11 | 12 | This library is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General 18 | Public License along with this library; if not, write to the 19 | Free Software Foundation, Inc., 59 Temple Place, Suite 330, 20 | Boston, MA 02111-1307 USA 21 | */ 22 | 23 | #include "wiring_private.h" 24 | #include "pins_arduino.h" 25 | 26 | /* Measures the length (in microseconds) of a pulse on the pin; state is HIGH 27 | * or LOW, the type of pulse to measure. Works on pulses from 2-3 microseconds 28 | * to 3 minutes in length, but must be called at least a few dozen microseconds 29 | * before the start of the pulse. 30 | * 31 | * This function performs better with short pulses in noInterrupt() context 32 | */ 33 | unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout) 34 | { 35 | // cache the port and bit of the pin in order to speed up the 36 | // pulse width measuring loop and achieve finer resolution. calling 37 | // digitalRead() instead yields much coarser resolution. 38 | uint8_t bit = digitalPinToBitMask(pin); 39 | uint8_t port = digitalPinToPort(pin); 40 | uint8_t stateMask = (state ? bit : 0); 41 | 42 | // convert the timeout from microseconds to a number of times through 43 | // the initial loop; it takes approximately 16 clock cycles per iteration 44 | unsigned long maxloops = microsecondsToClockCycles(timeout)/16; 45 | 46 | unsigned long width = countPulseASM(portInputRegister(port), bit, stateMask, maxloops); 47 | 48 | // prevent clockCyclesToMicroseconds to return bogus values if countPulseASM timed out 49 | if (width) 50 | return clockCyclesToMicroseconds(width * 16 + 16); 51 | else 52 | return 0; 53 | } 54 | 55 | /* Measures the length (in microseconds) of a pulse on the pin; state is HIGH 56 | * or LOW, the type of pulse to measure. Works on pulses from 2-3 microseconds 57 | * to 3 minutes in length, but must be called at least a few dozen microseconds 58 | * before the start of the pulse. 59 | * 60 | * ATTENTION: 61 | * this function relies on micros() so cannot be used in noInterrupt() context 62 | */ 63 | unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout) 64 | { 65 | // cache the port and bit of the pin in order to speed up the 66 | // pulse width measuring loop and achieve finer resolution. calling 67 | // digitalRead() instead yields much coarser resolution. 68 | uint8_t bit = digitalPinToBitMask(pin); 69 | uint8_t port = digitalPinToPort(pin); 70 | uint8_t stateMask = (state ? bit : 0); 71 | 72 | unsigned long startMicros = micros(); 73 | 74 | // wait for any previous pulse to end 75 | while ((*portInputRegister(port) & bit) == stateMask) { 76 | if (micros() - startMicros > timeout) 77 | return 0; 78 | } 79 | 80 | // wait for the pulse to start 81 | while ((*portInputRegister(port) & bit) != stateMask) { 82 | if (micros() - startMicros > timeout) 83 | return 0; 84 | } 85 | 86 | unsigned long start = micros(); 87 | // wait for the pulse to stop 88 | while ((*portInputRegister(port) & bit) == stateMask) { 89 | if (micros() - startMicros > timeout) 90 | return 0; 91 | } 92 | return micros() - start; 93 | } 94 | -------------------------------------------------------------------------------- /cores/arduino/wiring_shift.c: -------------------------------------------------------------------------------- 1 | /* 2 | wiring_shift.c - shiftOut() function 3 | Part of Arduino - http://www.arduino.cc/ 4 | 5 | Copyright (c) 2005-2006 David A. Mellis 6 | 7 | This library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public 9 | License as published by the Free Software Foundation; either 10 | version 2.1 of the License, or (at your option) any later version. 11 | 12 | This library is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General 18 | Public License along with this library; if not, write to the 19 | Free Software Foundation, Inc., 59 Temple Place, Suite 330, 20 | Boston, MA 02111-1307 USA 21 | */ 22 | 23 | #include "wiring_private.h" 24 | 25 | uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder) { 26 | uint8_t value = 0; 27 | uint8_t i; 28 | 29 | for (i = 0; i < 8; ++i) { 30 | digitalWrite(clockPin, HIGH); 31 | if (bitOrder == LSBFIRST) 32 | value |= digitalRead(dataPin) << i; 33 | else 34 | value |= digitalRead(dataPin) << (7 - i); 35 | digitalWrite(clockPin, LOW); 36 | } 37 | return value; 38 | } 39 | 40 | void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val) 41 | { 42 | uint8_t i; 43 | 44 | for (i = 0; i < 8; i++) { 45 | if (bitOrder == LSBFIRST) { 46 | digitalWrite(dataPin, val & 1); 47 | val >>= 1; 48 | } else { 49 | digitalWrite(dataPin, (val & 128) != 0); 50 | val <<= 1; 51 | } 52 | 53 | digitalWrite(clockPin, HIGH); 54 | digitalWrite(clockPin, LOW); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /cores/arduino/xinput/USB_XInput_API.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Project Arduino XInput - AVR Core 3 | * @author David Madison 4 | * @link github.com/dmadison/ArduinoXInput_AVR 5 | * @license MIT - Copyright (c) 2019 David Madison 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | * 25 | */ 26 | 27 | #include "USB_XInput_API.h" 28 | 29 | #ifdef USB_XINPUT 30 | 31 | void (*XInputUSB::RecvCallback)(void) = nullptr; 32 | 33 | boolean XInputUSB::connected() { 34 | return USBDevice.configured(); 35 | } 36 | 37 | uint8_t XInputUSB::available() { 38 | return USB_Available(XINPUT_RX_ENDPOINT); 39 | } 40 | 41 | int XInputUSB::recv(void *buffer, uint8_t nbytes) { 42 | return USB_Recv(XINPUT_RX_ENDPOINT, buffer, nbytes); 43 | } 44 | 45 | int XInputUSB::send(const void *buffer, uint8_t nbytes) { 46 | int result = USB_Send(XINPUT_TX_ENDPOINT, buffer, nbytes); 47 | if (result > 0) { 48 | USB_Flush(XINPUT_TX_ENDPOINT); 49 | } 50 | return result; 51 | } 52 | 53 | void XInputUSB::setRecvCallback(void(*callback)(void)) { 54 | XInputUSB::RecvCallback = callback; 55 | } 56 | 57 | #endif /* ifdef USB_XINPUT */ 58 | -------------------------------------------------------------------------------- /cores/arduino/xinput/USB_XInput_API.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Project Arduino XInput - AVR Core 3 | * @author David Madison 4 | * @link github.com/dmadison/ArduinoXInput_AVR 5 | * @license MIT - Copyright (c) 2019 David Madison 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | * 25 | */ 26 | 27 | #include "USBAPI.h" 28 | 29 | #ifndef USB_XINPUT_API_H 30 | #define USB_XINPUT_API_H 31 | 32 | #ifdef USBCON 33 | 34 | #define USB_XINPUT 35 | 36 | class XInputUSB { 37 | public: 38 | // API 39 | static bool connected(void); 40 | static uint8_t available(void); 41 | static int send(const void *buffer, uint8_t nbytes); 42 | static int recv(void *buffer, uint8_t nbytes); 43 | static void setRecvCallback(void(*callback)(void)); 44 | 45 | // Non-API Data 46 | static void (*RecvCallback)(void); 47 | }; 48 | 49 | #endif /* if defined(USBCON) */ 50 | 51 | #endif /* ifndef USB_XINPUT_API_H */ 52 | -------------------------------------------------------------------------------- /cores/arduino/xinput/USB_XInput_Descriptors.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Project Arduino XInput - AVR Core 3 | * @author David Madison 4 | * @link github.com/dmadison/ArduinoXInput_AVR 5 | * @license MIT - Copyright (c) 2019 David Madison 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | * 25 | */ 26 | 27 | #include "USBAPI.h" 28 | 29 | #ifndef USB_XINPUT_DESCRIPTORS_H 30 | #define USB_XINPUT_DESCRIPTORS_H 31 | 32 | #if defined(USBCON) 33 | 34 | // Device Descriptor 35 | extern const DeviceDescriptor USB_DeviceDescriptor PROGMEM; 36 | 37 | // Config Descriptor 38 | extern const u8 USB_ConfigDescriptor[] PROGMEM; 39 | extern const u16 USB_ConfigDescriptorSize PROGMEM; 40 | 41 | // String Descriptors 42 | extern const u8 STRING_SERIAL[] PROGMEM; 43 | extern const u8 STRING_SECURITY[] PROGMEM; 44 | 45 | #define ISECURITY 4 46 | 47 | // Endpoint Numbers 48 | #define XINPUT_TX_ENDPOINT 1 49 | #define XINPUT_RX_ENDPOINT 2 50 | 51 | #endif /* if defined(USBCON) */ 52 | 53 | #endif /* ifndef USB_XINPUT_DESCRIPTORS_H */ 54 | -------------------------------------------------------------------------------- /drivers/AdafruitCircuitPlayground.cat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmadison/ArduinoXInput_AVR/585e49e863ccc73083863d421d1e513ce69b9900/drivers/AdafruitCircuitPlayground.cat -------------------------------------------------------------------------------- /drivers/AdafruitCircuitPlayground.inf: -------------------------------------------------------------------------------- 1 | ;************************************************************ 2 | ; Windows USB CDC ACM Setup File 3 | ; Copyright (c) 2000 Microsoft Corporation 4 | ; For Adafruit Circuit Playground Board by Adafruit Industries LLC 2016 5 | 6 | [Version] 7 | Signature="$Windows NT$" 8 | Class=Ports 9 | ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318} 10 | Provider=%MFGNAME% 11 | LayoutFile=layout.inf 12 | CatalogFile=%MFGFILENAME%.cat 13 | DriverVer=02/25/2016,6.2.2600.0 14 | 15 | [Manufacturer] 16 | %MFGNAME%=DeviceList, NTamd64 17 | 18 | [DestinationDirs] 19 | DefaultDestDir=12 20 | 21 | [DefaultInstall] 22 | CopyINF="AdafruitCircuitPlayground.inf" 23 | 24 | ;------------------------------------------------------------------------------ 25 | ; Windows 2000/XP/Vista/Win7/Win8/Win8.1/Win10 32 bit Sections 26 | ;------------------------------------------------------------------------------ 27 | 28 | [DriverInstall.nt] 29 | include=mdmcpq.inf 30 | CopyFiles=DriverCopyFiles.nt 31 | AddReg=DriverInstall.nt.AddReg 32 | 33 | [DriverCopyFiles.nt] 34 | usbser.sys,,,0x20 35 | 36 | [DriverInstall.nt.AddReg] 37 | HKR,,DevLoader,,*ntkern 38 | HKR,,NTMPDriver,,%DRIVERFILENAME%.sys 39 | HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider" 40 | 41 | [DriverInstall.nt.Services] 42 | AddService=usbser, 0x00000002, DriverService.nt 43 | 44 | [DriverService.nt] 45 | DisplayName=%SERVICE% 46 | ServiceType=1 47 | StartType=3 48 | ErrorControl=1 49 | ServiceBinary=%12%\%DRIVERFILENAME%.sys 50 | 51 | ;------------------------------------------------------------------------------ 52 | ; Vista/Win7/Win8/Win8.1/Win10 64 bit Sections 53 | ;------------------------------------------------------------------------------ 54 | 55 | [DriverInstall.NTamd64] 56 | include=mdmcpq.inf 57 | CopyFiles=DriverCopyFiles.NTamd64 58 | AddReg=DriverInstall.NTamd64.AddReg 59 | 60 | [DriverCopyFiles.NTamd64] 61 | %DRIVERFILENAME%.sys,,,0x20 62 | 63 | [DriverInstall.NTamd64.AddReg] 64 | HKR,,DevLoader,,*ntkern 65 | HKR,,NTMPDriver,,%DRIVERFILENAME%.sys 66 | HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider" 67 | 68 | [DriverInstall.NTamd64.Services] 69 | AddService=usbser, 0x00000002, DriverService.NTamd64 70 | 71 | [DriverService.NTamd64] 72 | DisplayName=%SERVICE% 73 | ServiceType=1 74 | StartType=3 75 | ErrorControl=1 76 | ServiceBinary=%12%\%DRIVERFILENAME%.sys 77 | 78 | ;------------------------------------------------------------------------------ 79 | ; Vendor and Product ID Definitions 80 | ;------------------------------------------------------------------------------ 81 | ; When developing your USB device, the VID and PID used in the PC side 82 | ; application program and the firmware on the microcontroller must match. 83 | ; Modify the below line to use your VID and PID. Use the format as shown below. 84 | ; Note: One INF file can be used for multiple devices with different VID and PIDs. 85 | ; For each supported device, append ",USB\VID_xxxx&PID_yyyy" to the end of the line. 86 | ;------------------------------------------------------------------------------ 87 | [SourceDisksFiles] 88 | [SourceDisksNames] 89 | [DeviceList] 90 | %DESCRIPTION%=DriverInstall, USB\VID_239A&PID_0011 91 | %DESCRIPTION%=DriverInstall, USB\VID_239A&PID_8011&MI_00 92 | 93 | [DeviceList.NTamd64] 94 | %DESCRIPTION%=DriverInstall, USB\VID_239A&PID_0011 95 | %DESCRIPTION%=DriverInstall, USB\VID_239A&PID_8011&MI_00 96 | 97 | ;------------------------------------------------------------------------------ 98 | ; String Definitions 99 | ;------------------------------------------------------------------------------ 100 | ; Modify these strings to customize your device 101 | ; NOTE: Do not put spaces in %MFGFILENAME% to maintain Windows 7 compatibility 102 | ;------------------------------------------------------------------------------ 103 | [Strings] 104 | MFGFILENAME="AdafruitCircuitPlayground" 105 | DRIVERFILENAME ="usbser" 106 | MFGNAME="Adafruit Industries LLC" 107 | INSTDISK="Circuit Playground Board Driver Installer" 108 | DESCRIPTION="Adafruit Circuit Playground" 109 | SERVICE="USB RS-232 Emulation Driver" -------------------------------------------------------------------------------- /drivers/FTDI USB Drivers/Static/amd64/ftd2xx.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmadison/ArduinoXInput_AVR/585e49e863ccc73083863d421d1e513ce69b9900/drivers/FTDI USB Drivers/Static/amd64/ftd2xx.lib -------------------------------------------------------------------------------- /drivers/FTDI USB Drivers/Static/i386/ftd2xx.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmadison/ArduinoXInput_AVR/585e49e863ccc73083863d421d1e513ce69b9900/drivers/FTDI USB Drivers/Static/i386/ftd2xx.lib -------------------------------------------------------------------------------- /drivers/FTDI USB Drivers/amd64/ftbusui.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmadison/ArduinoXInput_AVR/585e49e863ccc73083863d421d1e513ce69b9900/drivers/FTDI USB Drivers/amd64/ftbusui.dll -------------------------------------------------------------------------------- /drivers/FTDI USB Drivers/amd64/ftcserco.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmadison/ArduinoXInput_AVR/585e49e863ccc73083863d421d1e513ce69b9900/drivers/FTDI USB Drivers/amd64/ftcserco.dll -------------------------------------------------------------------------------- /drivers/FTDI USB Drivers/amd64/ftd2xx.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmadison/ArduinoXInput_AVR/585e49e863ccc73083863d421d1e513ce69b9900/drivers/FTDI USB Drivers/amd64/ftd2xx.lib -------------------------------------------------------------------------------- /drivers/FTDI USB Drivers/amd64/ftd2xx64.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmadison/ArduinoXInput_AVR/585e49e863ccc73083863d421d1e513ce69b9900/drivers/FTDI USB Drivers/amd64/ftd2xx64.dll -------------------------------------------------------------------------------- /drivers/FTDI USB Drivers/amd64/ftdibus.sys: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmadison/ArduinoXInput_AVR/585e49e863ccc73083863d421d1e513ce69b9900/drivers/FTDI USB Drivers/amd64/ftdibus.sys -------------------------------------------------------------------------------- /drivers/FTDI USB Drivers/amd64/ftlang.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmadison/ArduinoXInput_AVR/585e49e863ccc73083863d421d1e513ce69b9900/drivers/FTDI USB Drivers/amd64/ftlang.dll -------------------------------------------------------------------------------- /drivers/FTDI USB Drivers/amd64/ftser2k.sys: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmadison/ArduinoXInput_AVR/585e49e863ccc73083863d421d1e513ce69b9900/drivers/FTDI USB Drivers/amd64/ftser2k.sys -------------------------------------------------------------------------------- /drivers/FTDI USB Drivers/amd64/ftserui2.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmadison/ArduinoXInput_AVR/585e49e863ccc73083863d421d1e513ce69b9900/drivers/FTDI USB Drivers/amd64/ftserui2.dll -------------------------------------------------------------------------------- /drivers/FTDI USB Drivers/ftd2xx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmadison/ArduinoXInput_AVR/585e49e863ccc73083863d421d1e513ce69b9900/drivers/FTDI USB Drivers/ftd2xx.h -------------------------------------------------------------------------------- /drivers/FTDI USB Drivers/ftdibus.cat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmadison/ArduinoXInput_AVR/585e49e863ccc73083863d421d1e513ce69b9900/drivers/FTDI USB Drivers/ftdibus.cat -------------------------------------------------------------------------------- /drivers/FTDI USB Drivers/ftdibus.inf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmadison/ArduinoXInput_AVR/585e49e863ccc73083863d421d1e513ce69b9900/drivers/FTDI USB Drivers/ftdibus.inf -------------------------------------------------------------------------------- /drivers/FTDI USB Drivers/ftdiport.cat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmadison/ArduinoXInput_AVR/585e49e863ccc73083863d421d1e513ce69b9900/drivers/FTDI USB Drivers/ftdiport.cat -------------------------------------------------------------------------------- /drivers/FTDI USB Drivers/ftdiport.inf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmadison/ArduinoXInput_AVR/585e49e863ccc73083863d421d1e513ce69b9900/drivers/FTDI USB Drivers/ftdiport.inf -------------------------------------------------------------------------------- /drivers/FTDI USB Drivers/i386/ftbusui.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmadison/ArduinoXInput_AVR/585e49e863ccc73083863d421d1e513ce69b9900/drivers/FTDI USB Drivers/i386/ftbusui.dll -------------------------------------------------------------------------------- /drivers/FTDI USB Drivers/i386/ftcserco.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmadison/ArduinoXInput_AVR/585e49e863ccc73083863d421d1e513ce69b9900/drivers/FTDI USB Drivers/i386/ftcserco.dll -------------------------------------------------------------------------------- /drivers/FTDI USB Drivers/i386/ftd2xx.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmadison/ArduinoXInput_AVR/585e49e863ccc73083863d421d1e513ce69b9900/drivers/FTDI USB Drivers/i386/ftd2xx.dll -------------------------------------------------------------------------------- /drivers/FTDI USB Drivers/i386/ftd2xx.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmadison/ArduinoXInput_AVR/585e49e863ccc73083863d421d1e513ce69b9900/drivers/FTDI USB Drivers/i386/ftd2xx.lib -------------------------------------------------------------------------------- /drivers/FTDI USB Drivers/i386/ftdibus.sys: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmadison/ArduinoXInput_AVR/585e49e863ccc73083863d421d1e513ce69b9900/drivers/FTDI USB Drivers/i386/ftdibus.sys -------------------------------------------------------------------------------- /drivers/FTDI USB Drivers/i386/ftlang.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmadison/ArduinoXInput_AVR/585e49e863ccc73083863d421d1e513ce69b9900/drivers/FTDI USB Drivers/i386/ftlang.dll -------------------------------------------------------------------------------- /drivers/FTDI USB Drivers/i386/ftser2k.sys: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmadison/ArduinoXInput_AVR/585e49e863ccc73083863d421d1e513ce69b9900/drivers/FTDI USB Drivers/i386/ftser2k.sys -------------------------------------------------------------------------------- /drivers/FTDI USB Drivers/i386/ftserui2.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmadison/ArduinoXInput_AVR/585e49e863ccc73083863d421d1e513ce69b9900/drivers/FTDI USB Drivers/i386/ftserui2.dll -------------------------------------------------------------------------------- /drivers/arduino-org.cat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmadison/ArduinoXInput_AVR/585e49e863ccc73083863d421d1e513ce69b9900/drivers/arduino-org.cat -------------------------------------------------------------------------------- /drivers/arduino.cat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmadison/ArduinoXInput_AVR/585e49e863ccc73083863d421d1e513ce69b9900/drivers/arduino.cat -------------------------------------------------------------------------------- /drivers/dpinst-amd64.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmadison/ArduinoXInput_AVR/585e49e863ccc73083863d421d1e513ce69b9900/drivers/dpinst-amd64.exe -------------------------------------------------------------------------------- /drivers/dpinst-x86.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmadison/ArduinoXInput_AVR/585e49e863ccc73083863d421d1e513ce69b9900/drivers/dpinst-x86.exe -------------------------------------------------------------------------------- /drivers/gemma/amd64/libusb0.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmadison/ArduinoXInput_AVR/585e49e863ccc73083863d421d1e513ce69b9900/drivers/gemma/amd64/libusb0.dll -------------------------------------------------------------------------------- /drivers/gemma/amd64/libusb0.sys: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmadison/ArduinoXInput_AVR/585e49e863ccc73083863d421d1e513ce69b9900/drivers/gemma/amd64/libusb0.sys -------------------------------------------------------------------------------- /drivers/gemma/arduino_gemma.cat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmadison/ArduinoXInput_AVR/585e49e863ccc73083863d421d1e513ce69b9900/drivers/gemma/arduino_gemma.cat -------------------------------------------------------------------------------- /drivers/gemma/arduino_gemma.inf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmadison/ArduinoXInput_AVR/585e49e863ccc73083863d421d1e513ce69b9900/drivers/gemma/arduino_gemma.inf -------------------------------------------------------------------------------- /drivers/gemma/ia64/libusb0.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmadison/ArduinoXInput_AVR/585e49e863ccc73083863d421d1e513ce69b9900/drivers/gemma/ia64/libusb0.dll -------------------------------------------------------------------------------- /drivers/gemma/ia64/libusb0.sys: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmadison/ArduinoXInput_AVR/585e49e863ccc73083863d421d1e513ce69b9900/drivers/gemma/ia64/libusb0.sys -------------------------------------------------------------------------------- /drivers/gemma/x86/libusb0.sys: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmadison/ArduinoXInput_AVR/585e49e863ccc73083863d421d1e513ce69b9900/drivers/gemma/x86/libusb0.sys -------------------------------------------------------------------------------- /drivers/gemma/x86/libusb0_x86.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmadison/ArduinoXInput_AVR/585e49e863ccc73083863d421d1e513ce69b9900/drivers/gemma/x86/libusb0_x86.dll -------------------------------------------------------------------------------- /drivers/genuino.cat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmadison/ArduinoXInput_AVR/585e49e863ccc73083863d421d1e513ce69b9900/drivers/genuino.cat -------------------------------------------------------------------------------- /drivers/genuino.inf: -------------------------------------------------------------------------------- 1 | ; 2 | ; Copyright 2016 Arduino LLC (http://www.arduino.cc/) 3 | ; 4 | ; Developed by Zach Eveland, Blacklabel Development, Inc. 5 | ; 6 | ; Arduino is free software; you can redistribute it and/or modify 7 | ; it under the terms of the GNU General Public License as published by 8 | ; the Free Software Foundation; either version 2 of the License, or 9 | ; (at your option) any later version. 10 | ; 11 | ; This program is distributed in the hope that it will be useful, 12 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ; GNU General Public License for more details. 15 | ; 16 | ; You should have received a copy of the GNU General Public License 17 | ; along with this program; if not, write to the Free Software 18 | ; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | ; 20 | ; As a special exception, you may use this file as part of a free software 21 | ; library without restriction. Specifically, if other files instantiate 22 | ; templates or use macros or inline functions from this file, or you compile 23 | ; this file and link it with other files to produce an executable, this 24 | ; file does not by itself cause the resulting executable to be covered by 25 | ; the GNU General Public License. This exception does not however 26 | ; invalidate any other reasons why the executable file might be covered by 27 | ; the GNU General Public License. 28 | ; 29 | 30 | [Strings] 31 | DriverPackageDisplayName="Genuino USB Driver" 32 | ManufacturerName="Arduino LLC (www.arduino.cc)" 33 | ServiceName="USB RS-232 Emulation Driver" 34 | unoR3.name="Genuino Uno" 35 | mega2560rev3.name="Genuino Mega 2560" 36 | micro.bootloader.name="Genuino Micro bootloader" 37 | micro.sketch.name="Genuino Micro" 38 | mkr1000.sketch.name="Genuino MKR1000" 39 | mkr1000.bootloader.name="Genuino MKR1000 bootloader" 40 | zero.sketch.name="Genuino Zero" 41 | zero.bootloader.name="Genuino Zero bootloader" 42 | 43 | [DefaultInstall] 44 | CopyINF=genuino.inf 45 | 46 | [Version] 47 | Class=Ports 48 | ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318} 49 | Signature="$Windows NT$" 50 | Provider=%ManufacturerName% 51 | DriverPackageDisplayName=%DriverPackageDisplayName% 52 | CatalogFile=genuino.cat 53 | ; DriverVer date is MM/DD/YYYY 54 | DriverVer=01/07/2016,1.0.3.0 55 | 56 | [Manufacturer] 57 | %ManufacturerName%=DeviceList, NTamd64, NTia64 58 | 59 | [DestinationDirs] 60 | FakeModemCopyFileSection=12 61 | DefaultDestDir=12 62 | 63 | [DeviceList] 64 | %mega2560rev3.name%=DriverInstall, USB\VID_2341&PID_0242 65 | %micro.bootloader.name%=DriverInstall, USB\VID_2341&PID_0237 66 | %micro.sketch.name%=DriverInstall, USB\VID_2341&PID_8237&MI_00 67 | %mkr1000.sketch.name%=DriverInstall, USB\VID_2341&PID_824E&MI_00 68 | %mkr1000.bootloader.name%=DriverInstall, USB\VID_2341&PID_024E 69 | %unoR3.name%=DriverInstall, USB\VID_2341&PID_0243 70 | %zero.sketch.name%=DriverInstall, USB\VID_2341&PID_824D&MI_00 71 | %zero.bootloader.name%=DriverInstall, USB\VID_2341&PID_024D 72 | 73 | [DeviceList.NTamd64] 74 | %mega2560rev3.name%=DriverInstall, USB\VID_2341&PID_0242 75 | %micro.bootloader.name%=DriverInstall, USB\VID_2341&PID_0237 76 | %micro.sketch.name%=DriverInstall, USB\VID_2341&PID_8237&MI_00 77 | %mkr1000.sketch.name%=DriverInstall, USB\VID_2341&PID_824E&MI_00 78 | %mkr1000.bootloader.name%=DriverInstall, USB\VID_2341&PID_024E 79 | %unoR3.name%=DriverInstall, USB\VID_2341&PID_0243 80 | %zero.sketch.name%=DriverInstall, USB\VID_2341&PID_824D&MI_00 81 | %zero.bootloader.name%=DriverInstall, USB\VID_2341&PID_024D 82 | 83 | [DeviceList.NTia64] 84 | %mega2560rev3.name%=DriverInstall, USB\VID_2341&PID_0242 85 | %micro.bootloader.name%=DriverInstall, USB\VID_2341&PID_0237 86 | %micro.sketch.name%=DriverInstall, USB\VID_2341&PID_8237&MI_00 87 | %mkr1000.sketch.name%=DriverInstall, USB\VID_2341&PID_824E&MI_00 88 | %mkr1000.bootloader.name%=DriverInstall, USB\VID_2341&PID_024E 89 | %unoR3.name%=DriverInstall, USB\VID_2341&PID_0243 90 | %zero.sketch.name%=DriverInstall, USB\VID_2341&PID_824D&MI_00 91 | %zero.bootloader.name%=DriverInstall, USB\VID_2341&PID_024D 92 | 93 | [DriverInstall] 94 | include=mdmcpq.inf,usb.inf 95 | CopyFiles = FakeModemCopyFileSection 96 | AddReg=DriverAddReg 97 | 98 | [DriverAddReg] 99 | HKR,,DevLoader,,*ntkern 100 | HKR,,NTMPDriver,,usbser.sys 101 | HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider" 102 | 103 | [DriverInstall.Services] 104 | include=mdmcpq.inf 105 | AddService=usbser, 0x00000002, DriverService 106 | 107 | [DriverService] 108 | DisplayName=%ServiceName% 109 | ServiceType=1 110 | StartType=3 111 | ErrorControl=1 112 | ServiceBinary=%12%\usbser.sys 113 | LoadOrderGroup=Base 114 | 115 | -------------------------------------------------------------------------------- /drivers/linino-boards_amd64.cat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmadison/ArduinoXInput_AVR/585e49e863ccc73083863d421d1e513ce69b9900/drivers/linino-boards_amd64.cat -------------------------------------------------------------------------------- /drivers/linino-boards_x86.cat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmadison/ArduinoXInput_AVR/585e49e863ccc73083863d421d1e513ce69b9900/drivers/linino-boards_x86.cat -------------------------------------------------------------------------------- /drivers/linino.inf: -------------------------------------------------------------------------------- 1 | ;************************************************************ 2 | ; Windows USB CDC ACM Setup File 3 | ; Copyright (c) 2000 Microsoft Corporation 4 | 5 | 6 | [Version] 7 | Signature="$Windows NT$" 8 | Class=Ports 9 | ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318} 10 | Provider=%MFGNAME% 11 | CatalogFile=%MFGFILENAME%.cat 12 | CatalogFile.NTx86=%MFGFILENAME%_x86.cat 13 | CatalogFile.NTIA64=%MFGFILENAME%_ia64.cat 14 | CatalogFile.NTAMD64=%MFGFILENAME%_amd64.cat 15 | DriverVer=01/13/2014,1.0.0.0 16 | 17 | [Manufacturer] 18 | %MFGNAME%=DeviceList, NTamd64 19 | 20 | [DestinationDirs] 21 | FakeModemCopyFileSection=12 22 | DefaultDestDir=12 23 | 24 | ;------------------------------------------------------------------------------ 25 | ; Windows 2000/XP/Vista-32bit Sections 26 | ;------------------------------------------------------------------------------ 27 | 28 | [DriverInstall.nt] 29 | include=mdmcpq.inf 30 | CopyFiles=FakeModemCopyFileSection 31 | AddReg=DriverInstall.nt.AddReg 32 | 33 | ;;[DriverCopyFiles.nt] 34 | ;;usbser.sys,,,0x20 35 | 36 | [DriverInstall.nt.AddReg] 37 | HKR,,DevLoader,,*ntkern 38 | HKR,,NTMPDriver,,%DRIVERFILENAME%.sys 39 | HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider" 40 | 41 | [DriverInstall.nt.Services] 42 | AddService=usbser, 0x00000002, DriverService.nt 43 | 44 | [DriverService.nt] 45 | DisplayName=%SERVICE% 46 | ServiceType=1 47 | StartType=3 48 | ErrorControl=1 49 | ServiceBinary=%12%\%DRIVERFILENAME%.sys 50 | 51 | ;------------------------------------------------------------------------------ 52 | ; Vista-64bit Sections 53 | ;------------------------------------------------------------------------------ 54 | 55 | [DriverInstall.NTamd64] 56 | include=mdmcpq.inf 57 | CopyFiles=FakeModemCopyFileSection 58 | AddReg=DriverInstall.NTamd64.AddReg 59 | 60 | [DriverCopyFiles.NTamd64] 61 | %DRIVERFILENAME%.sys,,,0x20 62 | 63 | [DriverInstall.NTamd64.AddReg] 64 | HKR,,DevLoader,,*ntkern 65 | HKR,,NTMPDriver,,%DRIVERFILENAME%.sys 66 | HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider" 67 | 68 | [DriverInstall.NTamd64.Services] 69 | AddService=usbser, 0x00000002, DriverService.NTamd64 70 | 71 | [DriverService.NTamd64] 72 | DisplayName=%SERVICE% 73 | ServiceType=1 74 | StartType=3 75 | ErrorControl=1 76 | ServiceBinary=%12%\%DRIVERFILENAME%.sys 77 | 78 | 79 | ;------------------------------------------------------------------------------ 80 | ; Vendor and Product ID Definitions 81 | ;------------------------------------------------------------------------------ 82 | ; When developing your USB device, the VID and PID used in the PC side 83 | ; application program and the firmware on the microcontroller must match. 84 | ; Modify the below line to use your VID and PID. Use the format as shown below. 85 | ; Note: One INF file can be used for multiple devices with different VID and PIDs. 86 | ; For each supported device, append ",USB\VID_xxxx&PID_yyyy" to the end of the line. 87 | ;------------------------------------------------------------------------------ 88 | [SourceDisksFiles] 89 | [SourceDisksNames] 90 | [DeviceList] 91 | %DESCRIPTION%=DriverInstall, USB\VID_2A03&PID_0001 92 | %DESCRIPTION%=DriverInstall, USB\VID_2A03&PID_8001&MI_00 93 | 94 | [DeviceList.NTamd64] 95 | %DESCRIPTION%=DriverInstall, USB\VID_2A03&PID_0001 96 | %DESCRIPTION%=DriverInstall, USB\VID_2A03&PID_0001&MI_00 97 | 98 | ;------------------------------------------------------------------------------ 99 | ; String Definitions 100 | ;------------------------------------------------------------------------------ 101 | ;Modify these strings to customize your device 102 | ;------------------------------------------------------------------------------ 103 | [Strings] 104 | MFGFILENAME="Linino-Boards" 105 | DRIVERFILENAME ="usbser" 106 | MFGNAME="Linino" 107 | INSTDISK="Linino Driver Installer" 108 | DESCRIPTION="Linino ONE" 109 | SERVICE="USB RS-232 Emulation Driver" 110 | 111 | -------------------------------------------------------------------------------- /libraries/EEPROM/README.md: -------------------------------------------------------------------------------- 1 | ## **EEPROM Library V2.0** for Arduino 2 | 3 | **Written by:** _Christopher Andrews_. 4 | 5 | ### **What is the EEPROM library.** 6 | 7 | Th EEPROM library provides an easy to use interface to interact with the internal non-volatile storage found in AVR based Arduino boards. This library will work on many AVR devices like ATtiny and ATmega chips. 8 | 9 | ### **How to use it** 10 | The EEPROM library is included in your IDE download. To add its functionality to your sketch you'll need to reference the library header file. You do this by adding an include directive to the top of your sketch. 11 | 12 | ```Arduino 13 | #include 14 | 15 | void setup(){ 16 | 17 | } 18 | 19 | void loop(){ 20 | 21 | } 22 | 23 | ``` 24 | 25 | The library provides a global variable named `EEPROM`, you use this variable to access the library functions. The methods provided in the EEPROM class are listed below. 26 | 27 | You can view all the examples [here](examples/). 28 | 29 | ### **Library functions** 30 | 31 | #### **`EEPROM.read( address )`** [[_example_]](examples/eeprom_read/eeprom_read.ino) 32 | 33 | This function allows you to read a single byte of data from the eeprom. 34 | Its only parameter is an `int` which should be set to the address you wish to read. 35 | 36 | The function returns an `unsigned char` containing the value read. 37 | 38 | #### **`EEPROM.write( address, value )`** [[_example_]](examples/eeprom_write/eeprom_write.ino) 39 | 40 | The `write()` method allows you to write a single byte of data to the EEPROM. 41 | Two parameters are needed. The first is an `int` containing the address that is to be written, and the second is a the data to be written (`unsigned char`). 42 | 43 | This function does not return any value. 44 | 45 | #### **`EEPROM.update( address, value )`** [[_example_]](examples/eeprom_update/eeprom_update.ino) 46 | 47 | This function is similar to `EEPROM.write()` however this method will only write data if the cell contents pointed to by `address` is different to `value`. This method can help prevent unnecessary wear on the EEPROM cells. 48 | 49 | This function does not return any value. 50 | 51 | #### **`EEPROM.get( address, object )`** [[_example_]](examples/eeprom_get/eeprom_get.ino) 52 | 53 | This function will retrieve any object from the EEPROM. 54 | Two parameters are needed to call this function. The first is an `int` containing the address that is to be written, and the second is the object you would like to read. 55 | 56 | This function returns a reference to the `object` passed in. It does not need to be used and is only returned for convenience. 57 | 58 | #### **`EEPROM.put( address, object )`** [[_example_]](examples/eeprom_put/eeprom_put.ino) 59 | 60 | This function will write any object to the EEPROM. 61 | Two parameters are needed to call this function. The first is an `int` containing the address that is to be written, and the second is the object you would like to write. 62 | 63 | This function uses the _update_ method to write its data, and therefore only rewrites changed cells. 64 | 65 | This function returns a reference to the `object` passed in. It does not need to be used and is only returned for convenience. 66 | 67 | #### **Subscript operator: `EEPROM[address]`** [[_example_]](examples/eeprom_crc/eeprom_crc.ino) 68 | 69 | This operator allows using the identifier `EEPROM` like an array. 70 | EEPROM cells can be read _and_ **_written_** directly using this method. 71 | 72 | This operator returns a reference to the EEPROM cell. 73 | 74 | ```c++ 75 | unsigned char val; 76 | 77 | //Read first EEPROM cell. 78 | val = EEPROM[ 0 ]; 79 | 80 | //Write first EEPROM cell. 81 | EEPROM[ 0 ] = val; 82 | 83 | //Compare contents 84 | if( val == EEPROM[ 0 ] ){ 85 | //Do something... 86 | } 87 | ``` 88 | 89 | #### **`EEPROM.length()`** 90 | 91 | This function returns an `unsigned int` containing the number of cells in the EEPROM. 92 | 93 | --- 94 | 95 | ### **Advanced features** 96 | 97 | This library uses a component based approach to provide its functionality. This means you can also use these components to design a customized approach. Two background classes are available for use: `EERef` & `EEPtr`. 98 | 99 | #### **`EERef` class** 100 | 101 | This object references an EEPROM cell. 102 | Its purpose is to mimic a typical byte of RAM, however its storage is the EEPROM. 103 | This class has an overhead of two bytes, similar to storing a pointer to an EEPROM cell. 104 | 105 | ```C++ 106 | EERef ref = EEPROM[ 10 ]; //Create a reference to 11th cell. 107 | 108 | ref = 4; //write to EEPROM cell. 109 | 110 | unsigned char val = ref; //Read referenced cell. 111 | ``` 112 | 113 | #### **`EEPtr` class** 114 | 115 | This object is a bidirectional pointer to EEPROM cells represented by `EERef` objects. 116 | Just like a normal pointer type, this type can be dereferenced and repositioned using 117 | increment/decrement operators. 118 | 119 | ```C++ 120 | EEPtr ptr = 10; //Create a pointer to 11th cell. 121 | 122 | *ptr = 4; //dereference and write to EEPROM cell. 123 | 124 | unsigned char val = *ptr; //dereference and read. 125 | 126 | ptr++; //Move to next EEPROM cell. 127 | ``` 128 | 129 | #### **`EEPROM.begin()`** 130 | 131 | This function returns an `EEPtr` pointing to the first cell in the EEPROM. 132 | This is useful for STL objects, custom iteration and C++11 style ranged for loops. 133 | 134 | #### **`EEPROM.end()`** 135 | 136 | This function returns an `EEPtr` pointing at the location after the last EEPROM cell. 137 | Used with `begin()` to provide custom iteration. 138 | 139 | **Note:** The `EEPtr` returned is invalid as it is out of range. In fact the hardware causes wrapping of the address (overflow) and `EEPROM.end()` actually references the first EEPROM cell. 140 | -------------------------------------------------------------------------------- /libraries/EEPROM/examples/eeprom_clear/eeprom_clear.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * EEPROM Clear 3 | * 4 | * Sets all of the bytes of the EEPROM to 0. 5 | * Please see eeprom_iteration for a more in depth 6 | * look at how to traverse the EEPROM. 7 | * 8 | * This example code is in the public domain. 9 | */ 10 | 11 | #include 12 | 13 | void setup() { 14 | // initialize the LED pin as an output. 15 | pinMode(13, OUTPUT); 16 | 17 | /*** 18 | Iterate through each byte of the EEPROM storage. 19 | 20 | Larger AVR processors have larger EEPROM sizes, E.g: 21 | - Arduino Duemilanove: 512 B EEPROM storage. 22 | - Arduino Uno: 1 kB EEPROM storage. 23 | - Arduino Mega: 4 kB EEPROM storage. 24 | 25 | Rather than hard-coding the length, you should use the pre-provided length function. 26 | This will make your code portable to all AVR processors. 27 | ***/ 28 | 29 | for (int i = 0 ; i < EEPROM.length() ; i++) { 30 | EEPROM.write(i, 0); 31 | } 32 | 33 | // turn the LED on when we're done 34 | digitalWrite(13, HIGH); 35 | } 36 | 37 | void loop() { 38 | /** Empty loop. **/ 39 | } 40 | -------------------------------------------------------------------------------- /libraries/EEPROM/examples/eeprom_crc/eeprom_crc.ino: -------------------------------------------------------------------------------- 1 | /*** 2 | Written by Christopher Andrews. 3 | CRC algorithm generated by pycrc, MIT licence ( https://github.com/tpircher/pycrc ). 4 | 5 | A CRC is a simple way of checking whether data has changed or become corrupted. 6 | This example calculates a CRC value directly on the EEPROM values. 7 | The purpose of this example is to highlight how the EEPROM object can be used just like an array. 8 | ***/ 9 | 10 | #include 11 | #include 12 | 13 | void setup() { 14 | 15 | //Start serial 16 | Serial.begin(9600); 17 | while (!Serial) { 18 | ; // wait for serial port to connect. Needed for native USB port only 19 | } 20 | 21 | //Print length of data to run CRC on. 22 | Serial.print("EEPROM length: "); 23 | Serial.println(EEPROM.length()); 24 | 25 | //Print the result of calling eeprom_crc() 26 | Serial.print("CRC32 of EEPROM data: 0x"); 27 | Serial.println(eeprom_crc(), HEX); 28 | Serial.print("\n\nDone!"); 29 | } 30 | 31 | void loop() { 32 | /* Empty loop */ 33 | } 34 | 35 | unsigned long eeprom_crc(void) { 36 | 37 | const unsigned long crc_table[16] = { 38 | 0x00000000, 0x1db71064, 0x3b6e20c8, 0x26d930ac, 39 | 0x76dc4190, 0x6b6b51f4, 0x4db26158, 0x5005713c, 40 | 0xedb88320, 0xf00f9344, 0xd6d6a3e8, 0xcb61b38c, 41 | 0x9b64c2b0, 0x86d3d2d4, 0xa00ae278, 0xbdbdf21c 42 | }; 43 | 44 | unsigned long crc = ~0L; 45 | 46 | for (int index = 0 ; index < EEPROM.length() ; ++index) { 47 | crc = crc_table[(crc ^ EEPROM[index]) & 0x0f] ^ (crc >> 4); 48 | crc = crc_table[(crc ^ (EEPROM[index] >> 4)) & 0x0f] ^ (crc >> 4); 49 | crc = ~crc; 50 | } 51 | return crc; 52 | } 53 | -------------------------------------------------------------------------------- /libraries/EEPROM/examples/eeprom_get/eeprom_get.ino: -------------------------------------------------------------------------------- 1 | /*** 2 | eeprom_get example. 3 | 4 | This shows how to use the EEPROM.get() method. 5 | 6 | To pre-set the EEPROM data, run the example sketch eeprom_put. 7 | This sketch will run without it, however, the values shown 8 | will be shown from what ever is already on the EEPROM. 9 | 10 | This may cause the serial object to print out a large string 11 | of garbage if there is no null character inside one of the strings 12 | loaded. 13 | 14 | Written by Christopher Andrews 2015 15 | Released under MIT licence. 16 | ***/ 17 | 18 | #include 19 | 20 | void setup() { 21 | 22 | float f = 0.00f; //Variable to store data read from EEPROM. 23 | int eeAddress = 0; //EEPROM address to start reading from 24 | 25 | Serial.begin(9600); 26 | while (!Serial) { 27 | ; // wait for serial port to connect. Needed for native USB port only 28 | } 29 | Serial.print("Read float from EEPROM: "); 30 | 31 | //Get the float data from the EEPROM at position 'eeAddress' 32 | EEPROM.get(eeAddress, f); 33 | Serial.println(f, 3); //This may print 'ovf, nan' if the data inside the EEPROM is not a valid float. 34 | 35 | /*** 36 | As get also returns a reference to 'f', you can use it inline. 37 | E.g: Serial.print( EEPROM.get( eeAddress, f ) ); 38 | ***/ 39 | 40 | /*** 41 | Get can be used with custom structures too. 42 | I have separated this into an extra function. 43 | ***/ 44 | 45 | secondTest(); //Run the next test. 46 | } 47 | 48 | struct MyObject { 49 | float field1; 50 | byte field2; 51 | char name[10]; 52 | }; 53 | 54 | void secondTest() { 55 | int eeAddress = sizeof(float); //Move address to the next byte after float 'f'. 56 | 57 | MyObject customVar; //Variable to store custom object read from EEPROM. 58 | EEPROM.get(eeAddress, customVar); 59 | 60 | Serial.println("Read custom object from EEPROM: "); 61 | Serial.println(customVar.field1); 62 | Serial.println(customVar.field2); 63 | Serial.println(customVar.name); 64 | } 65 | 66 | void loop() { 67 | /* Empty loop */ 68 | } 69 | -------------------------------------------------------------------------------- /libraries/EEPROM/examples/eeprom_iteration/eeprom_iteration.ino: -------------------------------------------------------------------------------- 1 | /*** 2 | eeprom_iteration example. 3 | 4 | A set of example snippets highlighting the 5 | simplest methods for traversing the EEPROM. 6 | 7 | Running this sketch is not necessary, this is 8 | simply highlighting certain programming methods. 9 | 10 | Written by Christopher Andrews 2015 11 | Released under MIT licence. 12 | ***/ 13 | 14 | #include 15 | 16 | void setup() { 17 | 18 | /*** 19 | Iterate the EEPROM using a for loop. 20 | ***/ 21 | 22 | for (int index = 0 ; index < EEPROM.length() ; index++) { 23 | 24 | //Add one to each cell in the EEPROM 25 | EEPROM[ index ] += 1; 26 | } 27 | 28 | /*** 29 | Iterate the EEPROM using a while loop. 30 | ***/ 31 | 32 | int index = 0; 33 | 34 | while (index < EEPROM.length()) { 35 | 36 | //Add one to each cell in the EEPROM 37 | EEPROM[ index ] += 1; 38 | index++; 39 | } 40 | 41 | /*** 42 | Iterate the EEPROM using a do-while loop. 43 | ***/ 44 | 45 | int idx = 0; //Used 'idx' to avoid name conflict with 'index' above. 46 | 47 | do { 48 | 49 | //Add one to each cell in the EEPROM 50 | EEPROM[ idx ] += 1; 51 | idx++; 52 | } while (idx < EEPROM.length()); 53 | 54 | 55 | } //End of setup function. 56 | 57 | void loop() {} 58 | -------------------------------------------------------------------------------- /libraries/EEPROM/examples/eeprom_put/eeprom_put.ino: -------------------------------------------------------------------------------- 1 | /*** 2 | eeprom_put example. 3 | 4 | This shows how to use the EEPROM.put() method. 5 | Also, this sketch will pre-set the EEPROM data for the 6 | example sketch eeprom_get. 7 | 8 | Note, unlike the single byte version EEPROM.write(), 9 | the put method will use update semantics. As in a byte 10 | will only be written to the EEPROM if the data is actually 11 | different. 12 | 13 | Written by Christopher Andrews 2015 14 | Released under MIT licence. 15 | ***/ 16 | 17 | #include 18 | 19 | struct MyObject { 20 | float field1; 21 | byte field2; 22 | char name[10]; 23 | }; 24 | 25 | void setup() { 26 | 27 | Serial.begin(9600); 28 | while (!Serial) { 29 | ; // wait for serial port to connect. Needed for native USB port only 30 | } 31 | 32 | float f = 123.456f; //Variable to store in EEPROM. 33 | int eeAddress = 0; //Location we want the data to be put. 34 | 35 | 36 | //One simple call, with the address first and the object second. 37 | EEPROM.put(eeAddress, f); 38 | 39 | Serial.println("Written float data type!"); 40 | 41 | /** Put is designed for use with custom structures also. **/ 42 | 43 | //Data to store. 44 | MyObject customVar = { 45 | 3.14f, 46 | 65, 47 | "Working!" 48 | }; 49 | 50 | eeAddress += sizeof(float); //Move address to the next byte after float 'f'. 51 | 52 | EEPROM.put(eeAddress, customVar); 53 | Serial.print("Written custom data type! \n\nView the example sketch eeprom_get to see how you can retrieve the values!"); 54 | } 55 | 56 | void loop() { 57 | /* Empty loop */ 58 | } 59 | -------------------------------------------------------------------------------- /libraries/EEPROM/examples/eeprom_read/eeprom_read.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * EEPROM Read 3 | * 4 | * Reads the value of each byte of the EEPROM and prints it 5 | * to the computer. 6 | * This example code is in the public domain. 7 | */ 8 | 9 | #include 10 | 11 | // start reading from the first byte (address 0) of the EEPROM 12 | int address = 0; 13 | byte value; 14 | 15 | void setup() { 16 | // initialize serial and wait for port to open: 17 | Serial.begin(9600); 18 | while (!Serial) { 19 | ; // wait for serial port to connect. Needed for native USB port only 20 | } 21 | } 22 | 23 | void loop() { 24 | // read a byte from the current address of the EEPROM 25 | value = EEPROM.read(address); 26 | 27 | Serial.print(address); 28 | Serial.print("\t"); 29 | Serial.print(value, DEC); 30 | Serial.println(); 31 | 32 | /*** 33 | Advance to the next address, when at the end restart at the beginning. 34 | 35 | Larger AVR processors have larger EEPROM sizes, E.g: 36 | - Arduino Duemilanove: 512 B EEPROM storage. 37 | - Arduino Uno: 1 kB EEPROM storage. 38 | - Arduino Mega: 4 kB EEPROM storage. 39 | 40 | Rather than hard-coding the length, you should use the pre-provided length function. 41 | This will make your code portable to all AVR processors. 42 | ***/ 43 | address = address + 1; 44 | if (address == EEPROM.length()) { 45 | address = 0; 46 | } 47 | 48 | /*** 49 | As the EEPROM sizes are powers of two, wrapping (preventing overflow) of an 50 | EEPROM address is also doable by a bitwise and of the length - 1. 51 | 52 | ++address &= EEPROM.length() - 1; 53 | ***/ 54 | 55 | delay(500); 56 | } 57 | -------------------------------------------------------------------------------- /libraries/EEPROM/examples/eeprom_update/eeprom_update.ino: -------------------------------------------------------------------------------- 1 | /*** 2 | EEPROM Update method 3 | 4 | Stores values read from analog input 0 into the EEPROM. 5 | These values will stay in the EEPROM when the board is 6 | turned off and may be retrieved later by another sketch. 7 | 8 | If a value has not changed in the EEPROM, it is not overwritten 9 | which would reduce the life span of the EEPROM unnecessarily. 10 | 11 | Released using MIT licence. 12 | ***/ 13 | 14 | #include 15 | 16 | /** the current address in the EEPROM (i.e. which byte we're going to write to next) **/ 17 | int address = 0; 18 | 19 | void setup() { 20 | /** Empty setup **/ 21 | } 22 | 23 | void loop() { 24 | /*** 25 | need to divide by 4 because analog inputs range from 26 | 0 to 1023 and each byte of the EEPROM can only hold a 27 | value from 0 to 255. 28 | ***/ 29 | int val = analogRead(0) / 4; 30 | 31 | /*** 32 | Update the particular EEPROM cell. 33 | these values will remain there when the board is 34 | turned off. 35 | ***/ 36 | EEPROM.update(address, val); 37 | 38 | /*** 39 | The function EEPROM.update(address, val) is equivalent to the following: 40 | 41 | if( EEPROM.read(address) != val ){ 42 | EEPROM.write(address, val); 43 | } 44 | ***/ 45 | 46 | 47 | /*** 48 | Advance to the next address, when at the end restart at the beginning. 49 | 50 | Larger AVR processors have larger EEPROM sizes, E.g: 51 | - Arduino Duemilanove: 512 B EEPROM storage. 52 | - Arduino Uno: 1 kB EEPROM storage. 53 | - Arduino Mega: 4 kB EEPROM storage. 54 | 55 | Rather than hard-coding the length, you should use the pre-provided length function. 56 | This will make your code portable to all AVR processors. 57 | ***/ 58 | address = address + 1; 59 | if (address == EEPROM.length()) { 60 | address = 0; 61 | } 62 | 63 | /*** 64 | As the EEPROM sizes are powers of two, wrapping (preventing overflow) of an 65 | EEPROM address is also doable by a bitwise and of the length - 1. 66 | 67 | ++address &= EEPROM.length() - 1; 68 | ***/ 69 | 70 | delay(100); 71 | } 72 | -------------------------------------------------------------------------------- /libraries/EEPROM/examples/eeprom_write/eeprom_write.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * EEPROM Write 3 | * 4 | * Stores values read from analog input 0 into the EEPROM. 5 | * These values will stay in the EEPROM when the board is 6 | * turned off and may be retrieved later by another sketch. 7 | */ 8 | 9 | #include 10 | 11 | /** the current address in the EEPROM (i.e. which byte we're going to write to next) **/ 12 | int addr = 0; 13 | 14 | void setup() { 15 | /** Empty setup. **/ 16 | } 17 | 18 | void loop() { 19 | /*** 20 | Need to divide by 4 because analog inputs range from 21 | 0 to 1023 and each byte of the EEPROM can only hold a 22 | value from 0 to 255. 23 | ***/ 24 | 25 | int val = analogRead(0) / 4; 26 | 27 | /*** 28 | Write the value to the appropriate byte of the EEPROM. 29 | these values will remain there when the board is 30 | turned off. 31 | ***/ 32 | 33 | EEPROM.write(addr, val); 34 | 35 | /*** 36 | Advance to the next address, when at the end restart at the beginning. 37 | 38 | Larger AVR processors have larger EEPROM sizes, E.g: 39 | - Arduino Duemilanove: 512 B EEPROM storage. 40 | - Arduino Uno: 1 kB EEPROM storage. 41 | - Arduino Mega: 4 kB EEPROM storage. 42 | 43 | Rather than hard-coding the length, you should use the pre-provided length function. 44 | This will make your code portable to all AVR processors. 45 | ***/ 46 | addr = addr + 1; 47 | if (addr == EEPROM.length()) { 48 | addr = 0; 49 | } 50 | 51 | /*** 52 | As the EEPROM sizes are powers of two, wrapping (preventing overflow) of an 53 | EEPROM address is also doable by a bitwise and of the length - 1. 54 | 55 | ++addr &= EEPROM.length() - 1; 56 | ***/ 57 | 58 | 59 | delay(100); 60 | } 61 | -------------------------------------------------------------------------------- /libraries/EEPROM/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For EEPROM 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | EEPROM KEYWORD1 10 | EERef KEYWORD1 11 | EEPtr KEYWORD2 12 | 13 | ####################################### 14 | # Methods and Functions (KEYWORD2) 15 | ####################################### 16 | 17 | update KEYWORD2 18 | 19 | ####################################### 20 | # Constants (LITERAL1) 21 | ####################################### 22 | 23 | -------------------------------------------------------------------------------- /libraries/EEPROM/library.properties: -------------------------------------------------------------------------------- 1 | name=EEPROM 2 | version=2.0 3 | author=Arduino, Christopher Andrews 4 | maintainer=Arduino 5 | sentence=Enables reading and writing to the permanent board storage. 6 | paragraph=This library allows to read and write data in a memory type, the EEPROM, that keeps its content also when the board is powered off. The amount of EEPROM available depends on the microcontroller type. 7 | category=Data Storage 8 | url=http://www.arduino.cc/en/Reference/EEPROM 9 | architectures=avr 10 | 11 | -------------------------------------------------------------------------------- /libraries/EEPROM/src/EEPROM.h: -------------------------------------------------------------------------------- 1 | /* 2 | EEPROM.h - EEPROM library 3 | Original Copyright (c) 2006 David A. Mellis. All right reserved. 4 | New version by Christopher Andrews 2015. 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef EEPROM_h 22 | #define EEPROM_h 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | /*** 29 | EERef class. 30 | 31 | This object references an EEPROM cell. 32 | Its purpose is to mimic a typical byte of RAM, however its storage is the EEPROM. 33 | This class has an overhead of two bytes, similar to storing a pointer to an EEPROM cell. 34 | ***/ 35 | 36 | struct EERef{ 37 | 38 | EERef( const int index ) 39 | : index( index ) {} 40 | 41 | //Access/read members. 42 | uint8_t operator*() const { return eeprom_read_byte( (uint8_t*) index ); } 43 | operator uint8_t() const { return **this; } 44 | 45 | //Assignment/write members. 46 | EERef &operator=( const EERef &ref ) { return *this = *ref; } 47 | EERef &operator=( uint8_t in ) { return eeprom_write_byte( (uint8_t*) index, in ), *this; } 48 | EERef &operator +=( uint8_t in ) { return *this = **this + in; } 49 | EERef &operator -=( uint8_t in ) { return *this = **this - in; } 50 | EERef &operator *=( uint8_t in ) { return *this = **this * in; } 51 | EERef &operator /=( uint8_t in ) { return *this = **this / in; } 52 | EERef &operator ^=( uint8_t in ) { return *this = **this ^ in; } 53 | EERef &operator %=( uint8_t in ) { return *this = **this % in; } 54 | EERef &operator &=( uint8_t in ) { return *this = **this & in; } 55 | EERef &operator |=( uint8_t in ) { return *this = **this | in; } 56 | EERef &operator <<=( uint8_t in ) { return *this = **this << in; } 57 | EERef &operator >>=( uint8_t in ) { return *this = **this >> in; } 58 | 59 | EERef &update( uint8_t in ) { return in != *this ? *this = in : *this; } 60 | 61 | /** Prefix increment/decrement **/ 62 | EERef& operator++() { return *this += 1; } 63 | EERef& operator--() { return *this -= 1; } 64 | 65 | /** Postfix increment/decrement **/ 66 | uint8_t operator++ (int){ 67 | uint8_t ret = **this; 68 | return ++(*this), ret; 69 | } 70 | 71 | uint8_t operator-- (int){ 72 | uint8_t ret = **this; 73 | return --(*this), ret; 74 | } 75 | 76 | int index; //Index of current EEPROM cell. 77 | }; 78 | 79 | /*** 80 | EEPtr class. 81 | 82 | This object is a bidirectional pointer to EEPROM cells represented by EERef objects. 83 | Just like a normal pointer type, this can be dereferenced and repositioned using 84 | increment/decrement operators. 85 | ***/ 86 | 87 | struct EEPtr{ 88 | 89 | EEPtr( const int index ) 90 | : index( index ) {} 91 | 92 | operator int() const { return index; } 93 | EEPtr &operator=( int in ) { return index = in, *this; } 94 | 95 | //Iterator functionality. 96 | bool operator!=( const EEPtr &ptr ) { return index != ptr.index; } 97 | EERef operator*() { return index; } 98 | 99 | /** Prefix & Postfix increment/decrement **/ 100 | EEPtr& operator++() { return ++index, *this; } 101 | EEPtr& operator--() { return --index, *this; } 102 | EEPtr operator++ (int) { return index++; } 103 | EEPtr operator-- (int) { return index--; } 104 | 105 | int index; //Index of current EEPROM cell. 106 | }; 107 | 108 | /*** 109 | EEPROMClass class. 110 | 111 | This object represents the entire EEPROM space. 112 | It wraps the functionality of EEPtr and EERef into a basic interface. 113 | This class is also 100% backwards compatible with earlier Arduino core releases. 114 | ***/ 115 | 116 | struct EEPROMClass{ 117 | 118 | //Basic user access methods. 119 | EERef operator[]( const int idx ) { return idx; } 120 | uint8_t read( int idx ) { return EERef( idx ); } 121 | void write( int idx, uint8_t val ) { (EERef( idx )) = val; } 122 | void update( int idx, uint8_t val ) { EERef( idx ).update( val ); } 123 | 124 | //STL and C++11 iteration capability. 125 | EEPtr begin() { return 0x00; } 126 | EEPtr end() { return length(); } //Standards requires this to be the item after the last valid entry. The returned pointer is invalid. 127 | uint16_t length() { return E2END + 1; } 128 | 129 | //Functionality to 'get' and 'put' objects to and from EEPROM. 130 | template< typename T > T &get( int idx, T &t ){ 131 | EEPtr e = idx; 132 | uint8_t *ptr = (uint8_t*) &t; 133 | for( int count = sizeof(T) ; count ; --count, ++e ) *ptr++ = *e; 134 | return t; 135 | } 136 | 137 | template< typename T > const T &put( int idx, const T &t ){ 138 | EEPtr e = idx; 139 | const uint8_t *ptr = (const uint8_t*) &t; 140 | for( int count = sizeof(T) ; count ; --count, ++e ) (*e).update( *ptr++ ); 141 | return t; 142 | } 143 | }; 144 | 145 | static EEPROMClass EEPROM; 146 | #endif 147 | -------------------------------------------------------------------------------- /libraries/SPI/examples/BarometricPressureSensor/BarometricPressureSensor.ino: -------------------------------------------------------------------------------- 1 | /* 2 | SCP1000 Barometric Pressure Sensor Display 3 | 4 | Shows the output of a Barometric Pressure Sensor on a 5 | Uses the SPI library. For details on the sensor, see: 6 | http://www.sparkfun.com/commerce/product_info.php?products_id=8161 7 | http://www.vti.fi/en/support/obsolete_products/pressure_sensors/ 8 | 9 | This sketch adapted from Nathan Seidle's SCP1000 example for PIC: 10 | http://www.sparkfun.com/datasheets/Sensors/SCP1000-Testing.zip 11 | 12 | Circuit: 13 | SCP1000 sensor attached to pins 6, 7, 10 - 13: 14 | DRDY: pin 6 15 | CSB: pin 7 16 | MOSI: pin 11 17 | MISO: pin 12 18 | SCK: pin 13 19 | 20 | created 31 July 2010 21 | modified 14 August 2010 22 | by Tom Igoe 23 | */ 24 | 25 | // the sensor communicates using SPI, so include the library: 26 | #include 27 | 28 | //Sensor's memory register addresses: 29 | const int PRESSURE = 0x1F; //3 most significant bits of pressure 30 | const int PRESSURE_LSB = 0x20; //16 least significant bits of pressure 31 | const int TEMPERATURE = 0x21; //16 bit temperature reading 32 | const byte READ = 0b11111100; // SCP1000's read command 33 | const byte WRITE = 0b00000010; // SCP1000's write command 34 | 35 | // pins used for the connection with the sensor 36 | // the other you need are controlled by the SPI library): 37 | const int dataReadyPin = 6; 38 | const int chipSelectPin = 7; 39 | 40 | void setup() { 41 | Serial.begin(9600); 42 | 43 | // start the SPI library: 44 | SPI.begin(); 45 | 46 | // initialize the data ready and chip select pins: 47 | pinMode(dataReadyPin, INPUT); 48 | pinMode(chipSelectPin, OUTPUT); 49 | 50 | //Configure SCP1000 for low noise configuration: 51 | writeRegister(0x02, 0x2D); 52 | writeRegister(0x01, 0x03); 53 | writeRegister(0x03, 0x02); 54 | // give the sensor time to set up: 55 | delay(100); 56 | } 57 | 58 | void loop() { 59 | //Select High Resolution Mode 60 | writeRegister(0x03, 0x0A); 61 | 62 | // don't do anything until the data ready pin is high: 63 | if (digitalRead(dataReadyPin) == HIGH) { 64 | //Read the temperature data 65 | int tempData = readRegister(0x21, 2); 66 | 67 | // convert the temperature to celsius and display it: 68 | float realTemp = (float)tempData / 20.0; 69 | Serial.print("Temp[C]="); 70 | Serial.print(realTemp); 71 | 72 | 73 | //Read the pressure data highest 3 bits: 74 | byte pressure_data_high = readRegister(0x1F, 1); 75 | pressure_data_high &= 0b00000111; //you only needs bits 2 to 0 76 | 77 | //Read the pressure data lower 16 bits: 78 | unsigned int pressure_data_low = readRegister(0x20, 2); 79 | //combine the two parts into one 19-bit number: 80 | long pressure = ((pressure_data_high << 16) | pressure_data_low) / 4; 81 | 82 | // display the temperature: 83 | Serial.println("\tPressure [Pa]=" + String(pressure)); 84 | } 85 | } 86 | 87 | //Read from or write to register from the SCP1000: 88 | unsigned int readRegister(byte thisRegister, int bytesToRead) { 89 | byte inByte = 0; // incoming byte from the SPI 90 | unsigned int result = 0; // result to return 91 | Serial.print(thisRegister, BIN); 92 | Serial.print("\t"); 93 | // SCP1000 expects the register name in the upper 6 bits 94 | // of the byte. So shift the bits left by two bits: 95 | thisRegister = thisRegister << 2; 96 | // now combine the address and the command into one byte 97 | byte dataToSend = thisRegister & READ; 98 | Serial.println(thisRegister, BIN); 99 | // take the chip select low to select the device: 100 | digitalWrite(chipSelectPin, LOW); 101 | // send the device the register you want to read: 102 | SPI.transfer(dataToSend); 103 | // send a value of 0 to read the first byte returned: 104 | result = SPI.transfer(0x00); 105 | // decrement the number of bytes left to read: 106 | bytesToRead--; 107 | // if you still have another byte to read: 108 | if (bytesToRead > 0) { 109 | // shift the first byte left, then get the second byte: 110 | result = result << 8; 111 | inByte = SPI.transfer(0x00); 112 | // combine the byte you just got with the previous one: 113 | result = result | inByte; 114 | // decrement the number of bytes left to read: 115 | bytesToRead--; 116 | } 117 | // take the chip select high to de-select: 118 | digitalWrite(chipSelectPin, HIGH); 119 | // return the result: 120 | return (result); 121 | } 122 | 123 | 124 | //Sends a write command to SCP1000 125 | 126 | void writeRegister(byte thisRegister, byte thisValue) { 127 | 128 | // SCP1000 expects the register address in the upper 6 bits 129 | // of the byte. So shift the bits left by two bits: 130 | thisRegister = thisRegister << 2; 131 | // now combine the register address and the command into one byte: 132 | byte dataToSend = thisRegister | WRITE; 133 | 134 | // take the chip select low to select the device: 135 | digitalWrite(chipSelectPin, LOW); 136 | 137 | SPI.transfer(dataToSend); //Send register location 138 | SPI.transfer(thisValue); //Send value to record into register 139 | 140 | // take the chip select high to de-select: 141 | digitalWrite(chipSelectPin, HIGH); 142 | } 143 | -------------------------------------------------------------------------------- /libraries/SPI/examples/DigitalPotControl/DigitalPotControl.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Digital Pot Control 3 | 4 | This example controls an Analog Devices AD5206 digital potentiometer. 5 | The AD5206 has 6 potentiometer channels. Each channel's pins are labeled 6 | A - connect this to voltage 7 | W - this is the pot's wiper, which changes when you set it 8 | B - connect this to ground. 9 | 10 | The AD5206 is SPI-compatible,and to command it, you send two bytes, 11 | one with the channel number (0 - 5) and one with the resistance value for the 12 | channel (0 - 255). 13 | 14 | The circuit: 15 | * All A pins of AD5206 connected to +5V 16 | * All B pins of AD5206 connected to ground 17 | * An LED and a 220-ohm resistor in series connected from each W pin to ground 18 | * CS - to digital pin 10 (SS pin) 19 | * SDI - to digital pin 11 (MOSI pin) 20 | * CLK - to digital pin 13 (SCK pin) 21 | 22 | created 10 Aug 2010 23 | by Tom Igoe 24 | 25 | Thanks to Heather Dewey-Hagborg for the original tutorial, 2005 26 | 27 | */ 28 | 29 | 30 | // include the SPI library: 31 | #include 32 | 33 | 34 | // set pin 10 as the slave select for the digital pot: 35 | const int slaveSelectPin = 10; 36 | 37 | void setup() { 38 | // set the slaveSelectPin as an output: 39 | pinMode(slaveSelectPin, OUTPUT); 40 | // initialize SPI: 41 | SPI.begin(); 42 | } 43 | 44 | void loop() { 45 | // go through the six channels of the digital pot: 46 | for (int channel = 0; channel < 6; channel++) { 47 | // change the resistance on this channel from min to max: 48 | for (int level = 0; level < 255; level++) { 49 | digitalPotWrite(channel, level); 50 | delay(10); 51 | } 52 | // wait a second at the top: 53 | delay(100); 54 | // change the resistance on this channel from max to min: 55 | for (int level = 0; level < 255; level++) { 56 | digitalPotWrite(channel, 255 - level); 57 | delay(10); 58 | } 59 | } 60 | 61 | } 62 | 63 | void digitalPotWrite(int address, int value) { 64 | // take the SS pin low to select the chip: 65 | digitalWrite(slaveSelectPin, LOW); 66 | delay(100); 67 | // send in the address and value via SPI: 68 | SPI.transfer(address); 69 | SPI.transfer(value); 70 | delay(100); 71 | // take the SS pin high to de-select the chip: 72 | digitalWrite(slaveSelectPin, HIGH); 73 | } 74 | -------------------------------------------------------------------------------- /libraries/SPI/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For SPI 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | SPI KEYWORD1 10 | 11 | ####################################### 12 | # Methods and Functions (KEYWORD2) 13 | ####################################### 14 | begin KEYWORD2 15 | end KEYWORD2 16 | transfer KEYWORD2 17 | setBitOrder KEYWORD2 18 | setDataMode KEYWORD2 19 | setClockDivider KEYWORD2 20 | 21 | 22 | ####################################### 23 | # Constants (LITERAL1) 24 | ####################################### 25 | SPI_CLOCK_DIV4 LITERAL1 26 | SPI_CLOCK_DIV16 LITERAL1 27 | SPI_CLOCK_DIV64 LITERAL1 28 | SPI_CLOCK_DIV128 LITERAL1 29 | SPI_CLOCK_DIV2 LITERAL1 30 | SPI_CLOCK_DIV8 LITERAL1 31 | SPI_CLOCK_DIV32 LITERAL1 32 | SPI_CLOCK_DIV64 LITERAL1 33 | SPI_MODE0 LITERAL1 34 | SPI_MODE1 LITERAL1 35 | SPI_MODE2 LITERAL1 36 | SPI_MODE3 LITERAL1 -------------------------------------------------------------------------------- /libraries/SPI/library.properties: -------------------------------------------------------------------------------- 1 | name=SPI 2 | version=1.0 3 | author=Arduino 4 | maintainer=Arduino 5 | sentence=Enables the communication with devices that use the Serial Peripheral Interface (SPI) Bus. 6 | paragraph=SPI is a synchronous serial data protocol used by microcontrollers for communicating with one or more peripheral devices quickly over short distances. It uses three lines common to all devices (MISO, MOSI and SCK) and one specific for each device. 7 | category=Communication 8 | url=http://www.arduino.cc/en/Reference/SPI 9 | architectures=avr 10 | 11 | -------------------------------------------------------------------------------- /libraries/SoftwareSerial/examples/SoftwareSerialExample/SoftwareSerialExample.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Software serial multiple serial test 3 | 4 | Receives from the hardware serial, sends to software serial. 5 | Receives from software serial, sends to hardware serial. 6 | 7 | The circuit: 8 | * RX is digital pin 10 (connect to TX of other device) 9 | * TX is digital pin 11 (connect to RX of other device) 10 | 11 | Note: 12 | Not all pins on the Mega and Mega 2560 support change interrupts, 13 | so only the following can be used for RX: 14 | 10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69 15 | 16 | Not all pins on the Leonardo and Micro support change interrupts, 17 | so only the following can be used for RX: 18 | 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI). 19 | 20 | created back in the mists of time 21 | modified 25 May 2012 22 | by Tom Igoe 23 | based on Mikal Hart's example 24 | 25 | This example code is in the public domain. 26 | 27 | */ 28 | #include 29 | 30 | SoftwareSerial mySerial(10, 11); // RX, TX 31 | 32 | void setup() { 33 | // Open serial communications and wait for port to open: 34 | Serial.begin(57600); 35 | while (!Serial) { 36 | ; // wait for serial port to connect. Needed for native USB port only 37 | } 38 | 39 | 40 | Serial.println("Goodnight moon!"); 41 | 42 | // set the data rate for the SoftwareSerial port 43 | mySerial.begin(4800); 44 | mySerial.println("Hello, world?"); 45 | } 46 | 47 | void loop() { // run over and over 48 | if (mySerial.available()) { 49 | Serial.write(mySerial.read()); 50 | } 51 | if (Serial.available()) { 52 | mySerial.write(Serial.read()); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /libraries/SoftwareSerial/examples/TwoPortReceive/TwoPortReceive.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Software serial multiple serial test 3 | 4 | Receives from the two software serial ports, 5 | sends to the hardware serial port. 6 | 7 | In order to listen on a software port, you call port.listen(). 8 | When using two software serial ports, you have to switch ports 9 | by listen()ing on each one in turn. Pick a logical time to switch 10 | ports, like the end of an expected transmission, or when the 11 | buffer is empty. This example switches ports when there is nothing 12 | more to read from a port 13 | 14 | The circuit: 15 | Two devices which communicate serially are needed. 16 | * First serial device's TX attached to digital pin 10(RX), RX to pin 11(TX) 17 | * Second serial device's TX attached to digital pin 8(RX), RX to pin 9(TX) 18 | 19 | Note: 20 | Not all pins on the Mega and Mega 2560 support change interrupts, 21 | so only the following can be used for RX: 22 | 10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69 23 | 24 | Not all pins on the Leonardo support change interrupts, 25 | so only the following can be used for RX: 26 | 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI). 27 | 28 | created 18 Apr. 2011 29 | modified 19 March 2016 30 | by Tom Igoe 31 | based on Mikal Hart's twoPortRXExample 32 | 33 | This example code is in the public domain. 34 | 35 | */ 36 | 37 | #include 38 | // software serial #1: RX = digital pin 10, TX = digital pin 11 39 | SoftwareSerial portOne(10, 11); 40 | 41 | // software serial #2: RX = digital pin 8, TX = digital pin 9 42 | // on the Mega, use other pins instead, since 8 and 9 don't work on the Mega 43 | SoftwareSerial portTwo(8, 9); 44 | 45 | void setup() { 46 | // Open serial communications and wait for port to open: 47 | Serial.begin(9600); 48 | while (!Serial) { 49 | ; // wait for serial port to connect. Needed for native USB port only 50 | } 51 | 52 | 53 | // Start each software serial port 54 | portOne.begin(9600); 55 | portTwo.begin(9600); 56 | } 57 | 58 | void loop() { 59 | // By default, the last initialized port is listening. 60 | // when you want to listen on a port, explicitly select it: 61 | portOne.listen(); 62 | Serial.println("Data from port one:"); 63 | // while there is data coming in, read it 64 | // and send to the hardware serial port: 65 | while (portOne.available() > 0) { 66 | char inByte = portOne.read(); 67 | Serial.write(inByte); 68 | } 69 | 70 | // blank line to separate data from the two ports: 71 | Serial.println(); 72 | 73 | // Now listen on the second port 74 | portTwo.listen(); 75 | // while there is data coming in, read it 76 | // and send to the hardware serial port: 77 | Serial.println("Data from port two:"); 78 | while (portTwo.available() > 0) { 79 | char inByte = portTwo.read(); 80 | Serial.write(inByte); 81 | } 82 | 83 | // blank line to separate data from the two ports: 84 | Serial.println(); 85 | } 86 | -------------------------------------------------------------------------------- /libraries/SoftwareSerial/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map for SoftwareSerial 3 | # (formerly NewSoftSerial) 4 | ####################################### 5 | 6 | ####################################### 7 | # Datatypes (KEYWORD1) 8 | ####################################### 9 | 10 | SoftwareSerial KEYWORD1 11 | 12 | ####################################### 13 | # Methods and Functions (KEYWORD2) 14 | ####################################### 15 | 16 | begin KEYWORD2 17 | end KEYWORD2 18 | read KEYWORD2 19 | write KEYWORD2 20 | available KEYWORD2 21 | isListening KEYWORD2 22 | overflow KEYWORD2 23 | flush KEYWORD2 24 | listen KEYWORD2 25 | peek KEYWORD2 26 | 27 | ####################################### 28 | # Constants (LITERAL1) 29 | ####################################### 30 | 31 | -------------------------------------------------------------------------------- /libraries/SoftwareSerial/library.properties: -------------------------------------------------------------------------------- 1 | name=SoftwareSerial 2 | version=1.0 3 | author=Arduino 4 | maintainer=Arduino 5 | sentence=Enables serial communication on any digital pin. 6 | paragraph=The SoftwareSerial library has been developed to allow serial communication on any digital pin of the board, using software to replicate the functionality of the hardware UART. It is possible to have multiple software serial ports with speeds up to 115200 bps. 7 | category=Communication 8 | url=http://www.arduino.cc/en/Reference/SoftwareSerial 9 | architectures=avr 10 | 11 | -------------------------------------------------------------------------------- /libraries/SoftwareSerial/src/SoftwareSerial.h: -------------------------------------------------------------------------------- 1 | /* 2 | SoftwareSerial.h (formerly NewSoftSerial.h) - 3 | Multi-instance software serial library for Arduino/Wiring 4 | -- Interrupt-driven receive and other improvements by ladyada 5 | (http://ladyada.net) 6 | -- Tuning, circular buffer, derivation from class Print/Stream, 7 | multi-instance support, porting to 8MHz processors, 8 | various optimizations, PROGMEM delay tables, inverse logic and 9 | direct port writing by Mikal Hart (http://www.arduiniana.org) 10 | -- Pin change interrupt macros by Paul Stoffregen (http://www.pjrc.com) 11 | -- 20MHz processor support by Garrett Mace (http://www.macetech.com) 12 | -- ATmega1280/2560 support by Brett Hagman (http://www.roguerobotics.com/) 13 | 14 | This library is free software; you can redistribute it and/or 15 | modify it under the terms of the GNU Lesser General Public 16 | License as published by the Free Software Foundation; either 17 | version 2.1 of the License, or (at your option) any later version. 18 | 19 | This library is distributed in the hope that it will be useful, 20 | but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | Lesser General Public License for more details. 23 | 24 | You should have received a copy of the GNU Lesser General Public 25 | License along with this library; if not, write to the Free Software 26 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 27 | 28 | The latest version of this library can always be found at 29 | http://arduiniana.org. 30 | */ 31 | 32 | #ifndef SoftwareSerial_h 33 | #define SoftwareSerial_h 34 | 35 | #include 36 | #include 37 | 38 | /****************************************************************************** 39 | * Definitions 40 | ******************************************************************************/ 41 | 42 | #ifndef _SS_MAX_RX_BUFF 43 | #define _SS_MAX_RX_BUFF 64 // RX buffer size 44 | #endif 45 | 46 | #ifndef GCC_VERSION 47 | #define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) 48 | #endif 49 | 50 | class SoftwareSerial : public Stream 51 | { 52 | private: 53 | // per object data 54 | uint8_t _receivePin; 55 | uint8_t _receiveBitMask; 56 | volatile uint8_t *_receivePortRegister; 57 | uint8_t _transmitBitMask; 58 | volatile uint8_t *_transmitPortRegister; 59 | volatile uint8_t *_pcint_maskreg; 60 | uint8_t _pcint_maskvalue; 61 | 62 | // Expressed as 4-cycle delays (must never be 0!) 63 | uint16_t _rx_delay_centering; 64 | uint16_t _rx_delay_intrabit; 65 | uint16_t _rx_delay_stopbit; 66 | uint16_t _tx_delay; 67 | 68 | uint16_t _buffer_overflow:1; 69 | uint16_t _inverse_logic:1; 70 | 71 | // static data 72 | static uint8_t _receive_buffer[_SS_MAX_RX_BUFF]; 73 | static volatile uint8_t _receive_buffer_tail; 74 | static volatile uint8_t _receive_buffer_head; 75 | static SoftwareSerial *active_object; 76 | 77 | // private methods 78 | inline void recv() __attribute__((__always_inline__)); 79 | uint8_t rx_pin_read(); 80 | void setTX(uint8_t transmitPin); 81 | void setRX(uint8_t receivePin); 82 | inline void setRxIntMsk(bool enable) __attribute__((__always_inline__)); 83 | 84 | // Return num - sub, or 1 if the result would be < 1 85 | static uint16_t subtract_cap(uint16_t num, uint16_t sub); 86 | 87 | // private static method for timing 88 | static inline void tunedDelay(uint16_t delay); 89 | 90 | public: 91 | // public methods 92 | SoftwareSerial(uint8_t receivePin, uint8_t transmitPin, bool inverse_logic = false); 93 | ~SoftwareSerial(); 94 | void begin(long speed); 95 | bool listen(); 96 | void end(); 97 | bool isListening() { return this == active_object; } 98 | bool stopListening(); 99 | bool overflow() { bool ret = _buffer_overflow; if (ret) _buffer_overflow = false; return ret; } 100 | int peek(); 101 | 102 | virtual size_t write(uint8_t byte); 103 | virtual int read(); 104 | virtual int available(); 105 | virtual void flush(); 106 | operator bool() { return true; } 107 | 108 | using Print::write; 109 | 110 | // public only for easy access by interrupt handlers 111 | static inline void handle_interrupt() __attribute__((__always_inline__)); 112 | }; 113 | 114 | #endif 115 | -------------------------------------------------------------------------------- /libraries/Wire/examples/SFRRanger_reader/SFRRanger_reader.ino: -------------------------------------------------------------------------------- 1 | // I2C SRF10 or SRF08 Devantech Ultrasonic Ranger Finder 2 | // by Nicholas Zambetti 3 | // and James Tichenor 4 | 5 | // Demonstrates use of the Wire library reading data from the 6 | // Devantech Ultrasonic Rangers SFR08 and SFR10 7 | 8 | // Created 29 April 2006 9 | 10 | // This example code is in the public domain. 11 | 12 | 13 | #include 14 | 15 | void setup() { 16 | Wire.begin(); // join I2C bus (address optional for master) 17 | Serial.begin(9600); // start serial communication at 9600 bps 18 | } 19 | 20 | int reading = 0; 21 | 22 | void loop() { 23 | // step 1: instruct sensor to read echoes 24 | Wire.beginTransmission(112); // transmit to device #112 (0x70) 25 | // the address specified in the datasheet is 224 (0xE0) 26 | // but I2C addressing uses the high 7 bits so it's 112 27 | Wire.write(byte(0x00)); // sets register pointer to the command register (0x00) 28 | Wire.write(byte(0x50)); // command sensor to measure in "inches" (0x50) 29 | // use 0x51 for centimeters 30 | // use 0x52 for ping microseconds 31 | Wire.endTransmission(); // stop transmitting 32 | 33 | // step 2: wait for readings to happen 34 | delay(70); // datasheet suggests at least 65 milliseconds 35 | 36 | // step 3: instruct sensor to return a particular echo reading 37 | Wire.beginTransmission(112); // transmit to device #112 38 | Wire.write(byte(0x02)); // sets register pointer to echo #1 register (0x02) 39 | Wire.endTransmission(); // stop transmitting 40 | 41 | // step 4: request reading from sensor 42 | Wire.requestFrom(112, 2); // request 2 bytes from slave device #112 43 | 44 | // step 5: receive reading from sensor 45 | if (2 <= Wire.available()) { // if two bytes were received 46 | reading = Wire.read(); // receive high byte (overwrites previous reading) 47 | reading = reading << 8; // shift high byte to be high 8 bits 48 | reading |= Wire.read(); // receive low byte as lower 8 bits 49 | Serial.println(reading); // print the reading 50 | } 51 | 52 | delay(250); // wait a bit since people have to read the output :) 53 | } 54 | 55 | 56 | /* 57 | 58 | // The following code changes the address of a Devantech Ultrasonic Range Finder (SRF10 or SRF08) 59 | // usage: changeAddress(0x70, 0xE6); 60 | 61 | void changeAddress(byte oldAddress, byte newAddress) 62 | { 63 | Wire.beginTransmission(oldAddress); 64 | Wire.write(byte(0x00)); 65 | Wire.write(byte(0xA0)); 66 | Wire.endTransmission(); 67 | 68 | Wire.beginTransmission(oldAddress); 69 | Wire.write(byte(0x00)); 70 | Wire.write(byte(0xAA)); 71 | Wire.endTransmission(); 72 | 73 | Wire.beginTransmission(oldAddress); 74 | Wire.write(byte(0x00)); 75 | Wire.write(byte(0xA5)); 76 | Wire.endTransmission(); 77 | 78 | Wire.beginTransmission(oldAddress); 79 | Wire.write(byte(0x00)); 80 | Wire.write(newAddress); 81 | Wire.endTransmission(); 82 | } 83 | 84 | */ 85 | -------------------------------------------------------------------------------- /libraries/Wire/examples/digital_potentiometer/digital_potentiometer.ino: -------------------------------------------------------------------------------- 1 | // I2C Digital Potentiometer 2 | // by Nicholas Zambetti 3 | // and Shawn Bonkowski 4 | 5 | // Demonstrates use of the Wire library 6 | // Controls AD5171 digital potentiometer via I2C/TWI 7 | 8 | // Created 31 March 2006 9 | 10 | // This example code is in the public domain. 11 | 12 | 13 | #include 14 | 15 | void setup() { 16 | Wire.begin(); // join I2C bus (address optional for master) 17 | } 18 | 19 | byte val = 0; 20 | 21 | void loop() { 22 | Wire.beginTransmission(44); // transmit to device #44 (0x2c) 23 | // device address is specified in datasheet 24 | Wire.write(byte(0x00)); // sends instruction byte 25 | Wire.write(val); // sends potentiometer value byte 26 | Wire.endTransmission(); // stop transmitting 27 | 28 | val++; // increment value 29 | if (val == 64) { // if reached 64th position (max) 30 | val = 0; // start over from lowest value 31 | } 32 | delay(500); 33 | } 34 | -------------------------------------------------------------------------------- /libraries/Wire/examples/i2c_scanner/i2c_scanner.ino: -------------------------------------------------------------------------------- 1 | // -------------------------------------- 2 | // i2c_scanner 3 | // 4 | // Version 1 5 | // This program (or code that looks like it) 6 | // can be found in many places. 7 | // For example on the Arduino.cc forum. 8 | // The original author is not known. 9 | // Version 2, Juni 2012, Using Arduino 1.0.1 10 | // Adapted to be as simple as possible by Arduino.cc user Krodal 11 | // Version 3, Feb 26 2013 12 | // V3 by louarnold 13 | // Version 4, March 3, 2013, Using Arduino 1.0.3 14 | // by Arduino.cc user Krodal. 15 | // Changes by louarnold removed. 16 | // Scanning addresses changed from 0...127 to 1...119, 17 | // according to the i2c scanner by Nick Gammon 18 | // https://www.gammon.com.au/forum/?id=10896 19 | // Version 5, March 28, 2013 20 | // As version 4, but address scans now to 127. 21 | // A sensor seems to use address 120. 22 | // Version 6, November 27, 2015. 23 | // Added waiting for the Leonardo serial communication. 24 | // 25 | // 26 | // This sketch tests the standard 7-bit addresses 27 | // Devices with higher bit address might not be seen properly. 28 | // 29 | 30 | #include 31 | 32 | void setup() { 33 | Wire.begin(); 34 | 35 | Serial.begin(9600); 36 | while (!Serial); // Leonardo: wait for Serial Monitor 37 | Serial.println("\nI2C Scanner"); 38 | } 39 | 40 | void loop() { 41 | int nDevices = 0; 42 | 43 | Serial.println("Scanning..."); 44 | 45 | for (byte address = 1; address < 127; ++address) { 46 | // The i2c_scanner uses the return value of 47 | // the Wire.endTransmission to see if 48 | // a device did acknowledge to the address. 49 | Wire.beginTransmission(address); 50 | byte error = Wire.endTransmission(); 51 | 52 | if (error == 0) { 53 | Serial.print("I2C device found at address 0x"); 54 | if (address < 16) { 55 | Serial.print("0"); 56 | } 57 | Serial.print(address, HEX); 58 | Serial.println(" !"); 59 | 60 | ++nDevices; 61 | } else if (error == 4) { 62 | Serial.print("Unknown error at address 0x"); 63 | if (address < 16) { 64 | Serial.print("0"); 65 | } 66 | Serial.println(address, HEX); 67 | } 68 | } 69 | if (nDevices == 0) { 70 | Serial.println("No I2C devices found\n"); 71 | } else { 72 | Serial.println("done\n"); 73 | } 74 | delay(5000); // Wait 5 seconds for next scan 75 | } 76 | -------------------------------------------------------------------------------- /libraries/Wire/examples/master_reader/master_reader.ino: -------------------------------------------------------------------------------- 1 | // Wire Master Reader 2 | // by Nicholas Zambetti 3 | 4 | // Demonstrates use of the Wire library 5 | // Reads data from an I2C/TWI slave device 6 | // Refer to the "Wire Slave Sender" example for use with this 7 | 8 | // Created 29 March 2006 9 | 10 | // This example code is in the public domain. 11 | 12 | 13 | #include 14 | 15 | void setup() { 16 | Wire.begin(); // join I2C bus (address optional for master) 17 | Serial.begin(9600); // start serial for output 18 | } 19 | 20 | void loop() { 21 | Wire.requestFrom(8, 6); // request 6 bytes from slave device #8 22 | 23 | while (Wire.available()) { // slave may send less than requested 24 | char c = Wire.read(); // receive a byte as character 25 | Serial.print(c); // print the character 26 | } 27 | 28 | delay(500); 29 | } 30 | -------------------------------------------------------------------------------- /libraries/Wire/examples/master_writer/master_writer.ino: -------------------------------------------------------------------------------- 1 | // Wire Master Writer 2 | // by Nicholas Zambetti 3 | 4 | // Demonstrates use of the Wire library 5 | // Writes data to an I2C/TWI slave device 6 | // Refer to the "Wire Slave Receiver" example for use with this 7 | 8 | // Created 29 March 2006 9 | 10 | // This example code is in the public domain. 11 | 12 | 13 | #include 14 | 15 | void setup() { 16 | Wire.begin(); // join I2C bus (address optional for master) 17 | } 18 | 19 | byte x = 0; 20 | 21 | void loop() { 22 | Wire.beginTransmission(8); // transmit to device #8 23 | Wire.write("x is "); // sends five bytes 24 | Wire.write(x); // sends one byte 25 | Wire.endTransmission(); // stop transmitting 26 | 27 | x++; 28 | delay(500); 29 | } 30 | -------------------------------------------------------------------------------- /libraries/Wire/examples/slave_receiver/slave_receiver.ino: -------------------------------------------------------------------------------- 1 | // Wire Slave Receiver 2 | // by Nicholas Zambetti 3 | 4 | // Demonstrates use of the Wire library 5 | // Receives data as an I2C/TWI slave device 6 | // Refer to the "Wire Master Writer" example for use with this 7 | 8 | // Created 29 March 2006 9 | 10 | // This example code is in the public domain. 11 | 12 | 13 | #include 14 | 15 | void setup() { 16 | Wire.begin(8); // join I2C bus with address #8 17 | Wire.onReceive(receiveEvent); // register event 18 | Serial.begin(9600); // start serial for output 19 | } 20 | 21 | void loop() { 22 | delay(100); 23 | } 24 | 25 | // function that executes whenever data is received from master 26 | // this function is registered as an event, see setup() 27 | void receiveEvent(int howMany) { 28 | while (1 < Wire.available()) { // loop through all but the last 29 | char c = Wire.read(); // receive byte as a character 30 | Serial.print(c); // print the character 31 | } 32 | int x = Wire.read(); // receive byte as an integer 33 | Serial.println(x); // print the integer 34 | } 35 | -------------------------------------------------------------------------------- /libraries/Wire/examples/slave_sender/slave_sender.ino: -------------------------------------------------------------------------------- 1 | // Wire Slave Sender 2 | // by Nicholas Zambetti 3 | 4 | // Demonstrates use of the Wire library 5 | // Sends data as an I2C/TWI slave device 6 | // Refer to the "Wire Master Reader" example for use with this 7 | 8 | // Created 29 March 2006 9 | 10 | // This example code is in the public domain. 11 | 12 | 13 | #include 14 | 15 | void setup() { 16 | Wire.begin(8); // join I2C bus with address #8 17 | Wire.onRequest(requestEvent); // register event 18 | } 19 | 20 | void loop() { 21 | delay(100); 22 | } 23 | 24 | // function that executes whenever data is requested by master 25 | // this function is registered as an event, see setup() 26 | void requestEvent() { 27 | Wire.write("hello "); // respond with message of 6 bytes 28 | // as expected by master 29 | } 30 | -------------------------------------------------------------------------------- /libraries/Wire/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For Wire 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | Wire KEYWORD1 10 | 11 | ####################################### 12 | # Methods and Functions (KEYWORD2) 13 | ####################################### 14 | 15 | begin KEYWORD2 16 | setClock KEYWORD2 17 | beginTransmission KEYWORD2 18 | endTransmission KEYWORD2 19 | requestFrom KEYWORD2 20 | onReceive KEYWORD2 21 | onRequest KEYWORD2 22 | 23 | ####################################### 24 | # Constants (LITERAL1) 25 | ####################################### 26 | 27 | -------------------------------------------------------------------------------- /libraries/Wire/library.properties: -------------------------------------------------------------------------------- 1 | name=Wire 2 | version=1.0 3 | author=Arduino 4 | maintainer=Arduino 5 | sentence=This library allows you to communicate with I2C and Two Wire Interface devices. 6 | paragraph=It allows the communication with I2C devices like temperature sensors, realtime clocks and many others using SDA (Data Line) and SCL (Clock Line). 7 | category=Communication 8 | url=http://www.arduino.cc/en/Reference/Wire 9 | architectures=avr 10 | 11 | -------------------------------------------------------------------------------- /libraries/Wire/src/Wire.h: -------------------------------------------------------------------------------- 1 | /* 2 | TwoWire.h - TWI/I2C library for Arduino & Wiring 3 | Copyright (c) 2006 Nicholas Zambetti. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Modified 2012 by Todd Krein (todd@krein.org) to implement repeated starts 20 | Modified 2020 by Greyson Christoforo (grey@christoforo.net) to implement timeouts 21 | */ 22 | 23 | #ifndef TwoWire_h 24 | #define TwoWire_h 25 | 26 | #include 27 | #include "Stream.h" 28 | 29 | #define BUFFER_LENGTH 32 30 | 31 | // WIRE_HAS_END means Wire has end() 32 | #define WIRE_HAS_END 1 33 | 34 | class TwoWire : public Stream 35 | { 36 | private: 37 | static uint8_t rxBuffer[]; 38 | static uint8_t rxBufferIndex; 39 | static uint8_t rxBufferLength; 40 | 41 | static uint8_t txAddress; 42 | static uint8_t txBuffer[]; 43 | static uint8_t txBufferIndex; 44 | static uint8_t txBufferLength; 45 | 46 | static uint8_t transmitting; 47 | static void (*user_onRequest)(void); 48 | static void (*user_onReceive)(int); 49 | static void onRequestService(void); 50 | static void onReceiveService(uint8_t*, int); 51 | public: 52 | TwoWire(); 53 | void begin(); 54 | void begin(uint8_t); 55 | void begin(int); 56 | void end(); 57 | void setClock(uint32_t); 58 | void setWireTimeout(uint32_t timeout = 25000, bool reset_with_timeout = false); 59 | bool getWireTimeoutFlag(void); 60 | void clearWireTimeoutFlag(void); 61 | void beginTransmission(uint8_t); 62 | void beginTransmission(int); 63 | uint8_t endTransmission(void); 64 | uint8_t endTransmission(uint8_t); 65 | uint8_t requestFrom(uint8_t, uint8_t); 66 | uint8_t requestFrom(uint8_t, uint8_t, uint8_t); 67 | uint8_t requestFrom(uint8_t, uint8_t, uint32_t, uint8_t, uint8_t); 68 | uint8_t requestFrom(int, int); 69 | uint8_t requestFrom(int, int, int); 70 | virtual size_t write(uint8_t); 71 | virtual size_t write(const uint8_t *, size_t); 72 | virtual int available(void); 73 | virtual int read(void); 74 | virtual int peek(void); 75 | virtual void flush(void); 76 | void onReceive( void (*)(int) ); 77 | void onRequest( void (*)(void) ); 78 | 79 | inline size_t write(unsigned long n) { return write((uint8_t)n); } 80 | inline size_t write(long n) { return write((uint8_t)n); } 81 | inline size_t write(unsigned int n) { return write((uint8_t)n); } 82 | inline size_t write(int n) { return write((uint8_t)n); } 83 | using Print::write; 84 | }; 85 | 86 | extern TwoWire Wire; 87 | 88 | #endif 89 | 90 | -------------------------------------------------------------------------------- /libraries/Wire/src/utility/twi.h: -------------------------------------------------------------------------------- 1 | /* 2 | twi.h - TWI/I2C library for Wiring & Arduino 3 | Copyright (c) 2006 Nicholas Zambetti. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Modified 2020 by Greyson Christoforo (grey@christoforo.net) to implement timeouts 20 | */ 21 | 22 | #ifndef twi_h 23 | #define twi_h 24 | 25 | #include 26 | 27 | //#define ATMEGA8 28 | 29 | #ifndef TWI_FREQ 30 | #define TWI_FREQ 100000L 31 | #endif 32 | 33 | #ifndef TWI_BUFFER_LENGTH 34 | #define TWI_BUFFER_LENGTH 32 35 | #endif 36 | 37 | #define TWI_READY 0 38 | #define TWI_MRX 1 39 | #define TWI_MTX 2 40 | #define TWI_SRX 3 41 | #define TWI_STX 4 42 | 43 | void twi_init(void); 44 | void twi_disable(void); 45 | void twi_setAddress(uint8_t); 46 | void twi_setFrequency(uint32_t); 47 | uint8_t twi_readFrom(uint8_t, uint8_t*, uint8_t, uint8_t); 48 | uint8_t twi_writeTo(uint8_t, uint8_t*, uint8_t, uint8_t, uint8_t); 49 | uint8_t twi_transmit(const uint8_t*, uint8_t); 50 | void twi_attachSlaveRxEvent( void (*)(uint8_t*, int) ); 51 | void twi_attachSlaveTxEvent( void (*)(void) ); 52 | void twi_reply(uint8_t); 53 | void twi_stop(void); 54 | void twi_releaseBus(void); 55 | void twi_setTimeoutInMicros(uint32_t, bool); 56 | void twi_handleTimeout(bool); 57 | bool twi_manageTimeoutFlag(bool); 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /post_install.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | set ARGS=/LM /SW /SA 3 | if "%PROCESSOR_ARCHITECTURE%" == "AMD64" ( 4 | drivers\dpinst-amd64.exe %ARGS% 5 | ) ELSE IF "%PROCESSOR_ARCHITEW6432%" == "AMD64" ( 6 | drivers\dpinst-amd64.exe %ARGS% 7 | ) ELSE ( 8 | drivers\dpinst-x86.exe %ARGS% 9 | ) 10 | 11 | REM dpinst /PATH has problems with relative paths, so use absolute path. 12 | if "%PROCESSOR_ARCHITECTURE%" == "AMD64" ( 13 | drivers\dpinst-amd64.exe /PATH "%cd%\drivers\gemma" %ARGS% 14 | ) ELSE IF "%PROCESSOR_ARCHITEW6432%" == "AMD64" ( 15 | drivers\dpinst-amd64.exe /PATH "%cd%\drivers\gemma" %ARGS% 16 | ) ELSE ( 17 | drivers\dpinst-x86.exe /PATH "%cd%\drivers\gemma" %ARGS% 18 | ) 19 | 20 | exit /b 0 21 | -------------------------------------------------------------------------------- /variants/micro/pins_arduino.h: -------------------------------------------------------------------------------- 1 | /* 2 | pins_arduino.h - Pin definition functions for Arduino 3 | Part of Arduino - http://www.arduino.cc/ 4 | 5 | Copyright (c) 2007 David A. Mellis 6 | 7 | This library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public 9 | License as published by the Free Software Foundation; either 10 | version 2.1 of the License, or (at your option) any later version. 11 | 12 | This library is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General 18 | Public License along with this library; if not, write to the 19 | Free Software Foundation, Inc., 59 Temple Place, Suite 330, 20 | Boston, MA 02111-1307 USA 21 | */ 22 | 23 | #include "../leonardo/pins_arduino.h" 24 | 25 | #undef TXLED0 26 | #undef TXLED1 27 | #undef RXLED0 28 | #undef RXLED1 29 | #undef TX_RX_LED_INIT 30 | 31 | #define TXLED0 PORTD &= ~(1<<5) 32 | #define TXLED1 PORTD |= (1<<5) 33 | #define RXLED0 PORTB &= ~(1<<0) 34 | #define RXLED1 PORTB |= (1<<0) 35 | #define TX_RX_LED_INIT DDRD |= (1<<5), DDRB |= (1<<0), TXLED0, RXLED0 36 | -------------------------------------------------------------------------------- /variants/yun/pins_arduino.h: -------------------------------------------------------------------------------- 1 | /* 2 | pins_arduino.h - Pin definition functions for Arduino 3 | Part of Arduino - http://www.arduino.cc/ 4 | 5 | Copyright (c) 2013 Arduino LLC 6 | 7 | This library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public 9 | License as published by the Free Software Foundation; either 10 | version 2.1 of the License, or (at your option) any later version. 11 | 12 | This library is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General 18 | Public License along with this library; if not, write to the 19 | Free Software Foundation, Inc., 59 Temple Place, Suite 330, 20 | Boston, MA 02111-1307 USA 21 | */ 22 | 23 | #include "../leonardo/pins_arduino.h" 24 | 25 | // These serial port names are intended to allow libraries and architecture-neutral 26 | // sketches to automatically default to the correct port name for a particular type 27 | // of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, 28 | // the first hardware serial port whose RX/TX pins are not dedicated to another use. 29 | // 30 | // SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor 31 | // 32 | // SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial 33 | // 34 | // SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library 35 | // 36 | // SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins. 37 | // 38 | // SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX 39 | // pins are NOT connected to anything by default. 40 | #define SERIAL_PORT_LINUXBRIDGE Serial1 41 | 42 | // defined in the Leonardo variant 43 | #undef SERIAL_PORT_HARDWARE_OPEN 44 | 45 | --------------------------------------------------------------------------------