├── .github └── workflows │ └── sync_issues.yml ├── CHANGELOG ├── README.md ├── boards.txt ├── cores └── arduino │ ├── Arduino.h │ ├── Client.h │ ├── HardwareSPI.cpp │ ├── HardwareSPI.h │ ├── HardwareSerial.cpp │ ├── HardwareSerial.h │ ├── HardwareTimer.cpp │ ├── HardwareTimer.h │ ├── IPAddress.cpp │ ├── IPAddress.h │ ├── Print.cpp │ ├── Print.h │ ├── Printable.h │ ├── Server.h │ ├── Stream.cpp │ ├── Stream.h │ ├── Udp.h │ ├── WProgram.h │ ├── WString.cpp │ ├── WString.h │ ├── avr │ ├── dtostrf.c │ ├── dtostrf.h │ └── pgmspace.h │ ├── bit_constants.h │ ├── bits.h │ ├── boards.cpp │ ├── boards.h │ ├── cxxabi-compat.cpp │ ├── ext_interrupts.cpp │ ├── ext_interrupts.h │ ├── io.h │ ├── itoa.c │ ├── itoa.h │ ├── libmaple │ ├── adc.c │ ├── adc.h │ ├── bitband.h │ ├── bkp.c │ ├── bkp.h │ ├── dac.c │ ├── dac.h │ ├── delay.h │ ├── dma.h │ ├── dmaF1.c │ ├── dmaF1.h │ ├── dmaF2.c │ ├── dmaF2.h │ ├── dma_common.h │ ├── exc.S │ ├── exti.c │ ├── exti.h │ ├── flash.c │ ├── flash.h │ ├── fsmc.c │ ├── fsmc.h │ ├── gpio.c │ ├── gpio.h │ ├── gpioF1.c │ ├── gpioF1.h │ ├── gpioF2.c │ ├── gpioF2.h │ ├── i2c.c │ ├── i2c.h │ ├── iwdg.c │ ├── iwdg.h │ ├── libmaple.h │ ├── libmaple_types.h │ ├── main.cpp │ ├── nvic.c │ ├── nvic.h │ ├── pwr.c │ ├── pwr.h │ ├── rcc.c │ ├── rcc.h │ ├── rccF1.c │ ├── rccF1.h │ ├── rccF2.c │ ├── rccF2.h │ ├── ring_buffer.h │ ├── rules.mk │ ├── scb.h │ ├── spi.c │ ├── spi.h │ ├── spiF4.h │ ├── spi_f4.c │ ├── spi_private.h │ ├── stm32.h │ ├── syscalls.c │ ├── systick.c │ ├── systick.h │ ├── timer.c │ ├── timer.h │ ├── usart.c │ ├── usart.h │ ├── usbF4 │ │ ├── STM32_USB_Device_Library │ │ │ ├── Class │ │ │ │ ├── audio │ │ │ │ │ └── inc │ │ │ │ │ │ ├── usbd_audio_core.h │ │ │ │ │ │ └── usbd_audio_out_if.h │ │ │ │ ├── cdc │ │ │ │ │ ├── inc │ │ │ │ │ │ ├── usbd_cdc_core.h │ │ │ │ │ │ └── usbd_cdc_if_template.h │ │ │ │ │ └── src │ │ │ │ │ │ └── usbd_cdc_core.c │ │ │ │ ├── dfu │ │ │ │ │ └── inc │ │ │ │ │ │ ├── usbd_dfu_core.h │ │ │ │ │ │ ├── usbd_dfu_mal.h │ │ │ │ │ │ ├── usbd_flash_if.h │ │ │ │ │ │ ├── usbd_mem_if_template.h │ │ │ │ │ │ └── usbd_otp_if.h │ │ │ │ ├── hid │ │ │ │ │ └── inc │ │ │ │ │ │ └── usbd_hid_core.h │ │ │ │ └── msc │ │ │ │ │ └── inc │ │ │ │ │ ├── usbd_msc_bot.h │ │ │ │ │ ├── usbd_msc_core.h │ │ │ │ │ ├── usbd_msc_data.h │ │ │ │ │ ├── usbd_msc_mem.h │ │ │ │ │ └── usbd_msc_scsi.h │ │ │ ├── Core │ │ │ │ ├── inc │ │ │ │ │ ├── usbd_conf_template.h │ │ │ │ │ ├── usbd_core.h │ │ │ │ │ ├── usbd_def.h │ │ │ │ │ ├── usbd_ioreq.h │ │ │ │ │ ├── usbd_req.h │ │ │ │ │ └── usbd_usr.h │ │ │ │ └── src │ │ │ │ │ ├── usbd_core.c │ │ │ │ │ ├── usbd_ioreq.c │ │ │ │ │ └── usbd_req.c │ │ │ └── Release_Notes.html │ │ ├── STM32_USB_OTG_Driver │ │ │ ├── Release_Notes.html │ │ │ ├── inc │ │ │ │ ├── usb_bsp.h │ │ │ │ ├── usb_conf_template.h │ │ │ │ ├── usb_core.h │ │ │ │ ├── usb_dcd.h │ │ │ │ ├── usb_dcd_int.h │ │ │ │ ├── usb_defines.h │ │ │ │ ├── usb_hcd.h │ │ │ │ ├── usb_hcd_int.h │ │ │ │ ├── usb_otg.h │ │ │ │ └── usb_regs.h │ │ │ └── src │ │ │ │ ├── usb_core.c │ │ │ │ ├── usb_dcd.c │ │ │ │ └── usb_dcd_int.c │ │ ├── VCP │ │ │ ├── core_cm4.h │ │ │ ├── core_cmInstr.h │ │ │ ├── misc.c │ │ │ ├── misc.h │ │ │ ├── usb_bsp.c │ │ │ ├── usb_conf.h │ │ │ ├── usbd_cdc_vcp.c │ │ │ ├── usbd_cdc_vcp.h │ │ │ ├── usbd_conf.h │ │ │ ├── usbd_desc.c │ │ │ ├── usbd_desc.h │ │ │ └── usbd_usr.c │ │ ├── usb.c │ │ └── usb.h │ ├── util.c │ └── util.h │ ├── pwm.cpp │ ├── pwm.h │ ├── usb_serial.cpp │ ├── usb_serial.h │ ├── wirish.h │ ├── wirish_analog.cpp │ ├── wirish_constants.h │ ├── wirish_debug.h │ ├── wirish_digital.cpp │ ├── wirish_math.cpp │ ├── wirish_math.h │ ├── wirish_shift.cpp │ ├── wirish_time.cpp │ ├── wirish_time.h │ └── wirish_types.h ├── driver ├── usb_device.cat └── usb_device.inf ├── libraries ├── RTClock │ ├── RTClock.cpp │ └── RTClock.h ├── SD │ ├── File.cpp │ ├── README.txt │ ├── SD.cpp │ ├── SD.h │ ├── examples │ │ ├── CardInfo │ │ │ └── CardInfo.ino │ │ ├── Datalogger │ │ │ └── Datalogger.ino │ │ ├── DumpFile │ │ │ └── DumpFile.ino │ │ ├── Files │ │ │ └── Files.ino │ │ ├── ReadWrite │ │ │ └── ReadWrite.ino │ │ └── listfiles │ │ │ └── listfiles.ino │ ├── keywords.txt │ └── utility │ │ ├── FatStructs.h │ │ ├── Sd2Card.cpp │ │ ├── Sd2Card.h │ │ ├── Sd2PinMap.h │ │ ├── SdFat.h │ │ ├── SdFatUtil.h │ │ ├── SdFatmainpage.h │ │ ├── SdFile.cpp │ │ ├── SdInfo.h │ │ ├── SdVolume.cpp │ │ └── platform_conf.h ├── SPI │ ├── SPI.cpp │ └── SPI.h ├── WS2812 │ ├── Seeed_ws2812.cpp │ ├── Seeed_ws2812.h │ └── examples │ │ └── ws2812 │ │ └── ws2812.ino └── Wire │ ├── Wire.cpp │ ├── Wire.h │ ├── master_reader │ └── master_reader.ino │ └── master_writer │ └── master_writer.ino ├── platform.txt └── variants └── discovery_f407 ├── discovery_f4.cpp ├── discovery_f4.h ├── ld ├── common.inc ├── extra_libs.inc ├── flash.ld ├── jtag.ld ├── names.inc ├── ram.ld └── vector_symbols.inc ├── pins_arduino.h ├── stm32_isrs.S ├── stm32_vector_table.S ├── variant.h └── wirish ├── start.S └── start_c.c /.github/workflows/sync_issues.yml: -------------------------------------------------------------------------------- 1 | name: Automate Issue Management 2 | 3 | on: 4 | issues: 5 | types: 6 | - opened 7 | - edited 8 | - assigned 9 | - unassigned 10 | - labeled 11 | - unlabeled 12 | - reopened 13 | 14 | jobs: 15 | add_issue_to_project: 16 | runs-on: ubuntu-latest 17 | steps: 18 | - name: Add issue to GitHub Project 19 | uses: actions/add-to-project@v1.0.2 20 | with: 21 | project-url: https://github.com/orgs/Seeed-Studio/projects/17 22 | github-token: ${{ secrets.ISSUE_ASSEMBLE }} 23 | labeled: bug 24 | label-operator: NOT -------------------------------------------------------------------------------- /CHANGELOG: -------------------------------------------------------------------------------- 1 | Seeed_STM32F4 core 1.2.4 2018.11.16 2 | * Add usbEnableSmartBlockingTx to avoid indefinite blocking. 3 | 4 | Seeed_STM32F4 core 1.2.4 2018.11.14 5 | 6 | * boards.txt: add macro ARDUINO_ARCH_STM32F4 in build.extra_flags 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | STM32F4 Arduino Core 2 | === 3 | 4 | This is an Arduino porting for STM32F405/407. 5 | 6 | 7 | ## How To Use 8 | 9 | 10 | 11 | Copy and paste the json URL to **Additional Boards Manager URLs** 12 | 13 | https://raw.githubusercontent.com/Seeed-Studio/Seeed_Platform/master/package_legacy_seeeduino_boards_index.json 14 | 15 | Search and install **Seeed STM32F4 Boards** within **Arduino Board Manager**. 16 | 17 | ## Special demostrations 18 | ### MCU enter standby mode 19 | 20 | ```C 21 | #include 22 | 23 | void setup() { 24 | pwr_enter_standby_mode(); 25 | 26 | } 27 | 28 | void loop() { 29 | // put your main code here, to run repeatedly: 30 | 31 | } 32 | ``` 33 | 34 | ### External interrupt 35 | ```C 36 | #include 37 | 38 | const int LedPin = 20; 39 | const int BtnPin = 38; 40 | const int SocketPwrPin = 26; 41 | static bool led_state = false; 42 | 43 | void led_change(void) 44 | { 45 | led_state = !led_state; 46 | led_state ? digitalWrite(20, HIGH) : digitalWrite(20, LOW); 47 | } 48 | 49 | void setup() { 50 | /* Turn on Seeed Wio LTE Cat.1 grove socket power */ 51 | pinMode(SocketPwrPin, OUTPUT); 52 | digitalWrite(SocketPwrPin, HIGH); 53 | 54 | /* Led pin */ 55 | pinMode(LedPin, OUTPUT); 56 | digitalWrite(LedPin, LOW); 57 | 58 | pinMode(BtnPin, INPUT); 59 | attachInterrupt(BtnPin, led_change, RISING); 60 | attachInterrupt(BtnPin, led_change, FALLING); 61 | } 62 | 63 | void loop() { 64 | 65 | } 66 | ``` 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /boards.txt: -------------------------------------------------------------------------------- 1 | ############################################################## 2 | 3 | wioGpsM4.name=Wio Tracker LTE 4 | 5 | wioGpsM4.upload.tool=stm32flash 6 | wioGpsM4.upload.protocol=dfu 7 | 8 | wioGpsM4.upload.use_1200bps_touch=true 9 | wioGpsM4.upload.file_type=bin 10 | wioGpsM4.upload.ram.maximum_size=196608 11 | wioGpsM4.upload.flash.maximum_size=1048576 12 | wioGpsM4.upload.maximum_size=1048576 13 | 14 | wioGpsM4.upload.usbID=0483:df11 15 | wioGpsM4.upload.altID=0 16 | wioGpsM4.upload.auto_reset=true 17 | wioGpsM4.upload.dfuse_addr=0x8000000 18 | 19 | wioGpsM4.build.mcu=cortex-m4 20 | wioGpsM4.build.f_cpu=168000000L 21 | wioGpsM4.build.core=arduino 22 | wioGpsM4.build.extra_flags=-DMCU_STM32F406VG -mthumb -DSTM32_HIGH_DENSITY -DSTM32F2 -DSTM32F4 -DBOARD_discovery_f4 -DARDUINO_STM32F4_WIO_GPS -DARDUINO_ARCH_STM32F4 23 | wioGpsM4.build.ldscript=ld/jtag.ld 24 | wioGpsM4.build.variant=discovery_f407 25 | wioGpsM4.build.variant_system_lib=lib_f407.a 26 | wioGpsM4.build.vect=VECT_TAB_BASE 27 | wioGpsM4.build.density=STM32_HIGH_DENSITY 28 | wioGpsM4.build.error_led_port=GPIOD 29 | wioGpsM4.build.error_led_pin=14 30 | wioGpsM4.build.board=WioGpsM4 31 | 32 | ############################################################## 33 | 34 | -------------------------------------------------------------------------------- /cores/arduino/Arduino.h: -------------------------------------------------------------------------------- 1 | #ifndef Arduino_h 2 | #define Arduino_h 3 | #include "WProgram.h" 4 | #endif 5 | 6 | #include "variant.h" 7 | -------------------------------------------------------------------------------- /cores/arduino/Client.h: -------------------------------------------------------------------------------- 1 | /* 2 | Client.h - Base class that provides Client 3 | Copyright (c) 2011 Adrian McEwen. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef client_h 21 | #define client_h 22 | #include "Print.h" 23 | #include "Stream.h" 24 | #include "IPAddress.h" 25 | 26 | class Client : public Stream { 27 | 28 | public: 29 | virtual int connect(IPAddress ip, uint16_t port) =0; 30 | virtual int connect(const char *host, uint16_t port) =0; 31 | virtual size_t write(uint8_t) =0; 32 | virtual size_t write(const uint8_t *buf, size_t size) =0; 33 | virtual int available() = 0; 34 | virtual int read() = 0; 35 | virtual int read(uint8_t *buf, size_t size) = 0; 36 | virtual int peek() = 0; 37 | virtual void flush() = 0; 38 | virtual void stop() = 0; 39 | virtual uint8_t connected() = 0; 40 | virtual operator bool() = 0; 41 | protected: 42 | uint8_t* rawIPAddress(IPAddress& addr) { return addr.raw_address(); }; 43 | }; 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /cores/arduino/HardwareSerial.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * The MIT License 3 | * 4 | * Copyright (c) 2010 Perry Hung. 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, copy, 10 | * modify, merge, publish, distribute, sublicense, and/or sell copies 11 | * of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be 15 | * included in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | *****************************************************************************/ 26 | 27 | /** 28 | * @file HardwareSerial.h 29 | * @brief Wirish serial port interface. 30 | */ 31 | 32 | #ifndef _HARDWARESERIAL_H_ 33 | #define _HARDWARESERIAL_H_ 34 | 35 | #include "libmaple_types.h" 36 | #include "usart.h" 37 | 38 | #include "Stream.h" 39 | 40 | /* 41 | * IMPORTANT: 42 | * 43 | * This class documented "by hand" (i.e., not using Doxygen) in the 44 | * leaflabs-docs/ repository. 45 | * 46 | * If you alter the public HardwareSerial interface, you MUST update 47 | * the documentation accordingly. 48 | */ 49 | 50 | class HardwareSerial : public Stream { 51 | public: 52 | HardwareSerial(usart_dev *usart_device, 53 | uint8 tx_pin, 54 | uint8 rx_pin); 55 | 56 | /* Set up/tear down */ 57 | void begin(uint32 baud); 58 | void end(void); 59 | 60 | /* I/O */ 61 | virtual int available(void); 62 | virtual int peek(void); 63 | virtual void flush(void); 64 | uint32 pending(void); 65 | virtual int read(void); 66 | virtual size_t write(unsigned char); 67 | using Print::write; 68 | operator bool() { return true; } 69 | 70 | /* Pin accessors */ 71 | int txPin(void) { return this->tx_pin; } 72 | int rxPin(void) { return this->rx_pin; } 73 | private: 74 | usart_dev *usart_device; 75 | uint8 tx_pin; 76 | uint8 rx_pin; 77 | }; 78 | 79 | extern HardwareSerial Serial; 80 | extern HardwareSerial Serial1; 81 | extern HardwareSerial Serial2; 82 | #if defined(STM32_HIGH_DENSITY) && !defined(BOARD_maple_RET6) 83 | extern HardwareSerial Serial3; 84 | extern HardwareSerial Serial4; 85 | #endif 86 | extern HardwareSerial &SerialDebug; 87 | #endif 88 | -------------------------------------------------------------------------------- /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 25 | #include 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 | String toString(); 68 | 69 | friend class EthernetClass; 70 | friend class UDP; 71 | friend class Client; 72 | friend class Server; 73 | friend class DhcpClass; 74 | friend class DNSClient; 75 | }; 76 | 77 | const IPAddress INADDR_NONE(0,0,0,0); 78 | 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /cores/arduino/Print.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Print.h - Base class that provides print() and println() 3 | * Copyright (c) 2008 David A. Mellis. All right reserved. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public License 7 | * as published by the Free Software Foundation; either version 2.1 of 8 | * the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, but 11 | * 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 18 | * 02110-1301 USA. 19 | * 20 | * Modified 12 April 2011 by Marti Bolivar 21 | */ 22 | 23 | #ifndef _WIRISH_PRINT_H_ 24 | #define _WIRISH_PRINT_H_ 25 | 26 | #include 27 | #include "WString.h" 28 | #include "Printable.h" 29 | 30 | enum { 31 | BYTE = 0, 32 | BIN = 2, 33 | OCT = 8, 34 | DEC = 10, 35 | HEX = 16 36 | }; 37 | 38 | class Print { 39 | public: 40 | virtual size_t write(uint8 ch) = 0; 41 | virtual size_t write(const char *str); 42 | virtual size_t write(const void *buf, uint32 len); 43 | 44 | size_t print(const String &); 45 | size_t print(char); 46 | size_t print(const char[]); 47 | size_t print(uint8, int=DEC); 48 | size_t print(int, int=DEC); 49 | size_t print(unsigned int, int=DEC); 50 | size_t print(long, int=DEC); 51 | size_t print(unsigned long, int=DEC); 52 | size_t print(long long, int=DEC); 53 | size_t print(unsigned long long, int=DEC); 54 | size_t print(double, int=2); 55 | size_t print(const __FlashStringHelper *); 56 | size_t print(const Printable&); 57 | size_t println(void); 58 | size_t println(const String &s); 59 | size_t println(char); 60 | size_t println(const char[]); 61 | size_t println(uint8, int=DEC); 62 | size_t println(int, int=DEC); 63 | size_t println(unsigned int, int=DEC); 64 | size_t println(long, int=DEC); 65 | size_t println(unsigned long, int=DEC); 66 | size_t println(long long, int=DEC); 67 | size_t println(unsigned long long, int=DEC); 68 | size_t println(double, int=2); 69 | size_t println(const __FlashStringHelper *); 70 | size_t println(const Printable&); 71 | #ifdef SUPPORTS_PRINTF 72 | // Roger Clark. Work in progress to add printf support 73 | int printf(const char * format, ...); 74 | #endif 75 | Print() : write_error(0) {} 76 | 77 | int getWriteError() { return write_error; } 78 | void clearWriteError() { setWriteError(0); } 79 | 80 | protected: 81 | void setWriteError(int err = 1) { write_error = err; } 82 | 83 | private: 84 | int write_error; 85 | size_t printNumber(unsigned long long, uint8); 86 | size_t printFloat(double, uint8); 87 | }; 88 | 89 | #endif 90 | -------------------------------------------------------------------------------- /cores/arduino/Printable.h: -------------------------------------------------------------------------------- 1 | /* 2 | Printable.h - Interface class that allows printing of complex types 3 | Copyright (c) 2011 Adrian McEwen. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef Printable_h 21 | #define Printable_h 22 | 23 | #include 24 | 25 | class Print; 26 | 27 | /** The Printable class provides a way for new classes to allow themselves to be printed. 28 | By deriving from Printable and implementing the printTo method, it will then be possible 29 | for users to print out instances of this class by passing them into the usual 30 | Print::print and Print::println methods. 31 | */ 32 | 33 | class Printable 34 | { 35 | public: 36 | virtual size_t printTo(Print& p) const = 0; 37 | }; 38 | 39 | #endif 40 | 41 | -------------------------------------------------------------------------------- /cores/arduino/Server.h: -------------------------------------------------------------------------------- 1 | /* 2 | Server.h - Base class that provides Server 3 | Copyright (c) 2011 Adrian McEwen. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef server_h 21 | #define server_h 22 | 23 | #include "Print.h" 24 | 25 | class Server : public Print { 26 | public: 27 | virtual void begin() =0; 28 | }; 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /cores/arduino/WProgram.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * The MIT License 3 | * 4 | * Copyright (c) 2010 LeafLabs LLC. 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, copy, 10 | * modify, merge, publish, distribute, sublicense, and/or sell copies 11 | * of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be 15 | * included in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | *****************************************************************************/ 26 | 27 | #include "wirish.h" 28 | 29 | void setup(); 30 | void loop(); 31 | -------------------------------------------------------------------------------- /cores/arduino/avr/dtostrf.c: -------------------------------------------------------------------------------- 1 | /* 2 | dtostrf - Emulation for dtostrf function from avr-libc 3 | Copyright (c) 2013 Arduino. All rights reserved. 4 | Written by Cristian Maglie 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include 22 | 23 | char *dtostrf (double val, signed char width, unsigned char prec, char *sout) { 24 | char fmt[20]; 25 | sprintf(fmt, "%%%d.%df", width, prec); 26 | sprintf(sout, fmt, val); 27 | return sout; 28 | } 29 | 30 | -------------------------------------------------------------------------------- /cores/arduino/avr/dtostrf.h: -------------------------------------------------------------------------------- 1 | /* 2 | dtostrf - Emulation for dtostrf function from avr-libc 3 | Copyright (c) 2013 Arduino. All rights reserved. 4 | Written by Cristian Maglie 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | char *dtostrf (double val, signed char width, unsigned char prec, char *sout); 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif 30 | -------------------------------------------------------------------------------- /cores/arduino/avr/pgmspace.h: -------------------------------------------------------------------------------- 1 | #ifndef __PGMSPACE_H_ 2 | #define __PGMSPACE_H_ 1 3 | 4 | #include 5 | 6 | #define PROGMEM 7 | #define PGM_P const char * 8 | #define PSTR(str) (str) 9 | 10 | #define _SFR_BYTE(n) (n) 11 | 12 | typedef void prog_void; 13 | typedef char prog_char; 14 | typedef unsigned char prog_uchar; 15 | typedef int8_t prog_int8_t; 16 | typedef uint8_t prog_uint8_t; 17 | typedef int16_t prog_int16_t; 18 | typedef uint16_t prog_uint16_t; 19 | typedef int32_t prog_int32_t; 20 | typedef uint32_t prog_uint32_t; 21 | 22 | #define memcpy_P(dest, src, num) memcpy((dest), (src), (num)) 23 | #define strcpy_P(dest, src) strcpy((dest), (src)) 24 | #define strcat_P(dest, src) strcat((dest), (src)) 25 | #define strcmp_P(a, b) strcmp((a), (b)) 26 | #define strstr_P(a, b) strstr((a), (b)) 27 | #define strlen_P(a) strlen((a)) 28 | #define sprintf_P(s, f, ...) sprintf((s), (f), __VA_ARGS__) 29 | 30 | #define pgm_read_byte(addr) (*(const unsigned char *)(addr)) 31 | #define pgm_read_word(addr) (*(const unsigned short *)(addr)) 32 | #define pgm_read_dword(addr) (*(const unsigned long *)(addr)) 33 | #define pgm_read_float(addr) (*(const float *)(addr)) 34 | 35 | #define pgm_read_byte_near(addr) pgm_read_byte(addr) 36 | #define pgm_read_word_near(addr) pgm_read_word(addr) 37 | #define pgm_read_dword_near(addr) pgm_read_dword(addr) 38 | #define pgm_read_float_near(addr) pgm_read_float(addr) 39 | #define pgm_read_byte_far(addr) pgm_read_byte(addr) 40 | #define pgm_read_word_far(addr) pgm_read_word(addr) 41 | #define pgm_read_dword_far(addr) pgm_read_dword(addr) 42 | #define pgm_read_float_far(addr) pgm_read_float(addr) 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /cores/arduino/bits.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * The MIT License 3 | * 4 | * Copyright (c) 2010 LeafLabs, LLC. 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, copy, 10 | * modify, merge, publish, distribute, sublicense, and/or sell copies 11 | * of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be 15 | * included in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | *****************************************************************************/ 26 | 27 | /* Note: Use of this header file is deprecated. Use bit_constants.h 28 | instead. */ 29 | 30 | #include "bit_constants.h" 31 | -------------------------------------------------------------------------------- /cores/arduino/cxxabi-compat.cpp: -------------------------------------------------------------------------------- 1 | /* We compile with nodefaultlibs, so we need to provide an error 2 | * handler for an empty pure virtual function */ 3 | extern "C" void __cxa_pure_virtual(void) { 4 | while(1) 5 | ; 6 | } 7 | -------------------------------------------------------------------------------- /cores/arduino/ext_interrupts.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * The MIT License 3 | * 4 | * Copyright (c) 2010 Perry Hung. 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, copy, 10 | * modify, merge, publish, distribute, sublicense, and/or sell copies 11 | * of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be 15 | * included in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | *****************************************************************************/ 26 | 27 | /** 28 | * @file ext_interrupts.c 29 | * 30 | * @brief Wiring-like interface for external interrupts 31 | */ 32 | 33 | #include "boards.h" 34 | #include "gpio.h" 35 | #include "exti.h" 36 | #include "ext_interrupts.h" 37 | 38 | static inline exti_trigger_mode exti_out_mode(ExtIntTriggerMode mode); 39 | 40 | /** 41 | * @brief Attach an interrupt handler to a pin, triggering on the given mode. 42 | * @param pin Pin to attach an interrupt handler onto. 43 | * @param handler Function to call when the external interrupt is triggered. 44 | * @param mode Trigger mode for the given interrupt. 45 | * @see ExtIntTriggerMode 46 | */ 47 | void attachInterrupt(uint8 pin, voidFuncPtr handler, ExtIntTriggerMode mode) { 48 | if (pin >= BOARD_NR_GPIO_PINS || !handler) { 49 | return; 50 | } 51 | 52 | exti_trigger_mode outMode = exti_out_mode(mode); 53 | 54 | exti_attach_interrupt((afio_exti_num)(PIN_MAP[pin].gpio_bit), 55 | gpio_exti_port(PIN_MAP[pin].gpio_device), 56 | handler, 57 | outMode); 58 | } 59 | 60 | /** 61 | * @brief Disable any external interrupt attached to a pin. 62 | * @param pin Pin number to detach any interrupt from. 63 | */ 64 | void detachInterrupt(uint8 pin) { 65 | if (pin >= BOARD_NR_GPIO_PINS) { 66 | return; 67 | } 68 | 69 | exti_detach_interrupt((afio_exti_num)(PIN_MAP[pin].gpio_bit)); 70 | } 71 | 72 | static inline exti_trigger_mode exti_out_mode(ExtIntTriggerMode mode) { 73 | switch (mode) { 74 | case RISING: 75 | return EXTI_RISING; 76 | case FALLING: 77 | return EXTI_FALLING; 78 | case CHANGE: 79 | return EXTI_RISING_FALLING; 80 | } 81 | // Can't happen 82 | ASSERT(0); 83 | return (exti_trigger_mode)0; 84 | } 85 | -------------------------------------------------------------------------------- /cores/arduino/itoa.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011 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 _ITOA_ 20 | #define _ITOA_ 21 | 22 | #ifdef __cplusplus 23 | extern "C"{ 24 | #endif // __cplusplus 25 | 26 | #if 0 27 | 28 | extern void itoa( int n, char s[] ) ; 29 | 30 | #else 31 | 32 | extern char* itoa( int value, char *string, int radix ) ; 33 | extern char* ltoa( long value, char *string, int radix ) ; 34 | extern char* utoa( unsigned long value, char *string, int radix ) ; 35 | extern char* ultoa( unsigned long value, char *string, int radix ) ; 36 | #endif /* 0 */ 37 | 38 | #ifdef __cplusplus 39 | } // extern "C" 40 | #endif // __cplusplus 41 | 42 | #endif // _ITOA_ 43 | -------------------------------------------------------------------------------- /cores/arduino/libmaple/delay.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file delay.h 3 | * @brief Delay implementation 4 | */ 5 | 6 | #include "libmaple_types.h" 7 | #include "stm32.h" 8 | 9 | #ifndef _DELAY_H_ 10 | #define _DELAY_H_ 11 | 12 | /** 13 | * @brief Delay the given number of microseconds. 14 | * 15 | * @param us Number of microseconds to delay. 16 | */ 17 | static inline void delay_us(uint32 us) { 18 | us *= STM32_DELAY_US_MULT; 19 | 20 | /* fudge for function call overhead */ 21 | //us--; 22 | asm volatile(" mov r0, %[us] \n\t" 23 | "1: subs r0, #1 \n\t" 24 | " bhi 1b \n\t" 25 | : 26 | : [us] "r" (us) 27 | : "r0"); 28 | } 29 | 30 | static inline void delay_ns100(uint32 us) { 31 | us *= STM32_DELAY_US_MULT; 32 | us /= 10; 33 | 34 | /* fudge for function call overhead */ 35 | //us--; 36 | asm volatile(" mov r0, %[us] \n\t" 37 | "1: subs r0, #1 \n\t" 38 | " bhi 1b \n\t" 39 | : 40 | : [us] "r" (us) 41 | : "r0"); 42 | } 43 | #endif 44 | 45 | -------------------------------------------------------------------------------- /cores/arduino/libmaple/dma.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * The MIT License 3 | * 4 | * Copyright (c) 2010 Perry Hung. 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, copy, 10 | * modify, merge, publish, distribute, sublicense, and/or sell copies 11 | * of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be 15 | * included in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | *****************************************************************************/ 26 | 27 | /** 28 | * @file dma.h 29 | * 30 | * @brief Direct Memory Access peripheral support 31 | */ 32 | 33 | #ifdef STM32F2 34 | #include "dmaF2.h" 35 | #include 36 | #else 37 | #include "dmaF1.h" 38 | #endif 39 | -------------------------------------------------------------------------------- /cores/arduino/libmaple/exc.S: -------------------------------------------------------------------------------- 1 | /* ***************************************************************************** 2 | * The MIT License 3 | * 4 | * Copyright (c) 2010 Perry Hung. 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 | # On an exception, push a fake stack thread mode stack frame and redirect 26 | # thread execution to a thread mode error handler 27 | 28 | # From RM008: 29 | # The SP is decremented by eight words by the completion of the stack push. 30 | # Figure 5-1 shows the contents of the stack after an exception pre-empts the 31 | # current program flow. 32 | # 33 | # Old SP--> 34 | # xPSR 35 | # PC 36 | # LR 37 | # r12 38 | # r3 39 | # r2 40 | # r1 41 | # SP--> r0 42 | 43 | .text 44 | .globl __exc_hardfault 45 | .globl __exc_nmi 46 | .globl __exc_hardfault 47 | .globl __exc_memmanage 48 | .globl __exc_busfault 49 | .globl __exc_usagefault 50 | 51 | .code 16 52 | .thumb_func 53 | __exc_nmi: 54 | mov r0, #1 55 | b __default_exc 56 | 57 | .thumb_func 58 | __exc_hardfault: 59 | mov r0, #2 60 | b __default_exc 61 | 62 | .thumb_func 63 | __exc_memmanage: 64 | mov r0, #3 65 | b __default_exc 66 | 67 | .thumb_func 68 | __exc_busfault: 69 | mov r0, #4 70 | b __default_exc 71 | 72 | .thumb_func 73 | __exc_usagefault: 74 | mov r0, #5 75 | b __default_exc 76 | 77 | .thumb_func 78 | __default_exc: 79 | b __default_exc 80 | 81 | 82 | ldr r2, NVIC_CCR @ Enable returning to thread mode even if there are 83 | mov r1 ,#1 @ pending exceptions. See flag NONEBASETHRDENA. 84 | str r1, [r2] 85 | cpsid i @ Disable global interrupts 86 | ldr r2, SYSTICK_CSR @ Disable systick handler 87 | mov r1, #0 88 | str r1, [r2] 89 | ldr r1, CPSR_MASK @ Set default CPSR 90 | push {r1} 91 | ldr r1, TARGET_PC @ Set target pc 92 | push {r1} 93 | sub sp, sp, #24 @ Don't care 94 | ldr r1, EXC_RETURN @ Return to thread mode 95 | mov lr, r1 96 | bx lr @ Exception exit 97 | 98 | .align 4 99 | CPSR_MASK: .word 0x61000000 100 | EXC_RETURN: .word 0xFFFFFFF9 101 | TARGET_PC: .word __error 102 | NVIC_CCR: .word 0xE000ED14 @ NVIC configuration control register 103 | SYSTICK_CSR: .word 0xE000E010 @ Systick control register 104 | 105 | -------------------------------------------------------------------------------- /cores/arduino/libmaple/exti.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * The MIT License 3 | * 4 | * Copyright (c) 2010 Perry Hung. 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, copy, 10 | * modify, merge, publish, distribute, sublicense, and/or sell copies 11 | * of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be 15 | * included in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | *****************************************************************************/ 26 | 27 | /** 28 | * @file exti.h 29 | * @brief External interrupt control prototypes and defines 30 | */ 31 | 32 | /* See notes/exti.txt for more info */ 33 | 34 | #include "libmaple.h" 35 | #include "gpio.h" 36 | 37 | #ifndef _EXTI_H_ 38 | #define _EXTI_H_ 39 | 40 | #ifdef __cplusplus 41 | extern "C"{ 42 | #endif 43 | 44 | /** EXTI register map type */ 45 | typedef struct exti_reg_map { 46 | __io uint32 IMR; /**< Interrupt mask register */ 47 | __io uint32 EMR; /**< Event mask register */ 48 | __io uint32 RTSR; /**< Rising trigger selection register */ 49 | __io uint32 FTSR; /**< Falling trigger selection register */ 50 | __io uint32 SWIER; /**< Software interrupt event register */ 51 | __io uint32 PR; /**< Pending register */ 52 | } exti_reg_map; 53 | 54 | /** EXTI register map base pointer */ 55 | #ifdef STM32F2 56 | #define EXTI_BASE ((struct exti_reg_map*)0x40013C00) 57 | #else 58 | #define EXTI_BASE ((struct exti_reg_map*)0x40010400) 59 | #endif 60 | 61 | /** External interrupt trigger mode */ 62 | typedef enum exti_trigger_mode { 63 | EXTI_RISING, /**< Trigger on the rising edge */ 64 | EXTI_FALLING, /**< Trigger on the falling edge */ 65 | EXTI_RISING_FALLING /**< Trigger on both the rising and falling edges */ 66 | } exti_trigger_mode; 67 | 68 | void exti_attach_interrupt(afio_exti_num num, 69 | afio_exti_port port, 70 | voidFuncPtr handler, 71 | exti_trigger_mode mode); 72 | void exti_detach_interrupt(afio_exti_num num); 73 | 74 | #ifdef __cplusplus 75 | } // extern "C" 76 | #endif 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /cores/arduino/libmaple/flash.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * The MIT License 3 | * 4 | * Copyright (c) 2010 Perry Hung. 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, copy, 10 | * modify, merge, publish, distribute, sublicense, and/or sell copies 11 | * of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be 15 | * included in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | *****************************************************************************/ 26 | 27 | /** 28 | * @file flash.c 29 | * @brief Flash management functions 30 | */ 31 | 32 | #include "libmaple.h" 33 | #include "flash.h" 34 | #include "bitband.h" 35 | 36 | /** 37 | * @brief Turn on the hardware prefetcher. 38 | */ 39 | void flash_enable_prefetch(void) { 40 | *bb_perip(&FLASH_BASE->ACR, FLASH_ACR_PRFTBE_BIT) = 1; 41 | } 42 | 43 | /** 44 | * @brief Set flash wait states 45 | * 46 | * See ST PM0042, section 3.1 for restrictions on the acceptable value 47 | * of wait_states for a given SYSCLK configuration. 48 | * 49 | * @param wait_states number of wait states (one of 50 | * FLASH_WAIT_STATE_0, FLASH_WAIT_STATE_1, 51 | * FLASH_WAIT_STATE_2). 52 | */ 53 | void flash_set_latency(uint32 wait_states) { 54 | uint32 val = FLASH_BASE->ACR; 55 | 56 | val &= ~FLASH_ACR_LATENCY; 57 | val |= wait_states; 58 | 59 | FLASH_BASE->ACR = val; 60 | } 61 | -------------------------------------------------------------------------------- /cores/arduino/libmaple/gpio.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * The MIT License 3 | * 4 | * Copyright (c) 2010 Perry Hung. 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, copy, 10 | * modify, merge, publish, distribute, sublicense, and/or sell copies 11 | * of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be 15 | * included in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | *****************************************************************************/ 26 | 27 | /** 28 | * @file gpio.c 29 | * @brief GPIO initialization routine 30 | */ 31 | 32 | // #ifdef STM32F2 33 | // #include "gpioF2.c" 34 | // #else 35 | // #include "gpioF1.c" 36 | // #endif 37 | -------------------------------------------------------------------------------- /cores/arduino/libmaple/gpio.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * The MIT License 3 | * 4 | * Copyright (c) 2010 Perry Hung. 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, copy, 10 | * modify, merge, publish, distribute, sublicense, and/or sell copies 11 | * of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be 15 | * included in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | *****************************************************************************/ 26 | 27 | /** 28 | * @file gpio.h 29 | * 30 | * @brief General purpose I/O (GPIO) and Alternate Function I/O 31 | * (AFIO) prototypes, defines, and inlined access functions. 32 | */ 33 | 34 | #ifdef STM32F2 35 | #include "gpioF2.h" 36 | #else 37 | #include "gpioF1.h" 38 | #endif 39 | -------------------------------------------------------------------------------- /cores/arduino/libmaple/iwdg.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * The MIT License 3 | * 4 | * Copyright (c) 2010 Michael Hope. 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, copy, 10 | * modify, merge, publish, distribute, sublicense, and/or sell copies 11 | * of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be 15 | * included in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | *****************************************************************************/ 26 | 27 | /** 28 | * @file iwdg.c 29 | * @brief Independent watchdog (IWDG) support 30 | */ 31 | 32 | #include "iwdg.h" 33 | 34 | /** 35 | * @brief Initialise and start the watchdog 36 | * 37 | * The prescaler and reload set the timeout. For example, a prescaler 38 | * of IWDG_PRE_32 divides the 40 kHz clock by 32 and gives roughly 1 39 | * ms per reload. 40 | * 41 | * @param prescaler Prescaler for the 40 kHz IWDG clock. 42 | * @param reload Independent watchdog counter reload value. 43 | */ 44 | void iwdg_init(iwdg_prescaler prescaler, uint16 reload) { 45 | IWDG_BASE->KR = IWDG_KR_UNLOCK; 46 | IWDG_BASE->PR = prescaler; 47 | IWDG_BASE->RLR = reload; 48 | 49 | /* Start things off */ 50 | IWDG_BASE->KR = IWDG_KR_START; 51 | iwdg_feed(); 52 | } 53 | 54 | /** 55 | * @brief Reset the IWDG counter. 56 | * 57 | * Calling this function will cause the IWDG counter to be reset to 58 | * its reload value. 59 | */ 60 | void iwdg_feed(void) { 61 | IWDG_BASE->KR = IWDG_KR_FEED; 62 | } 63 | -------------------------------------------------------------------------------- /cores/arduino/libmaple/libmaple.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * The MIT License 3 | * 4 | * Copyright (c) 2010 Perry Hung. 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, copy, 10 | * modify, merge, publish, distribute, sublicense, and/or sell copies 11 | * of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be 15 | * included in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | *****************************************************************************/ 26 | 27 | /** 28 | * @file libmaple.h 29 | * @brief General include file for libmaple 30 | */ 31 | 32 | #ifndef _LIBMAPLE_H_ 33 | #define _LIBMAPLE_H_ 34 | 35 | #include "libmaple_types.h" 36 | #include "stm32.h" 37 | #include "util.h" 38 | #include "delay.h" 39 | 40 | /* 41 | * Where to put usercode, based on space reserved for bootloader. 42 | * 43 | * FIXME this has no business being here 44 | */ 45 | #if defined(MCU_STM32F103VE) || defined(MCU_STM32F205VE) || defined(MCU_STM32F406VG) 46 | /* e.g., Aeroquad32 */ 47 | #define USER_ADDR_ROM 0x08010000 /* ala42 */ 48 | #define USER_ADDR_RAM 0x20000C00 49 | #define STACK_TOP 0x20000800 50 | #elif defined(BOARD_freeflight) 51 | #define USER_ADDR_ROM 0x08000000 52 | #define USER_ADDR_RAM 0x20000000 53 | #define STACK_TOP 0x20000800 54 | #else 55 | #define USER_ADDR_ROM 0x08005000 56 | #define USER_ADDR_RAM 0x20000C00 57 | #define STACK_TOP 0x20000800 58 | #endif 59 | #endif 60 | 61 | -------------------------------------------------------------------------------- /cores/arduino/libmaple/libmaple_types.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * The MIT License 3 | * 4 | * Copyright (c) 2010 Perry Hung. 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, copy, 10 | * modify, merge, publish, distribute, sublicense, and/or sell copies 11 | * of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be 15 | * included in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | *****************************************************************************/ 26 | 27 | /** 28 | * @file libmaple_types.h 29 | * 30 | * @brief libmaple types 31 | */ 32 | 33 | #ifndef _LIBMAPLE_TYPES_H_ 34 | #define _LIBMAPLE_TYPES_H_ 35 | 36 | typedef unsigned char uint8; 37 | typedef unsigned short uint16; 38 | typedef unsigned int uint32; 39 | typedef unsigned long long uint64; 40 | 41 | typedef signed char int8; 42 | typedef short int16; 43 | typedef int int32; 44 | typedef long long int64; 45 | 46 | typedef void (*voidFuncPtr)(void); 47 | 48 | #define __io volatile 49 | #define __attr_flash __attribute__((section (".USER_FLASH"))) 50 | 51 | #define __always_inline inline __attribute__((always_inline)) 52 | 53 | #ifndef NULL 54 | #define NULL 0 55 | #endif 56 | 57 | #endif 58 | 59 | -------------------------------------------------------------------------------- /cores/arduino/libmaple/main.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * The MIT License 3 | * 4 | * Copyright (c) 2010 LeafLabs LLC. 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, copy, 10 | * modify, merge, publish, distribute, sublicense, and/or sell copies 11 | * of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be 15 | * included in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | *****************************************************************************/ 26 | 27 | extern void setup(void); 28 | extern void loop(void); 29 | extern void init(void); 30 | 31 | // Force init to be called *first*, i.e. before static object allocation. 32 | // Otherwise, statically allocated objects that need libmaple may fail. 33 | __attribute__(( constructor )) void premain() { 34 | init(); 35 | } 36 | 37 | int main(void) { 38 | setup(); 39 | 40 | while (1) { 41 | loop(); 42 | } 43 | return 0; 44 | } 45 | -------------------------------------------------------------------------------- /cores/arduino/libmaple/nvic.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * The MIT License 3 | * 4 | * Copyright (c) 2010 Perry Hung. 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, copy, 10 | * modify, merge, publish, distribute, sublicense, and/or sell copies 11 | * of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be 15 | * included in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | *****************************************************************************/ 26 | 27 | /** 28 | * @file nvic.c 29 | * @brief Nested vector interrupt controller support. 30 | */ 31 | 32 | #include "nvic.h" 33 | #include "scb.h" 34 | #include "stm32.h" 35 | 36 | /** 37 | * @brief Set interrupt priority for an interrupt line 38 | * 39 | * Note: The STM32 only implements 4 bits of priority, ignoring the 40 | * lower 4 bits. This means there are only 16 levels of priority. 41 | * Bits[3:0] read as zero and ignore writes. 42 | * 43 | * @param irqn device to set 44 | * @param priority Priority to set, 0 being highest priority and 15 45 | * being lowest. 46 | */ 47 | void nvic_irq_set_priority(nvic_irq_num irqn, uint8 priority) { 48 | if (irqn < 0) { 49 | /* This interrupt is in the system handler block */ 50 | SCB_BASE->SHP[((uint32)irqn & 0xF) - 4] = (priority & 0xF) << 4; 51 | } else { 52 | NVIC_BASE->IP[irqn] = (priority & 0xF) << 4; 53 | } 54 | } 55 | 56 | /** 57 | * @brief Initialize the NVIC 58 | * @param vector_table_address Vector table base address. 59 | * @param offset Offset from vector_table_address. Some restrictions 60 | * apply to the use of nonzero offsets; see ST RM0008 61 | * and the ARM Cortex M3 Technical Reference Manual. 62 | */ 63 | void nvic_init(uint32 vector_table_address, uint32 offset) { 64 | uint32 i; 65 | 66 | nvic_set_vector_table(vector_table_address, offset); 67 | 68 | /* 69 | * Lower priority level for all peripheral interrupts to lowest 70 | * possible. 71 | */ 72 | for (i = 0; i < STM32_NR_INTERRUPTS; i++) { 73 | nvic_irq_set_priority((nvic_irq_num)i, 0xF); 74 | } 75 | 76 | /* Lower systick interrupt priority to lowest level */ 77 | nvic_irq_set_priority(NVIC_SYSTICK, 0xF); 78 | } 79 | 80 | /** 81 | * Reset the vector table address. 82 | */ 83 | void nvic_set_vector_table(uint32 addr, uint32 offset) { 84 | SCB_BASE->VTOR = addr | (offset & 0x1FFFFF80); 85 | } 86 | -------------------------------------------------------------------------------- /cores/arduino/libmaple/pwr.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * The MIT License 3 | * 4 | * Copyright (c) 2011 LeafLabs, LLC. 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, copy, 10 | * modify, merge, publish, distribute, sublicense, and/or sell copies 11 | * of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be 15 | * included in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | *****************************************************************************/ 26 | 27 | /** 28 | * @file pwr.c 29 | * @brief Power control (PWR) support. 30 | */ 31 | 32 | #include "pwr.h" 33 | #include "rcc.h" 34 | #include "scb.h" 35 | 36 | /** 37 | * Enables the power interface clock, and resets the power device. 38 | */ 39 | void pwr_init(void) { 40 | rcc_clk_enable(RCC_PWR); 41 | rcc_reset_dev(RCC_PWR); 42 | } 43 | 44 | /** 45 | * Let MCU enter power standby mode 46 | */ 47 | void pwr_enter_standby_mode(void) 48 | { 49 | /* Select Standby mode */ 50 | PWR_BASE->CR |= (1 << PWR_CR_PDDS); 51 | 52 | /* Set SLEEPDEEP bit of Cortex System Control Register */ 53 | SCB_BASE->SCR |= (unsigned long)SCB_SCR_SLEEPDEEP_Msk; 54 | 55 | /* Request Wait For Interrupt */ 56 | __asm("wfi"); 57 | 58 | } -------------------------------------------------------------------------------- /cores/arduino/libmaple/pwr.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * The MIT License 3 | * 4 | * Copyright (c) 2010 LeafLabs, LLC. 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, copy, 10 | * modify, merge, publish, distribute, sublicense, and/or sell copies 11 | * of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be 15 | * included in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | *****************************************************************************/ 26 | 27 | /** 28 | * @file pwr.h 29 | * @brief Power control (PWR) defines. 30 | */ 31 | 32 | #include "libmaple.h" 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | /** Power interface register map. */ 39 | typedef struct pwr_reg_map { 40 | __io uint32 CR; /**< Control register */ 41 | __io uint32 CSR; /**< Control and status register */ 42 | } pwr_reg_map; 43 | 44 | /** Power peripheral register map base pointer. */ 45 | #define PWR_BASE ((struct pwr_reg_map*)0x40007000) 46 | 47 | /* 48 | * Register bit definitions 49 | */ 50 | 51 | /* Control register */ 52 | 53 | /** Disable backup domain write protection bit */ 54 | #define PWR_CR_DBP 8 55 | /** Power voltage detector enable bit */ 56 | #define PWR_CR_PVDE 4 57 | /** Clear standby flag bit */ 58 | #define PWR_CR_CSBF 3 59 | /** Clear wakeup flag bit */ 60 | #define PWR_CR_CWUF 2 61 | /** Power down deepsleep bit */ 62 | #define PWR_CR_PDDS 1 63 | /** Low-power deepsleep bit */ 64 | #define PWR_CR_LPDS 0 65 | 66 | /* Control and status register */ 67 | 68 | /** Enable wakeup pin bit */ 69 | #define PWR_CSR_EWUP 8 70 | /** PVD output bit */ 71 | #define PWR_CSR_PVDO 2 72 | /** Standby flag bit */ 73 | #define PWR_CSR_SBF 1 74 | /** Wakeup flag bit */ 75 | #define PWR_CSR_WUF 0 76 | 77 | /* 78 | * Convenience functions 79 | */ 80 | 81 | void pwr_init(void); 82 | 83 | void pwr_enter_standby_mode(void); 84 | 85 | #ifdef __cplusplus 86 | } 87 | #endif 88 | -------------------------------------------------------------------------------- /cores/arduino/libmaple/rcc.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * The MIT License 3 | * 4 | * Copyright (c) 2010 Perry Hung. 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, copy, 10 | * modify, merge, publish, distribute, sublicense, and/or sell copies 11 | * of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be 15 | * included in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | *****************************************************************************/ 26 | 27 | /** 28 | * @file rcc.c 29 | * @brief Implements pretty much only the basic clock setup on the 30 | * stm32, clock enable/disable and peripheral reset commands. 31 | */ 32 | 33 | // #ifdef STM32F2 34 | // #include "rccF2.c" 35 | // #else 36 | // #include "rccF1.c" 37 | // #endif 38 | -------------------------------------------------------------------------------- /cores/arduino/libmaple/rcc.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * The MIT License 3 | * 4 | * Copyright (c) 2010 Perry Hung. 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, copy, 10 | * modify, merge, publish, distribute, sublicense, and/or sell copies 11 | * of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be 15 | * included in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | *****************************************************************************/ 26 | 27 | /** 28 | * @file rcc.h 29 | * @brief reset and clock control definitions and prototypes 30 | */ 31 | 32 | #ifdef STM32F2 33 | #include "rccF2.h" 34 | #else 35 | #include "rccF1.h" 36 | #endif 37 | -------------------------------------------------------------------------------- /cores/arduino/libmaple/rules.mk: -------------------------------------------------------------------------------- 1 | # Standard things 2 | sp := $(sp).x 3 | dirstack_$(sp) := $(d) 4 | d := $(dir) 5 | BUILDDIRS += $(BUILD_PATH)/$(d) 6 | ifneq ($(MCU_FAMILY), STM32F2) 7 | BUILDDIRS += $(BUILD_PATH)/$(d)/usb 8 | BUILDDIRS += $(BUILD_PATH)/$(d)/usb/usb_lib 9 | LIBMAPLE_INCLUDES := -I$(LIBMAPLE_PATH) -I$(LIBMAPLE_PATH)/usb -I$(LIBMAPLE_PATH)/usb/usb_lib 10 | else 11 | BUILDDIRS += $(BUILD_PATH)/$(d)/usbF4/STM32_USB_Device_Library/Core/src 12 | BUILDDIRS += $(BUILD_PATH)/$(d)/usbF4/STM32_USB_Device_Library/Class/cdc/src 13 | BUILDDIRS += $(BUILD_PATH)/$(d)/usbF4/STM32_USB_OTG_Driver/src 14 | BUILDDIRS += $(BUILD_PATH)/$(d)/usbF4/VCP 15 | LIBMAPLE_INCLUDES := -I$(LIBMAPLE_PATH) -I$(LIBMAPLE_PATH)/usbF4 16 | endif 17 | 18 | 19 | # Local flags 20 | CFLAGS_$(d) = -I$(d) $(LIBMAPLE_INCLUDES) -Wall 21 | #-Werror 22 | 23 | # Local rules and targets 24 | # bkp.c 25 | 26 | cSRCS_$(d) := adc.c \ 27 | dac.c \ 28 | dma.c \ 29 | exti.c \ 30 | flash.c \ 31 | fsmc.c \ 32 | gpio.c \ 33 | iwdg.c \ 34 | nvic.c \ 35 | pwr.c \ 36 | i2c.c \ 37 | rcc.c \ 38 | spi.c \ 39 | syscalls.c \ 40 | systick.c \ 41 | timer.c \ 42 | usart.c \ 43 | util.c 44 | 45 | ifneq ($(MCU_FAMILY), STM32F2) 46 | cSRCS_$(d) += \ 47 | usb/descriptors.c \ 48 | usb/usb.c \ 49 | usb/usb_callbacks.c \ 50 | usb/usb_hardware.c \ 51 | usb/usb_lib/usb_core.c \ 52 | usb/usb_lib/usb_init.c \ 53 | usb/usb_lib/usb_int.c \ 54 | usb/usb_lib/usb_mem.c \ 55 | usb/usb_lib/usb_regs.c 56 | else 57 | V=1 58 | cSRCS_$(d) += \ 59 | usbF4/STM32_USB_Device_Library/Core/src/usbd_core.c \ 60 | usbF4/STM32_USB_Device_Library/Core/src/usbd_ioreq.c \ 61 | usbF4/STM32_USB_Device_Library/Core/src/usbd_req.c \ 62 | usbF4/STM32_USB_Device_Library/Class/cdc/src/usbd_cdc_core.c \ 63 | usbF4/STM32_USB_OTG_Driver/src/usb_dcd.c \ 64 | usbF4/STM32_USB_OTG_Driver/src/usb_core.c \ 65 | usbF4/STM32_USB_OTG_Driver/src/usb_dcd_int.c \ 66 | usbF4/VCP/usb_bsp.c \ 67 | usbF4/VCP/usbd_cdc_vcp.c \ 68 | usbF4/VCP/usbd_desc.c \ 69 | usbF4/VCP/usbd_usr.c \ 70 | usbF4/usb.c \ 71 | usbF4/VCP/misc.c 72 | endif 73 | 74 | ifneq ($(MCU_FAMILY), STM32F2) 75 | cSRCS_$(d) += bkp.c 76 | endif 77 | 78 | sSRCS_$(d) := exc.S 79 | 80 | cFILES_$(d) := $(cSRCS_$(d):%=$(d)/%) 81 | sFILES_$(d) := $(sSRCS_$(d):%=$(d)/%) 82 | 83 | OBJS_$(d) := $(cFILES_$(d):%.c=$(BUILD_PATH)/%.o) $(sFILES_$(d):%.S=$(BUILD_PATH)/%.o) 84 | DEPS_$(d) := $(OBJS_$(d):%.o=%.d) 85 | 86 | $(OBJS_$(d)): TGT_CFLAGS := $(CFLAGS_$(d)) 87 | $(OBJS_$(d)): TGT_ASFLAGS := 88 | 89 | TGT_BIN += $(OBJS_$(d)) 90 | 91 | # Standard things 92 | -include $(DEPS_$(d)) 93 | d := $(dirstack_$(sp)) 94 | sp := $(basename $(sp)) 95 | -------------------------------------------------------------------------------- /cores/arduino/libmaple/spiF4.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * The MIT License 3 | * 4 | * Copyright (c) 2011, 2012 LeafLabs, LLC. 5 | * Copyright (c) 2010 Perry Hung. 6 | * 7 | * Permission is hereby granted, free of charge, to any person 8 | * obtaining a copy of this software and associated documentation 9 | * files (the "Software"), to deal in the Software without 10 | * restriction, including without limitation the rights to use, copy, 11 | * modify, merge, publish, distribute, sublicense, and/or sell copies 12 | * 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 16 | * included in all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 22 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 23 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 24 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | * SOFTWARE. 26 | *****************************************************************************/ 27 | 28 | /** 29 | * @file libmaple/stm32f1/include/series/spi.h 30 | * @author Marti Bolivar 31 | * @brief STM32F1 SPI/I2S series header. 32 | */ 33 | 34 | #ifndef _LIBMAPLE_STM32F1_SPI_H_ 35 | #define _LIBMAPLE_STM32F1_SPI_H_ 36 | 37 | #include 38 | 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | /* 44 | * Register map base pointers 45 | */ 46 | 47 | struct spi_reg_map; 48 | 49 | #define SPI1_BASE ((struct spi_reg_map*)0x40013000) 50 | #define SPI2_BASE ((struct spi_reg_map*)0x40003800) 51 | #define SPI3_BASE ((struct spi_reg_map*)0x40003C00) 52 | 53 | /* 54 | * Device pointers 55 | */ 56 | 57 | struct spi_dev; 58 | 59 | extern struct spi_dev *SPI1; 60 | extern struct spi_dev *SPI2; 61 | #if defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY) 62 | extern struct spi_dev *SPI3; 63 | #endif 64 | 65 | /* 66 | * Routines 67 | */ 68 | 69 | /* spi_gpio_cfg(): Backwards compatibility shim to spi_config_gpios() */ 70 | struct gpio_dev; 71 | extern void spi_config_gpios(struct spi_dev*, uint8, 72 | struct gpio_dev*, uint8, 73 | struct gpio_dev*, uint8, 74 | struct gpio_dev*, uint8, 75 | struct gpio_dev*, uint8); 76 | 77 | #ifdef __cplusplus 78 | } 79 | #endif 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /cores/arduino/libmaple/spi_f4.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * The MIT License 3 | * 4 | * Copyright (c) 2011, 2012 LeafLabs, LLC. 5 | * Copyright (c) 2010 Perry Hung. 6 | * 7 | * Permission is hereby granted, free of charge, to any person 8 | * obtaining a copy of this software and associated documentation 9 | * files (the "Software"), to deal in the Software without 10 | * restriction, including without limitation the rights to use, copy, 11 | * modify, merge, publish, distribute, sublicense, and/or sell copies 12 | * 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 16 | * included in all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 22 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 23 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 24 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | * SOFTWARE. 26 | *****************************************************************************/ 27 | 28 | /** 29 | * @file libmaple/stm32f1/spi.c 30 | * @author Marti Bolivar 31 | * @brief STM32F1 SPI/I2S. 32 | */ 33 | 34 | #include 35 | #include 36 | #include "spi_private.h" 37 | 38 | /* 39 | * Devices 40 | */ 41 | 42 | static spi_dev spi1 = SPI_DEV(1); 43 | static spi_dev spi2 = SPI_DEV(2); 44 | 45 | spi_dev *SPI1 = &spi1; 46 | spi_dev *SPI2 = &spi2; 47 | 48 | #if defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY) 49 | static spi_dev spi3 = SPI_DEV(3); 50 | spi_dev *SPI3 = &spi3; 51 | #endif 52 | 53 | /* 54 | * Routines 55 | */ 56 | 57 | void spi_config_gpios(spi_dev *ignored, 58 | uint8 as_master, 59 | gpio_dev *nss_dev, 60 | uint8 nss_bit, 61 | gpio_dev *sck_dev, 62 | uint8 sck_bit, 63 | gpio_dev *miso_dev, 64 | uint8 miso_bit, 65 | gpio_dev *mosi_dev, 66 | uint8 mosi_bit) { 67 | if (as_master) { 68 | // gpio_set_mode(nss_dev, nss_bit, GPIO_AF_OUTPUT_PP); 69 | gpio_set_mode(sck_dev, sck_bit, GPIO_AF_OUTPUT_PP); 70 | // gpio_set_mode(comm_dev, miso_bit, GPIO_INPUT_FLOATING); 71 | gpio_set_mode(miso_dev, miso_bit, GPIO_AF_INPUT_PD); 72 | gpio_set_mode(mosi_dev, mosi_bit, GPIO_AF_OUTPUT_PP); 73 | } else { 74 | gpio_set_mode(nss_dev, nss_bit, GPIO_INPUT_FLOATING); 75 | gpio_set_mode(sck_dev, sck_bit, GPIO_INPUT_FLOATING); 76 | gpio_set_mode(miso_dev, miso_bit, GPIO_AF_OUTPUT_PP); 77 | gpio_set_mode(mosi_dev, mosi_bit, GPIO_INPUT_FLOATING); 78 | } 79 | } 80 | 81 | void spi_foreach(void (*fn)(spi_dev*)) { 82 | fn(SPI1); 83 | fn(SPI2); 84 | #if defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY) 85 | fn(SPI3); 86 | #endif 87 | } 88 | -------------------------------------------------------------------------------- /cores/arduino/libmaple/spi_private.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * The MIT License 3 | * 4 | * Copyright (c) 2012 LeafLabs, LLC. 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, copy, 10 | * modify, merge, publish, distribute, sublicense, and/or sell copies 11 | * of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be 15 | * included in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | *****************************************************************************/ 26 | 27 | #ifndef _LIBMAPLE_SPI_PRIVATE_H_ 28 | #define _LIBMAPLE_SPI_PRIVATE_H_ 29 | 30 | #define SPI_DEV(num) \ 31 | { \ 32 | .regs = SPI##num##_BASE, \ 33 | .clk_id = RCC_SPI##num, \ 34 | .irq_num = NVIC_SPI##num, \ 35 | } 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /cores/arduino/libmaple/systick.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * The MIT License 3 | * 4 | * Copyright (c) 2010 Perry Hung. 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, copy, 10 | * modify, merge, publish, distribute, sublicense, and/or sell copies 11 | * of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be 15 | * included in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | *****************************************************************************/ 26 | 27 | /** 28 | * @file systick.c 29 | * @brief System timer interrupt handler and initialization routines 30 | */ 31 | 32 | #include "systick.h" 33 | #include "nvic.h" 34 | volatile uint32 systick_uptime_millis; 35 | static void (*systick_user_callback)(void); 36 | 37 | /** 38 | * @brief Initialize and enable SysTick. 39 | * 40 | * Clocks the system timer with the core clock, turns it on, and 41 | * enables interrupts. 42 | * 43 | * @param reload_val Appropriate reload counter to tick every 1 ms. 44 | */ 45 | void systick_init(uint32 reload_val) { 46 | SYSTICK_BASE->RVR = reload_val; 47 | systick_enable(); 48 | } 49 | 50 | /** 51 | * Clock the system timer with the core clock, but don't turn it 52 | * on or enable interrupt. 53 | */ 54 | void systick_disable() { 55 | SYSTICK_BASE->CSR = SYSTICK_CSR_CLKSOURCE_CORE; 56 | } 57 | 58 | /** 59 | * Clock the system timer with the core clock and turn it on; 60 | * interrupt every 1 ms, for systick_timer_millis. 61 | */ 62 | void systick_enable() { 63 | /* re-enables init registers without changing reload val */ 64 | SYSTICK_BASE->CSR = (SYSTICK_CSR_CLKSOURCE_CORE | 65 | SYSTICK_CSR_ENABLE | 66 | SYSTICK_CSR_TICKINT_PEND); 67 | } 68 | 69 | /** 70 | * @brief Attach a callback to be called from the SysTick exception handler. 71 | * 72 | * To detach a callback, call this function again with a null argument. 73 | */ 74 | void systick_attach_callback(void (*callback)(void)) { 75 | systick_user_callback = callback; 76 | } 77 | 78 | /* 79 | * SysTick ISR 80 | */ 81 | 82 | void __exc_systick(void) { 83 | nvic_globalirq_disable(); 84 | systick_check_underflow(); 85 | systick_uptime_millis++; 86 | nvic_globalirq_enable(); 87 | 88 | if (systick_user_callback) { 89 | systick_user_callback(); 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /cores/arduino/libmaple/usbF4/STM32_USB_Device_Library/Class/audio/inc/usbd_audio_out_if.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_audio_out_if.h 4 | * @author MCD Application Team 5 | * @version V1.0.0 6 | * @date 22-July-2011 7 | * @brief header file for the usbd_audio_out_if.c file. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /* Includes ------------------------------------------------------------------*/ 23 | 24 | #ifndef __USB_AUDIO_OUT_IF_H_ 25 | #define __USB_AUDIO_OUT_IF_H_ 26 | 27 | #ifdef STM32F2XX 28 | #include "stm322xg_usb_audio_codec.h" 29 | #elif defined(STM32F10X_CL) 30 | #include "stm3210c_usb_audio_codec.h" 31 | #endif /* STM32F2XX */ 32 | 33 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY 34 | * @{ 35 | */ 36 | 37 | /** @defgroup usbd_audio 38 | * @brief This file is the Header file for USBD_audio.c 39 | * @{ 40 | */ 41 | 42 | 43 | /** @defgroup usbd_audio_Exported_Defines 44 | * @{ 45 | */ 46 | /* Audio Commands enmueration */ 47 | typedef enum 48 | { 49 | AUDIO_CMD_PLAY = 1, 50 | AUDIO_CMD_PAUSE, 51 | AUDIO_CMD_STOP, 52 | }AUDIO_CMD_TypeDef; 53 | 54 | /* Mute commands */ 55 | #define AUDIO_MUTE 0x01 56 | #define AUDIO_UNMUTE 0x00 57 | 58 | /* Functions return value */ 59 | #define AUDIO_OK 0x00 60 | #define AUDIO_FAIL 0xFF 61 | 62 | /* Audio Machine States */ 63 | #define AUDIO_STATE_INACTIVE 0x00 64 | #define AUDIO_STATE_ACTIVE 0x01 65 | #define AUDIO_STATE_PLAYING 0x02 66 | #define AUDIO_STATE_PAUSED 0x03 67 | #define AUDIO_STATE_STOPPED 0x04 68 | #define AUDIO_STATE_ERROR 0x05 69 | 70 | /** 71 | * @} 72 | */ 73 | 74 | 75 | /** @defgroup USBD_CORE_Exported_TypesDefinitions 76 | * @{ 77 | */ 78 | /** 79 | * @} 80 | */ 81 | 82 | 83 | 84 | /** @defgroup USBD_CORE_Exported_Macros 85 | * @{ 86 | */ 87 | /** 88 | * @} 89 | */ 90 | 91 | /** @defgroup USBD_CORE_Exported_Variables 92 | * @{ 93 | */ 94 | 95 | extern AUDIO_FOPS_TypeDef AUDIO_OUT_fops; 96 | 97 | /** 98 | * @} 99 | */ 100 | 101 | /** @defgroup USB_CORE_Exported_Functions 102 | * @{ 103 | */ 104 | /** 105 | * @} 106 | */ 107 | 108 | #endif /* __USB_AUDIO_OUT_IF_H_ */ 109 | /** 110 | * @} 111 | */ 112 | 113 | /** 114 | * @} 115 | */ 116 | 117 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 118 | -------------------------------------------------------------------------------- /cores/arduino/libmaple/usbF4/STM32_USB_Device_Library/Class/cdc/inc/usbd_cdc_if_template.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_cdc_if_template.h 4 | * @author MCD Application Team 5 | * @version V1.0.0 6 | * @date 22-July-2011 7 | * @brief Header for dfu_mal.c file. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __USBD_CDC_IF_TEMPLATE_H 24 | #define __USBD_CDC_IF_TEMPLATE_H 25 | 26 | /* Includes ------------------------------------------------------------------*/ 27 | #ifdef STM32F2XX 28 | #include "stm32f2xx.h" 29 | #elif defined(STM32F10X_CL) 30 | #include "stm32f10x.h" 31 | #endif /* STM32F2XX */ 32 | 33 | #include "usbd_conf.h" 34 | #include "usbd_cdc_core.h" 35 | 36 | /* Exported types ------------------------------------------------------------*/ 37 | /* Exported constants --------------------------------------------------------*/ 38 | 39 | extern CDC_IF_Prop_TypeDef TEMPLATE_fops; 40 | 41 | /* Exported macro ------------------------------------------------------------*/ 42 | /* Exported functions ------------------------------------------------------- */ 43 | #endif /* __USBD_CDC_IF_TEMPLATE_H */ 44 | 45 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 46 | -------------------------------------------------------------------------------- /cores/arduino/libmaple/usbF4/STM32_USB_Device_Library/Class/dfu/inc/usbd_dfu_mal.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_dfu_mal.h 4 | * @author MCD Application Team 5 | * @version V1.0.0 6 | * @date 22-July-2011 7 | * @brief Header for usbd_dfu_mal.c file. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __DFU_MAL_H 24 | #define __DFU_MAL_H 25 | 26 | /* Includes ------------------------------------------------------------------*/ 27 | #ifdef STM32F2XX 28 | #include "stm32f2xx.h" 29 | #elif defined(STM32F10X_CL) 30 | #include "stm32f10x.h" 31 | #endif /* STM32F2XX */ 32 | 33 | #include "usbd_conf.h" 34 | #include "usbd_dfu_core.h" 35 | 36 | /* Exported types ------------------------------------------------------------*/ 37 | typedef struct _DFU_MAL_PROP 38 | { 39 | const uint8_t* pStrDesc; 40 | uint16_t (*pMAL_Init) (void); 41 | uint16_t (*pMAL_DeInit) (void); 42 | uint16_t (*pMAL_Erase) (uint32_t Add); 43 | uint16_t (*pMAL_Write) (uint32_t Add, uint32_t Len); 44 | uint8_t *(*pMAL_Read) (uint32_t Add, uint32_t Len); 45 | uint16_t (*pMAL_CheckAdd) (uint32_t Add); 46 | const uint32_t EraseTiming; 47 | const uint32_t WriteTiming; 48 | } 49 | DFU_MAL_Prop_TypeDef; 50 | 51 | 52 | /* Exported constants --------------------------------------------------------*/ 53 | #define MAL_OK 0 54 | #define MAL_FAIL 1 55 | 56 | /* utils macro ---------------------------------------------------------------*/ 57 | #define _1st_BYTE(x) (uint8_t)((x)&0xFF) /* 1st addressing cycle */ 58 | #define _2nd_BYTE(x) (uint8_t)(((x)&0xFF00)>>8) /* 2nd addressing cycle */ 59 | #define _3rd_BYTE(x) (uint8_t)(((x)&0xFF0000)>>16) /* 3rd addressing cycle */ 60 | #define _4th_BYTE(x) (uint8_t)(((x)&0xFF000000)>>24) /* 4th addressing cycle */ 61 | 62 | /* Exported macro ------------------------------------------------------------*/ 63 | #define SET_POLLING_TIMING(x) buffer[1] = _1st_BYTE(x);\ 64 | buffer[2] = _2nd_BYTE(x);\ 65 | buffer[3] = _3rd_BYTE(x); 66 | 67 | /* Exported functions ------------------------------------------------------- */ 68 | 69 | uint16_t MAL_Init (void); 70 | uint16_t MAL_DeInit (void); 71 | uint16_t MAL_Erase (uint32_t SectorAddress); 72 | uint16_t MAL_Write (uint32_t SectorAddress, uint32_t DataLength); 73 | uint8_t *MAL_Read (uint32_t SectorAddress, uint32_t DataLength); 74 | uint16_t MAL_GetStatus(uint32_t SectorAddress ,uint8_t Cmd, uint8_t *buffer); 75 | 76 | extern uint8_t MAL_Buffer[XFERSIZE]; /* RAM Buffer for Downloaded Data */ 77 | #endif /* __DFU_MAL_H */ 78 | 79 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 80 | -------------------------------------------------------------------------------- /cores/arduino/libmaple/usbF4/STM32_USB_Device_Library/Class/dfu/inc/usbd_flash_if.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_flash_if.h 4 | * @author MCD Application Team 5 | * @version V1.0.0RC1 6 | * @date 18-March-2011 7 | * @brief Header for usbd_flash_if.c file. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __FLASH_IF_MAL_H 24 | #define __FLASH_IF_MAL_H 25 | 26 | /* Includes ------------------------------------------------------------------*/ 27 | #include "usbd_dfu_mal.h" 28 | 29 | /* Exported types ------------------------------------------------------------*/ 30 | /* Exported constants --------------------------------------------------------*/ 31 | #define FLASH_START_ADD 0x08000000 32 | 33 | #ifdef STM32F2XX 34 | #define FLASH_END_ADD 0x08100000 35 | #define FLASH_IF_STRING "@Internal Flash /0x08000000/03*016Ka,01*016Kg,01*064Kg,07*128Kg" 36 | #elif defined(STM32F10X_CL) 37 | #define FLASH_END_ADD 0x08040000 38 | #define FLASH_IF_STRING "@Internal Flash /0x08000000/06*002Ka,122*002Kg" 39 | #endif /* STM32F2XX */ 40 | 41 | 42 | extern DFU_MAL_Prop_TypeDef DFU_Flash_cb; 43 | 44 | /* Exported macro ------------------------------------------------------------*/ 45 | /* Exported functions ------------------------------------------------------- */ 46 | 47 | #endif /* __FLASH_IF_MAL_H */ 48 | 49 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 50 | -------------------------------------------------------------------------------- /cores/arduino/libmaple/usbF4/STM32_USB_Device_Library/Class/dfu/inc/usbd_mem_if_template.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_mem_if_template.h 4 | * @author MCD Application Team 5 | * @version V1.0.0 6 | * @date 22-July-2011 7 | * @brief Header for usbd_mem_if_template.c file. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __MEM_IF_MAL_H 24 | #define __MEM_IF_MAL_H 25 | 26 | /* Includes ------------------------------------------------------------------*/ 27 | #ifdef STM32F2XX 28 | #include "stm32f2xx.h" 29 | #endif /* STM32F2XX */ 30 | #include "usbd_dfu_mal.h" 31 | 32 | /* Exported types ------------------------------------------------------------*/ 33 | /* Exported constants --------------------------------------------------------*/ 34 | #define MEM_START_ADD 0x00000000 /* Dummy start address */ 35 | #define MEM_END_ADD (uint32_t)(MEM_START_ADD + (5 * 1024)) /* Dummy Size = 5KB */ 36 | 37 | #define MEM_IF_STRING "@Dummy Memory /0x00000000/01*002Kg,03*001Kg" 38 | 39 | extern DFU_MAL_Prop_TypeDef DFU_Mem_cb; 40 | 41 | /* Exported macro ------------------------------------------------------------*/ 42 | /* Exported functions ------------------------------------------------------- */ 43 | 44 | #endif /* __MEM_IF_MAL_H */ 45 | 46 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 47 | -------------------------------------------------------------------------------- /cores/arduino/libmaple/usbF4/STM32_USB_Device_Library/Class/dfu/inc/usbd_otp_if.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_otp_if.h 4 | * @author MCD Application Team 5 | * @version V1.0.0 6 | * @date 22-July-2011 7 | * @brief Header for usbd_otp_if.c file. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __OTP_IF_MAL_H 24 | #define __OTP_IF_MAL_H 25 | 26 | /* Includes ------------------------------------------------------------------*/ 27 | #include "usbd_dfu_mal.h" 28 | 29 | /* Exported types ------------------------------------------------------------*/ 30 | /* Exported constants --------------------------------------------------------*/ 31 | #define OTP_START_ADD 0x1FFF7800 32 | #define OTP_END_ADD (uint32_t)(OTP_START_ADD + 528) 33 | 34 | #define OTP_IF_STRING "@OTP Area /0x1FFF7800/01*512 g,01*016 g" 35 | 36 | extern DFU_MAL_Prop_TypeDef DFU_Otp_cb; 37 | 38 | /* Exported macro ------------------------------------------------------------*/ 39 | /* Exported functions ------------------------------------------------------- */ 40 | 41 | #endif /* __OTP_IF_MAL_H */ 42 | 43 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 44 | -------------------------------------------------------------------------------- /cores/arduino/libmaple/usbF4/STM32_USB_Device_Library/Class/hid/inc/usbd_hid_core.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_hid_core.h 4 | * @author MCD Application Team 5 | * @version V1.0.0 6 | * @date 22-July-2011 7 | * @brief header file for the usbd_hid_core.c file. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /* Includes ------------------------------------------------------------------*/ 23 | 24 | #ifndef __USB_HID_CORE_H_ 25 | #define __USB_HID_CORE_H_ 26 | 27 | #include "usbd_ioreq.h" 28 | 29 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY 30 | * @{ 31 | */ 32 | 33 | /** @defgroup USBD_HID 34 | * @brief This file is the Header file for USBD_msc.c 35 | * @{ 36 | */ 37 | 38 | 39 | /** @defgroup USBD_HID_Exported_Defines 40 | * @{ 41 | */ 42 | #define USB_HID_CONFIG_DESC_SIZ 34 43 | #define USB_HID_DESC_SIZ 9 44 | #define HID_MOUSE_REPORT_DESC_SIZE 74 45 | 46 | #define HID_DESCRIPTOR_TYPE 0x21 47 | #define HID_REPORT_DESC 0x22 48 | 49 | 50 | #define HID_REQ_SET_PROTOCOL 0x0B 51 | #define HID_REQ_GET_PROTOCOL 0x03 52 | 53 | #define HID_REQ_SET_IDLE 0x0A 54 | #define HID_REQ_GET_IDLE 0x02 55 | 56 | #define HID_REQ_SET_REPORT 0x09 57 | #define HID_REQ_GET_REPORT 0x01 58 | /** 59 | * @} 60 | */ 61 | 62 | 63 | /** @defgroup USBD_CORE_Exported_TypesDefinitions 64 | * @{ 65 | */ 66 | 67 | 68 | /** 69 | * @} 70 | */ 71 | 72 | 73 | 74 | /** @defgroup USBD_CORE_Exported_Macros 75 | * @{ 76 | */ 77 | 78 | /** 79 | * @} 80 | */ 81 | 82 | /** @defgroup USBD_CORE_Exported_Variables 83 | * @{ 84 | */ 85 | 86 | extern USBD_Class_cb_TypeDef USBD_HID_cb; 87 | /** 88 | * @} 89 | */ 90 | 91 | /** @defgroup USB_CORE_Exported_Functions 92 | * @{ 93 | */ 94 | uint8_t USBD_HID_SendReport (USB_OTG_CORE_HANDLE *pdev, 95 | uint8_t *report, 96 | uint16_t len); 97 | /** 98 | * @} 99 | */ 100 | 101 | #endif // __USB_HID_CORE_H_ 102 | /** 103 | * @} 104 | */ 105 | 106 | /** 107 | * @} 108 | */ 109 | 110 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 111 | -------------------------------------------------------------------------------- /cores/arduino/libmaple/usbF4/STM32_USB_Device_Library/Class/msc/inc/usbd_msc_core.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_msc_core.h 4 | * @author MCD Application Team 5 | * @version V1.0.0 6 | * @date 22-July-2011 7 | * @brief header for the usbd_msc_core.c file 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef _USB_MSC_CORE_H_ 24 | #define _USB_MSC_CORE_H_ 25 | 26 | #include "usbd_ioreq.h" 27 | 28 | /** @addtogroup USBD_MSC_BOT 29 | * @{ 30 | */ 31 | 32 | /** @defgroup USBD_MSC 33 | * @brief This file is the Header file for USBD_msc.c 34 | * @{ 35 | */ 36 | 37 | 38 | /** @defgroup USBD_BOT_Exported_Defines 39 | * @{ 40 | */ 41 | 42 | 43 | #define BOT_GET_MAX_LUN 0xFE 44 | #define BOT_RESET 0xFF 45 | #define USB_MSC_CONFIG_DESC_SIZ 32 46 | 47 | #define MSC_EPIN_SIZE *(uint16_t *)(((USB_OTG_CORE_HANDLE *)pdev)->dev.pConfig_descriptor + 22) 48 | 49 | #define MSC_EPOUT_SIZE *(uint16_t *)(((USB_OTG_CORE_HANDLE *)pdev)->dev.pConfig_descriptor + 29) 50 | 51 | /** 52 | * @} 53 | */ 54 | 55 | /** @defgroup USB_CORE_Exported_Types 56 | * @{ 57 | */ 58 | 59 | extern USBD_Class_cb_TypeDef USBD_MSC_cb; 60 | /** 61 | * @} 62 | */ 63 | 64 | /** 65 | * @} 66 | */ 67 | #endif // _USB_MSC_CORE_H_ 68 | /** 69 | * @} 70 | */ 71 | 72 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 73 | -------------------------------------------------------------------------------- /cores/arduino/libmaple/usbF4/STM32_USB_Device_Library/Class/msc/inc/usbd_msc_data.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_msc_data.h 4 | * @author MCD Application Team 5 | * @version V1.0.0 6 | * @date 22-July-2011 7 | * @brief header for the usbd_msc_data.c file 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | 24 | #ifndef _USBD_MSC_DATA_H_ 25 | #define _USBD_MSC_DATA_H_ 26 | 27 | /* Includes ------------------------------------------------------------------*/ 28 | #include "usbd_conf.h" 29 | 30 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY 31 | * @{ 32 | */ 33 | 34 | /** @defgroup USB_INFO 35 | * @brief general defines for the usb device library file 36 | * @{ 37 | */ 38 | 39 | /** @defgroup USB_INFO_Exported_Defines 40 | * @{ 41 | */ 42 | #define MODE_SENSE6_LEN 8 43 | #define MODE_SENSE10_LEN 8 44 | #define LENGTH_INQUIRY_PAGE00 7 45 | #define LENGTH_FORMAT_CAPACITIES 20 46 | 47 | /** 48 | * @} 49 | */ 50 | 51 | 52 | /** @defgroup USBD_INFO_Exported_TypesDefinitions 53 | * @{ 54 | */ 55 | /** 56 | * @} 57 | */ 58 | 59 | 60 | 61 | /** @defgroup USBD_INFO_Exported_Macros 62 | * @{ 63 | */ 64 | 65 | /** 66 | * @} 67 | */ 68 | 69 | /** @defgroup USBD_INFO_Exported_Variables 70 | * @{ 71 | */ 72 | extern const uint8_t MSC_Page00_Inquiry_Data[]; 73 | extern const uint8_t MSC_Mode_Sense6_data[]; 74 | extern const uint8_t MSC_Mode_Sense10_data[] ; 75 | 76 | /** 77 | * @} 78 | */ 79 | 80 | /** @defgroup USBD_INFO_Exported_FunctionsPrototype 81 | * @{ 82 | */ 83 | 84 | /** 85 | * @} 86 | */ 87 | 88 | #endif /* _USBD_MSC_DATA_H_ */ 89 | 90 | /** 91 | * @} 92 | */ 93 | 94 | /** 95 | * @} 96 | */ 97 | 98 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 99 | -------------------------------------------------------------------------------- /cores/arduino/libmaple/usbF4/STM32_USB_Device_Library/Class/msc/inc/usbd_msc_mem.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_msc_mem.h 4 | * @author MCD Application Team 5 | * @version V1.0.0 6 | * @date 22-July-2011 7 | * @brief header for the STORAGE DISK file file 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | 24 | #ifndef __USBD_MEM_H 25 | #define __USBD_MEM_H 26 | /* Includes ------------------------------------------------------------------*/ 27 | #include "usbd_def.h" 28 | 29 | 30 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY 31 | * @{ 32 | */ 33 | 34 | /** @defgroup USBD_MEM 35 | * @brief header file for the storage disk file 36 | * @{ 37 | */ 38 | 39 | /** @defgroup USBD_MEM_Exported_Defines 40 | * @{ 41 | */ 42 | #define USBD_STD_INQUIRY_LENGTH 36 43 | /** 44 | * @} 45 | */ 46 | 47 | 48 | /** @defgroup USBD_MEM_Exported_TypesDefinitions 49 | * @{ 50 | */ 51 | 52 | typedef struct _USBD_STORAGE 53 | { 54 | int8_t (* Init) (uint8_t lun); 55 | int8_t (* GetCapacity) (uint8_t lun, uint32_t *block_num, uint32_t *block_size); 56 | int8_t (* IsReady) (uint8_t lun); 57 | int8_t (* IsWriteProtected) (uint8_t lun); 58 | int8_t (* Read) (uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len); 59 | int8_t (* Write)(uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len); 60 | int8_t (* GetMaxLun)(void); 61 | int8_t *pInquiry; 62 | 63 | }USBD_STORAGE_cb_TypeDef; 64 | /** 65 | * @} 66 | */ 67 | 68 | 69 | 70 | /** @defgroup USBD_MEM_Exported_Macros 71 | * @{ 72 | */ 73 | 74 | /** 75 | * @} 76 | */ 77 | 78 | /** @defgroup USBD_MEM_Exported_Variables 79 | * @{ 80 | */ 81 | 82 | /** 83 | * @} 84 | */ 85 | 86 | /** @defgroup USBD_MEM_Exported_FunctionsPrototype 87 | * @{ 88 | */ 89 | extern USBD_STORAGE_cb_TypeDef *USBD_STORAGE_fops; 90 | /** 91 | * @} 92 | */ 93 | 94 | #endif /* __USBD_MEM_H */ 95 | /** 96 | * @} 97 | */ 98 | 99 | /** 100 | * @} 101 | */ 102 | 103 | /** 104 | * @} 105 | */ 106 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 107 | -------------------------------------------------------------------------------- /cores/arduino/libmaple/usbF4/STM32_USB_Device_Library/Core/inc/usbd_conf_template.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_conf_template.h 4 | * @author MCD Application Team 5 | * @version V1.0.0 6 | * @date 22-July-2011 7 | * @brief usb device configuration template file 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __USBD_CONF__H__ 24 | #define __USBD_CONF__H__ 25 | 26 | /* Includes ------------------------------------------------------------------*/ 27 | #include "stm32f2xx.h" 28 | 29 | 30 | 31 | /** @defgroup USB_CONF_Exported_Defines 32 | * @{ 33 | */ 34 | #define USE_USB_OTG_HS 35 | 36 | #define USBD_CFG_MAX_NUM 1 37 | #define USB_MAX_STR_DESC_SIZ 64 38 | #define USBD_EP0_MAX_PACKET_SIZE 64 39 | 40 | /** 41 | * @} 42 | */ 43 | 44 | 45 | /** @defgroup USB_CONF_Exported_Types 46 | * @{ 47 | */ 48 | /** 49 | * @} 50 | */ 51 | 52 | 53 | /** @defgroup USB_CONF_Exported_Macros 54 | * @{ 55 | */ 56 | /** 57 | * @} 58 | */ 59 | 60 | /** @defgroup USB_CONF_Exported_Variables 61 | * @{ 62 | */ 63 | /** 64 | * @} 65 | */ 66 | 67 | /** @defgroup USB_CONF_Exported_FunctionsPrototype 68 | * @{ 69 | */ 70 | /** 71 | * @} 72 | */ 73 | 74 | 75 | #endif //__USBD_CONF__H__ 76 | 77 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 78 | 79 | -------------------------------------------------------------------------------- /cores/arduino/libmaple/usbF4/STM32_USB_Device_Library/Core/inc/usbd_core.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_core.h 4 | * @author MCD Application Team 5 | * @version V1.0.0 6 | * @date 22-July-2011 7 | * @brief Header file for usbd_core.c 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __USBD_CORE_H 24 | #define __USBD_CORE_H 25 | 26 | /* Includes ------------------------------------------------------------------*/ 27 | #include "usb_dcd.h" 28 | #include "usbd_def.h" 29 | #include "usbd_conf.h" 30 | 31 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY 32 | * @{ 33 | */ 34 | 35 | /** @defgroup USBD_CORE 36 | * @brief This file is the Header file for usbd_core.c file 37 | * @{ 38 | */ 39 | 40 | 41 | /** @defgroup USBD_CORE_Exported_Defines 42 | * @{ 43 | */ 44 | 45 | typedef enum { 46 | USBD_OK = 0, 47 | USBD_BUSY, 48 | USBD_FAIL, 49 | }USBD_Status; 50 | /** 51 | * @} 52 | */ 53 | 54 | 55 | /** @defgroup USBD_CORE_Exported_TypesDefinitions 56 | * @{ 57 | */ 58 | 59 | 60 | /** 61 | * @} 62 | */ 63 | 64 | 65 | 66 | /** @defgroup USBD_CORE_Exported_Macros 67 | * @{ 68 | */ 69 | 70 | /** 71 | * @} 72 | */ 73 | 74 | /** @defgroup USBD_CORE_Exported_Variables 75 | * @{ 76 | */ 77 | 78 | /** 79 | * @} 80 | */ 81 | 82 | /** @defgroup USBD_CORE_Exported_FunctionsPrototype 83 | * @{ 84 | */ 85 | void USBD_Init(USB_OTG_CORE_HANDLE *pdev, 86 | USB_OTG_CORE_ID_TypeDef coreID, 87 | USBD_DEVICE *pDevice, 88 | USBD_Class_cb_TypeDef *class_cb, 89 | USBD_Usr_cb_TypeDef *usr_cb); 90 | 91 | USBD_Status USBD_DeInit(USB_OTG_CORE_HANDLE *pdev); 92 | 93 | USBD_Status USBD_DeInitFull(USB_OTG_CORE_HANDLE *pdev); 94 | 95 | USBD_Status USBD_ClrCfg(USB_OTG_CORE_HANDLE *pdev, uint8_t cfgidx); 96 | 97 | USBD_Status USBD_SetCfg(USB_OTG_CORE_HANDLE *pdev, uint8_t cfgidx); 98 | 99 | /** 100 | * @} 101 | */ 102 | 103 | #endif /* __USBD_CORE_H */ 104 | 105 | /** 106 | * @} 107 | */ 108 | 109 | /** 110 | * @} 111 | */ 112 | 113 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /cores/arduino/libmaple/usbF4/STM32_USB_Device_Library/Core/inc/usbd_ioreq.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_ioreq.h 4 | * @author MCD Application Team 5 | * @version V1.0.0 6 | * @date 22-July-2011 7 | * @brief header file for the usbd_ioreq.c file 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | 24 | #ifndef __USBD_IOREQ_H_ 25 | #define __USBD_IOREQ_H_ 26 | 27 | /* Includes ------------------------------------------------------------------*/ 28 | #include "usbd_def.h" 29 | #include "usbd_core.h" 30 | 31 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY 32 | * @{ 33 | */ 34 | 35 | /** @defgroup USBD_IOREQ 36 | * @brief header file for the usbd_ioreq.c file 37 | * @{ 38 | */ 39 | 40 | /** @defgroup USBD_IOREQ_Exported_Defines 41 | * @{ 42 | */ 43 | /** 44 | * @} 45 | */ 46 | 47 | 48 | /** @defgroup USBD_IOREQ_Exported_Types 49 | * @{ 50 | */ 51 | 52 | 53 | /** 54 | * @} 55 | */ 56 | 57 | 58 | 59 | /** @defgroup USBD_IOREQ_Exported_Macros 60 | * @{ 61 | */ 62 | 63 | /** 64 | * @} 65 | */ 66 | 67 | /** @defgroup USBD_IOREQ_Exported_Variables 68 | * @{ 69 | */ 70 | 71 | /** 72 | * @} 73 | */ 74 | 75 | /** @defgroup USBD_IOREQ_Exported_FunctionsPrototype 76 | * @{ 77 | */ 78 | 79 | USBD_Status USBD_CtlSendData (USB_OTG_CORE_HANDLE *pdev, 80 | uint8_t *buf, 81 | uint16_t len); 82 | 83 | USBD_Status USBD_CtlContinueSendData (USB_OTG_CORE_HANDLE *pdev, 84 | uint8_t *pbuf, 85 | uint16_t len); 86 | 87 | USBD_Status USBD_CtlPrepareRx (USB_OTG_CORE_HANDLE *pdev, 88 | uint8_t *pbuf, 89 | uint16_t len); 90 | 91 | USBD_Status USBD_CtlContinueRx (USB_OTG_CORE_HANDLE *pdev, 92 | uint8_t *pbuf, 93 | uint16_t len); 94 | 95 | USBD_Status USBD_CtlSendStatus (USB_OTG_CORE_HANDLE *pdev); 96 | 97 | USBD_Status USBD_CtlReceiveStatus (USB_OTG_CORE_HANDLE *pdev); 98 | 99 | uint16_t USBD_GetRxCount (USB_OTG_CORE_HANDLE *pdev , 100 | uint8_t epnum); 101 | 102 | /** 103 | * @} 104 | */ 105 | 106 | #endif /* __USBD_IOREQ_H_ */ 107 | 108 | /** 109 | * @} 110 | */ 111 | 112 | /** 113 | * @} 114 | */ 115 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 116 | -------------------------------------------------------------------------------- /cores/arduino/libmaple/usbF4/STM32_USB_Device_Library/Core/inc/usbd_req.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_req.h 4 | * @author MCD Application Team 5 | * @version V1.0.0 6 | * @date 22-July-2011 7 | * @brief header file for the usbd_req.c file 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | 24 | #ifndef __USB_REQUEST_H_ 25 | #define __USB_REQUEST_H_ 26 | 27 | /* Includes ------------------------------------------------------------------*/ 28 | #include "usbd_def.h" 29 | #include "usbd_core.h" 30 | #include "usbd_conf.h" 31 | 32 | 33 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY 34 | * @{ 35 | */ 36 | 37 | /** @defgroup USBD_REQ 38 | * @brief header file for the usbd_ioreq.c file 39 | * @{ 40 | */ 41 | 42 | /** @defgroup USBD_REQ_Exported_Defines 43 | * @{ 44 | */ 45 | /** 46 | * @} 47 | */ 48 | 49 | 50 | /** @defgroup USBD_REQ_Exported_Types 51 | * @{ 52 | */ 53 | /** 54 | * @} 55 | */ 56 | 57 | 58 | 59 | /** @defgroup USBD_REQ_Exported_Macros 60 | * @{ 61 | */ 62 | /** 63 | * @} 64 | */ 65 | 66 | /** @defgroup USBD_REQ_Exported_Variables 67 | * @{ 68 | */ 69 | /** 70 | * @} 71 | */ 72 | 73 | /** @defgroup USBD_REQ_Exported_FunctionsPrototype 74 | * @{ 75 | */ 76 | 77 | USBD_Status USBD_StdDevReq (USB_OTG_CORE_HANDLE *pdev, USB_SETUP_REQ *req); 78 | USBD_Status USBD_StdItfReq (USB_OTG_CORE_HANDLE *pdev, USB_SETUP_REQ *req); 79 | USBD_Status USBD_StdEPReq (USB_OTG_CORE_HANDLE *pdev, USB_SETUP_REQ *req); 80 | void USBD_ParseSetupRequest( USB_OTG_CORE_HANDLE *pdev, 81 | USB_SETUP_REQ *req); 82 | 83 | void USBD_CtlError( USB_OTG_CORE_HANDLE *pdev, 84 | USB_SETUP_REQ *req); 85 | 86 | void USBD_GetString(uint8_t *desc, uint8_t *unicode, uint16_t *len); 87 | /** 88 | * @} 89 | */ 90 | 91 | #endif /* __USB_REQUEST_H_ */ 92 | 93 | /** 94 | * @} 95 | */ 96 | 97 | /** 98 | * @} 99 | */ 100 | 101 | 102 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 103 | -------------------------------------------------------------------------------- /cores/arduino/libmaple/usbF4/STM32_USB_Device_Library/Core/inc/usbd_usr.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_usr.h 4 | * @author MCD Application Team 5 | * @version V1.0.0 6 | * @date 22-July-2011 7 | * @brief Header file for usbd_usr.c 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __USBD_USR_H__ 24 | #define __USBD_USR_H__ 25 | 26 | /* Includes ------------------------------------------------------------------*/ 27 | #include "usbd_core.h" 28 | 29 | 30 | /** @addtogroup USBD_USER 31 | * @{ 32 | */ 33 | 34 | /** @addtogroup USBD_MSC_DEMO_USER_CALLBACKS 35 | * @{ 36 | */ 37 | 38 | /** @defgroup USBD_USR 39 | * @brief This file is the Header file for usbd_usr.c 40 | * @{ 41 | */ 42 | 43 | 44 | /** @defgroup USBD_USR_Exported_Types 45 | * @{ 46 | */ 47 | 48 | extern USBD_Usr_cb_TypeDef USR_cb; 49 | extern USBD_Usr_cb_TypeDef USR_FS_cb; 50 | extern USBD_Usr_cb_TypeDef USR_HS_cb; 51 | 52 | 53 | 54 | /** 55 | * @} 56 | */ 57 | 58 | 59 | 60 | /** @defgroup USBD_USR_Exported_Defines 61 | * @{ 62 | */ 63 | 64 | /** 65 | * @} 66 | */ 67 | 68 | /** @defgroup USBD_USR_Exported_Macros 69 | * @{ 70 | */ 71 | /** 72 | * @} 73 | */ 74 | 75 | /** @defgroup USBD_USR_Exported_Variables 76 | * @{ 77 | */ 78 | 79 | void USBD_USR_Init(void); 80 | void USBD_USR_DeviceReset (uint8_t speed); 81 | void USBD_USR_DeviceConfigured (void); 82 | void USBD_USR_DeviceSuspended(void); 83 | void USBD_USR_DeviceResumed(void); 84 | 85 | void USBD_USR_DeviceConnected(void); 86 | void USBD_USR_DeviceDisconnected(void); 87 | 88 | void USBD_USR_FS_Init(void); 89 | void USBD_USR_FS_DeviceReset (uint8_t speed); 90 | void USBD_USR_FS_DeviceConfigured (void); 91 | void USBD_USR_FS_DeviceSuspended(void); 92 | void USBD_USR_FS_DeviceResumed(void); 93 | 94 | void USBD_USR_FS_DeviceConnected(void); 95 | void USBD_USR_FS_DeviceDisconnected(void); 96 | 97 | void USBD_USR_HS_Init(void); 98 | void USBD_USR_HS_DeviceReset (uint8_t speed); 99 | void USBD_USR_HS_DeviceConfigured (void); 100 | void USBD_USR_HS_DeviceSuspended(void); 101 | void USBD_USR_HS_DeviceResumed(void); 102 | 103 | void USBD_USR_HS_DeviceConnected(void); 104 | void USBD_USR_HS_DeviceDisconnected(void); 105 | 106 | /** 107 | * @} 108 | */ 109 | 110 | /** @defgroup USBD_USR_Exported_FunctionsPrototype 111 | * @{ 112 | */ 113 | /** 114 | * @} 115 | */ 116 | 117 | #endif /*__USBD_USR_H__*/ 118 | 119 | /** 120 | * @} 121 | */ 122 | 123 | /** 124 | * @} 125 | */ 126 | 127 | /** 128 | * @} 129 | */ 130 | 131 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 132 | 133 | 134 | 135 | 136 | -------------------------------------------------------------------------------- /cores/arduino/libmaple/usbF4/STM32_USB_OTG_Driver/inc/usb_bsp.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usb_bsp.h 4 | * @author MCD Application Team 5 | * @version V2.0.0 6 | * @date 22-July-2011 7 | * @brief Specific api's relative to the used hardware platform 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __USB_BSP__H__ 24 | #define __USB_BSP__H__ 25 | 26 | /* Includes ------------------------------------------------------------------*/ 27 | #include "usb_core.h" 28 | //#include "stm32f4_discovery.h" 29 | 30 | /** @addtogroup USB_OTG_DRIVER 31 | * @{ 32 | */ 33 | 34 | /** @defgroup USB_BSP 35 | * @brief This file is the 36 | * @{ 37 | */ 38 | 39 | 40 | /** @defgroup USB_BSP_Exported_Defines 41 | * @{ 42 | */ 43 | /** 44 | * @} 45 | */ 46 | 47 | 48 | /** @defgroup USB_BSP_Exported_Types 49 | * @{ 50 | */ 51 | /** 52 | * @} 53 | */ 54 | 55 | 56 | /** @defgroup USB_BSP_Exported_Macros 57 | * @{ 58 | */ 59 | /** 60 | * @} 61 | */ 62 | 63 | /** @defgroup USB_BSP_Exported_Variables 64 | * @{ 65 | */ 66 | /** 67 | * @} 68 | */ 69 | 70 | /** @defgroup USB_BSP_Exported_FunctionsPrototype 71 | * @{ 72 | */ 73 | void BSP_Init(void); 74 | 75 | void USB_OTG_BSP_Init (USB_OTG_CORE_HANDLE *pdev); 76 | void USB_OTG_BSP_DeInit (USB_OTG_CORE_HANDLE *pdev); 77 | void USB_OTG_BSP_uDelay (const uint32_t usec); 78 | void USB_OTG_BSP_mDelay (const uint32_t msec); 79 | void USB_OTG_BSP_EnableInterrupt (USB_OTG_CORE_HANDLE *pdev); 80 | void USB_OTG_BSP_DisableInterrupt (USB_OTG_CORE_HANDLE *pdev); 81 | #ifdef USE_HOST_MODE 82 | void USB_OTG_BSP_ConfigVBUS(USB_OTG_CORE_HANDLE *pdev); 83 | void USB_OTG_BSP_DriveVBUS(USB_OTG_CORE_HANDLE *pdev,uint8_t state); 84 | #endif 85 | /** 86 | * @} 87 | */ 88 | 89 | #endif //__USB_BSP__H__ 90 | 91 | /** 92 | * @} 93 | */ 94 | 95 | /** 96 | * @} 97 | */ 98 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 99 | 100 | -------------------------------------------------------------------------------- /cores/arduino/libmaple/usbF4/STM32_USB_OTG_Driver/inc/usb_dcd_int.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usb_dcd_int.h 4 | * @author MCD Application Team 5 | * @version V2.0.0 6 | * @date 22-July-2011 7 | * @brief Peripheral Device Interface Layer 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef USB_DCD_INT_H__ 24 | #define USB_DCD_INT_H__ 25 | 26 | /* Includes ------------------------------------------------------------------*/ 27 | #include "usb_dcd.h" 28 | 29 | 30 | 31 | /** @addtogroup USB_OTG_DRIVER 32 | * @{ 33 | */ 34 | 35 | /** @defgroup USB_DCD_INT 36 | * @brief This file is the 37 | * @{ 38 | */ 39 | 40 | 41 | /** @defgroup USB_DCD_INT_Exported_Defines 42 | * @{ 43 | */ 44 | 45 | typedef struct _USBD_DCD_INT 46 | { 47 | uint8_t (* DataOutStage) (USB_OTG_CORE_HANDLE *pdev , uint8_t epnum); 48 | uint8_t (* DataInStage) (USB_OTG_CORE_HANDLE *pdev , uint8_t epnum); 49 | uint8_t (* SetupStage) (USB_OTG_CORE_HANDLE *pdev); 50 | uint8_t (* SOF) (USB_OTG_CORE_HANDLE *pdev); 51 | uint8_t (* Reset) (USB_OTG_CORE_HANDLE *pdev); 52 | uint8_t (* Suspend) (USB_OTG_CORE_HANDLE *pdev); 53 | uint8_t (* Resume) (USB_OTG_CORE_HANDLE *pdev); 54 | uint8_t (* IsoINIncomplete) (USB_OTG_CORE_HANDLE *pdev); 55 | uint8_t (* IsoOUTIncomplete) (USB_OTG_CORE_HANDLE *pdev); 56 | 57 | uint8_t (* DevConnected) (USB_OTG_CORE_HANDLE *pdev); 58 | uint8_t (* DevDisconnected) (USB_OTG_CORE_HANDLE *pdev); 59 | 60 | }USBD_DCD_INT_cb_TypeDef; 61 | 62 | extern USBD_DCD_INT_cb_TypeDef *USBD_DCD_INT_fops; 63 | /** 64 | * @} 65 | */ 66 | 67 | 68 | /** @defgroup USB_DCD_INT_Exported_Types 69 | * @{ 70 | */ 71 | /** 72 | * @} 73 | */ 74 | 75 | /** @defgroup USB_DCD_INT_Exported_Macros 76 | * @{ 77 | */ 78 | 79 | #define CLEAR_IN_EP_INTR(epnum,intr) \ 80 | diepint.d32=0; \ 81 | diepint.b.intr = 1; \ 82 | USB_OTG_WRITE_REG32(&pdev->regs.INEP_REGS[epnum]->DIEPINT,diepint.d32); 83 | 84 | #define CLEAR_OUT_EP_INTR(epnum,intr) \ 85 | doepint.d32=0; \ 86 | doepint.b.intr = 1; \ 87 | USB_OTG_WRITE_REG32(&pdev->regs.OUTEP_REGS[epnum]->DOEPINT,doepint.d32); 88 | 89 | /** 90 | * @} 91 | */ 92 | 93 | /** @defgroup USB_DCD_INT_Exported_Variables 94 | * @{ 95 | */ 96 | /** 97 | * @} 98 | */ 99 | 100 | /** @defgroup USB_DCD_INT_Exported_FunctionsPrototype 101 | * @{ 102 | */ 103 | 104 | uint32_t USBD_OTG_ISR_Handler (USB_OTG_CORE_HANDLE *pdev); 105 | 106 | /** 107 | * @} 108 | */ 109 | 110 | 111 | #endif // USB_DCD_INT_H__ 112 | 113 | /** 114 | * @} 115 | */ 116 | 117 | /** 118 | * @} 119 | */ 120 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 121 | 122 | -------------------------------------------------------------------------------- /cores/arduino/libmaple/usbF4/STM32_USB_OTG_Driver/inc/usb_hcd.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usb_hcd.h 4 | * @author MCD Application Team 5 | * @version V2.0.0 6 | * @date 22-July-2011 7 | * @brief Host layer Header file 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __USB_HCD_H__ 24 | #define __USB_HCD_H__ 25 | 26 | /* Includes ------------------------------------------------------------------*/ 27 | #include "usb_regs.h" 28 | #include "usb_core.h" 29 | 30 | 31 | /** @addtogroup USB_OTG_DRIVER 32 | * @{ 33 | */ 34 | 35 | /** @defgroup USB_HCD 36 | * @brief This file is the 37 | * @{ 38 | */ 39 | 40 | 41 | /** @defgroup USB_HCD_Exported_Defines 42 | * @{ 43 | */ 44 | /** 45 | * @} 46 | */ 47 | 48 | 49 | /** @defgroup USB_HCD_Exported_Types 50 | * @{ 51 | */ 52 | /** 53 | * @} 54 | */ 55 | 56 | 57 | /** @defgroup USB_HCD_Exported_Macros 58 | * @{ 59 | */ 60 | /** 61 | * @} 62 | */ 63 | 64 | /** @defgroup USB_HCD_Exported_Variables 65 | * @{ 66 | */ 67 | /** 68 | * @} 69 | */ 70 | 71 | /** @defgroup USB_HCD_Exported_FunctionsPrototype 72 | * @{ 73 | */ 74 | uint32_t HCD_Init (USB_OTG_CORE_HANDLE *pdev , 75 | USB_OTG_CORE_ID_TypeDef coreID); 76 | uint32_t HCD_HC_Init (USB_OTG_CORE_HANDLE *pdev , 77 | uint8_t hc_num); 78 | uint32_t HCD_SubmitRequest (USB_OTG_CORE_HANDLE *pdev , 79 | uint8_t hc_num) ; 80 | uint32_t HCD_GetCurrentSpeed (USB_OTG_CORE_HANDLE *pdev); 81 | uint32_t HCD_ResetPort (USB_OTG_CORE_HANDLE *pdev); 82 | uint32_t HCD_IsDeviceConnected (USB_OTG_CORE_HANDLE *pdev); 83 | uint32_t HCD_GetCurrentFrame (USB_OTG_CORE_HANDLE *pdev) ; 84 | URB_STATE HCD_GetURB_State (USB_OTG_CORE_HANDLE *pdev, uint8_t ch_num); 85 | uint32_t HCD_GetXferCnt (USB_OTG_CORE_HANDLE *pdev, uint8_t ch_num); 86 | HC_STATUS HCD_GetHCState (USB_OTG_CORE_HANDLE *pdev, uint8_t ch_num) ; 87 | /** 88 | * @} 89 | */ 90 | 91 | #endif //__USB_HCD_H__ 92 | 93 | 94 | /** 95 | * @} 96 | */ 97 | 98 | /** 99 | * @} 100 | */ 101 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 102 | 103 | -------------------------------------------------------------------------------- /cores/arduino/libmaple/usbF4/STM32_USB_OTG_Driver/inc/usb_otg.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usb_otg.h 4 | * @author MCD Application Team 5 | * @version V2.0.0 6 | * @date 22-July-2011 7 | * @brief OTG Core Header 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __USB_OTG__ 24 | #define __USB_OTG__ 25 | 26 | 27 | /** @addtogroup USB_OTG_DRIVER 28 | * @{ 29 | */ 30 | 31 | /** @defgroup USB_OTG 32 | * @brief This file is the 33 | * @{ 34 | */ 35 | 36 | 37 | /** @defgroup USB_OTG_Exported_Defines 38 | * @{ 39 | */ 40 | 41 | 42 | void USB_OTG_InitiateSRP(void); 43 | void USB_OTG_InitiateHNP(uint8_t state , uint8_t mode); 44 | void USB_OTG_Switchback (USB_OTG_CORE_HANDLE *pdev); 45 | uint32_t USB_OTG_GetCurrentState (USB_OTG_CORE_HANDLE *pdev); 46 | 47 | uint32_t STM32_USBO_OTG_ISR_Handler(USB_OTG_CORE_HANDLE *pdev); 48 | /** 49 | * @} 50 | */ 51 | 52 | 53 | /** @defgroup USB_OTG_Exported_Types 54 | * @{ 55 | */ 56 | /** 57 | * @} 58 | */ 59 | 60 | 61 | /** @defgroup USB_OTG_Exported_Macros 62 | * @{ 63 | */ 64 | /** 65 | * @} 66 | */ 67 | 68 | /** @defgroup USB_OTG_Exported_Variables 69 | * @{ 70 | */ 71 | /** 72 | * @} 73 | */ 74 | 75 | /** @defgroup USB_OTG_Exported_FunctionsPrototype 76 | * @{ 77 | */ 78 | /** 79 | * @} 80 | */ 81 | 82 | 83 | #endif //__USB_OTG__ 84 | 85 | 86 | /** 87 | * @} 88 | */ 89 | 90 | /** 91 | * @} 92 | */ 93 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 94 | 95 | -------------------------------------------------------------------------------- /cores/arduino/libmaple/usbF4/VCP/usbd_cdc_vcp.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_cdc_vcp.h 4 | * @author MCD Application Team 5 | * @version V1.0.0 6 | * @date 22-July-2011 7 | * @brief Header for usbd_cdc_vcp.c file. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __USBD_CDC_VCP_H 24 | #define __USBD_CDC_VCP_H 25 | 26 | /* Includes ------------------------------------------------------------------*/ 27 | //#include "stm32f4xx.h" 28 | 29 | #include "usbd_cdc_core.h" 30 | #include "usbd_conf.h" 31 | 32 | 33 | /* Exported typef ------------------------------------------------------------*/ 34 | /* The following structures groups all needed parameters to be configured for the 35 | ComPort. These parameters can modified on the fly by the host through CDC class 36 | command class requests. */ 37 | typedef struct 38 | { 39 | uint32_t bitrate; 40 | uint8_t format; 41 | uint8_t paritytype; 42 | uint8_t datatype; 43 | }LINE_CODING; 44 | 45 | /* Exported constants --------------------------------------------------------*/ 46 | /* The following define is used to route the USART IRQ handler to be used. 47 | The IRQ handler function is implemented in the usbd_cdc_vcp.c file. */ 48 | #ifdef USE_STM322xG_EVAL 49 | #define EVAL_COM_IRQHandler USART3_IRQHandler 50 | #elif defined(USE_STM3210C_EVAL) 51 | #define EVAL_COM_IRQHandler USART2_IRQHandler 52 | #endif /* USE_STM322xG_EVAL */ 53 | #define EVAL_COM_IRQHandler USART2_IRQHandler 54 | 55 | #define DEFAULT_CONFIG 0 56 | #define OTHER_CONFIG 1 57 | 58 | /* Exported macro ------------------------------------------------------------*/ 59 | /* Exported functions ------------------------------------------------------- */ 60 | 61 | #endif /* __USBD_CDC_VCP_H */ 62 | 63 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 64 | -------------------------------------------------------------------------------- /cores/arduino/libmaple/usbF4/VCP/usbd_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_conf.h 4 | * @author MCD Application Team 5 | * @version V1.0.0 6 | * @date 22-July-2011 7 | * @brief USB Device configuration file 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __USBD_CONF__H__ 24 | #define __USBD_CONF__H__ 25 | 26 | /* Includes ------------------------------------------------------------------*/ 27 | //#include "stm32f4_discovery.h" 28 | 29 | /** @defgroup USB_CONF_Exported_Defines 30 | * @{ 31 | */ 32 | #define USBD_CFG_MAX_NUM 1 33 | #define USBD_ITF_MAX_NUM 1 34 | #define USB_MAX_STR_DESC_SIZ 50 35 | 36 | /** @defgroup USB_VCP_Class_Layer_Parameter 37 | * @{ 38 | */ 39 | #define CDC_IN_EP 0x81 /* EP1 for data IN */ 40 | #define CDC_OUT_EP 0x01 /* EP1 for data OUT */ 41 | #define CDC_CMD_EP 0x82 /* EP2 for CDC commands */ 42 | 43 | /* CDC Endpoints parameters: you can fine tune these values depending on the needed baudrates and performance. */ 44 | #ifdef USE_USB_OTG_HS 45 | #define CDC_DATA_MAX_PACKET_SIZE 512 /* Endpoint IN & OUT Packet size */ 46 | #define CDC_CMD_PACKET_SZE 8 /* Control Endpoint Packet size */ 47 | 48 | #define CDC_IN_FRAME_INTERVAL 40 /* Number of micro-frames between IN transfers */ 49 | #define APP_RX_DATA_SIZE 2048 /* Total size of IN buffer: 50 | APP_RX_DATA_SIZE*8/MAX_BAUDARATE*1000 should be > CDC_IN_FRAME_INTERVAL*8 */ 51 | #else 52 | #define CDC_DATA_MAX_PACKET_SIZE 64 /* Endpoint IN & OUT Packet size */ 53 | #define CDC_CMD_PACKET_SZE 8 /* Control Endpoint Packet size */ 54 | 55 | #define CDC_IN_FRAME_INTERVAL 5 /* Number of frames between IN transfers */ 56 | #define APP_RX_DATA_SIZE 2048 /* Total size of IN buffer: 57 | APP_RX_DATA_SIZE*8/MAX_BAUDARATE*1000 should be > CDC_IN_FRAME_INTERVAL */ 58 | #endif /* USE_USB_OTG_HS */ 59 | 60 | #define APP_FOPS VCP_fops 61 | /** 62 | * @} 63 | */ 64 | 65 | /** @defgroup USB_CONF_Exported_Types 66 | * @{ 67 | */ 68 | /** 69 | * @} 70 | */ 71 | 72 | 73 | /** @defgroup USB_CONF_Exported_Macros 74 | * @{ 75 | */ 76 | /** 77 | * @} 78 | */ 79 | 80 | /** @defgroup USB_CONF_Exported_Variables 81 | * @{ 82 | */ 83 | /** 84 | * @} 85 | */ 86 | 87 | /** @defgroup USB_CONF_Exported_FunctionsPrototype 88 | * @{ 89 | */ 90 | /** 91 | * @} 92 | */ 93 | 94 | 95 | #endif //__USBD_CONF__H__ 96 | 97 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 98 | 99 | -------------------------------------------------------------------------------- /cores/arduino/libmaple/usbF4/usb.c: -------------------------------------------------------------------------------- 1 | #include "usbd_cdc_core.h" 2 | #include "usbd_usr.h" 3 | #include "usbd_desc.h" 4 | #include "usb.h" 5 | #include 6 | #include 7 | #include 8 | 9 | USB_OTG_CORE_HANDLE USB_OTG_dev; 10 | 11 | 12 | 13 | void setupUSB (void) { 14 | #define USB_DISC_DEV GPIOD 15 | #define USB_DISC_PIN 11 16 | 17 | gpio_set_mode(USB_DISC_DEV, USB_DISC_PIN, GPIO_OUTPUT_OD); // ala42 18 | #ifdef USB_DISC_OD 19 | //gpio_set_mode(USB_DISC_DEV, USB_DISC_PIN, GPIO_OUTPUT_OD); // ala42 20 | #else 21 | //gpio_set_mode(USB_DISC_DEV, USB_DISC_PIN, GPIO_OUTPUT_PP); // ala42 for active pull-up on disconnect pin 22 | #endif 23 | 24 | gpio_write_bit(USB_DISC_DEV, USB_DISC_PIN,0); // ala42 25 | delay_us(200000); 26 | 27 | /* setup the apb1 clock for USB */ 28 | //rcc_reg_map *pRCC = RCC_BASE; 29 | //pRCC->APB1ENR |= RCC_APB1ENR_USBEN; 30 | 31 | /* initialize the usb application */ 32 | gpio_write_bit(USB_DISC_DEV, USB_DISC_PIN, 1); // ala42 // presents us to the host 33 | USBD_Init(&USB_OTG_dev, 34 | USB_OTG_FS_CORE_ID, 35 | &USR_desc, 36 | &USBD_CDC_cb, 37 | &USR_cb); 38 | } 39 | 40 | extern uint16_t VCP_DataTx (uint8_t* Buf, uint32_t Len); 41 | extern void VCP_SetUSBTxBlocking(uint8_t mode); 42 | extern void VCP_SetUSBTxSmartBlockingTimeout(uint16_t timeout_ms); 43 | extern uint32_t VCPBytesAvailable(void); 44 | extern uint8_t VCPGetByte(void); 45 | 46 | uint32_t usbSendBytes(const uint8_t* sendBuf, uint32_t len) { 47 | VCP_DataTx((uint8_t*)sendBuf, len); 48 | return len; 49 | } 50 | 51 | void usbEnableBlockingTx(void) { 52 | VCP_SetUSBTxBlocking(1); 53 | } 54 | 55 | void usbEnableSmartBlockingTx(uint16_t timeout_ms) { 56 | VCP_SetUSBTxBlocking(2); 57 | VCP_SetUSBTxSmartBlockingTimeout(timeout_ms); 58 | } 59 | 60 | void usbDisableBlockingTx(void) { 61 | VCP_SetUSBTxBlocking(0); 62 | } 63 | 64 | uint32_t usbBytesAvailable(void) { 65 | return VCPBytesAvailable(); 66 | 67 | } 68 | uint32_t usbReceiveBytes(uint8_t* recvBuf, uint32_t len) { 69 | int newBytes = usbBytesAvailable(); 70 | if (len > newBytes) { 71 | len = newBytes; 72 | } 73 | 74 | int i; 75 | for (i=0;i> ((31 - (n)) + (m))) 51 | /** True if v is a power of two (1, 2, 4, 8, ...) */ 52 | #define IS_POWER_OF_TWO(v) ((v) && !((v) & ((v) - 1))) 53 | 54 | /* 55 | * Failure routines 56 | */ 57 | 58 | void __error(int num); 59 | void _fail(const char*, int, const char*); 60 | void throb(void); 61 | 62 | /* 63 | * Asserts and debug levels 64 | */ 65 | 66 | #define DEBUG_NONE 0 67 | #define DEBUG_FAULT 1 68 | #define DEBUG_ALL 2 69 | 70 | /** 71 | * \def DEBUG_LEVEL 72 | * 73 | * Controls the level of assertion checking. 74 | * 75 | * The higher the debug level, the more assertions will be compiled 76 | * in. This increases the amount of debugging information, but slows 77 | * down (and increases the size of) the binary. 78 | * 79 | * The debug levels, from lowest to highest, are DEBUG_NONE, 80 | * DEBUG_FAULT, and DEBUG_ALL. The default level is DEBUG_ALL. 81 | */ 82 | 83 | #ifndef DEBUG_LEVEL 84 | #define DEBUG_LEVEL DEBUG_ALL 85 | #endif 86 | 87 | #if DEBUG_LEVEL >= DEBUG_ALL 88 | #define ASSERT(exp) \ 89 | if (exp) { \ 90 | } else { \ 91 | _fail(__FILE__, __LINE__, #exp); \ 92 | } 93 | #else 94 | #define ASSERT(exp) (void)((0)) 95 | #endif 96 | 97 | #if DEBUG_LEVEL >= DEBUG_FAULT 98 | #define ASSERT_FAULT(exp) \ 99 | if (exp) { \ 100 | } else { \ 101 | _fail(__FILE__, __LINE__, #exp); \ 102 | } 103 | #else 104 | #define ASSERT_FAULT(exp) (void)((0)) 105 | #endif 106 | 107 | #ifdef __cplusplus 108 | } // extern "C" 109 | #endif 110 | 111 | #endif 112 | -------------------------------------------------------------------------------- /cores/arduino/pwm.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * The MIT License 3 | * 4 | * Copyright (c) 2010 Perry Hung. 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, copy, 10 | * modify, merge, publish, distribute, sublicense, and/or sell copies 11 | * of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be 15 | * included in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | *****************************************************************************/ 26 | 27 | /** 28 | * @brief Arduino-style PWM implementation. 29 | */ 30 | 31 | #include "libmaple_types.h" 32 | #include "timer.h" 33 | 34 | #include "boards.h" 35 | #include "pwm.h" 36 | 37 | void pwmWrite(uint8 pin, uint16 duty_cycle) { 38 | timer_dev *dev = PIN_MAP[pin].timer_device; 39 | if (pin >= BOARD_NR_GPIO_PINS || dev == NULL || dev->type == TIMER_BASIC) { 40 | return; 41 | } 42 | 43 | timer_set_compare(dev, PIN_MAP[pin].timer_channel, duty_cycle); 44 | } 45 | -------------------------------------------------------------------------------- /cores/arduino/pwm.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * The MIT License 3 | * 4 | * Copyright (c) 2010 Perry Hung. 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, copy, 10 | * modify, merge, publish, distribute, sublicense, and/or sell copies 11 | * of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be 15 | * included in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | *****************************************************************************/ 26 | 27 | /** 28 | * @file pwm.h 29 | * 30 | * @brief Arduino-compatible PWM interface. 31 | */ 32 | 33 | #ifndef _PWM_H_ 34 | #define _PWM_H_ 35 | 36 | /** 37 | * As a convenience, analogWrite is an alias of pwmWrite to ease 38 | * porting Arduino code. However, period and duty will have to be 39 | * recalibrated. 40 | */ 41 | #define analogWrite pwmWrite 42 | 43 | /** 44 | * Set the PWM duty on the given pin. 45 | * 46 | * User code is expected to determine and honor the maximum value 47 | * (based on the configured period). 48 | * 49 | * @param pin PWM output pin 50 | * @param duty_cycle Duty cycle to set. 51 | */ 52 | void pwmWrite(uint8 pin, uint16 duty_cycle); 53 | 54 | #endif 55 | 56 | -------------------------------------------------------------------------------- /cores/arduino/usb_serial.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * The MIT License 3 | * 4 | * Copyright (c) 2010 Perry Hung. 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, copy, 10 | * modify, merge, publish, distribute, sublicense, and/or sell copies 11 | * of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be 15 | * included in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | *****************************************************************************/ 26 | 27 | /** 28 | * @brief Wirish virtual serial port 29 | */ 30 | 31 | #ifndef _USB_SERIAL_H_ 32 | #define _USB_SERIAL_H_ 33 | 34 | #include "Stream.h" 35 | 36 | /** 37 | * @brief Virtual serial terminal. 38 | */ 39 | class USBSerial : public Stream { 40 | public: 41 | USBSerial(void); 42 | 43 | void begin(void); 44 | void begin(int); 45 | void end(void); 46 | 47 | virtual int available(void); 48 | virtual int peek(void); 49 | virtual void flush(void); 50 | 51 | virtual int read(void *buf, uint32 len); 52 | virtual int read(void); 53 | 54 | size_t write(uint8); 55 | size_t write(const char *str); 56 | size_t write(const void*, uint32); 57 | operator bool() { return true; } 58 | 59 | uint8 getRTS(); 60 | uint8 getDTR(); 61 | uint8 isConnected(); 62 | uint8 pending(); 63 | 64 | void enableBlockingTx(void); 65 | void enableSmartBlockingTx(uint16_t timeout_ms); 66 | void disableBlockingTx(void); 67 | }; 68 | 69 | extern USBSerial SerialUSB; 70 | 71 | #endif 72 | 73 | -------------------------------------------------------------------------------- /cores/arduino/wirish.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * The MIT License 3 | * 4 | * Copyright (c) 2010 Perry Hung. 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, copy, 10 | * modify, merge, publish, distribute, sublicense, and/or sell copies 11 | * of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be 15 | * included in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | *****************************************************************************/ 26 | 27 | /** 28 | * @brief Main include file for the Wirish core. 29 | * 30 | * Includes various Arduino wiring macros and bit defines 31 | */ 32 | 33 | #ifndef _WIRISH_H_ 34 | #define _WIRISH_H_ 35 | 36 | #include 37 | #include "libmaple.h" 38 | 39 | #include "wirish_types.h" 40 | #include "boards.h" 41 | #include "io.h" 42 | #include "bits.h" 43 | #include "pwm.h" 44 | #include "ext_interrupts.h" 45 | #include "wirish_debug.h" 46 | #include "wirish_math.h" 47 | #include "wirish_time.h" 48 | #include 49 | #include "HardwareSPI.h" 50 | #include "HardwareSerial.h" 51 | #include "HardwareTimer.h" 52 | #include "usb_serial.h" 53 | 54 | /* Arduino wiring macros and bit defines */ 55 | #define HIGH 0x1 56 | #define LOW 0x0 57 | 58 | #define true 0x1 59 | #define false 0x0 60 | 61 | 62 | #define lowByte(w) ((w) & 0xFF) 63 | #define highByte(w) (((w) >> 8) & 0xFF) 64 | #define bitRead(value, bit) (((value) >> (bit)) & 0x01) 65 | #define bitSet(value, bit) ((value) |= (1UL << (bit))) 66 | #define bitClear(value, bit) ((value) &= ~(1UL << (bit))) 67 | #define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : \ 68 | bitClear(value, bit)) 69 | #define bit(b) (1UL << (b)) 70 | 71 | typedef uint8 boolean; 72 | typedef uint8 byte; 73 | 74 | #endif 75 | 76 | -------------------------------------------------------------------------------- /cores/arduino/wirish_analog.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * The MIT License 3 | * 4 | * Copyright (c) 2010 Perry Hung. 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, copy, 10 | * modify, merge, publish, distribute, sublicense, and/or sell copies 11 | * of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be 15 | * included in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | *****************************************************************************/ 26 | 27 | /** 28 | * @brief Arduino-compatible ADC implementation. 29 | */ 30 | 31 | #include "libmaple.h" 32 | #include "wirish.h" 33 | #include "io.h" 34 | 35 | /* Assumes that the ADC has been initialized and that the pin is set 36 | * to INPUT_ANALOG */ 37 | uint16 analogRead(uint8 pin) { 38 | const adc_dev *dev = PIN_MAP[pin].adc_device; 39 | if (dev == NULL) { 40 | return 0; 41 | } 42 | 43 | return adc_read(dev, PIN_MAP[pin].adc_channel); 44 | } 45 | -------------------------------------------------------------------------------- /cores/arduino/wirish_constants.h: -------------------------------------------------------------------------------- 1 | #ifndef _WIRING_CONSTANTS_ 2 | #define _WIRING_CONSTANTS_ 3 | 4 | #ifdef __cplusplus 5 | extern "C"{ 6 | #endif 7 | 8 | enum BitOrder { 9 | LSBFIRST = 0, 10 | MSBFIRST = 1 11 | }; 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /cores/arduino/wirish_debug.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * The MIT License 3 | * 4 | * Copyright (c) 2011 LeafLabs, LLC. 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, copy, 10 | * modify, merge, publish, distribute, sublicense, and/or sell copies 11 | * of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be 15 | * included in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | *****************************************************************************/ 26 | 27 | /** 28 | * @file wirish_debug.h 29 | * @brief High level debug port configuration 30 | */ 31 | 32 | /** 33 | * @brief Disable the JTAG and Serial Wire (SW) debug ports. 34 | * 35 | * You can call this function in order to use the JTAG and SW debug 36 | * pins as ordinary GPIOs. 37 | * 38 | * @see enableDebugPorts() 39 | */ 40 | static inline void disableDebugPorts(void) { 41 | afio_cfg_debug_ports(AFIO_DEBUG_NONE); 42 | } 43 | 44 | /** 45 | * @brief Enable the JTAG and Serial Wire (SW) debug ports. 46 | * 47 | * After you call this function, the JTAG and SW debug pins will no 48 | * longer be usable as GPIOs. 49 | * 50 | * @see disableDebugPorts() 51 | */ 52 | static inline void enableDebugPorts(void) { 53 | afio_cfg_debug_ports(AFIO_DEBUG_FULL_SWJ); 54 | } 55 | -------------------------------------------------------------------------------- /cores/arduino/wirish_math.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Modified by LeafLabs, LLC. 3 | * 4 | * Part of the Wiring project - http://wiring.org.co Copyright (c) 5 | * 2004-06 Hernando Barragan Modified 13 August 2006, David A. Mellis 6 | * for Arduino - http://www.arduino.cc/ 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public License 10 | * as published by the Free Software Foundation; either version 2.1 of 11 | * the License, or (at your option) any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, but 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this library; if not, write to the Free Software 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 21 | * USA 22 | */ 23 | 24 | #include 25 | #include "math.h" 26 | 27 | void randomSeed(unsigned int seed) { 28 | if (seed != 0) { 29 | srand(seed); 30 | } 31 | } 32 | 33 | long random(long howbig) { 34 | if (howbig == 0) { 35 | return 0; 36 | } 37 | 38 | return rand() % howbig; 39 | } 40 | 41 | long random(long howsmall, long howbig) { 42 | if (howsmall >= howbig) { 43 | return howsmall; 44 | } 45 | 46 | long diff = howbig - howsmall; 47 | return random(diff) + howsmall; 48 | } 49 | 50 | -------------------------------------------------------------------------------- /cores/arduino/wirish_shift.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * wiring_shift.c - shiftOut() function 3 | * Part of Arduino - http://www.arduino.cc/ 4 | * 5 | * Copyright (c) 2005-2006 David A. Mellis 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public License 9 | * as published by the Free Software Foundation; either version 2.1 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 20 | * USA 21 | * 22 | * $Id: wiring.c 248 2007-02-03 15:36:30Z mellis $ 23 | */ 24 | 25 | #include "wirish.h" 26 | 27 | void shiftOut(uint8 dataPin, uint8 clockPin, uint8 bitOrder, uint8 val) { 28 | int i; 29 | 30 | for (i = 0; i < 8; i++) { 31 | if (bitOrder == LSBFIRST) { 32 | digitalWrite(dataPin, !!(val & (1 << i))); 33 | } else { 34 | digitalWrite(dataPin, !!(val & (1 << (7 - i)))); 35 | } 36 | 37 | digitalWrite(clockPin, HIGH); 38 | digitalWrite(clockPin, LOW); 39 | } 40 | } 41 | 42 | uint32 shiftIn( uint32 ulDataPin, uint32 ulClockPin, uint32 ulBitOrder ) 43 | { 44 | uint8_t value = 0 ; 45 | uint8_t i ; 46 | 47 | 48 | for ( i=0 ; i < 8 ; ++i ) 49 | { 50 | digitalWrite( ulClockPin, HIGH ) ; 51 | 52 | if ( ulBitOrder == LSBFIRST ) 53 | { 54 | value |= digitalRead( ulDataPin ) << i ; 55 | } 56 | else 57 | { 58 | value |= digitalRead( ulDataPin ) << (7 - i) ; 59 | } 60 | 61 | digitalWrite( ulClockPin, LOW ) ; 62 | } 63 | 64 | return value ; 65 | } -------------------------------------------------------------------------------- /cores/arduino/wirish_time.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * The MIT License 3 | * 4 | * Copyright (c) 2010 Perry Hung. 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, copy, 10 | * modify, merge, publish, distribute, sublicense, and/or sell copies 11 | * of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be 15 | * included in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | *****************************************************************************/ 26 | 27 | /** 28 | * @brief Delay implementation. 29 | */ 30 | 31 | #include "libmaple.h" 32 | #include "systick.h" 33 | #include "wirish_time.h" 34 | #include "delay.h" 35 | 36 | void delay(unsigned long ms) { 37 | uint32 i; 38 | for (i = 0; i < ms; i++) { 39 | delayMicroseconds(1000); 40 | } 41 | } 42 | 43 | void delayMicroseconds(uint32 us) { 44 | delay_us(us); 45 | } 46 | -------------------------------------------------------------------------------- /cores/arduino/wirish_time.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * The MIT License 3 | * 4 | * Copyright (c) 2010 Perry Hung. 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, copy, 10 | * modify, merge, publish, distribute, sublicense, and/or sell copies 11 | * of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be 15 | * included in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | *****************************************************************************/ 26 | 27 | /** 28 | * @file wirish_time.h 29 | * @brief Timing and delay functions. 30 | */ 31 | 32 | #ifndef __WIRISH_TIME_H_ 33 | #define __WIRISH_TIME_H_ 34 | 35 | #include "libmaple.h" 36 | #include "nvic.h" 37 | #include "systick.h" 38 | #include "boards.h" 39 | 40 | #define US_PER_MS 1000 41 | 42 | /** 43 | * Returns time (in milliseconds) since the beginning of program 44 | * execution. On overflow, restarts at 0. 45 | * @see micros() 46 | */ 47 | static inline uint32 millis(void) { 48 | return systick_uptime(); 49 | } 50 | 51 | /** 52 | * Returns time (in microseconds) since the beginning of program 53 | * execution. On overflow, restarts at 0. 54 | * @see millis() 55 | */ 56 | static inline uint32 micros(void) { 57 | uint32 ms; 58 | uint32 cycle_cnt; 59 | uint32 res; 60 | 61 | do { 62 | ms = millis(); 63 | cycle_cnt = systick_get_count(); 64 | asm volatile("nop"); //allow interrupt to fire 65 | asm volatile("nop"); 66 | } while (ms != millis()); 67 | 68 | if(systick_check_underflow()) { 69 | ms++; 70 | cycle_cnt = systick_get_count(); 71 | } 72 | 73 | /* SYSTICK_RELOAD_VAL is 1 less than the number of cycles it 74 | actually takes to complete a SysTick reload */ 75 | res = (ms * US_PER_MS) + 76 | (SYSTICK_RELOAD_VAL + 1 - cycle_cnt) / CYCLES_PER_MICROSECOND; 77 | 78 | return res; 79 | } 80 | 81 | /** 82 | * Delay for at least the given number of milliseconds. 83 | * 84 | * Interrupts, etc. may cause the actual number of milliseconds to 85 | * exceed ms. However, this function will return no less than ms 86 | * milliseconds from the time it is called. 87 | * 88 | * @param ms the number of milliseconds to delay. 89 | * @see delayMicroseconds() 90 | */ 91 | void delay(unsigned long ms); 92 | 93 | /** 94 | * Delay for at least the given number of microseconds. 95 | * 96 | * Interrupts, etc. may cause the actual number of microseconds to 97 | * exceed us. However, this function will return no less than us 98 | * microseconds from the time it is called. 99 | * 100 | * @param us the number of microseconds to delay. 101 | * @see delay() 102 | */ 103 | void delayMicroseconds(uint32 us); 104 | 105 | #endif 106 | -------------------------------------------------------------------------------- /cores/arduino/wirish_types.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * The MIT License 3 | * 4 | * Copyright (c) 2011 LeafLabs, LLC. 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, copy, 10 | * modify, merge, publish, distribute, sublicense, and/or sell copies 11 | * of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be 15 | * included in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | *****************************************************************************/ 26 | 27 | /** 28 | * @file wirish_types.h 29 | * @author Marti Bolivar 30 | * @brief Wirish library type definitions. 31 | */ 32 | 33 | #include "libmaple_types.h" 34 | #include "gpio.h" 35 | #include "timer.h" 36 | #include "adc.h" 37 | 38 | #ifndef _WIRISH_TYPES_H_ 39 | #define _WIRISH_TYPES_H_ 40 | 41 | /** 42 | * Invalid stm32_pin_info adc_channel value. 43 | * @see stm32_pin_info 44 | */ 45 | #define ADCx 0xFF 46 | 47 | /** 48 | * @brief Stores STM32-specific information related to a given Maple pin. 49 | * @see PIN_MAP 50 | */ 51 | typedef struct stm32_pin_info { 52 | gpio_dev *gpio_device; /**< Maple pin's GPIO device */ 53 | timer_dev *timer_device; /**< Pin's timer device, if any. */ 54 | const adc_dev *adc_device; /**< ADC device, if any. */ 55 | uint8 gpio_bit; /**< Pin's GPIO port bit. */ 56 | uint8 timer_channel; /**< Timer channel, or 0 if none. */ 57 | uint8 adc_channel; /**< Pin ADC channel, or ADCx if none. */ 58 | uint8 filler; 59 | } stm32_pin_info; 60 | 61 | /** 62 | * Variable attribute, instructs the linker to place the marked 63 | * variable in Flash instead of RAM. */ 64 | #define __FLASH__ __attr_flash 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /driver/usb_device.cat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Seeed-Studio/stm32f4ArduinoCore/860362a0662648b339c9efef0990407fadaa6218/driver/usb_device.cat -------------------------------------------------------------------------------- /driver/usb_device.inf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Seeed-Studio/stm32f4ArduinoCore/860362a0662648b339c9efef0990407fadaa6218/driver/usb_device.inf -------------------------------------------------------------------------------- /libraries/SD/File.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | SD - a slightly more friendly wrapper for sdfatlib 4 | 5 | This library aims to expose a subset of SD card functionality 6 | in the form of a higher level "wrapper" object. 7 | 8 | License: GNU General Public License V3 9 | (Because sdfatlib is licensed with this.) 10 | 11 | (C) Copyright 2010 SparkFun Electronics 12 | 13 | */ 14 | 15 | #include 16 | 17 | /* for debugging file open/close leaks 18 | uint8_t nfilecount=0; 19 | */ 20 | 21 | File::File(SdFile f, const char *n) { 22 | // oh man you are kidding me, new() doesnt exist? Ok we do it by hand! 23 | _file = (SdFile *)malloc(sizeof(SdFile)); 24 | if (_file) { 25 | memcpy(_file, &f, sizeof(SdFile)); 26 | 27 | strncpy(_name, n, 12); 28 | _name[12] = 0; 29 | 30 | /* for debugging file open/close leaks 31 | nfilecount++; 32 | Serial.print("Created \""); 33 | Serial.print(n); 34 | Serial.print("\": "); 35 | Serial.println(nfilecount, DEC); 36 | */ 37 | } 38 | } 39 | 40 | File::File(void) { 41 | _file = 0; 42 | _name[0] = 0; 43 | //Serial.print("Created empty file object"); 44 | } 45 | 46 | File::~File(void) { 47 | // Serial.print("Deleted file object"); 48 | } 49 | 50 | // returns a pointer to the file name 51 | char *File::name(void) { 52 | return _name; 53 | } 54 | 55 | // a directory is a special type of file 56 | boolean File::isDirectory(void) { 57 | return (_file && _file->isDir()); 58 | } 59 | 60 | 61 | size_t File::write(uint8_t val) { 62 | return write(&val, 1); 63 | } 64 | 65 | size_t File::write(const uint8_t *buf, size_t size) { 66 | size_t t; 67 | if (!_file) { 68 | setWriteError(); 69 | return 0; 70 | } 71 | _file->clearWriteError(); 72 | t = _file->write(buf, size); 73 | if (_file->getWriteError()) { 74 | setWriteError(); 75 | return 0; 76 | } 77 | return t; 78 | } 79 | 80 | int File::peek() { 81 | if (! _file) 82 | return 0; 83 | 84 | int c = _file->read(); 85 | if (c != -1) _file->seekCur(-1); 86 | return c; 87 | } 88 | 89 | int File::read() { 90 | if (_file) 91 | return _file->read(); 92 | return -1; 93 | } 94 | 95 | // buffered read for more efficient, high speed reading 96 | int File::read(void *buf, uint16_t nbyte) { 97 | if (_file) 98 | return _file->read(buf, nbyte); 99 | return 0; 100 | } 101 | 102 | int File::available() { 103 | if (! _file) return 0; 104 | 105 | uint32_t n = size() - position(); 106 | 107 | return n > 0X7FFF ? 0X7FFF : n; 108 | } 109 | 110 | void File::flush() { 111 | if (_file) 112 | _file->sync(); 113 | } 114 | 115 | boolean File::seek(uint32_t pos) { 116 | if (! _file) return false; 117 | 118 | return _file->seekSet(pos); 119 | } 120 | 121 | uint32_t File::position() { 122 | if (! _file) return -1; 123 | return _file->curPosition(); 124 | } 125 | 126 | uint32_t File::size() { 127 | if (! _file) return 0; 128 | return _file->fileSize(); 129 | } 130 | 131 | void File::close() { 132 | if (_file) { 133 | _file->close(); 134 | free(_file); 135 | _file = 0; 136 | 137 | /* for debugging file open/close leaks 138 | nfilecount--; 139 | Serial.print("Deleted "); 140 | Serial.println(nfilecount, DEC); 141 | */ 142 | } 143 | } 144 | 145 | File::operator bool() { 146 | if (_file) 147 | return _file->isOpen(); 148 | return false; 149 | } 150 | 151 | -------------------------------------------------------------------------------- /libraries/SD/README.txt: -------------------------------------------------------------------------------- 1 | 2 | ** SD - a slightly more friendly wrapper for sdfatlib ** 3 | 4 | This library aims to expose a subset of SD card functionality in the 5 | form of a higher level "wrapper" object. 6 | 7 | License: GNU General Public License V3 8 | (Because sdfatlib is licensed with this.) 9 | 10 | (C) Copyright 2010 SparkFun Electronics 11 | 12 | Now better than ever with optimization, multiple file support, directory handling, etc - ladyada! 13 | 14 | -------------------------------------------------------------------------------- /libraries/SD/SD.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | SD - a slightly more friendly wrapper for sdfatlib 4 | 5 | This library aims to expose a subset of SD card functionality 6 | in the form of a higher level "wrapper" object. 7 | 8 | License: GNU General Public License V3 9 | (Because sdfatlib is licensed with this.) 10 | 11 | (C) Copyright 2010 SparkFun Electronics 12 | 13 | */ 14 | 15 | #ifndef __SD_H__ 16 | #define __SD_H__ 17 | 18 | #if ARDUINO >= 100 19 | #include "Arduino.h" 20 | #else 21 | #include "WProgram.h" 22 | #endif 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | #define FILE_READ O_READ 29 | #define FILE_WRITE (O_READ | O_WRITE | O_CREAT) 30 | 31 | class File : public Stream { 32 | private: 33 | char _name[13]; // our name 34 | SdFile *_file; // underlying file pointer 35 | 36 | public: 37 | File(SdFile f, const char *name); // wraps an underlying SdFile 38 | File(void); // 'empty' constructor 39 | ~File(void); // destructor 40 | #if ARDUINO >= 100 41 | virtual size_t write(uint8_t); 42 | virtual size_t write(const uint8_t *buf, size_t size); 43 | #else 44 | virtual void write(uint8_t); 45 | virtual void write(const uint8_t *buf, size_t size); 46 | #endif 47 | virtual int read(); 48 | virtual int peek(); 49 | virtual int available(); 50 | virtual void flush(); 51 | int read(void *buf, uint16_t nbyte); 52 | boolean seek(uint32_t pos); 53 | uint32_t position(); 54 | uint32_t size(); 55 | void close(); 56 | operator bool(); 57 | char * name(); 58 | 59 | boolean isDirectory(void); 60 | File openNextFile(uint8_t mode = O_RDONLY); 61 | void rewindDirectory(void); 62 | 63 | using Print::write; 64 | }; 65 | 66 | class SDClass { 67 | 68 | private: 69 | // These are required for initialisation and use of sdfatlib 70 | Sd2Card card; 71 | SdVolume volume; 72 | SdFile root; 73 | 74 | // my quick&dirty iterator, should be replaced 75 | SdFile getParentDir(const char *filepath, int *indx); 76 | public: 77 | // This needs to be called to set up the connection to the SD card 78 | // before other methods are used. 79 | boolean begin(uint8_t csPin = SD_CHIP_SELECT_PIN, int8_t mosi = -1, int8_t miso = -1, int8_t sck = -1); 80 | 81 | //call this when a card is removed. It will allow you to inster and initialise a new card. 82 | void end(); 83 | 84 | // Open the specified file/directory with the supplied mode (e.g. read or 85 | // write, etc). Returns a File object for interacting with the file. 86 | // Note that currently only one file can be open at a time. 87 | File open(const char *filename, uint8_t mode = FILE_READ); 88 | 89 | // Methods to determine if the requested file path exists. 90 | boolean exists(char *filepath); 91 | 92 | // Create the requested directory heirarchy--if intermediate directories 93 | // do not exist they will be created. 94 | boolean mkdir(char *filepath); 95 | 96 | // Delete the file. 97 | boolean remove(char *filepath); 98 | 99 | boolean rmdir(char *filepath); 100 | 101 | void enableCRC(boolean mode); 102 | 103 | private: 104 | 105 | // This is used to determine the mode used to open a file 106 | // it's here because it's the easiest place to pass the 107 | // information through the directory walking function. But 108 | // it's probably not the best place for it. 109 | // It shouldn't be set directly--it is set via the parameters to `open`. 110 | int fileOpenMode; 111 | 112 | friend class File; 113 | friend boolean callback_openPath(SdFile&, char *, boolean, void *); 114 | }; 115 | 116 | extern SDClass SD; 117 | 118 | #endif 119 | -------------------------------------------------------------------------------- /libraries/SD/examples/Datalogger/Datalogger.ino: -------------------------------------------------------------------------------- 1 | /* 2 | SD card datalogger 3 | 4 | This example shows how to log data from three analog sensors 5 | to an SD card using the SD library. 6 | 7 | The circuit: 8 | * SD card attached to SPI bus as follows: 9 | ** UNO: MOSI - pin 11, MISO - pin 12, CLK - pin 13, CS - pin 4 (CS pin can be changed) 10 | and pin #10 (SS) must be an output 11 | ** Mega: MOSI - pin 51, MISO - pin 50, CLK - pin 52, CS - pin 4 (CS pin can be changed) 12 | and pin #52 (SS) must be an output 13 | ** Leonardo: Connect to hardware SPI via the ICSP header 14 | Pin 4 used here for consistency with other Arduino examples 15 | 16 | created 24 Nov 2010 17 | modified 9 Apr 2012 by Tom Igoe 18 | modified 16 Aug 2017 by Lambor Fang 19 | 20 | This example code is in the public domain. 21 | 22 | */ 23 | 24 | #include 25 | 26 | // On the Ethernet Shield, CS is pin 4. Note that even if it's not 27 | // used as the CS pin, the hardware CS pin (10 on most Arduino boards, 28 | // 53 on the Mega) must be left as an output or the SD library 29 | // functions will not work. 30 | const int chipSelect = 43; 31 | 32 | File dataFile; 33 | 34 | void setup() 35 | { 36 | SerialUSB.print("Initializing SD card..."); 37 | // make sure that the default chip select pin is set to 38 | // output, even if you don't use it: 39 | pinMode(SS, OUTPUT); 40 | 41 | // see if the card is present and can be initialized: 42 | if (!SD.begin(chipSelect)) { 43 | SerialUSB.println("Card failed, or not present"); 44 | // don't do anything more: 45 | while (1) ; 46 | } 47 | SerialUSB.println("card initialized."); 48 | 49 | // Open up the file we're going to log to! 50 | dataFile = SD.open("datalog.txt", FILE_WRITE); 51 | if (! dataFile) { 52 | SerialUSB.println("error opening datalog.txt"); 53 | // Wait forever since we cant write data 54 | while (1) ; 55 | } 56 | } 57 | 58 | void loop() 59 | { 60 | // make a string for assembling the data to log: 61 | String dataString = ""; 62 | 63 | // read three sensors and append to the string: 64 | for (int analogPin = 0; analogPin < 3; analogPin++) { 65 | int sensor = analogRead(analogPin); 66 | dataString += String(sensor); 67 | if (analogPin < 2) { 68 | dataString += ","; 69 | } 70 | } 71 | 72 | dataFile.println(dataString); 73 | 74 | // print to the serial port too: 75 | SerialUSB.println(dataString); 76 | 77 | // The following line will 'save' the file to the SD card after every 78 | // line of data - this will use more power and slow down how much data 79 | // you can read but it's safer! 80 | // If you want to speed up the system, remove the call to flush() and it 81 | // will save the file only every 512 bytes - every time a sector on the 82 | // SD card is filled with data. 83 | dataFile.flush(); 84 | 85 | // Take 1 measurement every 500 milliseconds 86 | delay(500); 87 | } 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /libraries/SD/examples/DumpFile/DumpFile.ino: -------------------------------------------------------------------------------- 1 | /* 2 | SD card file dump 3 | 4 | This example shows how to read a file from the SD card using the 5 | SD library and send it over the serialUSB port. 6 | 7 | The circuit: 8 | * SD card attached to SPI bus as follows: 9 | ** UNO: MOSI - pin 11, MISO - pin 12, CLK - pin 13, CS - pin 4 (CS pin can be changed) 10 | and pin #10 (SS) must be an output 11 | ** Mega: MOSI - pin 51, MISO - pin 50, CLK - pin 52, CS - pin 4 (CS pin can be changed) 12 | and pin #52 (SS) must be an output 13 | ** Leonardo: Connect to hardware SPI via the ICSP header 14 | 15 | created 22 December 2010 by Limor Fried 16 | modified 9 Apr 2012 by Tom Igoe 17 | modified 16 Aug 2017 by Lambor Fang 18 | 19 | This example code is in the public domain. 20 | 21 | */ 22 | #include 23 | 24 | // change this to match your SD shield or module; 25 | // Arduino Ethernet shield: pin 4 26 | // Adafruit SD shields and modules: pin 10 27 | // Sparkfun SD shield: pin 8 28 | const int chipSelect = 43; 29 | 30 | void setup() 31 | { 32 | SerialUSB.print("Initializing SD card..."); 33 | // make sure that the default chip select pin is set to 34 | // output, even if you don't use it: 35 | pinMode(SS, OUTPUT); 36 | 37 | // see if the card is present and can be initialized: 38 | if (!SD.begin(chipSelect)) { 39 | SerialUSB.println("Card failed, or not present"); 40 | // don't do anything more: 41 | return; 42 | } 43 | SerialUSB.println("card initialized."); 44 | 45 | // open the file. note that only one file can be open at a time, 46 | // so you have to close this one before opening another. 47 | File dataFile = SD.open("datalog.txt"); 48 | 49 | // if the file is available, write to it: 50 | if (dataFile) { 51 | while (dataFile.available()) { 52 | SerialUSB.write(dataFile.read()); 53 | } 54 | dataFile.close(); 55 | } 56 | // if the file isn't open, pop up an error: 57 | else { 58 | SerialUSB.println("error opening datalog.txt"); 59 | } 60 | } 61 | 62 | void loop() 63 | { 64 | } 65 | 66 | -------------------------------------------------------------------------------- /libraries/SD/examples/Files/Files.ino: -------------------------------------------------------------------------------- 1 | /* 2 | SD card basic file example 3 | 4 | This example shows how to create and destroy an SD card file 5 | The circuit: 6 | * SD card attached to SPI bus as follows: 7 | ** UNO: MOSI - pin 11, MISO - pin 12, CLK - pin 13, CS - pin 4 (CS pin can be changed) 8 | and pin #10 (SS) must be an output 9 | ** Mega: MOSI - pin 51, MISO - pin 50, CLK - pin 52, CS - pin 4 (CS pin can be changed) 10 | and pin #52 (SS) must be an output 11 | ** Leonardo: Connect to hardware SPI via the ICSP header 12 | 13 | created Nov 2010 14 | by David A. Mellis 15 | modified 9 Apr 2012 16 | by Tom Igoe 17 | modified 16 Aug 2017 by Lambor Fang 18 | 19 | This example code is in the public domain. 20 | 21 | */ 22 | #include 23 | 24 | File myFile; 25 | 26 | // change this to match your SD shield or module; 27 | // Arduino Ethernet shield: pin 4 28 | // Adafruit SD shields and modules: pin 10 29 | // Sparkfun SD shield: pin 8 30 | const int chipSelect = 43; 31 | 32 | void setup() 33 | { 34 | SerialUSB.print("Initializing SD card..."); 35 | // On the Ethernet Shield, CS is pin 4. It's set as an output by default. 36 | // Note that even if it's not used as the CS pin, the hardware SS pin 37 | // (10 on most Arduino boards, 53 on the Mega) must be left as an output 38 | // or the SD library functions will not work. 39 | pinMode(SS, OUTPUT); 40 | 41 | if (!SD.begin(chipSelect)) { 42 | SerialUSB.println("initialization failed!"); 43 | return; 44 | } 45 | SerialUSB.println("initialization done."); 46 | 47 | if (SD.exists("example.txt")) { 48 | SerialUSB.println("example.txt exists."); 49 | } 50 | else { 51 | SerialUSB.println("example.txt doesn't exist."); 52 | } 53 | 54 | // open a new file and immediately close it: 55 | SerialUSB.println("Creating example.txt..."); 56 | myFile = SD.open("example.txt", FILE_WRITE); 57 | myFile.close(); 58 | 59 | // Check to see if the file exists: 60 | if (SD.exists("example.txt")) { 61 | SerialUSB.println("example.txt exists."); 62 | } 63 | else { 64 | SerialUSB.println("example.txt doesn't exist."); 65 | } 66 | 67 | // delete the file: 68 | SerialUSB.println("Removing example.txt..."); 69 | SD.remove("example.txt"); 70 | 71 | if (SD.exists("example.txt")){ 72 | SerialUSB.println("example.txt exists."); 73 | } 74 | else { 75 | SerialUSB.println("example.txt doesn't exist."); 76 | } 77 | } 78 | 79 | void loop() 80 | { 81 | // nothing happens after setup finishes. 82 | } 83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /libraries/SD/examples/ReadWrite/ReadWrite.ino: -------------------------------------------------------------------------------- 1 | /* 2 | SD card read/write 3 | 4 | This example shows how to read and write data to and from an SD card file 5 | The circuit: 6 | * SD card attached to SPI bus as follows: 7 | ** UNO: MOSI - pin 11, MISO - pin 12, CLK - pin 13, CS - pin 4 (CS pin can be changed) 8 | and pin #10 (SS) must be an output 9 | ** Mega: MOSI - pin 51, MISO - pin 50, CLK - pin 52, CS - pin 4 (CS pin can be changed) 10 | and pin #52 (SS) must be an output 11 | ** Leonardo: Connect to hardware SPI via the ICSP header 12 | 13 | 14 | created Nov 2010 by David A. Mellis 15 | modified 9 Apr 2012 by Tom Igoe 16 | modified 16 Aug 2017 by Lambor Fang 17 | 18 | This example code is in the public domain. 19 | 20 | */ 21 | #include 22 | 23 | File myFile; 24 | 25 | // change this to match your SD shield or module; 26 | // Arduino Ethernet shield: pin 4 27 | // Adafruit SD shields and modules: pin 10 28 | // Sparkfun SD shield: pin 8 29 | const int chipSelect = 43; 30 | 31 | void setup() 32 | { 33 | SerialUSB.print("Initializing SD card..."); 34 | // On the Ethernet Shield, CS is pin 4. It's set as an output by default. 35 | // Note that even if it's not used as the CS pin, the hardware SS pin 36 | // (10 on most Arduino boards, 53 on the Mega) must be left as an output 37 | // or the SD library functions will not work. 38 | pinMode(SS, OUTPUT); 39 | 40 | if (!SD.begin(chipSelect)) { 41 | SerialUSB.println("initialization failed!"); 42 | return; 43 | } 44 | SerialUSB.println("initialization done."); 45 | 46 | // open the file. note that only one file can be open at a time, 47 | // so you have to close this one before opening another. 48 | myFile = SD.open("test.txt", FILE_WRITE); 49 | 50 | // if the file opened okay, write to it: 51 | if (myFile) { 52 | SerialUSB.print("Writing to test.txt..."); 53 | myFile.println("testing 1, 2, 3."); 54 | // close the file: 55 | myFile.close(); 56 | SerialUSB.println("done."); 57 | } else { 58 | // if the file didn't open, print an error: 59 | SerialUSB.println("error opening test.txt"); 60 | } 61 | 62 | // re-open the file for reading: 63 | myFile = SD.open("test.txt"); 64 | if (myFile) { 65 | SerialUSB.println("test.txt:"); 66 | 67 | // read from the file until there's nothing else in it: 68 | while (myFile.available()) { 69 | SerialUSB.write(myFile.read()); 70 | } 71 | // close the file: 72 | myFile.close(); 73 | } else { 74 | // if the file didn't open, print an error: 75 | SerialUSB.println("error opening test.txt"); 76 | } 77 | } 78 | 79 | void loop() 80 | { 81 | // nothing happens after setup 82 | } 83 | 84 | 85 | -------------------------------------------------------------------------------- /libraries/SD/examples/listfiles/listfiles.ino: -------------------------------------------------------------------------------- 1 | /* 2 | SD card basic file example 3 | 4 | This example shows how to create and destroy an SD card file 5 | The circuit: 6 | * SD card attached to SPI bus as follows: 7 | ** UNO: MOSI - pin 11, MISO - pin 12, CLK - pin 13, CS - pin 4 (CS pin can be changed) 8 | and pin #10 (SS) must be an output 9 | ** Mega: MOSI - pin 51, MISO - pin 50, CLK - pin 52, CS - pin 4 (CS pin can be changed) 10 | and pin #52 (SS) must be an output 11 | ** Leonardo: Connect to hardware SPI via the ICSP header 12 | 13 | created Nov 2010 by David A. Mellis 14 | modified 9 Apr 2012 by Tom Igoe 15 | modified 13 June 2012 by Limor Fried 16 | modified 16 Aug 2017 by Lambor Fang 17 | 18 | This example code is in the public domain. 19 | 20 | */ 21 | #include 22 | 23 | File root; 24 | 25 | // change this to match your SD shield or module; 26 | // Arduino Ethernet shield: pin 4 27 | // Adafruit SD shields and modules: pin 10 28 | // Sparkfun SD shield: pin 8 29 | const int chipSelect = 43; 30 | 31 | void setup() 32 | { 33 | SerialUSB.print("Initializing SD card..."); 34 | // On the Ethernet Shield, CS is pin 4. It's set as an output by default. 35 | // Note that even if it's not used as the CS pin, the hardware SS pin 36 | // (10 on Arduino Uno boards, 53 on the Mega) must be left as an output 37 | // or the SD library functions will not work. 38 | pinMode(SS, OUTPUT); 39 | 40 | if (!SD.begin(chipSelect)) { 41 | SerialUSB.println("initialization failed!"); 42 | return; 43 | } 44 | SerialUSB.println("initialization done."); 45 | 46 | root = SD.open("/"); 47 | 48 | printDirectory(root, 0); 49 | 50 | SerialUSB.println("done!"); 51 | } 52 | 53 | void loop() 54 | { 55 | // nothing happens after setup finishes. 56 | } 57 | 58 | void printDirectory(File dir, int numTabs) { 59 | // Begin at the start of the directory 60 | dir.rewindDirectory(); 61 | 62 | while(true) { 63 | File entry = dir.openNextFile(); 64 | if (! entry) { 65 | // no more files 66 | //SerialUSB.println("**nomorefiles**"); 67 | break; 68 | } 69 | for (uint8_t i=0; i. 19 | */ 20 | #ifndef SdFatUtil_h 21 | #define SdFatUtil_h 22 | /** 23 | * \file 24 | * Useful utility functions. 25 | */ 26 | #include 27 | #ifdef __AVR__ 28 | #include 29 | /** Store and print a string in flash memory.*/ 30 | #define PgmPrint(x) SerialPrint_P(PSTR(x)) 31 | /** Store and print a string in flash memory followed by a CR/LF.*/ 32 | #define PgmPrintln(x) SerialPrintln_P(PSTR(x)) 33 | /** Defined so doxygen works for function definitions. */ 34 | #endif 35 | #define NOINLINE __attribute__((noinline,unused)) 36 | #define UNUSEDOK __attribute__((unused)) 37 | //------------------------------------------------------------------------------ 38 | /** Return the number of bytes currently free in RAM. */ 39 | static UNUSEDOK int FreeRam(void) { 40 | extern int __bss_end; 41 | extern int* __brkval; 42 | int free_memory; 43 | if (reinterpret_cast(__brkval) == 0) { 44 | // if no heap use from end of bss section 45 | free_memory = reinterpret_cast(&free_memory) 46 | - reinterpret_cast(&__bss_end); 47 | } else { 48 | // use from top of stack to heap 49 | free_memory = reinterpret_cast(&free_memory) 50 | - reinterpret_cast(__brkval); 51 | } 52 | return free_memory; 53 | } 54 | #ifdef __AVR__ 55 | //------------------------------------------------------------------------------ 56 | /** 57 | * %Print a string in flash memory to the serial port. 58 | * 59 | * \param[in] str Pointer to string stored in flash memory. 60 | */ 61 | static NOINLINE void SerialPrint_P(PGM_P str) { 62 | for (uint8_t c; (c = pgm_read_byte(str)); str++) Serial.write(c); 63 | } 64 | //------------------------------------------------------------------------------ 65 | /** 66 | * %Print a string in flash memory followed by a CR/LF. 67 | * 68 | * \param[in] str Pointer to string stored in flash memory. 69 | */ 70 | static NOINLINE void SerialPrintln_P(PGM_P str) { 71 | SerialPrint_P(str); 72 | Serial.println(); 73 | } 74 | #endif // __AVR__ 75 | #endif // #define SdFatUtil_h 76 | -------------------------------------------------------------------------------- /libraries/SD/utility/platform_conf.h: -------------------------------------------------------------------------------- 1 | #ifndef platform_conf_h 2 | #define platform_conf_h 3 | // #include 4 | 5 | /* if board is STM32F4xx define this */ 6 | #define __STM32F4xx__ 7 | /* If use SPI lib define this */ 8 | // #define USE_SPI_LIB 9 | /* if use software spi define this */ 10 | #define SOFTWARE_SPI 11 | /* Define __arm__ if use arm platform */ 12 | #define __arm__ 13 | 14 | #endif -------------------------------------------------------------------------------- /libraries/WS2812/Seeed_ws2812.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Seeed_ws2812.h 3 | * Arduino library for RGB led WS2812 4 | * 5 | * Copyright (c) 2017 seeed technology inc. 6 | * Website : www.seeed.cc 7 | * Author : lambor 8 | * Create Time: April 2017 9 | * Change Log : 10 | * 11 | * The MIT License (MIT) 12 | * 13 | * Permission is hereby granted, free of charge, to any person obtaining a copy 14 | * of this software and associated documentation files (the "Software"), to deal 15 | * in the Software without restriction, including without limitation the rights 16 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17 | * copies of the Software, and to permit persons to whom the Software is 18 | * furnished to do so, subject to the following conditions: 19 | * 20 | * The above copyright notice and this permission notice shall be included in 21 | * all copies or substantial portions of the Software. 22 | * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 28 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 29 | * THE SOFTWARE. 30 | */ 31 | 32 | #ifndef SEEED_WS2812_h 33 | #define SEEED_WS2812_h 34 | 35 | #include 36 | #include 37 | 38 | class WS2812 { 39 | 40 | public: 41 | WS2812(uint32_t ledn, uint8_t sigPin); 42 | void begin(void); 43 | uint32_t getLedNum(void); 44 | void setLedNum(uint32_t); 45 | void WS2812Clear(void); 46 | void pureColor(uint8_t); 47 | void WS2812SetRGB(uint32_t led, uint8_t red, 48 | uint8_t green, uint8_t blue); 49 | void WS2812SetRGB(uint32_t led, uint8_t red, 50 | uint8_t green, uint8_t blue, uint8_t light); 51 | void WS2812Send(void); 52 | void WS2812SetHSV(uint32_t led, uint32_t hue, 53 | uint32_t saturation, uint32_t value); 54 | void rainbowCycle(uint8_t wait); 55 | uint32_t colorWheel(byte WheelPos, uint8_t n); 56 | void RGBCycle(uint16_t); 57 | 58 | uint8_t sigPin; 59 | uint32_t ledNum; 60 | uint8_t brightness = 255; 61 | uint8_t *WS2812Buffer; 62 | 63 | }; 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /libraries/WS2812/examples/ws2812/ws2812.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * ws2812.ino 3 | * 4 | * Example for ws2812 5 | * 6 | * Copyright (c) 2017 seeed technology inc. 7 | * Website : www.seeed.cc 8 | * Author : lambor 9 | * Create Time: April 2017 10 | * Change Log : 11 | * 12 | * The MIT License (MIT) 13 | * 14 | * Permission is hereby granted, free of charge, to any person obtaining a copy 15 | * of this software and associated documentation files (the "Software"), to deal 16 | * in the Software without restriction, including without limitation the rights 17 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 18 | * copies of the Software, and to permit persons to whom the Software is 19 | * furnished to do so, subject to the following conditions: 20 | * 21 | * The above copyright notice and this permission notice shall be included in 22 | * all copies or substantial portions of the Software. 23 | * 24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 27 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 28 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 29 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 30 | * THE SOFTWARE. 31 | */ 32 | 33 | #include "Seeed_ws2812.h" 34 | 35 | #define LEN_NUM 4 36 | #define LED_PIN 38 37 | 38 | WS2812 strip = WS2812(LEN_NUM, LED_PIN); 39 | 40 | void setup() { 41 | strip.begin(); 42 | strip.brightness = 20; 43 | } 44 | 45 | void loop() { 46 | strip.RGBCycle(1000); 47 | strip.rainbowCycle(20); 48 | } 49 | -------------------------------------------------------------------------------- /libraries/Wire/master_reader/master_reader.ino: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | void setup() 5 | { 6 | Wire.begin(); // join i2c bus (address optional for master) 7 | Serial.begin(9600); // start serial for output 8 | } 9 | 10 | void loop() 11 | { 12 | Wire.requestFrom(2, 6); // request 6 bytes from slave device #2 13 | 14 | while (Wire.available()) // slave may send less than requested 15 | { 16 | char c = Wire.read(); // receive a byte as character 17 | Serial.print(c); // print the character 18 | } 19 | Serial.println(); 20 | delay(500); 21 | } 22 | -------------------------------------------------------------------------------- /libraries/Wire/master_writer/master_writer.ino: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | void setup() 5 | { 6 | Wire.begin(); // join i2c bus (address optional for master) 7 | } 8 | 9 | byte x = 0; 10 | 11 | void loop() 12 | { 13 | Wire.beginTransmission(4); // transmit to device #4 14 | Wire.write("x is "); // sends five bytes 15 | Wire.write(x); // sends one byte 16 | Wire.endTransmission(); // stop transmitting 17 | 18 | x++; 19 | delay(500); 20 | } 21 | -------------------------------------------------------------------------------- /variants/discovery_f407/ld/extra_libs.inc: -------------------------------------------------------------------------------- 1 | /* 2 | * Extra archives needed by ARM's GCC ARM Embedded arm-none-eabi- 3 | * releases (https://launchpad.net/gcc-arm-embedded/). 4 | */ 5 | 6 | /* This is for the provided newlib. */ 7 | GROUP(libnosys.a) 8 | -------------------------------------------------------------------------------- /variants/discovery_f407/ld/flash.ld: -------------------------------------------------------------------------------- 1 | /* 2 | * Discovery F4 (STM32F407VGT6, high density) linker script for 3 | * Flash builds. 4 | */ 5 | 6 | MEMORY 7 | { 8 | ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 125K 9 | rom (rx) : ORIGIN = 0x08010000, LENGTH = 960K /* ala42 */ 10 | } 11 | 12 | /* GROUP(libcs4_stm32_high_density.a) */ 13 | 14 | REGION_ALIAS("REGION_TEXT", rom); 15 | REGION_ALIAS("REGION_DATA", ram); 16 | REGION_ALIAS("REGION_BSS", ram); 17 | REGION_ALIAS("REGION_RODATA", rom); 18 | 19 | _FLASH_BUILD = 1; 20 | INCLUDE common.inc 21 | -------------------------------------------------------------------------------- /variants/discovery_f407/ld/jtag.ld: -------------------------------------------------------------------------------- 1 | /* 2 | * STM32F4xx high density linker script for 3 | * JTAG (bare metal, no bootloader) builds. 4 | */ 5 | 6 | MEMORY 7 | { 8 | ram (rwx) : ORIGIN = 0x20000000, LENGTH = 112K 9 | rom (rx) : ORIGIN = 0x08000000, LENGTH = 1024K 10 | } 11 | 12 | /* GROUP(libcs3_stm32_high_density.a) */ 13 | 14 | REGION_ALIAS("REGION_TEXT", rom); 15 | REGION_ALIAS("REGION_DATA", ram); 16 | REGION_ALIAS("REGION_BSS", ram); 17 | REGION_ALIAS("REGION_RODATA", rom); 18 | 19 | _FLASH_BUILD = 1; 20 | INCLUDE common.inc 21 | -------------------------------------------------------------------------------- /variants/discovery_f407/ld/names.inc: -------------------------------------------------------------------------------- 1 | EXTERN(__cs3_stack) 2 | EXTERN(__cs3_reset) 3 | EXTERN(__exc_nmi) 4 | EXTERN(__exc_hardfault) 5 | EXTERN(__exc_memmanage) 6 | EXTERN(__exc_busfault) 7 | EXTERN(__exc_usagefault) 8 | EXTERN(__stm32reservedexception7) 9 | EXTERN(__stm32reservedexception8) 10 | EXTERN(__stm32reservedexception9) 11 | EXTERN(__stm32reservedexception10) 12 | EXTERN(__exc_svc) 13 | EXTERN(__exc_debug_monitor) 14 | EXTERN(__stm32reservedexception13) 15 | EXTERN(__exc_pendsv) 16 | EXTERN(__exc_systick) 17 | 18 | EXTERN(__irq_wwdg) 19 | EXTERN(__irq_pvd) 20 | EXTERN(__irq_tamper) 21 | EXTERN(__irq_rtc) 22 | EXTERN(__irq_flash) 23 | EXTERN(__irq_rcc) 24 | EXTERN(__irq_exti0) 25 | EXTERN(__irq_exti1) 26 | EXTERN(__irq_exti2) 27 | EXTERN(__irq_exti3) 28 | EXTERN(__irq_exti4) 29 | EXTERN(__irq_dma1_channel1) 30 | EXTERN(__irq_dma1_channel2) 31 | EXTERN(__irq_dma1_channel3) 32 | EXTERN(__irq_dma1_channel4) 33 | EXTERN(__irq_dma1_channel5) 34 | EXTERN(__irq_dma1_channel6) 35 | EXTERN(__irq_dma1_channel7) 36 | EXTERN(__irq_adc) 37 | EXTERN(__irq_usb_hp_can_tx) 38 | EXTERN(__irq_usb_lp_can_rx0) 39 | EXTERN(__irq_can_rx1) 40 | EXTERN(__irq_can_sce) 41 | EXTERN(__irq_exti9_5) 42 | EXTERN(__irq_tim1_brk) 43 | EXTERN(__irq_tim1_up) 44 | EXTERN(__irq_tim1_trg_com) 45 | EXTERN(__irq_tim1_cc) 46 | EXTERN(__irq_tim2) 47 | EXTERN(__irq_tim3) 48 | EXTERN(__irq_tim4) 49 | EXTERN(__irq_i2c1_ev) 50 | EXTERN(__irq_i2c1_er) 51 | EXTERN(__irq_i2c2_ev) 52 | EXTERN(__irq_i2c2_er) 53 | EXTERN(__irq_spi1) 54 | EXTERN(__irq_spi2) 55 | EXTERN(__irq_usart1) 56 | EXTERN(__irq_usart2) 57 | EXTERN(__irq_usart3) 58 | EXTERN(__irq_exti15_10) 59 | EXTERN(__irq_rtcalarm) 60 | EXTERN(__irq_usbwakeup) 61 | 62 | EXTERN(__irq_tim8_brk) 63 | EXTERN(__irq_tim8_up) 64 | EXTERN(__irq_tim8_trg_com) 65 | EXTERN(__irq_tim8_cc) 66 | EXTERN(__irq_adc3) 67 | EXTERN(__irq_fsmc) 68 | EXTERN(__irq_sdio) 69 | EXTERN(__irq_tim5) 70 | EXTERN(__irq_spi3) 71 | EXTERN(__irq_uart4) 72 | EXTERN(__irq_uart5) 73 | EXTERN(__irq_tim6) 74 | EXTERN(__irq_tim7) 75 | EXTERN(__irq_dma2_channel1) 76 | EXTERN(__irq_dma2_channel2) 77 | EXTERN(__irq_dma2_channel3) 78 | EXTERN(__irq_dma2_channel4_5) 79 | -------------------------------------------------------------------------------- /variants/discovery_f407/ld/ram.ld: -------------------------------------------------------------------------------- 1 | /* 2 | * aeroquad32 (STM32F103VET6, high density) linker script for 3 | * RAM builds. 4 | */ 5 | 6 | MEMORY 7 | { 8 | ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 61K 9 | /* rom (rx) : ORIGIN = 0x08005000, LENGTH = 0K ala42 */ 10 | rom (rx) : ORIGIN = 0x08010000, LENGTH = 0K /* ala42 */ 11 | } 12 | 13 | GROUP(libcs3_stm32_high_density.a) 14 | 15 | REGION_ALIAS("REGION_TEXT", ram); 16 | REGION_ALIAS("REGION_DATA", ram); 17 | REGION_ALIAS("REGION_BSS", ram); 18 | REGION_ALIAS("REGION_RODATA", ram); 19 | 20 | INCLUDE common.inc 21 | -------------------------------------------------------------------------------- /variants/discovery_f407/ld/vector_symbols.inc: -------------------------------------------------------------------------------- 1 | EXTERN(__msp_init) 2 | EXTERN(__exc_reset) 3 | EXTERN(__exc_nmi) 4 | EXTERN(__exc_hardfault) 5 | EXTERN(__exc_memmanage) 6 | EXTERN(__exc_busfault) 7 | EXTERN(__exc_usagefault) 8 | EXTERN(__stm32reservedexception7) 9 | EXTERN(__stm32reservedexception8) 10 | EXTERN(__stm32reservedexception9) 11 | EXTERN(__stm32reservedexception10) 12 | EXTERN(__exc_svc) 13 | EXTERN(__exc_debug_monitor) 14 | EXTERN(__stm32reservedexception13) 15 | EXTERN(__exc_pendsv) 16 | EXTERN(__exc_systick) 17 | 18 | EXTERN(__irq_wwdg) 19 | EXTERN(__irq_pvd) 20 | EXTERN(__irq_tamper) 21 | EXTERN(__irq_rtc) 22 | EXTERN(__irq_flash) 23 | EXTERN(__irq_rcc) 24 | EXTERN(__irq_exti0) 25 | EXTERN(__irq_exti1) 26 | EXTERN(__irq_exti2) 27 | EXTERN(__irq_exti3) 28 | EXTERN(__irq_exti4) 29 | EXTERN(__irq_dma1_channel1) 30 | EXTERN(__irq_dma1_channel2) 31 | EXTERN(__irq_dma1_channel3) 32 | EXTERN(__irq_dma1_channel4) 33 | EXTERN(__irq_dma1_channel5) 34 | EXTERN(__irq_dma1_channel6) 35 | EXTERN(__irq_dma1_channel7) 36 | EXTERN(__irq_adc) 37 | EXTERN(__irq_usb_hp_can_tx) 38 | EXTERN(__irq_usb_lp_can_rx0) 39 | EXTERN(__irq_can_rx1) 40 | EXTERN(__irq_can_sce) 41 | EXTERN(__irq_exti9_5) 42 | EXTERN(__irq_tim1_brk) 43 | EXTERN(__irq_tim1_up) 44 | EXTERN(__irq_tim1_trg_com) 45 | EXTERN(__irq_tim1_cc) 46 | EXTERN(__irq_tim2) 47 | EXTERN(__irq_tim3) 48 | EXTERN(__irq_tim4) 49 | EXTERN(__irq_i2c1_ev) 50 | EXTERN(__irq_i2c1_er) 51 | EXTERN(__irq_i2c2_ev) 52 | EXTERN(__irq_i2c2_er) 53 | EXTERN(__irq_spi1) 54 | EXTERN(__irq_spi2) 55 | EXTERN(__irq_usart1) 56 | EXTERN(__irq_usart2) 57 | EXTERN(__irq_usart3) 58 | EXTERN(__irq_exti15_10) 59 | EXTERN(__irq_rtcalarm) 60 | EXTERN(__irq_usbwakeup) 61 | 62 | EXTERN(__irq_tim8_brk) 63 | EXTERN(__irq_tim8_up) 64 | EXTERN(__irq_tim8_trg_com) 65 | EXTERN(__irq_tim8_cc) 66 | EXTERN(__irq_adc3) 67 | EXTERN(__irq_fsmc) 68 | EXTERN(__irq_sdio) 69 | EXTERN(__irq_tim5) 70 | EXTERN(__irq_spi3) 71 | EXTERN(__irq_uart4) 72 | EXTERN(__irq_uart5) 73 | EXTERN(__irq_tim6) 74 | EXTERN(__irq_tim7) 75 | EXTERN(__irq_dma2_channel1) 76 | EXTERN(__irq_dma2_channel2) 77 | EXTERN(__irq_dma2_channel3) 78 | EXTERN(__irq_dma2_channel4_5) 79 | -------------------------------------------------------------------------------- /variants/discovery_f407/pins_arduino.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | // API compatibility 6 | #include "variant.h" -------------------------------------------------------------------------------- /variants/discovery_f407/variant.h: -------------------------------------------------------------------------------- 1 | #ifndef _VARIANT_ARDUINO_STM32_ 2 | #define _VARIANT_ARDUINO_STM32_ 3 | 4 | #define digitalPinToPort(P) ( PIN_MAP[P].gpio_device ) 5 | #define digitalPinToBitMask(P) ( BIT(PIN_MAP[P].gpio_bit) ) 6 | #define portOutputRegister(port) ( &(port->regs->ODR) ) 7 | #define portInputRegister(port) ( &(port->regs->IDR) ) 8 | 9 | #define portSetRegister(pin) ( &(PIN_MAP[pin].gpio_device->regs->BSRR) ) 10 | #define portClearRegister(pin) ( &(PIN_MAP[pin].gpio_device->regs->BRR) ) 11 | 12 | #define portConfigRegister(pin) ( &(PIN_MAP[pin].gpio_device->regs->CRL) ) 13 | 14 | static const uint8_t SS = BOARD_SPI1_NSS_PIN; 15 | static const uint8_t SS1 = BOARD_SPI2_NSS_PIN; 16 | static const uint8_t MOSI = BOARD_SPI1_MOSI_PIN; 17 | static const uint8_t MISO = BOARD_SPI1_MISO_PIN; 18 | static const uint8_t SCK = BOARD_SPI1_SCK_PIN; 19 | 20 | #endif /* _VARIANT_ARDUINO_STM32_ */ -------------------------------------------------------------------------------- /variants/discovery_f407/wirish/start.S: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * The MIT License 3 | * 4 | * Copyright (c) 2011 LeafLabs, LLC. 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, copy, 10 | * modify, merge, publish, distribute, sublicense, and/or sell copies 11 | * of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be 15 | * included in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | *****************************************************************************/ 26 | 27 | /* 28 | * This file is a modified version of a file obtained from 29 | * CodeSourcery Inc. (now part of Mentor Graphics Corp.), in which the 30 | * following text appeared: 31 | * 32 | * The authors hereby grant permission to use, copy, modify, distribute, 33 | * and license this software and its documentation for any purpose, provided 34 | * that existing copyright notices are retained in all copies and that this 35 | * notice is included verbatim in any distributions. No written agreement, 36 | * license, or royalty fee is required for any of the authorized uses. 37 | * Modifications to this software may be copyrighted by their authors 38 | * and need not follow the licensing terms described here, provided that 39 | * the new terms are clearly indicated on the first page of each file where 40 | * they apply. 41 | */ 42 | 43 | .text 44 | .code 16 45 | .thumb_func 46 | 47 | .globl __start__ 48 | .type __start__, %function 49 | __start__: 50 | .fnstart 51 | ldr r1,=__msp_init 52 | mov sp,r1 53 | ldr r1,=start_c 54 | bx r1 55 | .pool 56 | .cantunwind 57 | .fnend 58 | -------------------------------------------------------------------------------- /variants/discovery_f407/wirish/start_c.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * The MIT License 3 | * 4 | * Copyright (c) 2011 LeafLabs, LLC. 5 | * 6 | * Permission is hereby granted, free of charge, to any person 7 | * obtaining a copy of this software and associated documentation 8 | * files (the "Software"), to deal in the Software without 9 | * restriction, including without limitation the rights to use, copy, 10 | * modify, merge, publish, distribute, sublicense, and/or sell copies 11 | * of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be 15 | * included in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | * SOFTWARE. 25 | *****************************************************************************/ 26 | 27 | /* 28 | * This file is a modified version of a file obtained from 29 | * CodeSourcery Inc. (now part of Mentor Graphics Corp.), in which the 30 | * following text appeared: 31 | * 32 | * Copyright (c) 2006, 2007 CodeSourcery Inc 33 | * 34 | * The authors hereby grant permission to use, copy, modify, distribute, 35 | * and license this software and its documentation for any purpose, provided 36 | * that existing copyright notices are retained in all copies and that this 37 | * notice is included verbatim in any distributions. No written agreement, 38 | * license, or royalty fee is required for any of the authorized uses. 39 | * Modifications to this software may be copyrighted by their authors 40 | * and need not follow the licensing terms described here, provided that 41 | * the new terms are clearly indicated on the first page of each file where 42 | * they apply. 43 | */ 44 | 45 | #include 46 | 47 | extern void __libc_init_array(void); 48 | 49 | extern int main(int, char**, char**); 50 | 51 | extern void exit(int) __attribute__((noreturn, weak)); 52 | 53 | /* The linker must ensure that these are at least 4-byte aligned. */ 54 | extern char __data_start__, __data_end__; 55 | extern char __bss_start__, __bss_end__; 56 | 57 | struct rom_img_cfg { 58 | int *img_start; 59 | }; 60 | 61 | extern char _lm_rom_img_cfgp; 62 | 63 | void __attribute__((noreturn)) start_c(void) { 64 | struct rom_img_cfg *img_cfg = (struct rom_img_cfg*)&_lm_rom_img_cfgp; 65 | int *src = img_cfg->img_start; 66 | int *dst = (int*)&__data_start__; 67 | int exit_code; 68 | 69 | /* Initialize .data, if necessary. */ 70 | if (src != dst) { 71 | int *end = (int*)&__data_end__; 72 | while (dst < end) { 73 | *dst++ = *src++; 74 | } 75 | } 76 | 77 | /* Zero .bss. */ 78 | dst = (int*)&__bss_start__; 79 | while (dst < (int*)&__bss_end__) { 80 | *dst++ = 0; 81 | } 82 | 83 | /* Run initializers. */ 84 | __libc_init_array(); 85 | 86 | /* Jump to main. */ 87 | exit_code = main(0, 0, 0); 88 | if (exit) { 89 | exit(exit_code); 90 | } 91 | 92 | /* If exit is NULL, make sure we don't return. */ 93 | for (;;) 94 | continue; 95 | } 96 | --------------------------------------------------------------------------------