Updated make file, and testing compile with DLMSTP datalink.
This commit is contained in:
@@ -82,7 +82,7 @@
|
|||||||
#define datalink_get_broadcast_address bip_get_broadcast_address
|
#define datalink_get_broadcast_address bip_get_broadcast_address
|
||||||
#define datalink_get_my_address bip_get_my_address
|
#define datalink_get_my_address bip_get_my_address
|
||||||
|
|
||||||
#elif defined(BACDL_TEST)
|
#else
|
||||||
#include "npdu.h"
|
#include "npdu.h"
|
||||||
|
|
||||||
extern int datalink_send_pdu(BACNET_ADDRESS * dest,
|
extern int datalink_send_pdu(BACNET_ADDRESS * dest,
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ uint16_t MSTP_Packets = 0;
|
|||||||
/* receive buffer */
|
/* receive buffer */
|
||||||
static DLMSTP_PACKET Receive_Packet;
|
static DLMSTP_PACKET Receive_Packet;
|
||||||
static DLMSTP_PACKET Transmit_Packet;
|
static DLMSTP_PACKET Transmit_Packet;
|
||||||
/* temp buffer for NPDU insertion */
|
|
||||||
/* local MS/TP port data - shared with RS-485 */
|
/* local MS/TP port data - shared with RS-485 */
|
||||||
static volatile struct mstp_port_struct_t MSTP_Port;
|
static volatile struct mstp_port_struct_t MSTP_Port;
|
||||||
/* buffers needed by mstp port struct */
|
/* buffers needed by mstp port struct */
|
||||||
|
|||||||
@@ -88,11 +88,11 @@ lib: $(LIBRARY)
|
|||||||
$(LIBRARY): $(COREOBJ) Makefile
|
$(LIBRARY): $(COREOBJ) Makefile
|
||||||
$(AR) rcs $@ $(COREOBJ)
|
$(AR) rcs $@ $(COREOBJ)
|
||||||
|
|
||||||
$(COBJ): %.o : %.c Makefile
|
.c.o:
|
||||||
$(CC) -c $(CFLAGS) $< -o $@
|
$(CC) -c $(CFLAGS) $*.c -o $@
|
||||||
|
|
||||||
$(AOBJ): %.o : %.s Makefile
|
.s.o:
|
||||||
$(CC) -c $(AFLAGS) $< -o $@
|
$(CC) -c $(AFLAGS) $*.s -o $@
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
touch Makefile
|
touch Makefile
|
||||||
|
|||||||
@@ -6,13 +6,43 @@
|
|||||||
PROJECT = bacnet
|
PROJECT = bacnet
|
||||||
MCU = atmega168
|
MCU = atmega168
|
||||||
TARGET = bacnet
|
TARGET = bacnet
|
||||||
CC = avr-gcc.exe
|
CC = avr-gcc
|
||||||
|
AR = avr-ar
|
||||||
|
|
||||||
CSRC = main.c \
|
CSRC = main.c \
|
||||||
timer.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)
|
COBJ = $(CSRC:.c=.o)
|
||||||
|
COREOBJ = $(CORESRC:.c=.o)
|
||||||
|
|
||||||
|
LIBRARY = lib$(TARGET).a
|
||||||
|
|
||||||
## Options common to compile, link and assembly rules
|
## Options common to compile, link and assembly rules
|
||||||
COMMON = -mmcu=$(MCU)
|
COMMON = -mmcu=$(MCU)
|
||||||
@@ -20,8 +50,9 @@ OPTIMIZATION = -O0
|
|||||||
#OPTIMIZATION = -Os
|
#OPTIMIZATION = -Os
|
||||||
|
|
||||||
## Compile options common for all C compilation units.
|
## Compile options common for all C compilation units.
|
||||||
|
BFLAGS = -DBACDL_MSTP -DMAX_APDU=50 -DBIG_ENDIAN=0
|
||||||
CFLAGS = $(COMMON)
|
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
|
CFLAGS += -MD -MP -MT $(*F).o -MF dep/$(@F).d
|
||||||
|
|
||||||
## Assembly specific flags
|
## Assembly specific flags
|
||||||
@@ -39,16 +70,13 @@ HEX_EEPROM_FLAGS = -j .eeprom
|
|||||||
HEX_EEPROM_FLAGS += --set-section-flags=.eeprom="alloc,load"
|
HEX_EEPROM_FLAGS += --set-section-flags=.eeprom="alloc,load"
|
||||||
HEX_EEPROM_FLAGS += --change-section-lma .eeprom=0 --no-change-warnings
|
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 that must be built in order to link
|
||||||
OBJECTS = $(COBJ)
|
OBJECTS = $(COBJ)
|
||||||
|
|
||||||
## Build
|
## Build
|
||||||
TARGET_ELF=$(TARGET).elf
|
TARGET_ELF=$(TARGET).elf
|
||||||
|
|
||||||
all: $(TARGET_ELF) $(TARGET).hex $(TARGET).eep size
|
all: $(TARGET_ELF) $(TARGET).hex $(TARGET).eep size $(LIBRARY) Makefile
|
||||||
|
|
||||||
##Link
|
##Link
|
||||||
$(TARGET_ELF): $(OBJECTS)
|
$(TARGET_ELF): $(OBJECTS)
|
||||||
@@ -63,8 +91,13 @@ $(TARGET_ELF): $(OBJECTS)
|
|||||||
%.lss: $(TARGET_ELF)
|
%.lss: $(TARGET_ELF)
|
||||||
avr-objdump -h -S $< > $@
|
avr-objdump -h -S $< > $@
|
||||||
|
|
||||||
$(COBJ): %.o : %.c Makefile
|
lib: $(LIBRARY)
|
||||||
$(CC) -c $(INCLUDES) $(CFLAGS) $< -o $@
|
|
||||||
|
$(LIBRARY): $(COREOBJ) Makefile
|
||||||
|
$(AR) rcs $@ $(COREOBJ)
|
||||||
|
|
||||||
|
.c.o:
|
||||||
|
$(CC) -c $(INCLUDES) $(CFLAGS) $*.c -o $@
|
||||||
|
|
||||||
size: ${TARGET_ELF}
|
size: ${TARGET_ELF}
|
||||||
@echo
|
@echo
|
||||||
@@ -75,6 +108,7 @@ size: ${TARGET_ELF}
|
|||||||
clean:
|
clean:
|
||||||
touch Makefile
|
touch Makefile
|
||||||
-rm -rf $(OBJECTS) $(TARGET_ELF) dep/*
|
-rm -rf $(OBJECTS) $(TARGET_ELF) dep/*
|
||||||
|
-rm -rf $(LIBRARY) $(COREOBJ)
|
||||||
-rm -rf $(TARGET).hex $(TARGET).eep $(TARGET).lss $(TARGET).map
|
-rm -rf $(TARGET).hex $(TARGET).eep $(TARGET).lss $(TARGET).map
|
||||||
|
|
||||||
## Other dependencies
|
## Other dependencies
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
#include "hardware.h"
|
#include "hardware.h"
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
#include "rs485.h"
|
#include "rs485.h"
|
||||||
|
#include "datalink.h"
|
||||||
|
|
||||||
/* For porting to IAR, see:
|
/* For porting to IAR, see:
|
||||||
http://www.avrfreaks.net/wiki/index.php/Documentation:AVR_GCC/IarToAvrgcc*/
|
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)
|
void init(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* Initialize I/O ports */
|
/* Initialize I/O ports */
|
||||||
/* For Port DDRx (Data Direction) Input=1, Output=1 */
|
/* For Port DDRx (Data Direction) Input=1, Output=1 */
|
||||||
/* For Port PORTx (Bit Value) TriState=0, High=1 */
|
/* For Port PORTx (Bit Value) TriState=0, High=1 */
|
||||||
@@ -49,11 +49,11 @@ void init(void)
|
|||||||
DDRD = 0;
|
DDRD = 0;
|
||||||
PORTD = 0;
|
PORTD = 0;
|
||||||
|
|
||||||
/* Configure the watchdog timer - Disabled for testing */
|
/* Configure the watchdog timer - Disabled for testing */
|
||||||
BIT_CLEAR(MCUSR,WDRF);
|
BIT_CLEAR(MCUSR,WDRF);
|
||||||
WDTCSR = 0;
|
WDTCSR = 0;
|
||||||
|
|
||||||
/* Configure USART */
|
/* Configure USART */
|
||||||
RS485_Initialize();
|
RS485_Initialize();
|
||||||
RS485_Set_Baud_Rate(38400);
|
RS485_Set_Baud_Rate(38400);
|
||||||
|
|
||||||
@@ -67,23 +67,36 @@ void init(void)
|
|||||||
void task_milliseconds(void)
|
void task_milliseconds(void)
|
||||||
{
|
{
|
||||||
while (Timer_Milliseconds) {
|
while (Timer_Milliseconds) {
|
||||||
Timer_Milliseconds--;
|
Timer_Milliseconds--;
|
||||||
/* add other millisecond timer tasks here */
|
/* add other millisecond timer tasks here */
|
||||||
Transmit_Timer++;
|
Transmit_Timer++;
|
||||||
}
|
dlmstp_millisecond_timer();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uint8_t PDUBuffer[MAX_MPDU];
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
|
uint16_t pdu_len = 0;
|
||||||
|
BACNET_ADDRESS src; /* source address */
|
||||||
|
|
||||||
init();
|
init();
|
||||||
for (;;) {
|
#if defined(BACDL_MSTP)
|
||||||
task_milliseconds();
|
RS485_Set_Baud_Rate(38400);
|
||||||
/* other tasks */
|
dlmstp_set_mac_address(86);
|
||||||
if (Transmit_Timer > 1000) {
|
dlmstp_set_max_master(127);
|
||||||
Transmit_Timer = 0;
|
dlmstp_set_max_info_frames(1);
|
||||||
RS485_Send_Frame(NULL,Transmit_Frame, MAX_FRAME);
|
#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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user