Updated make file, and testing compile with DLMSTP datalink.

This commit is contained in:
skarg
2007-08-16 00:37:56 +00:00
parent f2e0bbe834
commit 75302f4843
5 changed files with 75 additions and 29 deletions
+1 -1
View File
@@ -82,7 +82,7 @@
#define datalink_get_broadcast_address bip_get_broadcast_address
#define datalink_get_my_address bip_get_my_address
#elif defined(BACDL_TEST)
#else
#include "npdu.h"
extern int datalink_send_pdu(BACNET_ADDRESS * dest,
-1
View File
@@ -40,7 +40,6 @@ uint16_t MSTP_Packets = 0;
/* receive buffer */
static DLMSTP_PACKET Receive_Packet;
static DLMSTP_PACKET Transmit_Packet;
/* temp buffer for NPDU insertion */
/* local MS/TP port data - shared with RS-485 */
static volatile struct mstp_port_struct_t MSTP_Port;
/* buffers needed by mstp port struct */
+4 -4
View File
@@ -88,11 +88,11 @@ lib: $(LIBRARY)
$(LIBRARY): $(COREOBJ) Makefile
$(AR) rcs $@ $(COREOBJ)
$(COBJ): %.o : %.c Makefile
$(CC) -c $(CFLAGS) $< -o $@
.c.o:
$(CC) -c $(CFLAGS) $*.c -o $@
$(AOBJ): %.o : %.s Makefile
$(CC) -c $(AFLAGS) $< -o $@
.s.o:
$(CC) -c $(AFLAGS) $*.s -o $@
clean:
touch Makefile
+44 -10
View File
@@ -6,13 +6,43 @@
PROJECT = bacnet
MCU = atmega168
TARGET = bacnet
CC = avr-gcc.exe
CC = avr-gcc
AR = avr-ar
CSRC = main.c \
timer.c \
rs485.c
rs485.c \
dlmstp.c \
..\..\mstp.c \
..\..\crc.c
CORESRC = device.c \
../../npdu.c \
../../bacint.c \
../../apdu.c \
../../bacdcode.c \
../../bacstr.c \
../../abort.c \
../../bacerror.c \
../../reject.c \
../../bacapp.c \
../../datetime.c \
../../rp.c \
../../wp.c \
../../dcc.c \
../../rd.c \
../../whois.c \
../../iam.c \
../../version.c
## Include Directories
INCLUDES = -I. -I../.. -I../../demo/object
# Source to Object conversion
COBJ = $(CSRC:.c=.o)
COREOBJ = $(CORESRC:.c=.o)
LIBRARY = lib$(TARGET).a
## Options common to compile, link and assembly rules
COMMON = -mmcu=$(MCU)
@@ -20,8 +50,9 @@ OPTIMIZATION = -O0
#OPTIMIZATION = -Os
## Compile options common for all C compilation units.
BFLAGS = -DBACDL_MSTP -DMAX_APDU=50 -DBIG_ENDIAN=0
CFLAGS = $(COMMON)
CFLAGS += -Wall -gdwarf-2 -DF_CPU=7372800UL $(OPTIMIZATION) -fsigned-char
CFLAGS += -Wall -gdwarf-2 $(BFLAGS) $(OPTIMIZATION) -fsigned-char
CFLAGS += -MD -MP -MT $(*F).o -MF dep/$(@F).d
## Assembly specific flags
@@ -39,19 +70,16 @@ 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
## Include Directories
INCLUDES = -I. -I..\..
## Objects that must be built in order to link
OBJECTS = $(COBJ)
## Build
TARGET_ELF=$(TARGET).elf
all: $(TARGET_ELF) $(TARGET).hex $(TARGET).eep size
all: $(TARGET_ELF) $(TARGET).hex $(TARGET).eep size $(LIBRARY) Makefile
##Link
$(TARGET_ELF): $(OBJECTS)
$(TARGET_ELF): $(OBJECTS)
$(CC) $(LDFLAGS) $(OBJECTS) $(LIBDIRS) $(LIBS) -o $@
%.hex: $(TARGET_ELF)
@@ -63,8 +91,13 @@ $(TARGET_ELF): $(OBJECTS)
%.lss: $(TARGET_ELF)
avr-objdump -h -S $< > $@
$(COBJ): %.o : %.c Makefile
$(CC) -c $(INCLUDES) $(CFLAGS) $< -o $@
lib: $(LIBRARY)
$(LIBRARY): $(COREOBJ) Makefile
$(AR) rcs $@ $(COREOBJ)
.c.o:
$(CC) -c $(INCLUDES) $(CFLAGS) $*.c -o $@
size: ${TARGET_ELF}
@echo
@@ -75,6 +108,7 @@ size: ${TARGET_ELF}
clean:
touch Makefile
-rm -rf $(OBJECTS) $(TARGET_ELF) dep/*
-rm -rf $(LIBRARY) $(COREOBJ)
-rm -rf $(TARGET).hex $(TARGET).eep $(TARGET).lss $(TARGET).map
## Other dependencies
+26 -13
View File
@@ -28,6 +28,7 @@
#include "hardware.h"
#include "timer.h"
#include "rs485.h"
#include "datalink.h"
/* For porting to IAR, see:
http://www.avrfreaks.net/wiki/index.php/Documentation:AVR_GCC/IarToAvrgcc*/
@@ -38,7 +39,6 @@ static uint8_t Transmit_Frame[MAX_FRAME] = {0xAA, 0x55, 0x01, 0x45, 0xAB };
void init(void)
{
/* Initialize I/O ports */
/* For Port DDRx (Data Direction) Input=1, Output=1 */
/* For Port PORTx (Bit Value) TriState=0, High=1 */
@@ -49,11 +49,11 @@ void init(void)
DDRD = 0;
PORTD = 0;
/* Configure the watchdog timer - Disabled for testing */
/* Configure the watchdog timer - Disabled for testing */
BIT_CLEAR(MCUSR,WDRF);
WDTCSR = 0;
/* Configure USART */
/* Configure USART */
RS485_Initialize();
RS485_Set_Baud_Rate(38400);
@@ -67,23 +67,36 @@ void init(void)
void task_milliseconds(void)
{
while (Timer_Milliseconds) {
Timer_Milliseconds--;
/* add other millisecond timer tasks here */
Timer_Milliseconds--;
/* add other millisecond timer tasks here */
Transmit_Timer++;
}
dlmstp_millisecond_timer();
}
}
static uint8_t PDUBuffer[MAX_MPDU];
int main(void)
{
uint16_t pdu_len = 0;
BACNET_ADDRESS src; /* source address */
init();
for (;;) {
task_milliseconds();
/* other tasks */
if (Transmit_Timer > 1000) {
Transmit_Timer = 0;
RS485_Send_Frame(NULL,Transmit_Frame, MAX_FRAME);
#if defined(BACDL_MSTP)
RS485_Set_Baud_Rate(38400);
dlmstp_set_mac_address(86);
dlmstp_set_max_master(127);
dlmstp_set_max_info_frames(1);
#endif
datalink_init(NULL);
for (;;) {
task_milliseconds();
/* other tasks */
/* BACnet handling */
pdu_len = datalink_receive(&src, &PDUBuffer[0], MAX_MPDU, 0);
if (pdu_len) {
//npdu_handler(&src, &pdu[0], pdu_len);
}
}
}
return 0;
}