Merge branch 'master' into generic_f4

This commit is contained in:
stevstrong 2017-06-02 20:11:45 +02:00 committed by GitHub
commit 220aa0e20f
29 changed files with 117 additions and 27 deletions

View File

@ -193,7 +193,8 @@ size_t HardwareSerial::write(unsigned char ch) {
return 1;
}
/* edogaldo: Waits for the transmission of outgoing serial data to complete (Arduino 1.0 api specs) */
void HardwareSerial::flush(void) {
usart_reset_rx(this->usart_device);
usart_reset_tx(this->usart_device);
while(!rb_is_empty(this->usart_device->wb)); // wait for TX buffer empty
while(!((this->usart_device->regs->SR) & (1<<USART_SR_TC_BIT))); // wait for TC (Transmission Complete) flag set
}

View File

@ -120,8 +120,12 @@ extern char* ltoa( long value, char *string, int radix )
return string;
}
#if __GNUC__ > 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ > 9 || \
(__GNUC_MINOR__ == 9 && __GNUC_PATCHLEVEL__ > 2)))
extern char* utoa( unsigned value, char *string, int radix )
#else
extern char* utoa( unsigned long value, char *string, int radix )
#endif
{
return ultoa( value, string, radix ) ;
}

View File

@ -31,7 +31,12 @@ extern void itoa( int n, char s[] ) ;
extern char* itoa( int value, char *string, int radix ) ;
extern char* ltoa( long value, char *string, int radix ) ;
#if __GNUC__ > 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ > 9 || \
(__GNUC_MINOR__ == 9 && __GNUC_PATCHLEVEL__ > 2)))
extern char* utoa( unsigned value, char *string, int radix ) ;
#else
extern char* utoa( unsigned long value, char *string, int radix ) ;
#endif
extern char* ultoa( unsigned long value, char *string, int radix ) ;
#endif /* 0 */

View File

@ -142,7 +142,6 @@ gpio_pin_mode gpio_get_mode(gpio_dev *dev, uint8 pin) {
gpio_reg_map *regs = dev->regs;
__io uint32 *cr = &regs->CRL + (pin >> 3);
uint32 shift = (pin & 0x7) * 4;
uint32 tmp = *cr;
uint32 crMode = (*cr>>shift) & 0x0F;

View File

@ -521,6 +521,28 @@ uint16 EEPROMClass::write(uint16 Address, uint16 Data)
return status;
}
/**
* @brief Writes/upadtes variable data in EEPROM.
The value is written only if differs from the one already saved at the same address.
* @param VirtAddress: Variable virtual address
* @param Data: 16 bit data to be written
* @retval Success or error status:
* - EEPROM_SAME_VALUE: If new Data matches existing EEPROM Data
* - FLASH_COMPLETE: on success
* - EEPROM_BAD_ADDRESS: if address = 0xFFFF
* - EEPROM_PAGE_FULL: if valid page is full
* - EEPROM_NO_VALID_PAGE: if no valid page was found
* - EEPROM_OUT_SIZE: if no empty EEPROM variables
* - Flash error code: on write Flash error
*/
uint16 EEPROMClass::update(uint16 Address, uint16 Data)
{
if (read(Address) == Data)
return EEPROM_SAME_VALUE;
else
return write(Address, Data);
}
/**
* @brief Return number of variable
* @retval Number of variables

View File

@ -47,6 +47,7 @@ enum : uint16
EEPROM_BAD_ADDRESS = ((uint16)0x0082),
EEPROM_BAD_FLASH = ((uint16)0x0083),
EEPROM_NOT_INIT = ((uint16)0x0084),
EEPROM_SAME_VALUE = ((uint16)0x0085),
EEPROM_NO_VALID_PAGE = ((uint16)0x00AB)
};
@ -67,6 +68,7 @@ public:
uint16 read (uint16 address);
uint16 read (uint16 address, uint16 *data);
uint16 write(uint16 address, uint16 data);
uint16 update(uint16 address, uint16 data);
uint16 count(uint16 *);
uint16 maxcount(void);

View File

@ -16,13 +16,13 @@ compiler.warning_flags.all=-Wall -Wextra -DDEBUG_LEVEL=DEBUG_ALL
# ----------------------
compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/
compiler.c.cmd=arm-none-eabi-gcc
compiler.c.flags=-c -g -Os {compiler.warning_flags} -MMD -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -DBOARD_{build.variant} -D{build.vect} -DERROR_LED_PORT={build.error_led_port} -DERROR_LED_PIN={build.error_led_pin}
compiler.c.flags=-c -g -Os {compiler.warning_flags} -std=gnu11 -MMD -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -DBOARD_{build.variant} -D{build.vect} -DERROR_LED_PORT={build.error_led_port} -DERROR_LED_PIN={build.error_led_pin}
compiler.c.elf.cmd=arm-none-eabi-g++
compiler.c.elf.flags=-Os -Wl,--gc-sections
compiler.S.cmd=arm-none-eabi-gcc
compiler.S.flags=-c -g -x assembler-with-cpp -MMD
compiler.cpp.cmd=arm-none-eabi-g++
compiler.cpp.flags=-c -g -Os {compiler.warning_flags} -MMD -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -DBOARD_{build.variant} -D{build.vect} -DERROR_LED_PORT={build.error_led_port} -DERROR_LED_PIN={build.error_led_pin}
compiler.cpp.flags=-c -g -Os {compiler.warning_flags} -std=gnu++11 -MMD -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -DBOARD_{build.variant} -D{build.vect} -DERROR_LED_PORT={build.error_led_port} -DERROR_LED_PIN={build.error_led_pin}
compiler.ar.cmd=arm-none-eabi-ar
compiler.ar.flags=rcs
compiler.objcopy.cmd=arm-none-eabi-objcopy

View File

@ -52,9 +52,9 @@ extern "C"{
* One byte is left free to distinguish empty from full. */
typedef struct ring_buffer {
volatile uint8 *buf; /**< Buffer items are stored into */
uint16 head; /**< Index of the next item to remove */
uint16 tail; /**< Index where the next item will get inserted */
uint16 size; /**< Buffer capacity minus one */
volatile uint16 head; /**< Index of the next item to remove */
volatile uint16 tail; /**< Index where the next item will get inserted */
volatile uint16 size; /**< Buffer capacity minus one */
} ring_buffer;
/**

View File

@ -108,6 +108,12 @@ static inline uint32 systick_check_underflow(void) {
return SYSTICK_BASE->CSR & SYSTICK_CSR_COUNTFLAG;
}
/**
* @brief prototype for systick_attach_callback
*
*/
extern void systick_attach_callback(void (*callback)(void));
#ifdef __cplusplus
} // extern "C"
#endif

View File

@ -38,7 +38,8 @@
#define CYCLES_PER_MICROSECOND 24
//#define CYCLES_PER_MICROSECOND 24
#define CYCLES_PER_MICROSECOND (F_CPU / 1000000U)
//#define SYSTICK_RELOAD_VAL (F_CPU/1000) - 1 /* takes a cycle to reload */
#define SYSTICK_RELOAD_VAL 23999 /* takes a cycle to reload */

View File

@ -36,7 +36,7 @@
#ifndef _BOARD_GENERIC_STM32F103C_H_
#define _BOARD_GENERIC_STM32F103C_H_
#define CYCLES_PER_MICROSECOND 72
#define CYCLES_PER_MICROSECOND (F_CPU / 1000000U)
#define SYSTICK_RELOAD_VAL (F_CPU/1000) - 1 /* takes a cycle to reload */
#define BOARD_NR_USARTS 3

View File

@ -36,7 +36,7 @@
#ifndef _BOARD_GENERIC_STM32F103C_H_
#define _BOARD_GENERIC_STM32F103C_H_
#define CYCLES_PER_MICROSECOND 72
#define CYCLES_PER_MICROSECOND (F_CPU / 1000000U)
#define SYSTICK_RELOAD_VAL (F_CPU/1000) - 1 /* takes a cycle to reload */
#define BOARD_NR_USARTS 3
@ -73,6 +73,8 @@
#define BOARD_USB_DISC_DEV GPIOB
#define BOARD_USB_DISC_BIT 10
#define LED_BUILTIN PC13
// 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,

View File

@ -36,7 +36,7 @@
#ifndef _BOARD_GENERIC_STM32F103R8_H_
#define _BOARD_GENERIC_STM32F103R8_H_
#define CYCLES_PER_MICROSECOND 72
#define CYCLES_PER_MICROSECOND (F_CPU / 1000000U)
#define SYSTICK_RELOAD_VAL (F_CPU/1000) - 1 /* takes a cycle to reload */
#define BOARD_NR_USARTS 3

View File

@ -36,7 +36,7 @@
#ifndef _BOARD_GENERIC_STM32F103T_H_
#define _BOARD_GENERIC_STM32F103T_H_
#define CYCLES_PER_MICROSECOND 72
#define CYCLES_PER_MICROSECOND (F_CPU / 1000000U)
#define SYSTICK_RELOAD_VAL (F_CPU/1000) - 1 /* takes a cycle to reload */
#define BOARD_NR_USARTS 2

View File

@ -38,7 +38,7 @@
/* A few of these values will seem strange given that it's a
* high-density board. */
#define CYCLES_PER_MICROSECOND 72
#define CYCLES_PER_MICROSECOND (F_CPU / 1000000U)
#define SYSTICK_RELOAD_VAL (F_CPU/1000) - 1 /* takes a cycle to reload */
#define BOARD_BUTTON_PIN PC0

View File

@ -36,7 +36,7 @@
#ifndef _BOARD_GENERIC_STM32F103C_H_
#define _BOARD_GENERIC_STM32F103C_H_
#define CYCLES_PER_MICROSECOND 72
#define CYCLES_PER_MICROSECOND (F_CPU / 1000000U)
#define SYSTICK_RELOAD_VAL (F_CPU/1000) - 1 /* takes a cycle to reload */
#define BOARD_NR_USARTS 2

View File

@ -34,7 +34,7 @@
#define _BOARD_MAPLE_H_
/* 72 MHz -> 72 cycles per microsecond. */
#define CYCLES_PER_MICROSECOND 72
#define CYCLES_PER_MICROSECOND (F_CPU / 1000000U)
/* Roger clark

View File

@ -36,7 +36,7 @@
#ifndef _BOARD_MAPLE_MINI_H_
#define _BOARD_MAPLE_MINI_H_
#define CYCLES_PER_MICROSECOND 72
#define CYCLES_PER_MICROSECOND (F_CPU / 1000000U)
#define SYSTICK_RELOAD_VAL (F_CPU/1000) - 1 /* takes a cycle to reload */
#define BOARD_NR_USARTS 3
@ -71,6 +71,8 @@
#define BOARD_USB_DISC_DEV GPIOB
#define BOARD_USB_DISC_BIT 9
#define LED_BUILTIN PB1
enum {
PB11, PB10, PB2, PB0, PA7, PA6, PA5, PA4, PA3, PA2, PA1, PA0, PC15, PC14,
PC13, PB7, PB6, PB5, PB4, PB3, PA15, PA14, PA13, PA12, PA11, PA10, PA9,

View File

@ -37,7 +37,7 @@
#ifndef _BOARD_MICRODUINO_STM32_H_
#define _BOARD_MICRODUINO_STM32_H_
#define CYCLES_PER_MICROSECOND 72
#define CYCLES_PER_MICROSECOND (F_CPU / 1000000U)
#define SYSTICK_RELOAD_VAL (F_CPU/1000) - 1 /* takes a cycle to reload */
/* Roger Clark.

View File

@ -33,7 +33,7 @@
#ifndef _BOARD_MAPLE_H_
#define _BOARD_MAPLE_H_
#define _BOARD_NUCLEOF103RB_ 1 // hack for HardwareSerial.cpp for a new order of serials
#define CYCLES_PER_MICROSECOND 72
#define CYCLES_PER_MICROSECOND (F_CPU / 1000000U)
#define SYSTICK_RELOAD_VAL (F_CPU/1000) - 1 /* takes a cycle to reload */
/* Roger clark. Removed defines for LED pin and Button pin as they are not Arduino API defines */

View File

@ -38,8 +38,8 @@
#include <libmaple/stm32.h>
#define CYCLES_PER_MICROSECOND 72
#define SYSTICK_RELOAD_VAL 71999 /* takes a cycle to reload */
#define CYCLES_PER_MICROSECOND (F_CPU / 1000000U)
#define SYSTICK_RELOAD_VAL (F_CPU/1000) - 1 /* takes a cycle to reload */
enum {
PC13, PC14, PC15,

View File

@ -120,8 +120,12 @@ extern char* ltoa( long value, char *string, int radix )
return string;
}
#if __GNUC__ > 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ > 9 || \
(__GNUC_MINOR__ == 9 && __GNUC_PATCHLEVEL__ > 2)))
extern char* utoa( unsigned value, char *string, int radix )
#else
extern char* utoa( unsigned long value, char *string, int radix )
#endif
{
return ultoa( value, string, radix ) ;
}

View File

@ -31,7 +31,12 @@ extern void itoa( int n, char s[] ) ;
extern char* itoa( int value, char *string, int radix ) ;
extern char* ltoa( long value, char *string, int radix ) ;
#if __GNUC__ > 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ > 9 || \
(__GNUC_MINOR__ == 9 && __GNUC_PATCHLEVEL__ > 2)))
extern char* utoa( unsigned value, char *string, int radix ) ;
#else
extern char* utoa( unsigned long value, char *string, int radix ) ;
#endif
extern char* ultoa( unsigned long value, char *string, int radix ) ;
#endif /* 0 */

View File

@ -153,7 +153,7 @@ extern const adc_dev ADC3;
#define ADC_CR2_ALIGN_BIT 11
#define ADC_CR2_JEXTTRIG_BIT 15
#define ADC_CR2_EXTTRIG_BIT 20
#define ADC_CR2_TSEREFE_BIT 23
#define ADC_CR2_TSVREFE_BIT 23
#define ADC_CR2_JSWSTART_BIT 22
#define ADC_CR2_SWSTART_BIT 30
#define ADC_CR2_EXTSEL (0x0F000000)
@ -171,7 +171,7 @@ extern const adc_dev ADC3;
#define ADC_CR2_EXTTRIG BIT(ADC_CR2_EXTTRIG_BIT)
#define ADC_CR2_JSWSTART BIT(ADC_CR2_JSWSTART_BIT)
#define ADC_CR2_SWSTART BIT(ADC_CR2_SWSTART_BIT)
#define ADC_CR2_TSEREFE BIT(ADC_CR2_TSEREFE_BIT)
#define ADC_CR2_TSVREFE BIT(ADC_CR2_TSVREFE_BIT)
/* Sample time register 1 */

View File

@ -10,13 +10,13 @@ version=0.1.0
# ----------------------
compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/
compiler.c.cmd=arm-none-eabi-gcc
compiler.c.flags=-c -g -Os -Wall -MMD -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -DBOARD_{build.variant} -D{build.vect} -DERROR_LED_PORT={build.error_led_port} -DERROR_LED_PIN={build.error_led_pin}
compiler.c.flags=-c -g -Os -w -MMD -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -DBOARD_{build.variant} -D{build.vect} -DERROR_LED_PORT={build.error_led_port} -DERROR_LED_PIN={build.error_led_pin}
compiler.c.elf.cmd=arm-none-eabi-g++
compiler.c.elf.flags=-Os -Wl,--gc-sections
compiler.S.cmd=arm-none-eabi-gcc
compiler.S.flags=-c -g -x assembler-with-cpp -MMD
compiler.cpp.cmd=arm-none-eabi-g++
compiler.cpp.flags=-c -g -Os -Wall -MMD -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -DBOARD_{build.variant} -D{build.vect} -DERROR_LED_PORT={build.error_led_port} -DERROR_LED_PIN={build.error_led_pin}
compiler.cpp.flags=-c -g -Os -w -MMD -std=gnu++11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -DBOARD_{build.variant} -D{build.vect} -DERROR_LED_PORT={build.error_led_port} -DERROR_LED_PIN={build.error_led_pin}
compiler.ar.cmd=arm-none-eabi-ar
compiler.ar.flags=rcs
compiler.objcopy.cmd=arm-none-eabi-objcopy

View File

@ -38,3 +38,12 @@ if [ ! -x "${DFU_UTIL}" ]; then
fi
"${DFU_UTIL}" -d ${usbID} -a ${altID} -D ${binfile} ${dfuse_addr} -R
echo -n Waiting for ${dummy_port_fullpath} serial...
COUNTER=0
while [ ! -c ${dummy_port_fullpath} ] && ((COUNTER++ < 40)); do
sleep 0.1
done
echo Done

View File

@ -38,3 +38,12 @@ if [ ! -x "${DFU_UTIL}" ]; then
fi
"${DFU_UTIL}" -d ${usbID} -a ${altID} -D ${binfile} ${dfuse_addr} -R
echo -n Waiting for ${dummy_port_fullpath} serial...
COUNTER=0
while [ ! -c ${dummy_port_fullpath} ] && ((COUNTER++ < 40)); do
sleep 0.1
done
echo Done

View File

@ -51,3 +51,12 @@ if [ ! -x ${DFU_UTIL} ]; then
fi
${DFU_UTIL} -d ${usbID} -a ${altID} -D ${binfile} -R ${dfuse_addr} -R
echo -n Waiting for ${dummy_port_fullpath} serial...
COUNTER=0
while [ ! -c ${dummy_port_fullpath} ] && ((COUNTER++ < 40)); do
sleep 0.1
done
echo Done

View File

@ -6,3 +6,13 @@ set driverLetter=%driverLetter:~0,2%
%driverLetter%
cd %~dp0
java -jar maple_loader.jar %1 %2 %3 %4 %5 %6 %7 %8 %9
for /l %%x in (1, 1, 40) do (
ping -w 50 -n 1 192.0.2.1 > nul
mode %1 > nul
if ERRORLEVEL 0 goto comPortFound
)
echo timeout waiting for %1 serial
:comPortFound