-
Notifications
You must be signed in to change notification settings - Fork 327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Examples stuff: fix examples/rules, extend rules and add f7 examples #193
Open
h2obrain
wants to merge
11
commits into
libopencm3:master
Choose a base branch
from
h2obrain:examples-stuff
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
877749f
lpc43xx: Fixed lpc43xx examples (untested) and reenabled compilation
h2obrain 2a7e4fa
stm32l4: added missing l4 target to Makefile and added stm32/l4/Makef…
h2obrain 72027c9
rules.mk: define missing LIBDEPS for old style compilation
h2obrain 6aec4eb
rules.mk: fix build dependencies
h2obrain 6c02f9d
rules.mk: removed unnecessary recipe switch
h2obrain 16d6b24
rules.mk: build only for the required libopencm3 target
h2obrain e20be5f
rules.mk: pass CFLAGS variable to libopencm3
h2obrain 15a0ebf
rules.mk: avoid double slashes in paths
h2obrain e54f872
stm32f7: added demo Makefiles
h2obrain 4e6cb4f
stm32f769i-disco: added blinkled demo
h2obrain 7c432aa
stm32f769i-disco: added sdram demo
h2obrain File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,7 +60,7 @@ ifeq ($(strip $(OPENCM3_DIR)),) | |
LIBPATHS := ./libopencm3 ../../../../libopencm3 ../../../../../libopencm3 | ||
|
||
OPENCM3_DIR := $(wildcard $(LIBPATHS:=/locm3.sublime-project)) | ||
OPENCM3_DIR := $(firstword $(dir $(OPENCM3_DIR))) | ||
OPENCM3_DIR := $(patsubst %/,%,$(firstword $(dir $(OPENCM3_DIR)))) | ||
|
||
ifeq ($(strip $(OPENCM3_DIR)),) | ||
$(warning Cannot find libopencm3 library in the standard search paths.) | ||
|
@@ -84,6 +84,7 @@ ifeq ($(strip $(DEVICE)),) | |
DEFS += -I$(OPENCM3_DIR)/include | ||
LDFLAGS += -L$(OPENCM3_DIR)/lib | ||
LDLIBS += -l$(LIBNAME) | ||
LIBDEPS += $(OPENCM3_DIR)/lib/lib$(LIBNAME).a | ||
LDSCRIPT ?= $(BINARY).ld | ||
else | ||
# New style, assume device is provided, and we're generating the rest. | ||
|
@@ -167,11 +168,26 @@ else | |
include $(OPENCM3_DIR)/mk/genlink-rules.mk | ||
endif | ||
|
||
# Find libopencm3 library folder | ||
# this tries to match LIBNAME to manufacturer or manufacturer/series folder in lib/ | ||
# eg. LIBNAME=lm3s LIBFOLDER=lib/lm3s or LIBNAME=stm32f7 LIBFOLDER=lib/stm32/f7 | ||
DIR=$(notdir $(subst /.,,$(wildcard $1/*/.))) | ||
LIBFOLDER=lib/$(strip \ | ||
$(foreach M,$(filter-out usb ethernet dispatch,$(call DIR,$(OPENCM3_DIR)/lib)), \ | ||
$(if $(subst opencm3_$M,,$(LIBNAME)),\ | ||
$(foreach S,$(call DIR,$(OPENCM3_DIR)/lib/$(M)), \ | ||
$(if $(subst opencm3_$M$S,,$(LIBNAME)),,$M/$S)), \ | ||
$M))) | ||
# exceptions | ||
ifeq ($(LIBFOLDER),lib/lpc43xx) | ||
LIBFOLDER=lib/lpc43xx/m4 | ||
endif | ||
|
||
# Build libopencm3-lib if it does exists | ||
$(OPENCM3_DIR)/lib/lib$(LIBNAME).a: | ||
ifeq (,$(wildcard $@)) | ||
$(warning $(LIBNAME).a not found, attempting to rebuild in $(OPENCM3_DIR)) | ||
$(MAKE) -C $(OPENCM3_DIR) | ||
endif | ||
$(MAKE) -C $(OPENCM3_DIR) $(LIBFOLDER) $(if $(CFLAGS),CFLAGS="$(CFLAGS)") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what sort of usecase is this meant to support? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i guess it makes no sense having this in the examples |
||
$(OPENCM3_DIR)/include/%.h: $(OPENCM3_DIR)/lib/lib$(LIBNAME).a; | ||
|
||
# Define a helper macro for debugging make errors online | ||
# you can type "make print-OPENCM3_DIR" and it will show you | ||
|
@@ -199,19 +215,19 @@ print-%: | |
@#printf " OBJDUMP $(*).list\n" | ||
$(Q)$(OBJDUMP) -S $(*).elf > $(*).list | ||
|
||
%.elf %.map: $(OBJS) $(LDSCRIPT) $(OPENCM3_DIR)/lib/lib$(LIBNAME).a | ||
%.elf %.map: $(OBJS) $(LDSCRIPT) $(LIBDEPS) | ||
@#printf " LD $(*).elf\n" | ||
$(Q)$(LD) $(TGT_LDFLAGS) $(LDFLAGS) $(OBJS) $(LDLIBS) -o $(*).elf | ||
|
||
%.o: %.c | ||
%.o: %.c $(LIBDEPS) | ||
@#printf " CC $(*).c\n" | ||
$(Q)$(CC) $(TGT_CFLAGS) $(CFLAGS) $(TGT_CPPFLAGS) $(CPPFLAGS) -o $(*).o -c $(*).c | ||
|
||
%.o: %.cxx | ||
%.o: %.cxx $(LIBDEPS) | ||
@#printf " CXX $(*).cxx\n" | ||
$(Q)$(CXX) $(TGT_CXXFLAGS) $(CXXFLAGS) $(TGT_CPPFLAGS) $(CPPFLAGS) -o $(*).o -c $(*).cxx | ||
|
||
%.o: %.cpp | ||
%.o: %.cpp $(LIBDEPS) | ||
@#printf " CXX $(*).cpp\n" | ||
$(Q)$(CXX) $(TGT_CXXFLAGS) $(CXXFLAGS) $(TGT_CPPFLAGS) $(CPPFLAGS) -o $(*).o -c $(*).cpp | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
## | ||
## This file is part of the libopencm3 project. | ||
## | ||
## 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 3 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, see <http://www.gnu.org/licenses/>. | ||
## | ||
|
||
# You should use linker script generation! Specify device! | ||
ifeq ($(DEVICE),) | ||
LIBNAME = opencm3_stm32f7 | ||
DEFS += -DSTM32F7 | ||
|
||
FP_FLAGS ?= -mfloat-abi=hard -mfpu=fpv5-sp-d16 | ||
ARCH_FLAGS = -mthumb -mcpu=cortex-m7 $(FP_FLAGS) | ||
endif | ||
|
||
################################################################################ | ||
# OpenOCD specific variables | ||
|
||
OOCD ?= openocd | ||
OOCD_INTERFACE ?= stlink-v2-1 | ||
OOCD_TARGET ?= stm32f7x | ||
|
||
################################################################################ | ||
# Black Magic Probe specific variables | ||
# Set the BMP_PORT to a serial port and then BMP is used for flashing | ||
BMP_PORT ?= | ||
|
||
################################################################################ | ||
# texane/stlink specific variables | ||
#STLINK_PORT ?= :4242 | ||
|
||
|
||
include ../../../../rules.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
OBJS = clock.o | ||
|
||
BINARY = application | ||
|
||
CFLAGS = -O3 | ||
|
||
DEVICE = stm32f769nih6 | ||
|
||
include ../../Makefile.include |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# README | ||
|
||
Demo of gpio and exti. | ||
|
||
This simple program uses the LEDs LD1-3 to show a grey-counter. | ||
By pressing the blue button, all the LEDs light up. On release, the counter restarts from 0. |
119 changes: 119 additions & 0 deletions
119
examples/stm32/f7/stm32f769i-discovery/blinkled/application.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
/* | ||
* This file is part of the libopencm3 project. | ||
* | ||
* 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 3 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, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include <libopencm3/cm3/nvic.h> | ||
#include <libopencm3/stm32/rcc.h> | ||
#include <libopencm3/stm32/gpio.h> | ||
#include <libopencm3/stm32/exti.h> | ||
#include "clock.h" | ||
|
||
|
||
/** | ||
* Function definitions | ||
*/ | ||
static void pin_setup(void); | ||
static void update_led_counter(void); | ||
|
||
/** | ||
* Setup functions | ||
*/ | ||
#define LED_LD1 GPIOJ,GPIO13 | ||
#define LED_LD2 GPIOJ,GPIO5 | ||
#define LED_LD3 GPIOA,GPIO12 | ||
#define BUTTON_BLUE GPIOA,GPIO0 | ||
#define BUTTON_BLUE_PRESSED() gpio_get(BUTTON_BLUE) | ||
void pin_setup() | ||
{ | ||
/* pin-clocks */ | ||
rcc_periph_clock_enable(RCC_GPIOA); | ||
rcc_periph_clock_enable(RCC_GPIOJ); | ||
|
||
/* pins */ | ||
/* outputs (LEDs 1-3) */ | ||
gpio_mode_setup(GPIOJ, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO5 | GPIO13); | ||
gpio_set_output_options(GPIOJ, GPIO_OTYPE_PP, GPIO_OSPEED_25MHZ, GPIO5 | GPIO13); | ||
gpio_mode_setup(GPIOA, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO12); | ||
gpio_set_output_options(GPIOA, GPIO_OTYPE_PP, GPIO_OSPEED_25MHZ, GPIO12); | ||
/* inputs (blue button) */ | ||
gpio_mode_setup(GPIOA, GPIO_MODE_INPUT, GPIO_PUPD_NONE, GPIO0); | ||
|
||
/* setup blue/user button */ | ||
exti_select_source(EXTI0, GPIOA); | ||
exti_set_trigger(EXTI0, EXTI_TRIGGER_BOTH); | ||
exti_enable_request(EXTI0); | ||
nvic_enable_irq(NVIC_EXTI0_IRQ); | ||
} | ||
|
||
/** | ||
* Interrupts | ||
*/ | ||
|
||
/* Blue button interrupt (EXTI makes not too much sense here :)) */ | ||
static bool blue_button_state_changed = false; | ||
void exti0_isr() | ||
{ | ||
exti_reset_request(EXTI0); | ||
blue_button_state_changed = true; | ||
update_led_counter(); | ||
} | ||
|
||
/** | ||
* Functions | ||
*/ | ||
void update_led_counter() | ||
{ | ||
/* little grey code blinker */ | ||
static const uint32_t gcl[] = {0,1,3,2,6,7,5,4}; | ||
static const uint32_t *gc = gcl; | ||
static const uint32_t *gcle = gcl+sizeof(gcl)/sizeof(gcl[0])-1; | ||
if (blue_button_state_changed) { | ||
blue_button_state_changed = false; | ||
gc = gcl; | ||
} | ||
if (BUTTON_BLUE_PRESSED()) { | ||
gpio_set(LED_LD1); | ||
gpio_set(LED_LD2); | ||
gpio_set(LED_LD3); | ||
} else { | ||
if (*gc&0b001) gpio_set(LED_LD1); | ||
else gpio_clear(LED_LD1); | ||
if (*gc&0b010) gpio_set(LED_LD2); | ||
else gpio_clear(LED_LD2); | ||
if (*gc&0b100) gpio_set(LED_LD3); | ||
else gpio_clear(LED_LD3); | ||
if (gc==gcle) gc = gcl; | ||
else gc++; | ||
} | ||
} | ||
|
||
/** | ||
* Main loop | ||
*/ | ||
int main(void) | ||
{ | ||
/* init timers. */ | ||
clock_setup(); | ||
/* setup pins */ | ||
pin_setup(); | ||
|
||
while (1) { | ||
msleep(1000); | ||
update_led_counter(); | ||
} | ||
} | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
definitely not interested in this one. I've had enough rpoblems with people trying to pick and choose things, and reportings bugs when all they really needed to do was just run "make" once in the top and everythign would have been fine. This relies far too much on knowledge of the build system and file structure within the library, which should be treated as a simple .a dependency. It's a submodule for exactly that reason, just build it once, move on.