Merge branch 'lib'

master 0.1.0
Ondřej Hruška 9 years ago
commit ade297bb53
  1. 69
      Makefile
  2. 6
      README.md
  3. 30
      example/Makefile
  4. 2
      example/example.c
  5. 0
      include/scpi_builtins.h
  6. 0
      include/scpi_errors.h
  7. 0
      include/scpi_parser.h
  8. 0
      include/scpi_regs.h
  9. 0
      lib/.gitkeep
  10. BIN
      scpi

@ -1,27 +1,54 @@
SRC = example.c ###############################################################################
SRC+= source/scpi_parser.c
SRC+= source/scpi_regs.c # Makefile to build a library for ARM CortexM3
SRC+= source/scpi_builtins.c
SRC+= source/scpi_errors.c FP_FLAGS = -mfloat-abi=hard -mfpu=fpv4-sp-d16
ARCH_FLAGS = -mthumb -mcpu=cortex-m4 $(FP_FLAGS)
HDRS= source/scpi_parser.h
HDRS+= source/scpi_regs.h INCL_DIR = include
HDRS+= source/scpi_builtins.h SRC_DIR = source
HDRS+= source/scpi_errors.h
LIBNAME = arm_cortexM4_scpi
CFLAGS += -std=gnu99
OBJS = $(SRC_DIR)/scpi_parser.o
OBJS += $(SRC_DIR)/scpi_regs.o
OBJS += $(SRC_DIR)/scpi_errors.o
OBJS += $(SRC_DIR)/scpi_builtins.o
JUNK = *.o *.d *.elf *.bin *.hex *.srec *.list *.map *.dis *.disasm *.a
###############################################################################
PREFIX ?= arm-none-eabi
CC := $(PREFIX)-gcc
AR := $(PREFIX)-ar
###############################################################################
CFLAGS += -Os -ggdb -std=gnu99 -Wfatal-errors
CFLAGS += -Wall -Wextra -Wshadow CFLAGS += -Wall -Wextra -Wshadow
CFLAGS += -Wwrite-strings -Wold-style-definition -Winline CFLAGS += -Wwrite-strings -Wold-style-definition -Winline -Wmissing-noreturn -Wstrict-prototypes
CFLAGS += -Wredundant-decls -Wfloat-equal -Wsign-compare -Wunused-function CFLAGS += -Wredundant-decls -Wfloat-equal -Wsign-compare
CFLAGS += -fno-common -ffunction-sections -fdata-sections -Wunused-function
CFLAGS += -I$(INCL_DIR)
###############################################################################
all: $(SRC) $(HDRS) all: lib
gcc $(CFLAGS) $(SRC) -o example.elf
run: all %.o: %.c
./example.elf $(Q)$(CC) $(CFLAGS) $(ARCH_FLAGS) -o $(*).o -c $(*).c
lib: lib/lib$(LIBNAME).a
lib/lib$(LIBNAME).a: $(OBJS)
$(Q)$(AR) rcs $@ $(OBJS)
clean: clean:
rm -f *.o *.d *.so *.elf *.bin *.hex $(Q)$(RM) $(JUNK)
cd source $(Q)cd source && $(RM) $(JUNK)
rm -f *.o *.d *.so *.elf *.bin *.hex $(Q)cd lib && $(RM) $(JUNK)
$(Q)cd example && $(RM) $(JUNK)
.PHONY: clean all lib

@ -20,7 +20,11 @@ Built-in commands can be overriden in user command array.
## How to use ## How to use
See main.c for example of how to use the library. To test it with regular gcc, run the Makefile in the `example` directory.
The main Makefile builds a library for ARM Cortex M4 (can be easily adjusted for others).
### Stubs to implement
Here's an overview of stubs you have to implement (at the time of writing this readme): Here's an overview of stubs you have to implement (at the time of writing this readme):

@ -0,0 +1,30 @@
SRC = example.c
SRC += ../source/scpi_parser.c
SRC += ../source/scpi_regs.c
SRC += ../source/scpi_builtins.c
SRC += ../source/scpi_errors.c
INCL_DIR = ../include
CFLAGS = -std=gnu99
CFLAGS += -Wall -Wextra -Wshadow
CFLAGS += -Wwrite-strings -Wold-style-definition -Winline
CFLAGS += -Wredundant-decls -Wfloat-equal -Wsign-compare -Wunused-function
CC = gcc
%.o: %.c
all: example.elf
example.elf: $(SRC)
$(Q)$(CC) $(CFLAGS) -I$(INCL_DIR) -o example.elf $(SRC)
run: example.elf
./example.elf
clean:
rm -f *.o *.d *.so *.elf *.bin *.hex
cd ../source
rm -f *.o *.d *.so *.elf *.bin *.hex

@ -2,7 +2,7 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include "source/scpi_parser.h" #include "scpi_parser.h"
// ------- TESTING ---------- // ------- TESTING ----------

BIN
scpi

Binary file not shown.
Loading…
Cancel
Save