Add multi-application support
This commit is contained in:
parent
fe74ccd8e3
commit
df2d84dee1
4
.vscode/launch.json
vendored
4
.vscode/launch.json
vendored
@ -5,7 +5,7 @@
|
|||||||
"name": "Launch",
|
"name": "Launch",
|
||||||
"type": "cppdbg",
|
"type": "cppdbg",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "${workspaceFolder}/bin/nrf.elf",
|
"program": "${workspaceFolder}/bin/firmware.elf",
|
||||||
"args": [],
|
"args": [],
|
||||||
"stopAtEntry": true,
|
"stopAtEntry": true,
|
||||||
"cwd": "${workspaceFolder}",
|
"cwd": "${workspaceFolder}",
|
||||||
@ -36,7 +36,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "Load executable into debugger.",
|
"description": "Load executable into debugger.",
|
||||||
"text": "file ${workspaceFolder}/bin/nrf.elf",
|
"text": "file ${workspaceFolder}/bin/firmware.elf",
|
||||||
"ignoreFailures": false
|
"ignoreFailures": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
4
.vscode/tasks.json
vendored
4
.vscode/tasks.json
vendored
@ -6,6 +6,8 @@
|
|||||||
"env": {
|
"env": {
|
||||||
"PLATFORM": "nrf52",
|
"PLATFORM": "nrf52",
|
||||||
// "PLATFORM": "posix",
|
// "PLATFORM": "posix",
|
||||||
|
// "APPLICATION": "blinky",
|
||||||
|
"APPLICATION": "button",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"tasks": [
|
"tasks": [
|
||||||
@ -84,4 +86,4 @@
|
|||||||
"panel": "shared",
|
"panel": "shared",
|
||||||
"clear": true,
|
"clear": true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
16
Makefile
16
Makefile
@ -1,21 +1,23 @@
|
|||||||
.DEFAULT_GOAL := all
|
.DEFAULT_GOAL := all
|
||||||
|
|
||||||
PLATFORM ?= posix
|
APPLICATION ?= button
|
||||||
|
|
||||||
TARGET_FILE ?= firmware.elf
|
PLATFORM ?= posix
|
||||||
|
TARGET_FILE ?= $(APPLICATION).elf
|
||||||
|
|
||||||
CC = $(CROSS_COMPILE)gcc
|
CC = $(CROSS_COMPILE)gcc
|
||||||
CPP = $(CROSS_COMPILE)cpp
|
CPP = $(CROSS_COMPILE)cpp
|
||||||
OBJCOPY = $(CROSS_COMPILE)objcopy
|
OBJCOPY = $(CROSS_COMPILE)objcopy
|
||||||
|
|
||||||
SRC_DIR = src
|
SRC_DIR = src
|
||||||
OBJ_DIR = obj
|
OBJ_DIR = obj/$(PLATFORM)
|
||||||
BIN_DIR = bin
|
BIN_DIR = bin/$(PLATFORM)
|
||||||
|
|
||||||
CPP_FLAGS += $(addprefix -I, $(INCLUDES))
|
CPP_FLAGS += $(addprefix -I, $(INCLUDES))
|
||||||
|
|
||||||
C_SRCS = $(wildcard $(SRC_DIR)/*.c)
|
C_SRCS = $(wildcard $(SRC_DIR)/*.c)
|
||||||
C_SRCS += $(wildcard $(SRC_DIR)/platform/$(PLATFORM)/*.c)
|
C_SRCS += $(wildcard $(SRC_DIR)/platform/$(PLATFORM)/*.c)
|
||||||
|
C_SRCS += $(wildcard $(SRC_DIR)/application/$(APPLICATION)/*.c)
|
||||||
C_OBJS = $(patsubst $(SRC_DIR)%,$(OBJ_DIR)%,$(patsubst %.c,%.o,$(C_SRCS)))
|
C_OBJS = $(patsubst $(SRC_DIR)%,$(OBJ_DIR)%,$(patsubst %.c,%.o,$(C_SRCS)))
|
||||||
OBJS = $(NRF_A_OBJS) $(NRF_C_OBJS) $(C_OBJS)
|
OBJS = $(NRF_A_OBJS) $(NRF_C_OBJS) $(C_OBJS)
|
||||||
|
|
||||||
@ -46,14 +48,16 @@ clean:
|
|||||||
rm -f $(OBJS) $(patsubst %.o,%.d,$(OBJS))
|
rm -f $(OBJS) $(patsubst %.o,%.d,$(OBJS))
|
||||||
|
|
||||||
distclean:
|
distclean:
|
||||||
rm -rf $(OBJ_DIR) $(BIN_DIR)
|
rm -rf bin obj
|
||||||
|
|
||||||
$(TARGET): $(OBJS) $(THIS_MAKEFILE)
|
$(TARGET): $(OBJS) $(THIS_MAKEFILE)
|
||||||
@mkdir -p $(dir $@)
|
@mkdir -p $(dir $@)
|
||||||
$(CC) $(CC_FLAGS) $(LD_FLAGS) $(OBJS) $(addprefix -l,$(LIBS)) -o $@
|
$(CC) $(CC_FLAGS) $(LD_FLAGS) $(OBJS) $(addprefix -l,$(LIBS)) -o $@
|
||||||
|
ln -sf $(shell pwd)/$@ $(shell pwd)/bin/firmware.elf
|
||||||
|
|
||||||
$(TARGET_HEX): $(TARGET) $(THIS_MAKEFILE)
|
$(TARGET_HEX): $(TARGET) $(THIS_MAKEFILE)
|
||||||
$(OBJCOPY) -O ihex $(TARGET) $(TARGET_HEX)
|
$(OBJCOPY) -O ihex $(TARGET) $(TARGET_HEX)
|
||||||
|
ln -sf $(shell pwd)/$@ $(shell pwd)/bin/firmware.hex
|
||||||
|
|
||||||
$(OBJ_DIR)/%.d: $(SRC_DIR)/%.c
|
$(OBJ_DIR)/%.d: $(SRC_DIR)/%.c
|
||||||
@mkdir -p $(dir $@)
|
@mkdir -p $(dir $@)
|
||||||
@ -63,6 +67,6 @@ $(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
|
|||||||
@mkdir -p $(dir $@)
|
@mkdir -p $(dir $@)
|
||||||
$(CC) -c $(CPP_FLAGS) $(C_FLAGS) $< -o $@
|
$(CC) -c $(CPP_FLAGS) $(C_FLAGS) $< -o $@
|
||||||
|
|
||||||
ifneq ($(MAKECMDGOALS),clean)
|
ifeq "$(findstring $(MAKECMDGOALS), clean distclean)" ""
|
||||||
-include $(patsubst %.o,%.d,$(OBJS))
|
-include $(patsubst %.o,%.d,$(OBJS))
|
||||||
endif
|
endif
|
||||||
|
26
src/application/blinky/main.c
Normal file
26
src/application/blinky/main.c
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#include <stdbool.h>
|
||||||
|
#include <limits.h>
|
||||||
|
#include "nrf_delay.h"
|
||||||
|
#include "boards.h"
|
||||||
|
#include "platform/narf52/narf52_dk.h"
|
||||||
|
|
||||||
|
#include "driver.h"
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
drv_open(&led_1);
|
||||||
|
drv_open(&led_2);
|
||||||
|
drv_open(&led_3);
|
||||||
|
drv_open(&led_4);
|
||||||
|
|
||||||
|
while(true) {
|
||||||
|
for(unsigned int i = 0; i < UINT_MAX; i++) {
|
||||||
|
char x = 0x30 | (char)(1 & i);
|
||||||
|
drv_write(&led_1, &x, 1);
|
||||||
|
drv_write(&led_2, &x, 1);
|
||||||
|
drv_write(&led_3, &x, 1);
|
||||||
|
drv_write(&led_4, &x, 1);
|
||||||
|
nrf_delay_ms(500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user