Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Micha Hoiting
GD32VF103_Firmware_Library
Commits
4e35a853
Commit
4e35a853
authored
Sep 02, 2019
by
Kongou Hikari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Template: Optimize for code size
parent
9592ed5c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
12 deletions
+16
-12
Template/Makefile
Template/Makefile
+5
-5
Template/systick.c
Template/systick.c
+11
-7
No files found.
Template/Makefile
View file @
4e35a853
...
...
@@ -11,9 +11,9 @@ TARGET = gd32vf103
# building variables
######################################
# debug build?
DEBUG
=
1
DEBUG
=
0
# optimization
OPT
=
-O
g
OPT
=
-O
2
# Build path
BUILD_DIR
=
build
...
...
@@ -85,7 +85,7 @@ C_INCLUDES = \
# compile gcc flags
ASFLAGS
:=
$(CFLAGS)
$(ARCH)
$(AS_DEFS)
$(AS_INCLUDES)
$(OPT)
-Wl
,-Bstatic#,
-ffreestanding
-nostdlib
CFLAGS
:=
$(CFLAGS)
$(ARCH)
$(C_DEFS)
$(C_INCLUDES)
$(OPT)
-Wl
,-Bstatic#
,
-ffreestanding
-nostdlib
CFLAGS
:=
$(CFLAGS)
$(ARCH)
$(C_DEFS)
$(C_INCLUDES)
$(OPT)
-Wl
,-Bstatic
-ffunction-sections
-fdata-sections
# -ffreestanding -nostdlib
ifeq
($(DEBUG), 1)
CFLAGS
+=
-g
-gdwarf-2
...
...
@@ -101,9 +101,9 @@ CFLAGS += -std=gnu11 -MMD -MP # -MF$(@:%.o=%.d) -MT$(@:%.o=%.d)
LDSCRIPT
=
$(FIRMWARE_DIR)
/RISCV/env_Eclipse/GD32VF103x8.lds
# libraries
LIBS
=
-lc_nano
-lm
#
LIBS = -lc_nano -lm
LIBDIR
=
LDFLAGS
=
$(ARCH)
-T
$(LDSCRIPT)
$(LIBDIR)
$(LIBS)
$(PERIFLIB_SOURCES)
-Wl
,--no-relax
-Wl
,--gc-sections
-Wl
,-M
=
$(BUILD_DIR)
/
$(TARGET)
.map
-nostartfiles
#-ffreestanding -nostdlib
LDFLAGS
=
-flto
$(ARCH)
-T
$(LDSCRIPT)
$(LIBDIR)
$(LIBS)
$(PERIFLIB_SOURCES)
-Wl
,--no-relax
-Wl
,--gc-sections
-Wl
,-M
=
$(BUILD_DIR)
/
$(TARGET)
.map
-nostartfiles
#-ffreestanding -nostdlib
# default action: build all
all
:
$(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin
...
...
Template/systick.c
View file @
4e35a853
...
...
@@ -43,15 +43,19 @@ OF SUCH DAMAGE.
*/
void
delay_1ms
(
uint32_t
count
)
{
uint64_t
start_mtime
,
delta_mtime
;
volatile
uint64_t
start_mtime
,
delta_mtime
;
// Don't start measuruing until we see an mtime tick
uint64_t
tmp
=
get_timer_value
();
volatile
uint64_t
tmp
=
get_timer_value
();
do
{
start_mtime
=
get_timer_value
();
}
while
(
start_mtime
==
tmp
);
start_mtime
=
get_timer_value
();
}
while
(
start_mtime
==
tmp
);
uint64_t
delay_ticks
=
SystemCoreClock
/
4
;
// 1 second
delay_ticks
=
delay_ticks
*
count
/
1000
;
do
{
delta_mtime
=
get_timer_value
()
-
start_mtime
;
}
while
(
delta_mtime
<
(
SystemCoreClock
/
4000
.
0
*
count
));
delta_mtime
=
get_timer_value
()
-
start_mtime
;
}
while
(
delta_mtime
<
delay_ticks
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment