Added a makefile to compile with Arduino libraries
Added a extern "C" to sss7.h
This commit is contained in:
parent
b09b1960f3
commit
07a52f566d
|
@ -1,4 +1,5 @@
|
||||||
-I../sss7core
|
-I../sss7core
|
||||||
-I/usr/avr/include
|
-I/usr/avr/include
|
||||||
|
-I./arduino-1.6.13/hardware/arduino/avr/cores/arduino/
|
||||||
-D__AVR_ATmega2560__
|
-D__AVR_ATmega2560__
|
||||||
-DF_CPU=16000000
|
-DF_CPU=16000000
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
arduino-1.6.13
|
||||||
|
bin
|
|
@ -0,0 +1,111 @@
|
||||||
|
AVRMCU ?= atmega2560
|
||||||
|
F_CPU ?= 16000000
|
||||||
|
ISPPORT ?= /dev/ttyUSB0
|
||||||
|
|
||||||
|
VERSION = 0.1
|
||||||
|
|
||||||
|
HEADERS = ardusss7.h ../sss7core/sss7.h
|
||||||
|
SRC_C = ../sss7core/sss7.c
|
||||||
|
SRC_CPP = main.cpp ardusss7.cpp
|
||||||
|
TARGET = sss7
|
||||||
|
OBJDIR = bin
|
||||||
|
ARDUINO_DIR = ./arduino-1.6.13
|
||||||
|
ARDUINO_BOARD = mega
|
||||||
|
|
||||||
|
CC = avr-gcc
|
||||||
|
CPP = avr-g++
|
||||||
|
AR = avr-ar
|
||||||
|
OBJCOPY = avr-objcopy
|
||||||
|
OBJDUMP = avr-objdump
|
||||||
|
SIZE = avr-size
|
||||||
|
|
||||||
|
SRC_C_TMP = $(subst ../,,$(SRC_C))
|
||||||
|
OBJ = $(SRC_C_TMP:%.c=$(OBJDIR)/$(AVRMCU)/%.o)
|
||||||
|
OBJ += $(SRC_CPP:%.cpp=$(OBJDIR)/$(AVRMCU)/%.o)
|
||||||
|
|
||||||
|
ARDU_HEADERS = Arduino.h binary.h Client.h HardwareSerial.h IPAddress.h \
|
||||||
|
new.h Printable.h Print.h Server.h \
|
||||||
|
Stream.h Udp.h USBAPI.h USBCore.h USBDesc.h WCharacter.h \
|
||||||
|
wiring_private.h WString.h
|
||||||
|
|
||||||
|
ARDU_C_SRC = WInterrupts.c wiring_digital.c wiring_analog.c wiring_pulse.c \
|
||||||
|
wiring.c wiring_shift.c
|
||||||
|
|
||||||
|
ARDU_CPP_SRC = CDC.cpp new.cpp HardwareSerial0.cpp PluggableUSB.cpp \
|
||||||
|
HardwareSerial1.cpp Print.cpp HardwareSerial2.cpp Stream.cpp \
|
||||||
|
HardwareSerial3.cpp Tone.cpp HardwareSerial.cpp USBCore.cpp \
|
||||||
|
IPAddress.cpp WMath.cpp main.cpp WString.cpp \
|
||||||
|
|
||||||
|
ARDU_FULL_DIR = $(ARDUINO_DIR)/hardware/arduino/avr/cores/arduino
|
||||||
|
ARDU_VARIANT_DIR = $(ARDUINO_DIR)/hardware/arduino/avr/variants/$(ARDUINO_BOARD)
|
||||||
|
ARDU_FULL_HEADERS = $(ARDU_HEADERS:%.h=$(ARDU_FULL_DIR)/%.h)
|
||||||
|
ARDU_FULL_HEADERS += $(ARDU_VARIANT_DIR)/pins_arduino.h
|
||||||
|
ARDU_OBJS = $(ARDU_C_SRC:%.c=$(OBJDIR)/$(AVRMCU)/arduino/%.o)
|
||||||
|
ARDU_OBJS += $(ARDU_CPP_SRC:%.cpp=$(OBJDIR)/$(AVRMCU)/arduino/%.o)
|
||||||
|
|
||||||
|
CFLAGS = -I $(ARDU_FULL_DIR) -I $(ARDU_VARIANT_DIR) -I ../sss7core/ -Os -Wall -Wstrict-prototypes
|
||||||
|
CFLAGS += -ffunction-sections -fdata-sections
|
||||||
|
CFLAGS += -fshort-enums -fpack-struct -funsigned-char -funsigned-bitfields
|
||||||
|
CFLAGS += -mmcu=$(AVRMCU) -DF_CPU=$(F_CPU)UL -DVERSION=$(VERSION)
|
||||||
|
|
||||||
|
CPPFLAGS = -I $(ARDU_FULL_DIR) -I $(ARDU_VARIANT_DIR) -I ../sss7core/ -Os
|
||||||
|
CPPFLAGS += -ffunction-sections -fdata-sections
|
||||||
|
CPPFLAGS += -fshort-enums -fpack-struct -funsigned-char -funsigned-bitfields
|
||||||
|
CPPFLAGS += -mmcu=$(AVRMCU) -DF_CPU=$(F_CPU)UL -DVERSION=$(VERSION)
|
||||||
|
|
||||||
|
LDFLAGS = -mmcu=$(AVRMCU) -Wl,--gc-sections
|
||||||
|
|
||||||
|
all: start $(OBJDIR)/$(AVRMCU)/$(TARGET).hex size
|
||||||
|
@echo ":: Done !"
|
||||||
|
|
||||||
|
start:
|
||||||
|
@echo "SSS7 AVR port $(VERSION)"
|
||||||
|
@echo "========================"
|
||||||
|
@echo ":: Building for $(AVRMCU)"
|
||||||
|
@echo ":: MCU operating frequency is $(F_CPU)Hz"
|
||||||
|
|
||||||
|
|
||||||
|
$(OBJDIR)/$(AVRMCU)/%.o : %.c $(HEADERS) Makefile
|
||||||
|
@mkdir -p $$(dirname $@)
|
||||||
|
$(CC) $(CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
$(OBJDIR)/$(AVRMCU)/%.o : %.cpp $(HEADERS) Makefile
|
||||||
|
@mkdir -p $$(dirname $@)
|
||||||
|
$(CPP) $(CPPFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
$(OBJDIR)/$(AVRMCU)/sss7core/%.o : ../sss7core/%.c $(HEADERS) Makefile
|
||||||
|
@mkdir -p $$(dirname $@)
|
||||||
|
$(CC) $(CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
$(OBJDIR)/$(AVRMCU)/arduino/%.o : $(ARDU_FULL_DIR)/%.c $(ARDU_FULL_HEADERS) Makefile
|
||||||
|
@mkdir -p $$(dirname $@)
|
||||||
|
$(CC) $(CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
$(OBJDIR)/$(AVRMCU)/arduino/%.o : $(ARDU_FULL_DIR)/%.cpp $(ARDU_FULL_HEADERS) Makefile
|
||||||
|
@mkdir -p $$(dirname $@)
|
||||||
|
$(CPP) $(CPPFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
$(OBJDIR)/$(AVRMCU)/arduino/libarduino.a: $(ARDU_OBJS)
|
||||||
|
${AR} crs $@ $+
|
||||||
|
|
||||||
|
$(OBJDIR)/$(AVRMCU)/$(TARGET).elf : $(OBJ) $(OBJDIR)/$(AVRMCU)/arduino/libarduino.a
|
||||||
|
$(CC) $(LDFLAGS) $+ -o $@
|
||||||
|
|
||||||
|
$(OBJDIR)/$(AVRMCU)/$(TARGET).hex : $(OBJDIR)/$(AVRMCU)/$(TARGET).elf
|
||||||
|
$(OBJCOPY) -O ihex $< $@
|
||||||
|
|
||||||
|
size : $(OBJDIR)/$(AVRMCU)/$(TARGET).elf
|
||||||
|
@echo
|
||||||
|
@$(SIZE) --mcu=$(AVRMCU) -C $(OBJDIR)/$(AVRMCU)/$(TARGET).elf
|
||||||
|
@echo
|
||||||
|
|
||||||
|
clean :
|
||||||
|
@rm -rf $(OBJDIR)
|
||||||
|
|
||||||
|
flash : all
|
||||||
|
avrdude -c stk500v2 \
|
||||||
|
-p $(AVRMCU) -P $(ISPPORT) -D \
|
||||||
|
-U flash:w:$(OBJDIR)/$(AVRMCU)/$(TARGET).hex
|
||||||
|
|
||||||
|
test : flash
|
||||||
|
screen $(ISPPORT) 38400
|
|
@ -60,11 +60,11 @@ uint8_t uart_get_byte() {
|
||||||
return UDR1;
|
return UDR1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ISR(USART_RXC1_vect) {
|
ISR(USART1_RX_vect) {
|
||||||
sss7_process_rx();
|
sss7_process_rx();
|
||||||
}
|
}
|
||||||
|
|
||||||
ISR(USART_TXC1_vect) {
|
ISR(USART1_TX_vect) {
|
||||||
sss7_process_tx();
|
sss7_process_tx();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ class SSS7Wrapper {
|
||||||
private:
|
private:
|
||||||
void setupUart();
|
void setupUart();
|
||||||
void setupTimer();
|
void setupTimer();
|
||||||
}
|
};
|
||||||
|
|
||||||
extern SSS7Wrapper SSS7;
|
extern SSS7Wrapper SSS7;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
|
||||||
|
};
|
|
@ -1,6 +1,11 @@
|
||||||
#ifndef _SSS7_H_
|
#ifndef _SSS7_H_
|
||||||
#define _SSS7_H_
|
#define _SSS7_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
enum sss7State {
|
enum sss7State {
|
||||||
|
@ -53,4 +58,8 @@ static inline uint8_t sss7_has_received(void) {
|
||||||
|
|
||||||
void sss7_get_received(uint8_t msg[SSS7_PAYLOAD_SIZE]);
|
void sss7_get_received(uint8_t msg[SSS7_PAYLOAD_SIZE]);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue