Skip to content

Commit 220aa0e

Browse files
authored
Merge branch 'master' into generic_f4
2 parents 642495b + 920b57a commit 220aa0e

29 files changed

Lines changed: 117 additions & 27 deletions

File tree

STM32F1/cores/maple/HardwareSerial.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,8 @@ size_t HardwareSerial::write(unsigned char ch) {
193193
return 1;
194194
}
195195

196+
/* edogaldo: Waits for the transmission of outgoing serial data to complete (Arduino 1.0 api specs) */
196197
void HardwareSerial::flush(void) {
197-
usart_reset_rx(this->usart_device);
198-
usart_reset_tx(this->usart_device);
198+
while(!rb_is_empty(this->usart_device->wb)); // wait for TX buffer empty
199+
while(!((this->usart_device->regs->SR) & (1<<USART_SR_TC_BIT))); // wait for TC (Transmission Complete) flag set
199200
}

STM32F1/cores/maple/itoa.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,12 @@ extern char* ltoa( long value, char *string, int radix )
120120

121121
return string;
122122
}
123-
123+
#if __GNUC__ > 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ > 9 || \
124+
(__GNUC_MINOR__ == 9 && __GNUC_PATCHLEVEL__ > 2)))
125+
extern char* utoa( unsigned value, char *string, int radix )
126+
#else
124127
extern char* utoa( unsigned long value, char *string, int radix )
128+
#endif
125129
{
126130
return ultoa( value, string, radix ) ;
127131
}

STM32F1/cores/maple/itoa.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@ extern void itoa( int n, char s[] ) ;
3131

3232
extern char* itoa( int value, char *string, int radix ) ;
3333
extern char* ltoa( long value, char *string, int radix ) ;
34+
#if __GNUC__ > 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ > 9 || \
35+
(__GNUC_MINOR__ == 9 && __GNUC_PATCHLEVEL__ > 2)))
36+
extern char* utoa( unsigned value, char *string, int radix ) ;
37+
#else
3438
extern char* utoa( unsigned long value, char *string, int radix ) ;
39+
#endif
3540
extern char* ultoa( unsigned long value, char *string, int radix ) ;
3641
#endif /* 0 */
3742

STM32F1/cores/maple/libmaple/gpio_f1.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ gpio_pin_mode gpio_get_mode(gpio_dev *dev, uint8 pin) {
142142
gpio_reg_map *regs = dev->regs;
143143
__io uint32 *cr = &regs->CRL + (pin >> 3);
144144
uint32 shift = (pin & 0x7) * 4;
145-
uint32 tmp = *cr;
146145

147146
uint32 crMode = (*cr>>shift) & 0x0F;
148147

STM32F1/libraries/EEPROM/EEPROM.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,28 @@ uint16 EEPROMClass::write(uint16 Address, uint16 Data)
521521
return status;
522522
}
523523

524+
/**
525+
* @brief Writes/upadtes variable data in EEPROM.
526+
The value is written only if differs from the one already saved at the same address.
527+
* @param VirtAddress: Variable virtual address
528+
* @param Data: 16 bit data to be written
529+
* @retval Success or error status:
530+
* - EEPROM_SAME_VALUE: If new Data matches existing EEPROM Data
531+
* - FLASH_COMPLETE: on success
532+
* - EEPROM_BAD_ADDRESS: if address = 0xFFFF
533+
* - EEPROM_PAGE_FULL: if valid page is full
534+
* - EEPROM_NO_VALID_PAGE: if no valid page was found
535+
* - EEPROM_OUT_SIZE: if no empty EEPROM variables
536+
* - Flash error code: on write Flash error
537+
*/
538+
uint16 EEPROMClass::update(uint16 Address, uint16 Data)
539+
{
540+
if (read(Address) == Data)
541+
return EEPROM_SAME_VALUE;
542+
else
543+
return write(Address, Data);
544+
}
545+
524546
/**
525547
* @brief Return number of variable
526548
* @retval Number of variables

STM32F1/libraries/EEPROM/EEPROM.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ enum : uint16
4747
EEPROM_BAD_ADDRESS = ((uint16)0x0082),
4848
EEPROM_BAD_FLASH = ((uint16)0x0083),
4949
EEPROM_NOT_INIT = ((uint16)0x0084),
50+
EEPROM_SAME_VALUE = ((uint16)0x0085),
5051
EEPROM_NO_VALID_PAGE = ((uint16)0x00AB)
5152
};
5253

@@ -67,6 +68,7 @@ class EEPROMClass
6768
uint16 read (uint16 address);
6869
uint16 read (uint16 address, uint16 *data);
6970
uint16 write(uint16 address, uint16 data);
71+
uint16 update(uint16 address, uint16 data);
7072
uint16 count(uint16 *);
7173
uint16 maxcount(void);
7274

STM32F1/platform.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ compiler.warning_flags.all=-Wall -Wextra -DDEBUG_LEVEL=DEBUG_ALL
1616
# ----------------------
1717
compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/
1818
compiler.c.cmd=arm-none-eabi-gcc
19-
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}
19+
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}
2020
compiler.c.elf.cmd=arm-none-eabi-g++
2121
compiler.c.elf.flags=-Os -Wl,--gc-sections
2222
compiler.S.cmd=arm-none-eabi-gcc
2323
compiler.S.flags=-c -g -x assembler-with-cpp -MMD
2424
compiler.cpp.cmd=arm-none-eabi-g++
25-
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}
25+
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}
2626
compiler.ar.cmd=arm-none-eabi-ar
2727
compiler.ar.flags=rcs
2828
compiler.objcopy.cmd=arm-none-eabi-objcopy

STM32F1/system/libmaple/include/libmaple/ring_buffer.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ extern "C"{
5252
* One byte is left free to distinguish empty from full. */
5353
typedef struct ring_buffer {
5454
volatile uint8 *buf; /**< Buffer items are stored into */
55-
uint16 head; /**< Index of the next item to remove */
56-
uint16 tail; /**< Index where the next item will get inserted */
57-
uint16 size; /**< Buffer capacity minus one */
55+
volatile uint16 head; /**< Index of the next item to remove */
56+
volatile uint16 tail; /**< Index where the next item will get inserted */
57+
volatile uint16 size; /**< Buffer capacity minus one */
5858
} ring_buffer;
5959

6060
/**

STM32F1/system/libmaple/include/libmaple/systick.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,12 @@ static inline uint32 systick_check_underflow(void) {
108108
return SYSTICK_BASE->CSR & SYSTICK_CSR_COUNTFLAG;
109109
}
110110

111+
/**
112+
* @brief prototype for systick_attach_callback
113+
*
114+
*/
115+
extern void systick_attach_callback(void (*callback)(void));
116+
111117
#ifdef __cplusplus
112118
} // extern "C"
113119
#endif

STM32F1/variants/STM32VLD/board/board.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838

3939

4040

41-
#define CYCLES_PER_MICROSECOND 24
41+
//#define CYCLES_PER_MICROSECOND 24
42+
#define CYCLES_PER_MICROSECOND (F_CPU / 1000000U)
4243
//#define SYSTICK_RELOAD_VAL (F_CPU/1000) - 1 /* takes a cycle to reload */
4344
#define SYSTICK_RELOAD_VAL 23999 /* takes a cycle to reload */
4445

0 commit comments

Comments
 (0)