Merge remote-tracking branch 'refs/remotes/rogerclarkmelbourne/master'
This commit is contained in:
commit
22fad7582d
|
@ -9,7 +9,7 @@ Use of these files is at your own risk.
|
|||
|
||||
|
||||
##Summary:
|
||||
This repo contains, the "Hardware" files to support STM32 based boards on Arduino version 1.6.4 and 1.6.5, and 1.6.9 including [LeafLabs Maple, and Maple mini](http://www.leaflabs.com/about-maple/), and other generic STM32F103 boards
|
||||
This repo contains, the "Hardware" files to support STM32 based boards on Arduino version 1.6.13 or 1.6.12 (some older versions may also work) including [LeafLabs Maple, and Maple mini](http://www.leaflabs.com/about-maple/), and other generic STM32F103 boards
|
||||
|
||||
***PRIMARY SUPPORT FORUM: http://www.stm32duino.com/***
|
||||
|
||||
|
|
|
@ -580,3 +580,34 @@ genericGD32F103C.menu.cpu_speed.speed_96mhz.build.f_cpu=96000000L
|
|||
|
||||
genericGD32F103C.menu.cpu_speed.speed_72mhz=72Mhz (compatibility)
|
||||
genericGD32F103C.menu.cpu_speed.speed_72mhz.build.f_cpu=72000000L
|
||||
|
||||
########################### STM32VLD to FLASH ###########################
|
||||
|
||||
STM32VLD.name=STM32VLD to FLASH
|
||||
#STM32VLD.vid.0=0x1EAF
|
||||
#STM32VLD.pid.0=0x0004
|
||||
|
||||
STM32VLD.build.vect=VECT_TAB_ADDR=0x8000000
|
||||
STM32VLD.build.core=maple
|
||||
STM32VLD.build.board=STM32VLD
|
||||
STM32VLD.build.variant=STM32VLD
|
||||
STM32VLD.build.ldscript=ld/jtag.ld
|
||||
|
||||
STM32VLD.build.family=cortex-m3
|
||||
STM32VLD.build.f_cpu=24000000L
|
||||
STM32VLD.upload.use_1200bps_touch=false
|
||||
STM32VLD.upload.file_type=bin
|
||||
STM32VLD.upload.auto_reset=true
|
||||
STM32VLD.upload.params.quiet=no
|
||||
|
||||
STM32VLD.build.cpu_flags=-DMCU_STM32F100RB
|
||||
##---------------------------- UPLOAD METHODS ---------------------------
|
||||
|
||||
|
||||
STM32VLD.menu.upload_method.STLinkMethod=STLink
|
||||
STM32VLD.menu.upload_method.STLinkMethod.upload.protocol=STLink
|
||||
STM32VLD.menu.upload_method.STLinkMethod.upload.tool=stlink_upload
|
||||
STM32VLD.menu.upload_method.STLinkMethod.build.upload_flags=-DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG
|
||||
|
||||
|
||||
################################################################################
|
||||
|
|
|
@ -126,9 +126,7 @@ size_t Print::print(double n, int digits) {
|
|||
|
||||
size_t Print::print(const __FlashStringHelper *ifsh)
|
||||
{
|
||||
size_t n = print(ifsh);
|
||||
n += println();
|
||||
return n;
|
||||
return print(reinterpret_cast<const char *>(ifsh));
|
||||
}
|
||||
|
||||
size_t Print::print(const Printable& x)
|
||||
|
|
|
@ -160,4 +160,6 @@ uint16 analogRead(uint8 pin);
|
|||
*/
|
||||
void shiftOut(uint8 dataPin, uint8 clockPin, uint8 bitOrder, uint8 value);
|
||||
|
||||
uint32 shiftIn( uint32 ulDataPin, uint32 ulClockPin, uint32 ulBitOrder );
|
||||
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
Copyright (c) 2014 Arduino. All right reserved.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
void *operator new(size_t size) {
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
void *operator new[](size_t size) {
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
void operator delete(void * ptr) {
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
void operator delete[](void * ptr) {
|
||||
free(ptr);
|
||||
}
|
||||
|
|
@ -0,0 +1,203 @@
|
|||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// tone(pin,frequency[,duration]) generate a tone on a given pin
|
||||
//
|
||||
// noTone(pin) switch off the tone on the pin
|
||||
//
|
||||
// setToneTimerChannel(timer,channel) force use of given timer/channel
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "Arduino.h"
|
||||
#include <HardwareTimer.h>
|
||||
|
||||
|
||||
#define PinTimer(pin) (PIN_MAP[pin].timer_device->clk_id-RCC_TIMER1+1)
|
||||
#define PinChannel(pin) (PIN_MAP[pin].timer_channel)
|
||||
|
||||
// if USE_PIN_TIMER is set, the PWM timer/channel is used for PWM pins
|
||||
#define USE_PIN_TIMER
|
||||
|
||||
// if USE_BSRR is set the tone pin will be written via the fast BSRR register
|
||||
// instead of using the slow digitalWrite() function in the interrupt handler
|
||||
#define USE_BSRR
|
||||
|
||||
// construct static timer array (
|
||||
|
||||
|
||||
#ifdef STM32_HIGH_DENSITY
|
||||
// define default timer and channel
|
||||
#ifndef TONE_TIMER
|
||||
#define TONE_TIMER 8
|
||||
#endif
|
||||
#ifndef TONE_CHANNEL
|
||||
#define TONE_CHANNEL 8
|
||||
#endif
|
||||
|
||||
HardwareTimer TTimer1(1), TTimer2(2), TTimer3(3), TTimer4(4),TTimer5(5), TTimer6(6), TTimer7(7), TTimer8(8);
|
||||
HardwareTimer *TTimer[8] = { &TTimer1,&TTimer2,&TTimer3,&TTimer4,&TTimer5,&TTimer6,&TTimer7,&TTimer8 };
|
||||
#else
|
||||
// define default timer and channel
|
||||
#ifndef TONE_TIMER
|
||||
#define TONE_TIMER 4
|
||||
#endif
|
||||
#ifndef TONE_CHANNEL
|
||||
#define TONE_CHANNEL 4
|
||||
#endif
|
||||
|
||||
HardwareTimer TTimer1(1), TTimer2(2), TTimer3(3), TTimer4(4);
|
||||
HardwareTimer *TTimer[4] = { &TTimer1,&TTimer2,&TTimer3,&TTimer4 };
|
||||
#endif
|
||||
|
||||
|
||||
uint8_t tone_force_channel = 0; // forced timer channel
|
||||
uint8_t tone_force_ntimer = 0; // forced timer
|
||||
|
||||
HardwareTimer *tone_timer;// = TTimer[TONE_TIMER-1]; // timer used to generate frequency
|
||||
uint8_t tone_channel = TONE_CHANNEL; // timer channel used to generate frequency
|
||||
uint8_t tone_ntimer = TONE_TIMER; // timer used to generate frequency
|
||||
|
||||
bool tone_state = true; // last pin state for toggling
|
||||
short tone_pin = -1; // pin for outputting sound
|
||||
short tone_freq = 444; // tone frequency (0=pause)
|
||||
uint32_t tone_nhw = 0; // tone duration in number of half waves
|
||||
uint16_t tone_tcount = 0; // time between handler calls in 1/36 usec
|
||||
uint16_t tone_ncount = 0; // handler call between toggling
|
||||
uint16_t tone_n = 0; // remaining handler calls before toggling
|
||||
uint32_t tone_next = 0; // counter value of next interrupt
|
||||
|
||||
#ifdef USE_BSRR
|
||||
volatile uint32_t *tone_bsrr; // BSRR set register (lower 16 bits)
|
||||
uint32_t tone_smask=0; // BSRR set bitmask
|
||||
uint32_t tone_rmask=0; // BSRR reset bitmask
|
||||
#endif
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// timer hander for tone with no duration specified,
|
||||
// will keep going until noTone() is called
|
||||
void tone_handler_1(void) {
|
||||
tone_next += tone_tcount; // comparator value for next interrupt
|
||||
tone_timer->setCompare(tone_channel, tone_next); // and install it
|
||||
if(--tone_n == 0){
|
||||
tone_state = !tone_state; // toggle tone output
|
||||
|
||||
#ifdef USE_BSRR
|
||||
if(tone_state)
|
||||
*tone_bsrr = tone_smask;
|
||||
else
|
||||
*tone_bsrr = tone_rmask;
|
||||
#else
|
||||
digitalWrite(tone_pin,tone_state);// and output it
|
||||
#endif
|
||||
|
||||
tone_n = tone_ncount; // reset interrupt counter
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// timer hander for tone with a specified duration,
|
||||
// will stop automatically when duration time is up.
|
||||
void tone_handler_2(void) {
|
||||
tone_next += tone_tcount;
|
||||
tone_timer->setCompare(tone_channel, tone_next);
|
||||
if(--tone_n == 0){
|
||||
if(tone_freq>0){ // toggle pin
|
||||
tone_state = !tone_state;
|
||||
#ifdef USE_BSRR
|
||||
if(tone_state)
|
||||
*tone_bsrr = tone_smask;
|
||||
else
|
||||
*tone_bsrr = tone_rmask;
|
||||
#else
|
||||
digitalWrite(tone_pin,tone_state);// and output it
|
||||
#endif
|
||||
}
|
||||
tone_n = tone_ncount;
|
||||
if(!--tone_nhw){ // check if tone duration has finished
|
||||
tone_timer->pause(); // disable timer
|
||||
pinMode(tone_pin, INPUT); // disable tone pin
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// play a tone on given pin with given frequency and optional duration in msec
|
||||
void tone(uint32_t pin, uint32_t freq, uint32_t duration) {
|
||||
tone_pin = pin;
|
||||
|
||||
#ifdef USE_PIN_TIMER
|
||||
// if the pin has a PWM timer/channel, use it (unless the timer/channel are forced)
|
||||
if(PinChannel(tone_pin) && !tone_force_channel){
|
||||
tone_channel = PinChannel(tone_pin);
|
||||
tone_ntimer = PinTimer(tone_pin);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
// set timer and channel to default resp values forced with setToneTimerChannel
|
||||
tone_ntimer = tone_force_channel?tone_force_ntimer:TONE_TIMER;
|
||||
tone_channel = tone_force_channel?tone_force_channel:TONE_CHANNEL;
|
||||
}
|
||||
|
||||
tone_timer = TTimer[tone_ntimer-1];
|
||||
tone_freq = freq;
|
||||
tone_nhw = 0;
|
||||
tone_next = 0;
|
||||
|
||||
tone_timer->pause();
|
||||
|
||||
if(freq > 0 && duration >0 ){
|
||||
uint32_t count = 18000000/freq; // timer counts per half wave
|
||||
tone_ncount = tone_n = (count>>16)+1; // number of 16-bit count chunk
|
||||
tone_tcount = count/tone_ncount; // size of count chunk
|
||||
if(duration > 0) // number of half waves to be generated
|
||||
tone_nhw = ((duration*(freq>0?freq:100))/1000)<<1;
|
||||
else // no duration specified, continuous sound until noTone() called
|
||||
tone_nhw = 0;
|
||||
|
||||
pinMode(tone_pin, PWM); // configure output pin
|
||||
pinMode(tone_pin, OUTPUT); // configure output pin
|
||||
|
||||
#ifdef USE_BSRR
|
||||
// Set up BSRR register values for fast ISR
|
||||
tone_bsrr = &((PIN_MAP[tone_pin].gpio_device)->regs->BSRR);
|
||||
tone_smask = (BIT(PIN_MAP[tone_pin].gpio_bit));
|
||||
tone_rmask = tone_smask<<16;
|
||||
#endif
|
||||
|
||||
// Set up an interrupt on given timer and channel
|
||||
tone_next = tone_tcount; // prepare channel compare register
|
||||
tone_timer->setMode(tone_channel,TIMER_OUTPUT_COMPARE);
|
||||
tone_timer->setCompare(tone_channel,tone_next);
|
||||
// attach corresponding handler routine
|
||||
tone_timer->attachInterrupt(tone_channel,tone_nhw?tone_handler_2:tone_handler_1);
|
||||
|
||||
// Refresh the tone timer
|
||||
tone_timer->refresh();
|
||||
|
||||
// Start the timer counting
|
||||
tone_timer->resume();
|
||||
|
||||
} else {
|
||||
|
||||
// detach handler routine
|
||||
tone_timer->detachInterrupt(tone_channel);
|
||||
// disactive pin by configuring it as input
|
||||
pinMode(tone_pin, INPUT);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// disable tone on specified pin, if any
|
||||
void noTone(uint32_t pin){
|
||||
tone(pin,0,0); // it's all handled in tone()
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// set timer and channel to some different value
|
||||
// must be called before calling tone() or after noTone() was called
|
||||
void setToneTimerChannel(uint8_t ntimer, uint8_t channel){
|
||||
tone_force_ntimer = ntimer;
|
||||
tone_force_channel = channel;
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
Copyright (c) 2015 Arduino LLC. All right reserved.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include "Arduino.h"
|
||||
|
||||
void tone(uint32_t _pin, uint32_t frequency, uint32_t duration = 0);
|
||||
void noTone(uint32_t _pin);
|
||||
|
||||
#endif
|
|
@ -76,6 +76,7 @@
|
|||
#include <stdint.h>
|
||||
|
||||
#include <WCharacter.h>
|
||||
#include <tone.h>
|
||||
|
||||
typedef unsigned int word;
|
||||
// typedef uint16 word;// definition from Arduino website, now appears to be incorrect for 32 bit devices
|
||||
|
|
|
@ -35,3 +35,28 @@ void shiftOut(uint8 dataPin, uint8 clockPin, uint8 bitOrder, uint8 value) {
|
|||
gpio_toggle_bit(PIN_MAP[clockPin].gpio_device, PIN_MAP[clockPin].gpio_bit);// togglePin(clockPin);
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t shiftIn( uint32_t ulDataPin, uint32_t ulClockPin, uint32_t ulBitOrder )
|
||||
{
|
||||
uint8_t value = 0 ;
|
||||
uint8_t i ;
|
||||
|
||||
|
||||
for ( i=0 ; i < 8 ; ++i )
|
||||
{
|
||||
digitalWrite( ulClockPin, HIGH ) ;
|
||||
|
||||
if ( ulBitOrder == LSBFIRST )
|
||||
{
|
||||
value |= digitalRead( ulDataPin ) << i ;
|
||||
}
|
||||
else
|
||||
{
|
||||
value |= digitalRead( ulDataPin ) << (7 - i) ;
|
||||
}
|
||||
|
||||
digitalWrite( ulClockPin, LOW ) ;
|
||||
}
|
||||
|
||||
return value ;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ void setup_temperature_sensor() {
|
|||
// temperature sensor from power down mode. Do this first 'cause according to
|
||||
// the Datasheet section 5.3.21 it takes from 4 to 10 uS to power up the sensor.
|
||||
|
||||
regs->CR2 |= ADC_CR2_TSEREFE;
|
||||
regs->CR2 |= ADC_CR2_TSVREFE;
|
||||
|
||||
// 2. Select a sample time of 17.1 μs
|
||||
// set channel 16 sample time to 239.5 cycles
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
Controlling a servo position using a potentiometer (variable resistor)
|
||||
by Michal Rinott <http://people.interaction-ivrea.it/m.rinott>
|
||||
|
||||
modified on 8 Nov 2013
|
||||
by Scott Fitzgerald
|
||||
http://www.arduino.cc/en/Tutorial/Knob
|
||||
*/
|
||||
|
||||
#include <Servo.h>
|
||||
|
||||
Servo myservo; // create servo object to control a servo
|
||||
|
||||
int potpin = 0; // analog pin used to connect the potentiometer
|
||||
int val; // variable to read the value from the analog pin
|
||||
|
||||
void setup() {
|
||||
myservo.attach(9); // attaches the servo on pin 9 to the servo object
|
||||
}
|
||||
|
||||
void loop() {
|
||||
val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
|
||||
val = map(val, 0, 1023, 0, 180); // scale it to use it with the servo (value between 0 and 180)
|
||||
myservo.write(val); // sets the servo position according to the scaled value
|
||||
delay(15); // waits for the servo to get there
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
/* Sweep
|
||||
by BARRAGAN <http://barraganstudio.com>
|
||||
This example code is in the public domain.
|
||||
|
||||
modified 8 Nov 2013
|
||||
by Scott Fitzgerald
|
||||
http://www.arduino.cc/en/Tutorial/Sweep
|
||||
*/
|
||||
|
||||
#include <Servo.h>
|
||||
|
||||
Servo myservo; // create servo object to control a servo
|
||||
// twelve servo objects can be created on most boards
|
||||
|
||||
int pos = 0; // variable to store the servo position
|
||||
|
||||
void setup() {
|
||||
myservo.attach(9); // attaches the servo on pin 9 to the servo object
|
||||
}
|
||||
|
||||
void loop() {
|
||||
for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
|
||||
// in steps of 1 degree
|
||||
myservo.write(pos); // tell servo to go to position in variable 'pos'
|
||||
delay(15); // waits 15ms for the servo to reach the position
|
||||
}
|
||||
for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
|
||||
myservo.write(pos); // tell servo to go to position in variable 'pos'
|
||||
delay(15); // waits 15ms for the servo to reach the position
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
#######################################
|
||||
# Syntax Coloring Map Servo
|
||||
#######################################
|
||||
|
||||
#######################################
|
||||
# Datatypes (KEYWORD1)
|
||||
#######################################
|
||||
|
||||
Servo KEYWORD1 Servo
|
||||
|
||||
#######################################
|
||||
# Methods and Functions (KEYWORD2)
|
||||
#######################################
|
||||
attach KEYWORD2
|
||||
detach KEYWORD2
|
||||
write KEYWORD2
|
||||
read KEYWORD2
|
||||
attached KEYWORD2
|
||||
writeMicroseconds KEYWORD2
|
||||
readMicroseconds KEYWORD2
|
||||
|
||||
#######################################
|
||||
# Constants (LITERAL1)
|
||||
#######################################
|
|
@ -0,0 +1,9 @@
|
|||
name=Servo(STM32F1)
|
||||
version=1.1.2
|
||||
author=Unknown (possibly LeafLabs)
|
||||
maintainer=Roger Clark (roger@rogerclark.net)
|
||||
sentence=Allows STM32 boards to control a variety of servo motors.
|
||||
paragraph=
|
||||
category=Device Control
|
||||
url=http://www.arduino.cc/en/Reference/Servo
|
||||
architectures=STM32F1
|
|
@ -1,29 +0,0 @@
|
|||
# Standard things
|
||||
sp := $(sp).x
|
||||
dirstack_$(sp) := $(d)
|
||||
d := $(dir)
|
||||
BUILDDIRS += $(BUILD_PATH)/$(d)
|
||||
|
||||
# Local flags
|
||||
CXXFLAGS_$(d) := $(WIRISH_INCLUDES) $(LIBMAPLE_INCLUDES)
|
||||
|
||||
# Local rules and targets
|
||||
cSRCS_$(d) :=
|
||||
|
||||
cppSRCS_$(d) := Servo.cpp
|
||||
|
||||
cFILES_$(d) := $(cSRCS_$(d):%=$(d)/%)
|
||||
cppFILES_$(d) := $(cppSRCS_$(d):%=$(d)/%)
|
||||
|
||||
OBJS_$(d) := $(cFILES_$(d):%.c=$(BUILD_PATH)/%.o) \
|
||||
$(cppFILES_$(d):%.cpp=$(BUILD_PATH)/%.o)
|
||||
DEPS_$(d) := $(OBJS_$(d):%.o=%.d)
|
||||
|
||||
$(OBJS_$(d)): TGT_CXXFLAGS := $(CXXFLAGS_$(d))
|
||||
|
||||
TGT_BIN += $(OBJS_$(d))
|
||||
|
||||
# Standard things
|
||||
-include $(DEPS_$(d))
|
||||
d := $(dirstack_$(sp))
|
||||
sp := $(basename $(sp))
|
|
@ -0,0 +1,161 @@
|
|||
/******************************************************************************
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright (c) 2011 LeafLabs, LLC.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use, copy,
|
||||
* modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
* of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*****************************************************************************/
|
||||
|
||||
/**
|
||||
* @file wirish/boards/maple_mini/board.cpp
|
||||
* @author Marti Bolivar <mbolivar@leaflabs.com>
|
||||
* @brief Maple Mini board file.
|
||||
*/
|
||||
|
||||
#include <board/board.h>
|
||||
|
||||
#include <libmaple/gpio.h>
|
||||
#include <libmaple/timer.h>
|
||||
|
||||
/* Roger Clark. Added next to includes for changes to Serial */
|
||||
#include <libmaple/usart.h>
|
||||
#include <HardwareSerial.h>
|
||||
|
||||
#include <wirish_debug.h>
|
||||
#include <wirish_types.h>
|
||||
|
||||
/* Since we want the Serial Wire/JTAG pins as GPIOs, disable both SW
|
||||
* and JTAG debug support, unless configured otherwise. */
|
||||
void boardInit(void) {
|
||||
#ifndef CONFIG_MAPLE_MINI_NO_DISABLE_DEBUG
|
||||
disableDebugPorts();
|
||||
#endif
|
||||
}
|
||||
|
||||
// Note. See the enum of pin names in board.h
|
||||
|
||||
extern const stm32_pin_info PIN_MAP[BOARD_NR_GPIO_PINS] = {
|
||||
|
||||
|
||||
{&gpioa, &timer2, &adc1, 0, 1, 0}, /* PA0 */
|
||||
{&gpioa, &timer2, &adc1, 1, 2, 1}, /* PA1 */
|
||||
{&gpioa, &timer2, &adc1, 2, 3, 2}, /* PA2 */
|
||||
{&gpioa, &timer2, &adc1, 3, 4, 3}, /* PA3 */
|
||||
{&gpioa, NULL, &adc1, 4, 0, 4}, /* PA4 */
|
||||
{&gpioa, NULL, &adc1, 5, 0, 5}, /* PA5 */
|
||||
{&gpioa, &timer3, &adc1, 6, 1, 6}, /* PA6 */
|
||||
{&gpioa, &timer3, &adc1, 7, 2, 7}, /* PA7 */
|
||||
{&gpioa, &timer1, NULL, 8, 1, ADCx}, /* PA8 */
|
||||
{&gpioa, &timer1, NULL, 9, 2, ADCx}, /* PA9 */
|
||||
{&gpioa, &timer1, NULL, 10, 3, ADCx}, /* PA10 */
|
||||
{&gpioa, NULL, NULL, 11, 0, ADCx}, /* PA11 */
|
||||
{&gpioa, NULL, NULL, 12, 0, ADCx}, /* PA12 */
|
||||
{&gpioa, NULL, NULL, 13, 0, ADCx}, /* PA13 */
|
||||
{&gpioa, NULL, NULL, 14, 0, ADCx}, /* PA14 */
|
||||
{&gpioa, NULL, NULL, 15, 0, ADCx}, /* PA15 */
|
||||
|
||||
{&gpiob, &timer3, &adc1, 0, 3, 8}, /* PB0 */
|
||||
{&gpiob, &timer3, &adc1, 1, 4, 9}, /* PB1 */
|
||||
{&gpiob, NULL, NULL, 2, 0, ADCx}, /* PB2 */
|
||||
{&gpiob, NULL, NULL, 3, 0, ADCx}, /* PB3 */
|
||||
{&gpiob, NULL, NULL, 4, 0, ADCx}, /* PB4 */
|
||||
{&gpiob, NULL, NULL, 5, 0, ADCx}, /* PB5 */
|
||||
{&gpiob, &timer4, NULL, 6, 1, ADCx}, /* PB6 */
|
||||
{&gpiob, &timer4, NULL, 7, 2, ADCx}, /* PB7 */
|
||||
{&gpiob, &timer4, NULL, 8, 3, ADCx}, /* PB8 */
|
||||
{&gpiob, &timer4, NULL, 9, 4, ADCx}, /* PB9 */
|
||||
{&gpiob, NULL, NULL, 10, 0, ADCx}, /* PB10 */
|
||||
{&gpiob, NULL, NULL, 11, 0, ADCx}, /* PB11 */
|
||||
{&gpiob, NULL, NULL, 12, 0, ADCx}, /* PB12 */
|
||||
{&gpiob, NULL, NULL, 13, 0, ADCx}, /* PB13 */
|
||||
{&gpiob, NULL, NULL, 14, 0, ADCx}, /* PB14 */
|
||||
{&gpiob, NULL, NULL, 15, 0, ADCx}, /* PB15 */
|
||||
|
||||
/* Andy Hull - the R8 is similar to the C8 but exposes more GPIO as follows */
|
||||
{&gpioc, NULL, &adc1, 0, 0, 10}, /* PC0 */
|
||||
{&gpioc, NULL, &adc1, 1, 0, 11}, /* PC1 */
|
||||
{&gpioc, NULL, &adc1, 2, 0, 12}, /* PC2 */
|
||||
{&gpioc, NULL, &adc1, 3, 0, 13}, /* PC3 */
|
||||
{&gpioc, NULL, &adc1, 4, 0, 14}, /* PC4 */
|
||||
{&gpioc, NULL, &adc1, 5, 0, 15}, /* PC5 */
|
||||
|
||||
{&gpioc, NULL, NULL, 6, 0, ADCx}, /* PC6 */
|
||||
{&gpioc, NULL, NULL, 7, 0, ADCx}, /* PC7 */
|
||||
{&gpioc, NULL, NULL, 8, 0, ADCx}, /* PC8 */
|
||||
{&gpioc, NULL, NULL, 9, 0, ADCx}, /* PC9 */
|
||||
|
||||
{&gpioc, NULL, NULL, 10, 0, ADCx}, /* PC10 */
|
||||
{&gpioc, NULL, NULL, 11, 0, ADCx}, /* PC11 */
|
||||
{&gpioc, NULL, NULL, 12, 0, ADCx}, /* PC12 */
|
||||
{&gpioc, NULL, NULL, 13, 0, ADCx}, /* PC13 */
|
||||
{&gpioc, NULL, NULL, 14, 0, ADCx}, /* PC14 */
|
||||
{&gpioc, NULL, NULL, 15, 0, ADCx}, /* PC15 */
|
||||
|
||||
{&gpiod, NULL, NULL, 0, 0, ADCx}, /* PD2 */
|
||||
{&gpiod, NULL, NULL, 1, 0, ADCx}, /* PD2 */
|
||||
{&gpiod, NULL, NULL, 2, 0, ADCx}, /* PD2 */
|
||||
};
|
||||
|
||||
extern const uint8 boardPWMPins[BOARD_NR_PWM_PINS] __FLASH__ = {
|
||||
PA0, PA1, PA2, PA3, PA6, PA7, PA8, PA9, PA10, PB0, PB1, PB6, PB7, PB8, PB9
|
||||
};
|
||||
|
||||
extern const uint8 boardADCPins[BOARD_NR_ADC_PINS] __FLASH__ = {
|
||||
PA0, PA1, PA2 , PA3 , PA4 , PA5 , PA6 , PA7 , PB0 , PB1, PC0, PC1, PC2, PC3, PC4, PC5
|
||||
};
|
||||
|
||||
// Note. These defines are not really used by generic boards. They are for Maple Serial USB
|
||||
//#define USB_DP PA12
|
||||
//#define USB_DM PA11
|
||||
|
||||
// NOte. These definitions are not really used for generic boards, they only relate to boards modified to behave like Maple boards
|
||||
extern const uint8 boardUsedPins[BOARD_NR_USED_PINS] __FLASH__ = {
|
||||
BOARD_LED_PIN, BOARD_BUTTON_PIN, BOARD_JTMS_SWDIO_PIN,
|
||||
BOARD_JTCK_SWCLK_PIN, BOARD_JTDI_PIN, BOARD_JTDO_PIN, BOARD_NJTRST_PIN
|
||||
//USB_DP, USB_DM
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Roger Clark
|
||||
*
|
||||
* 2015/05/28
|
||||
*
|
||||
* Moved definitions for Hardware Serial devices from HardwareSerial.cpp so that each board can define which Arduino "Serial" instance
|
||||
* Maps to which hardware serial port on the microprocessor
|
||||
*/
|
||||
|
||||
#ifdef SERIAL_USB
|
||||
DEFINE_HWSERIAL(Serial1, 1);
|
||||
|
||||
DEFINE_HWSERIAL(Serial2, 2);
|
||||
|
||||
DEFINE_HWSERIAL(Serial3, 3);
|
||||
|
||||
#else
|
||||
DEFINE_HWSERIAL(Serial, 1);
|
||||
|
||||
DEFINE_HWSERIAL(Serial1, 2);
|
||||
|
||||
DEFINE_HWSERIAL(Serial2, 3);
|
||||
|
||||
|
||||
#endif
|
|
@ -0,0 +1,92 @@
|
|||
/******************************************************************************
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright (c) 2011 LeafLabs, LLC.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use, copy,
|
||||
* modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
* of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*****************************************************************************/
|
||||
|
||||
/**
|
||||
* @file wirish/boards/maple_mini/include/board/board.h
|
||||
* @author Marti Bolivar <mbolivar@leaflabs.com>
|
||||
* @brief Maple Mini board header.
|
||||
*
|
||||
* See wirish/boards/maple/include/board/board.h for more information
|
||||
* on these definitions.
|
||||
*/
|
||||
|
||||
#ifndef _BOARD_STM32VLD_H_
|
||||
#define _BOARD_STM32VLD_H_
|
||||
|
||||
|
||||
|
||||
#define CYCLES_PER_MICROSECOND 24
|
||||
//#define SYSTICK_RELOAD_VAL (F_CPU/1000) - 1 /* takes a cycle to reload */
|
||||
#define SYSTICK_RELOAD_VAL 23999 /* takes a cycle to reload */
|
||||
|
||||
#define BOARD_LED_PIN PC8 /* BlueLED(PC8) */
|
||||
#define BOARD_BUTTON_PIN PA0 /* USR SW(PA0) */
|
||||
|
||||
#define LED_G PC9
|
||||
#define LED_B PC8
|
||||
|
||||
#define BOARD_NR_USARTS 3
|
||||
#define BOARD_USART1_TX_PIN PA9
|
||||
#define BOARD_USART1_RX_PIN PA10
|
||||
#define BOARD_USART2_TX_PIN PA2
|
||||
#define BOARD_USART2_RX_PIN PA3
|
||||
#define BOARD_USART3_TX_PIN PB10
|
||||
#define BOARD_USART3_RX_PIN PB11
|
||||
|
||||
#define BOARD_NR_SPI 2
|
||||
#define BOARD_SPI1_NSS_PIN PA4
|
||||
#define BOARD_SPI1_MOSI_PIN PA7
|
||||
#define BOARD_SPI1_MISO_PIN PA6
|
||||
#define BOARD_SPI1_SCK_PIN PA5
|
||||
#define BOARD_SPI2_NSS_PIN PB12
|
||||
#define BOARD_SPI2_MOSI_PIN PB15
|
||||
#define BOARD_SPI2_MISO_PIN PB14
|
||||
#define BOARD_SPI2_SCK_PIN PB13
|
||||
|
||||
#define BOARD_NR_GPIO_PINS 51
|
||||
#define BOARD_NR_PWM_PINS 15
|
||||
#define BOARD_NR_ADC_PINS 16
|
||||
#define BOARD_NR_USED_PINS 7
|
||||
|
||||
#define BOARD_JTMS_SWDIO_PIN PA13
|
||||
#define BOARD_JTCK_SWCLK_PIN PA14
|
||||
#define BOARD_JTDI_PIN PA15
|
||||
#define BOARD_JTDO_PIN PB3
|
||||
#define BOARD_NJTRST_PIN PB4
|
||||
|
||||
|
||||
#define BOARD_USB_DISC_DEV GPIOB
|
||||
#define BOARD_USB_DISC_BIT 10
|
||||
|
||||
// Note this needs to match with the PIN_MAP array in board.cpp
|
||||
enum {
|
||||
PA0, PA1, PA2, PA3, PA4, PA5, PA6, PA7, PA8, PA9, PA10, PA11, PA12, PA13, PA14, PA15,
|
||||
PB0, PB1, PB2, PB3, PB4, PB5, PB6, PB7, PB8, PB9, PB10, PB11, PB12, PB13, PB14, PB15,
|
||||
PC0, PC1, PC2, PC3, PC4, PC5, PC6, PC7, PC8, PC9, PC10, PC11, PC12, PC13, PC14, PC15,
|
||||
PD0, PD1, PD2
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,220 @@
|
|||
/*
|
||||
* Linker script for libmaple.
|
||||
*
|
||||
* Original author "lanchon" from ST forums, with modifications by LeafLabs.
|
||||
*/
|
||||
|
||||
OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
|
||||
|
||||
/*
|
||||
* Configure other libraries we want in the link.
|
||||
*
|
||||
* libgcc, libc, and libm are common across supported toolchains.
|
||||
* However, some toolchains require additional archives which aren't
|
||||
* present everywhere (e.g. ARM's gcc-arm-embedded releases).
|
||||
*
|
||||
* To hack around this, we let the build system specify additional
|
||||
* archives by putting the right extra_libs.inc (in a directory under
|
||||
* toolchains/) in our search path.
|
||||
*/
|
||||
GROUP(libgcc.a libc.a libm.a)
|
||||
INCLUDE extra_libs.inc
|
||||
|
||||
/*
|
||||
* These force the linker to search for vector table symbols.
|
||||
*
|
||||
* These symbols vary by STM32 family (and also within families).
|
||||
* It's up to the build system to configure the link's search path
|
||||
* properly for the target MCU.
|
||||
*/
|
||||
INCLUDE vector_symbols.inc
|
||||
|
||||
/* STM32 vector table. */
|
||||
EXTERN(__stm32_vector_table)
|
||||
|
||||
/* C runtime initialization function. */
|
||||
EXTERN(start_c)
|
||||
|
||||
/* main entry point */
|
||||
EXTERN(main)
|
||||
|
||||
/* Initial stack pointer value. */
|
||||
EXTERN(__msp_init)
|
||||
PROVIDE(__msp_init = ORIGIN(ram) + LENGTH(ram));
|
||||
|
||||
/* Reset vector and chip reset entry point */
|
||||
EXTERN(__start__)
|
||||
ENTRY(__start__)
|
||||
PROVIDE(__exc_reset = __start__);
|
||||
|
||||
/* Heap boundaries, for libmaple */
|
||||
EXTERN(_lm_heap_start);
|
||||
EXTERN(_lm_heap_end);
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.text :
|
||||
{
|
||||
__text_start__ = .;
|
||||
/*
|
||||
* STM32 vector table. Leave this here. Yes, really.
|
||||
*/
|
||||
*(.stm32.interrupt_vector)
|
||||
|
||||
/*
|
||||
* Program code and vague linking
|
||||
*/
|
||||
*(.text .text.* .gnu.linkonce.t.*)
|
||||
*(.plt)
|
||||
*(.gnu.warning)
|
||||
*(.glue_7t) *(.glue_7) *(.vfp11_veneer)
|
||||
|
||||
*(.ARM.extab* .gnu.linkonce.armextab.*)
|
||||
*(.gcc_except_table)
|
||||
*(.eh_frame_hdr)
|
||||
*(.eh_frame)
|
||||
|
||||
. = ALIGN(4);
|
||||
KEEP(*(.init))
|
||||
|
||||
. = ALIGN(4);
|
||||
__preinit_array_start = .;
|
||||
KEEP (*(.preinit_array))
|
||||
__preinit_array_end = .;
|
||||
|
||||
. = ALIGN(4);
|
||||
__init_array_start = .;
|
||||
KEEP (*(SORT(.init_array.*)))
|
||||
KEEP (*(.init_array))
|
||||
__init_array_end = .;
|
||||
|
||||
. = ALIGN(0x4);
|
||||
KEEP (*crtbegin.o(.ctors))
|
||||
KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
|
||||
KEEP (*(SORT(.ctors.*)))
|
||||
KEEP (*crtend.o(.ctors))
|
||||
|
||||
. = ALIGN(4);
|
||||
KEEP(*(.fini))
|
||||
|
||||
. = ALIGN(4);
|
||||
__fini_array_start = .;
|
||||
KEEP (*(.fini_array))
|
||||
KEEP (*(SORT(.fini_array.*)))
|
||||
__fini_array_end = .;
|
||||
|
||||
KEEP (*crtbegin.o(.dtors))
|
||||
KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
|
||||
KEEP (*(SORT(.dtors.*)))
|
||||
KEEP (*crtend.o(.dtors))
|
||||
} > REGION_TEXT
|
||||
|
||||
/*
|
||||
* End of text
|
||||
*/
|
||||
.text.align :
|
||||
{
|
||||
. = ALIGN(8);
|
||||
__text_end__ = .;
|
||||
} > REGION_TEXT
|
||||
|
||||
/*
|
||||
* .ARM.exidx exception unwinding; mandated by ARM's C++ ABI
|
||||
*/
|
||||
__exidx_start = .;
|
||||
.ARM.exidx :
|
||||
{
|
||||
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
|
||||
} > REGION_RODATA
|
||||
__exidx_end = .;
|
||||
|
||||
/*
|
||||
* .data
|
||||
*/
|
||||
.data :
|
||||
{
|
||||
__data_start__ = .;
|
||||
LONG(0)
|
||||
. = ALIGN(8);
|
||||
|
||||
*(.got.plt) *(.got)
|
||||
*(.data .data.* .gnu.linkonce.d.*)
|
||||
|
||||
. = ALIGN(8);
|
||||
__data_end__ = .;
|
||||
} > REGION_DATA AT> REGION_RODATA
|
||||
|
||||
/*
|
||||
* Read-only data
|
||||
*/
|
||||
.rodata :
|
||||
{
|
||||
*(.rodata .rodata.* .gnu.linkonce.r.*)
|
||||
/* .USER_FLASH: We allow users to allocate into Flash here */
|
||||
*(.USER_FLASH)
|
||||
/* ROM image configuration; for C startup */
|
||||
. = ALIGN(4);
|
||||
_lm_rom_img_cfgp = .;
|
||||
LONG(LOADADDR(.data));
|
||||
/*
|
||||
* Heap: Linker scripts may choose a custom heap by overriding
|
||||
* _lm_heap_start and _lm_heap_end. Otherwise, the heap is in
|
||||
* internal SRAM, beginning after .bss, and growing towards
|
||||
* the stack.
|
||||
*
|
||||
* I'm shoving these here naively; there's probably a cleaner way
|
||||
* to go about this. [mbolivar]
|
||||
*/
|
||||
_lm_heap_start = DEFINED(_lm_heap_start) ? _lm_heap_start : _end;
|
||||
_lm_heap_end = DEFINED(_lm_heap_end) ? _lm_heap_end : __msp_init;
|
||||
} > REGION_RODATA
|
||||
|
||||
/*
|
||||
* .bss
|
||||
*/
|
||||
.bss :
|
||||
{
|
||||
. = ALIGN(8);
|
||||
__bss_start__ = .;
|
||||
*(.bss .bss.* .gnu.linkonce.b.*)
|
||||
*(COMMON)
|
||||
. = ALIGN (8);
|
||||
__bss_end__ = .;
|
||||
_end = __bss_end__;
|
||||
} > REGION_BSS
|
||||
|
||||
/*
|
||||
* Debugging sections
|
||||
*/
|
||||
.stab 0 (NOLOAD) : { *(.stab) }
|
||||
.stabstr 0 (NOLOAD) : { *(.stabstr) }
|
||||
/* DWARF debug sections.
|
||||
* Symbols in the DWARF debugging sections are relative to the beginning
|
||||
* of the section so we begin them at 0. */
|
||||
/* DWARF 1 */
|
||||
.debug 0 : { *(.debug) }
|
||||
.line 0 : { *(.line) }
|
||||
/* GNU DWARF 1 extensions */
|
||||
.debug_srcinfo 0 : { *(.debug_srcinfo) }
|
||||
.debug_sfnames 0 : { *(.debug_sfnames) }
|
||||
/* DWARF 1.1 and DWARF 2 */
|
||||
.debug_aranges 0 : { *(.debug_aranges) }
|
||||
.debug_pubnames 0 : { *(.debug_pubnames) }
|
||||
/* DWARF 2 */
|
||||
.debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
|
||||
.debug_abbrev 0 : { *(.debug_abbrev) }
|
||||
.debug_line 0 : { *(.debug_line) }
|
||||
.debug_frame 0 : { *(.debug_frame) }
|
||||
.debug_str 0 : { *(.debug_str) }
|
||||
.debug_loc 0 : { *(.debug_loc) }
|
||||
.debug_macinfo 0 : { *(.debug_macinfo) }
|
||||
/* SGI/MIPS DWARF 2 extensions */
|
||||
.debug_weaknames 0 : { *(.debug_weaknames) }
|
||||
.debug_funcnames 0 : { *(.debug_funcnames) }
|
||||
.debug_typenames 0 : { *(.debug_typenames) }
|
||||
.debug_varnames 0 : { *(.debug_varnames) }
|
||||
|
||||
.note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) }
|
||||
.ARM.attributes 0 : { KEEP (*(.ARM.attributes)) }
|
||||
/DISCARD/ : { *(.note.GNU-stack) }
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
/*
|
||||
* Extra archives needed by ARM's GCC ARM Embedded arm-none-eabi-
|
||||
* releases (https://launchpad.net/gcc-arm-embedded/).
|
||||
*/
|
||||
|
||||
/* This is for the provided newlib. */
|
||||
GROUP(libnosys.a)
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* This file is part of the libopencm3 project.
|
||||
*
|
||||
* Copyright (C) 2009 Uwe Hermann <uwe@hermann-uwe.de>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* Linker script for STM32F100RB */
|
||||
|
||||
/* Define memory regions. */
|
||||
MEMORY
|
||||
{
|
||||
rom (rx) : ORIGIN = 0x08000000, LENGTH = 128K
|
||||
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 8K
|
||||
}
|
||||
|
||||
REGION_ALIAS("REGION_TEXT", rom);
|
||||
REGION_ALIAS("REGION_DATA", ram);
|
||||
REGION_ALIAS("REGION_BSS", ram);
|
||||
REGION_ALIAS("REGION_RODATA", rom);
|
||||
|
||||
|
||||
INCLUDE common.inc
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
EXTERN(__msp_init)
|
||||
EXTERN(__exc_reset)
|
||||
EXTERN(__exc_nmi)
|
||||
EXTERN(__exc_hardfault)
|
||||
EXTERN(__exc_memmanage)
|
||||
EXTERN(__exc_busfault)
|
||||
EXTERN(__exc_usagefault)
|
||||
EXTERN(__stm32reservedexception7)
|
||||
EXTERN(__stm32reservedexception8)
|
||||
EXTERN(__stm32reservedexception9)
|
||||
EXTERN(__stm32reservedexception10)
|
||||
EXTERN(__exc_svc)
|
||||
EXTERN(__exc_debug_monitor)
|
||||
EXTERN(__stm32reservedexception13)
|
||||
EXTERN(__exc_pendsv)
|
||||
EXTERN(__exc_systick)
|
||||
|
||||
EXTERN(__irq_wwdg)
|
||||
EXTERN(__irq_pvd)
|
||||
EXTERN(__irq_tamper)
|
||||
EXTERN(__irq_rtc)
|
||||
EXTERN(__irq_flash)
|
||||
EXTERN(__irq_rcc)
|
||||
EXTERN(__irq_exti0)
|
||||
EXTERN(__irq_exti1)
|
||||
EXTERN(__irq_exti2)
|
||||
EXTERN(__irq_exti3)
|
||||
EXTERN(__irq_exti4)
|
||||
EXTERN(__irq_dma1_channel1)
|
||||
EXTERN(__irq_dma1_channel2)
|
||||
EXTERN(__irq_dma1_channel3)
|
||||
EXTERN(__irq_dma1_channel4)
|
||||
EXTERN(__irq_dma1_channel5)
|
||||
EXTERN(__irq_dma1_channel6)
|
||||
EXTERN(__irq_dma1_channel7)
|
||||
EXTERN(__irq_adc)
|
||||
EXTERN(__irq_usb_hp_can_tx)
|
||||
EXTERN(__irq_usb_lp_can_rx0)
|
||||
EXTERN(__irq_can_rx1)
|
||||
EXTERN(__irq_can_sce)
|
||||
EXTERN(__irq_exti9_5)
|
||||
EXTERN(__irq_tim1_brk)
|
||||
EXTERN(__irq_tim1_up)
|
||||
EXTERN(__irq_tim1_trg_com)
|
||||
EXTERN(__irq_tim1_cc)
|
||||
EXTERN(__irq_tim2)
|
||||
EXTERN(__irq_tim3)
|
||||
EXTERN(__irq_tim4)
|
||||
EXTERN(__irq_i2c1_ev)
|
||||
EXTERN(__irq_i2c1_er)
|
||||
EXTERN(__irq_i2c2_ev)
|
||||
EXTERN(__irq_i2c2_er)
|
||||
EXTERN(__irq_spi1)
|
||||
EXTERN(__irq_spi2)
|
||||
EXTERN(__irq_usart1)
|
||||
EXTERN(__irq_usart2)
|
||||
EXTERN(__irq_usart3)
|
||||
EXTERN(__irq_exti15_10)
|
||||
EXTERN(__irq_rtcalarm)
|
||||
EXTERN(__irq_usbwakeup)
|
||||
|
||||
EXTERN(__irq_tim8_brk)
|
||||
EXTERN(__irq_tim8_up)
|
||||
EXTERN(__irq_tim8_trg_com)
|
||||
EXTERN(__irq_tim8_cc)
|
||||
EXTERN(__irq_adc3)
|
||||
EXTERN(__irq_fsmc)
|
||||
EXTERN(__irq_sdio)
|
||||
EXTERN(__irq_tim5)
|
||||
EXTERN(__irq_spi3)
|
||||
EXTERN(__irq_uart4)
|
||||
EXTERN(__irq_uart5)
|
||||
EXTERN(__irq_tim6)
|
||||
EXTERN(__irq_tim7)
|
||||
EXTERN(__irq_dma2_channel1)
|
||||
EXTERN(__irq_dma2_channel2)
|
||||
EXTERN(__irq_dma2_channel3)
|
||||
EXTERN(__irq_dma2_channel4_5)
|
|
@ -0,0 +1,6 @@
|
|||
|
||||
|
||||
|
||||
|
||||
// API compatibility
|
||||
#include "variant.h"
|
|
@ -0,0 +1,20 @@
|
|||
#ifndef _VARIANT_ARDUINO_STM32_
|
||||
#define _VARIANT_ARDUINO_STM32_
|
||||
|
||||
#define digitalPinToPort(P) ( PIN_MAP[P].gpio_device )
|
||||
#define digitalPinToBitMask(P) ( BIT(PIN_MAP[P].gpio_bit) )
|
||||
#define portOutputRegister(port) ( &(port->regs->ODR) )
|
||||
#define portInputRegister(port) ( &(port->regs->IDR) )
|
||||
|
||||
#define portSetRegister(pin) ( &(PIN_MAP[pin].gpio_device->regs->BSRR) )
|
||||
#define portClearRegister(pin) ( &(PIN_MAP[pin].gpio_device->regs->BRR) )
|
||||
|
||||
#define portConfigRegister(pin) ( &(PIN_MAP[pin].gpio_device->regs->CRL) )
|
||||
|
||||
static const uint8_t SS = BOARD_SPI1_NSS_PIN;
|
||||
static const uint8_t SS1 = BOARD_SPI2_NSS_PIN;
|
||||
static const uint8_t MOSI = BOARD_SPI1_MOSI_PIN;
|
||||
static const uint8_t MISO = BOARD_SPI1_MISO_PIN;
|
||||
static const uint8_t SCK = BOARD_SPI1_SCK_PIN;
|
||||
|
||||
#endif /* _VARIANT_ARDUINO_STM32_ */
|
|
@ -0,0 +1,229 @@
|
|||
/******************************************************************************
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright (c) 2010 Perry Hung.
|
||||
* Copyright (c) 2011, 2012 LeafLabs, LLC.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use, copy,
|
||||
* modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
* of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*****************************************************************************/
|
||||
|
||||
/**
|
||||
* @file wirish/boards.cpp
|
||||
* @brief init() and board routines.
|
||||
*
|
||||
* This file is mostly interesting for the init() function, which
|
||||
* configures Flash, the core clocks, and a variety of other available
|
||||
* peripherals on the board so the rest of Wirish doesn't have to turn
|
||||
* things on before using them.
|
||||
*
|
||||
* Prior to returning, init() calls boardInit(), which allows boards
|
||||
* to perform any initialization they need to. This file includes a
|
||||
* weak no-op definition of boardInit(), so boards that don't need any
|
||||
* special initialization don't have to define their own.
|
||||
*
|
||||
* How init() works is chip-specific. See the boards_setup.cpp files
|
||||
* under e.g. wirish/stm32f1/, wirish/stmf32f2 for the details, but be
|
||||
* advised: their contents are unstable, and can/will change without
|
||||
* notice.
|
||||
*/
|
||||
|
||||
#include <boards.h>
|
||||
#include <libmaple/libmaple_types.h>
|
||||
#include <libmaple/flash.h>
|
||||
#include <libmaple/nvic.h>
|
||||
#include <libmaple/systick.h>
|
||||
#include "boards_private.h"
|
||||
|
||||
static void setup_flash(void);
|
||||
static void setup_clocks(void);
|
||||
static void setup_nvic(void);
|
||||
static void setup_adcs(void);
|
||||
static void setup_timers(void);
|
||||
|
||||
/*
|
||||
* Exported functions
|
||||
*/
|
||||
|
||||
void init(void) {
|
||||
setup_flash();
|
||||
setup_clocks();
|
||||
setup_nvic();
|
||||
systick_init(SYSTICK_RELOAD_VAL);
|
||||
wirish::priv::board_setup_gpio();
|
||||
setup_adcs();
|
||||
setup_timers();
|
||||
wirish::priv::board_setup_usb();
|
||||
wirish::priv::series_init();
|
||||
boardInit();
|
||||
}
|
||||
|
||||
/* Provide a default no-op boardInit(). */
|
||||
__weak void boardInit(void) {
|
||||
}
|
||||
|
||||
/* You could farm this out to the files in boards/ if e.g. it takes
|
||||
* too long to test on boards with lots of pins. */
|
||||
bool boardUsesPin(uint8 pin) {
|
||||
for (int i = 0; i < BOARD_NR_USED_PINS; i++) {
|
||||
if (pin == boardUsedPins[i]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Auxiliary routines
|
||||
*/
|
||||
|
||||
static void setup_flash(void) {
|
||||
// Turn on as many Flash "go faster" features as
|
||||
// possible. flash_enable_features() just ignores any flags it
|
||||
// can't support.
|
||||
flash_enable_features(FLASH_PREFETCH | FLASH_ICACHE | FLASH_DCACHE);
|
||||
// Configure the wait states, assuming we're operating at "close
|
||||
// enough" to 3.3V.
|
||||
flash_set_latency(FLASH_SAFE_WAIT_STATES);
|
||||
}
|
||||
|
||||
static void setup_clocks(void) {
|
||||
// Turn on HSI. We'll switch to and run off of this while we're
|
||||
// setting up the main PLL.
|
||||
rcc_turn_on_clk(RCC_CLK_HSI);
|
||||
|
||||
// Turn off and reset the clock subsystems we'll be using, as well
|
||||
// as the clock security subsystem (CSS). Note that resetting CFGR
|
||||
// to its default value of 0 implies a switch to HSI for SYSCLK.
|
||||
RCC_BASE->CFGR = 0x00000000;
|
||||
rcc_disable_css();
|
||||
rcc_turn_off_clk(RCC_CLK_PLL);
|
||||
rcc_turn_off_clk(RCC_CLK_HSE);
|
||||
wirish::priv::board_reset_pll();
|
||||
// Clear clock readiness interrupt flags and turn off clock
|
||||
// readiness interrupts.
|
||||
RCC_BASE->CIR = 0x00000000;
|
||||
|
||||
// Enable HSE, and wait until it's ready.
|
||||
rcc_turn_on_clk(RCC_CLK_HSE);
|
||||
while (!rcc_is_clk_ready(RCC_CLK_HSE))
|
||||
;
|
||||
|
||||
// Configure AHBx, APBx, etc. prescalers and the main PLL.
|
||||
wirish::priv::board_setup_clock_prescalers();
|
||||
rcc_configure_pll(&wirish::priv::w_board_pll_cfg);
|
||||
|
||||
// Enable the PLL, and wait until it's ready.
|
||||
rcc_turn_on_clk(RCC_CLK_PLL);
|
||||
while(!rcc_is_clk_ready(RCC_CLK_PLL))
|
||||
;
|
||||
|
||||
// Finally, switch to the now-ready PLL as the main clock source.
|
||||
rcc_switch_sysclk(RCC_CLKSRC_PLL);
|
||||
}
|
||||
|
||||
/*
|
||||
* These addresses are where usercode starts when a bootloader is
|
||||
* present. If no bootloader is present, the user NVIC usually starts
|
||||
* at the Flash base address, 0x08000000.
|
||||
*/
|
||||
#if defined(BOOTLOADER_maple)
|
||||
#define USER_ADDR_ROM 0x08005000
|
||||
#else
|
||||
#if defined(BOOTLOADER_robotis)
|
||||
#define USER_ADDR_ROM 0x08003000
|
||||
#else
|
||||
#define USER_ADDR_ROM 0x08000000
|
||||
#endif
|
||||
#endif
|
||||
#define USER_ADDR_RAM 0x20000C00
|
||||
extern char __text_start__;
|
||||
|
||||
static void setup_nvic(void) {
|
||||
|
||||
nvic_init((uint32)VECT_TAB_ADDR, 0);
|
||||
|
||||
/* Roger Clark. We now control nvic vector table in boards.txt using the build.vect paramater
|
||||
#ifdef VECT_TAB_FLASH
|
||||
nvic_init(USER_ADDR_ROM, 0);
|
||||
#elif defined VECT_TAB_RAM
|
||||
nvic_init(USER_ADDR_RAM, 0);
|
||||
#elif defined VECT_TAB_BASE
|
||||
nvic_init((uint32)0x08000000, 0);
|
||||
#elif defined VECT_TAB_ADDR
|
||||
// A numerically supplied value
|
||||
nvic_init((uint32)VECT_TAB_ADDR, 0);
|
||||
#else
|
||||
// Use the __text_start__ value from the linker script; this
|
||||
// should be the start of the vector table.
|
||||
nvic_init((uint32)&__text_start__, 0);
|
||||
#endif
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
static void adc_default_config(adc_dev *dev) {
|
||||
adc_enable_single_swstart(dev);
|
||||
adc_set_sample_rate(dev, wirish::priv::w_adc_smp);
|
||||
}
|
||||
|
||||
static void setup_adcs(void) {
|
||||
adc_set_prescaler(wirish::priv::w_adc_pre);
|
||||
adc_foreach(adc_default_config);
|
||||
}
|
||||
|
||||
static void timer_default_config(timer_dev *dev) {
|
||||
timer_adv_reg_map *regs = (dev->regs).adv;
|
||||
const uint16 full_overflow = 0xFFFF;
|
||||
const uint16 half_duty = 0x8FFF;
|
||||
|
||||
timer_init(dev);
|
||||
timer_pause(dev);
|
||||
|
||||
regs->CR1 = TIMER_CR1_ARPE;
|
||||
regs->PSC = 1;
|
||||
regs->SR = 0;
|
||||
regs->DIER = 0;
|
||||
regs->EGR = TIMER_EGR_UG;
|
||||
switch (dev->type) {
|
||||
case TIMER_ADVANCED:
|
||||
regs->BDTR = TIMER_BDTR_MOE | TIMER_BDTR_LOCK_OFF;
|
||||
// fall-through
|
||||
case TIMER_GENERAL:
|
||||
timer_set_reload(dev, full_overflow);
|
||||
for (uint8 channel = 1; channel <= 4; channel++) {
|
||||
if (timer_has_cc_channel(dev, channel)) {
|
||||
timer_set_compare(dev, channel, half_duty);
|
||||
timer_oc_set_mode(dev, channel, TIMER_OC_MODE_PWM_1,
|
||||
TIMER_OC_PE);
|
||||
}
|
||||
}
|
||||
// fall-through
|
||||
case TIMER_BASIC:
|
||||
break;
|
||||
}
|
||||
|
||||
timer_generate_update(dev);
|
||||
timer_resume(dev);
|
||||
}
|
||||
|
||||
static void setup_timers(void) {
|
||||
timer_foreach(timer_default_config);
|
||||
}
|
|
@ -0,0 +1,104 @@
|
|||
/******************************************************************************
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright (c) 2012 LeafLabs, LLC.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use, copy,
|
||||
* modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
* of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*****************************************************************************/
|
||||
|
||||
/**
|
||||
* @file wirish/stm32f1/boards_setup.cpp
|
||||
* @author Marti Bolivar <mbolivar@leaflabs.com>
|
||||
* @brief STM32F1 chip setup.
|
||||
*
|
||||
* This file controls how init() behaves on the STM32F1. Be very
|
||||
* careful when changing anything here. Many of these values depend
|
||||
* upon each other.
|
||||
*/
|
||||
|
||||
#include "boards_private.h"
|
||||
|
||||
#include <libmaple/gpio.h>
|
||||
#include <libmaple/timer.h>
|
||||
|
||||
#include <boards.h>
|
||||
#include <usb_serial.h>
|
||||
|
||||
// Allow boards to provide a PLL multiplier. This is useful for
|
||||
// e.g. STM32F100 value line MCUs, which use slower multipliers.
|
||||
// (We're leaving the default to RCC_PLLMUL_9 for now, since that
|
||||
// works for F103 performance line MCUs, which is all that LeafLabs
|
||||
// currently officially supports).
|
||||
#ifndef BOARD_RCC_PLLMUL
|
||||
#define BOARD_RCC_PLLMUL RCC_PLLMUL_3
|
||||
#endif
|
||||
|
||||
namespace wirish {
|
||||
namespace priv {
|
||||
|
||||
static stm32f1_rcc_pll_data pll_data = {BOARD_RCC_PLLMUL};
|
||||
__weak rcc_pll_cfg w_board_pll_cfg = {RCC_PLLSRC_HSE, &pll_data};
|
||||
__weak adc_prescaler w_adc_pre = ADC_PRE_PCLK2_DIV_6;
|
||||
__weak adc_smp_rate w_adc_smp = ADC_SMPR_55_5;
|
||||
|
||||
__weak void board_reset_pll(void) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
__weak void board_setup_clock_prescalers(void) {
|
||||
rcc_set_prescaler(RCC_PRESCALER_AHB, RCC_AHB_SYSCLK_DIV_1);
|
||||
rcc_set_prescaler(RCC_PRESCALER_APB1, RCC_APB1_HCLK_DIV_2);
|
||||
rcc_set_prescaler(RCC_PRESCALER_APB2, RCC_APB2_HCLK_DIV_1);
|
||||
rcc_clk_disable(RCC_USB);
|
||||
#if F_CPU == 72000000
|
||||
rcc_set_prescaler(RCC_PRESCALER_USB, RCC_USB_SYSCLK_DIV_1_5);
|
||||
#elif F_CPU == 48000000
|
||||
rcc_set_prescaler(RCC_PRESCALER_USB, RCC_USB_SYSCLK_DIV_1_5);
|
||||
#endif
|
||||
}
|
||||
|
||||
__weak void board_setup_gpio(void) {
|
||||
gpio_init_all();
|
||||
}
|
||||
|
||||
__weak void board_setup_usb(void) {
|
||||
#ifdef SERIAL_USB
|
||||
|
||||
#ifdef GENERIC_BOOTLOADER
|
||||
//Reset the USB interface on generic boards - developed by Victor PV
|
||||
gpio_set_mode(PIN_MAP[PA12].gpio_device, PIN_MAP[PA12].gpio_bit, GPIO_OUTPUT_PP);
|
||||
gpio_write_bit(PIN_MAP[PA12].gpio_device, PIN_MAP[PA12].gpio_bit,0);
|
||||
|
||||
for(volatile unsigned int i=0;i<512;i++);// Only small delay seems to be needed, and USB pins will get configured in Serial.begin
|
||||
gpio_set_mode(PIN_MAP[PA12].gpio_device, PIN_MAP[PA12].gpio_bit, GPIO_INPUT_FLOATING);
|
||||
#endif
|
||||
Serial.begin();// Roger Clark. Changed SerialUSB to Serial for Arduino sketch compatibility
|
||||
#endif
|
||||
}
|
||||
|
||||
__weak void series_init(void) {
|
||||
// Initialize AFIO here, too, so peripheral remaps and external
|
||||
// interrupts work out of the box.
|
||||
afio_init();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
/******************************************************************************
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright (c) 2011 LeafLabs, LLC.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use, copy,
|
||||
* modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
* of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*****************************************************************************/
|
||||
|
||||
/*
|
||||
* This file is a modified version of a file obtained from
|
||||
* CodeSourcery Inc. (now part of Mentor Graphics Corp.), in which the
|
||||
* following text appeared:
|
||||
*
|
||||
* The authors hereby grant permission to use, copy, modify, distribute,
|
||||
* and license this software and its documentation for any purpose, provided
|
||||
* that existing copyright notices are retained in all copies and that this
|
||||
* notice is included verbatim in any distributions. No written agreement,
|
||||
* license, or royalty fee is required for any of the authorized uses.
|
||||
* Modifications to this software may be copyrighted by their authors
|
||||
* and need not follow the licensing terms described here, provided that
|
||||
* the new terms are clearly indicated on the first page of each file where
|
||||
* they apply.
|
||||
*/
|
||||
|
||||
.text
|
||||
.code 16
|
||||
.thumb_func
|
||||
|
||||
.globl __start__
|
||||
.type __start__, %function
|
||||
__start__:
|
||||
.fnstart
|
||||
ldr r1,=__msp_init
|
||||
mov sp,r1
|
||||
ldr r1,=start_c
|
||||
bx r1
|
||||
.pool
|
||||
.cantunwind
|
||||
.fnend
|
|
@ -0,0 +1,95 @@
|
|||
/******************************************************************************
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright (c) 2011 LeafLabs, LLC.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use, copy,
|
||||
* modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
* of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*****************************************************************************/
|
||||
|
||||
/*
|
||||
* This file is a modified version of a file obtained from
|
||||
* CodeSourcery Inc. (now part of Mentor Graphics Corp.), in which the
|
||||
* following text appeared:
|
||||
*
|
||||
* Copyright (c) 2006, 2007 CodeSourcery Inc
|
||||
*
|
||||
* The authors hereby grant permission to use, copy, modify, distribute,
|
||||
* and license this software and its documentation for any purpose, provided
|
||||
* that existing copyright notices are retained in all copies and that this
|
||||
* notice is included verbatim in any distributions. No written agreement,
|
||||
* license, or royalty fee is required for any of the authorized uses.
|
||||
* Modifications to this software may be copyrighted by their authors
|
||||
* and need not follow the licensing terms described here, provided that
|
||||
* the new terms are clearly indicated on the first page of each file where
|
||||
* they apply.
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
extern void __libc_init_array(void);
|
||||
|
||||
extern int main(int, char**, char**);
|
||||
|
||||
extern void exit(int) __attribute__((noreturn, weak));
|
||||
|
||||
/* The linker must ensure that these are at least 4-byte aligned. */
|
||||
extern char __data_start__, __data_end__;
|
||||
extern char __bss_start__, __bss_end__;
|
||||
|
||||
struct rom_img_cfg {
|
||||
int *img_start;
|
||||
};
|
||||
|
||||
extern char _lm_rom_img_cfgp;
|
||||
|
||||
void __attribute__((noreturn)) start_c(void) {
|
||||
struct rom_img_cfg *img_cfg = (struct rom_img_cfg*)&_lm_rom_img_cfgp;
|
||||
int *src = img_cfg->img_start;
|
||||
int *dst = (int*)&__data_start__;
|
||||
int exit_code;
|
||||
|
||||
/* Initialize .data, if necessary. */
|
||||
if (src != dst) {
|
||||
int *end = (int*)&__data_end__;
|
||||
while (dst < end) {
|
||||
*dst++ = *src++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Zero .bss. */
|
||||
dst = (int*)&__bss_start__;
|
||||
while (dst < (int*)&__bss_end__) {
|
||||
*dst++ = 0;
|
||||
}
|
||||
|
||||
/* Run initializers. */
|
||||
__libc_init_array();
|
||||
|
||||
/* Jump to main. */
|
||||
exit_code = main(0, 0, 0);
|
||||
if (exit) {
|
||||
exit(exit_code);
|
||||
}
|
||||
|
||||
/* If exit is NULL, make sure we don't return. */
|
||||
for (;;)
|
||||
continue;
|
||||
}
|
|
@ -0,0 +1,176 @@
|
|||
/******************************************************************************
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright (c) 2010 Perry Hung.
|
||||
* Copyright (c) 2011, 2012 LeafLabs, LLC.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use, copy,
|
||||
* modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
* of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*****************************************************************************/
|
||||
|
||||
/**
|
||||
* @file wirish/syscalls.c
|
||||
* @brief newlib stubs
|
||||
*
|
||||
* Low level system routines used by newlib for basic I/O and memory
|
||||
* allocation. You can override most of these.
|
||||
*/
|
||||
|
||||
#include <libmaple/libmaple.h>
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include <stddef.h>
|
||||
|
||||
/* If CONFIG_HEAP_START (or CONFIG_HEAP_END) isn't defined, then
|
||||
* assume _lm_heap_start (resp. _lm_heap_end) is appropriately set by
|
||||
* the linker */
|
||||
#ifndef CONFIG_HEAP_START
|
||||
extern char _lm_heap_start;
|
||||
#define CONFIG_HEAP_START ((void *)&_lm_heap_start)
|
||||
#endif
|
||||
#ifndef CONFIG_HEAP_END
|
||||
extern char _lm_heap_end;
|
||||
#define CONFIG_HEAP_END ((void *)&_lm_heap_end)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* _sbrk -- Increment the program break.
|
||||
*
|
||||
* Get incr bytes more RAM (for use by the heap). malloc() and
|
||||
* friends call this function behind the scenes.
|
||||
*/
|
||||
void *_sbrk(int incr) {
|
||||
static void * pbreak = NULL; /* current program break */
|
||||
void * ret;
|
||||
|
||||
if (pbreak == NULL) {
|
||||
pbreak = CONFIG_HEAP_START;
|
||||
}
|
||||
|
||||
if ((CONFIG_HEAP_END - pbreak < incr) ||
|
||||
(pbreak - CONFIG_HEAP_START < -incr)) {
|
||||
errno = ENOMEM;
|
||||
return (void *)-1;
|
||||
}
|
||||
|
||||
ret = pbreak;
|
||||
pbreak += incr;
|
||||
return ret;
|
||||
}
|
||||
|
||||
__weak int _open(const char *path, int flags, ...) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
__weak int _close(int fd) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
__weak int _fstat(int fd, struct stat *st) {
|
||||
st->st_mode = S_IFCHR;
|
||||
return 0;
|
||||
}
|
||||
|
||||
__weak int _isatty(int fd) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
__weak int isatty(int fd) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
__weak int _lseek(int fd, off_t pos, int whence) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
__weak unsigned char getch(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
__weak int _read(int fd, char *buf, size_t cnt) {
|
||||
*buf = getch();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
__weak void putch(unsigned char c) {
|
||||
}
|
||||
|
||||
__weak void cgets(char *s, int bufsize) {
|
||||
char *p;
|
||||
int c;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < bufsize; i++) {
|
||||
*(s+i) = 0;
|
||||
}
|
||||
// memset(s, 0, bufsize);
|
||||
|
||||
p = s;
|
||||
|
||||
for (p = s; p < s + bufsize-1;) {
|
||||
c = getch();
|
||||
switch (c) {
|
||||
case '\r' :
|
||||
case '\n' :
|
||||
putch('\r');
|
||||
putch('\n');
|
||||
*p = '\n';
|
||||
return;
|
||||
|
||||
case '\b' :
|
||||
if (p > s) {
|
||||
*p-- = 0;
|
||||
putch('\b');
|
||||
putch(' ');
|
||||
putch('\b');
|
||||
}
|
||||
break;
|
||||
|
||||
default :
|
||||
putch(c);
|
||||
*p++ = c;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
__weak int _write(int fd, const char *buf, size_t cnt) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < cnt; i++)
|
||||
putch(buf[i]);
|
||||
|
||||
return cnt;
|
||||
}
|
||||
|
||||
/* Override fgets() in newlib with a version that does line editing */
|
||||
__weak char *fgets(char *s, int bufsize, void *f) {
|
||||
cgets(s, bufsize);
|
||||
return s;
|
||||
}
|
||||
|
||||
__weak void _exit(int exitcode) {
|
||||
while (1)
|
||||
;
|
||||
}
|
|
@ -17,4 +17,6 @@ static const uint8_t MOSI = BOARD_SPI1_MOSI_PIN;
|
|||
static const uint8_t MISO = BOARD_SPI1_MISO_PIN;
|
||||
static const uint8_t SCK = BOARD_SPI1_SCK_PIN;
|
||||
|
||||
#define LED_BUILTIN PC13
|
||||
|
||||
#endif /* _VARIANT_ARDUINO_STM32_ */
|
|
@ -17,4 +17,6 @@ static const uint8_t MOSI = BOARD_SPI1_MOSI_PIN;
|
|||
static const uint8_t MISO = BOARD_SPI1_MISO_PIN;
|
||||
static const uint8_t SCK = BOARD_SPI1_SCK_PIN;
|
||||
|
||||
#define LED_BUILTIN PB1
|
||||
|
||||
#endif /* _VARIANT_ARDUINO_STM32_ */
|
|
@ -3,7 +3,7 @@
|
|||
##############################################################
|
||||
discovery_f407.name=STM32 Discovery F407
|
||||
|
||||
discovery_f407.upload.tool=stlink
|
||||
discovery_f407.upload.tool=stlink_upload
|
||||
discovery_f407.upload.protocol=stlink
|
||||
|
||||
#discovery_f407.upload.use_1200bps_touch=false
|
||||
|
|
|
@ -126,9 +126,7 @@ size_t Print::print(double n, int digits) {
|
|||
|
||||
size_t Print::print(const __FlashStringHelper *ifsh)
|
||||
{
|
||||
size_t n = print(ifsh);
|
||||
n += println();
|
||||
return n;
|
||||
return print(reinterpret_cast<const char *>(ifsh));
|
||||
}
|
||||
|
||||
size_t Print::print(const Printable& x)
|
||||
|
|
|
@ -218,5 +218,7 @@ uint8 waitForButtonPress(uint32 timeout_millis=0);
|
|||
*/
|
||||
void shiftOut(uint8 dataPin, uint8 clockPin, uint8 bitOrder, uint8 value);
|
||||
|
||||
uint32 shiftIn( uint32 ulDataPin, uint32 ulClockPin, uint32 ulBitOrder );
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -38,3 +38,28 @@ void shiftOut(uint8 dataPin, uint8 clockPin, uint8 bitOrder, uint8 val) {
|
|||
digitalWrite(clockPin, LOW);
|
||||
}
|
||||
}
|
||||
|
||||
uint32 shiftIn( uint32 ulDataPin, uint32 ulClockPin, uint32 ulBitOrder )
|
||||
{
|
||||
uint8_t value = 0 ;
|
||||
uint8_t i ;
|
||||
|
||||
|
||||
for ( i=0 ; i < 8 ; ++i )
|
||||
{
|
||||
digitalWrite( ulClockPin, HIGH ) ;
|
||||
|
||||
if ( ulBitOrder == LSBFIRST )
|
||||
{
|
||||
value |= digitalRead( ulDataPin ) << i ;
|
||||
}
|
||||
else
|
||||
{
|
||||
value |= digitalRead( ulDataPin ) << (7 - i) ;
|
||||
}
|
||||
|
||||
digitalWrite( ulClockPin, LOW ) ;
|
||||
}
|
||||
|
||||
return value ;
|
||||
}
|
|
@ -96,6 +96,10 @@ recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build
|
|||
recipe.size.regex=^(?:\.text|\.rodata|\.ARM.exidx)\s+([0-9]+).*
|
||||
recipe.size.regex.data=^(?:\.data|\.bss|\.noinit)\s+([0-9]+).*
|
||||
|
||||
## Save Compiled Binary
|
||||
recipe.output.tmp_file={build.project_name}.bin
|
||||
recipe.output.save_file={build.project_name}.{build.variant}.bin
|
||||
|
||||
# Uploader tools
|
||||
# -------------------
|
||||
|
||||
|
@ -113,28 +117,14 @@ tools.maple_upload.upload.pattern="{path}/{cmd}" {serial.port.file} {upload.altI
|
|||
# Generic STM32 upload via serial to Serial Port 1 (pins PA9 and PA10) - note. Boot0 line needs to high on board reset to enable upload via serial
|
||||
# at the end of the upload the program is automatically run, without the board being reset
|
||||
|
||||
tools.serial_upload.cmd=serial_upload
|
||||
tools.serial_upload.cmd.windows=serial_upload.bat
|
||||
tools.serial_upload.cmd.macosx=serial_upload
|
||||
tools.serial_upload.path={runtime.hardware.path}/tools/win
|
||||
tools.serial_upload.path.macosx={runtime.hardware.path}/tools/macosx
|
||||
tools.serial_upload.path.linux={runtime.hardware.path}/tools/linux
|
||||
tools.serial_upload.path.linux64={runtime.hardware.path}/tools/linux64
|
||||
tools.serial_upload.upload.params.verbose=-d
|
||||
tools.serial_upload.upload.params.quiet=
|
||||
tools.serial_upload.upload.pattern="{path}/{cmd}" {serial.port.file} {upload.altID} {upload.usbID} "{build.path}/{build.project_name}.bin"
|
||||
|
||||
# STLINK/V2
|
||||
|
||||
tools.stlink.cmd=stlink_upload
|
||||
tools.stlink.cmd.windows=stlink_upload.bat
|
||||
# stlink upload
|
||||
tools.stlink_upload.cmd=stlink_upload
|
||||
tools.stlink_upload.cmd.windows=stlink_upload.bat
|
||||
tools.stlink_upload.path.windows={runtime.hardware.path}/tools/win
|
||||
tools.stlink_upload.path.macosx={runtime.hardware.path}/tools/macosx
|
||||
tools.stlink_upload.path.linux={runtime.hardware.path}/tools/linux
|
||||
tools.stlink_upload.path.linux64={runtime.hardware.path}/tools/linux64
|
||||
tools.stlink.path.linux={runtime.hardware.path}/tools/linux/
|
||||
tools.stlink.path.macosx={runtime.hardware.path}/tools/macosx/
|
||||
tools.stlink.upload.params.verbose=-d
|
||||
tools.stlink.upload.params.quiet=
|
||||
tools.stlink.upload.pattern="{path}/{cmd}" {serial.port.file} {upload.altID} {upload.usbID} "{build.path}/{build.project_name}.bin"
|
||||
tools.stlink_upload.upload.params.verbose=-d
|
||||
tools.stlink_upload.upload.params.quiet=
|
||||
tools.stlink_upload.upload.pattern="{path}/{cmd}" {serial.port.file} {upload.altID} {upload.usbID} "{build.path}/{build.project_name}.bin"
|
||||
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
@echo off
|
||||
|
||||
echo Installing STM Serial driver...
|
||||
"%~dp0wdi-simple" --vid 0x0483 --pid 0x5740 --type 3 --name "STM Serial" --dest "%~dp0maple-serial"
|
||||
echo.
|
||||
|
||||
pause
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
ATTRS{idProduct}=="1001", ATTRS{idVendor}=="0110", MODE="664", GROUP="plugdev"
|
||||
ATTRS{idProduct}=="1002", ATTRS{idVendor}=="0110", MODE="664", GROUP="plugdev"
|
||||
ATTRS{idProduct}=="0003", ATTRS{idVendor}=="1eaf", MODE="664", GROUP="plugdev" SYMLINK+="maple"
|
||||
ATTRS{idProduct}=="0004", ATTRS{idVendor}=="1eaf", MODE="664", GROUP="plugdev" SYMLINK+="maple"
|
||||
ATTRS{idProduct}=="0003", ATTRS{idVendor}=="1eaf", MODE="664", GROUP="plugdev" SYMLINK+="maple", ENV{ID_MM_DEVICE_IGNORE}="1"
|
||||
ATTRS{idProduct}=="0004", ATTRS{idVendor}=="1eaf", MODE="664", GROUP="plugdev" SYMLINK+="maple", ENV{ID_MM_DEVICE_IGNORE}="1"
|
||||
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
dfu-util 0.9
|
||||
|
||||
These binaries are for Microsoft Windows 64-bit
|
||||
|
||||
They were built using MinGW-64 from MSYS2 with gcc 5.3.0,
|
||||
for build instructions please see:
|
||||
http://dfu-util.sourceforge.net/build.html
|
||||
|
||||
Source code:
|
||||
https://sourceforge.net/p/dfu-util/dfu-util/ci/v0.9/tree/
|
||||
|
||||
dfu-util.exe requires libusb-1.0.dll. The shipped libusb-1.0.dll
|
||||
is built from libusb 1.0.20 and can be replaced with another
|
||||
version if desired.
|
||||
|
||||
dfu-util-static.exe has the libusb 1.0.20 code embedded and runs
|
||||
without any libusb-1.0.dll.
|
||||
|
||||
Notes:
|
||||
1. To work around a bug in gcc/mingw, a small patch was applied, see
|
||||
https://sourceforge.net/p/dfu-util/tickets/13/
|
||||
2. The dfu-util-static.exe includes libusb that has been patched
|
||||
to work around a silicon bug in STM32F42X devices:
|
||||
https://github.com/axoloti/axoloti/blob/master/platform_osx/src/libusb.stdfu.patch
|
||||
|
||||
2016-02-11 Tormod Volden
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue