fixed svn EOL and MIME settings.
This commit is contained in:
@@ -1,152 +1,152 @@
|
||||
# Makefile for AT91SAM7S evaluation kit with RS-485 Transceiver on UART0
|
||||
# Written by Steve Karg <skarg@users.sourceforge.net> 06-Aug-2007
|
||||
|
||||
TARGET=bacnet
|
||||
|
||||
# Tools
|
||||
CC=arm-elf-gcc
|
||||
OBJCOPY=arm-elf-objcopy
|
||||
OBJDUMP=arm-elf-objdump
|
||||
AR=arm-elf-ar
|
||||
SIZE = arm-elf-size
|
||||
|
||||
LDSCRIPT=at91sam7s256.ld
|
||||
|
||||
BACNET_FLAGS = -DBACDL_MSTP
|
||||
BACNET_FLAGS += -DMAX_TSM_TRANSACTIONS=0
|
||||
BACNET_FLAGS += -DPRINT_ENABLED=0
|
||||
BACNET_FLAGS += -DMAX_APDU=480
|
||||
BACNET_FLAGS += -DCRC_USE_TABLE
|
||||
#BACNET_FLAGS += -DDLMSTP_TEST
|
||||
|
||||
BACNET_CORE = ../../src
|
||||
BACNET_DEMO = ../../demo
|
||||
BACNET_INCLUDE = ../../include
|
||||
BACNET_OBJECT = ../../demo/object
|
||||
BACNET_HANDLER = ../../demo/handler
|
||||
INCLUDES = -I.
|
||||
INCLUDES += -I$(BACNET_INCLUDE)
|
||||
INCLUDES += -I$(BACNET_OBJECT)
|
||||
INCLUDES += -I$(BACNET_HANDLER)
|
||||
#OPTIMIZATION = -O0
|
||||
OPTIMIZATION = -Os
|
||||
CFLAGS = -fno-common $(INCLUDES) $(BACNET_FLAGS) -Wall -g
|
||||
CFLAGS += -mno-thumb-interwork
|
||||
# dead code removal
|
||||
CFLAGS += -fdata-sections -ffunction-sections
|
||||
LIBRARY = lib$(TARGET).a
|
||||
# -Wa,<options> Pass comma-separated <options> on to the assembler
|
||||
AFLAGS = -Wa,-ahls,-mapcs-32,-adhlns=$(<:.s=.lst)
|
||||
# -Wl,<options> Pass comma-separated <options> on to the linker
|
||||
LIBRARIES=-lc,-lgcc,-lm,-L.,-l$(TARGET)
|
||||
LDFLAGS = -nostartfiles
|
||||
LDFLAGS += -Wl,-nostdlib,-Map=$(TARGET).map,$(LIBRARIES),-T$(LDSCRIPT)
|
||||
# dead code removal
|
||||
LDFLAGS += -Wl,--gc-sections,-static
|
||||
CPFLAGS = --output-target=binary
|
||||
ODFLAGS = -x --syms
|
||||
|
||||
ASRC = crt.s
|
||||
|
||||
PORTSRC = main.c \
|
||||
timer.c \
|
||||
isr.c \
|
||||
init.c \
|
||||
blinker.c \
|
||||
rs485.c \
|
||||
dlmstp.c \
|
||||
$(BACNET_CORE)/crc.c
|
||||
|
||||
DEMOSRC = ai.c \
|
||||
av.c \
|
||||
bi.c \
|
||||
bv.c \
|
||||
device.c \
|
||||
$(BACNET_DEMO)/handler/txbuf.c \
|
||||
$(BACNET_DEMO)/handler/noserv.c \
|
||||
$(BACNET_DEMO)/handler/h_npdu.c \
|
||||
$(BACNET_DEMO)/handler/h_whohas.c \
|
||||
$(BACNET_DEMO)/handler/h_whois.c \
|
||||
$(BACNET_DEMO)/handler/h_rd.c \
|
||||
$(BACNET_DEMO)/handler/h_rp.c \
|
||||
$(BACNET_DEMO)/handler/h_rpm.c \
|
||||
$(BACNET_DEMO)/handler/h_wp.c \
|
||||
$(BACNET_DEMO)/handler/h_dcc.c \
|
||||
$(BACNET_DEMO)/handler/s_iam.c \
|
||||
$(BACNET_DEMO)/handler/s_ihave.c
|
||||
|
||||
CORESRC = $(BACNET_CORE)/npdu.c \
|
||||
$(BACNET_CORE)/apdu.c \
|
||||
$(BACNET_CORE)/bacdcode.c \
|
||||
$(BACNET_CORE)/bacint.c \
|
||||
$(BACNET_CORE)/bacreal.c \
|
||||
$(BACNET_CORE)/bacstr.c \
|
||||
$(BACNET_CORE)/bacaddr.c \
|
||||
$(BACNET_CORE)/abort.c \
|
||||
$(BACNET_CORE)/bacerror.c \
|
||||
$(BACNET_CORE)/reject.c \
|
||||
$(BACNET_CORE)/bacapp.c \
|
||||
$(BACNET_CORE)/datetime.c \
|
||||
$(BACNET_CORE)/dcc.c \
|
||||
$(BACNET_CORE)/iam.c \
|
||||
$(BACNET_CORE)/ihave.c \
|
||||
$(BACNET_CORE)/memcopy.c \
|
||||
$(BACNET_CORE)/ringbuf.c \
|
||||
$(BACNET_CORE)/rd.c \
|
||||
$(BACNET_CORE)/rp.c \
|
||||
$(BACNET_CORE)/rpm.c \
|
||||
$(BACNET_CORE)/wp.c \
|
||||
$(BACNET_CORE)/whohas.c \
|
||||
$(BACNET_CORE)/whois.c \
|
||||
$(BACNET_CORE)/version.c
|
||||
|
||||
CSRC = $(PORTSRC) $(DEMOSRC)
|
||||
#CSRC = $(PORTSRC)
|
||||
|
||||
AOBJ = $(ASRC:.s=.o)
|
||||
COBJ = $(CSRC:.c=.o)
|
||||
COREOBJ = $(CORESRC:.c=.o)
|
||||
|
||||
all: $(TARGET).bin $(TARGET).elf
|
||||
$(OBJDUMP) $(ODFLAGS) $(TARGET).elf > $(TARGET).dmp
|
||||
$(SIZE) $(TARGET).elf
|
||||
|
||||
$(TARGET).bin: $(TARGET).elf
|
||||
$(OBJCOPY) $(TARGET).elf $(CPFLAGS) $(TARGET).bin
|
||||
|
||||
$(TARGET).elf: $(COBJ) $(AOBJ) $(LIBRARY) Makefile
|
||||
$(CC) $(CFLAGS) $(AOBJ) $(COBJ) $(LDFLAGS) -o $@
|
||||
|
||||
lib: $(LIBRARY)
|
||||
|
||||
$(LIBRARY): $(COREOBJ) Makefile
|
||||
$(AR) rcs $@ $(COREOBJ)
|
||||
|
||||
# allow a single file to be unoptimized for debugging purposes
|
||||
#dlmstp.o:
|
||||
# $(CC) -c $(CFLAGS) $*.c -o $@
|
||||
#
|
||||
#main.o:
|
||||
# $(CC) -c $(CFLAGS) $*.c -o $@
|
||||
#
|
||||
#$(BACNET_CORE)/npdu.o:
|
||||
# $(CC) -c $(CFLAGS) $*.c -o $@
|
||||
#
|
||||
#$(BACNET_CORE)/apdu.o:
|
||||
# $(CC) -c $(CFLAGS) $*.c -o $@
|
||||
|
||||
.c.o:
|
||||
$(CC) -c $(OPTIMIZATION) $(CFLAGS) $*.c -o $@
|
||||
|
||||
.s.o:
|
||||
$(CC) -c $(AFLAGS) $*.s -o $@
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-rm -rf $(COBJ) $(AOBJ) $(COREOBJ)
|
||||
-rm -rf $(TARGET).elf $(TARGET).bin $(TARGET).dmp $(TARGET).map
|
||||
-rm -rf $(LIBRARY)
|
||||
-rm -rf *.lst
|
||||
|
||||
## Other dependencies
|
||||
-include $(shell mkdir dep 2>/dev/null) $(wildcard dep/*)
|
||||
# Makefile for AT91SAM7S evaluation kit with RS-485 Transceiver on UART0
|
||||
# Written by Steve Karg <skarg@users.sourceforge.net> 06-Aug-2007
|
||||
|
||||
TARGET=bacnet
|
||||
|
||||
# Tools
|
||||
CC=arm-elf-gcc
|
||||
OBJCOPY=arm-elf-objcopy
|
||||
OBJDUMP=arm-elf-objdump
|
||||
AR=arm-elf-ar
|
||||
SIZE = arm-elf-size
|
||||
|
||||
LDSCRIPT=at91sam7s256.ld
|
||||
|
||||
BACNET_FLAGS = -DBACDL_MSTP
|
||||
BACNET_FLAGS += -DMAX_TSM_TRANSACTIONS=0
|
||||
BACNET_FLAGS += -DPRINT_ENABLED=0
|
||||
BACNET_FLAGS += -DMAX_APDU=480
|
||||
BACNET_FLAGS += -DCRC_USE_TABLE
|
||||
#BACNET_FLAGS += -DDLMSTP_TEST
|
||||
|
||||
BACNET_CORE = ../../src
|
||||
BACNET_DEMO = ../../demo
|
||||
BACNET_INCLUDE = ../../include
|
||||
BACNET_OBJECT = ../../demo/object
|
||||
BACNET_HANDLER = ../../demo/handler
|
||||
INCLUDES = -I.
|
||||
INCLUDES += -I$(BACNET_INCLUDE)
|
||||
INCLUDES += -I$(BACNET_OBJECT)
|
||||
INCLUDES += -I$(BACNET_HANDLER)
|
||||
#OPTIMIZATION = -O0
|
||||
OPTIMIZATION = -Os
|
||||
CFLAGS = -fno-common $(INCLUDES) $(BACNET_FLAGS) -Wall -g
|
||||
CFLAGS += -mno-thumb-interwork
|
||||
# dead code removal
|
||||
CFLAGS += -fdata-sections -ffunction-sections
|
||||
LIBRARY = lib$(TARGET).a
|
||||
# -Wa,<options> Pass comma-separated <options> on to the assembler
|
||||
AFLAGS = -Wa,-ahls,-mapcs-32,-adhlns=$(<:.s=.lst)
|
||||
# -Wl,<options> Pass comma-separated <options> on to the linker
|
||||
LIBRARIES=-lc,-lgcc,-lm,-L.,-l$(TARGET)
|
||||
LDFLAGS = -nostartfiles
|
||||
LDFLAGS += -Wl,-nostdlib,-Map=$(TARGET).map,$(LIBRARIES),-T$(LDSCRIPT)
|
||||
# dead code removal
|
||||
LDFLAGS += -Wl,--gc-sections,-static
|
||||
CPFLAGS = --output-target=binary
|
||||
ODFLAGS = -x --syms
|
||||
|
||||
ASRC = crt.s
|
||||
|
||||
PORTSRC = main.c \
|
||||
timer.c \
|
||||
isr.c \
|
||||
init.c \
|
||||
blinker.c \
|
||||
rs485.c \
|
||||
dlmstp.c \
|
||||
$(BACNET_CORE)/crc.c
|
||||
|
||||
DEMOSRC = ai.c \
|
||||
av.c \
|
||||
bi.c \
|
||||
bv.c \
|
||||
device.c \
|
||||
$(BACNET_DEMO)/handler/txbuf.c \
|
||||
$(BACNET_DEMO)/handler/noserv.c \
|
||||
$(BACNET_DEMO)/handler/h_npdu.c \
|
||||
$(BACNET_DEMO)/handler/h_whohas.c \
|
||||
$(BACNET_DEMO)/handler/h_whois.c \
|
||||
$(BACNET_DEMO)/handler/h_rd.c \
|
||||
$(BACNET_DEMO)/handler/h_rp.c \
|
||||
$(BACNET_DEMO)/handler/h_rpm.c \
|
||||
$(BACNET_DEMO)/handler/h_wp.c \
|
||||
$(BACNET_DEMO)/handler/h_dcc.c \
|
||||
$(BACNET_DEMO)/handler/s_iam.c \
|
||||
$(BACNET_DEMO)/handler/s_ihave.c
|
||||
|
||||
CORESRC = $(BACNET_CORE)/npdu.c \
|
||||
$(BACNET_CORE)/apdu.c \
|
||||
$(BACNET_CORE)/bacdcode.c \
|
||||
$(BACNET_CORE)/bacint.c \
|
||||
$(BACNET_CORE)/bacreal.c \
|
||||
$(BACNET_CORE)/bacstr.c \
|
||||
$(BACNET_CORE)/bacaddr.c \
|
||||
$(BACNET_CORE)/abort.c \
|
||||
$(BACNET_CORE)/bacerror.c \
|
||||
$(BACNET_CORE)/reject.c \
|
||||
$(BACNET_CORE)/bacapp.c \
|
||||
$(BACNET_CORE)/datetime.c \
|
||||
$(BACNET_CORE)/dcc.c \
|
||||
$(BACNET_CORE)/iam.c \
|
||||
$(BACNET_CORE)/ihave.c \
|
||||
$(BACNET_CORE)/memcopy.c \
|
||||
$(BACNET_CORE)/ringbuf.c \
|
||||
$(BACNET_CORE)/rd.c \
|
||||
$(BACNET_CORE)/rp.c \
|
||||
$(BACNET_CORE)/rpm.c \
|
||||
$(BACNET_CORE)/wp.c \
|
||||
$(BACNET_CORE)/whohas.c \
|
||||
$(BACNET_CORE)/whois.c \
|
||||
$(BACNET_CORE)/version.c
|
||||
|
||||
CSRC = $(PORTSRC) $(DEMOSRC)
|
||||
#CSRC = $(PORTSRC)
|
||||
|
||||
AOBJ = $(ASRC:.s=.o)
|
||||
COBJ = $(CSRC:.c=.o)
|
||||
COREOBJ = $(CORESRC:.c=.o)
|
||||
|
||||
all: $(TARGET).bin $(TARGET).elf
|
||||
$(OBJDUMP) $(ODFLAGS) $(TARGET).elf > $(TARGET).dmp
|
||||
$(SIZE) $(TARGET).elf
|
||||
|
||||
$(TARGET).bin: $(TARGET).elf
|
||||
$(OBJCOPY) $(TARGET).elf $(CPFLAGS) $(TARGET).bin
|
||||
|
||||
$(TARGET).elf: $(COBJ) $(AOBJ) $(LIBRARY) Makefile
|
||||
$(CC) $(CFLAGS) $(AOBJ) $(COBJ) $(LDFLAGS) -o $@
|
||||
|
||||
lib: $(LIBRARY)
|
||||
|
||||
$(LIBRARY): $(COREOBJ) Makefile
|
||||
$(AR) rcs $@ $(COREOBJ)
|
||||
|
||||
# allow a single file to be unoptimized for debugging purposes
|
||||
#dlmstp.o:
|
||||
# $(CC) -c $(CFLAGS) $*.c -o $@
|
||||
#
|
||||
#main.o:
|
||||
# $(CC) -c $(CFLAGS) $*.c -o $@
|
||||
#
|
||||
#$(BACNET_CORE)/npdu.o:
|
||||
# $(CC) -c $(CFLAGS) $*.c -o $@
|
||||
#
|
||||
#$(BACNET_CORE)/apdu.o:
|
||||
# $(CC) -c $(CFLAGS) $*.c -o $@
|
||||
|
||||
.c.o:
|
||||
$(CC) -c $(OPTIMIZATION) $(CFLAGS) $*.c -o $@
|
||||
|
||||
.s.o:
|
||||
$(CC) -c $(AFLAGS) $*.s -o $@
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-rm -rf $(COBJ) $(AOBJ) $(COREOBJ)
|
||||
-rm -rf $(TARGET).elf $(TARGET).bin $(TARGET).dmp $(TARGET).map
|
||||
-rm -rf $(LIBRARY)
|
||||
-rm -rf *.lst
|
||||
|
||||
## Other dependencies
|
||||
-include $(shell mkdir dep 2>/dev/null) $(wildcard dep/*)
|
||||
|
||||
+2095
-2095
File diff suppressed because it is too large
Load Diff
@@ -1,10 +1,10 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
|
||||
<workspace>
|
||||
<project>
|
||||
<path>$WS_DIR$\bacnet.ewp</path>
|
||||
</project>
|
||||
<batchBuild/>
|
||||
</workspace>
|
||||
|
||||
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
|
||||
<workspace>
|
||||
<project>
|
||||
<path>$WS_DIR$\bacnet.ewp</path>
|
||||
</project>
|
||||
<batchBuild/>
|
||||
</workspace>
|
||||
|
||||
|
||||
|
||||
+178
-178
@@ -1,178 +1,178 @@
|
||||
###############################################################################
|
||||
# Makefile for BACnet
|
||||
###############################################################################
|
||||
|
||||
## General Flags
|
||||
PROJECT = bacnet
|
||||
MCU = atmega168
|
||||
TARGET = bacnet
|
||||
## Tools
|
||||
CC = avr-gcc
|
||||
AR = avr-ar
|
||||
OBJCOPY = avr-objcopy
|
||||
OBJDUMP = avr-objdump
|
||||
SIZE = avr-size
|
||||
|
||||
# Source locations
|
||||
BACNET_CORE = ../../src
|
||||
BACNET_INCLUDE = ../../include
|
||||
BACNET_DEMO = ../../demo
|
||||
|
||||
# local files for this project
|
||||
CSRC = main.c \
|
||||
timer.c \
|
||||
rs485.c \
|
||||
dlmstp.c \
|
||||
apdu.c \
|
||||
$(BACNET_CORE)/crc.c
|
||||
|
||||
# common demo files needed
|
||||
DEMOSRC = h_rp.c \
|
||||
device.c \
|
||||
$(BACNET_DEMO)/handler/txbuf.c \
|
||||
$(BACNET_DEMO)/handler/h_npdu.c \
|
||||
$(BACNET_DEMO)/handler/noserv.c
|
||||
|
||||
# core BACnet stack files
|
||||
CORESRC = \
|
||||
$(BACNET_CORE)/apdu.c \
|
||||
$(BACNET_CORE)/npdu.c \
|
||||
$(BACNET_CORE)/bacdcode.c \
|
||||
$(BACNET_CORE)/bacint.c \
|
||||
$(BACNET_CORE)/bacreal.c \
|
||||
$(BACNET_CORE)/bacstr.c \
|
||||
$(BACNET_CORE)/rp.c \
|
||||
$(BACNET_CORE)/bacaddr.c \
|
||||
$(BACNET_CORE)/abort.c \
|
||||
$(BACNET_CORE)/reject.c \
|
||||
$(BACNET_CORE)/bacerror.c \
|
||||
$(BACNET_CORE)/bacapp.c
|
||||
|
||||
# $(BACNET_CORE)/iam.c \
|
||||
# $(BACNET_CORE)/whois.c \
|
||||
# $(BACNET_CORE)/wp.c \
|
||||
# $(BACNET_CORE)/version.c
|
||||
# $(BACNET_CORE)/bacprop.c \
|
||||
# $(BACNET_CORE)/bactext.c \
|
||||
# $(BACNET_CORE)/datetime.c \
|
||||
# $(BACNET_CORE)/indtext.c \
|
||||
# $(BACNET_CORE)/bigend.c \
|
||||
# $(BACNET_CORE)/arf.c \
|
||||
# $(BACNET_CORE)/awf.c \
|
||||
# $(BACNET_CORE)/cov.c \
|
||||
# $(BACNET_CORE)/dcc.c \
|
||||
# $(BACNET_CORE)/iam/iam_client.c \
|
||||
# $(BACNET_CORE)/ihave.c \
|
||||
# $(BACNET_CORE)/rd.c \
|
||||
# $(BACNET_CORE)/rpm.c \
|
||||
# $(BACNET_CORE)/timesync.c \
|
||||
# $(BACNET_CORE)/whohas.c \
|
||||
# $(BACNET_CORE)/filename.c \
|
||||
# $(BACNET_CORE)/tsm.c \
|
||||
# $(BACNET_CORE)/address.c \
|
||||
|
||||
## Include Directories
|
||||
INCLUDES = -I. -I$(BACNET_INCLUDE)
|
||||
|
||||
# Source to Object conversion
|
||||
COBJ = $(CSRC:.c=.o)
|
||||
DEMOOBJ = $(DEMOSRC:.c=.o)
|
||||
COREOBJ = $(CORESRC:.c=.o)
|
||||
|
||||
LIBRARY = lib$(TARGET).a
|
||||
|
||||
## Options common to compile, link and assembly rules
|
||||
COMMON = -mmcu=$(MCU)
|
||||
|
||||
OPTIMIZE_FLAGS = -mcall-prologues
|
||||
#OPTIMIZE_FLAGS += -finline-functions
|
||||
OPTIMIZE_FLAGS += -finline-functions-called-once
|
||||
#OPTIMIZATION = -O0
|
||||
#OPTIMIZATION = -Os
|
||||
OPTIMIZATION = -Os $(OPTIMIZE_FLAGS)
|
||||
#OPTIMIZATION = -O3 $(OPTIMIZE_FLAGS)
|
||||
|
||||
## Compile options common for all C compilation units.
|
||||
BFLAGS = -DBACDL_MSTP
|
||||
BFLAGS += -DMAX_APDU=50
|
||||
BFLAGS += -DBIG_ENDIAN=0
|
||||
BFLAGS += -DMAX_TSM_TRANSACTIONS=0
|
||||
#BFLAGS += -DCRC_USE_TABLE
|
||||
#BFLAGS += -DBACAPP_REAL
|
||||
#BFLAGS += -DBACAPP_OBJECT_ID
|
||||
#BFLAGS += -DBACAPP_UNSIGNED
|
||||
#BFLAGS += -DBACAPP_ENUMERATED
|
||||
#BFLAGS += -DBACAPP_CHARACTER_STRING
|
||||
#BFLAGS += -DWRITE_PROPERTY
|
||||
BFLAGS += -DMAX_ANALOG_VALUES=0
|
||||
BFLAGS += -DMAX_BINARY_VALUES=0
|
||||
CFLAGS = $(COMMON)
|
||||
# dead code removal
|
||||
CFLAGS += -ffunction-sections -fdata-sections
|
||||
CFLAGS += -Wall -gdwarf-2 $(BFLAGS) $(OPTIMIZATION) -fsigned-char
|
||||
CFLAGS += -MD -MP -MT $(*F).o -MF dep/$(@F).d
|
||||
|
||||
## Assembly specific flags
|
||||
ASMFLAGS = $(COMMON)
|
||||
ASMFLAGS += $(CFLAGS)
|
||||
ASMFLAGS += -x assembler-with-cpp -Wa,-gdwarf2
|
||||
|
||||
## Linker flags
|
||||
LDFLAGS = $(COMMON)
|
||||
#dead code removal
|
||||
#LDFLAGS += -Wl,-nostartfiles,-nostdlib
|
||||
LDFLAGS += -Wl,--gc-sections,-static
|
||||
LDFLAGS += -Wl,-Map=$(TARGET).map,-L.,-l$(TARGET)
|
||||
#LDFLAGS += -Wl,-Map=$(TARGET).map
|
||||
|
||||
## Intel Hex file production flags
|
||||
HEX_FLASH_FLAGS = -R .eeprom
|
||||
HEX_EEPROM_FLAGS = -j .eeprom
|
||||
HEX_EEPROM_FLAGS += --set-section-flags=.eeprom="alloc,load"
|
||||
HEX_EEPROM_FLAGS += --change-section-lma .eeprom=0 --no-change-warnings
|
||||
|
||||
## Objects that must be built in order to link
|
||||
OBJECTS = $(COBJ) $(DEMOOBJ)
|
||||
#OBJECTS = $(COBJ)
|
||||
|
||||
## Build
|
||||
TARGET_ELF=$(TARGET).elf
|
||||
|
||||
all: $(LIBRARY) $(TARGET_ELF) $(TARGET).hex $(TARGET).eep $(TARGET).lst \
|
||||
size Makefile
|
||||
|
||||
##Link
|
||||
$(TARGET_ELF): $(OBJECTS) $(LIBRARY)
|
||||
$(CC) $(OBJECTS) $(LDFLAGS) -o $@
|
||||
|
||||
%.hex: $(TARGET_ELF)
|
||||
$(OBJCOPY) -O ihex $(HEX_FLASH_FLAGS) $< $@
|
||||
|
||||
%.eep: $(TARGET_ELF)
|
||||
-$(OBJCOPY) $(HEX_EEPROM_FLAGS) -O ihex $< $@ || exit 0
|
||||
|
||||
%.lst: $(TARGET_ELF)
|
||||
$(OBJDUMP) -h -S $< > $@
|
||||
|
||||
lib: $(LIBRARY)
|
||||
|
||||
$(LIBRARY): $(COREOBJ) Makefile
|
||||
$(AR) rcs $@ $(COREOBJ)
|
||||
$(OBJDUMP) --syms $@ > $(LIBRARY:.a=.lst)
|
||||
|
||||
.c.o:
|
||||
$(CC) -c $(INCLUDES) $(CFLAGS) $*.c -o $@
|
||||
|
||||
size: ${TARGET_ELF}
|
||||
@echo
|
||||
@${SIZE} -C --mcu=${MCU} ${TARGET_ELF}
|
||||
|
||||
## Clean target
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-rm -rf $(OBJECTS) $(TARGET_ELF) dep/*
|
||||
-rm -rf $(LIBRARY) $(COREOBJ) $(LIBRARY:.a=.lst)
|
||||
-rm -rf $(TARGET).hex $(TARGET).eep $(TARGET).lst $(TARGET).map
|
||||
|
||||
## Other dependencies
|
||||
-include $(shell mkdir dep 2>/dev/null) $(wildcard dep/*)
|
||||
###############################################################################
|
||||
# Makefile for BACnet
|
||||
###############################################################################
|
||||
|
||||
## General Flags
|
||||
PROJECT = bacnet
|
||||
MCU = atmega168
|
||||
TARGET = bacnet
|
||||
## Tools
|
||||
CC = avr-gcc
|
||||
AR = avr-ar
|
||||
OBJCOPY = avr-objcopy
|
||||
OBJDUMP = avr-objdump
|
||||
SIZE = avr-size
|
||||
|
||||
# Source locations
|
||||
BACNET_CORE = ../../src
|
||||
BACNET_INCLUDE = ../../include
|
||||
BACNET_DEMO = ../../demo
|
||||
|
||||
# local files for this project
|
||||
CSRC = main.c \
|
||||
timer.c \
|
||||
rs485.c \
|
||||
dlmstp.c \
|
||||
apdu.c \
|
||||
$(BACNET_CORE)/crc.c
|
||||
|
||||
# common demo files needed
|
||||
DEMOSRC = h_rp.c \
|
||||
device.c \
|
||||
$(BACNET_DEMO)/handler/txbuf.c \
|
||||
$(BACNET_DEMO)/handler/h_npdu.c \
|
||||
$(BACNET_DEMO)/handler/noserv.c
|
||||
|
||||
# core BACnet stack files
|
||||
CORESRC = \
|
||||
$(BACNET_CORE)/apdu.c \
|
||||
$(BACNET_CORE)/npdu.c \
|
||||
$(BACNET_CORE)/bacdcode.c \
|
||||
$(BACNET_CORE)/bacint.c \
|
||||
$(BACNET_CORE)/bacreal.c \
|
||||
$(BACNET_CORE)/bacstr.c \
|
||||
$(BACNET_CORE)/rp.c \
|
||||
$(BACNET_CORE)/bacaddr.c \
|
||||
$(BACNET_CORE)/abort.c \
|
||||
$(BACNET_CORE)/reject.c \
|
||||
$(BACNET_CORE)/bacerror.c \
|
||||
$(BACNET_CORE)/bacapp.c
|
||||
|
||||
# $(BACNET_CORE)/iam.c \
|
||||
# $(BACNET_CORE)/whois.c \
|
||||
# $(BACNET_CORE)/wp.c \
|
||||
# $(BACNET_CORE)/version.c
|
||||
# $(BACNET_CORE)/bacprop.c \
|
||||
# $(BACNET_CORE)/bactext.c \
|
||||
# $(BACNET_CORE)/datetime.c \
|
||||
# $(BACNET_CORE)/indtext.c \
|
||||
# $(BACNET_CORE)/bigend.c \
|
||||
# $(BACNET_CORE)/arf.c \
|
||||
# $(BACNET_CORE)/awf.c \
|
||||
# $(BACNET_CORE)/cov.c \
|
||||
# $(BACNET_CORE)/dcc.c \
|
||||
# $(BACNET_CORE)/iam/iam_client.c \
|
||||
# $(BACNET_CORE)/ihave.c \
|
||||
# $(BACNET_CORE)/rd.c \
|
||||
# $(BACNET_CORE)/rpm.c \
|
||||
# $(BACNET_CORE)/timesync.c \
|
||||
# $(BACNET_CORE)/whohas.c \
|
||||
# $(BACNET_CORE)/filename.c \
|
||||
# $(BACNET_CORE)/tsm.c \
|
||||
# $(BACNET_CORE)/address.c \
|
||||
|
||||
## Include Directories
|
||||
INCLUDES = -I. -I$(BACNET_INCLUDE)
|
||||
|
||||
# Source to Object conversion
|
||||
COBJ = $(CSRC:.c=.o)
|
||||
DEMOOBJ = $(DEMOSRC:.c=.o)
|
||||
COREOBJ = $(CORESRC:.c=.o)
|
||||
|
||||
LIBRARY = lib$(TARGET).a
|
||||
|
||||
## Options common to compile, link and assembly rules
|
||||
COMMON = -mmcu=$(MCU)
|
||||
|
||||
OPTIMIZE_FLAGS = -mcall-prologues
|
||||
#OPTIMIZE_FLAGS += -finline-functions
|
||||
OPTIMIZE_FLAGS += -finline-functions-called-once
|
||||
#OPTIMIZATION = -O0
|
||||
#OPTIMIZATION = -Os
|
||||
OPTIMIZATION = -Os $(OPTIMIZE_FLAGS)
|
||||
#OPTIMIZATION = -O3 $(OPTIMIZE_FLAGS)
|
||||
|
||||
## Compile options common for all C compilation units.
|
||||
BFLAGS = -DBACDL_MSTP
|
||||
BFLAGS += -DMAX_APDU=50
|
||||
BFLAGS += -DBIG_ENDIAN=0
|
||||
BFLAGS += -DMAX_TSM_TRANSACTIONS=0
|
||||
#BFLAGS += -DCRC_USE_TABLE
|
||||
#BFLAGS += -DBACAPP_REAL
|
||||
#BFLAGS += -DBACAPP_OBJECT_ID
|
||||
#BFLAGS += -DBACAPP_UNSIGNED
|
||||
#BFLAGS += -DBACAPP_ENUMERATED
|
||||
#BFLAGS += -DBACAPP_CHARACTER_STRING
|
||||
#BFLAGS += -DWRITE_PROPERTY
|
||||
BFLAGS += -DMAX_ANALOG_VALUES=0
|
||||
BFLAGS += -DMAX_BINARY_VALUES=0
|
||||
CFLAGS = $(COMMON)
|
||||
# dead code removal
|
||||
CFLAGS += -ffunction-sections -fdata-sections
|
||||
CFLAGS += -Wall -gdwarf-2 $(BFLAGS) $(OPTIMIZATION) -fsigned-char
|
||||
CFLAGS += -MD -MP -MT $(*F).o -MF dep/$(@F).d
|
||||
|
||||
## Assembly specific flags
|
||||
ASMFLAGS = $(COMMON)
|
||||
ASMFLAGS += $(CFLAGS)
|
||||
ASMFLAGS += -x assembler-with-cpp -Wa,-gdwarf2
|
||||
|
||||
## Linker flags
|
||||
LDFLAGS = $(COMMON)
|
||||
#dead code removal
|
||||
#LDFLAGS += -Wl,-nostartfiles,-nostdlib
|
||||
LDFLAGS += -Wl,--gc-sections,-static
|
||||
LDFLAGS += -Wl,-Map=$(TARGET).map,-L.,-l$(TARGET)
|
||||
#LDFLAGS += -Wl,-Map=$(TARGET).map
|
||||
|
||||
## Intel Hex file production flags
|
||||
HEX_FLASH_FLAGS = -R .eeprom
|
||||
HEX_EEPROM_FLAGS = -j .eeprom
|
||||
HEX_EEPROM_FLAGS += --set-section-flags=.eeprom="alloc,load"
|
||||
HEX_EEPROM_FLAGS += --change-section-lma .eeprom=0 --no-change-warnings
|
||||
|
||||
## Objects that must be built in order to link
|
||||
OBJECTS = $(COBJ) $(DEMOOBJ)
|
||||
#OBJECTS = $(COBJ)
|
||||
|
||||
## Build
|
||||
TARGET_ELF=$(TARGET).elf
|
||||
|
||||
all: $(LIBRARY) $(TARGET_ELF) $(TARGET).hex $(TARGET).eep $(TARGET).lst \
|
||||
size Makefile
|
||||
|
||||
##Link
|
||||
$(TARGET_ELF): $(OBJECTS) $(LIBRARY)
|
||||
$(CC) $(OBJECTS) $(LDFLAGS) -o $@
|
||||
|
||||
%.hex: $(TARGET_ELF)
|
||||
$(OBJCOPY) -O ihex $(HEX_FLASH_FLAGS) $< $@
|
||||
|
||||
%.eep: $(TARGET_ELF)
|
||||
-$(OBJCOPY) $(HEX_EEPROM_FLAGS) -O ihex $< $@ || exit 0
|
||||
|
||||
%.lst: $(TARGET_ELF)
|
||||
$(OBJDUMP) -h -S $< > $@
|
||||
|
||||
lib: $(LIBRARY)
|
||||
|
||||
$(LIBRARY): $(COREOBJ) Makefile
|
||||
$(AR) rcs $@ $(COREOBJ)
|
||||
$(OBJDUMP) --syms $@ > $(LIBRARY:.a=.lst)
|
||||
|
||||
.c.o:
|
||||
$(CC) -c $(INCLUDES) $(CFLAGS) $*.c -o $@
|
||||
|
||||
size: ${TARGET_ELF}
|
||||
@echo
|
||||
@${SIZE} -C --mcu=${MCU} ${TARGET_ELF}
|
||||
|
||||
## Clean target
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-rm -rf $(OBJECTS) $(TARGET_ELF) dep/*
|
||||
-rm -rf $(LIBRARY) $(COREOBJ) $(LIBRARY:.a=.lst)
|
||||
-rm -rf $(TARGET).hex $(TARGET).eep $(TARGET).lst $(TARGET).map
|
||||
|
||||
## Other dependencies
|
||||
-include $(shell mkdir dep 2>/dev/null) $(wildcard dep/*)
|
||||
|
||||
@@ -1,45 +1,45 @@
|
||||
This port was originally done with the Atmel ATmega168
|
||||
I used the following tools:
|
||||
1. The WinAVR compiler avr-gcc (GCC) 4.1.2 (WinAVR 20070525)
|
||||
and tools from <http://winavr.sourceforge.net/>, hints and
|
||||
sample code from <http://www.avrfreaks.net/> and
|
||||
<http://savannah.gnu.org/projects/avr-libc/>.
|
||||
"avr-binutils, avr-gcc, and avr-libc form the heart of the
|
||||
Free Software toolchain for the Atmel AVR microcontrollers."
|
||||
2. AVR Studio 4 from Atmel <http://atmel.com/>
|
||||
|
||||
The hardware is expected to utilize the signals as defined
|
||||
in the spreadsheet hardware.ods (OpenOffice.org calc).
|
||||
Attach a DS75176 RS-485 transceiver (or similar) to the USART.
|
||||
DS75176 ATmega168
|
||||
------ ---------
|
||||
RO RXD
|
||||
/RE --choice of I/O
|
||||
DE --choice of I/O
|
||||
DI TXD
|
||||
GND GND
|
||||
DO --to RS-485 wire
|
||||
DO --to RS-485 wire
|
||||
+5V From 5V Regulator
|
||||
|
||||
The makefile allows you to build a simple server.
|
||||
dlmstp is the datalink layer for MS/TP over RS-485.
|
||||
This project uses an MS/TP Slave Node.
|
||||
|
||||
I used the makefile from the command line on Windows:
|
||||
C:\code\bacnet-stack\ports\atmega168> make clean all
|
||||
|
||||
The BACnet Capabilities include ReadProperty support.
|
||||
The BACnet objects include only a Device object.
|
||||
All required object properties can be retrieved using ReadProperty.
|
||||
|
||||
With full optimization, the statistics on the demo are:
|
||||
|
||||
avr-gcc (GCC) 4.2.2 (WinAVR 20071221rc1)
|
||||
Device: atmega168
|
||||
Program: 8734 bytes (53.3% Full)
|
||||
Data: 254 bytes (24.8% Full) (does not include CStack)
|
||||
|
||||
Hopefully you find this code useful!
|
||||
|
||||
Steve Karg <skarg@users.sourceforge.net>
|
||||
This port was originally done with the Atmel ATmega168
|
||||
I used the following tools:
|
||||
1. The WinAVR compiler avr-gcc (GCC) 4.1.2 (WinAVR 20070525)
|
||||
and tools from <http://winavr.sourceforge.net/>, hints and
|
||||
sample code from <http://www.avrfreaks.net/> and
|
||||
<http://savannah.gnu.org/projects/avr-libc/>.
|
||||
"avr-binutils, avr-gcc, and avr-libc form the heart of the
|
||||
Free Software toolchain for the Atmel AVR microcontrollers."
|
||||
2. AVR Studio 4 from Atmel <http://atmel.com/>
|
||||
|
||||
The hardware is expected to utilize the signals as defined
|
||||
in the spreadsheet hardware.ods (OpenOffice.org calc).
|
||||
Attach a DS75176 RS-485 transceiver (or similar) to the USART.
|
||||
DS75176 ATmega168
|
||||
------ ---------
|
||||
RO RXD
|
||||
/RE --choice of I/O
|
||||
DE --choice of I/O
|
||||
DI TXD
|
||||
GND GND
|
||||
DO --to RS-485 wire
|
||||
DO --to RS-485 wire
|
||||
+5V From 5V Regulator
|
||||
|
||||
The makefile allows you to build a simple server.
|
||||
dlmstp is the datalink layer for MS/TP over RS-485.
|
||||
This project uses an MS/TP Slave Node.
|
||||
|
||||
I used the makefile from the command line on Windows:
|
||||
C:\code\bacnet-stack\ports\atmega168> make clean all
|
||||
|
||||
The BACnet Capabilities include ReadProperty support.
|
||||
The BACnet objects include only a Device object.
|
||||
All required object properties can be retrieved using ReadProperty.
|
||||
|
||||
With full optimization, the statistics on the demo are:
|
||||
|
||||
avr-gcc (GCC) 4.2.2 (WinAVR 20071221rc1)
|
||||
Device: atmega168
|
||||
Program: 8734 bytes (53.3% Full)
|
||||
Data: 254 bytes (24.8% Full) (does not include CStack)
|
||||
|
||||
Hopefully you find this code useful!
|
||||
|
||||
Steve Karg <skarg@users.sourceforge.net>
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
Made with the free Dev-C++ IDE
|
||||
|
||||
http://bloodshed.net/dev/
|
||||
Made with the free Dev-C++ IDE
|
||||
|
||||
http://bloodshed.net/dev/
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,10 +1,10 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
|
||||
<workspace>
|
||||
<project>
|
||||
<path>$WS_DIR$\bacnet.ewp</path>
|
||||
</project>
|
||||
<batchBuild/>
|
||||
</workspace>
|
||||
|
||||
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
|
||||
<workspace>
|
||||
<project>
|
||||
<path>$WS_DIR$\bacnet.ewp</path>
|
||||
</project>
|
||||
<batchBuild/>
|
||||
</workspace>
|
||||
|
||||
|
||||
|
||||
@@ -15,8 +15,8 @@ ATmega323 iom323.h 64 16 256 0x73 0x1E 0x95 0x01 UBRRL UCSRB UCSRA TXEN RXEN TXC
|
||||
ATmega329 iom329.h 64 32 256 0x1E 0x95 0x03 UBRR UCSRB UCSRA TXEN RXEN TXC RXC UDR SPMCSR
|
||||
ATmega3290 iom3290.h 64 32 256 0x1E 0x95 0x04 UBRR UCSRB UCSRA TXEN RXEN TXC RXC UDR SPMCSR
|
||||
ATmega64 iom64.h 128 32 256 0x46 0x1E 0x96 0x02 UBRR0L UCSR0B UCSR0A TXEN0 RXEN0 TXC0 RXC0 UDR0 SPMCR
|
||||
ATmega644 iom644.h 128 32 256 0x1E 0x96 0x09 UBRR0 UCSR0B UCSR0A TXEN0 RXEN0 TXC0 RXC0 UDR0 SPMCSR
|
||||
ATmega644P iom644.h 128 32 256 0x1E 0x96 0x0A UBRR1 UCSR1B UCSR1A TXEN1 RXEN1 TXC1 RXC1 UDR1 SPMCSR
|
||||
ATmega644 iom644.h 128 32 256 0x1E 0x96 0x09 UBRR0 UCSR0B UCSR0A TXEN0 RXEN0 TXC0 RXC0 UDR0 SPMCSR
|
||||
ATmega644P iom644.h 128 32 256 0x1E 0x96 0x0A UBRR1 UCSR1B UCSR1A TXEN1 RXEN1 TXC1 RXC1 UDR1 SPMCSR
|
||||
ATmega649 iom649.h 128 32 256 0x1E 0x96 0x03 UBRR UCSRB UCSRA TXEN RXEN TXC RXC UDR SPMCSR
|
||||
ATmega6490 iom6490.h 128 32 256 0x1E 0x96 0x04 UBRR UCSRB UCSRA TXEN RXEN TXC RXC UDR SPMCSR
|
||||
ATmega128 iom128.h 128 32 512 0x44 0x1E 0x97 0x02 UBRR0L UCSR0B UCSR0A TXEN0 RXEN0 TXC0 RXC0 UDR0 SPMCSR
|
||||
|
||||
Binary file not shown.
@@ -32,6 +32,8 @@
|
||||
#include "bo.h"
|
||||
#include "rs485.h"
|
||||
#include "dlmstp.h"
|
||||
#include "seeprom.h"
|
||||
#include "nvdata.h"
|
||||
/* me */
|
||||
#include "test.h"
|
||||
|
||||
@@ -117,6 +119,7 @@ void test_task(
|
||||
void)
|
||||
{
|
||||
uint8_t data_register = 0;
|
||||
uint16_t id = 0;
|
||||
|
||||
if (timer_interval_expired(&Test_Timer)) {
|
||||
timer_interval_reset(&Test_Timer);
|
||||
@@ -159,13 +162,20 @@ void test_task(
|
||||
case '9':
|
||||
rs485_baud_rate_set(9600);
|
||||
break;
|
||||
case 'e':
|
||||
seeprom_bytes_read(NV_SEEPROM_TYPE_0, (uint8_t *) &id, 2);
|
||||
sprintf(Send_Buffer, "\r\n%04X", id);
|
||||
serial_bytes_send((uint8_t *) Send_Buffer, strlen(Send_Buffer));
|
||||
break;
|
||||
case 'b':
|
||||
sprintf(Send_Buffer, "\r\n%lubps",
|
||||
(unsigned long) rs485_baud_rate());
|
||||
serial_bytes_send((uint8_t *) Send_Buffer, strlen(Send_Buffer));
|
||||
break;
|
||||
case 'm':
|
||||
sprintf(Send_Buffer, "\r\nMax:%u",
|
||||
(unsigned) dlmstp_max_master());
|
||||
serial_bytes_send((uint8_t *) Send_Buffer, strlen(Send_Buffer));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -1,431 +1,431 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright (C) 2009 Steve Karg <skarg@users.sourceforge.net>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*********************************************************************/
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "timer.h"
|
||||
|
||||
/* generic elapsed timer handling */
|
||||
/* interval not to exceed 49.7 days */
|
||||
/* interval of 1ms may be 0 to 1ms */
|
||||
|
||||
/*************************************************************************
|
||||
* Description: Sets the start time for an elapsed timer
|
||||
* Returns: the value of the start timer
|
||||
* Notes: none
|
||||
*************************************************************************/
|
||||
void timer_elapsed_start(
|
||||
struct etimer *t)
|
||||
{
|
||||
uint32_t now = timer_milliseconds();
|
||||
|
||||
if (t) {
|
||||
t->start = now;
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Description: Gets the amount of elapsed time in milliseconds
|
||||
* Returns: elapsed time in milliseconds
|
||||
* Notes: none
|
||||
*************************************************************************/
|
||||
uint32_t timer_elapsed_time(
|
||||
struct etimer *t)
|
||||
{
|
||||
uint32_t now = timer_milliseconds();
|
||||
uint32_t delta = 0;
|
||||
|
||||
if (t) {
|
||||
delta = now - t->start;
|
||||
}
|
||||
|
||||
return delta;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Description: Sets the start time with an offset
|
||||
* Returns: elapsed time in milliseconds
|
||||
* Notes: none
|
||||
*************************************************************************/
|
||||
void timer_elapsed_start_offset(
|
||||
struct etimer *t,
|
||||
uint32_t offset)
|
||||
{
|
||||
uint32_t now = timer_milliseconds();
|
||||
|
||||
if (t) {
|
||||
t->start = now + offset;
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Description: Tests to see if time has elapsed
|
||||
* Returns: true if time has elapsed
|
||||
* Notes: none
|
||||
*************************************************************************/
|
||||
bool timer_elapsed_milliseconds(
|
||||
struct etimer *t,
|
||||
uint32_t milliseconds)
|
||||
{
|
||||
return (timer_elapsed_time(t) >= milliseconds);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Description: Tests to see if time has elapsed
|
||||
* Returns: true if time has elapsed
|
||||
* Notes: none
|
||||
*************************************************************************/
|
||||
bool timer_elapsed_seconds(
|
||||
struct etimer * t,
|
||||
uint32_t seconds)
|
||||
{
|
||||
uint32_t milliseconds = seconds;
|
||||
|
||||
milliseconds *= 1000L;
|
||||
|
||||
return timer_elapsed_milliseconds(t, milliseconds);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Description: Tests to see if time has elapsed
|
||||
* Returns: true if time has elapsed
|
||||
* Notes: none
|
||||
*************************************************************************/
|
||||
bool timer_elapsed_minutes(
|
||||
struct etimer * t,
|
||||
uint32_t minutes)
|
||||
{
|
||||
uint32_t milliseconds = minutes;
|
||||
|
||||
milliseconds *= 1000L;
|
||||
milliseconds *= 60L;
|
||||
|
||||
return timer_elapsed_milliseconds(t, milliseconds);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Description: Tests to see if time has elapsed
|
||||
* Returns: true if time has elapsed
|
||||
* Notes: none
|
||||
*************************************************************************/
|
||||
bool timer_elapsed_milliseconds_short(
|
||||
struct etimer * t,
|
||||
uint16_t value)
|
||||
{
|
||||
uint32_t milliseconds;
|
||||
|
||||
milliseconds = value;
|
||||
|
||||
return (timer_elapsed_time(t) >= milliseconds);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Description: Tests to see if time has elapsed
|
||||
* Returns: true if time has elapsed
|
||||
* Notes: none
|
||||
*************************************************************************/
|
||||
bool timer_elapsed_seconds_short(
|
||||
struct etimer * t,
|
||||
uint16_t value)
|
||||
{
|
||||
return timer_elapsed_seconds(t, value);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Description: Tests to see if time has elapsed
|
||||
* Returns: true if time has elapsed
|
||||
* Notes: none
|
||||
*************************************************************************/
|
||||
bool timer_elapsed_minutes_short(
|
||||
struct etimer * t,
|
||||
uint16_t value)
|
||||
{
|
||||
return timer_elapsed_minutes(t, value);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Description: Starts an interval timer
|
||||
* Returns: nothing
|
||||
* Notes: none
|
||||
*************************************************************************/
|
||||
void timer_interval_start(
|
||||
struct itimer *t,
|
||||
uint32_t interval)
|
||||
{
|
||||
if (t) {
|
||||
t->start = timer_milliseconds();
|
||||
t->interval = interval;
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Description: Starts an interval timer
|
||||
* Returns: nothing
|
||||
* Notes: none
|
||||
*************************************************************************/
|
||||
void timer_interval_start_seconds(
|
||||
struct itimer *t,
|
||||
uint32_t seconds)
|
||||
{
|
||||
uint32_t interval = seconds;
|
||||
|
||||
interval *= 1000L;
|
||||
timer_interval_start(t, interval);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Description: Starts an interval timer
|
||||
* Returns: nothing
|
||||
* Notes: none
|
||||
*************************************************************************/
|
||||
void timer_interval_start_minutes(
|
||||
struct itimer *t,
|
||||
uint32_t minutes)
|
||||
{
|
||||
uint32_t interval = minutes;
|
||||
|
||||
interval *= 1000L;
|
||||
interval *= 60L;
|
||||
timer_interval_start(t, interval);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Description: Determines the amount of time that has elapsed
|
||||
* Returns: elapsed milliseconds
|
||||
* Notes: none
|
||||
*************************************************************************/
|
||||
uint32_t timer_interval_elapsed(
|
||||
struct itimer *t)
|
||||
{
|
||||
uint32_t now = timer_milliseconds();
|
||||
uint32_t delta = 0;
|
||||
|
||||
if (t) {
|
||||
delta = now - t->start;
|
||||
}
|
||||
|
||||
return delta;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Description: Determines the amount of time that has elapsed
|
||||
* Returns: elapsed milliseconds
|
||||
* Notes: none
|
||||
*************************************************************************/
|
||||
uint32_t timer_interval(
|
||||
struct itimer * t)
|
||||
{
|
||||
uint32_t interval = 0;
|
||||
|
||||
if (t) {
|
||||
interval = t->interval;
|
||||
}
|
||||
|
||||
return interval;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Description: Tests to see if time has elapsed
|
||||
* Returns: true if time has elapsed
|
||||
* Notes: none
|
||||
*************************************************************************/
|
||||
bool timer_interval_expired(
|
||||
struct itimer * t)
|
||||
{
|
||||
bool expired = false;
|
||||
|
||||
if (t) {
|
||||
if (t->interval) {
|
||||
expired = timer_interval_elapsed(t) >= t->interval;
|
||||
}
|
||||
}
|
||||
|
||||
return expired;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Description: Sets the interval value to zero so it never expires
|
||||
* Returns: nothing
|
||||
* Notes: none
|
||||
*************************************************************************/
|
||||
void timer_interval_no_expire(
|
||||
struct itimer *t)
|
||||
{
|
||||
if (t) {
|
||||
t->interval = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Description: Adds another interval to the start time. Used for cyclic
|
||||
* timers that won't lose ticks.
|
||||
* Returns: nothing
|
||||
* Notes: none
|
||||
*************************************************************************/
|
||||
void timer_interval_reset(
|
||||
struct itimer *t)
|
||||
{
|
||||
if (t) {
|
||||
t->start += t->interval;
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Description: Restarts the timer with the same interval
|
||||
* Returns: nothing
|
||||
* Notes: none
|
||||
*************************************************************************/
|
||||
void timer_interval_restart(
|
||||
struct itimer *t)
|
||||
{
|
||||
if (t) {
|
||||
t->start = timer_milliseconds();
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Description: Return the elapsed time
|
||||
* Returns: number of milliseconds elapsed
|
||||
* Notes: only up to 255ms elapsed
|
||||
**************************************************************************/
|
||||
uint8_t timer_milliseconds_delta(
|
||||
uint8_t start)
|
||||
{
|
||||
return (timer_milliseconds_byte() - start);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Description: Mark the start of a delta timer
|
||||
* Returns: mark timer starting tick
|
||||
* Notes: only up to 255ms elapsed
|
||||
**************************************************************************/
|
||||
uint8_t timer_milliseconds_mark(
|
||||
void)
|
||||
{
|
||||
return timer_milliseconds_byte();
|
||||
}
|
||||
|
||||
#ifdef TEST
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "ctest.h"
|
||||
|
||||
static uint32_t Milliseconds;
|
||||
|
||||
uint32_t timer_milliseconds(
|
||||
void)
|
||||
{
|
||||
return Milliseconds;
|
||||
}
|
||||
|
||||
uint32_t timer_milliseconds_set(
|
||||
uint32_t value)
|
||||
{
|
||||
uint32_t old_value = Milliseconds;
|
||||
|
||||
Milliseconds = value;
|
||||
|
||||
return old_value;
|
||||
}
|
||||
|
||||
void testElapsedTimer(
|
||||
Test * pTest)
|
||||
{
|
||||
struct etimer t;
|
||||
uint32_t test_time = 0;
|
||||
|
||||
timer_milliseconds_set(test_time);
|
||||
timer_elapsed_start(&t);
|
||||
ct_test(pTest, timer_elapsed_time(&t) == test_time);
|
||||
test_time = 0xffff;
|
||||
timer_milliseconds_set(test_time);
|
||||
ct_test(pTest, timer_elapsed_time(&t) == test_time);
|
||||
test_time = 0xffffffff;
|
||||
timer_milliseconds_set(test_time);
|
||||
ct_test(pTest, timer_elapsed_time(&t) == test_time);
|
||||
}
|
||||
|
||||
void testIntervalTimer(
|
||||
Test * pTest)
|
||||
{
|
||||
struct itimer t;
|
||||
uint32_t interval = 0;
|
||||
uint32_t test_time = 0;
|
||||
|
||||
timer_milliseconds_set(test_time);
|
||||
timer_interval_start(&t, interval);
|
||||
test_time = 0xffff;
|
||||
timer_milliseconds_set(test_time);
|
||||
ct_test(pTest, timer_interval(&t) == interval);
|
||||
ct_test(pTest, timer_interval_elapsed(&t) == test_time);
|
||||
test_time = 0xffffffff;
|
||||
timer_milliseconds_set(test_time);
|
||||
ct_test(pTest, timer_interval(&t) == interval);
|
||||
ct_test(pTest, timer_interval_elapsed(&t) == test_time);
|
||||
test_time = 0;
|
||||
timer_milliseconds_set(test_time);
|
||||
interval = 0xffff;
|
||||
timer_interval_start(&t, interval);
|
||||
ct_test(pTest, timer_interval(&t) == interval);
|
||||
interval = 0xffffffff;
|
||||
timer_interval_start(&t, interval);
|
||||
ct_test(pTest, timer_interval(&t) == interval);
|
||||
|
||||
interval = 0;
|
||||
timer_interval_start_seconds(&t, interval);
|
||||
ct_test(pTest, timer_interval(&t) == interval);
|
||||
interval = 60L;
|
||||
timer_interval_start_seconds(&t, interval);
|
||||
interval *= 1000L;
|
||||
ct_test(pTest, timer_interval(&t) == interval);
|
||||
|
||||
}
|
||||
|
||||
|
||||
#ifdef TEST_TIMER
|
||||
int main(
|
||||
void)
|
||||
{
|
||||
Test *pTest;
|
||||
bool rc;
|
||||
|
||||
pTest = ct_create("Timer", NULL);
|
||||
|
||||
/* individual tests */
|
||||
rc = ct_addTestFunction(pTest, testElapsedTimer);
|
||||
assert(rc);
|
||||
rc = ct_addTestFunction(pTest, testIntervalTimer);
|
||||
assert(rc);
|
||||
|
||||
|
||||
ct_setStream(pTest, stdout);
|
||||
ct_run(pTest);
|
||||
(void) ct_report(pTest);
|
||||
|
||||
ct_destroy(pTest);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright (C) 2009 Steve Karg <skarg@users.sourceforge.net>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*********************************************************************/
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "timer.h"
|
||||
|
||||
/* generic elapsed timer handling */
|
||||
/* interval not to exceed 49.7 days */
|
||||
/* interval of 1ms may be 0 to 1ms */
|
||||
|
||||
/*************************************************************************
|
||||
* Description: Sets the start time for an elapsed timer
|
||||
* Returns: the value of the start timer
|
||||
* Notes: none
|
||||
*************************************************************************/
|
||||
void timer_elapsed_start(
|
||||
struct etimer *t)
|
||||
{
|
||||
uint32_t now = timer_milliseconds();
|
||||
|
||||
if (t) {
|
||||
t->start = now;
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Description: Gets the amount of elapsed time in milliseconds
|
||||
* Returns: elapsed time in milliseconds
|
||||
* Notes: none
|
||||
*************************************************************************/
|
||||
uint32_t timer_elapsed_time(
|
||||
struct etimer *t)
|
||||
{
|
||||
uint32_t now = timer_milliseconds();
|
||||
uint32_t delta = 0;
|
||||
|
||||
if (t) {
|
||||
delta = now - t->start;
|
||||
}
|
||||
|
||||
return delta;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Description: Sets the start time with an offset
|
||||
* Returns: elapsed time in milliseconds
|
||||
* Notes: none
|
||||
*************************************************************************/
|
||||
void timer_elapsed_start_offset(
|
||||
struct etimer *t,
|
||||
uint32_t offset)
|
||||
{
|
||||
uint32_t now = timer_milliseconds();
|
||||
|
||||
if (t) {
|
||||
t->start = now + offset;
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Description: Tests to see if time has elapsed
|
||||
* Returns: true if time has elapsed
|
||||
* Notes: none
|
||||
*************************************************************************/
|
||||
bool timer_elapsed_milliseconds(
|
||||
struct etimer *t,
|
||||
uint32_t milliseconds)
|
||||
{
|
||||
return (timer_elapsed_time(t) >= milliseconds);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Description: Tests to see if time has elapsed
|
||||
* Returns: true if time has elapsed
|
||||
* Notes: none
|
||||
*************************************************************************/
|
||||
bool timer_elapsed_seconds(
|
||||
struct etimer * t,
|
||||
uint32_t seconds)
|
||||
{
|
||||
uint32_t milliseconds = seconds;
|
||||
|
||||
milliseconds *= 1000L;
|
||||
|
||||
return timer_elapsed_milliseconds(t, milliseconds);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Description: Tests to see if time has elapsed
|
||||
* Returns: true if time has elapsed
|
||||
* Notes: none
|
||||
*************************************************************************/
|
||||
bool timer_elapsed_minutes(
|
||||
struct etimer * t,
|
||||
uint32_t minutes)
|
||||
{
|
||||
uint32_t milliseconds = minutes;
|
||||
|
||||
milliseconds *= 1000L;
|
||||
milliseconds *= 60L;
|
||||
|
||||
return timer_elapsed_milliseconds(t, milliseconds);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Description: Tests to see if time has elapsed
|
||||
* Returns: true if time has elapsed
|
||||
* Notes: none
|
||||
*************************************************************************/
|
||||
bool timer_elapsed_milliseconds_short(
|
||||
struct etimer * t,
|
||||
uint16_t value)
|
||||
{
|
||||
uint32_t milliseconds;
|
||||
|
||||
milliseconds = value;
|
||||
|
||||
return (timer_elapsed_time(t) >= milliseconds);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Description: Tests to see if time has elapsed
|
||||
* Returns: true if time has elapsed
|
||||
* Notes: none
|
||||
*************************************************************************/
|
||||
bool timer_elapsed_seconds_short(
|
||||
struct etimer * t,
|
||||
uint16_t value)
|
||||
{
|
||||
return timer_elapsed_seconds(t, value);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Description: Tests to see if time has elapsed
|
||||
* Returns: true if time has elapsed
|
||||
* Notes: none
|
||||
*************************************************************************/
|
||||
bool timer_elapsed_minutes_short(
|
||||
struct etimer * t,
|
||||
uint16_t value)
|
||||
{
|
||||
return timer_elapsed_minutes(t, value);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Description: Starts an interval timer
|
||||
* Returns: nothing
|
||||
* Notes: none
|
||||
*************************************************************************/
|
||||
void timer_interval_start(
|
||||
struct itimer *t,
|
||||
uint32_t interval)
|
||||
{
|
||||
if (t) {
|
||||
t->start = timer_milliseconds();
|
||||
t->interval = interval;
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Description: Starts an interval timer
|
||||
* Returns: nothing
|
||||
* Notes: none
|
||||
*************************************************************************/
|
||||
void timer_interval_start_seconds(
|
||||
struct itimer *t,
|
||||
uint32_t seconds)
|
||||
{
|
||||
uint32_t interval = seconds;
|
||||
|
||||
interval *= 1000L;
|
||||
timer_interval_start(t, interval);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Description: Starts an interval timer
|
||||
* Returns: nothing
|
||||
* Notes: none
|
||||
*************************************************************************/
|
||||
void timer_interval_start_minutes(
|
||||
struct itimer *t,
|
||||
uint32_t minutes)
|
||||
{
|
||||
uint32_t interval = minutes;
|
||||
|
||||
interval *= 1000L;
|
||||
interval *= 60L;
|
||||
timer_interval_start(t, interval);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Description: Determines the amount of time that has elapsed
|
||||
* Returns: elapsed milliseconds
|
||||
* Notes: none
|
||||
*************************************************************************/
|
||||
uint32_t timer_interval_elapsed(
|
||||
struct itimer *t)
|
||||
{
|
||||
uint32_t now = timer_milliseconds();
|
||||
uint32_t delta = 0;
|
||||
|
||||
if (t) {
|
||||
delta = now - t->start;
|
||||
}
|
||||
|
||||
return delta;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Description: Determines the amount of time that has elapsed
|
||||
* Returns: elapsed milliseconds
|
||||
* Notes: none
|
||||
*************************************************************************/
|
||||
uint32_t timer_interval(
|
||||
struct itimer * t)
|
||||
{
|
||||
uint32_t interval = 0;
|
||||
|
||||
if (t) {
|
||||
interval = t->interval;
|
||||
}
|
||||
|
||||
return interval;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Description: Tests to see if time has elapsed
|
||||
* Returns: true if time has elapsed
|
||||
* Notes: none
|
||||
*************************************************************************/
|
||||
bool timer_interval_expired(
|
||||
struct itimer * t)
|
||||
{
|
||||
bool expired = false;
|
||||
|
||||
if (t) {
|
||||
if (t->interval) {
|
||||
expired = timer_interval_elapsed(t) >= t->interval;
|
||||
}
|
||||
}
|
||||
|
||||
return expired;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Description: Sets the interval value to zero so it never expires
|
||||
* Returns: nothing
|
||||
* Notes: none
|
||||
*************************************************************************/
|
||||
void timer_interval_no_expire(
|
||||
struct itimer *t)
|
||||
{
|
||||
if (t) {
|
||||
t->interval = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Description: Adds another interval to the start time. Used for cyclic
|
||||
* timers that won't lose ticks.
|
||||
* Returns: nothing
|
||||
* Notes: none
|
||||
*************************************************************************/
|
||||
void timer_interval_reset(
|
||||
struct itimer *t)
|
||||
{
|
||||
if (t) {
|
||||
t->start += t->interval;
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Description: Restarts the timer with the same interval
|
||||
* Returns: nothing
|
||||
* Notes: none
|
||||
*************************************************************************/
|
||||
void timer_interval_restart(
|
||||
struct itimer *t)
|
||||
{
|
||||
if (t) {
|
||||
t->start = timer_milliseconds();
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Description: Return the elapsed time
|
||||
* Returns: number of milliseconds elapsed
|
||||
* Notes: only up to 255ms elapsed
|
||||
**************************************************************************/
|
||||
uint8_t timer_milliseconds_delta(
|
||||
uint8_t start)
|
||||
{
|
||||
return (timer_milliseconds_byte() - start);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Description: Mark the start of a delta timer
|
||||
* Returns: mark timer starting tick
|
||||
* Notes: only up to 255ms elapsed
|
||||
**************************************************************************/
|
||||
uint8_t timer_milliseconds_mark(
|
||||
void)
|
||||
{
|
||||
return timer_milliseconds_byte();
|
||||
}
|
||||
|
||||
#ifdef TEST
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "ctest.h"
|
||||
|
||||
static uint32_t Milliseconds;
|
||||
|
||||
uint32_t timer_milliseconds(
|
||||
void)
|
||||
{
|
||||
return Milliseconds;
|
||||
}
|
||||
|
||||
uint32_t timer_milliseconds_set(
|
||||
uint32_t value)
|
||||
{
|
||||
uint32_t old_value = Milliseconds;
|
||||
|
||||
Milliseconds = value;
|
||||
|
||||
return old_value;
|
||||
}
|
||||
|
||||
void testElapsedTimer(
|
||||
Test * pTest)
|
||||
{
|
||||
struct etimer t;
|
||||
uint32_t test_time = 0;
|
||||
|
||||
timer_milliseconds_set(test_time);
|
||||
timer_elapsed_start(&t);
|
||||
ct_test(pTest, timer_elapsed_time(&t) == test_time);
|
||||
test_time = 0xffff;
|
||||
timer_milliseconds_set(test_time);
|
||||
ct_test(pTest, timer_elapsed_time(&t) == test_time);
|
||||
test_time = 0xffffffff;
|
||||
timer_milliseconds_set(test_time);
|
||||
ct_test(pTest, timer_elapsed_time(&t) == test_time);
|
||||
}
|
||||
|
||||
void testIntervalTimer(
|
||||
Test * pTest)
|
||||
{
|
||||
struct itimer t;
|
||||
uint32_t interval = 0;
|
||||
uint32_t test_time = 0;
|
||||
|
||||
timer_milliseconds_set(test_time);
|
||||
timer_interval_start(&t, interval);
|
||||
test_time = 0xffff;
|
||||
timer_milliseconds_set(test_time);
|
||||
ct_test(pTest, timer_interval(&t) == interval);
|
||||
ct_test(pTest, timer_interval_elapsed(&t) == test_time);
|
||||
test_time = 0xffffffff;
|
||||
timer_milliseconds_set(test_time);
|
||||
ct_test(pTest, timer_interval(&t) == interval);
|
||||
ct_test(pTest, timer_interval_elapsed(&t) == test_time);
|
||||
test_time = 0;
|
||||
timer_milliseconds_set(test_time);
|
||||
interval = 0xffff;
|
||||
timer_interval_start(&t, interval);
|
||||
ct_test(pTest, timer_interval(&t) == interval);
|
||||
interval = 0xffffffff;
|
||||
timer_interval_start(&t, interval);
|
||||
ct_test(pTest, timer_interval(&t) == interval);
|
||||
|
||||
interval = 0;
|
||||
timer_interval_start_seconds(&t, interval);
|
||||
ct_test(pTest, timer_interval(&t) == interval);
|
||||
interval = 60L;
|
||||
timer_interval_start_seconds(&t, interval);
|
||||
interval *= 1000L;
|
||||
ct_test(pTest, timer_interval(&t) == interval);
|
||||
|
||||
}
|
||||
|
||||
|
||||
#ifdef TEST_TIMER
|
||||
int main(
|
||||
void)
|
||||
{
|
||||
Test *pTest;
|
||||
bool rc;
|
||||
|
||||
pTest = ct_create("Timer", NULL);
|
||||
|
||||
/* individual tests */
|
||||
rc = ct_addTestFunction(pTest, testElapsedTimer);
|
||||
assert(rc);
|
||||
rc = ct_addTestFunction(pTest, testIntervalTimer);
|
||||
assert(rc);
|
||||
|
||||
|
||||
ct_setStream(pTest, stdout);
|
||||
ct_run(pTest);
|
||||
(void) ct_report(pTest);
|
||||
|
||||
ct_destroy(pTest);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
BACnet Etherent
|
||||
Demonstrates the Ethernet peripheral by implmenting BACnet over Ethernet
|
||||
on the RX62N Development Kit. The project is compiled with the RX Standard
|
||||
Toolchain, and the default drivers included with the RX62N kit.
|
||||
|
||||
The project does not use any additional hardware.
|
||||
|
||||
The project was tested using a BACnet/IP to BACnet Ethernet router, using the bacnet-tools from the BACnet Protocol Stack site.
|
||||
BACnet Etherent
|
||||
Demonstrates the Ethernet peripheral by implmenting BACnet over Ethernet
|
||||
on the RX62N Development Kit. The project is compiled with the RX Standard
|
||||
Toolchain, and the default drivers included with the RX62N kit.
|
||||
|
||||
The project does not use any additional hardware.
|
||||
|
||||
The project was tested using a BACnet/IP to BACnet Ethernet router, using the bacnet-tools from the BACnet Protocol Stack site.
|
||||
|
||||
+2037
-2037
File diff suppressed because it is too large
Load Diff
@@ -1,10 +1,10 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
|
||||
<workspace>
|
||||
<project>
|
||||
<path>$WS_DIR$\bacnet.ewp</path>
|
||||
</project>
|
||||
<batchBuild/>
|
||||
</workspace>
|
||||
|
||||
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
|
||||
<workspace>
|
||||
<project>
|
||||
<path>$WS_DIR$\bacnet.ewp</path>
|
||||
</project>
|
||||
<batchBuild/>
|
||||
</workspace>
|
||||
|
||||
|
||||
|
||||
@@ -1,31 +1,31 @@
|
||||
This port was done with the STM32 ARM Cortex-M3 STM32F103RGT6 on
|
||||
a STM32 Discovery Kit using the STM32 CMSIS library and drivers
|
||||
and IAR EWARM 6.10 compiler.
|
||||
|
||||
The CMSIS library was 21MiB compressed, so I didn't include it
|
||||
as part of this project. The CMSIS and drivers
|
||||
can be found by following the 'Click here for STM32
|
||||
embedded firmware' link from the resources page:
|
||||
http://www.st.com/stonline/stappl/resourceSelector/app?page=resourceSelector&doctype=FIRMWARE&SubClassID=1169
|
||||
There will be a list of firmware resources.
|
||||
The library you are looking for is in the
|
||||
‘ARM-based 32-bit MCU STM32F10xxx standard peripheral library’.
|
||||
Download the
|
||||
‘ARM-based 32-bit MCU STM32F10xxx standard peripheral library’
|
||||
and the CMSIS library can be found in
|
||||
'…\STM32F10x_StdPeriph_Lib_V3.4.0\Libraries\CMSIS\CM3'.
|
||||
Copy the contents of 'CMSIS' to the 'CMSIS' folder in this project.
|
||||
and the drivers library can be found in
|
||||
'…\STM32F10x_StdPeriph_Lib_V3.4.0\Libraries\STM32F10x_StdPeriph_Driver'.
|
||||
Copy the contents of 'STM32F10x_StdPeriph_Driver' to the
|
||||
'drivers' folder in this project.
|
||||
|
||||
The hardware interface only uses the USART and a peripheral pin
|
||||
(RTS) for the MS/TP RS-485 interface, and the System Clock for
|
||||
the millisecond timer.
|
||||
|
||||
It was created for the STM32 Design Challenge on March 20, 2011,
|
||||
by Steve Karg. Although the design didn't win any awards,
|
||||
it was one of the six finalists and was on display at the
|
||||
STM booth at the 2010 Embedded Systems Conference West.
|
||||
http://www.stm32challenge.com/
|
||||
This port was done with the STM32 ARM Cortex-M3 STM32F103RGT6 on
|
||||
a STM32 Discovery Kit using the STM32 CMSIS library and drivers
|
||||
and IAR EWARM 6.10 compiler.
|
||||
|
||||
The CMSIS library was 21MiB compressed, so I didn't include it
|
||||
as part of this project. The CMSIS and drivers
|
||||
can be found by following the 'Click here for STM32
|
||||
embedded firmware' link from the resources page:
|
||||
http://www.st.com/stonline/stappl/resourceSelector/app?page=resourceSelector&doctype=FIRMWARE&SubClassID=1169
|
||||
There will be a list of firmware resources.
|
||||
The library you are looking for is in the
|
||||
‘ARM-based 32-bit MCU STM32F10xxx standard peripheral library’.
|
||||
Download the
|
||||
‘ARM-based 32-bit MCU STM32F10xxx standard peripheral library’
|
||||
and the CMSIS library can be found in
|
||||
'…\STM32F10x_StdPeriph_Lib_V3.4.0\Libraries\CMSIS\CM3'.
|
||||
Copy the contents of 'CMSIS' to the 'CMSIS' folder in this project.
|
||||
and the drivers library can be found in
|
||||
'…\STM32F10x_StdPeriph_Lib_V3.4.0\Libraries\STM32F10x_StdPeriph_Driver'.
|
||||
Copy the contents of 'STM32F10x_StdPeriph_Driver' to the
|
||||
'drivers' folder in this project.
|
||||
|
||||
The hardware interface only uses the USART and a peripheral pin
|
||||
(RTS) for the MS/TP RS-485 interface, and the System Clock for
|
||||
the millisecond timer.
|
||||
|
||||
It was created for the STM32 Design Challenge on March 20, 2011,
|
||||
by Steve Karg. Although the design didn't win any awards,
|
||||
it was one of the six finalists and was on display at the
|
||||
STM booth at the 2010 Embedded Systems Conference West.
|
||||
http://www.stm32challenge.com/
|
||||
|
||||
@@ -1,31 +1,31 @@
|
||||
/*###ICF### Section handled by ICF editor, don't touch! ****/
|
||||
/*-Editor annotation file-*/
|
||||
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
|
||||
/*-Specials-*/
|
||||
define symbol __ICFEDIT_intvec_start__ = 0x08000000;
|
||||
/*-Memory Regions-*/
|
||||
define symbol __ICFEDIT_region_ROM_start__ = 0x08000000 ;
|
||||
define symbol __ICFEDIT_region_ROM_end__ = 0x080FFFFF;
|
||||
define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
|
||||
define symbol __ICFEDIT_region_RAM_end__ = 0x20017FFF;
|
||||
/*-Sizes-*/
|
||||
define symbol __ICFEDIT_size_cstack__ = 0x800;
|
||||
define symbol __ICFEDIT_size_heap__ = 0x200;
|
||||
/**** End of ICF editor section. ###ICF###*/
|
||||
|
||||
|
||||
define memory mem with size = 4G;
|
||||
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
|
||||
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
|
||||
|
||||
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
|
||||
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
|
||||
|
||||
initialize by copy { readwrite };
|
||||
do not initialize { section .noinit };
|
||||
|
||||
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
|
||||
|
||||
place in ROM_region { readonly };
|
||||
place in RAM_region { readwrite,
|
||||
/*###ICF### Section handled by ICF editor, don't touch! ****/
|
||||
/*-Editor annotation file-*/
|
||||
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
|
||||
/*-Specials-*/
|
||||
define symbol __ICFEDIT_intvec_start__ = 0x08000000;
|
||||
/*-Memory Regions-*/
|
||||
define symbol __ICFEDIT_region_ROM_start__ = 0x08000000 ;
|
||||
define symbol __ICFEDIT_region_ROM_end__ = 0x080FFFFF;
|
||||
define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
|
||||
define symbol __ICFEDIT_region_RAM_end__ = 0x20017FFF;
|
||||
/*-Sizes-*/
|
||||
define symbol __ICFEDIT_size_cstack__ = 0x800;
|
||||
define symbol __ICFEDIT_size_heap__ = 0x200;
|
||||
/**** End of ICF editor section. ###ICF###*/
|
||||
|
||||
|
||||
define memory mem with size = 4G;
|
||||
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
|
||||
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
|
||||
|
||||
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
|
||||
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
|
||||
|
||||
initialize by copy { readwrite };
|
||||
do not initialize { section .noinit };
|
||||
|
||||
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
|
||||
|
||||
place in ROM_region { readonly };
|
||||
place in RAM_region { readwrite,
|
||||
block CSTACK, block HEAP };
|
||||
@@ -1,7 +1,7 @@
|
||||
@echo off
|
||||
echo Build for Borland 5.5 tools
|
||||
set BORLAND_DIR=c:\borland\bcc55
|
||||
%BORLAND_DIR%\bin\make -f makefile.mak clean
|
||||
%BORLAND_DIR%\bin\make -f makefile.mak all
|
||||
|
||||
|
||||
@echo off
|
||||
echo Build for Borland 5.5 tools
|
||||
set BORLAND_DIR=c:\borland\bcc55
|
||||
%BORLAND_DIR%\bin\make -f makefile.mak clean
|
||||
%BORLAND_DIR%\bin\make -f makefile.mak all
|
||||
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
BACnet Stack - Win32
|
||||
|
||||
This directory contains a demo program that compiles with a Win32 compiler.
|
||||
It was tested with the freely downloadable Borland C++ 5.5, as well as
|
||||
Borland C++ 5 and Visual C++ 6.0.
|
||||
|
||||
The makefile.mak file is used with the Borland command line tools.
|
||||
Run setvars.bat to configure the environment for the Borland tools.
|
||||
Edit it if necessary to set the correct location of your tools.
|
||||
|
||||
The bacnet.ide file is used with the Borland IDE.
|
||||
|
||||
The bacnet directory is used with Visual C++ 6 tools, and there is a
|
||||
workspace file bacnet.dsw that is used to compile the demo program.
|
||||
|
||||
BACnet Stack - Win32
|
||||
|
||||
This directory contains a demo program that compiles with a Win32 compiler.
|
||||
It was tested with the freely downloadable Borland C++ 5.5, as well as
|
||||
Borland C++ 5 and Visual C++ 6.0.
|
||||
|
||||
The makefile.mak file is used with the Borland command line tools.
|
||||
Run setvars.bat to configure the environment for the Borland tools.
|
||||
Edit it if necessary to set the correct location of your tools.
|
||||
|
||||
The bacnet.ide file is used with the Borland IDE.
|
||||
|
||||
The bacnet directory is used with Visual C++ 6 tools, and there is a
|
||||
workspace file bacnet.dsw that is used to compile the demo program.
|
||||
|
||||
|
||||
+109
-109
@@ -1,110 +1,110 @@
|
||||
#
|
||||
# Simple makefile to build an executable for Win32 console
|
||||
#
|
||||
# This makefile assumes Borland development environment
|
||||
# on Windows NT/9x/2000/XP
|
||||
# Tools: bcc32, make, ilink
|
||||
|
||||
!ifndef BORLAND_DIR
|
||||
BORLAND_DIR_Not_Defined:
|
||||
@echo .
|
||||
@echo You must define environment variable BORLAND_DIR to compile.
|
||||
!endif
|
||||
|
||||
PRODUCT = rs485
|
||||
PRODUCT_EXE = $(PRODUCT).exe
|
||||
|
||||
# Choose the Data Link Layer to Enable
|
||||
DEFINES = -DBACDL_MSTP=1;TEST_RS485;TEST_RS485_TRANSMIT
|
||||
|
||||
SRCS = rs485.c
|
||||
OBJS = $(SRCS:.c=.obj)
|
||||
|
||||
# Compiler definitions
|
||||
#
|
||||
BCC_CFG = bcc32.cfg
|
||||
CC = $(BORLAND_DIR)\bin\bcc32 +$(BCC_CFG)
|
||||
#LINK = $(BORLAND_DIR)\bin\tlink32
|
||||
LINK = $(BORLAND_DIR)\bin\ilink32
|
||||
TLIB = $(BORLAND_DIR)\bin\tlib
|
||||
|
||||
#
|
||||
# Include directories
|
||||
#
|
||||
CC_DIR = $(BORLAND_DIR)\BIN
|
||||
BACNET_INCL = ..\..\include;.
|
||||
INCL_DIRS = -I$(BORLAND_DIR)\include;$(BACNET_INCL)
|
||||
|
||||
CFLAGS = $(INCL_DIRS) $(CS_FLAGS) $(DEFINES)
|
||||
|
||||
# Libraries
|
||||
#
|
||||
C_LIB_DIR = $(BORLAND_DIR)\lib
|
||||
|
||||
LIBS = $(C_LIB_DIR)\IMPORT32.lib \
|
||||
$(C_LIB_DIR)\CW32MT.lib
|
||||
|
||||
#
|
||||
# Main target
|
||||
#
|
||||
# This should be the first one in the makefile
|
||||
|
||||
all : $(BCC_CFG) $(PRODUCT_EXE)
|
||||
|
||||
# Linker specific: the link below is for BCC linker/compiler. If you link
|
||||
# with a different linker - please change accordingly.
|
||||
#
|
||||
|
||||
# need a temp response file (@&&) because command line is too long
|
||||
$(PRODUCT_EXE) : $(OBJS)
|
||||
@echo Running Linker for $(PRODUCT_EXE)
|
||||
$(LINK) -L$(C_LIB_DIR) -m -c -s -v @&&| # temp response file, starts with |
|
||||
$(BORLAND_DIR)\lib\c0x32.obj $** # $** lists each dependency
|
||||
$<
|
||||
$*.map
|
||||
$(LIBS)
|
||||
| # end of temp response file
|
||||
|
||||
#
|
||||
# Utilities
|
||||
|
||||
clean :
|
||||
@echo Deleting obj files, $(PRODUCT_EXE) and map files.
|
||||
del *.obj
|
||||
del ..\..\*.obj
|
||||
del ..\..\demo\handler\*.obj
|
||||
del ..\..\demo\object\*.obj
|
||||
del $(PRODUCT_EXE)
|
||||
del *.map
|
||||
del $(BCC_CFG)
|
||||
|
||||
#
|
||||
# Generic rules
|
||||
#
|
||||
.SUFFIXES: .cpp .c .sbr .obj
|
||||
|
||||
#
|
||||
# cc generic rule
|
||||
#
|
||||
.c.obj:
|
||||
$(CC) -o$@ $<
|
||||
|
||||
# Compiler configuration file
|
||||
$(BCC_CFG) :
|
||||
Copy &&|
|
||||
$(CFLAGS)
|
||||
-c
|
||||
-y #include line numbers in OBJ's
|
||||
-v #include debug info
|
||||
-w+ #turn on all warnings
|
||||
-Od #disable all optimizations
|
||||
#-a4 #32 bit data alignment
|
||||
#-M # generate link map
|
||||
#-ls # linker options
|
||||
#-WM- #not multithread
|
||||
-WM #multithread
|
||||
-w-aus # ignore warning assigned a value that is never used
|
||||
-w-sig # ignore warning conversion may lose sig digits
|
||||
| $@
|
||||
|
||||
#
|
||||
# Simple makefile to build an executable for Win32 console
|
||||
#
|
||||
# This makefile assumes Borland development environment
|
||||
# on Windows NT/9x/2000/XP
|
||||
# Tools: bcc32, make, ilink
|
||||
|
||||
!ifndef BORLAND_DIR
|
||||
BORLAND_DIR_Not_Defined:
|
||||
@echo .
|
||||
@echo You must define environment variable BORLAND_DIR to compile.
|
||||
!endif
|
||||
|
||||
PRODUCT = rs485
|
||||
PRODUCT_EXE = $(PRODUCT).exe
|
||||
|
||||
# Choose the Data Link Layer to Enable
|
||||
DEFINES = -DBACDL_MSTP=1;TEST_RS485;TEST_RS485_TRANSMIT
|
||||
|
||||
SRCS = rs485.c
|
||||
OBJS = $(SRCS:.c=.obj)
|
||||
|
||||
# Compiler definitions
|
||||
#
|
||||
BCC_CFG = bcc32.cfg
|
||||
CC = $(BORLAND_DIR)\bin\bcc32 +$(BCC_CFG)
|
||||
#LINK = $(BORLAND_DIR)\bin\tlink32
|
||||
LINK = $(BORLAND_DIR)\bin\ilink32
|
||||
TLIB = $(BORLAND_DIR)\bin\tlib
|
||||
|
||||
#
|
||||
# Include directories
|
||||
#
|
||||
CC_DIR = $(BORLAND_DIR)\BIN
|
||||
BACNET_INCL = ..\..\include;.
|
||||
INCL_DIRS = -I$(BORLAND_DIR)\include;$(BACNET_INCL)
|
||||
|
||||
CFLAGS = $(INCL_DIRS) $(CS_FLAGS) $(DEFINES)
|
||||
|
||||
# Libraries
|
||||
#
|
||||
C_LIB_DIR = $(BORLAND_DIR)\lib
|
||||
|
||||
LIBS = $(C_LIB_DIR)\IMPORT32.lib \
|
||||
$(C_LIB_DIR)\CW32MT.lib
|
||||
|
||||
#
|
||||
# Main target
|
||||
#
|
||||
# This should be the first one in the makefile
|
||||
|
||||
all : $(BCC_CFG) $(PRODUCT_EXE)
|
||||
|
||||
# Linker specific: the link below is for BCC linker/compiler. If you link
|
||||
# with a different linker - please change accordingly.
|
||||
#
|
||||
|
||||
# need a temp response file (@&&) because command line is too long
|
||||
$(PRODUCT_EXE) : $(OBJS)
|
||||
@echo Running Linker for $(PRODUCT_EXE)
|
||||
$(LINK) -L$(C_LIB_DIR) -m -c -s -v @&&| # temp response file, starts with |
|
||||
$(BORLAND_DIR)\lib\c0x32.obj $** # $** lists each dependency
|
||||
$<
|
||||
$*.map
|
||||
$(LIBS)
|
||||
| # end of temp response file
|
||||
|
||||
#
|
||||
# Utilities
|
||||
|
||||
clean :
|
||||
@echo Deleting obj files, $(PRODUCT_EXE) and map files.
|
||||
del *.obj
|
||||
del ..\..\*.obj
|
||||
del ..\..\demo\handler\*.obj
|
||||
del ..\..\demo\object\*.obj
|
||||
del $(PRODUCT_EXE)
|
||||
del *.map
|
||||
del $(BCC_CFG)
|
||||
|
||||
#
|
||||
# Generic rules
|
||||
#
|
||||
.SUFFIXES: .cpp .c .sbr .obj
|
||||
|
||||
#
|
||||
# cc generic rule
|
||||
#
|
||||
.c.obj:
|
||||
$(CC) -o$@ $<
|
||||
|
||||
# Compiler configuration file
|
||||
$(BCC_CFG) :
|
||||
Copy &&|
|
||||
$(CFLAGS)
|
||||
-c
|
||||
-y #include line numbers in OBJ's
|
||||
-v #include debug info
|
||||
-w+ #turn on all warnings
|
||||
-Od #disable all optimizations
|
||||
#-a4 #32 bit data alignment
|
||||
#-M # generate link map
|
||||
#-ls # linker options
|
||||
#-WM- #not multithread
|
||||
-WM #multithread
|
||||
-w-aus # ignore warning assigned a value that is never used
|
||||
-w-sig # ignore warning conversion may lose sig digits
|
||||
| $@
|
||||
|
||||
# EOF: makefile
|
||||
+114
-114
@@ -1,114 +1,114 @@
|
||||
#
|
||||
# Simple makefile to build an executable for Win32 console
|
||||
#
|
||||
# This makefile assumes Borland development environment
|
||||
# on Windows NT/9x/2000/XP
|
||||
# Tools: bcc32, make, ilink
|
||||
|
||||
!ifndef BORLAND_DIR
|
||||
BORLAND_DIR_Not_Defined:
|
||||
@echo .
|
||||
@echo You must define environment variable BORLAND_DIR to compile.
|
||||
!endif
|
||||
|
||||
PRODUCT = rx_fsm
|
||||
PRODUCT_EXE = $(PRODUCT).exe
|
||||
|
||||
# Choose the Data Link Layer to Enable
|
||||
DEFINES = -DBACDL_MSTP -DBACAPP_ALL -DPRINT_ENABLED=1
|
||||
#DEFINED += -DPRINT_ENABLED_RECEIVE_DATA=1
|
||||
|
||||
SRCS = rs485.c \
|
||||
rx_fsm.c \
|
||||
..\..\src\mstp.c \
|
||||
..\..\src\mstptext.c \
|
||||
..\..\src\indtext.c \
|
||||
..\..\src\crc.c
|
||||
|
||||
OBJS = $(SRCS:.c=.obj)
|
||||
|
||||
# Compiler definitions
|
||||
#
|
||||
BCC_CFG = bcc32.cfg
|
||||
CC = $(BORLAND_DIR)\bin\bcc32 +$(BCC_CFG)
|
||||
#LINK = $(BORLAND_DIR)\bin\tlink32
|
||||
LINK = $(BORLAND_DIR)\bin\ilink32
|
||||
TLIB = $(BORLAND_DIR)\bin\tlib
|
||||
|
||||
#
|
||||
# Include directories
|
||||
#
|
||||
CC_DIR = $(BORLAND_DIR)\BIN
|
||||
BACNET_INCL = ..\..\include;.
|
||||
INCL_DIRS = -I$(BORLAND_DIR)\include;$(BACNET_INCL)
|
||||
|
||||
CFLAGS = $(INCL_DIRS) $(CS_FLAGS) $(DEFINES)
|
||||
|
||||
# Libraries
|
||||
#
|
||||
C_LIB_DIR = $(BORLAND_DIR)\lib
|
||||
|
||||
LIBS = $(C_LIB_DIR)\IMPORT32.lib \
|
||||
$(C_LIB_DIR)\CW32MT.lib
|
||||
|
||||
#
|
||||
# Main target
|
||||
#
|
||||
# This should be the first one in the makefile
|
||||
|
||||
all : $(BCC_CFG) $(PRODUCT_EXE)
|
||||
|
||||
# Linker specific: the link below is for BCC linker/compiler. If you link
|
||||
# with a different linker - please change accordingly.
|
||||
#
|
||||
|
||||
# need a temp response file (@&&) because command line is too long
|
||||
$(PRODUCT_EXE) : $(OBJS)
|
||||
@echo Running Linker for $(PRODUCT_EXE)
|
||||
$(LINK) -L$(C_LIB_DIR) -m -c -s -v @&&| # temp response file, starts with |
|
||||
$(BORLAND_DIR)\lib\c0x32.obj $** # $** lists each dependency
|
||||
$<
|
||||
$*.map
|
||||
$(LIBS)
|
||||
| # end of temp response file
|
||||
|
||||
#
|
||||
# Utilities
|
||||
|
||||
clean :
|
||||
@echo Deleting obj files, $(PRODUCT_EXE) and map files.
|
||||
del $(OBJS)
|
||||
del $(PRODUCT_EXE)
|
||||
del *.map
|
||||
del $(BCC_CFG)
|
||||
|
||||
#
|
||||
# Generic rules
|
||||
#
|
||||
.SUFFIXES: .cpp .c .sbr .obj
|
||||
|
||||
#
|
||||
# cc generic rule
|
||||
#
|
||||
.c.obj:
|
||||
$(CC) -o$@ $<
|
||||
|
||||
# Compiler configuration file
|
||||
$(BCC_CFG) :
|
||||
Copy &&|
|
||||
$(CFLAGS)
|
||||
-c
|
||||
-y #include line numbers in OBJ's
|
||||
-v #include debug info
|
||||
-w+ #turn on all warnings
|
||||
-Od #disable all optimizations
|
||||
#-a4 #32 bit data alignment
|
||||
#-M # generate link map
|
||||
#-ls # linker options
|
||||
#-WM- #not multithread
|
||||
-WM #multithread
|
||||
-w-aus # ignore warning assigned a value that is never used
|
||||
-w-sig # ignore warning conversion may lose sig digits
|
||||
| $@
|
||||
|
||||
# EOF: makefile
|
||||
#
|
||||
# Simple makefile to build an executable for Win32 console
|
||||
#
|
||||
# This makefile assumes Borland development environment
|
||||
# on Windows NT/9x/2000/XP
|
||||
# Tools: bcc32, make, ilink
|
||||
|
||||
!ifndef BORLAND_DIR
|
||||
BORLAND_DIR_Not_Defined:
|
||||
@echo .
|
||||
@echo You must define environment variable BORLAND_DIR to compile.
|
||||
!endif
|
||||
|
||||
PRODUCT = rx_fsm
|
||||
PRODUCT_EXE = $(PRODUCT).exe
|
||||
|
||||
# Choose the Data Link Layer to Enable
|
||||
DEFINES = -DBACDL_MSTP -DBACAPP_ALL -DPRINT_ENABLED=1
|
||||
#DEFINED += -DPRINT_ENABLED_RECEIVE_DATA=1
|
||||
|
||||
SRCS = rs485.c \
|
||||
rx_fsm.c \
|
||||
..\..\src\mstp.c \
|
||||
..\..\src\mstptext.c \
|
||||
..\..\src\indtext.c \
|
||||
..\..\src\crc.c
|
||||
|
||||
OBJS = $(SRCS:.c=.obj)
|
||||
|
||||
# Compiler definitions
|
||||
#
|
||||
BCC_CFG = bcc32.cfg
|
||||
CC = $(BORLAND_DIR)\bin\bcc32 +$(BCC_CFG)
|
||||
#LINK = $(BORLAND_DIR)\bin\tlink32
|
||||
LINK = $(BORLAND_DIR)\bin\ilink32
|
||||
TLIB = $(BORLAND_DIR)\bin\tlib
|
||||
|
||||
#
|
||||
# Include directories
|
||||
#
|
||||
CC_DIR = $(BORLAND_DIR)\BIN
|
||||
BACNET_INCL = ..\..\include;.
|
||||
INCL_DIRS = -I$(BORLAND_DIR)\include;$(BACNET_INCL)
|
||||
|
||||
CFLAGS = $(INCL_DIRS) $(CS_FLAGS) $(DEFINES)
|
||||
|
||||
# Libraries
|
||||
#
|
||||
C_LIB_DIR = $(BORLAND_DIR)\lib
|
||||
|
||||
LIBS = $(C_LIB_DIR)\IMPORT32.lib \
|
||||
$(C_LIB_DIR)\CW32MT.lib
|
||||
|
||||
#
|
||||
# Main target
|
||||
#
|
||||
# This should be the first one in the makefile
|
||||
|
||||
all : $(BCC_CFG) $(PRODUCT_EXE)
|
||||
|
||||
# Linker specific: the link below is for BCC linker/compiler. If you link
|
||||
# with a different linker - please change accordingly.
|
||||
#
|
||||
|
||||
# need a temp response file (@&&) because command line is too long
|
||||
$(PRODUCT_EXE) : $(OBJS)
|
||||
@echo Running Linker for $(PRODUCT_EXE)
|
||||
$(LINK) -L$(C_LIB_DIR) -m -c -s -v @&&| # temp response file, starts with |
|
||||
$(BORLAND_DIR)\lib\c0x32.obj $** # $** lists each dependency
|
||||
$<
|
||||
$*.map
|
||||
$(LIBS)
|
||||
| # end of temp response file
|
||||
|
||||
#
|
||||
# Utilities
|
||||
|
||||
clean :
|
||||
@echo Deleting obj files, $(PRODUCT_EXE) and map files.
|
||||
del $(OBJS)
|
||||
del $(PRODUCT_EXE)
|
||||
del *.map
|
||||
del $(BCC_CFG)
|
||||
|
||||
#
|
||||
# Generic rules
|
||||
#
|
||||
.SUFFIXES: .cpp .c .sbr .obj
|
||||
|
||||
#
|
||||
# cc generic rule
|
||||
#
|
||||
.c.obj:
|
||||
$(CC) -o$@ $<
|
||||
|
||||
# Compiler configuration file
|
||||
$(BCC_CFG) :
|
||||
Copy &&|
|
||||
$(CFLAGS)
|
||||
-c
|
||||
-y #include line numbers in OBJ's
|
||||
-v #include debug info
|
||||
-w+ #turn on all warnings
|
||||
-Od #disable all optimizations
|
||||
#-a4 #32 bit data alignment
|
||||
#-M # generate link map
|
||||
#-ls # linker options
|
||||
#-WM- #not multithread
|
||||
-WM #multithread
|
||||
-w-aus # ignore warning assigned a value that is never used
|
||||
-w-sig # ignore warning conversion may lose sig digits
|
||||
| $@
|
||||
|
||||
# EOF: makefile
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
set BORLAND_DIR=\bcc55
|
||||
|
||||
set BORLAND_DIR=\bcc55
|
||||
|
||||
|
||||
Reference in New Issue
Block a user