mirror of
https://github.com/eddyem/stm32samples.git
synced 2025-12-06 02:35:23 +03:00
-flto
This commit is contained in:
parent
a5e420ac51
commit
e98aa11f72
@ -61,13 +61,12 @@ CFLAGS += -O2 -g -MD -D__thumb2__=1
|
|||||||
CFLAGS += -Wall -Werror -Wextra -Wshadow -Wimplicit-function-declaration
|
CFLAGS += -Wall -Werror -Wextra -Wshadow -Wimplicit-function-declaration
|
||||||
CFLAGS += -Wredundant-decls $(INCLUDE)
|
CFLAGS += -Wredundant-decls $(INCLUDE)
|
||||||
# -Wmissing-prototypes -Wstrict-prototypes
|
# -Wmissing-prototypes -Wstrict-prototypes
|
||||||
CFLAGS += -fno-common -ffunction-sections -fdata-sections
|
CFLAGS += -fno-common -ffunction-sections -fdata-sections -flto
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Linker flags
|
# Linker flags
|
||||||
LDFLAGS += --static -nostartfiles -nostdlib
|
LDFLAGS += --static -nostartfiles -nostdlib
|
||||||
LDFLAGS += -Wl,--gc-sections -Wl,--print-memory-usage
|
LDFLAGS += -Wl,--gc-sections -Wl,--print-memory-usage --specs=nano.specs -flto
|
||||||
#--specs=nano.specs
|
|
||||||
LDFLAGS += -L$(LIB_DIR)
|
LDFLAGS += -L$(LIB_DIR)
|
||||||
LDFLAGS += -T$(LDSCRIPT)
|
LDFLAGS += -T$(LDSCRIPT)
|
||||||
LDFLAGS += -Wl,-Map=$(OBJDIR)/$(BINARY).map
|
LDFLAGS += -Wl,-Map=$(OBJDIR)/$(BINARY).map
|
||||||
|
|||||||
Binary file not shown.
@ -1,2 +1,2 @@
|
|||||||
#define BUILD_NUMBER "168"
|
#define BUILD_NUMBER "169"
|
||||||
#define BUILD_DATE "2022-06-17"
|
#define BUILD_DATE "2023-01-11"
|
||||||
|
|||||||
@ -795,7 +795,7 @@ typedef struct {
|
|||||||
|
|
||||||
extern unsigned _stack;
|
extern unsigned _stack;
|
||||||
|
|
||||||
vector_table_t vector_table __attribute__ ((section(".vector_table"))) = {
|
vector_table_t vector_table __attribute__ ((used, section(".vector_table"))) = {
|
||||||
.initial_sp_value = &_stack,
|
.initial_sp_value = &_stack,
|
||||||
.reset = reset_handler,
|
.reset = reset_handler,
|
||||||
.nmi = nmi_handler,
|
.nmi = nmi_handler,
|
||||||
@ -828,7 +828,7 @@ void WEAK __attribute__ ((naked)) __attribute__ ((noreturn)) reset_handler(void)
|
|||||||
char *src = &_ldata;
|
char *src = &_ldata;
|
||||||
|
|
||||||
// enable 8-byte stack alignment to comply with AAPCS
|
// enable 8-byte stack alignment to comply with AAPCS
|
||||||
SCB->CCR |= 0x00000200;
|
// SCB->CCR |= 0x00000200;
|
||||||
|
|
||||||
// copy initialized variables data
|
// copy initialized variables data
|
||||||
while ( dst < &_edata ) { *dst++ = *src++; }
|
while ( dst < &_edata ) { *dst++ = *src++; }
|
||||||
|
|||||||
Binary file not shown.
@ -68,7 +68,7 @@ CFLAGS += $(ARCH_FLAGS)
|
|||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Linker flags
|
# Linker flags
|
||||||
LDFLAGS += -nostartfiles --static -nostdlibs --gc-sections --print-memory-usage
|
LDFLAGS += -nostartfiles --static --gc-sections --print-memory-usage -specs=nano.specs
|
||||||
LDFLAGS += -L$(LIB_DIR) -L$(TOOLCHLIB)
|
LDFLAGS += -L$(LIB_DIR) -L$(TOOLCHLIB)
|
||||||
LDFLAGS += -T$(LDSCRIPT)
|
LDFLAGS += -T$(LDSCRIPT)
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@ -1,2 +1,2 @@
|
|||||||
#define BUILD_NUMBER "71"
|
#define BUILD_NUMBER "72"
|
||||||
#define BUILD_DATE "2022-05-28"
|
#define BUILD_DATE "2023-01-11"
|
||||||
|
|||||||
@ -795,7 +795,7 @@ typedef struct {
|
|||||||
|
|
||||||
extern unsigned _stack;
|
extern unsigned _stack;
|
||||||
|
|
||||||
vector_table_t vector_table __attribute__ ((section(".vector_table"))) = {
|
vector_table_t vector_table __attribute__ ((used, section(".vector_table"))) = {
|
||||||
.initial_sp_value = &_stack,
|
.initial_sp_value = &_stack,
|
||||||
.reset = reset_handler,
|
.reset = reset_handler,
|
||||||
.nmi = nmi_handler,
|
.nmi = nmi_handler,
|
||||||
@ -828,7 +828,7 @@ void WEAK __attribute__ ((naked)) __attribute__ ((noreturn)) reset_handler(void)
|
|||||||
char *src = &_ldata;
|
char *src = &_ldata;
|
||||||
|
|
||||||
// enable 8-byte stack alignment to comply with AAPCS
|
// enable 8-byte stack alignment to comply with AAPCS
|
||||||
SCB->CCR |= 0x00000200;
|
// SCB->CCR |= 0x00000200;
|
||||||
|
|
||||||
// copy initialized variables data
|
// copy initialized variables data
|
||||||
while ( dst < &_edata ) { *dst++ = *src++; }
|
while ( dst < &_edata ) { *dst++ = *src++; }
|
||||||
|
|||||||
@ -60,7 +60,7 @@ LIB_DIR := $(INC_DIR)/ld
|
|||||||
CFLAGS += -g -gdwarf-2 # debuggin symbols in listing
|
CFLAGS += -g -gdwarf-2 # debuggin symbols in listing
|
||||||
CFLAGS += -O2 -D__thumb2__=1 -MD
|
CFLAGS += -O2 -D__thumb2__=1 -MD
|
||||||
CFLAGS += -Wall -Werror -Wextra -Wshadow
|
CFLAGS += -Wall -Werror -Wextra -Wshadow
|
||||||
CFLAGS += -fshort-enums -ffunction-sections -fdata-sections
|
CFLAGS += -fshort-enums -ffunction-sections -fdata-sections -flto
|
||||||
#CFLAGS += -fno-common -ffunction-sections -fdata-sections -fno-stack-protector
|
#CFLAGS += -fno-common -ffunction-sections -fdata-sections -fno-stack-protector
|
||||||
CFLAGS += $(ARCH_FLAGS)
|
CFLAGS += $(ARCH_FLAGS)
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ CFLAGS += $(ARCH_FLAGS)
|
|||||||
# Linker flags
|
# Linker flags
|
||||||
#LDFLAGS += -nostartfiles --static -nostdlib -specs=nosys.specs -specs=nano.specs
|
#LDFLAGS += -nostartfiles --static -nostdlib -specs=nosys.specs -specs=nano.specs
|
||||||
LDFLAGS += $(ARCH_FLAGS)
|
LDFLAGS += $(ARCH_FLAGS)
|
||||||
LDFLAGS += -specs=nano.specs -specs=nosys.specs
|
LDFLAGS += -specs=nano.specs -flto
|
||||||
LDFLAGS += -L$(LIB_DIR)
|
LDFLAGS += -L$(LIB_DIR)
|
||||||
#-L$(TOOLCHLIB)
|
#-L$(TOOLCHLIB)
|
||||||
LDFLAGS += -T$(LDSCRIPT)
|
LDFLAGS += -T$(LDSCRIPT)
|
||||||
|
|||||||
Binary file not shown.
@ -798,7 +798,7 @@ typedef struct {
|
|||||||
|
|
||||||
extern unsigned _stack;
|
extern unsigned _stack;
|
||||||
|
|
||||||
vector_table_t vector_table __attribute__ ((section(".vector_table"))) = {
|
vector_table_t vector_table __attribute__ ((used, section(".vector_table"))) = {
|
||||||
.initial_sp_value = &_stack,
|
.initial_sp_value = &_stack,
|
||||||
.reset = reset_handler,
|
.reset = reset_handler,
|
||||||
.nmi = nmi_handler,
|
.nmi = nmi_handler,
|
||||||
@ -831,7 +831,7 @@ void WEAK __attribute__ ((naked)) __attribute__ ((noreturn)) reset_handler(void)
|
|||||||
char *src = &_ldata;
|
char *src = &_ldata;
|
||||||
|
|
||||||
// enable 8-byte stack alignment to comply with AAPCS
|
// enable 8-byte stack alignment to comply with AAPCS
|
||||||
SCB->CCR |= 0x00000200;
|
// SCB->CCR |= 0x00000200;
|
||||||
|
|
||||||
/* FPU settings ------------------------------------------------------------*/
|
/* FPU settings ------------------------------------------------------------*/
|
||||||
#if (__FPU_PRESENT == 1)
|
#if (__FPU_PRESENT == 1)
|
||||||
|
|||||||
@ -70,7 +70,7 @@ LIB_DIR := $(INC_DIR)/ld
|
|||||||
CFLAGS += -g3 -gdwarf-2
|
CFLAGS += -g3 -gdwarf-2
|
||||||
CFLAGS += -O2 -D__thumb2__=1 -MD
|
CFLAGS += -O2 -D__thumb2__=1 -MD
|
||||||
CFLAGS += -Wall -Werror -Wextra -Wshadow
|
CFLAGS += -Wall -Werror -Wextra -Wshadow
|
||||||
CFLAGS += -fshort-enums -ffunction-sections -fdata-sections
|
CFLAGS += -fshort-enums -ffunction-sections -fdata-sections -flto
|
||||||
#CFLAGS += -fno-common -ffunction-sections -fdata-sections -fno-stack-protector
|
#CFLAGS += -fno-common -ffunction-sections -fdata-sections -fno-stack-protector
|
||||||
CFLAGS += $(ARCH_FLAGS)
|
CFLAGS += $(ARCH_FLAGS)
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ CFLAGS += $(ARCH_FLAGS)
|
|||||||
# Linker flags
|
# Linker flags
|
||||||
#LDFLAGS += -nostartfiles --static -nostdlib -specs=nosys.specs -specs=nano.specs
|
#LDFLAGS += -nostartfiles --static -nostdlib -specs=nosys.specs -specs=nano.specs
|
||||||
LDFLAGS += $(ARCH_FLAGS)
|
LDFLAGS += $(ARCH_FLAGS)
|
||||||
LDFLAGS += -specs=nosys.specs -specs=nano.specs
|
LDFLAGS += -specs=nano.specs -flto
|
||||||
LDFLAGS += -L$(LIB_DIR)
|
LDFLAGS += -L$(LIB_DIR)
|
||||||
#LDFLAGS += -L$(TOOLCHLIB)
|
#LDFLAGS += -L$(TOOLCHLIB)
|
||||||
LDFLAGS += -T$(LDSCRIPT)
|
LDFLAGS += -T$(LDSCRIPT)
|
||||||
|
|||||||
Binary file not shown.
@ -798,7 +798,7 @@ typedef struct {
|
|||||||
|
|
||||||
extern unsigned _stack;
|
extern unsigned _stack;
|
||||||
|
|
||||||
vector_table_t vector_table __attribute__ ((section(".vector_table"))) = {
|
vector_table_t vector_table __attribute__ ((used, section(".vector_table"))) = {
|
||||||
.initial_sp_value = &_stack,
|
.initial_sp_value = &_stack,
|
||||||
.reset = reset_handler,
|
.reset = reset_handler,
|
||||||
.nmi = nmi_handler,
|
.nmi = nmi_handler,
|
||||||
|
|||||||
@ -54,12 +54,11 @@ CFLAGS += -O2 -MD -D__thumb2__=1
|
|||||||
CFLAGS += -Wall -Werror -Wextra -Wshadow -Wimplicit-function-declaration
|
CFLAGS += -Wall -Werror -Wextra -Wshadow -Wimplicit-function-declaration
|
||||||
CFLAGS += -Wredundant-decls $(INCLUDE)
|
CFLAGS += -Wredundant-decls $(INCLUDE)
|
||||||
# -Wmissing-prototypes -Wstrict-prototypes
|
# -Wmissing-prototypes -Wstrict-prototypes
|
||||||
CFLAGS += -fno-common -ffunction-sections -fdata-sections
|
CFLAGS += -fno-common -ffunction-sections -fdata-sections -flto
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Linker flags
|
# Linker flags
|
||||||
LDFLAGS += --static -nostartfiles
|
LDFLAGS += --static -nostartfiles --specs=nano.specs -flto
|
||||||
#--specs=nano.specs
|
|
||||||
LDFLAGS += -L$(LIB_DIR)
|
LDFLAGS += -L$(LIB_DIR)
|
||||||
LDFLAGS += -T$(LDSCRIPT)
|
LDFLAGS += -T$(LDSCRIPT)
|
||||||
LDFLAGS += -Wl,-Map=$(OBJDIR)/$(BINARY).map
|
LDFLAGS += -Wl,-Map=$(OBJDIR)/$(BINARY).map
|
||||||
@ -127,7 +126,7 @@ clean:
|
|||||||
@rmdir $(OBJDIR) 2>/dev/null || true
|
@rmdir $(OBJDIR) 2>/dev/null || true
|
||||||
|
|
||||||
size: $(ELF)
|
size: $(ELF)
|
||||||
$(SIZE) $(ELF)
|
$(SIZE) -Ax $(ELF)
|
||||||
|
|
||||||
flash: $(BIN)
|
flash: $(BIN)
|
||||||
@echo " FLASH $(BIN)"
|
@echo " FLASH $(BIN)"
|
||||||
|
|||||||
Binary file not shown.
@ -64,11 +64,11 @@ CFLAGS += -O2 -MD -D__thumb2__=1
|
|||||||
CFLAGS += -Wall -Werror -Wextra -Wshadow -Wimplicit-function-declaration
|
CFLAGS += -Wall -Werror -Wextra -Wshadow -Wimplicit-function-declaration
|
||||||
CFLAGS += -Wredundant-decls $(INCLUDE)
|
CFLAGS += -Wredundant-decls $(INCLUDE)
|
||||||
# -Wmissing-prototypes -Wstrict-prototypes
|
# -Wmissing-prototypes -Wstrict-prototypes
|
||||||
CFLAGS += -fno-common -ffunction-sections -fdata-sections
|
CFLAGS += -fno-common -ffunction-sections -fdata-sections -flto
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Linker flags
|
# Linker flags
|
||||||
LDFLAGS += --static -nostartfiles --specs=nano.specs
|
LDFLAGS += --static -nostartfiles --specs=nano.specs -flto
|
||||||
LDFLAGS += -L$(LIB_DIR)
|
LDFLAGS += -L$(LIB_DIR)
|
||||||
LDFLAGS += -T$(LDSCRIPT)
|
LDFLAGS += -T$(LDSCRIPT)
|
||||||
LDFLAGS += -Wl,-Map=$(OBJDIR)/$(BINARY).map
|
LDFLAGS += -Wl,-Map=$(OBJDIR)/$(BINARY).map
|
||||||
|
|||||||
@ -17,7 +17,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stm32g0.h>
|
#include <stm32g0.h>
|
||||||
#include "strfunc.h" // mymemcpy
|
#include <string.h>
|
||||||
|
#include "strfunc.h" // hexdump
|
||||||
#include "usart.h"
|
#include "usart.h"
|
||||||
#include "i2c.h"
|
#include "i2c.h"
|
||||||
|
|
||||||
@ -166,7 +167,7 @@ uint8_t write_i2c(uint8_t addr, uint8_t *data, uint8_t nbytes){
|
|||||||
|
|
||||||
uint8_t write_i2c_dma(uint8_t addr, uint8_t *data, uint8_t nbytes){
|
uint8_t write_i2c_dma(uint8_t addr, uint8_t *data, uint8_t nbytes){
|
||||||
if(!data || nbytes < 1) return 0;
|
if(!data || nbytes < 1) return 0;
|
||||||
mymemcpy((char*)I2Cbuf, (char*)data, nbytes);
|
memcpy((char*)I2Cbuf, (char*)data, nbytes);
|
||||||
if(isI2Cbusy()) return 0;
|
if(isI2Cbusy()) return 0;
|
||||||
i2cDMAsetup(1, nbytes);
|
i2cDMAsetup(1, nbytes);
|
||||||
goterr = 0;
|
goterr = 0;
|
||||||
|
|||||||
Binary file not shown.
@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stm32g0.h>
|
#include <stm32g0.h>
|
||||||
|
#include <string.h>
|
||||||
#include "i2c.h"
|
#include "i2c.h"
|
||||||
#include "strfunc.h"
|
#include "strfunc.h"
|
||||||
#include "usart.h"
|
#include "usart.h"
|
||||||
@ -24,6 +25,7 @@
|
|||||||
#define LOCBUFFSZ (32)
|
#define LOCBUFFSZ (32)
|
||||||
// local buffer for I2C data to send
|
// local buffer for I2C data to send
|
||||||
static uint8_t locBuffer[LOCBUFFSZ];
|
static uint8_t locBuffer[LOCBUFFSZ];
|
||||||
|
extern volatile uint32_t Tms;
|
||||||
|
|
||||||
const char *helpstring =
|
const char *helpstring =
|
||||||
"i0..2 - setup I2C with lowest..highest speed (7.7, 10 and 100kHz)\n"
|
"i0..2 - setup I2C with lowest..highest speed (7.7, 10 and 100kHz)\n"
|
||||||
@ -36,6 +38,7 @@ const char *helpstring =
|
|||||||
"In n - just read n bytes\n"
|
"In n - just read n bytes\n"
|
||||||
"IN n - the same but with DMA\n"
|
"IN n - the same but with DMA\n"
|
||||||
"Is - scan I2C bus\n"
|
"Is - scan I2C bus\n"
|
||||||
|
"T - print current Tms\n"
|
||||||
"U - send long buffer over USART\n"
|
"U - send long buffer over USART\n"
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -167,6 +170,11 @@ char *parse_cmd(char *buf){
|
|||||||
// "short" commands
|
// "short" commands
|
||||||
if(buf[1]) return buf; // echo wrong data
|
if(buf[1]) return buf; // echo wrong data
|
||||||
switch(*buf){
|
switch(*buf){
|
||||||
|
case 'T':
|
||||||
|
usart3_sendstr("T=");
|
||||||
|
usart3_sendstr(u2str(Tms));
|
||||||
|
usart3_send("\n", 1);
|
||||||
|
break;
|
||||||
case 'U':
|
case 'U':
|
||||||
U3sendlong(longbuff);
|
U3sendlong(longbuff);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -247,7 +247,9 @@ char *getnum(const char *txt, uint32_t *N){
|
|||||||
return nxt;
|
return nxt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
void mymemcpy(char *dest, const char *src, int len){
|
void mymemcpy(char *dest, const char *src, int len){
|
||||||
if(len < 1) return;
|
if(len < 1) return;
|
||||||
while(len--) *dest++ = *src++;
|
while(len--) *dest++ = *src++;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|||||||
@ -19,7 +19,6 @@
|
|||||||
#include <stm32g0.h>
|
#include <stm32g0.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "strfunc.h" // mymemcpy
|
|
||||||
#include "usart.h"
|
#include "usart.h"
|
||||||
|
|
||||||
// RX/TX DMA->CCR without EN flag
|
// RX/TX DMA->CCR without EN flag
|
||||||
@ -84,7 +83,7 @@ int usart3_send(const char *str, int len){
|
|||||||
int rest = UARTBUFSZ - txlen[tbufno];
|
int rest = UARTBUFSZ - txlen[tbufno];
|
||||||
if(rest == 0 && !u3txrdy) return 0; // buffer is full while transmission in process
|
if(rest == 0 && !u3txrdy) return 0; // buffer is full while transmission in process
|
||||||
if(len < rest) rest = len;
|
if(len < rest) rest = len;
|
||||||
mymemcpy((char*)(tbuf[tbufno] + txlen[tbufno]), str, rest);
|
memcpy((char*)(tbuf[tbufno] + txlen[tbufno]), str, rest);
|
||||||
txlen[tbufno] += rest;
|
txlen[tbufno] += rest;
|
||||||
if(!u3txrdy) return rest;
|
if(!u3txrdy) return rest;
|
||||||
if(txlen[tbufno] == UARTBUFSZ) usart3_sendbuf();
|
if(txlen[tbufno] == UARTBUFSZ) usart3_sendbuf();
|
||||||
@ -92,7 +91,7 @@ int usart3_send(const char *str, int len){
|
|||||||
len -= rest;
|
len -= rest;
|
||||||
// now fill another - empty - buffer
|
// now fill another - empty - buffer
|
||||||
if(len > UARTBUFSZ) len = UARTBUFSZ;
|
if(len > UARTBUFSZ) len = UARTBUFSZ;
|
||||||
mymemcpy((char*)tbuf[tbufno], str + rest, len);
|
memcpy((char*)tbuf[tbufno], str + rest, len);
|
||||||
txlen[tbufno] = len;
|
txlen[tbufno] = len;
|
||||||
return rest + len;
|
return rest + len;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -88,7 +88,7 @@ typedef struct {
|
|||||||
|
|
||||||
extern unsigned _stack;
|
extern unsigned _stack;
|
||||||
|
|
||||||
vector_table_t vector_table __attribute__ ((section(".vector_table"))) = {
|
vector_table_t vector_table __attribute__ ((used, section(".vector_table"))) = {
|
||||||
.initial_sp_value = &_stack,
|
.initial_sp_value = &_stack,
|
||||||
.reset = reset_handler,
|
.reset = reset_handler,
|
||||||
.nmi = nmi_handler,
|
.nmi = nmi_handler,
|
||||||
|
|||||||
@ -64,12 +64,11 @@ CFLAGS += -O2 -MD -D__thumb2__=1
|
|||||||
CFLAGS += -Wall -Werror -Wextra -Wshadow -Wimplicit-function-declaration
|
CFLAGS += -Wall -Werror -Wextra -Wshadow -Wimplicit-function-declaration
|
||||||
CFLAGS += -Wredundant-decls $(INCLUDE)
|
CFLAGS += -Wredundant-decls $(INCLUDE)
|
||||||
# -Wmissing-prototypes -Wstrict-prototypes
|
# -Wmissing-prototypes -Wstrict-prototypes
|
||||||
CFLAGS += -fno-common -ffunction-sections -fdata-sections
|
CFLAGS += -fno-common -ffunction-sections -fdata-sections -flto
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Linker flags
|
# Linker flags
|
||||||
LDFLAGS += --static -nostartfiles
|
LDFLAGS += --static -nostartfiles --specs=nano.specs -flto
|
||||||
#--specs=nano.specs
|
|
||||||
LDFLAGS += -L$(LIB_DIR)
|
LDFLAGS += -L$(LIB_DIR)
|
||||||
LDFLAGS += -T$(LDSCRIPT)
|
LDFLAGS += -T$(LDSCRIPT)
|
||||||
LDFLAGS += -Wl,-Map=$(OBJDIR)/$(BINARY).map
|
LDFLAGS += -Wl,-Map=$(OBJDIR)/$(BINARY).map
|
||||||
@ -146,7 +145,7 @@ clean:
|
|||||||
@rmdir $(OBJDIR) 2>/dev/null || true
|
@rmdir $(OBJDIR) 2>/dev/null || true
|
||||||
|
|
||||||
size: $(ELF)
|
size: $(ELF)
|
||||||
$(SIZE) $(ELF)
|
$(SIZE) -Ax $(ELF)
|
||||||
|
|
||||||
flash: $(BIN)
|
flash: $(BIN)
|
||||||
@echo " FLASH $(BIN)"
|
@echo " FLASH $(BIN)"
|
||||||
|
|||||||
Binary file not shown.
@ -25,18 +25,18 @@
|
|||||||
#define DMARXCCR (DMA_CCR_MINC | DMA_CCR_TCIE | DMA_CCR_TEIE)
|
#define DMARXCCR (DMA_CCR_MINC | DMA_CCR_TCIE | DMA_CCR_TEIE)
|
||||||
#define DMATXCCR (DMA_CCR_MINC | DMA_CCR_DIR | DMA_CCR_TCIE | DMA_CCR_TEIE)
|
#define DMATXCCR (DMA_CCR_MINC | DMA_CCR_DIR | DMA_CCR_TCIE | DMA_CCR_TEIE)
|
||||||
|
|
||||||
static int txrdy = 1, rxrdy = 0; // transmission done, next line received
|
static volatile int txrdy = 1, rxrdy = 0; // transmission done, next line received
|
||||||
static int bufovr = 0, wasbufovr = 0; // Rx buffer overflow or error flag -> delete next line
|
static volatile int bufovr = 0, wasbufovr = 0; // Rx buffer overflow or error flag -> delete next line
|
||||||
static int rbufno = 0, tbufno = 0; // current buf number
|
static volatile int rbufno = 0, tbufno = 0; // current buf number
|
||||||
static char rbuf[2][UARTBUFSZ], tbuf[2][UARTBUFSZ]; // receive & transmit buffers
|
static volatile char rbuf[2][UARTBUFSZ], tbuf[2][UARTBUFSZ]; // receive & transmit buffers
|
||||||
static int rxlen[2] = {0}, txlen[2] = {0};
|
static volatile int rxlen[2] = {0}, txlen[2] = {0};
|
||||||
|
|
||||||
char *usart3_getline(int *wasbo){
|
char *usart3_getline(int *wasbo){
|
||||||
if(wasbo) *wasbo = wasbufovr;
|
if(wasbo) *wasbo = wasbufovr;
|
||||||
wasbufovr = 0;
|
wasbufovr = 0;
|
||||||
if(!rxrdy) return NULL;
|
if(!rxrdy) return NULL;
|
||||||
rxrdy = 0; // clear ready flag
|
rxrdy = 0; // clear ready flag
|
||||||
return rbuf[!rbufno]; // current buffer is in filling stage, return old - filled - buffer
|
return (char*)rbuf[!rbufno]; // current buffer is in filling stage, return old - filled - buffer
|
||||||
}
|
}
|
||||||
|
|
||||||
#define USART_BRR(speed) ((64000000 + speed/2) / speed)
|
#define USART_BRR(speed) ((64000000 + speed/2) / speed)
|
||||||
@ -87,7 +87,7 @@ int usart3_send(const char *str, int len){
|
|||||||
int rest = UARTBUFSZ - txlen[tbufno];
|
int rest = UARTBUFSZ - txlen[tbufno];
|
||||||
if(rest == 0 && !txrdy) return 0; // buffer is full while transmission in process
|
if(rest == 0 && !txrdy) return 0; // buffer is full while transmission in process
|
||||||
if(len < rest) rest = len;
|
if(len < rest) rest = len;
|
||||||
mymemcpy(tbuf[tbufno] + txlen[tbufno], str, rest);
|
mymemcpy((char*)(tbuf[tbufno] + txlen[tbufno]), str, rest);
|
||||||
txlen[tbufno] += rest;
|
txlen[tbufno] += rest;
|
||||||
if(!txrdy) return rest;
|
if(!txrdy) return rest;
|
||||||
if(txlen[tbufno] == UARTBUFSZ) usart3_sendbuf();
|
if(txlen[tbufno] == UARTBUFSZ) usart3_sendbuf();
|
||||||
@ -95,7 +95,7 @@ int usart3_send(const char *str, int len){
|
|||||||
len -= rest;
|
len -= rest;
|
||||||
// now fill another - empty - buffer
|
// now fill another - empty - buffer
|
||||||
if(len > UARTBUFSZ) len = UARTBUFSZ;
|
if(len > UARTBUFSZ) len = UARTBUFSZ;
|
||||||
mymemcpy(tbuf[tbufno], str + rest, len);
|
mymemcpy((char*)tbuf[tbufno], str + rest, len);
|
||||||
txlen[tbufno] = len;
|
txlen[tbufno] = len;
|
||||||
return rest + len;
|
return rest + len;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user