Add multi-application support

This commit is contained in:
Thomas Klaehn 2020-03-10 13:31:33 +01:00
parent fe74ccd8e3
commit df2d84dee1
5 changed files with 41 additions and 9 deletions

4
.vscode/launch.json vendored
View File

@ -5,7 +5,7 @@
"name": "Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/bin/nrf.elf",
"program": "${workspaceFolder}/bin/firmware.elf",
"args": [],
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
@ -36,7 +36,7 @@
},
{
"description": "Load executable into debugger.",
"text": "file ${workspaceFolder}/bin/nrf.elf",
"text": "file ${workspaceFolder}/bin/firmware.elf",
"ignoreFailures": false
},
{

4
.vscode/tasks.json vendored
View File

@ -6,6 +6,8 @@
"env": {
"PLATFORM": "nrf52",
// "PLATFORM": "posix",
// "APPLICATION": "blinky",
"APPLICATION": "button",
},
},
"tasks": [
@ -84,4 +86,4 @@
"panel": "shared",
"clear": true,
}
}
}

View File

@ -1,21 +1,23 @@
.DEFAULT_GOAL := all
PLATFORM ?= posix
APPLICATION ?= button
TARGET_FILE ?= firmware.elf
PLATFORM ?= posix
TARGET_FILE ?= $(APPLICATION).elf
CC = $(CROSS_COMPILE)gcc
CPP = $(CROSS_COMPILE)cpp
OBJCOPY = $(CROSS_COMPILE)objcopy
SRC_DIR = src
OBJ_DIR = obj
BIN_DIR = bin
OBJ_DIR = obj/$(PLATFORM)
BIN_DIR = bin/$(PLATFORM)
CPP_FLAGS += $(addprefix -I, $(INCLUDES))
C_SRCS = $(wildcard $(SRC_DIR)/*.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)))
OBJS = $(NRF_A_OBJS) $(NRF_C_OBJS) $(C_OBJS)
@ -46,14 +48,16 @@ clean:
rm -f $(OBJS) $(patsubst %.o,%.d,$(OBJS))
distclean:
rm -rf $(OBJ_DIR) $(BIN_DIR)
rm -rf bin obj
$(TARGET): $(OBJS) $(THIS_MAKEFILE)
@mkdir -p $(dir $@)
$(CC) $(CC_FLAGS) $(LD_FLAGS) $(OBJS) $(addprefix -l,$(LIBS)) -o $@
ln -sf $(shell pwd)/$@ $(shell pwd)/bin/firmware.elf
$(TARGET_HEX): $(TARGET) $(THIS_MAKEFILE)
$(OBJCOPY) -O ihex $(TARGET) $(TARGET_HEX)
ln -sf $(shell pwd)/$@ $(shell pwd)/bin/firmware.hex
$(OBJ_DIR)/%.d: $(SRC_DIR)/%.c
@mkdir -p $(dir $@)
@ -63,6 +67,6 @@ $(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
@mkdir -p $(dir $@)
$(CC) -c $(CPP_FLAGS) $(C_FLAGS) $< -o $@
ifneq ($(MAKECMDGOALS),clean)
ifeq "$(findstring $(MAKECMDGOALS), clean distclean)" ""
-include $(patsubst %.o,%.d,$(OBJS))
endif

View 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);
}
}
}