├── arduino └── mini_sam │ └── hardware │ └── samd │ ├── 1.0.0 │ ├── CHANGELOG │ ├── VARIANT_COMPLIANCE_CHANGELOG │ ├── bootloaders │ │ └── mini_sam │ │ │ ├── README.md │ │ │ └── samd21_sam_ba_mini_sam.bin │ ├── post_install.bat │ ├── variants │ │ └── mini_sam │ │ │ ├── pins_arduino.h │ │ │ ├── openocd_scripts │ │ │ └── samd21e18a.cfg │ │ │ └── debug_scripts │ │ │ └── samd21e18a.gdb │ ├── programmers.txt │ ├── boards.txt │ └── README.md │ └── 2.0.0 │ ├── drivers │ ├── cdc_vista.cat │ ├── dpinst-x86.exe │ ├── arduino-samd.cat │ ├── dpinst-amd64.exe │ └── genuino-samd.cat │ ├── cores │ └── arduino │ │ ├── SERCOM.cpp │ │ ├── avr │ │ ├── interrupt.h │ │ ├── dtostrf.h │ │ ├── dtostrf.c │ │ └── io.h │ │ ├── wiring.h │ │ ├── Tone.h │ │ ├── Reset.h │ │ ├── Server.h │ │ ├── new.cpp │ │ ├── WMath.h │ │ ├── wiring_private.h │ │ ├── itoa.h │ │ ├── wiring_shift.h │ │ ├── abi.cpp │ │ ├── Printable.h │ │ ├── pulse.h │ │ ├── main.cpp │ │ ├── WInterrupts.h │ │ ├── USB │ │ ├── USBDesc.h │ │ ├── PluggableUSB.h │ │ └── USB_host.h │ │ ├── RingBuffer.h │ │ ├── Client.h │ │ ├── WMath.cpp │ │ ├── hooks.c │ │ ├── wiring_constants.h │ │ ├── Uart.h │ │ ├── wiring_shift.c │ │ ├── RingBuffer.cpp │ │ ├── pulse.c │ │ ├── wiring_analog.h │ │ ├── Reset.cpp │ │ ├── delay.c │ │ ├── Print.h │ │ ├── wiring_digital.h │ │ └── IPAddress.h │ ├── bootloaders │ └── zero_osc32k │ │ ├── samd21_sam_ba.bin │ │ ├── board_driver_led.c │ │ ├── samd21_sam_ba.atsln │ │ ├── board_driver_usb.h │ │ ├── sam_ba_monitor.h │ │ ├── ATMEL │ │ ├── samd.h │ │ ├── samr.h │ │ ├── samr21 │ │ │ ├── include │ │ │ │ ├── samr21.h │ │ │ │ ├── system_samr21.h │ │ │ │ └── instance │ │ │ │ │ ├── rfctrl.h │ │ │ │ │ ├── pac0.h │ │ │ │ │ ├── pac1.h │ │ │ │ │ └── pac2.h │ │ │ └── source │ │ │ │ └── system_samr21.c │ │ └── samd21 │ │ │ ├── include │ │ │ ├── system_samd21.h │ │ │ └── instance │ │ │ │ ├── pac0.h │ │ │ │ ├── pac1.h │ │ │ │ └── pac2.h │ │ │ └── source │ │ │ └── system_samd21.c │ │ ├── board_driver_led.h │ │ ├── sam_ba_cdc.h │ │ ├── README.md │ │ ├── sam_ba_cdc.c │ │ └── board_driver_serial.h │ ├── post_install.bat │ ├── libraries │ ├── HID │ │ ├── library.properties │ │ └── keywords.txt │ ├── SAMD_AnalogCorrection │ │ ├── library.properties │ │ └── src │ │ │ ├── SAMD_AnalogCorrection.h │ │ │ └── SAMD_AnalogCorrection.cpp │ ├── I2S │ │ ├── library.properties │ │ ├── keywords.txt │ │ ├── examples │ │ │ ├── InputSerialPlotter │ │ │ │ └── InputSerialPlotter.ino │ │ │ └── SimpleTone │ │ │ │ └── SimpleTone.ino │ │ └── src │ │ │ └── utility │ │ │ ├── I2SDoubleBuffer.h │ │ │ ├── DMA.h │ │ │ └── I2SDoubleBuffer.cpp │ ├── SPI │ │ ├── library.properties │ │ ├── keywords.txt │ │ └── examples │ │ │ └── DigitalPotControl │ │ │ └── DigitalPotControl.ino │ ├── Wire │ │ ├── library.properties │ │ ├── examples │ │ │ ├── master_writer │ │ │ │ └── master_writer.ino │ │ │ ├── slave_sender │ │ │ │ └── slave_sender.ino │ │ │ ├── master_reader │ │ │ │ └── master_reader.ino │ │ │ ├── slave_receiver │ │ │ │ └── slave_receiver.ino │ │ │ ├── digital_potentiometer │ │ │ │ └── digital_potentiometer.ino │ │ │ └── SFRRanger_reader │ │ │ │ └── SFRRanger_reader.ino │ │ └── keywords.txt │ └── USBHost │ │ ├── library.properties │ │ ├── keywords.txt │ │ ├── src │ │ ├── Usb.h │ │ ├── sink_parser.h │ │ ├── KeyboardController.cpp │ │ ├── KeyboardController.h │ │ ├── MouseController.h │ │ ├── parsetools.cpp │ │ ├── hexdump.h │ │ ├── printhex.h │ │ ├── MouseController.cpp │ │ └── message.h │ │ └── examples │ │ ├── ADKTerminalTest │ │ └── ADKTerminalTest.ino │ │ ├── KeyboardController │ │ └── KeyboardController.ino │ │ ├── MouseController │ │ └── MouseController.ino │ │ └── USB_desc │ │ └── pgmstrings.h │ ├── VARIANT_COMPLIANCE_CHANGELOG │ ├── variants │ └── mini_sam │ │ ├── pins_arduino.h │ │ ├── openocd_scripts │ │ └── samd21e18a.cfg │ │ └── debug_scripts │ │ └── variant.gdb │ ├── programmers.txt │ └── boards.txt ├── MINI_Sam_2016_09_28_003.pdf ├── MINI_Sam_2016_10_24_002.pdf ├── BOM Minifigure-SAMD21E OCT 6 BOARD.pdf ├── board ├── 2017 │ └── 01 │ │ ├── MINI_SAM_2017-01-002.pdf │ │ ├── MINI_SAM_2017-01-010.pdf │ │ ├── MINI_SAM_2017-01-012.pdf │ │ └── MINI_SAM_2017-01-015.pdf └── README.md ├── circuitpython ├── mini_sam_m0 │ ├── firmware.bin │ ├── firmware.uf2 │ ├── readme.md │ ├── mpconfigboard.mk │ ├── mpconfigboard.h │ ├── board.c │ └── pins.c └── boardpins.txt ├── MINI_SAM_TQFP_2.54_BB_2017_01_12_001.pdf ├── MINI_SAM_TQFP_2.54_BB_2017_01_17_004.pdf ├── MINI_SAM_TQFP_1.27_SIMPLE_2016_12_12_001.pdf └── MINI_SAM_TQFP_8-Pin_SIMPLE_2016_12_09_001.pdf /arduino/mini_sam/hardware/samd/1.0.0/CHANGELOG: -------------------------------------------------------------------------------- 1 | MINI SAM 1.0.0 2017.01.24 2 | 3 | * First public release. 4 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/1.0.0/VARIANT_COMPLIANCE_CHANGELOG: -------------------------------------------------------------------------------- 1 | MINI SAM 1.0.0 2 | 3 | Initial Release 4 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/1.0.0/bootloaders/mini_sam/README.md: -------------------------------------------------------------------------------- 1 | #Bootloader files for Mini SAM - Compiled. 2 | -------------------------------------------------------------------------------- /MINI_Sam_2016_09_28_003.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bwshockley/Minifigure-SAMD21E/HEAD/MINI_Sam_2016_09_28_003.pdf -------------------------------------------------------------------------------- /MINI_Sam_2016_10_24_002.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bwshockley/Minifigure-SAMD21E/HEAD/MINI_Sam_2016_10_24_002.pdf -------------------------------------------------------------------------------- /BOM Minifigure-SAMD21E OCT 6 BOARD.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bwshockley/Minifigure-SAMD21E/HEAD/BOM Minifigure-SAMD21E OCT 6 BOARD.pdf -------------------------------------------------------------------------------- /board/2017/01/MINI_SAM_2017-01-002.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bwshockley/Minifigure-SAMD21E/HEAD/board/2017/01/MINI_SAM_2017-01-002.pdf -------------------------------------------------------------------------------- /board/2017/01/MINI_SAM_2017-01-010.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bwshockley/Minifigure-SAMD21E/HEAD/board/2017/01/MINI_SAM_2017-01-010.pdf -------------------------------------------------------------------------------- /board/2017/01/MINI_SAM_2017-01-012.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bwshockley/Minifigure-SAMD21E/HEAD/board/2017/01/MINI_SAM_2017-01-012.pdf -------------------------------------------------------------------------------- /board/2017/01/MINI_SAM_2017-01-015.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bwshockley/Minifigure-SAMD21E/HEAD/board/2017/01/MINI_SAM_2017-01-015.pdf -------------------------------------------------------------------------------- /circuitpython/mini_sam_m0/firmware.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bwshockley/Minifigure-SAMD21E/HEAD/circuitpython/mini_sam_m0/firmware.bin -------------------------------------------------------------------------------- /circuitpython/mini_sam_m0/firmware.uf2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bwshockley/Minifigure-SAMD21E/HEAD/circuitpython/mini_sam_m0/firmware.uf2 -------------------------------------------------------------------------------- /MINI_SAM_TQFP_2.54_BB_2017_01_12_001.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bwshockley/Minifigure-SAMD21E/HEAD/MINI_SAM_TQFP_2.54_BB_2017_01_12_001.pdf -------------------------------------------------------------------------------- /MINI_SAM_TQFP_2.54_BB_2017_01_17_004.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bwshockley/Minifigure-SAMD21E/HEAD/MINI_SAM_TQFP_2.54_BB_2017_01_17_004.pdf -------------------------------------------------------------------------------- /MINI_SAM_TQFP_1.27_SIMPLE_2016_12_12_001.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bwshockley/Minifigure-SAMD21E/HEAD/MINI_SAM_TQFP_1.27_SIMPLE_2016_12_12_001.pdf -------------------------------------------------------------------------------- /MINI_SAM_TQFP_8-Pin_SIMPLE_2016_12_09_001.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bwshockley/Minifigure-SAMD21E/HEAD/MINI_SAM_TQFP_8-Pin_SIMPLE_2016_12_09_001.pdf -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/drivers/cdc_vista.cat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bwshockley/Minifigure-SAMD21E/HEAD/arduino/mini_sam/hardware/samd/2.0.0/drivers/cdc_vista.cat -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/drivers/dpinst-x86.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bwshockley/Minifigure-SAMD21E/HEAD/arduino/mini_sam/hardware/samd/2.0.0/drivers/dpinst-x86.exe -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/cores/arduino/SERCOM.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bwshockley/Minifigure-SAMD21E/HEAD/arduino/mini_sam/hardware/samd/2.0.0/cores/arduino/SERCOM.cpp -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/drivers/arduino-samd.cat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bwshockley/Minifigure-SAMD21E/HEAD/arduino/mini_sam/hardware/samd/2.0.0/drivers/arduino-samd.cat -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/drivers/dpinst-amd64.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bwshockley/Minifigure-SAMD21E/HEAD/arduino/mini_sam/hardware/samd/2.0.0/drivers/dpinst-amd64.exe -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/drivers/genuino-samd.cat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bwshockley/Minifigure-SAMD21E/HEAD/arduino/mini_sam/hardware/samd/2.0.0/drivers/genuino-samd.cat -------------------------------------------------------------------------------- /board/README.md: -------------------------------------------------------------------------------- 1 | #EAGLE Files 2 | At this time I only have EAGLE files for the Minifigure Board. If someone wants to convert them to KiCAD, I'd be happy to add those files to the repository. 3 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/bootloaders/zero_osc32k/samd21_sam_ba.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bwshockley/Minifigure-SAMD21E/HEAD/arduino/mini_sam/hardware/samd/2.0.0/bootloaders/zero_osc32k/samd21_sam_ba.bin -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/1.0.0/bootloaders/mini_sam/samd21_sam_ba_mini_sam.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bwshockley/Minifigure-SAMD21E/HEAD/arduino/mini_sam/hardware/samd/1.0.0/bootloaders/mini_sam/samd21_sam_ba_mini_sam.bin -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/post_install.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | set ARGS=/A /SE /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 | exit /b 0 11 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/1.0.0/post_install.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | set ARGS=/A /SE /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 | exit /b 0 11 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/libraries/HID/library.properties: -------------------------------------------------------------------------------- 1 | name=HID 2 | version=1.0 3 | author=Arduino 4 | maintainer=Arduino 5 | sentence=Module for PluggableUSB infrastructure. Exposes an API for devices like Keyboards, Mice and Gamepads 6 | paragraph= 7 | category=Other 8 | url=http://www.arduino.cc/en/Reference/HID 9 | architectures=samd 10 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/libraries/SAMD_AnalogCorrection/library.properties: -------------------------------------------------------------------------------- 1 | name=SAMD_AnalogCorrection 2 | version=1.0 3 | author=Arduino 4 | maintainer=Arduino 5 | sentence=Sets and enables the digital correction logic of the SAMD ADC. 6 | paragraph=Useful to correct the values returned by the ADC. 7 | category=Other 8 | url= 9 | architectures=samd 10 | -------------------------------------------------------------------------------- /circuitpython/mini_sam_m0/readme.md: -------------------------------------------------------------------------------- 1 | # Mini Sam M0 CircuitPython Firmware 2 | 3 | ## Source Files 4 | Source Files Included: 5 | - board.c 6 | - mpconfigboard.h 7 | - mpconfigboard.mk 8 | - pins.c 9 | 10 | Use these files and https://circuitpython.readthedocs.io/en/latest/ports/atmel-samd/README.html to build firmware. 11 | 12 | ## Built Firmware 13 | - firmware.bin 14 | - firmware.uf2 15 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/libraries/I2S/library.properties: -------------------------------------------------------------------------------- 1 | name=I2S 2 | version=1.0 3 | author=Arduino 4 | maintainer=Arduino 5 | sentence=Enables the communication with devices that use the Inter-IC Sound (I2S) Bus. Specific implementation for Arduino Zero. 6 | paragraph= 7 | category=Communication 8 | url=http://www.arduino.cc/en/Reference/I2S 9 | architectures=samd 10 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/libraries/SPI/library.properties: -------------------------------------------------------------------------------- 1 | name=SPI 2 | version=1.0 3 | author=Jonathan BAUDIN, Thibaut VIARD, Arduino 4 | maintainer=Arduino 5 | sentence=Enables the communication with devices that use the Serial Peripheral Interface (SPI) Bus. Specific implementation for Arduino Zero. 6 | paragraph= 7 | category=Communication 8 | url=http://www.arduino.cc/en/Reference/SPI 9 | architectures=samd 10 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/libraries/Wire/library.properties: -------------------------------------------------------------------------------- 1 | name=Wire 2 | version=1.0 3 | author=Jonathan BAUDIN, Thibaut VIARD, Arduino 4 | maintainer=Arduino 5 | sentence=Allows the communication between devices or sensors connected via Two Wire Interface Bus. Specific implementation for Arduino Zero. 6 | paragraph= 7 | category=Communication 8 | url=http://www.arduino.cc/en/Reference/Wire 9 | architectures=samd 10 | -------------------------------------------------------------------------------- /circuitpython/mini_sam_m0/mpconfigboard.mk: -------------------------------------------------------------------------------- 1 | LD_FILE = boards/samd21x18-bootloader.ld 2 | USB_VID = 0x1209 3 | USB_PID = 0x2017 4 | USB_PRODUCT = "Mini SAM M0" 5 | USB_MANUFACTURER = "Benjamin Shockley" 6 | 7 | INTERNAL_FLASH_FILESYSTEM = 1 8 | LONGINT_IMPL = NONE 9 | 10 | CHIP_VARIANT = SAMD21E18A 11 | CHIP_FAMILY = samd21 12 | 13 | # Include these Python libraries in firmware. 14 | FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel 15 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/VARIANT_COMPLIANCE_CHANGELOG: -------------------------------------------------------------------------------- 1 | SAMD CORE 1.6.10 2 | 3 | * The linker script must define `__text_start__` symbol at the beginning of .text section. 4 | This symbol is used to automatically determine the bootloader size. 5 | 6 | SAMD CORE 1.6.6 7 | 8 | * `digitalPinToInterrupt` #define moved to Arduino.h, variant.h must no longer define it. 9 | 10 | SAMD CORE 1.6.3 11 | 12 | * Timer for pin PWM selected based on value of `PIN_ATTR_TIMER_ALT` or `PIN_ATTR_TIMER`. 13 | Prior to this "pin type" (ulPinType) was used. 14 | -------------------------------------------------------------------------------- /circuitpython/boardpins.txt: -------------------------------------------------------------------------------- 1 | PIN mini_sam_m0 2 | PA00 3 | PA01 4 | PA02 ~A0 5 | PA03 6 | PB08 7 | PB09 8 | PA04 ~A3 9 | PA05 ~A4 10 | PA06 ~A1 11 | PA07 ~A2 12 | PA08 ~A5 13 | PA09 A6 14 | PA10 D1 / TX 15 | PA11 D0 / RX 16 | PB10 17 | PB11 18 | PA12 19 | PA13 20 | PA14 D14 21 | PA15 LED / D15 22 | PA16 MOSI 23 | PA17 SCK 24 | PA18 SS / D18 25 | PA19 MISO 26 | PA20 27 | PA21 28 | PA22 SDA 29 | PA23 SCL 30 | PA24 31 | PA25 32 | PB22 33 | PB23 34 | PA27 NEOPIXEL / D27 35 | PA28 BUTTON / D28 36 | PA29 37 | PA30 38 | PA31 39 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/libraries/USBHost/library.properties: -------------------------------------------------------------------------------- 1 | name=USBHost 2 | version=1.0 3 | author=Arduino 4 | maintainer=Arduino 5 | sentence=Allows the communication with USB peripherals like mice, keyboards, and thumbdrives. For Arduino MKR1000 and Zero. 6 | paragraph=The USBHost library allows the board to appear as a USB host, enabling it to communicate with peripherals like USB mice and keyboards. USBHost does not support devices that are connected through USB hubs. This includes some keyboards that have an internal hub. 7 | category=Other 8 | url=http://arduino.cc/en/Reference/USBHost 9 | architectures=samd 10 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/libraries/HID/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map HID 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | HID KEYWORD1 10 | 11 | ####################################### 12 | # Methods and Functions (KEYWORD2) 13 | ####################################### 14 | begin KEYWORD2 15 | SendReport KEYWORD2 16 | AppendDescriptor KEYWORD2 17 | 18 | ####################################### 19 | # Constants (LITERAL1) 20 | ####################################### 21 | HID_TX LITERAL1 -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/libraries/I2S/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map I2S 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | I2S KEYWORD1 10 | 11 | ####################################### 12 | # Methods and Functions (KEYWORD2) 13 | ####################################### 14 | begin KEYWORD2 15 | end KEYWORD2 16 | 17 | onReceive KEYWORD2 18 | onTransmit KEYWORD2 19 | 20 | ####################################### 21 | # Constants (LITERAL1) 22 | ####################################### 23 | I2S_PHILIPS_MODE LITERAL1 24 | I2S_RIGHT_JUSTIFIED_MODE LITERAL1 25 | I2S_LEFT_JUSTIFIED_MODE LITERAL1 26 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/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 | { 17 | Wire.begin(); // join i2c bus (address optional for master) 18 | } 19 | 20 | byte x = 0; 21 | 22 | void loop() 23 | { 24 | Wire.beginTransmission(4); // transmit to device #4 25 | Wire.write("x is "); // sends five bytes 26 | Wire.write(x); // sends one byte 27 | Wire.endTransmission(); // stop transmitting 28 | 29 | x++; 30 | delay(500); 31 | } 32 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/libraries/SPI/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map 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_MODE0 LITERAL1 26 | SPI_MODE1 LITERAL1 27 | SPI_MODE2 LITERAL1 28 | SPI_MODE3 LITERAL1 29 | 30 | SPI_CONTINUE LITERAL1 31 | SPI_LAST LITERAL1 32 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/libraries/Wire/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For Wire 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | ####################################### 10 | # Methods and Functions (KEYWORD2) 11 | ####################################### 12 | 13 | begin KEYWORD2 14 | beginTransmission KEYWORD2 15 | endTransmission KEYWORD2 16 | requestFrom KEYWORD2 17 | onReceive KEYWORD2 18 | onRequest KEYWORD2 19 | 20 | ####################################### 21 | # Instances (KEYWORD2) 22 | ####################################### 23 | 24 | Wire KEYWORD2 25 | Wire1 KEYWORD2 26 | 27 | ####################################### 28 | # Constants (LITERAL1) 29 | ####################################### 30 | 31 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/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 | { 17 | Wire.begin(2); // join i2c bus with address #2 18 | Wire.onRequest(requestEvent); // register event 19 | } 20 | 21 | void loop() 22 | { 23 | delay(100); 24 | } 25 | 26 | // function that executes whenever data is requested by master 27 | // this function is registered as an event, see setup() 28 | void requestEvent() 29 | { 30 | Wire.write("hello "); // respond with message of 6 bytes 31 | // as expected by master 32 | } 33 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/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 | { 17 | Wire.begin(); // join i2c bus (address optional for master) 18 | Serial.begin(9600); // start serial for output 19 | } 20 | 21 | void loop() 22 | { 23 | Wire.requestFrom(2, 6); // request 6 bytes from slave device #2 24 | 25 | while(Wire.available()) // slave may send less than requested 26 | { 27 | char c = Wire.read(); // receive a byte as character 28 | Serial.print(c); // print the character 29 | } 30 | 31 | delay(500); 32 | } 33 | -------------------------------------------------------------------------------- /circuitpython/mini_sam_m0/mpconfigboard.h: -------------------------------------------------------------------------------- 1 | // LEDs 2 | //#define MICROPY_HW_LED_MSC PIN_PA15 // red 3 | 4 | #define MICROPY_HW_BOARD_NAME "Mini Sam M0" 5 | #define MICROPY_HW_MCU_NAME "samd21e18" 6 | 7 | #define MICROPY_PORT_A (PORT_PA24 | PORT_PA25) 8 | #define MICROPY_PORT_B (0) 9 | #define MICROPY_PORT_C (0) 10 | 11 | #include "internal_flash.h" 12 | 13 | #define CIRCUITPY_INTERNAL_NVM_SIZE 0 14 | 15 | #define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000) 16 | 17 | #define DEFAULT_I2C_BUS_SCL (&pin_PA23) 18 | #define DEFAULT_I2C_BUS_SDA (&pin_PA22) 19 | 20 | #define DEFAULT_SPI_BUS_SCK (&pin_PA17) 21 | #define DEFAULT_SPI_BUS_MOSI (&pin_PA16) 22 | #define DEFAULT_SPI_BUS_MISO (&pin_PA19) 23 | 24 | #define DEFAULT_UART_BUS_RX (&pin_PA11) 25 | #define DEFAULT_UART_BUS_TX (&pin_PA10) 26 | 27 | // USB is always used internally so skip the pin objects for it. 28 | #define IGNORE_PIN_PA24 1 29 | #define IGNORE_PIN_PA25 1 30 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/1.0.0/variants/mini_sam/pins_arduino.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014-2015 Arduino LLC. 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 | // API compatibility 20 | #include "variant.h" 21 | 22 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/variants/mini_sam/pins_arduino.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014-2015 Arduino LLC. 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 | // API compatibility 20 | #include "variant.h" 21 | 22 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/libraries/USBHost/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For USBHost 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | MouseController KEYWORD1 10 | USBHost KEYWORD1 11 | KeyboardController KEYWORD1 12 | 13 | ####################################### 14 | # Methods and Functions (KEYWORD2) 15 | ####################################### 16 | 17 | Task KEYWORD2 18 | mouseMoved KEYWORD2 19 | mouseDragged KEYWORD2 20 | mousePressed KEYWORD2 21 | mouseReleased KEYWORD2 22 | getXChange KEYWORD2 23 | getYChange KEYWORD2 24 | getButton KEYWORD2 25 | keyPressed KEYWORD2 26 | keyReleased KEYWORD2 27 | getModifiers KEYWORD2 28 | getKey KEYWORD2 29 | getOemKey KEYWORD2 30 | 31 | 32 | ####################################### 33 | # Constants (LITERAL1) 34 | ####################################### 35 | 36 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/bootloaders/zero_osc32k/board_driver_led.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015 Arduino LLC. All right reserved. 3 | Copyright (c) 2015 Atmel Corporation/Thibaut VIARD. 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. 13 | See the GNU 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 "board_driver_led.h" 21 | 22 | 23 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/cores/arduino/avr/interrupt.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015 Arduino LCC. 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 file. 21 | This file is here to allow compatibility with sketches (made for AVR) 22 | that includes 23 | */ 24 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/libraries/SAMD_AnalogCorrection/src/SAMD_AnalogCorrection.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015 Arduino LLC. 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 | #pragma once 20 | 21 | #include 22 | 23 | void analogReadCorrection (int offset, uint16_t gain); 24 | 25 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/cores/arduino/wiring.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015 Arduino LLC. 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 | #pragma once 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | extern void init(void); 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif 30 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/bootloaders/zero_osc32k/samd21_sam_ba.atsln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Atmel Studio Solution File, Format Version 11.00 4 | VisualStudioVersion = 14.0.23107.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "samd21_sam_ba", "samd21_sam_ba.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|ARM = Debug|ARM 11 | Release|ARM = Release|ARM 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|ARM.ActiveCfg = Debug|ARM 15 | {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|ARM.Build.0 = Debug|ARM 16 | {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|ARM.ActiveCfg = Release|ARM 17 | {DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|ARM.Build.0 = Release|ARM 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/cores/arduino/Tone.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015 Arduino LLC. 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 | #pragma once 20 | 21 | #ifdef __cplusplus 22 | 23 | #include "Arduino.h" 24 | 25 | void tone(uint32_t _pin, uint32_t frequency, uint32_t duration = 0); 26 | void noTone(uint32_t _pin); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/cores/arduino/Reset.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015 Arduino LLC. 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 | #pragma once 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | void initiateReset(int ms); 26 | void tickReset(); 27 | void cancelReset(); 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/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 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/cores/arduino/avr/dtostrf.h: -------------------------------------------------------------------------------- 1 | /* 2 | dtostrf - Emulation for dtostrf function from avr-libc 3 | Copyright (c) 2015 Arduino LLC. All rights 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 | #pragma once 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | char *dtostrf(double val, signed char width, unsigned char prec, char *sout); 27 | 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/1.0.0/variants/mini_sam/openocd_scripts/samd21e18a.cfg: -------------------------------------------------------------------------------- 1 | # 2 | # Arduino Zero OpenOCD script. 3 | # 4 | # Copyright (c) 2014-2015 Arduino LLC. All right reserved. 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. 14 | # See the GNU 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 | source [find interface/cmsis-dap.cfg] 22 | 23 | # chip name 24 | set CHIPNAME at91samd21e18 25 | set ENDIAN little 26 | 27 | # choose a port here 28 | set telnet_port 0 29 | 30 | source [find target/at91samdXX.cfg] 31 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/variants/mini_sam/openocd_scripts/samd21e18a.cfg: -------------------------------------------------------------------------------- 1 | # 2 | # Arduino Zero OpenOCD script. 3 | # 4 | # Copyright (c) 2014-2015 Arduino LLC. All right reserved. 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. 14 | # See the GNU 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 | source [find interface/cmsis-dap.cfg] 22 | 23 | # chip name 24 | set CHIPNAME at91samd21g18 25 | set ENDIAN little 26 | 27 | # choose a port here 28 | set telnet_port 0 29 | 30 | source [find target/at91samdXX.cfg] 31 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/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 | { 17 | Wire.begin(4); // join i2c bus with address #4 18 | Wire.onReceive(receiveEvent); // register event 19 | Serial.begin(9600); // start serial for output 20 | } 21 | 22 | void loop() 23 | { 24 | delay(100); 25 | } 26 | 27 | // function that executes whenever data is received from master 28 | // this function is registered as an event, see setup() 29 | void receiveEvent(int howMany) 30 | { 31 | while(1 < Wire.available()) // loop through all but the last 32 | { 33 | char c = Wire.read(); // receive byte as a character 34 | Serial.print(c); // print the character 35 | } 36 | int x = Wire.read(); // receive byte as an integer 37 | Serial.println(x); // print the integer 38 | } 39 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/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 20 | 21 | void *operator new(size_t size) { 22 | return malloc(size); 23 | } 24 | 25 | void *operator new[](size_t size) { 26 | return malloc(size); 27 | } 28 | 29 | void operator delete(void * ptr) { 30 | free(ptr); 31 | } 32 | 33 | void operator delete[](void * ptr) { 34 | free(ptr); 35 | } 36 | 37 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/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 | // This example code is in the public domain. 13 | 14 | 15 | #include 16 | 17 | void setup() 18 | { 19 | Wire.begin(); // join i2c bus (address optional for master) 20 | } 21 | 22 | byte val = 0; 23 | 24 | void loop() 25 | { 26 | Wire.beginTransmission(44); // transmit to device #44 (0x2c) 27 | // device address is specified in datasheet 28 | Wire.write(byte(0x00)); // sends instruction byte 29 | Wire.write(val); // sends potentiometer value byte 30 | Wire.endTransmission(); // stop transmitting 31 | 32 | val++; // increment value 33 | if(val == 64) // if reached 64th position (max) 34 | { 35 | val = 0; // start over from lowest value 36 | } 37 | delay(500); 38 | } 39 | 40 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/cores/arduino/avr/dtostrf.c: -------------------------------------------------------------------------------- 1 | /* 2 | dtostrf - Emulation for dtostrf function from avr-libc 3 | Copyright (c) 2015 Arduino LLC. All rights 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 | char *dtostrf (double val, signed char width, unsigned char prec, char *sout) { 23 | asm(".global _printf_float"); 24 | 25 | char fmt[20]; 26 | sprintf(fmt, "%%%d.%df", width, prec); 27 | sprintf(sout, fmt, val); 28 | return sout; 29 | } 30 | 31 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/1.0.0/programmers.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2014-2015 Arduino LLC. All right reserved. 2 | # 3 | # This library is free software; you can redistribute it and/or 4 | # modify it under the terms of the GNU Lesser General Public 5 | # License as published by the Free Software Foundation; either 6 | # version 2.1 of the License, or (at your option) any later version. 7 | # 8 | # This library is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # See the GNU Lesser General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU Lesser General Public 14 | # License along with this library; if not, write to the Free Software 15 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 16 | 17 | atmel_ice.name=Atmel-ICE 18 | atmel_ice.communication=USB 19 | atmel_ice.protocol= 20 | atmel_ice.program.protocol= 21 | atmel_ice.program.tool=openocd 22 | atmel_ice.program.extra_params= 23 | 24 | sam_ice.name=Atmel SAM-ICE 25 | sam_ice.communication=USB 26 | sam_ice.protocol= 27 | sam_ice.program.protocol= 28 | sam_ice.program.tool=openocd 29 | sam_ice.program.extra_params= 30 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/programmers.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2014-2015 Arduino LLC. All right reserved. 2 | # 3 | # This library is free software; you can redistribute it and/or 4 | # modify it under the terms of the GNU Lesser General Public 5 | # License as published by the Free Software Foundation; either 6 | # version 2.1 of the License, or (at your option) any later version. 7 | # 8 | # This library is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # See the GNU Lesser General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU Lesser General Public 14 | # License along with this library; if not, write to the Free Software 15 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 16 | 17 | atmel_ice.name=Atmel-ICE 18 | atmel_ice.communication=USB 19 | atmel_ice.protocol= 20 | atmel_ice.program.protocol= 21 | atmel_ice.program.tool=openocd 22 | atmel_ice.program.extra_params= 23 | 24 | sam_ice.name=Atmel SAM-ICE 25 | sam_ice.communication=USB 26 | sam_ice.protocol= 27 | sam_ice.program.protocol= 28 | sam_ice.program.tool=openocd 29 | sam_ice.program.extra_params= 30 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/variants/mini_sam/debug_scripts/variant.gdb: -------------------------------------------------------------------------------- 1 | # 2 | # Arduino Zero OpenOCD script. 3 | # 4 | # Copyright (c) 2014-2015 Arduino LLC. All right reserved. 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. 14 | # See the GNU 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 | # Define 'reset' command 22 | define reset 23 | 24 | info reg 25 | 26 | break main 27 | 28 | # End of 'reset' command 29 | end 30 | 31 | target remote | openocd -c "interface cmsis-dap" -c "set CHIPNAME at91samd21e18" -f target/at91samdXX.cfg -c "gdb_port pipe; log_output openocd.log" 32 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/1.0.0/variants/mini_sam/debug_scripts/samd21e18a.gdb: -------------------------------------------------------------------------------- 1 | # 2 | # Arduino Zero OpenOCD script. 3 | # 4 | # Copyright (c) 2014-2015 Arduino LLC. All right reserved. 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. 14 | # See the GNU 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 | # Define 'reset' command 22 | define reset 23 | 24 | info reg 25 | 26 | break main 27 | 28 | # End of 'reset' command 29 | end 30 | 31 | target remote | openocd -c "interface cmsis-dap" -c "set CHIPNAME at91samd21e18" -f target/at91samdXX.cfg -c "gdb_port pipe; log_output openocd.log" 32 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/cores/arduino/WMath.h: -------------------------------------------------------------------------------- 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 _WIRING_MATH_ 20 | #define _WIRING_MATH_ 21 | 22 | extern long random( long ) ; 23 | extern long random( long, long ) ; 24 | extern void randomSeed( uint32_t dwSeed ) ; 25 | extern long map( long, long, long, long, long ) ; 26 | 27 | extern uint16_t makeWord( uint16_t w ) ; 28 | extern uint16_t makeWord( uint8_t h, uint8_t l ) ; 29 | 30 | #define word(...) makeWord(__VA_ARGS__) 31 | 32 | 33 | #endif /* _WIRING_MATH_ */ 34 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/libraries/SAMD_AnalogCorrection/src/SAMD_AnalogCorrection.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015 Arduino LLC. 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 "SAMD_AnalogCorrection.h" 20 | 21 | void analogReadCorrection (int offset, uint16_t gain) 22 | { 23 | // Set correction values 24 | ADC->OFFSETCORR.reg = ADC_OFFSETCORR_OFFSETCORR(offset); 25 | ADC->GAINCORR.reg = ADC_GAINCORR_GAINCORR(gain); 26 | 27 | // Enable digital correction logic 28 | ADC->CTRLB.bit.CORREN = 1; 29 | while(ADC->STATUS.bit.SYNCBUSY); 30 | } 31 | 32 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/cores/arduino/wiring_private.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015 Arduino LLC. 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 | #pragma once 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | // Includes Atmel CMSIS 30 | #include "sam.h" 31 | 32 | #include "wiring_constants.h" 33 | 34 | int pinPeripheral( uint32_t ulPin, EPioType ulPeripheral ); 35 | 36 | #ifdef __cplusplus 37 | } // extern "C" 38 | 39 | #include "HardwareSerial.h" 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/cores/arduino/itoa.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015 Arduino LLC. 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 | #pragma once 20 | 21 | #ifdef __cplusplus 22 | extern "C"{ 23 | #endif 24 | 25 | //extern void itoa( int n, char s[] ) ; 26 | 27 | extern char* itoa( int value, char *string, int radix ) ; 28 | extern char* ltoa( long value, char *string, int radix ) ; 29 | extern char* utoa( unsigned int value, char *string, int radix ) ; 30 | extern char* ultoa( unsigned long value, char *string, int radix ) ; 31 | 32 | #ifdef __cplusplus 33 | } // extern "C" 34 | #endif 35 | 36 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/cores/arduino/wiring_shift.h: -------------------------------------------------------------------------------- 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 _WIRING_SHIFT_ 20 | #define _WIRING_SHIFT_ 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | /* 27 | * \brief 28 | */ 29 | extern uint32_t shiftIn( uint32_t ulDataPin, uint32_t ulClockPin, uint32_t ulBitOrder ) ; 30 | 31 | 32 | /* 33 | * \brief 34 | */ 35 | extern void shiftOut( uint32_t ulDataPin, uint32_t ulClockPin, uint32_t ulBitOrder, uint32_t ulVal ) ; 36 | 37 | 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | 42 | #endif /* _WIRING_SHIFT_ */ 43 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/libraries/USBHost/src/Usb.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. 2 | 3 | This software may be distributed and modified under the terms of the GNU 4 | General Public License version 2 (GPL2) as published by the Free Software 5 | Foundation and appearing in the file GPL2.TXT included in the packaging of 6 | this file. Please note that GPL2 Section 2[b] requires that all works based 7 | on this software must also be made publicly available under the terms of 8 | the GPL2 ("Copyleft"). 9 | 10 | Contact information 11 | ------------------- 12 | 13 | Circuits At Home, LTD 14 | Web : http://www.circuitsathome.com 15 | e-mail : support@circuitsathome.com 16 | */ 17 | /* USB functions */ 18 | 19 | #ifndef USB_H_INCLUDED 20 | #define USB_H_INCLUDED 21 | #define _usb_h_ 22 | 23 | #include 24 | 25 | //#include "Arduino.h" 26 | #include "macros.h" 27 | // None of these should ever be included by a driver, or a user's sketch. 28 | 29 | #include "variant.h" 30 | #define USB_HOST_SERIAL SERIAL_PORT_MONITOR 31 | #include "Print.h" 32 | #include "printhex.h" 33 | #include "message.h" 34 | #include "hexdump.h" 35 | #include "sink_parser.h" 36 | 37 | #include "address.h" 38 | 39 | #include "usb_ch9.h" 40 | //#include "usbhost.h" 41 | #include "UsbCore.h" 42 | #include "parsetools.h" 43 | 44 | #include "confdescparser.h" 45 | 46 | #endif /* USB_H_INCLUDED */ 47 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/libraries/USBHost/src/sink_parser.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. 2 | 3 | This software may be distributed and modified under the terms of the GNU 4 | General Public License version 2 (GPL2) as published by the Free Software 5 | Foundation and appearing in the file GPL2.TXT included in the packaging of 6 | this file. Please note that GPL2 Section 2[b] requires that all works based 7 | on this software must also be made publicly available under the terms of 8 | the GPL2 ("Copyleft"). 9 | 10 | Contact information 11 | ------------------- 12 | 13 | Circuits At Home, LTD 14 | Web : http://www.circuitsathome.com 15 | e-mail : support@circuitsathome.com 16 | */ 17 | #if !defined(_usb_h_) || defined(__SINK_PARSER_H__) 18 | #error "Never include hexdump.h directly; include Usb.h instead" 19 | #else 20 | #define __SINK_PARSER_H__ 21 | 22 | extern int UsbDEBUGlvl; 23 | 24 | // This parser does absolutely nothing with the data, just swallows it. 25 | 26 | template 27 | class SinkParser : public BASE_CLASS { 28 | public: 29 | 30 | SinkParser() { 31 | }; 32 | 33 | void Initialize() { 34 | }; 35 | 36 | void Parse(const LEN_TYPE /* len */, const uint8_t * /* pbuf */, const OFFSET_TYPE & /* offset */) { 37 | }; 38 | }; 39 | 40 | 41 | #endif // __HEXDUMP_H__ 42 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/cores/arduino/abi.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014 Arduino LLC. 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 | void __cxa_pure_virtual(void) { 25 | // We might want to write some diagnostics to uart in this case 26 | //std::terminate(); 27 | while (1) 28 | ; 29 | } 30 | 31 | void __cxa_deleted_virtual(void) { 32 | // We might want to write some diagnostics to uart in this case 33 | //std::terminate(); 34 | while (1) 35 | ; 36 | } 37 | 38 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/cores/arduino/Printable.h: -------------------------------------------------------------------------------- 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 Printable_h 20 | #define Printable_h 21 | 22 | #include 23 | 24 | class Print; 25 | 26 | /** The Printable class provides a way for new classes to allow themselves to be printed. 27 | By deriving from Printable and implementing the printTo method, it will then be possible 28 | for users to print out instances of this class by passing them into the usual 29 | Print::print and Print::println methods. 30 | */ 31 | 32 | class Printable 33 | { 34 | public: 35 | virtual size_t printTo(Print& p) const = 0; 36 | }; 37 | 38 | #endif 39 | 40 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/cores/arduino/avr/io.h: -------------------------------------------------------------------------------- 1 | /* 2 | io.h - Definitions for compatibility with AVR io macros 3 | 4 | Copyright (c) 2016 Arduino LLC 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE 23 | */ 24 | 25 | #ifndef _IO_H_ 26 | #define _IO_H_ 27 | 28 | #define RAMSTART (HMCRAMC0_ADDR) 29 | #define RAMSIZE (HMCRAMC0_SIZE) 30 | #define RAMEND (RAMSTART + RAMSIZE - 1) 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /circuitpython/mini_sam_m0/board.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MicroPython project, http://micropython.org/ 3 | * 4 | * The MIT License (MIT) 5 | * 6 | * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | #include "boards/board.h" 28 | 29 | void board_init(void) 30 | { 31 | } 32 | 33 | bool board_requests_safe_mode(void) { 34 | return false; 35 | } 36 | 37 | void reset_board(void) { 38 | } 39 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/cores/arduino/pulse.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015 Arduino LLC. 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 | #pragma once 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | /* 26 | * \brief 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 | uint32_t pulseIn(uint32_t pin, uint32_t state, uint32_t timeout); 32 | 33 | #ifdef __cplusplus 34 | // Provides a version of pulseIn with a default argument (C++ only) 35 | uint32_t pulseIn(uint32_t pin, uint32_t state, uint32_t timeout = 1000000L); 36 | 37 | } // extern "C" 38 | #endif 39 | 40 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/libraries/I2S/examples/InputSerialPlotter/InputSerialPlotter.ino: -------------------------------------------------------------------------------- 1 | /* 2 | This example reads audio data from an Invensense's ICS43432 I2S microphone 3 | breakout board, and prints out the samples to the Serial console. The 4 | Serial Plotter built into the Arduino IDE can be used to plot the audio 5 | data (Tools -> Serial Plotter) 6 | 7 | Circuit: 8 | * Arduino/Genuino Zero, MKRZero or MKR1000 board 9 | * ICS43432: 10 | * GND connected GND 11 | * 3.3V connected 3.3V (Zero) or VCC (MKR1000, MKRZero) 12 | * WS connected to pin 0 (Zero) or pin 3 (MKR1000, MKRZero) 13 | * CLK connected to pin 1 (Zero) or pin 2 (MKR1000, MKRZero) 14 | * SD connected to pin 9 (Zero) or pin A6 (MKR1000, MKRZero) 15 | 16 | created 17 November 2016 17 | by Sandeep Mistry 18 | */ 19 | 20 | #include 21 | 22 | void setup() { 23 | // Open serial communications and wait for port to open: 24 | // A baud rate of 115200 is used instead of 9600 for a faster data rate 25 | // on non-native USB ports 26 | Serial.begin(115200); 27 | while (!Serial) { 28 | ; // wait for serial port to connect. Needed for native USB port only 29 | } 30 | 31 | // start I2S at 8 kHz with 32-bits per sample 32 | if (!I2S.begin(I2S_PHILIPS_MODE, 8000, 32)) { 33 | Serial.println("Failed to initialize I2S!"); 34 | while (1); // do nothing 35 | } 36 | } 37 | 38 | void loop() { 39 | // read a sample 40 | int sample = I2S.read(); 41 | 42 | if (sample) { 43 | // if it's non-zero print value to serial 44 | Serial.println(sample); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/libraries/USBHost/src/KeyboardController.cpp: -------------------------------------------------------------------------------- 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 | #include 20 | 21 | extern "C" { 22 | void __keyboardControllerEmptyCallback() { } 23 | } 24 | 25 | void keyPressed() __attribute__ ((weak, alias("__keyboardControllerEmptyCallback"))); 26 | void keyReleased() __attribute__ ((weak, alias("__keyboardControllerEmptyCallback"))); 27 | 28 | void KeyboardController::OnKeyDown(uint8_t _mod, uint8_t _oemKey) { 29 | modifiers = _mod; 30 | keyOem = _oemKey; 31 | key = OemToAscii(_mod, _oemKey); 32 | keyPressed(); 33 | } 34 | 35 | void KeyboardController::OnKeyUp(uint8_t _mod, uint8_t _oemKey) { 36 | modifiers = _mod; 37 | keyOem = _oemKey; 38 | key = OemToAscii(_mod, _oemKey); 39 | keyReleased(); 40 | } 41 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/cores/arduino/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015 Arduino LLC. 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 | #define ARDUINO_MAIN 20 | #include "Arduino.h" 21 | 22 | // Weak empty variant initialization function. 23 | // May be redefined by variant files. 24 | void initVariant() __attribute__((weak)); 25 | void initVariant() { } 26 | 27 | // Initialize C library 28 | extern "C" void __libc_init_array(void); 29 | 30 | /* 31 | * \brief Main entry point of Arduino application 32 | */ 33 | int main( void ) 34 | { 35 | init(); 36 | 37 | __libc_init_array(); 38 | 39 | initVariant(); 40 | 41 | delay(1); 42 | #if defined(USBCON) 43 | USBDevice.init(); 44 | USBDevice.attach(); 45 | #endif 46 | 47 | setup(); 48 | 49 | for (;;) 50 | { 51 | loop(); 52 | if (serialEventRun) serialEventRun(); 53 | } 54 | 55 | return 0; 56 | } 57 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/libraries/I2S/src/utility/I2SDoubleBuffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016 Arduino LLC. 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 _I2S_DOUBLE_BUFFER_H_INCLUDED 20 | #define _I2S_DOUBLE_BUFFER_H_INCLUDED 21 | 22 | #include 23 | #include 24 | 25 | #define I2S_BUFFER_SIZE 512 26 | 27 | class I2SDoubleBuffer 28 | { 29 | public: 30 | I2SDoubleBuffer(); 31 | virtual ~I2SDoubleBuffer(); 32 | 33 | void reset(); 34 | 35 | size_t availableForWrite(); 36 | size_t write(const void *buffer, size_t size); 37 | size_t read(void *buffer, size_t size); 38 | size_t peek(void *buffer, size_t size); 39 | void* data(); 40 | size_t available(); 41 | void swap(int length = 0); 42 | 43 | private: 44 | uint8_t _buffer[2][I2S_BUFFER_SIZE]; 45 | volatile int _length[2]; 46 | volatile int _readOffset[2]; 47 | volatile int _index; 48 | }; 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/cores/arduino/WInterrupts.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015 Arduino LLC. 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 _WIRING_INTERRUPTS_ 20 | #define _WIRING_INTERRUPTS_ 21 | 22 | #include 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | // LOW 0 29 | // HIGH 1 30 | #define CHANGE 2 31 | #define FALLING 3 32 | #define RISING 4 33 | 34 | #define DEFAULT 1 35 | #define EXTERNAL 0 36 | 37 | typedef void (*voidFuncPtr)(void); 38 | 39 | /* 40 | * \brief Specifies a named Interrupt Service Routine (ISR) to call when an interrupt occurs. 41 | * Replaces any previous function that was attached to the interrupt. 42 | */ 43 | void attachInterrupt(uint32_t pin, voidFuncPtr callback, uint32_t mode); 44 | 45 | /* 46 | * \brief Turns off the given interrupt. 47 | */ 48 | void detachInterrupt(uint32_t pin); 49 | 50 | #ifdef __cplusplus 51 | } 52 | #endif 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/cores/arduino/USB/USBDesc.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014 Arduino LLC. 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 __USBDESC_H__ 20 | #define __USBDESC_H__ 21 | 22 | // CDC or HID can be enabled together. 23 | #define CDC_ENABLED 24 | #define PLUGGABLE_USB_ENABLED 25 | 26 | #ifdef CDC_ENABLED 27 | #define CDC_INTERFACE_COUNT 2 28 | #define CDC_ENPOINT_COUNT 3 29 | #endif 30 | 31 | // CDC 32 | #define CDC_ACM_INTERFACE 0 // CDC ACM 33 | #define CDC_DATA_INTERFACE 1 // CDC Data 34 | #define CDC_FIRST_ENDPOINT 1 35 | #define CDC_ENDPOINT_ACM 1 36 | #define CDC_ENDPOINT_OUT 2 37 | #define CDC_ENDPOINT_IN 3 38 | 39 | #ifdef CDC_ENABLED 40 | #define CDC_RX CDC_ENDPOINT_OUT 41 | #define CDC_TX CDC_ENDPOINT_IN 42 | #endif 43 | 44 | #define ISERIAL_MAX_LEN 33 45 | 46 | // Defined string description 47 | #define IMANUFACTURER 1 48 | #define IPRODUCT 2 49 | #define ISERIAL 3 50 | 51 | #endif /* __USBDESC_H__ */ 52 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/cores/arduino/RingBuffer.h: -------------------------------------------------------------------------------- 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 _RING_BUFFER_ 20 | #define _RING_BUFFER_ 21 | 22 | #include 23 | 24 | // Define constants and variables for buffering incoming serial data. We're 25 | // using a ring buffer (I think), in which head is the index of the location 26 | // to which to write the next incoming character and tail is the index of the 27 | // location from which to read. 28 | #define SERIAL_BUFFER_SIZE 64 29 | 30 | class RingBuffer 31 | { 32 | public: 33 | uint8_t _aucBuffer[SERIAL_BUFFER_SIZE] ; 34 | int _iHead ; 35 | int _iTail ; 36 | 37 | public: 38 | RingBuffer( void ) ; 39 | void store_char( uint8_t c ) ; 40 | void clear(); 41 | int read_char(); 42 | int available(); 43 | int peek(); 44 | bool isFull(); 45 | 46 | private: 47 | int nextIndex(int index); 48 | } ; 49 | 50 | #endif /* _RING_BUFFER_ */ 51 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/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 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/libraries/I2S/examples/SimpleTone/SimpleTone.ino: -------------------------------------------------------------------------------- 1 | /* 2 | This example generates a square wave based tone at a specified frequency 3 | and sample rate. Then outputs the data using the I2S interface to a 4 | MAX08357 I2S Amp Breakout board. 5 | 6 | Circuit: 7 | * Arduino/Genuino Zero, MKRZero or MKR1000 board 8 | * MAX08357: 9 | * GND connected GND 10 | * VIN connected 5V 11 | * LRC connected to pin 0 (Zero) or pin 3 (MKR1000, MKRZero) 12 | * BCLK connected to pin 1 (Zero) or pin 2 (MKR1000, MKRZero) 13 | * DIN connected to pin 9 (Zero) or pin A6 (MKR1000, MKRZero) 14 | 15 | created 17 November 2016 16 | by Sandeep Mistry 17 | */ 18 | 19 | #include 20 | 21 | const int frequency = 440; // frequency of square wave in Hz 22 | const int amplitude = 500; // amplitude of square wave 23 | const int sampleRate = 8000; // sample rate in Hz 24 | 25 | const int halfWavelength = (sampleRate / frequency); // half wavelength of square wave 26 | 27 | short sample = amplitude; // current sample value 28 | int count = 0; 29 | 30 | void setup() { 31 | Serial.begin(9600); 32 | Serial.println("I2S simple tone"); 33 | 34 | // start I2S at the sample rate with 16-bits per sample 35 | if (!I2S.begin(I2S_PHILIPS_MODE, sampleRate, 16)) { 36 | Serial.println("Failed to initialize I2S!"); 37 | while (1); // do nothing 38 | } 39 | } 40 | 41 | void loop() { 42 | if (count % halfWavelength == 0) { 43 | // invert the sample every half wavelength count multiple to generate square wave 44 | sample = -1 * sample; 45 | } 46 | 47 | // write the same sample twice, once for left and once for the right channel 48 | I2S.write(sample); 49 | I2S.write(sample); 50 | 51 | // increment the counter for the next sample 52 | count++; 53 | } 54 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/libraries/USBHost/src/KeyboardController.h: -------------------------------------------------------------------------------- 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 | #ifndef KEYBOARD_CONTROLLER_H 20 | #define KEYBOARD_CONTROLLER_H 21 | 22 | #include 23 | 24 | enum KeyboardModifiers { 25 | LeftCtrl = 1, 26 | LeftShift = 2, 27 | Alt = 4, 28 | LeftCmd = 8, 29 | RightCtrl = 16, 30 | RightShift = 32, 31 | AltGr = 64, 32 | RightCmd = 128 33 | }; 34 | 35 | class KeyboardController : public KeyboardReportParser { 36 | public: 37 | KeyboardController(USBHost &usb) : hostKeyboard(&usb), key(0), keyOem(0), modifiers(0) { 38 | hostKeyboard.SetReportParser(0, this); 39 | }; 40 | 41 | uint8_t getKey() { return key; }; 42 | uint8_t getModifiers() { return modifiers; }; 43 | uint8_t getOemKey() { return keyOem; }; 44 | 45 | protected: 46 | virtual void OnKeyDown(uint8_t mod, uint8_t key); 47 | virtual void OnKeyUp(uint8_t mod, uint8_t key); 48 | 49 | private: 50 | HIDBoot hostKeyboard; 51 | uint8_t key, keyOem, modifiers; 52 | }; 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/cores/arduino/WMath.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 | extern "C" { 20 | #include "stdlib.h" 21 | #include "stdint.h" 22 | } 23 | #include "WMath.h" 24 | 25 | extern void randomSeed( uint32_t dwSeed ) 26 | { 27 | if ( dwSeed != 0 ) 28 | { 29 | srand( dwSeed ) ; 30 | } 31 | } 32 | 33 | extern long random( long howbig ) 34 | { 35 | if ( howbig == 0 ) 36 | { 37 | return 0 ; 38 | } 39 | 40 | return rand() % howbig; 41 | } 42 | 43 | extern long random( long howsmall, long howbig ) 44 | { 45 | if (howsmall >= howbig) 46 | { 47 | return howsmall; 48 | } 49 | 50 | long diff = howbig - howsmall; 51 | 52 | return random(diff) + howsmall; 53 | } 54 | 55 | extern long map(long x, long in_min, long in_max, long out_min, long out_max) 56 | { 57 | return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; 58 | } 59 | 60 | extern uint16_t makeWord( uint16_t w ) 61 | { 62 | return w ; 63 | } 64 | 65 | extern uint16_t makeWord( uint8_t h, uint8_t l ) 66 | { 67 | return (h << 8) | l ; 68 | } 69 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/bootloaders/zero_osc32k/board_driver_usb.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015 Arduino LLC. All right reserved. 3 | Copyright (c) 2015 Atmel Corporation/Thibaut VIARD. All right reserved. 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 | This library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | See the GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public 13 | License along with this library; if not, write to the Free Software 14 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | */ 16 | 17 | #ifndef _BOARD_DRIVER_USB_H_ 18 | #define _BOARD_DRIVER_USB_H_ 19 | 20 | #include "sam_ba_cdc.h" 21 | 22 | extern UsbDeviceDescriptor usb_endpoint_table[MAX_EP]; 23 | extern uint8_t udd_ep_out_cache_buffer[2][64]; //1 for CTRL, 1 for BULK 24 | extern uint8_t udd_ep_in_cache_buffer[2][64]; //1 for CTRL, 1 for BULK 25 | 26 | P_USB_CDC USB_Open(P_USB_CDC pCdc, Usb *pUsb); 27 | 28 | void USB_Init(void); 29 | 30 | uint32_t USB_Write(Usb *pUsb, const char *pData, uint32_t length, uint8_t ep_num); 31 | uint32_t USB_Read(Usb *pUsb, char *pData, uint32_t length); 32 | uint32_t USB_Read_blocking(Usb *pUsb, char *pData, uint32_t length); 33 | 34 | uint8_t USB_IsConfigured(P_USB_CDC pCdc); 35 | 36 | void USB_SendStall(Usb *pUsb, bool direction_in); 37 | void USB_SendZlp(Usb *pUsb); 38 | 39 | void USB_SetAddress(Usb *pUsb, uint16_t wValue); 40 | void USB_Configure(Usb *pUsb); 41 | 42 | #endif // _BOARD_DRIVER_USB_H_ -------------------------------------------------------------------------------- /circuitpython/mini_sam_m0/pins.c: -------------------------------------------------------------------------------- 1 | #include "shared-bindings/board/__init__.h" 2 | 3 | #include "board_busses.h" 4 | 5 | STATIC const mp_rom_map_elem_t board_global_dict_table[] = { 6 | { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) }, 7 | { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA06) }, 8 | { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PA07) }, 9 | { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA04) }, 10 | { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PA05) }, 11 | { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PA08) }, 12 | { MP_ROM_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_PA09) }, 13 | { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PA17) }, 14 | { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PA16) }, 15 | { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PA19) }, 16 | { MP_ROM_QSTR(MP_QSTR_SS), MP_ROM_PTR(&pin_PA18) }, 17 | { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_PA11) }, 18 | { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PA11) }, 19 | { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PA10) }, 20 | { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PA10) }, 21 | { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA22) }, 22 | { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA23) }, 23 | { MP_ROM_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_PA14) }, 24 | { MP_ROM_QSTR(MP_QSTR_D15), MP_ROM_PTR(&pin_PA15) }, 25 | { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_PA15) }, 26 | { MP_ROM_QSTR(MP_QSTR_D18), MP_ROM_PTR(&pin_PA18) }, 27 | { MP_ROM_QSTR(MP_QSTR_D27), MP_ROM_PTR(&pin_PA27) }, 28 | { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_PA27) }, 29 | { MP_ROM_QSTR(MP_QSTR_D28), MP_ROM_PTR(&pin_PA28) }, 30 | { MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_PA28) }, 31 | { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, 32 | { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, 33 | { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, 34 | }; 35 | MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); 36 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/1.0.0/boards.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2014-2015 Arduino LLC. All right reserved. 2 | # 3 | # This library is free software; you can redistribute it and/or 4 | # modify it under the terms of the GNU Lesser General Public 5 | # License as published by the Free Software Foundation; either 6 | # version 2.1 of the License, or (at your option) any later version. 7 | # 8 | # This library is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # See the GNU Lesser General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU Lesser General Public 14 | # License along with this library; if not, write to the Free Software 15 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 16 | 17 | # Mini SAM - SAMD21E18A Board (Native USB Port) 18 | mini_sam.name=Mini SAM 19 | mini_sam.vid.0=0x1209 20 | mini_sam.pid.0=0x2017 21 | mini_sam.vid.1=0x1209 22 | mini_sam.pid.1=0x2017 23 | mini_sam.upload.tool=arduino:bossac 24 | mini_sam.upload.protocol=sam-ba 25 | mini_sam.upload.maximum_size=262144 26 | mini_sam.upload.use_1200bps_touch=true 27 | mini_sam.upload.wait_for_upload_port=true 28 | mini_sam.upload.native_usb=true 29 | mini_sam.build.mcu=cortex-m0plus 30 | mini_sam.build.f_cpu=48000000L 31 | mini_sam.build.usb_product="Mini SAM" 32 | mini_sam.build.usb_manufacturer="Benjamin Shockley" 33 | mini_sam.build.board=SAMD_MINI_SAM 34 | mini_sam.build.core=arduino:arduino 35 | mini_sam.build.extra_flags=-D__SAMD21E18A__ {build.usb_flags} 36 | mini_sam.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld 37 | mini_sam.build.openocdscript=openocd_scripts/samd21e18a.cfg 38 | mini_sam.build.variant=mini_sam 39 | mini_sam.build.variant_system_lib= 40 | mini_sam.build.vid=0x1209 41 | mini_sam.build.pid=0x2017 42 | mini_sam.bootloader.tool=openocd 43 | mini_sam.bootloader.file=mini_sam/samd21_sam_ba_mini_sam.bin 44 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/cores/arduino/hooks.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015 Arduino LLC. 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 | 33 | /** 34 | * SysTick hook 35 | * 36 | * This function is called from SysTick handler, before the default 37 | * handler provided by Arduino. 38 | */ 39 | static int __false() { 40 | // Return false 41 | return 0; 42 | } 43 | int sysTickHook(void) __attribute__ ((weak, alias("__false"))); 44 | 45 | /** 46 | * SVC hook 47 | * PendSV hook 48 | * 49 | * These functions are called from SVC handler, and PensSV handler. 50 | * Default action is halting. 51 | */ 52 | static void __halt() { 53 | // Halts 54 | while (1) 55 | ; 56 | } 57 | void svcHook(void) __attribute__ ((weak, alias("__halt"))); 58 | void pendSVHook(void) __attribute__ ((weak, alias("__halt"))); 59 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/libraries/USBHost/src/MouseController.h: -------------------------------------------------------------------------------- 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 | #ifndef MOUSE_CONTROLLER_H 20 | #define MOUSE_CONTROLLER_H 21 | 22 | #include 23 | 24 | enum MouseButton { 25 | LEFT_BUTTON = 0x01, 26 | MIDDLE_BUTTON = 0x02, 27 | RIGHT_BUTTON = 0x04 28 | }; 29 | 30 | class MouseController : public MouseReportParser 31 | { 32 | public: 33 | MouseController(USBHost &usb) : hostMouse(&usb), dx(0), dy(0), buttons(0) { 34 | hostMouse.SetReportParser(0, this); 35 | }; 36 | 37 | bool getButton(MouseButton button) { return (buttons & button) == button; }; 38 | int getXChange(); 39 | int getYChange(); 40 | // int getWheelChange(); // Not implemented 41 | 42 | protected: 43 | virtual void OnMouseMove(MOUSEINFO *mi); 44 | virtual void OnLeftButtonUp(MOUSEINFO *mi); 45 | virtual void OnLeftButtonDown(MOUSEINFO *mi); 46 | virtual void OnMiddleButtonUp(MOUSEINFO *mi); 47 | virtual void OnMiddleButtonDown(MOUSEINFO *mi); 48 | virtual void OnRightButtonUp(MOUSEINFO *mi); 49 | virtual void OnRightButtonDown(MOUSEINFO *mi); 50 | 51 | private: 52 | HIDBoot hostMouse; 53 | int dx, dy; 54 | int buttons; 55 | }; 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/cores/arduino/wiring_constants.h: -------------------------------------------------------------------------------- 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 _WIRING_CONSTANTS_ 20 | #define _WIRING_CONSTANTS_ 21 | 22 | #ifdef __cplusplus 23 | extern "C"{ 24 | #endif // __cplusplus 25 | 26 | #define LOW (0x0) 27 | #define HIGH (0x1) 28 | 29 | #define INPUT (0x0) 30 | #define OUTPUT (0x1) 31 | #define INPUT_PULLUP (0x2) 32 | #define INPUT_PULLDOWN (0x3) 33 | 34 | #define PI 3.1415926535897932384626433832795 35 | #define HALF_PI 1.5707963267948966192313216916398 36 | #define TWO_PI 6.283185307179586476925286766559 37 | #define DEG_TO_RAD 0.017453292519943295769236907684886 38 | #define RAD_TO_DEG 57.295779513082320876798154814105 39 | #define EULER 2.718281828459045235360287471352 40 | 41 | #define SERIAL 0x0 42 | #define DISPLAY 0x1 43 | 44 | enum BitOrder { 45 | LSBFIRST = 0, 46 | MSBFIRST = 1 47 | }; 48 | 49 | // moved to WInterrupts.h 50 | //// LOW 0 51 | //// HIGH 1 52 | //#define CHANGE 2 53 | //#define FALLING 3 54 | //#define RISING 4 55 | // 56 | //#define DEFAULT 1 57 | //#define EXTERNAL 0 58 | 59 | #ifdef __cplusplus 60 | } // extern "C" 61 | #endif // __cplusplus 62 | 63 | #endif /* _WIRING_CONSTANTS_ */ 64 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/cores/arduino/Uart.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015 Arduino LLC. 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 | #pragma once 20 | 21 | #include "HardwareSerial.h" 22 | #include "SERCOM.h" 23 | #include "RingBuffer.h" 24 | 25 | #include 26 | 27 | class Uart : public HardwareSerial 28 | { 29 | public: 30 | Uart(SERCOM *_s, uint8_t _pinRX, uint8_t _pinTX, SercomRXPad _padRX, SercomUartTXPad _padTX); 31 | void begin(unsigned long baudRate); 32 | void begin(unsigned long baudrate, uint16_t config); 33 | void end(); 34 | int available(); 35 | int availableForWrite(); 36 | int peek(); 37 | int read(); 38 | void flush(); 39 | size_t write(const uint8_t data); 40 | using Print::write; // pull in write(str) and write(buf, size) from Print 41 | 42 | void IrqHandler(); 43 | 44 | operator bool() { return true; } 45 | 46 | private: 47 | SERCOM *sercom; 48 | RingBuffer rxBuffer; 49 | 50 | uint8_t uc_pinRX; 51 | uint8_t uc_pinTX; 52 | SercomRXPad uc_padRX; 53 | SercomUartTXPad uc_padTX; 54 | 55 | SercomNumberStopBit extractNbStopBit(uint16_t config); 56 | SercomUartCharSize extractCharSize(uint16_t config); 57 | SercomParityMode extractParity(uint16_t config); 58 | }; 59 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/libraries/USBHost/src/parsetools.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. 2 | 3 | This software may be distributed and modified under the terms of the GNU 4 | General Public License version 2 (GPL2) as published by the Free Software 5 | Foundation and appearing in the file GPL2.TXT included in the packaging of 6 | this file. Please note that GPL2 Section 2[b] requires that all works based 7 | on this software must also be made publicly available under the terms of 8 | the GPL2 ("Copyleft"). 9 | 10 | Contact information 11 | ------------------- 12 | 13 | Circuits At Home, LTD 14 | Web : http://www.circuitsathome.com 15 | e-mail : support@circuitsathome.com 16 | */ 17 | #include "Usb.h" 18 | 19 | bool MultiByteValueParser::Parse(uint8_t **pp, uint32_t *pcntdn) { 20 | if(!pBuf) { 21 | Notify(PSTR("Buffer pointer is NULL!\r\n"), 0x80); 22 | return false; 23 | } 24 | for (; countDown && (*pcntdn); countDown--, (*pcntdn)--, (*pp)++) 25 | pBuf[valueSize - countDown] = (**pp); 26 | 27 | if(countDown) 28 | return false; 29 | 30 | countDown = valueSize; 31 | return true; 32 | } 33 | 34 | bool PTPListParser::Parse(uint8_t **pp, uint32_t *pcntdn, PTP_ARRAY_EL_FUNC pf, const void *me) { 35 | switch(nStage) { 36 | case 0: 37 | pBuf->valueSize = lenSize; 38 | theParser.Initialize(pBuf); 39 | nStage = 1; 40 | 41 | case 1: 42 | if(!theParser.Parse(pp, pcntdn)) 43 | return false; 44 | 45 | arLen = 0; 46 | arLen = (pBuf->valueSize >= 4) ? *((uint32_t*)pBuf->pValue) : (uint32_t)(*((uint16_t*)pBuf->pValue)); 47 | arLenCntdn = arLen; 48 | nStage = 2; 49 | 50 | case 2: 51 | pBuf->valueSize = valSize; 52 | theParser.Initialize(pBuf); 53 | nStage = 3; 54 | 55 | case 3: 56 | for(; arLenCntdn; arLenCntdn--) { 57 | if(!theParser.Parse(pp, pcntdn)) 58 | return false; 59 | 60 | if(pf) 61 | pf(pBuf, (arLen - arLenCntdn), me); 62 | } 63 | 64 | nStage = 0; 65 | } 66 | return true; 67 | } 68 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/1.0.0/README.md: -------------------------------------------------------------------------------- 1 | # Arduino Core for SAMD21 CPU - Mini SAM Specific 2 | 3 | This repository contains the source code and configuration files of the Arduino Core 4 | for Atmel's SAMD21 processor used for the Mini SAM board. 5 | 6 | ## Installation on Arduino IDE 7 | 8 | Copy the directory [mini_sam](https://github.com/bwshockley/Minifigure-SAMD21E/new/master/arduino) to your Arduino packages directory. 9 | 10 | ## Support 11 | 12 | Support for this repository is provided via the [Issues](https://github.com/bwshockley/Minifigure-SAMD21E/issues) page. 13 | 14 | ## Bugs or Issues 15 | 16 | If you find a bug you can submit an issue here on github: 17 | 18 | [https://github.com/bwshockley/Minifigure-SAMD21E/issues](https://github.com/bwshockley/Minifigure-SAMD21E/issues) 19 | 20 | Before posting a new issue, please check if the same problem has been already reported by someone else 21 | to avoid duplicates. 22 | 23 | ## Contributions 24 | 25 | Contributions are always welcome. The preferred way to receive code cotribution is by submitting a 26 | Pull Request on github. 27 | 28 | 29 | ## License and credits 30 | 31 | This core was developed for the Mini SAM development board and uses files and build tools from Arduino and Atmel. 32 | 33 | ``` 34 | 35 | This library is free software; you can redistribute it and/or 36 | modify it under the terms of the GNU Lesser General Public 37 | License as published by the Free Software Foundation; either 38 | version 2.1 of the License, or (at your option) any later version. 39 | 40 | This library is distributed in the hope that it will be useful, 41 | but WITHOUT ANY WARRANTY; without even the implied warranty of 42 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 43 | See the GNU Lesser General Public License for more details. 44 | 45 | You should have received a copy of the GNU Lesser General Public 46 | License along with this library; if not, write to the Free Software 47 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 48 | ``` 49 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/boards.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2014-2015 Arduino LLC. All right reserved. 2 | # 3 | # This package for the Mini SAM Atmel SAM D21E variant was derrived from the 4 | # Arduino Zero board package 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. 14 | # See the GNU 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 | # Mini SAM - SAMD21E18A Board (Native USB Port) 20 | mini_sam.name=Mini SAM 21 | mini_sam.vid.0=0x1209 22 | mini_sam.pid.0=0x2017 23 | mini_sam.vid.1=0x1209 24 | mini_sam.pid.1=0x2017 25 | mini_sam.upload.tool=arduino:bossac 26 | mini_sam.upload.protocol=sam-ba 27 | mini_sam.upload.maximum_size=262144 28 | mini_sam.upload.use_1200bps_touch=true 29 | mini_sam.upload.wait_for_upload_port=true 30 | mini_sam.upload.native_usb=true 31 | mini_sam.build.mcu=cortex-m0plus 32 | mini_sam.build.f_cpu=48000000L 33 | mini_sam.build.usb_product="Mini SAM" 34 | mini_sam.build.usb_manufacturer="Benjamin Shockley" 35 | mini_sam.build.board=SAMD_MINI_SAM 36 | mini_sam.build.core=arduino:arduino 37 | mini_sam.build.extra_flags=-D__SAMD21E18A__ {build.usb_flags} 38 | mini_sam.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld 39 | mini_sam.build.openocdscript=openocd_scripts/samd21e18a.cfg 40 | mini_sam.build.variant=mini_sam 41 | mini_sam.build.variant_system_lib= 42 | mini_sam.build.vid=0x1209 43 | mini_sam.build.pid=0x2017 44 | mini_sam.bootloader.tool=openocd 45 | mini_sam.bootloader.file=zero_osc32k/samd21_sam_ba.bin -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/cores/arduino/wiring_shift.c: -------------------------------------------------------------------------------- 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 | #include "wiring_shift.h" 21 | #include "wiring_digital.h" 22 | #include "wiring_private.h" 23 | 24 | #ifdef __cplusplus 25 | extern "C"{ 26 | #endif 27 | 28 | uint32_t shiftIn( uint32_t ulDataPin, uint32_t ulClockPin, uint32_t ulBitOrder ) 29 | { 30 | uint8_t value = 0 ; 31 | uint8_t i ; 32 | 33 | for ( i=0 ; i < 8 ; ++i ) 34 | { 35 | digitalWrite( ulClockPin, HIGH ) ; 36 | 37 | if ( ulBitOrder == LSBFIRST ) 38 | { 39 | value |= digitalRead( ulDataPin ) << i ; 40 | } 41 | else 42 | { 43 | value |= digitalRead( ulDataPin ) << (7 - i) ; 44 | } 45 | 46 | digitalWrite( ulClockPin, LOW ) ; 47 | } 48 | 49 | return value ; 50 | } 51 | 52 | void shiftOut( uint32_t ulDataPin, uint32_t ulClockPin, uint32_t ulBitOrder, uint32_t ulVal ) 53 | { 54 | uint8_t i ; 55 | 56 | for ( i=0 ; i < 8 ; i++ ) 57 | { 58 | if ( ulBitOrder == LSBFIRST ) 59 | { 60 | digitalWrite( ulDataPin, !!(ulVal & (1 << i)) ) ; 61 | } 62 | else 63 | { 64 | digitalWrite( ulDataPin, !!(ulVal & (1 << (7 - i))) ) ; 65 | } 66 | 67 | digitalWrite( ulClockPin, HIGH ) ; 68 | digitalWrite( ulClockPin, LOW ) ; 69 | } 70 | } 71 | 72 | #ifdef __cplusplus 73 | } // extern "C" 74 | #endif 75 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/bootloaders/zero_osc32k/sam_ba_monitor.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015 Arduino LLC. All right reserved. 3 | Copyright (c) 2015 Atmel Corporation/Thibaut VIARD. All right reserved. 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 | This library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | See the GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public 13 | License along with this library; if not, write to the Free Software 14 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | */ 16 | 17 | #ifndef _MONITOR_SAM_BA_H_ 18 | #define _MONITOR_SAM_BA_H_ 19 | 20 | #define SAM_BA_VERSION "2.0" 21 | 22 | /* Enable the interfaces to save code size */ 23 | #define SAM_BA_BOTH_INTERFACES 0 24 | #define SAM_BA_UART_ONLY 1 25 | #define SAM_BA_USBCDC_ONLY 2 26 | 27 | #ifndef SAM_BA_INTERFACE 28 | #define SAM_BA_INTERFACE SAM_BA_USBCDC_ONLY // SAM_BA_BOTH_INTERFACES 29 | #endif 30 | 31 | /* Selects USB as the communication interface of the monitor */ 32 | #define SAM_BA_INTERFACE_USBCDC 0 33 | /* Selects USART as the communication interface of the monitor */ 34 | #define SAM_BA_INTERFACE_USART 1 35 | 36 | /* Selects USB as the communication interface of the monitor */ 37 | #define SIZEBUFMAX 64 38 | 39 | /** 40 | * \brief Initialize the monitor 41 | * 42 | */ 43 | void sam_ba_monitor_init(uint8_t com_interface); 44 | 45 | /** 46 | * \brief Main function of the SAM-BA Monitor 47 | * 48 | */ 49 | void sam_ba_monitor_run(void); 50 | 51 | /** 52 | * \brief 53 | * 54 | */ 55 | void sam_ba_putdata_term(uint8_t* data, uint32_t length); 56 | 57 | /** 58 | * \brief 59 | * 60 | */ 61 | void call_applet(uint32_t address); 62 | 63 | #endif // _MONITOR_SAM_BA_H_ -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/libraries/I2S/src/utility/DMA.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016 Arduino LLC. 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 | #pragma once 19 | 20 | #define NUM_DMA_CHANNELS 1 21 | 22 | /* 23 | WARNING: The API for this class may change and it's not intended for public use! 24 | */ 25 | class DMAClass 26 | { 27 | public: 28 | DMAClass(); 29 | virtual ~DMAClass(); 30 | 31 | void begin(); 32 | void end(); 33 | 34 | int allocateChannel(); 35 | void freeChannel(int channel); 36 | 37 | void setPriorityLevel(int channel, int level); 38 | void setTriggerSource(int channel, int source); 39 | void setTransferWidth(int channel, int transferWidth); 40 | void incSrc(int channel); 41 | void incDst(int channel); 42 | int transfer(int channel, void* src, void* dst, uint16_t size); 43 | 44 | void onTransferComplete(int channel, void(*function)(int)); 45 | void onTransferError(int channel, void(*function)(int)); 46 | 47 | void onService(); 48 | 49 | private: 50 | static int _beginCount; 51 | uint32_t _channelMask; 52 | 53 | void (*_transferCompleteCallbacks[NUM_DMA_CHANNELS])(int); 54 | void (*_transferErrorCallbacks[NUM_DMA_CHANNELS])(int); 55 | 56 | DmacDescriptor _descriptors[NUM_DMA_CHANNELS] __attribute__ ((aligned (16))); 57 | DmacDescriptor _descriptorsWriteBack[NUM_DMA_CHANNELS] __attribute__ ((aligned (16))); 58 | }; 59 | 60 | extern DMAClass DMA; 61 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/bootloaders/zero_osc32k/ATMEL/samd.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | * SAM Software Package License 3 | * ---------------------------------------------------------------------------- 4 | * Copyright (c) 2014, Atmel Corporation 5 | * 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following condition is met: 10 | * 11 | * - Redistributions of source code must retain the above copyright notice, 12 | * this list of conditions and the disclaimer below. 13 | * 14 | * Atmel's name may not be used to endorse or promote products derived from 15 | * this software without specific prior written permission. 16 | * 17 | * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 20 | * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 23 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 25 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 26 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * ---------------------------------------------------------------------------- 28 | */ 29 | #ifndef _SAMD_INCLUDED_ 30 | #define _SAMD_INCLUDED_ 31 | 32 | #if defined (__SAMD21E16A__) 33 | #include "samd21/include/samd21.h" 34 | #elif defined (__SAMD21E17A__) 35 | #include "samd21/include/samd21.h" 36 | #elif defined (__SAMD21E18A__) 37 | #include "samd21/include/samd21.h" 38 | #elif defined (__SAMD21G16A__) 39 | #include "samd21/include/samd21.h" 40 | #elif defined (__SAMD21G17A__) 41 | #include "samd21/include/samd21.h" 42 | #elif defined (__SAMD21G18A__) 43 | #include "samd21/include/samd21.h" 44 | #endif 45 | 46 | #endif /* _SAMD_INCLUDED_ */ 47 | 48 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/bootloaders/zero_osc32k/ATMEL/samr.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | * SAM Software Package License 3 | * ---------------------------------------------------------------------------- 4 | * Copyright (c) 2014, Atmel Corporation 5 | * 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following condition is met: 10 | * 11 | * - Redistributions of source code must retain the above copyright notice, 12 | * this list of conditions and the disclaimer below. 13 | * 14 | * Atmel's name may not be used to endorse or promote products derived from 15 | * this software without specific prior written permission. 16 | * 17 | * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 20 | * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 23 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 25 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 26 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * ---------------------------------------------------------------------------- 28 | */ 29 | #ifndef _SAMR_INCLUDED_ 30 | #define _SAMR_INCLUDED_ 31 | 32 | #if defined (__SAMR21E16A__) 33 | #include "samr21/include/samr21.h" 34 | #elif defined (__SAMR21E17A__) 35 | #include "samr21/include/samr21.h" 36 | #elif defined (__SAMR21E18A__) 37 | #include "samr21/include/samr21.h" 38 | #elif defined (__SAMR21G16A__) 39 | #include "samr21/include/samr21.h" 40 | #elif defined (__SAMR21G17A__) 41 | #include "samr21/include/samr21.h" 42 | #elif defined (__SAMR21G18A__) 43 | #include "samr21/include/samr21.h" 44 | #endif 45 | 46 | #endif /* _SAMR_INCLUDED_ */ 47 | 48 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/bootloaders/zero_osc32k/ATMEL/samr21/include/samr21.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | * SAM Software Package License 3 | * ---------------------------------------------------------------------------- 4 | * Copyright (c) 2014, Atmel Corporation 5 | * 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following condition is met: 10 | * 11 | * - Redistributions of source code must retain the above copyright notice, 12 | * this list of conditions and the disclaimer below. 13 | * 14 | * Atmel's name may not be used to endorse or promote products derived from 15 | * this software without specific prior written permission. 16 | * 17 | * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 20 | * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 23 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 25 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 26 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * ---------------------------------------------------------------------------- 28 | */ 29 | #ifndef _SAMR21_ 30 | #define _SAMR21_ 31 | 32 | #if defined (__SAMR21E16A__) 33 | #include "samr21e16a.h" 34 | #elif defined (__SAMR21E17A__) 35 | #include "samr21e17a.h" 36 | #elif defined (__SAMR21E18A__) 37 | #include "samr21e18a.h" 38 | #elif defined (__SAMR21G16A__) 39 | #include "samr21g16a.h" 40 | #elif defined (__SAMR21G17A__) 41 | #include "samr21g17a.h" 42 | #elif defined (__SAMR21G18A__) 43 | #include "samr21g18a.h" 44 | #else 45 | #error Library does not support the specified device. 46 | #endif 47 | 48 | #endif /* _SAMR21_ */ 49 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/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 resisor 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 | // inslude 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 | // send in the address and value via SPI: 67 | SPI.transfer(address); 68 | SPI.transfer(value); 69 | // take the SS pin high to de-select the chip: 70 | digitalWrite(slaveSelectPin, HIGH); 71 | } 72 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/bootloaders/zero_osc32k/board_driver_led.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015 Arduino LLC. All right reserved. 3 | Copyright (c) 2015 Atmel Corporation/Thibaut VIARD. 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. 13 | See the GNU 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 _BOARD_DRIVER_LED_ 21 | #define _BOARD_DRIVER_LED_ 22 | 23 | #include 24 | #include "board_definitions.h" 25 | 26 | inline void LED_init(void) { PORT->Group[BOARD_LED_PORT].DIRSET.reg = (1<Group[BOARD_LED_PORT].OUTSET.reg = (1<Group[BOARD_LED_PORT].OUTCLR.reg = (1<Group[BOARD_LED_PORT].OUTTGL.reg = (1<Group[BOARD_LEDRX_PORT].DIRSET.reg = (1<Group[BOARD_LEDRX_PORT].OUTSET.reg = (1<Group[BOARD_LEDRX_PORT].OUTCLR.reg = (1<Group[BOARD_LEDRX_PORT].OUTTGL.reg = (1<Group[BOARD_LEDTX_PORT].DIRSET.reg = (1<Group[BOARD_LEDTX_PORT].OUTSET.reg = (1<Group[BOARD_LEDTX_PORT].OUTCLR.reg = (1<Group[BOARD_LEDTX_PORT].OUTTGL.reg = (1< 21 | 22 | RingBuffer::RingBuffer( void ) 23 | { 24 | memset( _aucBuffer, 0, SERIAL_BUFFER_SIZE ) ; 25 | clear(); 26 | } 27 | 28 | void RingBuffer::store_char( uint8_t c ) 29 | { 30 | int i = nextIndex(_iHead); 31 | 32 | // if we should be storing the received character into the location 33 | // just before the tail (meaning that the head would advance to the 34 | // current location of the tail), we're about to overflow the buffer 35 | // and so we don't write the character or advance the head. 36 | if ( i != _iTail ) 37 | { 38 | _aucBuffer[_iHead] = c ; 39 | _iHead = i ; 40 | } 41 | } 42 | 43 | void RingBuffer::clear() 44 | { 45 | _iHead = 0; 46 | _iTail = 0; 47 | } 48 | 49 | int RingBuffer::read_char() 50 | { 51 | if(_iTail == _iHead) 52 | return -1; 53 | 54 | uint8_t value = _aucBuffer[_iTail]; 55 | _iTail = nextIndex(_iTail); 56 | 57 | return value; 58 | } 59 | 60 | int RingBuffer::available() 61 | { 62 | int delta = _iHead - _iTail; 63 | 64 | if(delta < 0) 65 | return SERIAL_BUFFER_SIZE + delta; 66 | else 67 | return delta; 68 | } 69 | 70 | int RingBuffer::peek() 71 | { 72 | if(_iTail == _iHead) 73 | return -1; 74 | 75 | return _aucBuffer[_iTail]; 76 | } 77 | 78 | int RingBuffer::nextIndex(int index) 79 | { 80 | return (uint32_t)(index + 1) % SERIAL_BUFFER_SIZE; 81 | } 82 | 83 | bool RingBuffer::isFull() 84 | { 85 | return (nextIndex(_iHead) == _iTail); 86 | } 87 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/libraries/USBHost/src/hexdump.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. 2 | 3 | This software may be distributed and modified under the terms of the GNU 4 | General Public License version 2 (GPL2) as published by the Free Software 5 | Foundation and appearing in the file GPL2.TXT included in the packaging of 6 | this file. Please note that GPL2 Section 2[b] requires that all works based 7 | on this software must also be made publicly available under the terms of 8 | the GPL2 ("Copyleft"). 9 | 10 | Contact information 11 | ------------------- 12 | 13 | Circuits At Home, LTD 14 | Web : http://www.circuitsathome.com 15 | e-mail : support@circuitsathome.com 16 | */ 17 | #if !defined(_usb_h_) || defined(__HEXDUMP_H__) 18 | #error "Never include hexdump.h directly; include Usb.h instead" 19 | #else 20 | #define __HEXDUMP_H__ 21 | 22 | extern int UsbDEBUGlvl; 23 | 24 | template 25 | class HexDumper : public BASE_CLASS { 26 | uint8_t byteCount; 27 | OFFSET_TYPE byteTotal; 28 | 29 | public: 30 | 31 | HexDumper() : byteCount(0), byteTotal(0) { 32 | }; 33 | 34 | void Initialize() { 35 | byteCount = 0; 36 | byteTotal = 0; 37 | }; 38 | 39 | virtual void Parse(const LEN_TYPE len, const uint8_t *pbuf, const OFFSET_TYPE &offset); 40 | }; 41 | 42 | template 43 | void HexDumper::Parse(const LEN_TYPE len, const uint8_t *pbuf, const OFFSET_TYPE &offset) { 44 | if(UsbDEBUGlvl >= 0x80) { // Fully bypass this block of code if we do not debug. 45 | for(LEN_TYPE j = 0; j < len; j++, byteCount++, byteTotal++) { 46 | if(!byteCount) { 47 | PrintHex (byteTotal, 0x80); 48 | E_Notify(PSTR(": "), 0x80); 49 | } 50 | PrintHex (pbuf[j], 0x80); 51 | E_Notify(PSTR(" "), 0x80); 52 | 53 | if(byteCount == 15) { 54 | E_Notify(PSTR("\r\n"), 0x80); 55 | byteCount = 0xFF; 56 | } 57 | } 58 | } 59 | } 60 | 61 | #endif // __HEXDUMP_H__ 62 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/cores/arduino/USB/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, uint32_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 uint32_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 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/bootloaders/zero_osc32k/ATMEL/samr21/include/system_samr21.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Low-level initialization functions called upon chip startup 5 | * 6 | * Copyright (c) 2014 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | 44 | #ifndef _SYSTEM_SAMR21_H_INCLUDED_ 45 | #define _SYSTEM_SAMR21_H_INCLUDED_ 46 | 47 | #ifdef __cplusplus 48 | extern "C" { 49 | #endif 50 | 51 | #include 52 | 53 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 54 | 55 | void SystemInit(void); 56 | void SystemCoreClockUpdate(void); 57 | 58 | #ifdef __cplusplus 59 | } 60 | #endif 61 | 62 | #endif /* SYSTEM_SAMR21_H_INCLUDED */ 63 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/libraries/USBHost/examples/ADKTerminalTest/ADKTerminalTest.ino: -------------------------------------------------------------------------------- 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 | #define ARDUINO_MAIN 20 | //#include "variant.h" 21 | #include "Arduino.h" 22 | #include 23 | #include 24 | 25 | 26 | USBHost usb; 27 | ADK adk(&usb,"Arduino SA", 28 | "Arduino_Terminal", 29 | "Arduino Terminal for Android", 30 | "1.0", 31 | "http://labs.arduino.cc/uploads/ADK/ArduinoTerminal/ThibaultTerminal_ICS_0001.apk", 32 | "1"); 33 | 34 | void setup(void) 35 | { 36 | SERIAL_PORT_MONITOR.begin( 115200 ); 37 | while (!SERIAL_PORT_MONITOR); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection 38 | SERIAL_PORT_MONITOR.println("\r\nADK demo start"); 39 | 40 | if (usb.Init() == -1) 41 | SERIAL_PORT_MONITOR.println("OSC did not start."); 42 | 43 | delay(20); 44 | } 45 | 46 | #define RCVSIZE 128 47 | 48 | void loop(void) 49 | { 50 | uint8_t buf[RCVSIZE]; 51 | uint32_t nbread = 0; 52 | char helloworld[] = "Hello World!\r\n"; 53 | 54 | usb.Task(); 55 | 56 | if( adk.isReady() == false ) { 57 | return; 58 | } 59 | /* Write hello string to ADK */ 60 | adk.SndData(strlen(helloworld), (uint8_t *)helloworld); 61 | 62 | delay(1000); 63 | 64 | /* Read data from ADK and print to UART */ 65 | adk.RcvData((uint8_t *)&nbread, buf); 66 | if (nbread > 0) 67 | { 68 | SERIAL_PORT_MONITOR.print("RCV: "); 69 | for (uint32_t i = 0; i < nbread; ++i) 70 | { 71 | SERIAL_PORT_MONITOR.print((char)buf[i]); 72 | } 73 | SERIAL_PORT_MONITOR.print("\r\n"); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/cores/arduino/pulse.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015 Arduino LLC. 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 | // See pulse_asm.S 22 | extern unsigned long countPulseASM(const volatile uint32_t *port, uint32_t bit, uint32_t stateMask, unsigned long maxloops); 23 | 24 | /* Measures the length (in microseconds) of a pulse on the pin; state is HIGH 25 | * or LOW, the type of pulse to measure. Works on pulses from 2-3 microseconds 26 | * to 3 minutes in length, but must be called at least a few dozen microseconds 27 | * before the start of the pulse. */ 28 | uint32_t pulseIn(uint32_t pin, uint32_t state, uint32_t timeout) 29 | { 30 | // cache the port and bit of the pin in order to speed up the 31 | // pulse width measuring loop and achieve finer resolution. calling 32 | // digitalRead() instead yields much coarser resolution. 33 | PinDescription p = g_APinDescription[pin]; 34 | uint32_t bit = 1 << p.ulPin; 35 | uint32_t stateMask = state ? bit : 0; 36 | 37 | // convert the timeout from microseconds to a number of times through 38 | // the initial loop; it takes (roughly) 13 clock cycles per iteration. 39 | uint32_t maxloops = microsecondsToClockCycles(timeout) / 13; 40 | 41 | uint32_t width = countPulseASM(&(PORT->Group[p.ulPort].IN.reg), bit, stateMask, maxloops); 42 | 43 | // convert the reading to microseconds. The loop has been determined 44 | // to be 13 clock cycles long and have about 16 clocks between the edge 45 | // and the start of the loop. There will be some error introduced by 46 | // the interrupt handlers. 47 | if (width) 48 | return clockCyclesToMicroseconds(width * 13 + 16); 49 | else 50 | return 0; 51 | } 52 | 53 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/cores/arduino/wiring_analog.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015 Arduino LLC. 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 | #pragma once 20 | 21 | #include 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* 28 | * \brief SAMD products have only one reference for ADC 29 | */ 30 | typedef enum _eAnalogReference 31 | { 32 | AR_DEFAULT, 33 | AR_INTERNAL, 34 | AR_EXTERNAL, 35 | AR_INTERNAL1V0, 36 | AR_INTERNAL1V65, 37 | AR_INTERNAL2V23 38 | } eAnalogReference ; 39 | 40 | 41 | /* 42 | * \brief Configures the reference voltage used for analog input (i.e. the value used as the top of the input range). 43 | * This function is kept only for compatibility with existing AVR based API. 44 | * 45 | * \param ulMmode Should be set to AR_DEFAULT. 46 | */ 47 | extern void analogReference( eAnalogReference ulMode ) ; 48 | 49 | /* 50 | * \brief Writes an analog value (PWM wave) to a pin. 51 | * 52 | * \param ulPin 53 | * \param ulValue 54 | */ 55 | extern void analogWrite( uint32_t ulPin, uint32_t ulValue ) ; 56 | 57 | /* 58 | * \brief Reads the value from the specified analog pin. 59 | * 60 | * \param ulPin 61 | * 62 | * \return Read value from selected pin, if no error. 63 | */ 64 | extern uint32_t analogRead( uint32_t ulPin ) ; 65 | 66 | /* 67 | * \brief Set the resolution of analogRead return values. Default is 10 bits (range from 0 to 1023). 68 | * 69 | * \param res 70 | */ 71 | extern void analogReadResolution(int res); 72 | 73 | /* 74 | * \brief Set the resolution of analogWrite parameters. Default is 8 bits (range from 0 to 255). 75 | * 76 | * \param res 77 | */ 78 | extern void analogWriteResolution(int res); 79 | 80 | extern void analogOutputInit( void ) ; 81 | 82 | #ifdef __cplusplus 83 | } 84 | #endif 85 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/bootloaders/zero_osc32k/ATMEL/samd21/include/system_samd21.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Low-level initialization functions called upon chip startup 5 | * 6 | * Copyright (c) 2013-2014 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | /** 44 | * Support and FAQ: visit Atmel Support 45 | */ 46 | 47 | #ifndef _SYSTEM_SAMD21_H_INCLUDED_ 48 | #define _SYSTEM_SAMD21_H_INCLUDED_ 49 | 50 | #ifdef __cplusplus 51 | extern "C" { 52 | #endif 53 | 54 | #include 55 | 56 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 57 | 58 | void SystemInit(void); 59 | void SystemCoreClockUpdate(void); 60 | 61 | #ifdef __cplusplus 62 | } 63 | #endif 64 | 65 | #endif /* SYSTEM_SAMD21_H_INCLUDED */ 66 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/cores/arduino/Reset.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015 Arduino LLC. 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 | #include "Reset.h" 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | #define NVM_MEMORY ((volatile uint16_t *)0x000000) 27 | 28 | #if (ARDUINO_SAMD_VARIANT_COMPLIANCE >= 10610) 29 | 30 | extern const uint32_t __text_start__; 31 | #define APP_START ((volatile uint32_t)(&__text_start__) + 4) 32 | 33 | #else 34 | #define APP_START 0x00002004 35 | #endif 36 | 37 | static inline bool nvmReady(void) { 38 | return NVMCTRL->INTFLAG.reg & NVMCTRL_INTFLAG_READY; 39 | } 40 | 41 | __attribute__ ((long_call, section (".ramfunc"))) 42 | static void banzai() { 43 | // Disable all interrupts 44 | __disable_irq(); 45 | 46 | // Avoid erasing the application if APP_START is < than the minimum bootloader size 47 | // This could happen if without_bootloader linker script was chosen 48 | // Minimum bootloader size in SAMD21 family is 512bytes (RM section 22.6.5) 49 | if (APP_START < (0x200 + 4)) { 50 | goto reset; 51 | } 52 | 53 | // Erase application 54 | while (!nvmReady()) 55 | ; 56 | NVMCTRL->STATUS.reg |= NVMCTRL_STATUS_MASK; 57 | NVMCTRL->ADDR.reg = (uintptr_t)&NVM_MEMORY[APP_START / 4]; 58 | NVMCTRL->CTRLA.reg = NVMCTRL_CTRLA_CMD_ER | NVMCTRL_CTRLA_CMDEX_KEY; 59 | while (!nvmReady()) 60 | ; 61 | 62 | reset: 63 | // Reset the device 64 | NVIC_SystemReset() ; 65 | 66 | while (true); 67 | } 68 | 69 | static int ticks = -1; 70 | 71 | void initiateReset(int _ticks) { 72 | ticks = _ticks; 73 | } 74 | 75 | void cancelReset() { 76 | ticks = -1; 77 | } 78 | 79 | void tickReset() { 80 | if (ticks == -1) 81 | return; 82 | ticks--; 83 | if (ticks == 0) 84 | banzai(); 85 | } 86 | 87 | #ifdef __cplusplus 88 | } 89 | #endif 90 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/cores/arduino/USB/USB_host.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014 Arduino LLC. 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 USB_HOST_H_INCLUDED 20 | #define USB_HOST_H_INCLUDED 21 | 22 | #include 23 | #include "samd21_host.h" 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | #define tokSETUP USB_HOST_PCFG_PTOKEN_SETUP 29 | #define tokIN USB_HOST_PCFG_PTOKEN_IN 30 | #define tokOUT USB_HOST_PCFG_PTOKEN_OUT 31 | #define tokINHS USB_HOST_PCFG_PTOKEN_IN 32 | #define tokOUTHS USB_HOST_PCFG_PTOKEN_OUT 33 | 34 | //! \brief Device speed 35 | /*typedef enum { 36 | UHD_SPEED_LOW = 0, 37 | UHD_SPEED_FULL = 1, 38 | UHD_SPEED_HIGH = 2, 39 | } uhd_speed_t;*/ 40 | 41 | //! States of USBB interface 42 | typedef enum { 43 | UHD_STATE_NO_VBUS = 0, 44 | UHD_STATE_DISCONNECTED = 1, 45 | UHD_STATE_CONNECTED = 2, 46 | UHD_STATE_ERROR = 3, 47 | } uhd_vbus_state_t; 48 | 49 | extern void UHD_Init(void); 50 | extern void UHD_Handler(void); 51 | extern void USB_SetHandler(void (*pf_isr)(void)); 52 | extern uhd_vbus_state_t UHD_GetVBUSState(void); 53 | extern uint32_t UHD_Pipe0_Alloc(uint32_t ul_add, uint32_t ul_ep_size); 54 | extern uint32_t UHD_Pipe_Alloc(uint32_t ul_dev_addr, uint32_t ul_dev_ep, uint32_t ul_type, uint32_t ul_dir, uint32_t ul_maxsize, uint32_t ul_interval, uint32_t ul_nb_bank); 55 | extern void UHD_Pipe_CountZero(uint32_t ul_pipe); 56 | extern void UHD_Pipe_Free(uint32_t ul_pipe); 57 | extern uint32_t UHD_Pipe_Read(uint32_t ul_pipe, uint32_t ul_size, uint8_t* data); 58 | extern void UHD_Pipe_Write(uint32_t ul_pipe, uint32_t ul_size, uint8_t* data); 59 | extern void UHD_Pipe_Send(uint32_t ul_pipe, uint32_t ul_token_type); 60 | extern uint32_t UHD_Pipe_Is_Transfer_Complete(uint32_t ul_pipe, uint32_t ul_token_type); 61 | 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | 66 | #endif /* USB_HOST_H_INCLUDED */ 67 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/libraries/USBHost/examples/KeyboardController/KeyboardController.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Keyboard Controller Example 3 | 4 | Shows the output of a USB Keyboard connected to 5 | the Native USB port on an Arduino Due Board. 6 | 7 | created 8 Oct 2012 8 | by Cristian Maglie 9 | 10 | http://arduino.cc/en/Tutorial/KeyboardController 11 | 12 | This sample code is part of the public domain. 13 | */ 14 | 15 | // Require keyboard control library 16 | #include 17 | 18 | // Initialize USB Controller 19 | USBHost usb; 20 | 21 | // Attach keyboard controller to USB 22 | KeyboardController keyboard(usb); 23 | 24 | void printKey(); 25 | 26 | // This function intercepts key press 27 | void keyPressed() { 28 | SERIAL_PORT_MONITOR.print("Pressed: "); 29 | printKey(); 30 | } 31 | 32 | // This function intercepts key release 33 | void keyReleased() { 34 | SERIAL_PORT_MONITOR.print("Released: "); 35 | printKey(); 36 | } 37 | 38 | void printKey() { 39 | // getOemKey() returns the OEM-code associated with the key 40 | SERIAL_PORT_MONITOR.print(" key:"); 41 | SERIAL_PORT_MONITOR.print(keyboard.getOemKey()); 42 | 43 | // getModifiers() returns a bits field with the modifiers-keys 44 | int mod = keyboard.getModifiers(); 45 | SERIAL_PORT_MONITOR.print(" mod:"); 46 | SERIAL_PORT_MONITOR.print(mod); 47 | 48 | SERIAL_PORT_MONITOR.print(" => "); 49 | 50 | if (mod & LeftCtrl) 51 | SERIAL_PORT_MONITOR.print("L-Ctrl "); 52 | if (mod & LeftShift) 53 | SERIAL_PORT_MONITOR.print("L-Shift "); 54 | if (mod & Alt) 55 | SERIAL_PORT_MONITOR.print("Alt "); 56 | if (mod & LeftCmd) 57 | SERIAL_PORT_MONITOR.print("L-Cmd "); 58 | if (mod & RightCtrl) 59 | SERIAL_PORT_MONITOR.print("R-Ctrl "); 60 | if (mod & RightShift) 61 | SERIAL_PORT_MONITOR.print("R-Shift "); 62 | if (mod & AltGr) 63 | SERIAL_PORT_MONITOR.print("AltGr "); 64 | if (mod & RightCmd) 65 | SERIAL_PORT_MONITOR.print("R-Cmd "); 66 | 67 | // getKey() returns the ASCII translation of OEM key 68 | // combined with modifiers. 69 | SERIAL_PORT_MONITOR.write(keyboard.getKey()); 70 | SERIAL_PORT_MONITOR.println(); 71 | } 72 | 73 | void setup() 74 | { 75 | SERIAL_PORT_MONITOR.begin( 115200 ); 76 | while (!SERIAL_PORT_MONITOR); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection 77 | SERIAL_PORT_MONITOR.println("Keyboard Controller Program started"); 78 | 79 | if (usb.Init() == -1) 80 | SERIAL_PORT_MONITOR.println("OSC did not start."); 81 | 82 | delay( 20 ); 83 | } 84 | 85 | void loop() 86 | { 87 | // Process USB tasks 88 | usb.Task(); 89 | } 90 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/bootloaders/zero_osc32k/ATMEL/samr21/include/instance/rfctrl.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Instance description for RFCTRL 5 | * 6 | * Copyright (c) 2014 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | 44 | #ifndef _SAMR21_RFCTRL_INSTANCE_ 45 | #define _SAMR21_RFCTRL_INSTANCE_ 46 | 47 | /* ========== Register definition for RFCTRL peripheral ========== */ 48 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 49 | #define REG_RFCTRL_FECFG (0x42005400U) /**< \brief (RFCTRL) Front-end control bus configuration */ 50 | #else 51 | #define REG_RFCTRL_FECFG (*(RwReg16*)0x42005400U) /**< \brief (RFCTRL) Front-end control bus configuration */ 52 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 53 | 54 | /* ========== Instance parameters for RFCTRL peripheral ========== */ 55 | #define RFCTRL_FBUSMSB 5 56 | 57 | #endif /* _SAMR21_RFCTRL_INSTANCE_ */ 58 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/libraries/USBHost/src/printhex.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. 2 | 3 | This software may be distributed and modified under the terms of the GNU 4 | General Public License version 2 (GPL2) as published by the Free Software 5 | Foundation and appearing in the file GPL2.TXT included in the packaging of 6 | this file. Please note that GPL2 Section 2[b] requires that all works based 7 | on this software must also be made publicly available under the terms of 8 | the GPL2 ("Copyleft"). 9 | 10 | Contact information 11 | ------------------- 12 | 13 | Circuits At Home, LTD 14 | Web : http://www.circuitsathome.com 15 | e-mail : support@circuitsathome.com 16 | */ 17 | 18 | #if !defined(_usb_h_) || defined(__PRINTHEX_H__) 19 | #error "Never include printhex.h directly; include Usb.h instead" 20 | #else 21 | #define __PRINTHEX_H__ 22 | 23 | #include 24 | 25 | void E_Notifyc(char c, int lvl); 26 | 27 | template 28 | void PrintHex(T val, int lvl) { 29 | int num_nibbles = sizeof (T) * 2; 30 | 31 | do { 32 | char v = 48 + (((val >> (num_nibbles - 1) * 4)) & 0x0f); 33 | if(v > 57) v += 7; 34 | E_Notifyc(v, lvl); 35 | } while(--num_nibbles); 36 | } 37 | 38 | template 39 | void PrintBin(T val, int lvl) { 40 | for(T mask = (((T)1) << ((sizeof (T) << 3) - 1)); mask; mask >>= 1) 41 | if(val & mask) 42 | E_Notifyc('1', lvl); 43 | else 44 | E_Notifyc('0', lvl); 45 | } 46 | 47 | template 48 | void SerialPrintHex(T val) { 49 | int num_nibbles = sizeof (T) * 2; 50 | 51 | do { 52 | char v = 48 + (((val >> (num_nibbles - 1) * 4)) & 0x0f); 53 | if(v > 57) v += 7; 54 | USB_HOST_SERIAL.print(v); 55 | } while(--num_nibbles); 56 | } 57 | 58 | template 59 | void PrintHex2(Print *prn, T val) { 60 | T mask = (((T)1) << (((sizeof (T) << 1) - 1) << 2)); 61 | 62 | while(mask > 1) { 63 | if(val < mask) 64 | prn->print("0"); 65 | 66 | mask >>= 4; 67 | } 68 | prn->print((T)val, HEX); 69 | } 70 | 71 | #ifdef DEBUG_USB_HOST 72 | template void D_PrintHex(T val, int lvl) { 73 | PrintHex (val, lvl); 74 | } 75 | 76 | template 77 | void D_PrintBin(T val, int lvl) { 78 | PrintBin (val, lvl); 79 | } 80 | #else 81 | template void D_PrintHex(T, int) { 82 | } 83 | 84 | template 85 | void D_PrintBin(T, int) { 86 | } 87 | #endif 88 | 89 | 90 | 91 | #endif // __PRINTHEX_H__ 92 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/libraries/USBHost/src/MouseController.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Arduino LLC. 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" { 22 | void __mouseControllerEmptyCallback() { } 23 | } 24 | 25 | void mouseClicked() __attribute__ ((weak, alias("__mouseControllerEmptyCallback"))); 26 | void mouseDragged() __attribute__ ((weak, alias("__mouseControllerEmptyCallback"))); 27 | void mouseMoved() __attribute__ ((weak, alias("__mouseControllerEmptyCallback"))); 28 | void mousePressed() __attribute__ ((weak, alias("__mouseControllerEmptyCallback"))); 29 | void mouseReleased() __attribute__ ((weak, alias("__mouseControllerEmptyCallback"))); 30 | 31 | int MouseController::getXChange() { 32 | int r = dx; 33 | dx = 0; 34 | return r; 35 | } 36 | 37 | int MouseController::getYChange() { 38 | int r = dy; 39 | dy = 0; 40 | return r; 41 | } 42 | 43 | void MouseController::OnMouseMove(MOUSEINFO *mi) { 44 | dx += mi->dX; 45 | dy += mi->dY; 46 | if (buttons != 0) 47 | mouseDragged(); 48 | else 49 | mouseMoved(); 50 | } 51 | 52 | void MouseController::OnLeftButtonUp(MOUSEINFO * /* mi */) { 53 | buttons &= ~LEFT_BUTTON; 54 | mouseReleased(); 55 | mouseClicked(); 56 | } 57 | 58 | void MouseController::OnLeftButtonDown(MOUSEINFO * /* mi */) { 59 | buttons |= LEFT_BUTTON; 60 | mousePressed(); 61 | } 62 | 63 | void MouseController::OnMiddleButtonUp(MOUSEINFO * /* mi */) { 64 | buttons &= ~MIDDLE_BUTTON; 65 | mouseReleased(); 66 | mouseClicked(); 67 | } 68 | 69 | void MouseController::OnMiddleButtonDown(MOUSEINFO * /* mi */) { 70 | buttons |= MIDDLE_BUTTON; 71 | mousePressed(); 72 | } 73 | 74 | void MouseController::OnRightButtonUp(MOUSEINFO * /* mi */) { 75 | buttons &= ~RIGHT_BUTTON; 76 | mouseReleased(); 77 | mouseClicked(); 78 | } 79 | 80 | void MouseController::OnRightButtonDown(MOUSEINFO * /* mi */) { 81 | buttons |= RIGHT_BUTTON; 82 | mousePressed(); 83 | } 84 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/bootloaders/zero_osc32k/sam_ba_cdc.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015 Arduino LLC. All right reserved. 3 | Copyright (c) 2015 Atmel Corporation/Thibaut VIARD. All right reserved. 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 | This library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | See the GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public 13 | License along with this library; if not, write to the Free Software 14 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | */ 16 | 17 | #ifndef _SAM_BA_USB_CDC_H_ 18 | #define _SAM_BA_USB_CDC_H_ 19 | 20 | #include 21 | #include "sam_ba_usb.h" 22 | 23 | typedef struct 24 | { 25 | uint32_t dwDTERate; 26 | uint8_t bCharFormat; 27 | uint8_t bParityType; 28 | uint8_t bDataBits; 29 | } usb_cdc_line_coding_t; 30 | 31 | /* CDC Class Specific Request Code */ 32 | #define GET_LINE_CODING 0x21A1 33 | #define SET_LINE_CODING 0x2021 34 | #define SET_CONTROL_LINE_STATE 0x2221 35 | 36 | extern usb_cdc_line_coding_t line_coding; 37 | 38 | 39 | /** 40 | * \brief Sends a single byte through USB CDC 41 | * 42 | * \param Data to send 43 | * \return number of data sent 44 | */ 45 | int cdc_putc(/*P_USB_CDC pCdc,*/ int value); 46 | 47 | /** 48 | * \brief Reads a single byte through USB CDC 49 | * 50 | * \return Data read through USB 51 | */ 52 | int cdc_getc(/*P_USB_CDC pCdc*/); 53 | 54 | /** 55 | * \brief Checks if a character has been received on USB CDC 56 | * 57 | * \return \c 1 if a byte is ready to be read. 58 | */ 59 | bool cdc_is_rx_ready(/*P_USB_CDC pCdc*/); 60 | 61 | /** 62 | * \brief Sends buffer on USB CDC 63 | * 64 | * \param data pointer 65 | * \param number of data to send 66 | * \return number of data sent 67 | */ 68 | uint32_t cdc_write_buf(/*P_USB_CDC pCdc,*/ void const* data, uint32_t length); 69 | 70 | /** 71 | * \brief Gets data on USB CDC 72 | * 73 | * \param data pointer 74 | * \param number of data to read 75 | * \return number of data read 76 | */ 77 | uint32_t cdc_read_buf(/*P_USB_CDC pCdc,*/ void* data, uint32_t length); 78 | 79 | /** 80 | * \brief Gets specified number of bytes on USB CDC 81 | * 82 | * \param data pointer 83 | * \param number of data to read 84 | * \return number of data read 85 | */ 86 | uint32_t cdc_read_buf_xmd(/*P_USB_CDC pCdc,*/ void* data, uint32_t length); 87 | 88 | #endif // _SAM_BA_USB_CDC_H_ -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/cores/arduino/delay.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015 Arduino LLC. 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 "delay.h" 20 | #include "Arduino.h" 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | /** Tick Counter united by ms */ 27 | static volatile uint32_t _ulTickCount=0 ; 28 | 29 | uint32_t millis( void ) 30 | { 31 | // todo: ensure no interrupts 32 | return _ulTickCount ; 33 | } 34 | 35 | // Interrupt-compatible version of micros 36 | // Theory: repeatedly take readings of SysTick counter, millis counter and SysTick interrupt pending flag. 37 | // When it appears that millis counter and pending is stable and SysTick hasn't rolled over, use these 38 | // values to calculate micros. If there is a pending SysTick, add one to the millis counter in the calculation. 39 | uint32_t micros( void ) 40 | { 41 | uint32_t ticks, ticks2; 42 | uint32_t pend, pend2; 43 | uint32_t count, count2; 44 | 45 | ticks2 = SysTick->VAL; 46 | pend2 = !!(SCB->ICSR & SCB_ICSR_PENDSTSET_Msk) ; 47 | count2 = _ulTickCount ; 48 | 49 | do 50 | { 51 | ticks=ticks2; 52 | pend=pend2; 53 | count=count2; 54 | ticks2 = SysTick->VAL; 55 | pend2 = !!(SCB->ICSR & SCB_ICSR_PENDSTSET_Msk) ; 56 | count2 = _ulTickCount ; 57 | } while ((pend != pend2) || (count != count2) || (ticks < ticks2)); 58 | 59 | return ((count+pend) * 1000) + (((SysTick->LOAD - ticks)*(1048576/(VARIANT_MCK/1000000)))>>20) ; 60 | // this is an optimization to turn a runtime division into two compile-time divisions and 61 | // a runtime multiplication and shift, saving a few cycles 62 | } 63 | 64 | void delay( uint32_t ms ) 65 | { 66 | if ( ms == 0 ) 67 | { 68 | return ; 69 | } 70 | 71 | uint32_t start = _ulTickCount ; 72 | 73 | do 74 | { 75 | yield() ; 76 | } while ( _ulTickCount - start < ms ) ; 77 | } 78 | 79 | #include "Reset.h" // for tickReset() 80 | 81 | void SysTick_DefaultHandler(void) 82 | { 83 | // Increment tick count each ms 84 | _ulTickCount++; 85 | tickReset(); 86 | } 87 | 88 | #ifdef __cplusplus 89 | } 90 | #endif 91 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/bootloaders/zero_osc32k/ATMEL/samr21/include/instance/pac0.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Instance description for PAC0 5 | * 6 | * Copyright (c) 2014 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | 44 | #ifndef _SAMR21_PAC0_INSTANCE_ 45 | #define _SAMR21_PAC0_INSTANCE_ 46 | 47 | /* ========== Register definition for PAC0 peripheral ========== */ 48 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 49 | #define REG_PAC0_WPCLR (0x40000000U) /**< \brief (PAC0) Write Protection Clear */ 50 | #define REG_PAC0_WPSET (0x40000004U) /**< \brief (PAC0) Write Protection Set */ 51 | #else 52 | #define REG_PAC0_WPCLR (*(RwReg *)0x40000000U) /**< \brief (PAC0) Write Protection Clear */ 53 | #define REG_PAC0_WPSET (*(RwReg *)0x40000004U) /**< \brief (PAC0) Write Protection Set */ 54 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 55 | 56 | /* ========== Instance parameters for PAC0 peripheral ========== */ 57 | #define PAC0_WPROT_DEFAULT_VAL 0x00000000 // PAC protection mask at reset 58 | 59 | #endif /* _SAMR21_PAC0_INSTANCE_ */ 60 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/bootloaders/zero_osc32k/ATMEL/samr21/include/instance/pac1.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Instance description for PAC1 5 | * 6 | * Copyright (c) 2014 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | 44 | #ifndef _SAMR21_PAC1_INSTANCE_ 45 | #define _SAMR21_PAC1_INSTANCE_ 46 | 47 | /* ========== Register definition for PAC1 peripheral ========== */ 48 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 49 | #define REG_PAC1_WPCLR (0x41000000U) /**< \brief (PAC1) Write Protection Clear */ 50 | #define REG_PAC1_WPSET (0x41000004U) /**< \brief (PAC1) Write Protection Set */ 51 | #else 52 | #define REG_PAC1_WPCLR (*(RwReg *)0x41000000U) /**< \brief (PAC1) Write Protection Clear */ 53 | #define REG_PAC1_WPSET (*(RwReg *)0x41000004U) /**< \brief (PAC1) Write Protection Set */ 54 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 55 | 56 | /* ========== Instance parameters for PAC1 peripheral ========== */ 57 | #define PAC1_WPROT_DEFAULT_VAL 0x00000002 // PAC protection mask at reset 58 | 59 | #endif /* _SAMR21_PAC1_INSTANCE_ */ 60 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/bootloaders/zero_osc32k/ATMEL/samr21/include/instance/pac2.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Instance description for PAC2 5 | * 6 | * Copyright (c) 2014 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | 44 | #ifndef _SAMR21_PAC2_INSTANCE_ 45 | #define _SAMR21_PAC2_INSTANCE_ 46 | 47 | /* ========== Register definition for PAC2 peripheral ========== */ 48 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 49 | #define REG_PAC2_WPCLR (0x42000000U) /**< \brief (PAC2) Write Protection Clear */ 50 | #define REG_PAC2_WPSET (0x42000004U) /**< \brief (PAC2) Write Protection Set */ 51 | #else 52 | #define REG_PAC2_WPCLR (*(RwReg *)0x42000000U) /**< \brief (PAC2) Write Protection Clear */ 53 | #define REG_PAC2_WPSET (*(RwReg *)0x42000004U) /**< \brief (PAC2) Write Protection Set */ 54 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 55 | 56 | /* ========== Instance parameters for PAC2 peripheral ========== */ 57 | #define PAC2_WPROT_DEFAULT_VAL 0x00800000 // PAC protection mask at reset 58 | 59 | #endif /* _SAMR21_PAC2_INSTANCE_ */ 60 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/cores/arduino/Print.h: -------------------------------------------------------------------------------- 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 Print_h 20 | #define Print_h 21 | 22 | #include 23 | #include // for size_t 24 | 25 | #include "WString.h" 26 | #include "Printable.h" 27 | 28 | #define DEC 10 29 | #define HEX 16 30 | #define OCT 8 31 | #define BIN 2 32 | 33 | class Print 34 | { 35 | private: 36 | int write_error; 37 | size_t printNumber(unsigned long, uint8_t); 38 | size_t printFloat(double, uint8_t); 39 | protected: 40 | void setWriteError(int err = 1) { write_error = err; } 41 | public: 42 | Print() : write_error(0) {} 43 | 44 | int getWriteError() { return write_error; } 45 | void clearWriteError() { setWriteError(0); } 46 | 47 | virtual size_t write(uint8_t) = 0; 48 | size_t write(const char *str) { 49 | if (str == NULL) return 0; 50 | return write((const uint8_t *)str, strlen(str)); 51 | } 52 | virtual size_t write(const uint8_t *buffer, size_t size); 53 | size_t write(const char *buffer, size_t size) { 54 | return write((const uint8_t *)buffer, size); 55 | } 56 | 57 | size_t print(const __FlashStringHelper *); 58 | size_t print(const String &); 59 | size_t print(const char[]); 60 | size_t print(char); 61 | size_t print(unsigned char, int = DEC); 62 | size_t print(int, int = DEC); 63 | size_t print(unsigned int, int = DEC); 64 | size_t print(long, int = DEC); 65 | size_t print(unsigned long, int = DEC); 66 | size_t print(double, int = 2); 67 | size_t print(const Printable&); 68 | 69 | size_t println(const __FlashStringHelper *); 70 | size_t println(const String &s); 71 | size_t println(const char[]); 72 | size_t println(char); 73 | size_t println(unsigned char, int = DEC); 74 | size_t println(int, int = DEC); 75 | size_t println(unsigned int, int = DEC); 76 | size_t println(long, int = DEC); 77 | size_t println(unsigned long, int = DEC); 78 | size_t println(double, int = 2); 79 | size_t println(const Printable&); 80 | size_t println(void); 81 | }; 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/bootloaders/zero_osc32k/README.md: -------------------------------------------------------------------------------- 1 | # Arduino Zero Bootloader 2 | 3 | ## 1- Prerequisites 4 | 5 | The project build is based on Makefile system. 6 | Makefile is present at project root and try to handle multi-platform cases. 7 | 8 | Multi-plaform GCC is provided by ARM here: https://launchpad.net/gcc-arm-embedded/+download 9 | 10 | Atmel Studio contains both make and ARM GCC toolchain. You don't need to install them in this specific use case. 11 | 12 | ### Windows 13 | 14 | * Native command line 15 | Make binary can be obtained here: http://gnuwin32.sourceforge.net/packages/make.htm 16 | 17 | * Cygwin/MSys/MSys2/Babun/etc... 18 | It is available natively in all distributions. 19 | 20 | * Atmel Studio 21 | An Atmel Studio **7** Makefile-based project is present at project root, just open samd21_sam_ba.atsln file in AS7. 22 | 23 | ### Linux 24 | 25 | Make is usually available by default. 26 | 27 | ### OS X 28 | 29 | Make is available through XCode package. 30 | 31 | 32 | ## 2- Selecting available SAM-BA interfaces 33 | 34 | By default both USB and UART are made available, but this parameter can be modified in sam_ba_monitor.h, line 31: 35 | 36 | Set the define SAM_BA_INTERFACE to 37 | * SAM_BA_UART_ONLY for only UART interface 38 | * SAM_BA_USBCDC_ONLY for only USB CDC interface 39 | * SAM_BA_BOTH_INTERFACES for enabling both the interfaces 40 | 41 | ## 3- Behaviour 42 | 43 | This bootloader implements the double-tap on Reset button. 44 | By quickly pressing this button two times, the board will reset and stay in bootloader, waiting for communication on either USB or USART. 45 | 46 | The USB port in use is the USB Native port, close to the Reset button. 47 | The USART in use is the one available on pins D0/D1, labelled respectively RX/TX. Communication parameters are a baudrate at 115200, 8bits of data, no parity and 1 stop bit (8N1). 48 | 49 | ## 4- Description 50 | 51 | **Pinmap** 52 | 53 | The following pins are used by the program : 54 | PA25 : input/output (USB DP) 55 | PA24 : input/output (USB DM) 56 | PA11 : input (USART RX) 57 | PA10 : output (USART TX) 58 | 59 | The application board shall avoid driving the PA25, PA24, PB23 and PB22 signals while the boot program is running (after a POR for example). 60 | 61 | **Clock system** 62 | 63 | CPU runs at 48MHz from Generic Clock Generator 0 on DFLL48M. 64 | 65 | Generic Clock Generator 1 is using external 32kHz oscillator and is the source of DFLL48M. 66 | 67 | USB and USART are using Generic Clock Generator 0 also. 68 | 69 | **Memory Mapping** 70 | 71 | Bootloader code will be located at 0x0 and executed before any applicative code. 72 | 73 | Applications compiled to be executed along with the bootloader will start at 0x2000 (see linker script bootloader_samd21x18.ld). 74 | 75 | Before jumping to the application, the bootloader changes the VTOR register to use the interrupt vectors of the application @0x2000.<- not required as application code is taking care of this. 76 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/libraries/USBHost/examples/MouseController/MouseController.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Mouse Controller Example 3 | 4 | Shows the output of a USB Mouse connected to 5 | the Native USB port on an Arduino Due Board. 6 | 7 | created 8 Oct 2012 8 | by Cristian Maglie 9 | 10 | http://arduino.cc/en/Tutorial/MouseController 11 | 12 | This sample code is part of the public domain. 13 | */ 14 | 15 | // Require mouse control library 16 | #include 17 | 18 | // Initialize USB Controller 19 | USBHost usb; 20 | 21 | // Attach mouse controller to USB 22 | MouseController mouse(usb); 23 | 24 | // variables for mouse button states 25 | boolean leftButton = false; 26 | boolean middleButton = false; 27 | boolean rightButton = false; 28 | 29 | // This function intercepts mouse movements 30 | void mouseMoved() { 31 | SERIAL_PORT_MONITOR.print("Move: "); 32 | SERIAL_PORT_MONITOR.print(mouse.getXChange()); 33 | SERIAL_PORT_MONITOR.print(", "); 34 | SERIAL_PORT_MONITOR.println(mouse.getYChange()); 35 | } 36 | 37 | // This function intercepts mouse movements while a button is pressed 38 | void mouseDragged() { 39 | SERIAL_PORT_MONITOR.print("DRAG: "); 40 | SERIAL_PORT_MONITOR.print(mouse.getXChange()); 41 | SERIAL_PORT_MONITOR.print(", "); 42 | SERIAL_PORT_MONITOR.println(mouse.getYChange()); 43 | } 44 | 45 | // This function intercepts mouse button press 46 | void mousePressed() { 47 | SERIAL_PORT_MONITOR.print("Pressed: "); 48 | if (mouse.getButton(LEFT_BUTTON)) { 49 | SERIAL_PORT_MONITOR.print("L"); 50 | leftButton = true; 51 | } 52 | if (mouse.getButton(MIDDLE_BUTTON)) { 53 | SERIAL_PORT_MONITOR.print("M"); 54 | middleButton = true; 55 | } 56 | if (mouse.getButton(RIGHT_BUTTON)) { 57 | SERIAL_PORT_MONITOR.print("R"); 58 | rightButton = true; 59 | } 60 | SERIAL_PORT_MONITOR.println(); 61 | } 62 | 63 | // This function intercepts mouse button release 64 | void mouseReleased() { 65 | SERIAL_PORT_MONITOR.print("Released: "); 66 | if (!mouse.getButton(LEFT_BUTTON) && leftButton == true) { 67 | SERIAL_PORT_MONITOR.print("L"); 68 | leftButton = false; 69 | } 70 | if (!mouse.getButton(MIDDLE_BUTTON) && middleButton == true) { 71 | SERIAL_PORT_MONITOR.print("M"); 72 | middleButton = false; 73 | } 74 | if (!mouse.getButton(RIGHT_BUTTON) && rightButton == true) { 75 | SERIAL_PORT_MONITOR.print("R"); 76 | rightButton = false; 77 | } 78 | SERIAL_PORT_MONITOR.println(); 79 | } 80 | 81 | void setup() 82 | { 83 | SERIAL_PORT_MONITOR.begin( 115200 ); 84 | while (!SERIAL_PORT_MONITOR); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection 85 | SERIAL_PORT_MONITOR.println("Mouse Controller Program started"); 86 | 87 | if (usb.Init() == -1) 88 | SERIAL_PORT_MONITOR.println("OSC did not start."); 89 | 90 | delay( 20 ); 91 | } 92 | 93 | void loop() 94 | { 95 | // Process USB tasks 96 | usb.Task(); 97 | } 98 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/bootloaders/zero_osc32k/ATMEL/samr21/source/system_samr21.c: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Low-level initialization functions called upon chip startup. 5 | * 6 | * Copyright (c) 2014 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | 44 | #include "samr21.h" 45 | 46 | /** 47 | * Initial system clock frequency. The System RC Oscillator (RCSYS) provides 48 | * the source for the main clock at chip startup. 49 | */ 50 | #define __SYSTEM_CLOCK (1000000) 51 | 52 | uint32_t SystemCoreClock = __SYSTEM_CLOCK;/*!< System Clock Frequency (Core Clock)*/ 53 | 54 | /** 55 | * Initialize the system 56 | * 57 | * @brief Setup the microcontroller system. 58 | * Initialize the System and update the SystemCoreClock variable. 59 | */ 60 | void SystemInit(void) 61 | { 62 | // Keep the default device state after reset 63 | SystemCoreClock = __SYSTEM_CLOCK; 64 | return; 65 | } 66 | 67 | /** 68 | * Update SystemCoreClock variable 69 | * 70 | * @brief Updates the SystemCoreClock with current core Clock 71 | * retrieved from cpu registers. 72 | */ 73 | void SystemCoreClockUpdate(void) 74 | { 75 | // Not implemented 76 | SystemCoreClock = __SYSTEM_CLOCK; 77 | return; 78 | } 79 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/bootloaders/zero_osc32k/ATMEL/samd21/include/instance/pac0.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Instance description for PAC0 5 | * 6 | * Copyright (c) 2014 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | /** 44 | * Support and FAQ: visit Atmel Support 45 | */ 46 | 47 | #ifndef _SAMD21_PAC0_INSTANCE_ 48 | #define _SAMD21_PAC0_INSTANCE_ 49 | 50 | /* ========== Register definition for PAC0 peripheral ========== */ 51 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 52 | #define REG_PAC0_WPCLR (0x40000000U) /**< \brief (PAC0) Write Protection Clear */ 53 | #define REG_PAC0_WPSET (0x40000004U) /**< \brief (PAC0) Write Protection Set */ 54 | #else 55 | #define REG_PAC0_WPCLR (*(RwReg *)0x40000000U) /**< \brief (PAC0) Write Protection Clear */ 56 | #define REG_PAC0_WPSET (*(RwReg *)0x40000004U) /**< \brief (PAC0) Write Protection Set */ 57 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 58 | 59 | /* ========== Instance parameters for PAC0 peripheral ========== */ 60 | #define PAC0_WPROT_DEFAULT_VAL 0x00000000 // PAC protection mask at reset 61 | 62 | #endif /* _SAMD21_PAC0_INSTANCE_ */ 63 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/bootloaders/zero_osc32k/ATMEL/samd21/include/instance/pac1.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Instance description for PAC1 5 | * 6 | * Copyright (c) 2014 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | /** 44 | * Support and FAQ: visit Atmel Support 45 | */ 46 | 47 | #ifndef _SAMD21_PAC1_INSTANCE_ 48 | #define _SAMD21_PAC1_INSTANCE_ 49 | 50 | /* ========== Register definition for PAC1 peripheral ========== */ 51 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 52 | #define REG_PAC1_WPCLR (0x41000000U) /**< \brief (PAC1) Write Protection Clear */ 53 | #define REG_PAC1_WPSET (0x41000004U) /**< \brief (PAC1) Write Protection Set */ 54 | #else 55 | #define REG_PAC1_WPCLR (*(RwReg *)0x41000000U) /**< \brief (PAC1) Write Protection Clear */ 56 | #define REG_PAC1_WPSET (*(RwReg *)0x41000004U) /**< \brief (PAC1) Write Protection Set */ 57 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 58 | 59 | /* ========== Instance parameters for PAC1 peripheral ========== */ 60 | #define PAC1_WPROT_DEFAULT_VAL 0x00000002 // PAC protection mask at reset 61 | 62 | #endif /* _SAMD21_PAC1_INSTANCE_ */ 63 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/bootloaders/zero_osc32k/ATMEL/samd21/include/instance/pac2.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Instance description for PAC2 5 | * 6 | * Copyright (c) 2014 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | /** 44 | * Support and FAQ: visit Atmel Support 45 | */ 46 | 47 | #ifndef _SAMD21_PAC2_INSTANCE_ 48 | #define _SAMD21_PAC2_INSTANCE_ 49 | 50 | /* ========== Register definition for PAC2 peripheral ========== */ 51 | #if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) 52 | #define REG_PAC2_WPCLR (0x42000000U) /**< \brief (PAC2) Write Protection Clear */ 53 | #define REG_PAC2_WPSET (0x42000004U) /**< \brief (PAC2) Write Protection Set */ 54 | #else 55 | #define REG_PAC2_WPCLR (*(RwReg *)0x42000000U) /**< \brief (PAC2) Write Protection Clear */ 56 | #define REG_PAC2_WPSET (*(RwReg *)0x42000004U) /**< \brief (PAC2) Write Protection Set */ 57 | #endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */ 58 | 59 | /* ========== Instance parameters for PAC2 peripheral ========== */ 60 | #define PAC2_WPROT_DEFAULT_VAL 0x00800000 // PAC protection mask at reset 61 | 62 | #endif /* _SAMD21_PAC2_INSTANCE_ */ 63 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/libraries/I2S/src/utility/I2SDoubleBuffer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016 Arduino LLC. 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 | #include "I2SDoubleBuffer.h" 22 | 23 | I2SDoubleBuffer::I2SDoubleBuffer() 24 | { 25 | reset(); 26 | } 27 | 28 | I2SDoubleBuffer::~I2SDoubleBuffer() 29 | { 30 | } 31 | 32 | void I2SDoubleBuffer::reset() 33 | { 34 | _index = 0; 35 | _length[0] = 0; 36 | _length[1] = 0; 37 | _readOffset[0] = 0; 38 | _readOffset[1] = 0; 39 | } 40 | 41 | size_t I2SDoubleBuffer::availableForWrite() 42 | { 43 | return (I2S_BUFFER_SIZE - (_length[_index] - _readOffset[_index])); 44 | } 45 | 46 | size_t I2SDoubleBuffer::write(const void *buffer, size_t size) 47 | { 48 | size_t space = availableForWrite(); 49 | 50 | if (size > space) { 51 | size = space; 52 | } 53 | 54 | if (size == 0) { 55 | return 0; 56 | } 57 | 58 | memcpy(&_buffer[_index][_length[_index]], buffer, size); 59 | 60 | _length[_index] += size; 61 | 62 | return size; 63 | } 64 | 65 | size_t I2SDoubleBuffer::read(void *buffer, size_t size) 66 | { 67 | size_t avail = available(); 68 | 69 | if (size > avail) { 70 | size = avail; 71 | } 72 | 73 | if (size == 0) { 74 | return 0; 75 | } 76 | 77 | memcpy(buffer, &_buffer[_index][_readOffset[_index]], size); 78 | _readOffset[_index] += size; 79 | 80 | return size; 81 | } 82 | 83 | size_t I2SDoubleBuffer::peek(void *buffer, size_t size) 84 | { 85 | size_t avail = available(); 86 | 87 | if (size > avail) { 88 | size = avail; 89 | } 90 | 91 | if (size == 0) { 92 | return 0; 93 | } 94 | 95 | memcpy(buffer, &_buffer[_index][_readOffset[_index]], size); 96 | 97 | return size; 98 | } 99 | 100 | void* I2SDoubleBuffer::data() 101 | { 102 | return (void*)_buffer[_index]; 103 | } 104 | 105 | size_t I2SDoubleBuffer::available() 106 | { 107 | return _length[_index] - _readOffset[_index]; 108 | } 109 | 110 | void I2SDoubleBuffer::swap(int length) 111 | { 112 | if (_index == 0) { 113 | _index = 1; 114 | } else { 115 | _index = 0; 116 | } 117 | 118 | _length[_index] = length; 119 | _readOffset[_index] = 0; 120 | } 121 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/libraries/USBHost/examples/USB_desc/pgmstrings.h: -------------------------------------------------------------------------------- 1 | #if !defined(__PGMSTRINGS_H__) 2 | #define __PGMSTRINGS_H__ 3 | 4 | #define LOBYTE(x) ((char*)(&(x)))[0] 5 | #define HIBYTE(x) ((char*)(&(x)))[1] 6 | #define BUFSIZE 256 //buffer size 7 | 8 | 9 | /* Print strings in Program Memory */ 10 | const char Gen_Error_str[] PROGMEM = "\r\nRequest error. Error code:\t"; 11 | const char Dev_Header_str[] PROGMEM ="\r\nDevice descriptor: "; 12 | const char Dev_Length_str[] PROGMEM ="\r\nDescriptor Length:\t"; 13 | const char Dev_Type_str[] PROGMEM ="\r\nDescriptor type:\t"; 14 | const char Dev_Version_str[] PROGMEM ="\r\nUSB version:\t\t"; 15 | const char Dev_Class_str[] PROGMEM ="\r\nDevice class:\t\t"; 16 | const char Dev_Subclass_str[] PROGMEM ="\r\nDevice Subclass:\t"; 17 | const char Dev_Protocol_str[] PROGMEM ="\r\nDevice Protocol:\t"; 18 | const char Dev_Pktsize_str[] PROGMEM ="\r\nMax.packet size:\t"; 19 | const char Dev_Vendor_str[] PROGMEM ="\r\nVendor ID:\t\t"; 20 | const char Dev_Product_str[] PROGMEM ="\r\nProduct ID:\t\t"; 21 | const char Dev_Revision_str[] PROGMEM ="\r\nRevision ID:\t\t"; 22 | const char Dev_Mfg_str[] PROGMEM ="\r\nMfg.string index:\t"; 23 | const char Dev_Prod_str[] PROGMEM ="\r\nProd.string index:\t"; 24 | const char Dev_Serial_str[] PROGMEM ="\r\nSerial number index:\t"; 25 | const char Dev_Nconf_str[] PROGMEM ="\r\nNumber of conf.:\t"; 26 | const char Conf_Trunc_str[] PROGMEM ="Total length truncated to 256 bytes"; 27 | const char Conf_Header_str[] PROGMEM ="\r\nConfiguration descriptor:"; 28 | const char Conf_Totlen_str[] PROGMEM ="\r\nTotal length:\t\t"; 29 | const char Conf_Nint_str[] PROGMEM ="\r\nNum.intf:\t\t"; 30 | const char Conf_Value_str[] PROGMEM ="\r\nConf.value:\t\t"; 31 | const char Conf_String_str[] PROGMEM ="\r\nConf.string:\t\t"; 32 | const char Conf_Attr_str[] PROGMEM ="\r\nAttr.:\t\t\t"; 33 | const char Conf_Pwr_str[] PROGMEM ="\r\nMax.pwr:\t\t"; 34 | const char Int_Header_str[] PROGMEM ="\r\n\r\nInterface descriptor:"; 35 | const char Int_Number_str[] PROGMEM ="\r\nIntf.number:\t\t"; 36 | const char Int_Alt_str[] PROGMEM ="\r\nAlt.:\t\t\t"; 37 | const char Int_Endpoints_str[] PROGMEM ="\r\nEndpoints:\t\t"; 38 | const char Int_Class_str[] PROGMEM ="\r\nIntf. Class:\t\t"; 39 | const char Int_Subclass_str[] PROGMEM ="\r\nIntf. Subclass:\t\t"; 40 | const char Int_Protocol_str[] PROGMEM ="\r\nIntf. Protocol:\t\t"; 41 | const char Int_String_str[] PROGMEM ="\r\nIntf.string:\t\t"; 42 | const char End_Header_str[] PROGMEM ="\r\n\r\nEndpoint descriptor:"; 43 | const char End_Address_str[] PROGMEM ="\r\nEndpoint address:\t"; 44 | const char End_Attr_str[] PROGMEM ="\r\nAttr.:\t\t\t"; 45 | const char End_Pktsize_str[] PROGMEM ="\r\nMax.pkt size:\t\t"; 46 | const char End_Interval_str[] PROGMEM ="\r\nPolling interval:\t"; 47 | const char Unk_Header_str[] PROGMEM = "\r\nUnknown descriptor:"; 48 | const char Unk_Length_str[] PROGMEM ="\r\nLength:\t\t"; 49 | const char Unk_Type_str[] PROGMEM ="\r\nType:\t\t"; 50 | const char Unk_Contents_str[] PROGMEM ="\r\nContents:\t"; 51 | 52 | #endif // __PGMSTRINGS_H__ -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/libraries/USBHost/src/message.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. 2 | 3 | This software may be distributed and modified under the terms of the GNU 4 | General Public License version 2 (GPL2) as published by the Free Software 5 | Foundation and appearing in the file GPL2.TXT included in the packaging of 6 | this file. Please note that GPL2 Section 2[b] requires that all works based 7 | on this software must also be made publicly available under the terms of 8 | the GPL2 ("Copyleft"). 9 | 10 | Contact information 11 | ------------------- 12 | 13 | Circuits At Home, LTD 14 | Web : http://www.circuitsathome.com 15 | e-mail : support@circuitsathome.com 16 | */ 17 | #if !defined(_usb_h_) || defined(__MESSAGE_H__) 18 | #error "Never include message.h directly; include Usb.h instead" 19 | #else 20 | #define __MESSAGE_H__ 21 | 22 | extern int UsbDEBUGlvl; 23 | 24 | void E_Notify(char const * msg, int lvl); 25 | void E_Notify(uint8_t b, int lvl); 26 | void E_NotifyStr(char const * msg, int lvl); 27 | void E_Notifyc(char c, int lvl); 28 | 29 | #ifdef DEBUG_USB_HOST 30 | #define Notify E_Notify 31 | #define NotifyStr E_NotifyStr 32 | #define Notifyc E_Notifyc 33 | void NotifyFailGetDevDescr(uint8_t reason); 34 | void NotifyFailSetDevTblEntry(uint8_t reason); 35 | void NotifyFailGetConfDescr(uint8_t reason); 36 | void NotifyFailSetConfDescr(uint8_t reason); 37 | void NotifyFailGetDevDescr(void); 38 | void NotifyFailSetDevTblEntry(void); 39 | void NotifyFailGetConfDescr(void); 40 | void NotifyFailSetConfDescr(void); 41 | void NotifyFailUnknownDevice(uint16_t VID, uint16_t PID); 42 | void NotifyFail(uint8_t rcode); 43 | #else 44 | #define Notify(...) ((void)0) 45 | #define NotifyStr(...) ((void)0) 46 | #define Notifyc(...) ((void)0) 47 | #define NotifyFailGetDevDescr(...) ((void)0) 48 | #define NotifyFailSetDevTblEntry(...) ((void)0) 49 | #define NotifyFailGetConfDescr(...) ((void)0) 50 | #define NotifyFailGetDevDescr(...) ((void)0) 51 | #define NotifyFailSetDevTblEntry(...) ((void)0) 52 | #define NotifyFailGetConfDescr(...) ((void)0) 53 | #define NotifyFailSetConfDescr(...) ((void)0) 54 | #define NotifyFailUnknownDevice(...) ((void)0) 55 | #define NotifyFail(...) ((void)0) 56 | #endif 57 | 58 | #ifdef DEBUG_USB_HOST 59 | template 60 | void ErrorMessage(uint8_t level, char const * msg, ERROR_TYPE rcode = 0) { 61 | Notify(msg, level); 62 | Notify(PSTR(": "), level); 63 | D_PrintHex (rcode, level); 64 | Notify(PSTR("\r\n"), level); 65 | } 66 | 67 | template 68 | void ErrorMessage(char const * msg, ERROR_TYPE rcode = 0) { 69 | Notify(msg, 0x80); 70 | Notify(PSTR(": "), 0x80); 71 | D_PrintHex (rcode, 0x80); 72 | Notify(PSTR("\r\n"), 0x80); 73 | } 74 | #else 75 | template 76 | void ErrorMessage(uint8_t, char const *, ERROR_TYPE = 0) { 77 | } 78 | 79 | template 80 | void ErrorMessage(char const *, ERROR_TYPE = 0) { 81 | } 82 | #endif 83 | 84 | #endif // __MESSAGE_H__ 85 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/bootloaders/zero_osc32k/ATMEL/samd21/source/system_samd21.c: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Low-level initialization functions called upon chip startup. 5 | * 6 | * Copyright (c) 2013-2014 Atmel Corporation. All rights reserved. 7 | * 8 | * \asf_license_start 9 | * 10 | * \page License 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, 19 | * this list of conditions and the following disclaimer in the documentation 20 | * and/or other materials provided with the distribution. 21 | * 22 | * 3. The name of Atmel may not be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * 4. This software may only be redistributed and used in connection with an 26 | * Atmel microcontroller product. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | * POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * \asf_license_stop 41 | * 42 | */ 43 | /** 44 | * Support and FAQ: visit Atmel Support 45 | */ 46 | 47 | #include "samd21.h" 48 | 49 | /** 50 | * Initial system clock frequency. The System RC Oscillator (RCSYS) provides 51 | * the source for the main clock at chip startup. 52 | */ 53 | #define __SYSTEM_CLOCK (1000000) 54 | 55 | uint32_t SystemCoreClock = __SYSTEM_CLOCK;/*!< System Clock Frequency (Core Clock)*/ 56 | 57 | /** 58 | * Initialize the system 59 | * 60 | * @brief Setup the microcontroller system. 61 | * Initialize the System and update the SystemCoreClock variable. 62 | */ 63 | void SystemInit(void) 64 | { 65 | // Keep the default device state after reset 66 | SystemCoreClock = __SYSTEM_CLOCK; 67 | return; 68 | } 69 | 70 | /** 71 | * Update SystemCoreClock variable 72 | * 73 | * @brief Updates the SystemCoreClock with current core Clock 74 | * retrieved from cpu registers. 75 | */ 76 | void SystemCoreClockUpdate(void) 77 | { 78 | // Not implemented 79 | SystemCoreClock = __SYSTEM_CLOCK; 80 | return; 81 | } 82 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/cores/arduino/wiring_digital.h: -------------------------------------------------------------------------------- 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 _WIRING_DIGITAL_ 20 | #define _WIRING_DIGITAL_ 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | #include "WVariant.h" 27 | 28 | /** 29 | * \brief Configures the specified pin to behave either as an input or an output. See the description of digital pins for details. 30 | * 31 | * \param ulPin The number of the pin whose mode you wish to set 32 | * \param ulMode Can be INPUT, OUTPUT, INPUT_PULLUP or INPUT_PULLDOWN 33 | */ 34 | extern void pinMode( uint32_t dwPin, uint32_t dwMode ) ; 35 | 36 | /** 37 | * \brief Write a HIGH or a LOW value to a digital pin. 38 | * 39 | * If the pin has been configured as an OUTPUT with pinMode(), its voltage will be set to the 40 | * corresponding value: 5V (or 3.3V on 3.3V boards) for HIGH, 0V (ground) for LOW. 41 | * 42 | * If the pin is configured as an INPUT, writing a HIGH value with digitalWrite() will enable an internal 43 | * 20K pullup resistor (see the tutorial on digital pins). Writing LOW will disable the pullup. The pullup 44 | * resistor is enough to light an LED dimly, so if LEDs appear to work, but very dimly, this is a likely 45 | * cause. The remedy is to set the pin to an output with the pinMode() function. 46 | * 47 | * \note Digital pin PIN_LED is harder to use as a digital input than the other digital pins because it has an LED 48 | * and resistor attached to it that's soldered to the board on most boards. If you enable its internal 20k pull-up 49 | * resistor, it will hang at around 1.7 V instead of the expected 5V because the onboard LED and series resistor 50 | * pull the voltage level down, meaning it always returns LOW. If you must use pin PIN_LED as a digital input, use an 51 | * external pull down resistor. 52 | * 53 | * \param dwPin the pin number 54 | * \param dwVal HIGH or LOW 55 | */ 56 | extern void digitalWrite( uint32_t dwPin, uint32_t dwVal ) ; 57 | 58 | /** 59 | * \brief Reads the value from a specified digital pin, either HIGH or LOW. 60 | * 61 | * \param ulPin The number of the digital pin you want to read (int) 62 | * 63 | * \return HIGH or LOW 64 | */ 65 | extern int digitalRead( uint32_t ulPin ) ; 66 | 67 | #ifdef __cplusplus 68 | } 69 | #endif 70 | 71 | #endif /* _WIRING_DIGITAL_ */ 72 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/bootloaders/zero_osc32k/sam_ba_cdc.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015 Arduino LLC. All right reserved. 3 | Copyright (c) 2015 Atmel Corporation/Thibaut VIARD. All right reserved. 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 | This library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | See the GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public 13 | License along with this library; if not, write to the Free Software 14 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | */ 16 | 17 | #include "sam_ba_cdc.h" 18 | #include "board_driver_usb.h" 19 | 20 | usb_cdc_line_coding_t line_coding= 21 | { 22 | 115200, // baudrate 23 | 0, // 1 Stop Bit 24 | 0, // None Parity 25 | 8 // 8 Data bits 26 | }; 27 | 28 | #define pCdc (&sam_ba_cdc) 29 | 30 | int cdc_putc(/*P_USB_CDC pCdc,*/ int value) 31 | { 32 | /* Send single byte on USB CDC */ 33 | USB_Write(pCdc->pUsb, (const char *)&value, 1, USB_EP_IN); 34 | 35 | return 1; 36 | } 37 | 38 | int cdc_getc(/*P_USB_CDC pCdc*/void) 39 | { 40 | uint8_t rx_char; 41 | 42 | /* Read singly byte on USB CDC */ 43 | USB_Read(pCdc->pUsb, (char *)&rx_char, 1); 44 | 45 | return (int)rx_char; 46 | } 47 | 48 | bool cdc_is_rx_ready(/*P_USB_CDC pCdc*/void) 49 | { 50 | /* Check whether the device is configured */ 51 | if ( !USB_IsConfigured(pCdc) ) 52 | return 0; 53 | 54 | /* Return transfer complete 0 flag status */ 55 | return (pCdc->pUsb->DEVICE.DeviceEndpoint[USB_EP_OUT].EPINTFLAG.bit.TRCPT0); 56 | } 57 | 58 | uint32_t cdc_write_buf(/*P_USB_CDC pCdc,*/ void const* data, uint32_t length) 59 | { 60 | /* Send the specified number of bytes on USB CDC */ 61 | USB_Write(pCdc->pUsb, (const char *)data, length, USB_EP_IN); 62 | return length; 63 | } 64 | 65 | uint32_t cdc_read_buf(/*P_USB_CDC pCdc,*/ void* data, uint32_t length) 66 | { 67 | /* Check whether the device is configured */ 68 | if ( !USB_IsConfigured(pCdc) ) 69 | return 0; 70 | 71 | /* Read from USB CDC */ 72 | return USB_Read(pCdc->pUsb, (char *)data, length); 73 | } 74 | 75 | uint32_t cdc_read_buf_xmd(/*P_USB_CDC pCdc,*/ void* data, uint32_t length) 76 | { 77 | /* Check whether the device is configured */ 78 | if ( !USB_IsConfigured(pCdc) ) 79 | return 0; 80 | 81 | /* Blocking read till specified number of bytes is received */ 82 | // XXX: USB_Read_blocking is not reliable 83 | // return USB_Read_blocking(pCdc, (char *)data, length); 84 | 85 | char *dst = (char *)data; 86 | uint32_t remaining = length; 87 | while (remaining) 88 | { 89 | uint32_t readed = USB_Read(pCdc->pUsb, (char *)dst, remaining); 90 | remaining -= readed; 91 | dst += readed; 92 | } 93 | 94 | return length; 95 | } -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/bootloaders/zero_osc32k/board_driver_serial.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015 Arduino LLC. All right reserved. 3 | Copyright (c) 2015 Atmel Corporation/Thibaut VIARD. 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. 13 | See the GNU 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 UART_DRIVER_H 21 | #define UART_DRIVER_H 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #define PINMUX_UNUSED 0xFFFFFFFF 28 | //#define GCLK_ID_SERCOM0_CORE 0x14 29 | #define GCLK_ID_SERCOM1_CORE 0x15 30 | 31 | /* SERCOM UART available pad settings */ 32 | enum uart_pad_settings { 33 | UART_RX_PAD0_TX_PAD2 = SERCOM_USART_CTRLA_RXPO(0) | SERCOM_USART_CTRLA_TXPO(1), 34 | UART_RX_PAD1_TX_PAD2 = SERCOM_USART_CTRLA_RXPO(1) | SERCOM_USART_CTRLA_TXPO(1), 35 | UART_RX_PAD2_TX_PAD0 = SERCOM_USART_CTRLA_RXPO(2), 36 | UART_RX_PAD3_TX_PAD0 = SERCOM_USART_CTRLA_RXPO(3), 37 | UART_RX_PAD1_TX_PAD0 = SERCOM_USART_CTRLA_RXPO(1), 38 | UART_RX_PAD3_TX_PAD2 = SERCOM_USART_CTRLA_RXPO(3) | SERCOM_USART_CTRLA_TXPO(1), 39 | }; 40 | 41 | /** 42 | * \brief Initializes the UART 43 | * 44 | * \param Pointer to SERCOM instance 45 | * \param Baud value corresponding to the desired baudrate 46 | * \param SERCOM pad settings 47 | */ 48 | void uart_basic_init(Sercom *sercom, uint16_t baud_val, enum uart_pad_settings pad_conf); 49 | 50 | /** 51 | * \brief Disables UART interface 52 | * 53 | * \param Pointer to SERCOM instance 54 | */ 55 | void uart_disable(Sercom *sercom); 56 | 57 | /** 58 | * \brief Sends a single byte through UART interface 59 | * 60 | * \param Pointer to SERCOM instance 61 | * \param Data to send 62 | */ 63 | void uart_write_byte(Sercom *sercom, uint8_t data); 64 | 65 | /** 66 | * \brief Reads a single character from UART interface 67 | * 68 | * \param Pointer to SERCOM instance 69 | * \return Data byte read 70 | */ 71 | uint8_t uart_read_byte(Sercom *sercom); 72 | 73 | /** 74 | * \brief Sends buffer on UART interface 75 | * 76 | * \param Pointer to SERCOM instance 77 | * \param Pointer to data to send 78 | * \param Number of bytes to send 79 | */ 80 | void uart_write_buffer_polled(Sercom *sercom, uint8_t *ptr, uint16_t length); 81 | 82 | /** 83 | * \brief Reads data on UART interface 84 | * 85 | * \param Pointer to SERCOM instance 86 | * \param Pointer to store read data 87 | * \param Number of bytes to read 88 | */ 89 | void uart_read_buffer_polled(Sercom *sercom, uint8_t *ptr, uint16_t length); 90 | 91 | #endif 92 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/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 | -------------------------------------------------------------------------------- /arduino/mini_sam/hardware/samd/2.0.0/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 Utrasonic 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 | { 17 | Wire.begin(); // join i2c bus (address optional for master) 18 | Serial.begin(9600); // start serial communication at 9600bps 19 | } 20 | 21 | int reading = 0; 22 | 23 | void loop() 24 | { 25 | // step 1: instruct sensor to read echoes 26 | Wire.beginTransmission(112); // transmit to device #112 (0x70) 27 | // the address specified in the datasheet is 224 (0xE0) 28 | // but i2c adressing uses the high 7 bits so it's 112 29 | Wire.write(byte(0x00)); // sets register pointer to the command register (0x00) 30 | Wire.write(byte(0x50)); // command sensor to measure in "inches" (0x50) 31 | // use 0x51 for centimeters 32 | // use 0x52 for ping microseconds 33 | Wire.endTransmission(); // stop transmitting 34 | 35 | // step 2: wait for readings to happen 36 | delay(70); // datasheet suggests at least 65 milliseconds 37 | 38 | // step 3: instruct sensor to return a particular echo reading 39 | Wire.beginTransmission(112); // transmit to device #112 40 | Wire.write(byte(0x02)); // sets register pointer to echo #1 register (0x02) 41 | Wire.endTransmission(); // stop transmitting 42 | 43 | // step 4: request reading from sensor 44 | Wire.requestFrom(112, 2); // request 2 bytes from slave device #112 45 | 46 | // step 5: receive reading from sensor 47 | if(2 <= Wire.available()) // if two bytes were received 48 | { 49 | reading = Wire.read(); // receive high byte (overwrites previous reading) 50 | reading = reading << 8; // shift high byte to be high 8 bits 51 | reading |= Wire.read(); // receive low byte as lower 8 bits 52 | Serial.println(reading); // print the reading 53 | } 54 | 55 | delay(250); // wait a bit since people have to read the output :) 56 | } 57 | 58 | 59 | /* 60 | 61 | // The following code changes the address of a Devantech Ultrasonic Range Finder (SRF10 or SRF08) 62 | // usage: changeAddress(0x70, 0xE6); 63 | 64 | void changeAddress(byte oldAddress, byte newAddress) 65 | { 66 | Wire.beginTransmission(oldAddress); 67 | Wire.write(byte(0x00)); 68 | Wire.write(byte(0xA0)); 69 | Wire.endTransmission(); 70 | 71 | Wire.beginTransmission(oldAddress); 72 | Wire.write(byte(0x00)); 73 | Wire.write(byte(0xAA)); 74 | Wire.endTransmission(); 75 | 76 | Wire.beginTransmission(oldAddress); 77 | Wire.write(byte(0x00)); 78 | Wire.write(byte(0xA5)); 79 | Wire.endTransmission(); 80 | 81 | Wire.beginTransmission(oldAddress); 82 | Wire.write(byte(0x00)); 83 | Wire.write(newAddress); 84 | Wire.endTransmission(); 85 | } 86 | 87 | */ 88 | --------------------------------------------------------------------------------