From 3fd93c77d5ff2e161235a682b54e6f1b4d8be1c1 Mon Sep 17 00:00:00 2001 From: skarg Date: Mon, 30 May 2016 14:55:50 +0000 Subject: [PATCH] Updated the PIC18F6720 port, and added PIC18F97J60 port. Both compile and build but were untested on actual hardware. --- .../nbproject/Makefile-default.mk | 4 +- .../nbproject/Makefile-genesis.properties | 2 +- .../nbproject/configurations.xml | 2 +- bacnet-stack/ports/pic18f6720/hardware.h | 171 --- bacnet-stack/ports/pic18f6720/isr.c | 1 - bacnet-stack/ports/pic18f6720/main.c | 84 +- .../pic18f97j60/BACnet-Server.X/Makefile | 108 ++ .../nbproject/Makefile-default.mk | 659 +++++++++ .../nbproject/Makefile-genesis.properties | 8 + .../nbproject/Makefile-impl.mk | 69 + .../nbproject/Makefile-local-default.mk | 37 + .../nbproject/Makefile-variables.mk | 13 + .../nbproject/Package-default.bash | 73 + .../nbproject/configurations.xml | 198 +++ .../nbproject/private/configurations.xml | 25 + .../nbproject/private/private.xml | 11 + .../nbproject/project.properties | 0 .../BACnet-Server.X/nbproject/project.xml | 16 + bacnet-stack/ports/pic18f97j60/Makefile | 164 +++ bacnet-stack/ports/pic18f97j60/ai.c | 174 +++ bacnet-stack/ports/pic18f97j60/apdu.c | 232 +++ bacnet-stack/ports/pic18f97j60/av.c | 413 ++++++ bacnet-stack/ports/pic18f97j60/bi.c | 197 +++ bacnet-stack/ports/pic18f97j60/bv.c | 328 +++++ bacnet-stack/ports/pic18f97j60/device.c | 752 ++++++++++ bacnet-stack/ports/pic18f97j60/dlmstp.c | 319 +++++ bacnet-stack/ports/pic18f97j60/dlmstp.h | 125 ++ bacnet-stack/ports/pic18f97j60/hardware.h | 128 ++ bacnet-stack/ports/pic18f97j60/isr.c | 206 +++ bacnet-stack/ports/pic18f97j60/main.c | 223 +++ bacnet-stack/ports/pic18f97j60/mstp.c | 1250 +++++++++++++++++ bacnet-stack/ports/pic18f97j60/mstp.h | 188 +++ bacnet-stack/ports/pic18f97j60/readme.txt | 44 + bacnet-stack/ports/pic18f97j60/rs485.c | 353 +++++ bacnet-stack/ports/pic18f97j60/rs485.h | 80 ++ bacnet-stack/ports/pic18f97j60/stdbool.h | 28 + bacnet-stack/ports/pic18f97j60/stdint.h | 18 + 37 files changed, 6449 insertions(+), 254 deletions(-) create mode 100644 bacnet-stack/ports/pic18f97j60/BACnet-Server.X/Makefile create mode 100644 bacnet-stack/ports/pic18f97j60/BACnet-Server.X/nbproject/Makefile-default.mk create mode 100644 bacnet-stack/ports/pic18f97j60/BACnet-Server.X/nbproject/Makefile-genesis.properties create mode 100644 bacnet-stack/ports/pic18f97j60/BACnet-Server.X/nbproject/Makefile-impl.mk create mode 100644 bacnet-stack/ports/pic18f97j60/BACnet-Server.X/nbproject/Makefile-local-default.mk create mode 100644 bacnet-stack/ports/pic18f97j60/BACnet-Server.X/nbproject/Makefile-variables.mk create mode 100644 bacnet-stack/ports/pic18f97j60/BACnet-Server.X/nbproject/Package-default.bash create mode 100644 bacnet-stack/ports/pic18f97j60/BACnet-Server.X/nbproject/configurations.xml create mode 100644 bacnet-stack/ports/pic18f97j60/BACnet-Server.X/nbproject/private/configurations.xml create mode 100644 bacnet-stack/ports/pic18f97j60/BACnet-Server.X/nbproject/private/private.xml create mode 100644 bacnet-stack/ports/pic18f97j60/BACnet-Server.X/nbproject/project.properties create mode 100644 bacnet-stack/ports/pic18f97j60/BACnet-Server.X/nbproject/project.xml create mode 100644 bacnet-stack/ports/pic18f97j60/Makefile create mode 100644 bacnet-stack/ports/pic18f97j60/ai.c create mode 100644 bacnet-stack/ports/pic18f97j60/apdu.c create mode 100644 bacnet-stack/ports/pic18f97j60/av.c create mode 100644 bacnet-stack/ports/pic18f97j60/bi.c create mode 100644 bacnet-stack/ports/pic18f97j60/bv.c create mode 100644 bacnet-stack/ports/pic18f97j60/device.c create mode 100644 bacnet-stack/ports/pic18f97j60/dlmstp.c create mode 100644 bacnet-stack/ports/pic18f97j60/dlmstp.h create mode 100644 bacnet-stack/ports/pic18f97j60/hardware.h create mode 100644 bacnet-stack/ports/pic18f97j60/isr.c create mode 100644 bacnet-stack/ports/pic18f97j60/main.c create mode 100644 bacnet-stack/ports/pic18f97j60/mstp.c create mode 100644 bacnet-stack/ports/pic18f97j60/mstp.h create mode 100644 bacnet-stack/ports/pic18f97j60/readme.txt create mode 100644 bacnet-stack/ports/pic18f97j60/rs485.c create mode 100644 bacnet-stack/ports/pic18f97j60/rs485.h create mode 100644 bacnet-stack/ports/pic18f97j60/stdbool.h create mode 100644 bacnet-stack/ports/pic18f97j60/stdint.h diff --git a/bacnet-stack/ports/pic18f6720/BACnet-Server.X/nbproject/Makefile-default.mk b/bacnet-stack/ports/pic18f6720/BACnet-Server.X/nbproject/Makefile-default.mk index 1c56405d..ba5fc384 100644 --- a/bacnet-stack/ports/pic18f6720/BACnet-Server.X/nbproject/Makefile-default.mk +++ b/bacnet-stack/ports/pic18f6720/BACnet-Server.X/nbproject/Makefile-default.mk @@ -630,11 +630,11 @@ endif ifeq ($(TYPE_IMAGE), DEBUG_RUN) dist/${CND_CONF}/${IMAGE_TYPE}/BACnet-Server.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX}: ${OBJECTFILES} nbproject/Makefile-${CND_CONF}.mk @${MKDIR} dist/${CND_CONF}/${IMAGE_TYPE} - ${MP_LD} $(MP_EXTRA_LD_PRE) "..\18F6720.lkr" -p$(MP_PROCESSOR_OPTION_LD) -w -x -u_DEBUG -z__MPLAB_BUILD=1 -u_CRUNTIME -z__MPLAB_DEBUG=1 -z__MPLAB_DEBUGGER_ICD3=1 $(MP_LINKER_DEBUG_OPTION) -l ${MP_CC_DIR}\\..\\lib -o dist/${CND_CONF}/${IMAGE_TYPE}/BACnet-Server.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX} ${OBJECTFILES_QUOTED_IF_SPACED} + ${MP_LD} $(MP_EXTRA_LD_PRE) -p$(MP_PROCESSOR_OPTION_LD) -w -x -u_DEBUG -z__MPLAB_BUILD=1 -u_CRUNTIME -z__MPLAB_DEBUG=1 -z__MPLAB_DEBUGGER_ICD3=1 $(MP_LINKER_DEBUG_OPTION) -l ${MP_CC_DIR}\\..\\lib -o dist/${CND_CONF}/${IMAGE_TYPE}/BACnet-Server.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX} ${OBJECTFILES_QUOTED_IF_SPACED} else dist/${CND_CONF}/${IMAGE_TYPE}/BACnet-Server.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX}: ${OBJECTFILES} nbproject/Makefile-${CND_CONF}.mk @${MKDIR} dist/${CND_CONF}/${IMAGE_TYPE} - ${MP_LD} $(MP_EXTRA_LD_PRE) "..\18F6720.lkr" -p$(MP_PROCESSOR_OPTION_LD) -w -z__MPLAB_BUILD=1 -u_CRUNTIME -l ${MP_CC_DIR}\\..\\lib -o dist/${CND_CONF}/${IMAGE_TYPE}/BACnet-Server.X.${IMAGE_TYPE}.${DEBUGGABLE_SUFFIX} ${OBJECTFILES_QUOTED_IF_SPACED} + ${MP_LD} $(MP_EXTRA_LD_PRE) -p$(MP_PROCESSOR_OPTION_LD) -w -z__MPLAB_BUILD=1 -u_CRUNTIME -l ${MP_CC_DIR}\\..\\lib -o dist/${CND_CONF}/${IMAGE_TYPE}/BACnet-Server.X.${IMAGE_TYPE}.${DEBUGGABLE_SUFFIX} ${OBJECTFILES_QUOTED_IF_SPACED} endif diff --git a/bacnet-stack/ports/pic18f6720/BACnet-Server.X/nbproject/Makefile-genesis.properties b/bacnet-stack/ports/pic18f6720/BACnet-Server.X/nbproject/Makefile-genesis.properties index aae7cf14..73831ec1 100644 --- a/bacnet-stack/ports/pic18f6720/BACnet-Server.X/nbproject/Makefile-genesis.properties +++ b/bacnet-stack/ports/pic18f6720/BACnet-Server.X/nbproject/Makefile-genesis.properties @@ -1,5 +1,5 @@ # -#Thu May 26 09:55:31 CDT 2016 +#Mon May 30 09:47:38 CDT 2016 default.com-microchip-mplab-nbide-toolchainC18-C18LanguageToolchain.md5=21ae92f54c0f89bc027339aedc19b7f9 default.languagetoolchain.dir=C\:\\Program Files (x86)\\Microchip\\mplabc18\\v3.40\\bin com-microchip-mplab-nbide-embedded-makeproject-MakeProject.md5=ef199adcc8f049579a105cca20571dcb diff --git a/bacnet-stack/ports/pic18f6720/BACnet-Server.X/nbproject/configurations.xml b/bacnet-stack/ports/pic18f6720/BACnet-Server.X/nbproject/configurations.xml index 2f9d5e30..e1de7d50 100644 --- a/bacnet-stack/ports/pic18f6720/BACnet-Server.X/nbproject/configurations.xml +++ b/bacnet-stack/ports/pic18f6720/BACnet-Server.X/nbproject/configurations.xml @@ -23,11 +23,11 @@ ../../../include/bacstr.h ../../../include/bigend.h ../../../include/config.h + ../hardware.h - ../18F6720.lkr #include -/* PORTA.0 Photocell Input PORTA.1 LED Row6 PORTA.2 LED Row5 PORTA.3 LED - * Row4 PORTA.4 Square Wave input from RTC PORTA.5 LCD RW PORTB.0 Zero - * Cross PORTB.1 USB RXF# PORTB.2 USB TXE# PORTB.3 Keypad Row Enable - * (74HC373 Output Control) PORTB.4 Keypad Row Gate (74HC373 Gate) - * PORTB.5 Switch Input Latch & Keypad Column Gate (74HC373 Gate) PORTB.6 - * ICD connection PORTB.7 ICD connection PORTC.0 Pilot Latch PORTC.1 - * Pilot Output Enable (low) PORTC.2 Piezo PORTC.3 I2C clock PORTC.4 I2C - * data PORTC.5 RS232 enable (low) PORTC.6 RS232 Tx PORTC.7 RS232 Rx - * PORTD.0 Data bus PORTD.1 Data bus PORTD.2 Data bus PORTD.3 Data bus - * PORTD.4 Data bus PORTD.5 Data bus PORTD.6 Data bus PORTD.7 Data bus - * PORTE.0 USB RD PORTE.1 USB WR PORTE.2 LCD RS PORTE.3 485 transmit - * enable PORTE.4 Relay data latch PORTE.5 Switch Input Clock PORTE.6 - * Switch Input High/Low PORTE.7 Switch Input Data PORTF.0 LED Row2 - * PORTF.1 LED Row1 PORTF.2 LED Col5 PORTF.3 LED Col4 PORTF.4 LED Col3 - * PORTF.5 LED Col2 PORTF.6 LED Col1 PORTF.7 LED Col0 PORTG.0 485 receive - * enable PORTG.1 485 Tx PORTG.2 485 Rx PORTG.3 LCD E PORTG.4 LED Row0 */ -#define LCD_BUSY PORTDbits.RD7 -#define LCD_E PORTGbits.RG3 -#define LCD_RW PORTAbits.RA5 -#define LCD_RS PORTEbits.RE2 -#define LCD_DATA PORTD -#define LCD_TRIS TRISD - -#define PILOT_LATCH PORTCbits.RC0 -#define PILOT_ENABLE PORTCbits.RC1 -#define PILOT_PORT PORTD -#define PILOT_PORT_TRIS TRISD - -#define PIEZO PORTCbits.RC2 -#define PIEZO_ON() TRISCbits.TRISC2 = 0 -#define PIEZO_OFF() TRISCbits.TRISC2 = 1 - -#define RS232_ENABLE PORTCbits.RC5 - #define RS485_TX_ENABLE PORTEbits.RE3 #define RS485_RX_DISABLE PORTGbits.RG0 -#define SWITCH_LOAD PORTBbits.RB5 -#define SWITCH_CLK PORTEbits.RE5 -#define SWITCH_COM PORTEbits.RE6 -#define SWITCH_DATA PORTEbits.RE7 - -#define LEDPORT PORTF -#define LEDTRIS TRISF -#define LED_ROW1 PORTGbits.RG4 -#define LED_ROW2 PORTFbits.RF1 -#define LED_ROW3 PORTFbits.RF0 -#define LED_ROW4 PORTAbits.RA3 -#define LED_ROW5 PORTAbits.RA2 -#define LED_ROW6 PORTAbits.RA1 - -#define RELAY_PORT PORTD -#define RELAY_PORT_TRIS TRISD -#define RELAY_LATCH PORTEbits.RE4 - -#define KEYPAD_DATA PORTD -#define KEYPAD_TRIS TRISD -#define KEYPAD_COL_LATCH PORTBbits.RB5 -#define KEYPAD_ROW_ENABLE PORTBbits.RB3 -#define KEYPAD_ROW_LATCH PORTBbits.RB4 -#define KEYPAD_ROW1 0 b00000001 -#define KEYPAD_ROW2 0 b00000010 -#define KEYPAD_ROW3 0 b00000100 -#define KEYPAD_ROW4 0 b00001000 -#define KEYPAD_ROW5 0 b00010000 -#define KEYPAD_ROW6 0 b00100000 - -#define USB_RD_EMPTY PORTBbits.RB1 -#define USB_WR_FULL PORTBbits.RB2 -#define USB_RD PORTEbits.RE0 -#define USB_WR PORTEbits.RE1 -#define USB_PORT PORTD -#define USB_PORT_TRIS TRISD - -#define ZERO_CROSS PORTBbits.RB0 - -#define PORT_A_TRIS_MASK 0x11 /* 0b00010001 */ -#define PORT_B_TRIS_MASK 0xC7 /* 0b11000111 */ -#define PORT_C_TRIS_MASK 0x9C /* 0b10011100 */ -#define PORT_D_TRIS_MASK 0xFF /* 0b11111111 */ -#define PORT_E_TRIS_MASK 0x88 /* 0b10001000 */ -#define PORT_F_TRIS_MASK 0x00 /* 0b00000000 */ -#define PORT_G_TRIS_MASK 0x04 /* 0b00000100 */ - #define TURN_OFF_COMPARATORS() CMCON = 0x07 -#define SHORT_BEEP 50 -#define LONG_BEEP 250 - -#define CLICK() Hardware_Sound_Piezo(SHORT_BEEP); -#define BEEP() Hardware_Sound_Piezo(LONG_BEEP); - -typedef union { - struct { - uint8_t:1; - uint8_t:1; - uint8_t Thursday:1; - uint8_t Wednesday:1; - uint8_t Tuesday:1; - uint8_t Monday:1; - uint8_t Program:1; - uint8_t Run:1; - - uint8_t:1; - uint8_t:1; - uint8_t Input1:1; - uint8_t Input2:1; - uint8_t Input3:1; - uint8_t Input4:1; - uint8_t Input5:1; - uint8_t Input6:1; - - uint8_t:1; - uint8_t:1; - uint8_t:1; - uint8_t Input7:1; - uint8_t:1; - uint8_t:1; - uint8_t Input8:1; - uint8_t Photocell:1; - - uint8_t:1; - uint8_t:1; - uint8_t:1; - uint8_t:1; - uint8_t:1; - uint8_t:1; - uint8_t Remote:1; - uint8_t Relay8:1; - - uint8_t:1; - uint8_t:1; - uint8_t:1; - uint8_t Relay7:1; - uint8_t Relay6:1; - uint8_t Relay5:1; - uint8_t Relay4:1; - uint8_t Relay3:1; - - uint8_t:1; - uint8_t:1; - uint8_t Relay2:1; - uint8_t Relay1:1; - uint8_t Holiday:1; - uint8_t Sunday:1; - uint8_t Saturday:1; - uint8_t Friday:1; - }; - struct { - uint8_t row1; - uint8_t row2; - uint8_t row3; - uint8_t row4; - uint8_t row5; - uint8_t row6; - }; -} LED_REGS; - -union SWITCH_REGS { - struct { - uint8_t All_On:1; - uint8_t All_Off:1; - uint8_t Addr:4; - uint8_t Pilot_Fault:1; - uint8_t Master:1; - }; - uint8_t Sw_Byte; -}; - enum INT_STATE { INT_DISABLED, INT_ENABLED, INT_RESTORE }; #define RESTART_WDT() { _asm CLRWDT _endasm } @@ -261,11 +97,4 @@ enum INT_STATE { INT_DISABLED, INT_ENABLED, INT_RESTORE }; T2CON = (mode | (postscale - 1) << 3); \ PR2 = period - -/* Global Vars */ -extern volatile LED_REGS LEDS; -extern volatile LED_REGS Blink; -extern uint8_t Piezo_Timer; -extern volatile bool DataPortLocked; - #endif /* HARDWARE_H */ diff --git a/bacnet-stack/ports/pic18f6720/isr.c b/bacnet-stack/ports/pic18f6720/isr.c index 503e5919..1b62e3fd 100644 --- a/bacnet-stack/ports/pic18f6720/isr.c +++ b/bacnet-stack/ports/pic18f6720/isr.c @@ -22,7 +22,6 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * *********************************************************************/ -#include #include "stdint.h" #include "hardware.h" #include "rs485.h" diff --git a/bacnet-stack/ports/pic18f6720/main.c b/bacnet-stack/ports/pic18f6720/main.c index 79a007fc..41a016ec 100644 --- a/bacnet-stack/ports/pic18f6720/main.c +++ b/bacnet-stack/ports/pic18f6720/main.c @@ -26,7 +26,6 @@ #include #include #include /* for memmove */ -#include #include #include #include "stdint.h" @@ -129,98 +128,27 @@ void Global_Int( void Hardware_Initialize( void) { - /* PORTA.0 Input - Photocell PORTA.1 Output - LED Row6 PORTA.2 Output - * - LED Row5 PORTA.3 Output - LED Row4 PORTA.4 Input - Square Wave - * input from RTC PORTA.5 Output - LCD RW */ - TRISA = 0xD1; - - /* PORTB.0 Input - Zero Cross PORTB.1 Input - USB RXF# PORTB.2 Input - * USB TXE# PORTB.3 Output - Keypad Row Enable (74HC373 Output Control) - * PORTB.4 Output Keypad Row Gate (74HC373 Gate) PORTB.5 Output Switch - * Input Latch & Keypad Column Gate (74HC373 Gate) PORTB.6 Input - ICD - * connection PORTB.7 Input - ICD connection */ - TRISB = 0xC7; - - /* PORTC.0 Output - Pilot Latch PORTC.1 Output - Pilot Output Enable - * (low) PORTC.2 I/O - Piezo PORTC.3 Input - I2C clock PORTC.4 Input - * I2C data PORTC.5 Output RS232 enable (low) PORTC.6 Output - RS232 Tx - * PORTC.7 Input - RS232 Rx */ - TRISC = 0x9C; - - /* PORTD.0 I/O - Data bus PORTD.1 I/O - Data bus PORTD.2 I/O - Data - * bus PORTD.3 I/O - Data bus PORTD.4 I/O - Data bus PORTD.5 I/O - Data - * bus PORTD.6 I/O - Data bus PORTD.7 I/O - Data bus */ - TRISD = 0xFF; - - /* PORTE.0 Input - USB RD PORTE.1 Input - USB WR PORTE.2 Output - LCD - * RS PORTE.3 Output - 485 transmit enable PORTE.4 Output - Relay data - * latch PORTE.5 Output Switch Input Clock PORTE.6 Output - Switch - * Input High/Low PORTE.7 Input Switch Input Data */ - TRISE = 0x83; - - /* PORTF.0 Output - LED Row2 PORTF.1 Output - LED Row1 PORTF.2 Output - * - LED Col5 PORTF.3 Output - LED Col4 PORTF.4 Output - LED Col3 - * PORTF.5 Output - LED Col2 PORTF.6 Output - LED Col1 PORTF.7 Output - * LED Col0 */ + TRISA = 0x00; + TRISB = 0x00; + TRISC = 0x00; + TRISD = 0x00; + TRISE = 0x00; TRISF = 0x00; - - /* PORTG.0 Output - 485 receive enable PORTG.1 Output - 485 Tx PORTG.2 - * Input 485 Rx PORTG.3 Output - LCD E PORTG.4 Output - LED Row0 */ - TRISG = 0xE6; - - /* The initial state of the keypad enables and latches */ - KEYPAD_ROW_ENABLE = 1; - KEYPAD_ROW_LATCH = 0; - KEYPAD_COL_LATCH = 1; - - RELAY_LATCH = 0; - - /* Setup to read the switch inputs */ - SWITCH_COM = 1; - - /* Enable the RS232 transmitter */ - RS232_ENABLE = 0; - - /* Turn all leds off. These are the hardware pins */ - LED_ROW1 = 1; - LED_ROW2 = 1; - LED_ROW3 = 1; - LED_ROW4 = 1; - LED_ROW5 = 1; - LED_ROW6 = 1; - LEDPORT = 0x03; - - /* The initial values for the signals to the LCD */ - LCD_E = 1; - LCD_RW = 1; - LCD_RS = 1; - - /* The following gives us a PWM frequency of 1.990KHz with a 50% duty - * cycle It also serves to multiplex the LEDs. */ - PIEZO_OFF(); - CCPR1L = 0x4E; - CCP1CON = 0x2F; - setup_timer2(6, 156, 2); - PIE1bits.TMR2IE = 1; - + TRISG = 0x00; /* We will use Timer4 as our system tick timer. Our system tick is set * to 1ms. Hold off on enabling the int. */ setup_timer4(5, 250, 5); - /* Setup our interrupt priorities */ RCONbits.IPEN = 1; IPR1 = 0; IPR2 = 0; IPR3 = 0; - /* Setup TMR0 to be high priority */ INTCON2 = 0xFC; INTCON3 = 0; - /* USART 1 high priority */ IPR1bits.RC1IP = 1; IPR1bits.TX1IP = 1; - /* Finally enable our ints */ Global_Int(INT_ENABLED); } diff --git a/bacnet-stack/ports/pic18f97j60/BACnet-Server.X/Makefile b/bacnet-stack/ports/pic18f97j60/BACnet-Server.X/Makefile new file mode 100644 index 00000000..447582bc --- /dev/null +++ b/bacnet-stack/ports/pic18f97j60/BACnet-Server.X/Makefile @@ -0,0 +1,108 @@ +# +# There exist several targets which are by default empty and which can be +# used for execution of your targets. These targets are usually executed +# before and after some main targets. They are: +# +# .build-pre: called before 'build' target +# .build-post: called after 'build' target +# .clean-pre: called before 'clean' target +# .clean-post: called after 'clean' target +# .clobber-pre: called before 'clobber' target +# .clobber-post: called after 'clobber' target +# .all-pre: called before 'all' target +# .all-post: called after 'all' target +# .help-pre: called before 'help' target +# .help-post: called after 'help' target +# +# Targets beginning with '.' are not intended to be called on their own. +# +# Main targets can be executed directly, and they are: +# +# build build a specific configuration +# clean remove built files from a configuration +# clobber remove all built files +# all build all configurations +# help print help mesage +# +# Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and +# .help-impl are implemented in nbproject/makefile-impl.mk. +# +# Available make variables: +# +# CND_BASEDIR base directory for relative paths +# CND_DISTDIR default top distribution directory (build artifacts) +# CND_BUILDDIR default top build directory (object files, ...) +# CONF name of current configuration +# CND_ARTIFACT_DIR_${CONF} directory of build artifact (current configuration) +# CND_ARTIFACT_NAME_${CONF} name of build artifact (current configuration) +# CND_ARTIFACT_PATH_${CONF} path to build artifact (current configuration) +# CND_PACKAGE_DIR_${CONF} directory of package (current configuration) +# CND_PACKAGE_NAME_${CONF} name of package (current configuration) +# CND_PACKAGE_PATH_${CONF} path to package (current configuration) +# +# NOCDDL + + +# Environment +MKDIR=mkdir +CP=cp +CCADMIN=CCadmin +RANLIB=ranlib + + +# build +build: .build-post + +.build-pre: +# Add your pre 'build' code here... + +.build-post: .build-impl +# Add your post 'build' code here... + + +# clean +clean: .clean-post + +.clean-pre: +# Add your pre 'clean' code here... + +.clean-post: .clean-impl +# Add your post 'clean' code here... + + +# clobber +clobber: .clobber-post + +.clobber-pre: +# Add your pre 'clobber' code here... + +.clobber-post: .clobber-impl +# Add your post 'clobber' code here... + + +# all +all: .all-post + +.all-pre: +# Add your pre 'all' code here... + +.all-post: .all-impl +# Add your post 'all' code here... + + +# help +help: .help-post + +.help-pre: +# Add your pre 'help' code here... + +.help-post: .help-impl +# Add your post 'help' code here... + + + +# include project implementation makefile +include nbproject/Makefile-impl.mk + +# include project make variables +include nbproject/Makefile-variables.mk diff --git a/bacnet-stack/ports/pic18f97j60/BACnet-Server.X/nbproject/Makefile-default.mk b/bacnet-stack/ports/pic18f97j60/BACnet-Server.X/nbproject/Makefile-default.mk new file mode 100644 index 00000000..3b491990 --- /dev/null +++ b/bacnet-stack/ports/pic18f97j60/BACnet-Server.X/nbproject/Makefile-default.mk @@ -0,0 +1,659 @@ +# +# Generated Makefile - do not edit! +# +# Edit the Makefile in the project folder instead (../Makefile). Each target +# has a -pre and a -post target defined where you can add customized code. +# +# This makefile implements configuration specific macros and targets. + + +# Include project Makefile +include Makefile +# Include makefile containing local settings +ifeq "$(wildcard nbproject/Makefile-local-default.mk)" "nbproject/Makefile-local-default.mk" +include nbproject/Makefile-local-default.mk +endif + +# Environment +MKDIR=gnumkdir -p +RM=rm -f +MV=mv +CP=cp + +# Macros +CND_CONF=default +ifeq ($(TYPE_IMAGE), DEBUG_RUN) +IMAGE_TYPE=debug +OUTPUT_SUFFIX=cof +DEBUGGABLE_SUFFIX=cof +FINAL_IMAGE=dist/${CND_CONF}/${IMAGE_TYPE}/BACnet-Server.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX} +else +IMAGE_TYPE=production +OUTPUT_SUFFIX=hex +DEBUGGABLE_SUFFIX=cof +FINAL_IMAGE=dist/${CND_CONF}/${IMAGE_TYPE}/BACnet-Server.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX} +endif + +# Object Directory +OBJECTDIR=build/${CND_CONF}/${IMAGE_TYPE} + +# Distribution Directory +DISTDIR=dist/${CND_CONF}/${IMAGE_TYPE} + +# Object Files Quoted if spaced +OBJECTFILES_QUOTED_IF_SPACED=${OBJECTDIR}/_ext/1386528437/abort.o ${OBJECTDIR}/_ext/1386528437/bacapp.o ${OBJECTDIR}/_ext/1386528437/bacdcode.o ${OBJECTDIR}/_ext/1386528437/bacerror.o ${OBJECTDIR}/_ext/1386528437/bacstr.o ${OBJECTDIR}/_ext/1386528437/crc.o ${OBJECTDIR}/_ext/1386528437/dcc.o ${OBJECTDIR}/_ext/1386528437/iam.o ${OBJECTDIR}/_ext/1386528437/rd.o ${OBJECTDIR}/_ext/1386528437/reject.o ${OBJECTDIR}/_ext/1386528437/rp.o ${OBJECTDIR}/_ext/1386528437/whois.o ${OBJECTDIR}/_ext/1394255507/h_dcc.o ${OBJECTDIR}/_ext/1394255507/h_rd.o ${OBJECTDIR}/_ext/1472/main.o ${OBJECTDIR}/_ext/1472/dlmstp.o ${OBJECTDIR}/_ext/1472/device.o ${OBJECTDIR}/_ext/1472/rs485.o ${OBJECTDIR}/_ext/1472/isr.o ${OBJECTDIR}/_ext/1386528437/datetime.o ${OBJECTDIR}/_ext/1394255507/txbuf.o ${OBJECTDIR}/_ext/1394255507/h_whois.o ${OBJECTDIR}/_ext/1472/mstp.o ${OBJECTDIR}/_ext/1472/bv.o ${OBJECTDIR}/_ext/1472/ai.o ${OBJECTDIR}/_ext/1472/bi.o ${OBJECTDIR}/_ext/1472/av.o ${OBJECTDIR}/_ext/1386528437/wp.o ${OBJECTDIR}/_ext/1394255507/h_npdu.o ${OBJECTDIR}/_ext/1394255507/s_iam.o ${OBJECTDIR}/_ext/1386528437/bacreal.o ${OBJECTDIR}/_ext/1386528437/bacint.o ${OBJECTDIR}/_ext/1386528437/npdu.o ${OBJECTDIR}/_ext/1472/apdu.o ${OBJECTDIR}/_ext/1394255507/noserv.o ${OBJECTDIR}/_ext/1386528437/fifo.o ${OBJECTDIR}/_ext/1394255507/h_rp.o ${OBJECTDIR}/_ext/1394255507/h_wp.o ${OBJECTDIR}/_ext/1386528437/bacaddr.o +POSSIBLE_DEPFILES=${OBJECTDIR}/_ext/1386528437/abort.o.d ${OBJECTDIR}/_ext/1386528437/bacapp.o.d ${OBJECTDIR}/_ext/1386528437/bacdcode.o.d ${OBJECTDIR}/_ext/1386528437/bacerror.o.d ${OBJECTDIR}/_ext/1386528437/bacstr.o.d ${OBJECTDIR}/_ext/1386528437/crc.o.d ${OBJECTDIR}/_ext/1386528437/dcc.o.d ${OBJECTDIR}/_ext/1386528437/iam.o.d ${OBJECTDIR}/_ext/1386528437/rd.o.d ${OBJECTDIR}/_ext/1386528437/reject.o.d ${OBJECTDIR}/_ext/1386528437/rp.o.d ${OBJECTDIR}/_ext/1386528437/whois.o.d ${OBJECTDIR}/_ext/1394255507/h_dcc.o.d ${OBJECTDIR}/_ext/1394255507/h_rd.o.d ${OBJECTDIR}/_ext/1472/main.o.d ${OBJECTDIR}/_ext/1472/dlmstp.o.d ${OBJECTDIR}/_ext/1472/device.o.d ${OBJECTDIR}/_ext/1472/rs485.o.d ${OBJECTDIR}/_ext/1472/isr.o.d ${OBJECTDIR}/_ext/1386528437/datetime.o.d ${OBJECTDIR}/_ext/1394255507/txbuf.o.d ${OBJECTDIR}/_ext/1394255507/h_whois.o.d ${OBJECTDIR}/_ext/1472/mstp.o.d ${OBJECTDIR}/_ext/1472/bv.o.d ${OBJECTDIR}/_ext/1472/ai.o.d ${OBJECTDIR}/_ext/1472/bi.o.d ${OBJECTDIR}/_ext/1472/av.o.d ${OBJECTDIR}/_ext/1386528437/wp.o.d ${OBJECTDIR}/_ext/1394255507/h_npdu.o.d ${OBJECTDIR}/_ext/1394255507/s_iam.o.d ${OBJECTDIR}/_ext/1386528437/bacreal.o.d ${OBJECTDIR}/_ext/1386528437/bacint.o.d ${OBJECTDIR}/_ext/1386528437/npdu.o.d ${OBJECTDIR}/_ext/1472/apdu.o.d ${OBJECTDIR}/_ext/1394255507/noserv.o.d ${OBJECTDIR}/_ext/1386528437/fifo.o.d ${OBJECTDIR}/_ext/1394255507/h_rp.o.d ${OBJECTDIR}/_ext/1394255507/h_wp.o.d ${OBJECTDIR}/_ext/1386528437/bacaddr.o.d + +# Object Files +OBJECTFILES=${OBJECTDIR}/_ext/1386528437/abort.o ${OBJECTDIR}/_ext/1386528437/bacapp.o ${OBJECTDIR}/_ext/1386528437/bacdcode.o ${OBJECTDIR}/_ext/1386528437/bacerror.o ${OBJECTDIR}/_ext/1386528437/bacstr.o ${OBJECTDIR}/_ext/1386528437/crc.o ${OBJECTDIR}/_ext/1386528437/dcc.o ${OBJECTDIR}/_ext/1386528437/iam.o ${OBJECTDIR}/_ext/1386528437/rd.o ${OBJECTDIR}/_ext/1386528437/reject.o ${OBJECTDIR}/_ext/1386528437/rp.o ${OBJECTDIR}/_ext/1386528437/whois.o ${OBJECTDIR}/_ext/1394255507/h_dcc.o ${OBJECTDIR}/_ext/1394255507/h_rd.o ${OBJECTDIR}/_ext/1472/main.o ${OBJECTDIR}/_ext/1472/dlmstp.o ${OBJECTDIR}/_ext/1472/device.o ${OBJECTDIR}/_ext/1472/rs485.o ${OBJECTDIR}/_ext/1472/isr.o ${OBJECTDIR}/_ext/1386528437/datetime.o ${OBJECTDIR}/_ext/1394255507/txbuf.o ${OBJECTDIR}/_ext/1394255507/h_whois.o ${OBJECTDIR}/_ext/1472/mstp.o ${OBJECTDIR}/_ext/1472/bv.o ${OBJECTDIR}/_ext/1472/ai.o ${OBJECTDIR}/_ext/1472/bi.o ${OBJECTDIR}/_ext/1472/av.o ${OBJECTDIR}/_ext/1386528437/wp.o ${OBJECTDIR}/_ext/1394255507/h_npdu.o ${OBJECTDIR}/_ext/1394255507/s_iam.o ${OBJECTDIR}/_ext/1386528437/bacreal.o ${OBJECTDIR}/_ext/1386528437/bacint.o ${OBJECTDIR}/_ext/1386528437/npdu.o ${OBJECTDIR}/_ext/1472/apdu.o ${OBJECTDIR}/_ext/1394255507/noserv.o ${OBJECTDIR}/_ext/1386528437/fifo.o ${OBJECTDIR}/_ext/1394255507/h_rp.o ${OBJECTDIR}/_ext/1394255507/h_wp.o ${OBJECTDIR}/_ext/1386528437/bacaddr.o + + +CFLAGS= +ASFLAGS= +LDLIBSOPTIONS= + +############# Tool locations ########################################## +# If you copy a project from one host to another, the path where the # +# compiler is installed may be different. # +# If you open this project with MPLAB X in the new host, this # +# makefile will be regenerated and the paths will be corrected. # +####################################################################### +# fixDeps replaces a bunch of sed/cat/printf statements that slow down the build +FIXDEPS=fixDeps + +.build-conf: ${BUILD_SUBPROJECTS} + ${MAKE} ${MAKE_OPTIONS} -f nbproject/Makefile-default.mk dist/${CND_CONF}/${IMAGE_TYPE}/BACnet-Server.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX} + +MP_PROCESSOR_OPTION=18F97J60 +MP_PROCESSOR_OPTION_LD=18f97j60 +MP_LINKER_DEBUG_OPTION= +# ------------------------------------------------------------------------------------ +# Rules for buildStep: assemble +ifeq ($(TYPE_IMAGE), DEBUG_RUN) +else +endif + +# ------------------------------------------------------------------------------------ +# Rules for buildStep: compile +ifeq ($(TYPE_IMAGE), DEBUG_RUN) +${OBJECTDIR}/_ext/1386528437/abort.o: ../../../src/abort.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1386528437 + @${RM} ${OBJECTDIR}/_ext/1386528437/abort.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1386528437/abort.o ../../../src/abort.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1386528437/abort.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1386528437/abort.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1386528437/bacapp.o: ../../../src/bacapp.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1386528437 + @${RM} ${OBJECTDIR}/_ext/1386528437/bacapp.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1386528437/bacapp.o ../../../src/bacapp.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1386528437/bacapp.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1386528437/bacapp.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1386528437/bacdcode.o: ../../../src/bacdcode.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1386528437 + @${RM} ${OBJECTDIR}/_ext/1386528437/bacdcode.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1386528437/bacdcode.o ../../../src/bacdcode.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1386528437/bacdcode.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1386528437/bacdcode.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1386528437/bacerror.o: ../../../src/bacerror.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1386528437 + @${RM} ${OBJECTDIR}/_ext/1386528437/bacerror.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1386528437/bacerror.o ../../../src/bacerror.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1386528437/bacerror.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1386528437/bacerror.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1386528437/bacstr.o: ../../../src/bacstr.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1386528437 + @${RM} ${OBJECTDIR}/_ext/1386528437/bacstr.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1386528437/bacstr.o ../../../src/bacstr.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1386528437/bacstr.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1386528437/bacstr.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1386528437/crc.o: ../../../src/crc.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1386528437 + @${RM} ${OBJECTDIR}/_ext/1386528437/crc.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1386528437/crc.o ../../../src/crc.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1386528437/crc.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1386528437/crc.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1386528437/dcc.o: ../../../src/dcc.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1386528437 + @${RM} ${OBJECTDIR}/_ext/1386528437/dcc.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1386528437/dcc.o ../../../src/dcc.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1386528437/dcc.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1386528437/dcc.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1386528437/iam.o: ../../../src/iam.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1386528437 + @${RM} ${OBJECTDIR}/_ext/1386528437/iam.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1386528437/iam.o ../../../src/iam.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1386528437/iam.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1386528437/iam.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1386528437/rd.o: ../../../src/rd.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1386528437 + @${RM} ${OBJECTDIR}/_ext/1386528437/rd.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1386528437/rd.o ../../../src/rd.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1386528437/rd.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1386528437/rd.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1386528437/reject.o: ../../../src/reject.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1386528437 + @${RM} ${OBJECTDIR}/_ext/1386528437/reject.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1386528437/reject.o ../../../src/reject.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1386528437/reject.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1386528437/reject.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1386528437/rp.o: ../../../src/rp.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1386528437 + @${RM} ${OBJECTDIR}/_ext/1386528437/rp.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1386528437/rp.o ../../../src/rp.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1386528437/rp.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1386528437/rp.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1386528437/whois.o: ../../../src/whois.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1386528437 + @${RM} ${OBJECTDIR}/_ext/1386528437/whois.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1386528437/whois.o ../../../src/whois.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1386528437/whois.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1386528437/whois.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1394255507/h_dcc.o: ../../../demo/handler/h_dcc.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1394255507 + @${RM} ${OBJECTDIR}/_ext/1394255507/h_dcc.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1394255507/h_dcc.o ../../../demo/handler/h_dcc.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1394255507/h_dcc.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1394255507/h_dcc.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1394255507/h_rd.o: ../../../demo/handler/h_rd.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1394255507 + @${RM} ${OBJECTDIR}/_ext/1394255507/h_rd.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1394255507/h_rd.o ../../../demo/handler/h_rd.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1394255507/h_rd.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1394255507/h_rd.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1472/main.o: ../main.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1472 + @${RM} ${OBJECTDIR}/_ext/1472/main.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1472/main.o ../main.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1472/main.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1472/main.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1472/dlmstp.o: ../dlmstp.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1472 + @${RM} ${OBJECTDIR}/_ext/1472/dlmstp.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1472/dlmstp.o ../dlmstp.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1472/dlmstp.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1472/dlmstp.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1472/device.o: ../device.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1472 + @${RM} ${OBJECTDIR}/_ext/1472/device.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1472/device.o ../device.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1472/device.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1472/device.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1472/rs485.o: ../rs485.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1472 + @${RM} ${OBJECTDIR}/_ext/1472/rs485.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1472/rs485.o ../rs485.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1472/rs485.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1472/rs485.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1472/isr.o: ../isr.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1472 + @${RM} ${OBJECTDIR}/_ext/1472/isr.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1472/isr.o ../isr.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1472/isr.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1472/isr.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1386528437/datetime.o: ../../../src/datetime.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1386528437 + @${RM} ${OBJECTDIR}/_ext/1386528437/datetime.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1386528437/datetime.o ../../../src/datetime.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1386528437/datetime.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1386528437/datetime.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1394255507/txbuf.o: ../../../demo/handler/txbuf.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1394255507 + @${RM} ${OBJECTDIR}/_ext/1394255507/txbuf.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1394255507/txbuf.o ../../../demo/handler/txbuf.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1394255507/txbuf.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1394255507/txbuf.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1394255507/h_whois.o: ../../../demo/handler/h_whois.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1394255507 + @${RM} ${OBJECTDIR}/_ext/1394255507/h_whois.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1394255507/h_whois.o ../../../demo/handler/h_whois.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1394255507/h_whois.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1394255507/h_whois.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1472/mstp.o: ../mstp.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1472 + @${RM} ${OBJECTDIR}/_ext/1472/mstp.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1472/mstp.o ../mstp.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1472/mstp.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1472/mstp.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1472/bv.o: ../bv.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1472 + @${RM} ${OBJECTDIR}/_ext/1472/bv.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1472/bv.o ../bv.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1472/bv.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1472/bv.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1472/ai.o: ../ai.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1472 + @${RM} ${OBJECTDIR}/_ext/1472/ai.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1472/ai.o ../ai.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1472/ai.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1472/ai.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1472/bi.o: ../bi.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1472 + @${RM} ${OBJECTDIR}/_ext/1472/bi.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1472/bi.o ../bi.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1472/bi.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1472/bi.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1472/av.o: ../av.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1472 + @${RM} ${OBJECTDIR}/_ext/1472/av.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1472/av.o ../av.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1472/av.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1472/av.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1386528437/wp.o: ../../../src/wp.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1386528437 + @${RM} ${OBJECTDIR}/_ext/1386528437/wp.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1386528437/wp.o ../../../src/wp.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1386528437/wp.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1386528437/wp.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1394255507/h_npdu.o: ../../../demo/handler/h_npdu.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1394255507 + @${RM} ${OBJECTDIR}/_ext/1394255507/h_npdu.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1394255507/h_npdu.o ../../../demo/handler/h_npdu.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1394255507/h_npdu.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1394255507/h_npdu.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1394255507/s_iam.o: ../../../demo/handler/s_iam.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1394255507 + @${RM} ${OBJECTDIR}/_ext/1394255507/s_iam.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1394255507/s_iam.o ../../../demo/handler/s_iam.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1394255507/s_iam.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1394255507/s_iam.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1386528437/bacreal.o: ../../../src/bacreal.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1386528437 + @${RM} ${OBJECTDIR}/_ext/1386528437/bacreal.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1386528437/bacreal.o ../../../src/bacreal.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1386528437/bacreal.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1386528437/bacreal.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1386528437/bacint.o: ../../../src/bacint.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1386528437 + @${RM} ${OBJECTDIR}/_ext/1386528437/bacint.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1386528437/bacint.o ../../../src/bacint.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1386528437/bacint.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1386528437/bacint.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1386528437/npdu.o: ../../../src/npdu.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1386528437 + @${RM} ${OBJECTDIR}/_ext/1386528437/npdu.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1386528437/npdu.o ../../../src/npdu.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1386528437/npdu.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1386528437/npdu.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1472/apdu.o: ../apdu.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1472 + @${RM} ${OBJECTDIR}/_ext/1472/apdu.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1472/apdu.o ../apdu.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1472/apdu.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1472/apdu.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1394255507/noserv.o: ../../../demo/handler/noserv.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1394255507 + @${RM} ${OBJECTDIR}/_ext/1394255507/noserv.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1394255507/noserv.o ../../../demo/handler/noserv.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1394255507/noserv.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1394255507/noserv.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1386528437/fifo.o: ../../../src/fifo.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1386528437 + @${RM} ${OBJECTDIR}/_ext/1386528437/fifo.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1386528437/fifo.o ../../../src/fifo.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1386528437/fifo.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1386528437/fifo.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1394255507/h_rp.o: ../../../demo/handler/h_rp.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1394255507 + @${RM} ${OBJECTDIR}/_ext/1394255507/h_rp.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1394255507/h_rp.o ../../../demo/handler/h_rp.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1394255507/h_rp.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1394255507/h_rp.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1394255507/h_wp.o: ../../../demo/handler/h_wp.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1394255507 + @${RM} ${OBJECTDIR}/_ext/1394255507/h_wp.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1394255507/h_wp.o ../../../demo/handler/h_wp.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1394255507/h_wp.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1394255507/h_wp.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1386528437/bacaddr.o: ../../../src/bacaddr.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1386528437 + @${RM} ${OBJECTDIR}/_ext/1386528437/bacaddr.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -D__DEBUG -D__MPLAB_DEBUGGER_ICD3=1 -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1386528437/bacaddr.o ../../../src/bacaddr.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1386528437/bacaddr.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1386528437/bacaddr.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +else +${OBJECTDIR}/_ext/1386528437/abort.o: ../../../src/abort.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1386528437 + @${RM} ${OBJECTDIR}/_ext/1386528437/abort.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1386528437/abort.o ../../../src/abort.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1386528437/abort.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1386528437/abort.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1386528437/bacapp.o: ../../../src/bacapp.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1386528437 + @${RM} ${OBJECTDIR}/_ext/1386528437/bacapp.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1386528437/bacapp.o ../../../src/bacapp.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1386528437/bacapp.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1386528437/bacapp.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1386528437/bacdcode.o: ../../../src/bacdcode.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1386528437 + @${RM} ${OBJECTDIR}/_ext/1386528437/bacdcode.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1386528437/bacdcode.o ../../../src/bacdcode.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1386528437/bacdcode.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1386528437/bacdcode.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1386528437/bacerror.o: ../../../src/bacerror.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1386528437 + @${RM} ${OBJECTDIR}/_ext/1386528437/bacerror.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1386528437/bacerror.o ../../../src/bacerror.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1386528437/bacerror.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1386528437/bacerror.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1386528437/bacstr.o: ../../../src/bacstr.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1386528437 + @${RM} ${OBJECTDIR}/_ext/1386528437/bacstr.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1386528437/bacstr.o ../../../src/bacstr.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1386528437/bacstr.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1386528437/bacstr.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1386528437/crc.o: ../../../src/crc.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1386528437 + @${RM} ${OBJECTDIR}/_ext/1386528437/crc.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1386528437/crc.o ../../../src/crc.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1386528437/crc.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1386528437/crc.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1386528437/dcc.o: ../../../src/dcc.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1386528437 + @${RM} ${OBJECTDIR}/_ext/1386528437/dcc.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1386528437/dcc.o ../../../src/dcc.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1386528437/dcc.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1386528437/dcc.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1386528437/iam.o: ../../../src/iam.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1386528437 + @${RM} ${OBJECTDIR}/_ext/1386528437/iam.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1386528437/iam.o ../../../src/iam.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1386528437/iam.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1386528437/iam.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1386528437/rd.o: ../../../src/rd.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1386528437 + @${RM} ${OBJECTDIR}/_ext/1386528437/rd.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1386528437/rd.o ../../../src/rd.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1386528437/rd.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1386528437/rd.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1386528437/reject.o: ../../../src/reject.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1386528437 + @${RM} ${OBJECTDIR}/_ext/1386528437/reject.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1386528437/reject.o ../../../src/reject.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1386528437/reject.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1386528437/reject.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1386528437/rp.o: ../../../src/rp.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1386528437 + @${RM} ${OBJECTDIR}/_ext/1386528437/rp.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1386528437/rp.o ../../../src/rp.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1386528437/rp.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1386528437/rp.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1386528437/whois.o: ../../../src/whois.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1386528437 + @${RM} ${OBJECTDIR}/_ext/1386528437/whois.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1386528437/whois.o ../../../src/whois.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1386528437/whois.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1386528437/whois.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1394255507/h_dcc.o: ../../../demo/handler/h_dcc.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1394255507 + @${RM} ${OBJECTDIR}/_ext/1394255507/h_dcc.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1394255507/h_dcc.o ../../../demo/handler/h_dcc.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1394255507/h_dcc.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1394255507/h_dcc.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1394255507/h_rd.o: ../../../demo/handler/h_rd.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1394255507 + @${RM} ${OBJECTDIR}/_ext/1394255507/h_rd.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1394255507/h_rd.o ../../../demo/handler/h_rd.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1394255507/h_rd.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1394255507/h_rd.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1472/main.o: ../main.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1472 + @${RM} ${OBJECTDIR}/_ext/1472/main.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1472/main.o ../main.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1472/main.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1472/main.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1472/dlmstp.o: ../dlmstp.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1472 + @${RM} ${OBJECTDIR}/_ext/1472/dlmstp.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1472/dlmstp.o ../dlmstp.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1472/dlmstp.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1472/dlmstp.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1472/device.o: ../device.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1472 + @${RM} ${OBJECTDIR}/_ext/1472/device.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1472/device.o ../device.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1472/device.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1472/device.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1472/rs485.o: ../rs485.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1472 + @${RM} ${OBJECTDIR}/_ext/1472/rs485.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1472/rs485.o ../rs485.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1472/rs485.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1472/rs485.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1472/isr.o: ../isr.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1472 + @${RM} ${OBJECTDIR}/_ext/1472/isr.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1472/isr.o ../isr.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1472/isr.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1472/isr.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1386528437/datetime.o: ../../../src/datetime.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1386528437 + @${RM} ${OBJECTDIR}/_ext/1386528437/datetime.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1386528437/datetime.o ../../../src/datetime.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1386528437/datetime.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1386528437/datetime.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1394255507/txbuf.o: ../../../demo/handler/txbuf.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1394255507 + @${RM} ${OBJECTDIR}/_ext/1394255507/txbuf.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1394255507/txbuf.o ../../../demo/handler/txbuf.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1394255507/txbuf.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1394255507/txbuf.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1394255507/h_whois.o: ../../../demo/handler/h_whois.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1394255507 + @${RM} ${OBJECTDIR}/_ext/1394255507/h_whois.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1394255507/h_whois.o ../../../demo/handler/h_whois.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1394255507/h_whois.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1394255507/h_whois.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1472/mstp.o: ../mstp.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1472 + @${RM} ${OBJECTDIR}/_ext/1472/mstp.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1472/mstp.o ../mstp.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1472/mstp.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1472/mstp.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1472/bv.o: ../bv.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1472 + @${RM} ${OBJECTDIR}/_ext/1472/bv.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1472/bv.o ../bv.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1472/bv.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1472/bv.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1472/ai.o: ../ai.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1472 + @${RM} ${OBJECTDIR}/_ext/1472/ai.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1472/ai.o ../ai.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1472/ai.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1472/ai.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1472/bi.o: ../bi.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1472 + @${RM} ${OBJECTDIR}/_ext/1472/bi.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1472/bi.o ../bi.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1472/bi.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1472/bi.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1472/av.o: ../av.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1472 + @${RM} ${OBJECTDIR}/_ext/1472/av.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1472/av.o ../av.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1472/av.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1472/av.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1386528437/wp.o: ../../../src/wp.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1386528437 + @${RM} ${OBJECTDIR}/_ext/1386528437/wp.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1386528437/wp.o ../../../src/wp.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1386528437/wp.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1386528437/wp.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1394255507/h_npdu.o: ../../../demo/handler/h_npdu.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1394255507 + @${RM} ${OBJECTDIR}/_ext/1394255507/h_npdu.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1394255507/h_npdu.o ../../../demo/handler/h_npdu.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1394255507/h_npdu.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1394255507/h_npdu.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1394255507/s_iam.o: ../../../demo/handler/s_iam.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1394255507 + @${RM} ${OBJECTDIR}/_ext/1394255507/s_iam.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1394255507/s_iam.o ../../../demo/handler/s_iam.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1394255507/s_iam.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1394255507/s_iam.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1386528437/bacreal.o: ../../../src/bacreal.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1386528437 + @${RM} ${OBJECTDIR}/_ext/1386528437/bacreal.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1386528437/bacreal.o ../../../src/bacreal.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1386528437/bacreal.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1386528437/bacreal.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1386528437/bacint.o: ../../../src/bacint.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1386528437 + @${RM} ${OBJECTDIR}/_ext/1386528437/bacint.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1386528437/bacint.o ../../../src/bacint.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1386528437/bacint.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1386528437/bacint.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1386528437/npdu.o: ../../../src/npdu.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1386528437 + @${RM} ${OBJECTDIR}/_ext/1386528437/npdu.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1386528437/npdu.o ../../../src/npdu.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1386528437/npdu.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1386528437/npdu.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1472/apdu.o: ../apdu.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1472 + @${RM} ${OBJECTDIR}/_ext/1472/apdu.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1472/apdu.o ../apdu.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1472/apdu.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1472/apdu.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1394255507/noserv.o: ../../../demo/handler/noserv.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1394255507 + @${RM} ${OBJECTDIR}/_ext/1394255507/noserv.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1394255507/noserv.o ../../../demo/handler/noserv.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1394255507/noserv.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1394255507/noserv.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1386528437/fifo.o: ../../../src/fifo.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1386528437 + @${RM} ${OBJECTDIR}/_ext/1386528437/fifo.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1386528437/fifo.o ../../../src/fifo.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1386528437/fifo.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1386528437/fifo.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1394255507/h_rp.o: ../../../demo/handler/h_rp.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1394255507 + @${RM} ${OBJECTDIR}/_ext/1394255507/h_rp.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1394255507/h_rp.o ../../../demo/handler/h_rp.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1394255507/h_rp.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1394255507/h_rp.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1394255507/h_wp.o: ../../../demo/handler/h_wp.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1394255507 + @${RM} ${OBJECTDIR}/_ext/1394255507/h_wp.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1394255507/h_wp.o ../../../demo/handler/h_wp.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1394255507/h_wp.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1394255507/h_wp.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +${OBJECTDIR}/_ext/1386528437/bacaddr.o: ../../../src/bacaddr.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} ${OBJECTDIR}/_ext/1386528437 + @${RM} ${OBJECTDIR}/_ext/1386528437/bacaddr.o.d + ${MP_CC} $(MP_EXTRA_CC_PRE) -p$(MP_PROCESSOR_OPTION) -DPRINT_ENABLED=0 -DBACDL_MSTP=1 -DBIG_ENDIAN=0 -DMAX_APDU=50 -DMAX_TSM_TRANSACTIONS=0 -DBACAPP_MINIMAL -I"../" -I"../../../include" -I"../../../demo/object" -ml -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1386528437/bacaddr.o ../../../src/bacaddr.c + @${DEP_GEN} -d ${OBJECTDIR}/_ext/1386528437/bacaddr.o + @${FIXDEPS} "${OBJECTDIR}/_ext/1386528437/bacaddr.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18 + +endif + +# ------------------------------------------------------------------------------------ +# Rules for buildStep: link +ifeq ($(TYPE_IMAGE), DEBUG_RUN) +dist/${CND_CONF}/${IMAGE_TYPE}/BACnet-Server.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX}: ${OBJECTFILES} nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} dist/${CND_CONF}/${IMAGE_TYPE} + ${MP_LD} $(MP_EXTRA_LD_PRE) -p$(MP_PROCESSOR_OPTION_LD) -w -x -u_DEBUG -z__MPLAB_BUILD=1 -u_CRUNTIME -z__MPLAB_DEBUG=1 -z__MPLAB_DEBUGGER_ICD3=1 $(MP_LINKER_DEBUG_OPTION) -l ${MP_CC_DIR}\\..\\lib -o dist/${CND_CONF}/${IMAGE_TYPE}/BACnet-Server.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX} ${OBJECTFILES_QUOTED_IF_SPACED} +else +dist/${CND_CONF}/${IMAGE_TYPE}/BACnet-Server.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX}: ${OBJECTFILES} nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} dist/${CND_CONF}/${IMAGE_TYPE} + ${MP_LD} $(MP_EXTRA_LD_PRE) -p$(MP_PROCESSOR_OPTION_LD) -w -z__MPLAB_BUILD=1 -u_CRUNTIME -l ${MP_CC_DIR}\\..\\lib -o dist/${CND_CONF}/${IMAGE_TYPE}/BACnet-Server.X.${IMAGE_TYPE}.${DEBUGGABLE_SUFFIX} ${OBJECTFILES_QUOTED_IF_SPACED} +endif + + +# Subprojects +.build-subprojects: + + +# Subprojects +.clean-subprojects: + +# Clean Targets +.clean-conf: ${CLEAN_SUBPROJECTS} + ${RM} -r build/default + ${RM} -r dist/default + +# Enable dependency checking +.dep.inc: .depcheck-impl + +DEPFILES=$(shell mplabwildcard ${POSSIBLE_DEPFILES}) +ifneq (${DEPFILES},) +include ${DEPFILES} +endif diff --git a/bacnet-stack/ports/pic18f97j60/BACnet-Server.X/nbproject/Makefile-genesis.properties b/bacnet-stack/ports/pic18f97j60/BACnet-Server.X/nbproject/Makefile-genesis.properties new file mode 100644 index 00000000..db24bb04 --- /dev/null +++ b/bacnet-stack/ports/pic18f97j60/BACnet-Server.X/nbproject/Makefile-genesis.properties @@ -0,0 +1,8 @@ +# +#Mon May 30 09:28:30 CDT 2016 +default.com-microchip-mplab-nbide-toolchainC18-C18LanguageToolchain.md5=21ae92f54c0f89bc027339aedc19b7f9 +default.languagetoolchain.dir=C\:\\Program Files (x86)\\Microchip\\mplabc18\\v3.40\\bin +com-microchip-mplab-nbide-embedded-makeproject-MakeProject.md5=ef199adcc8f049579a105cca20571dcb +default.languagetoolchain.version=3.40 +host.platform=windows +conf.ids=default diff --git a/bacnet-stack/ports/pic18f97j60/BACnet-Server.X/nbproject/Makefile-impl.mk b/bacnet-stack/ports/pic18f97j60/BACnet-Server.X/nbproject/Makefile-impl.mk new file mode 100644 index 00000000..cfa87f01 --- /dev/null +++ b/bacnet-stack/ports/pic18f97j60/BACnet-Server.X/nbproject/Makefile-impl.mk @@ -0,0 +1,69 @@ +# +# Generated Makefile - do not edit! +# +# Edit the Makefile in the project folder instead (../Makefile). Each target +# has a pre- and a post- target defined where you can add customization code. +# +# This makefile implements macros and targets common to all configurations. +# +# NOCDDL + + +# Building and Cleaning subprojects are done by default, but can be controlled with the SUB +# macro. If SUB=no, subprojects will not be built or cleaned. The following macro +# statements set BUILD_SUB-CONF and CLEAN_SUB-CONF to .build-reqprojects-conf +# and .clean-reqprojects-conf unless SUB has the value 'no' +SUB_no=NO +SUBPROJECTS=${SUB_${SUB}} +BUILD_SUBPROJECTS_=.build-subprojects +BUILD_SUBPROJECTS_NO= +BUILD_SUBPROJECTS=${BUILD_SUBPROJECTS_${SUBPROJECTS}} +CLEAN_SUBPROJECTS_=.clean-subprojects +CLEAN_SUBPROJECTS_NO= +CLEAN_SUBPROJECTS=${CLEAN_SUBPROJECTS_${SUBPROJECTS}} + + +# Project Name +PROJECTNAME=BACnet-Server.X + +# Active Configuration +DEFAULTCONF=default +CONF=${DEFAULTCONF} + +# All Configurations +ALLCONFS=default + + +# build +.build-impl: .build-pre + ${MAKE} -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .build-conf + + +# clean +.clean-impl: .clean-pre + ${MAKE} -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .clean-conf + +# clobber +.clobber-impl: .clobber-pre .depcheck-impl + ${MAKE} SUBPROJECTS=${SUBPROJECTS} CONF=default clean + + + +# all +.all-impl: .all-pre .depcheck-impl + ${MAKE} SUBPROJECTS=${SUBPROJECTS} CONF=default build + + + +# dependency checking support +.depcheck-impl: +# @echo "# This code depends on make tool being used" >.dep.inc +# @if [ -n "${MAKE_VERSION}" ]; then \ +# echo "DEPFILES=\$$(wildcard \$$(addsuffix .d, \$${OBJECTFILES}))" >>.dep.inc; \ +# echo "ifneq (\$${DEPFILES},)" >>.dep.inc; \ +# echo "include \$${DEPFILES}" >>.dep.inc; \ +# echo "endif" >>.dep.inc; \ +# else \ +# echo ".KEEP_STATE:" >>.dep.inc; \ +# echo ".KEEP_STATE_FILE:.make.state.\$${CONF}" >>.dep.inc; \ +# fi diff --git a/bacnet-stack/ports/pic18f97j60/BACnet-Server.X/nbproject/Makefile-local-default.mk b/bacnet-stack/ports/pic18f97j60/BACnet-Server.X/nbproject/Makefile-local-default.mk new file mode 100644 index 00000000..715a50f6 --- /dev/null +++ b/bacnet-stack/ports/pic18f97j60/BACnet-Server.X/nbproject/Makefile-local-default.mk @@ -0,0 +1,37 @@ +# +# Generated Makefile - do not edit! +# +# +# This file contains information about the location of compilers and other tools. +# If you commmit this file into your revision control server, you will be able to +# to checkout the project and build it from the command line with make. However, +# if more than one person works on the same project, then this file might show +# conflicts since different users are bound to have compilers in different places. +# In that case you might choose to not commit this file and let MPLAB X recreate this file +# for each user. The disadvantage of not commiting this file is that you must run MPLAB X at +# least once so the file gets created and the project can be built. Finally, you can also +# avoid using this file at all if you are only building from the command line with make. +# You can invoke make with the values of the macros: +# $ makeMP_CC="/opt/microchip/mplabc30/v3.30c/bin/pic30-gcc" ... +# +SHELL=cmd.exe +PATH_TO_IDE_BIN=C:/Program Files (x86)/Microchip/MPLABX/mplab_ide/mplab_ide/modules/../../bin/ +# Adding MPLAB X bin directory to path. +PATH:=C:/Program Files (x86)/Microchip/MPLABX/mplab_ide/mplab_ide/modules/../../bin/:$(PATH) +# Path to java used to run MPLAB X when this makefile was created +MP_JAVA_PATH="C:\Program Files (x86)\Microchip\MPLABX\sys\java\jre1.6.0_32-windows-x64\java-windows/bin/" +OS_CURRENT="$(shell uname -s)" +MP_CC="C:\Program Files (x86)\Microchip\mplabc18\v3.40\bin\mcc18.exe" +# MP_CPPC is not defined +# MP_BC is not defined +MP_AS="C:\Program Files (x86)\Microchip\mplabc18\v3.40\bin\..\mpasm\MPASMWIN.exe" +MP_LD="C:\Program Files (x86)\Microchip\mplabc18\v3.40\bin\mplink.exe" +MP_AR="C:\Program Files (x86)\Microchip\mplabc18\v3.40\bin\mplib.exe" +DEP_GEN=${MP_JAVA_PATH}java -jar "C:/Program Files (x86)/Microchip/MPLABX/mplab_ide/mplab_ide/modules/../../bin/extractobjectdependencies.jar" +MP_CC_DIR="C:\Program Files (x86)\Microchip\mplabc18\v3.40\bin" +# MP_CPPC_DIR is not defined +# MP_BC_DIR is not defined +MP_AS_DIR="C:\Program Files (x86)\Microchip\mplabc18\v3.40\bin\..\mpasm" +MP_LD_DIR="C:\Program Files (x86)\Microchip\mplabc18\v3.40\bin" +MP_AR_DIR="C:\Program Files (x86)\Microchip\mplabc18\v3.40\bin" +# MP_BC_DIR is not defined diff --git a/bacnet-stack/ports/pic18f97j60/BACnet-Server.X/nbproject/Makefile-variables.mk b/bacnet-stack/ports/pic18f97j60/BACnet-Server.X/nbproject/Makefile-variables.mk new file mode 100644 index 00000000..204009b0 --- /dev/null +++ b/bacnet-stack/ports/pic18f97j60/BACnet-Server.X/nbproject/Makefile-variables.mk @@ -0,0 +1,13 @@ +# +# Generated - do not edit! +# +# NOCDDL +# +CND_BASEDIR=`pwd` +# default configuration +CND_ARTIFACT_DIR_default=dist/default/production +CND_ARTIFACT_NAME_default=BACnet-Server.X.production.hex +CND_ARTIFACT_PATH_default=dist/default/production/BACnet-Server.X.production.hex +CND_PACKAGE_DIR_default=${CND_DISTDIR}/default/package +CND_PACKAGE_NAME_default=bacnet-server.x.tar +CND_PACKAGE_PATH_default=${CND_DISTDIR}/default/package/bacnet-server.x.tar diff --git a/bacnet-stack/ports/pic18f97j60/BACnet-Server.X/nbproject/Package-default.bash b/bacnet-stack/ports/pic18f97j60/BACnet-Server.X/nbproject/Package-default.bash new file mode 100644 index 00000000..fe987452 --- /dev/null +++ b/bacnet-stack/ports/pic18f97j60/BACnet-Server.X/nbproject/Package-default.bash @@ -0,0 +1,73 @@ +#!/bin/bash -x + +# +# Generated - do not edit! +# + +# Macros +TOP=`pwd` +CND_CONF=default +CND_DISTDIR=dist +TMPDIR=build/${CND_CONF}/${IMAGE_TYPE}/tmp-packaging +TMPDIRNAME=tmp-packaging +OUTPUT_PATH=dist/${CND_CONF}/${IMAGE_TYPE}/BACnet-Server.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX} +OUTPUT_BASENAME=BACnet-Server.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX} +PACKAGE_TOP_DIR=bacnet-server.x/ + +# Functions +function checkReturnCode +{ + rc=$? + if [ $rc != 0 ] + then + exit $rc + fi +} +function makeDirectory +# $1 directory path +# $2 permission (optional) +{ + mkdir -p "$1" + checkReturnCode + if [ "$2" != "" ] + then + chmod $2 "$1" + checkReturnCode + fi +} +function copyFileToTmpDir +# $1 from-file path +# $2 to-file path +# $3 permission +{ + cp "$1" "$2" + checkReturnCode + if [ "$3" != "" ] + then + chmod $3 "$2" + checkReturnCode + fi +} + +# Setup +cd "${TOP}" +mkdir -p ${CND_DISTDIR}/${CND_CONF}/package +rm -rf ${TMPDIR} +mkdir -p ${TMPDIR} + +# Copy files and create directories and links +cd "${TOP}" +makeDirectory ${TMPDIR}/bacnet-server.x/bin +copyFileToTmpDir "${OUTPUT_PATH}" "${TMPDIR}/${PACKAGE_TOP_DIR}bin/${OUTPUT_BASENAME}" 0755 + + +# Generate tar file +cd "${TOP}" +rm -f ${CND_DISTDIR}/${CND_CONF}/package/bacnet-server.x.tar +cd ${TMPDIR} +tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/package/bacnet-server.x.tar * +checkReturnCode + +# Cleanup +cd "${TOP}" +rm -rf ${TMPDIR} diff --git a/bacnet-stack/ports/pic18f97j60/BACnet-Server.X/nbproject/configurations.xml b/bacnet-stack/ports/pic18f97j60/BACnet-Server.X/nbproject/configurations.xml new file mode 100644 index 00000000..18b0ec6a --- /dev/null +++ b/bacnet-stack/ports/pic18f97j60/BACnet-Server.X/nbproject/configurations.xml @@ -0,0 +1,198 @@ + + + + + ../stdbool.h + ../stdint.h + ../rs485.h + ../mstp.h + ../../../include/bits.h + ../../../include/abort.h + ../../../include/apdu.h + ../../../include/bacaddr.h + ../../../include/bacapp.h + ../../../include/bacdcode.h + ../../../include/bacdef.h + ../../../include/bacenum.h + ../../../include/bacerror.h + ../../../include/bacint.h + ../../../include/bacprop.h + ../../../include/bacreal.h + ../../../include/bacstr.h + ../../../include/bigend.h + ../../../include/config.h + ../hardware.h + + + + + ../../../src/abort.c + ../../../src/bacapp.c + ../../../src/bacdcode.c + ../../../src/bacerror.c + ../../../src/bacstr.c + ../../../src/crc.c + ../../../src/dcc.c + ../../../src/iam.c + ../../../src/rd.c + ../../../src/reject.c + ../../../src/rp.c + ../../../src/whois.c + ../../../demo/handler/h_dcc.c + ../../../demo/handler/h_rd.c + ../main.c + ../dlmstp.c + ../device.c + ../rs485.c + ../isr.c + ../../../src/datetime.c + ../../../demo/handler/txbuf.c + ../../../demo/handler/h_whois.c + ../mstp.c + ../bv.c + ../ai.c + ../bi.c + ../av.c + ../../../src/wp.c + ../../../demo/handler/h_npdu.c + ../../../demo/handler/s_iam.c + ../../../src/bacreal.c + ../../../src/bacint.c + ../../../src/npdu.c + ../apdu.c + ../../../demo/handler/noserv.c + ../../../src/fifo.c + ../../../demo/handler/h_rp.c + ../../../demo/handler/h_wp.c + ../../../src/bacaddr.c + + + Makefile + + + + ../ + + Makefile + + + + localhost + PIC18F97J60 + + + ICD3PlatformTool + C18 + + 3 + + + + + + + + false + + + + + false + + false + + false + false + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bacnet-stack/ports/pic18f97j60/BACnet-Server.X/nbproject/private/configurations.xml b/bacnet-stack/ports/pic18f97j60/BACnet-Server.X/nbproject/private/configurations.xml new file mode 100644 index 00000000..5fcfb04f --- /dev/null +++ b/bacnet-stack/ports/pic18f97j60/BACnet-Server.X/nbproject/private/configurations.xml @@ -0,0 +1,25 @@ + + + Makefile + 0 + + + + + + place holder 1 + place holder 2 + + + + + true + 0 + 0 + 0 + + + + + + diff --git a/bacnet-stack/ports/pic18f97j60/BACnet-Server.X/nbproject/private/private.xml b/bacnet-stack/ports/pic18f97j60/BACnet-Server.X/nbproject/private/private.xml new file mode 100644 index 00000000..bf1ea206 --- /dev/null +++ b/bacnet-stack/ports/pic18f97j60/BACnet-Server.X/nbproject/private/private.xml @@ -0,0 +1,11 @@ + + + + + file:/D:/code/bacnet-stack/ports/pic18f97j60/main.c + file:/D:/code/bacnet-stack/ports/pic18f97j60/isr.c + file:/D:/code/bacnet-stack/ports/pic18f97j60/rs485.h + file:/D:/code/bacnet-stack/ports/pic18f97j60/rs485.c + file:/D:/code/bacnet-stack/ports/pic18f97j60/hardware.h + + diff --git a/bacnet-stack/ports/pic18f97j60/BACnet-Server.X/nbproject/project.properties b/bacnet-stack/ports/pic18f97j60/BACnet-Server.X/nbproject/project.properties new file mode 100644 index 00000000..e69de29b diff --git a/bacnet-stack/ports/pic18f97j60/BACnet-Server.X/nbproject/project.xml b/bacnet-stack/ports/pic18f97j60/BACnet-Server.X/nbproject/project.xml new file mode 100644 index 00000000..6c3e07d6 --- /dev/null +++ b/bacnet-stack/ports/pic18f97j60/BACnet-Server.X/nbproject/project.xml @@ -0,0 +1,16 @@ + + + com.microchip.mplab.nbide.embedded.makeproject + + + BACnet-Server + e54ca906-513b-4f74-a23b-6b0204c4509a + 0 + c + + h + ISO-8859-1 + + + + diff --git a/bacnet-stack/ports/pic18f97j60/Makefile b/bacnet-stack/ports/pic18f97j60/Makefile new file mode 100644 index 00000000..24366525 --- /dev/null +++ b/bacnet-stack/ports/pic18f97j60/Makefile @@ -0,0 +1,164 @@ +############################################################################### +# Makefile for BACnet +############################################################################### + +## General Flags +MCU = pic18 +PORT = 18f6720 +TARGET = bacnet +## Tools +CC = sdcc +PACK = packihx + +# Source locations +BACNET_CORE = ../../src +BACNET_INCLUDE = ../../include +BACNET_DEMO = ../../demo + +CSRC = main.c \ + isr.c \ + rs485.c \ + dlmstp.c \ + mstp.c \ + $(BACNET_CORE)/crc.c + +DEMOSRC = h_rp.c \ + device.c \ + ai.c \ + av.c \ + bi.c \ + bv.c \ + $(BACNET_DEMO)/handler/txbuf.c \ + $(BACNET_DEMO)/handler/noserv.c \ + $(BACNET_DEMO)/handler/h_npdu.c \ + $(BACNET_DEMO)/handler/h_whois.c \ + h_wp.c + +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)/iam.c \ + $(BACNET_CORE)/rp.c \ + $(BACNET_CORE)/wp.c \ + $(BACNET_CORE)/whois.c \ + $(BACNET_CORE)/bacaddr.c \ + $(BACNET_CORE)/abort.c \ + $(BACNET_CORE)/reject.c \ + $(BACNET_CORE)/bacerror.c \ + $(BACNET_CORE)/bacapp.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 = -m$(MCU) -p$(PORT) +OPTIMIZATION = --opt-code-size + +## Compile options common for all C compilation units. +BFLAGS = -DBACDL_MSTP +BFLAGS += -DMAX_APDU=128 +BFLAGS += -DBIG_ENDIAN=0 +BFLAGS += -DMAX_TSM_TRANSACTIONS=0 +#BFLAGS += -DCRC_USE_TABLE +BFLAGS += -DBACAPP_REAL +CFLAGS = $(COMMON) +# dead code removal +CFLAGS += -ffunction-sections -fdata-sections +CFLAGS += -Wall $(BFLAGS) $(OPTIMIZATION) +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,--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: + touch Makefile + -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/*) diff --git a/bacnet-stack/ports/pic18f97j60/ai.c b/bacnet-stack/ports/pic18f97j60/ai.c new file mode 100644 index 00000000..07d07c39 --- /dev/null +++ b/bacnet-stack/ports/pic18f97j60/ai.c @@ -0,0 +1,174 @@ +/************************************************************************** +* +* Copyright (C) 2005 Steve Karg +* +* 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. +* +*********************************************************************/ + +/* Analog Input Objects customize for your use */ + +#include +#include +#include +#include "bacdef.h" +#include "bacdcode.h" +#include "bacenum.h" +#include "config.h" +#include "wp.h" +#include "rp.h" +#include "ai.h" + +/* Analog Input = Photocell */ +#define MAX_ANALOG_INPUTS 2 + +static uint8_t Present_Value[MAX_ANALOG_INPUTS]; + +/* we simply have 0-n object instances. Yours might be */ +/* more complex, and then you need validate that the */ +/* given instance exists */ +bool Analog_Input_Valid_Instance( + uint32_t object_instance) +{ + if (object_instance < MAX_ANALOG_INPUTS) + return true; + + return false; +} + +/* we simply have 0-n object instances. */ +unsigned Analog_Input_Count( + void) +{ + return MAX_ANALOG_INPUTS; +} + +/* we simply have 0-n object instances. */ +uint32_t Analog_Input_Index_To_Instance( + unsigned index) +{ + return index; +} + +char *Analog_Input_Name( + uint32_t object_instance) +{ + static char text_string[16] = ""; /* okay for single thread */ + + if (object_instance < MAX_ANALOG_INPUTS) { + sprintf(text_string, "AI-%lu", (unsigned long) object_instance); + return text_string; + } + + return NULL; +} + +float Analog_Input_Present_Value( + uint32_t object_instance) +{ + float value = 0.0; + + if (object_instance < MAX_ANALOG_INPUTS) + value = Present_Value[object_instance]; + + return value; +} + +void Analog_Input_Present_Value_Set( + uint32_t object_instance, + float value) +{ + if (object_instance < MAX_ANALOG_INPUTS) { + Present_Value[object_instance] = value; + } +} + +/* return apdu length, or -1 on error */ +/* assumption - object has already exists */ +int Analog_Input_Read_Property( + BACNET_READ_PROPERTY_DATA * rpdata) +{ + int apdu_len = 0; /* return value */ + BACNET_BIT_STRING bit_string; + BACNET_CHARACTER_STRING char_string; + uint8_t *apdu = NULL; + + if ((rpdata == NULL) || (rpdata->application_data == NULL) || + (rpdata->application_data_len == 0)) { + return 0; + } + apdu = rpdata->application_data; + switch (rpdata->object_property) { + case PROP_OBJECT_IDENTIFIER: + apdu_len = + encode_application_object_id(&apdu[0], OBJECT_ANALOG_INPUT, + rpdata->object_instance); + break; + /* note: Name and Description don't have to be the same. + You could make Description writable and different */ + case PROP_OBJECT_NAME: + case PROP_DESCRIPTION: + characterstring_init_ansi(&char_string, + Analog_Input_Name(rpdata->object_instance)); + apdu_len = + encode_application_character_string(&apdu[0], &char_string); + break; + case PROP_OBJECT_TYPE: + apdu_len = + encode_application_enumerated(&apdu[0], OBJECT_ANALOG_INPUT); + break; + case PROP_PRESENT_VALUE: + apdu_len = + encode_application_real(&apdu[0], + Analog_Input_Present_Value(rpdata->object_instance)); + break; + case PROP_STATUS_FLAGS: + bitstring_init(&bit_string); + bitstring_set_bit(&bit_string, STATUS_FLAG_IN_ALARM, false); + bitstring_set_bit(&bit_string, STATUS_FLAG_FAULT, false); + bitstring_set_bit(&bit_string, STATUS_FLAG_OVERRIDDEN, false); + bitstring_set_bit(&bit_string, STATUS_FLAG_OUT_OF_SERVICE, false); + apdu_len = encode_application_bitstring(&apdu[0], &bit_string); + break; + case PROP_EVENT_STATE: + apdu_len = + encode_application_enumerated(&apdu[0], EVENT_STATE_NORMAL); + break; + case PROP_OUT_OF_SERVICE: + apdu_len = encode_application_boolean(&apdu[0], false); + break; + case PROP_UNITS: + apdu_len = encode_application_enumerated(&apdu[0], UNITS_PERCENT); + break; + default: + rpdata->error_class = ERROR_CLASS_PROPERTY; + rpdata->error_code = ERROR_CODE_UNKNOWN_PROPERTY; + apdu_len = -1; + break; + } + /* only array properties can have array options */ + if ((apdu_len >= 0) && (rpdata->array_index != BACNET_ARRAY_ALL)) { + rpdata->error_class = ERROR_CLASS_PROPERTY; + rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY; + apdu_len = -1; + } + + return apdu_len; +} diff --git a/bacnet-stack/ports/pic18f97j60/apdu.c b/bacnet-stack/ports/pic18f97j60/apdu.c new file mode 100644 index 00000000..d1ba05be --- /dev/null +++ b/bacnet-stack/ports/pic18f97j60/apdu.c @@ -0,0 +1,232 @@ +/*####COPYRIGHTBEGIN#### + ------------------------------------------- + Copyright (C) 2007 Steve Karg + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to: + The Free Software Foundation, Inc. + 59 Temple Place - Suite 330 + Boston, MA 02111-1307, USA. + + As a special exception, if other files instantiate templates or + use macros or inline functions from this file, or you compile + this file and link it with other works to produce a work based + on this file, this file does not by itself cause the resulting + work to be covered by the GNU General Public License. However + the source code for this file must still be made available in + accordance with section (3) of the GNU General Public License. + + This exception does not invalidate any other reasons why a work + based on this file might be covered by the GNU General Public + License. + ------------------------------------------- +####COPYRIGHTEND####*/ +#include +#include +#include +#include "bits.h" +#include "bacdef.h" +#include "bacdcode.h" +#include "bacenum.h" +#include "dcc.h" +#include "handlers.h" +/* me */ +#include "apdu.h" + +uint16_t apdu_timeout( + void) +{ + return 3000; +} + +uint8_t apdu_retries( + void) +{ + return 3; +} + +bool apdu_service_supported( + BACNET_SERVICES_SUPPORTED service_supported) +{ + bool status = false; + + switch (service_supported) { + case SERVICE_SUPPORTED_READ_PROPERTY: + case SERVICE_SUPPORTED_WHO_IS: + case SERVICE_CONFIRMED_REINITIALIZE_DEVICE: + case SERVICE_SUPPORTED_WRITE_PROPERTY: + case SERVICE_CONFIRMED_DEVICE_COMMUNICATION_CONTROL: + status = true; + break; + default: + break; + } + + return status; +} + +uint16_t apdu_decode_confirmed_service_request( + uint8_t * apdu, /* APDU data */ + uint16_t apdu_len, + BACNET_CONFIRMED_SERVICE_DATA * service_data, + uint8_t * service_choice, + uint8_t ** service_request, + uint16_t * service_request_len) +{ + uint16_t len = 0; /* counts where we are in PDU */ + + service_data->segmented_message = (apdu[0] & BIT3) ? true : false; + service_data->more_follows = (apdu[0] & BIT2) ? true : false; + service_data->segmented_response_accepted = + (apdu[0] & BIT1) ? true : false; + service_data->max_segs = decode_max_segs(apdu[1]); + service_data->max_resp = decode_max_apdu(apdu[1]); + service_data->invoke_id = apdu[2]; + len = 3; + if (service_data->segmented_message) { + service_data->sequence_number = apdu[len++]; + service_data->proposed_window_number = apdu[len++]; + } + *service_choice = apdu[len++]; + *service_request = &apdu[len]; + *service_request_len = apdu_len - len; + + return len; +} + +/* When network communications are completely disabled, + only DeviceCommunicationControl and ReinitializeDevice APDUs + shall be processed and no messages shall be initiated. + When the initiation of communications is disabled, + all APDUs shall be processed and responses returned as + required... */ +static bool apdu_confirmed_dcc_disabled( + uint8_t service_choice) +{ + bool status = false; + + if (dcc_communication_disabled()) { + switch (service_choice) { + case SERVICE_CONFIRMED_DEVICE_COMMUNICATION_CONTROL: + case SERVICE_CONFIRMED_REINITIALIZE_DEVICE: + break; + default: + status = true; + break; + } + } + + return status; +} + +/* When network communications are completely disabled, + only DeviceCommunicationControl and ReinitializeDevice APDUs + shall be processed and no messages shall be initiated. */ +/* If the request is valid and the 'Enable/Disable' parameter is + DISABLE_INITIATION, the responding BACnet-user shall + discontinue the initiation of messages except for I-Am + requests issued in accordance with the Who-Is service procedure.*/ +static bool apdu_unconfirmed_dcc_disabled( + uint8_t service_choice) +{ + bool status = false; + + if (dcc_communication_disabled()) { + /* there are no Unconfirmed messages that + can be processed in this state */ + status = true; + } else if (dcc_communication_initiation_disabled()) { + /* WhoIs will be processed and I-Am initiated as response. */ + switch (service_choice) { + case SERVICE_UNCONFIRMED_WHO_IS: + break; + default: + status = true; + break; + } + } + + return status; +} + +void apdu_handler( + BACNET_ADDRESS * src, + uint8_t * apdu, /* APDU data */ + uint16_t apdu_len) +{ + BACNET_CONFIRMED_SERVICE_DATA service_data = { 0 }; + uint8_t service_choice = 0; + uint8_t *service_request = NULL; + uint16_t service_request_len = 0; + uint16_t len = 0; /* counts where we are in PDU */ + + if (apdu) { + /* PDU Type */ + switch (apdu[0] & 0xF0) { + case PDU_TYPE_CONFIRMED_SERVICE_REQUEST: + len = apdu_decode_confirmed_service_request(&apdu[0], /* APDU data */ + apdu_len, &service_data, &service_choice, &service_request, + &service_request_len); + if (apdu_confirmed_dcc_disabled(service_choice)) { + /* When network communications are completely disabled, + only DeviceCommunicationControl and ReinitializeDevice APDUs + shall be processed and no messages shall be initiated. */ + break; + } + if (service_choice == SERVICE_CONFIRMED_READ_PROPERTY) { + handler_read_property(service_request, service_request_len, + src, &service_data); + } else if (service_choice == SERVICE_CONFIRMED_WRITE_PROPERTY) { + handler_write_property(service_request, + service_request_len, src, &service_data); + } else if (service_choice == + SERVICE_CONFIRMED_REINITIALIZE_DEVICE) { + handler_reinitialize_device(service_request, + service_request_len, src, &service_data); + } else if (service_choice == + SERVICE_CONFIRMED_DEVICE_COMMUNICATION_CONTROL) { + handler_device_communication_control(service_request, + service_request_len, src, &service_data); + } else { + handler_unrecognized_service(service_request, + service_request_len, src, &service_data); + } + break; + case PDU_TYPE_UNCONFIRMED_SERVICE_REQUEST: + service_choice = apdu[1]; + service_request = &apdu[2]; + service_request_len = apdu_len - 2; + if (apdu_unconfirmed_dcc_disabled(service_choice)) { + /* When network communications are disabled, + only DeviceCommunicationControl and ReinitializeDevice APDUs + shall be processed and no messages shall be initiated. + If communications have been initiation disabled, then + WhoIs may be processed. */ + break; + } + if (service_choice == SERVICE_UNCONFIRMED_WHO_IS) { + handler_who_is(service_request, service_request_len, src); + } + break; + case PDU_TYPE_SIMPLE_ACK: + case PDU_TYPE_COMPLEX_ACK: + case PDU_TYPE_SEGMENT_ACK: + case PDU_TYPE_ERROR: + case PDU_TYPE_REJECT: + case PDU_TYPE_ABORT: + default: + break; + } + } + return; +} diff --git a/bacnet-stack/ports/pic18f97j60/av.c b/bacnet-stack/ports/pic18f97j60/av.c new file mode 100644 index 00000000..96790671 --- /dev/null +++ b/bacnet-stack/ports/pic18f97j60/av.c @@ -0,0 +1,413 @@ +/************************************************************************** +* +* Copyright (C) 2006 Steve Karg +* +* 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. +* +*********************************************************************/ + +/* Analog Value Objects - customize for your use */ + +#include +#include +#include +#include "bacdef.h" +#include "bacdcode.h" +#include "bacenum.h" +#include "bacapp.h" +#include "config.h" /* the custom stuff */ +#include "wp.h" +#include "rp.h" +#include "av.h" + +#define MAX_ANALOG_VALUES 4 + +/* we choose to have a NULL level in our system represented by */ +/* a particular value. When the priorities are not in use, they */ +/* will be relinquished (i.e. set to the NULL level). */ +#define ANALOG_LEVEL_NULL 255 +/* When all the priorities are level null, the present value returns */ +/* the Relinquish Default value */ +#define ANALOG_RELINQUISH_DEFAULT 0 +/* Here is our Present_Value. They are supposed to be Real, but */ +/* we don't have that kind of memory, so we will use a single byte */ +/* and load a Real for returning the value when asked. */ +static uint8_t Present_Value[MAX_ANALOG_VALUES]; + +/* we need to have our arrays initialized before answering any calls */ +static bool Analog_Value_Initialized = false; + +void Analog_Value_Init( + void) +{ + unsigned i; + + if (!Analog_Value_Initialized) { + Analog_Value_Initialized = true; + + /* initialize all the analog output priority arrays to NULL */ + for (i = 0; i < MAX_ANALOG_VALUES; i++) { + Present_Value[i] = ANALOG_LEVEL_NULL; + } + } + + return; +} + +/* we simply have 0-n object instances. Yours might be */ +/* more complex, and then you need validate that the */ +/* given instance exists */ +bool Analog_Value_Valid_Instance( + uint32_t object_instance) +{ + Analog_Value_Init(); + if (object_instance < MAX_ANALOG_VALUES) + return true; + + return false; +} + +/* we simply have 0-n object instances. Yours might be */ +/* more complex, and then count how many you have */ +unsigned Analog_Value_Count( + void) +{ + Analog_Value_Init(); + return MAX_ANALOG_VALUES; +} + +/* we simply have 0-n object instances. Yours might be */ +/* more complex, and then you need to return the instance */ +/* that correlates to the correct index */ +uint32_t Analog_Value_Index_To_Instance( + unsigned index) +{ + Analog_Value_Init(); + return index; +} + +/* we simply have 0-n object instances. Yours might be */ +/* more complex, and then you need to return the index */ +/* that correlates to the correct instance number */ +unsigned Analog_Value_Instance_To_Index( + uint32_t object_instance) +{ + unsigned index = MAX_ANALOG_VALUES; + + Analog_Value_Init(); + if (object_instance < MAX_ANALOG_VALUES) + index = object_instance; + + return index; +} + +float Analog_Value_Present_Value( + uint32_t object_instance) +{ + float value = ANALOG_RELINQUISH_DEFAULT; + unsigned index = 0; + unsigned i = 0; + + Analog_Value_Init(); + index = Analog_Value_Instance_To_Index(object_instance); + if (index < MAX_ANALOG_VALUES) { + value = Present_Value[index]; + } + + return value; +} + +/* note: the object name must be unique within this device */ +char *Analog_Value_Name( + uint32_t object_instance) +{ + static char text_string[32] = ""; /* okay for single thread */ + + if (object_instance < MAX_ANALOG_VALUES) { + sprintf(text_string, "AV-%lu", object_instance); + return text_string; + } + + return NULL; +} + +/* return apdu len, or -1 on error */ +int Analog_Value_Read_Property( + BACNET_READ_PROPERTY_DATA * rpdata) +{ + int len = 0; + int apdu_len = 0; /* return value */ + BACNET_BIT_STRING bit_string; + BACNET_CHARACTER_STRING char_string; + float real_value = (float) 1.414; + unsigned object_index = 0; + unsigned i = 0; + bool state = false; + uint8_t *apdu = NULL; + + Analog_Value_Init(); + if ((rpdata == NULL) || (rpdata->application_data == NULL) || + (rpdata->application_data_len == 0)) { + return 0; + } + apdu = rpdata->application_data; + switch (rpdata->object_property) { + case PROP_OBJECT_IDENTIFIER: + apdu_len = + encode_application_object_id(&apdu[0], OBJECT_ANALOG_VALUE, + rpdata->object_instance); + break; + case PROP_OBJECT_NAME: + case PROP_DESCRIPTION: + characterstring_init_ansi(&char_string, + Analog_Value_Name(rpdata->object_instance)); + apdu_len = + encode_application_character_string(&apdu[0], &char_string); + break; + case PROP_OBJECT_TYPE: + apdu_len = + encode_application_enumerated(&apdu[0], OBJECT_ANALOG_VALUE); + break; + case PROP_PRESENT_VALUE: + real_value = Analog_Value_Present_Value(rpdata->object_instance); + apdu_len = encode_application_real(&apdu[0], real_value); + break; + case PROP_STATUS_FLAGS: + bitstring_init(&bit_string); + bitstring_set_bit(&bit_string, STATUS_FLAG_IN_ALARM, false); + bitstring_set_bit(&bit_string, STATUS_FLAG_FAULT, false); + bitstring_set_bit(&bit_string, STATUS_FLAG_OVERRIDDEN, false); + bitstring_set_bit(&bit_string, STATUS_FLAG_OUT_OF_SERVICE, false); + apdu_len = encode_application_bitstring(&apdu[0], &bit_string); + break; + case PROP_EVENT_STATE: + apdu_len = + encode_application_enumerated(&apdu[0], EVENT_STATE_NORMAL); + break; + case PROP_OUT_OF_SERVICE: +#if 0 + object_index = Analog_Value_Instance_To_Index(object_instance); + state = Analog_Value_Out_Of_Service[object_index]; +#endif + apdu_len = encode_application_boolean(&apdu[0], false); + break; + case PROP_UNITS: + apdu_len = encode_application_enumerated(&apdu[0], UNITS_PERCENT); + break; +#if 0 + case PROP_PRIORITY_ARRAY: + /* Array element zero is the number of elements in the array */ + if (array_index == 0) + apdu_len = + encode_application_unsigned(&apdu[0], BACNET_MAX_PRIORITY); + /* if no index was specified, then try to encode the entire list */ + /* into one packet. */ + else if (array_index == BACNET_ARRAY_ALL) { + object_index = Analog_Value_Instance_To_Index(object_instance); + for (i = 0; i < BACNET_MAX_PRIORITY; i++) { + /* FIXME: check if we have room before adding it to APDU */ + if (Present_Value[object_index][i] == ANALOG_LEVEL_NULL) + len = encode_application_null(&apdu[apdu_len]); + else { + real_value = Present_Value[object_index][i]; + len = + encode_application_real(&apdu[apdu_len], + real_value); + } + /* add it if we have room */ + if ((apdu_len + len) < MAX_APDU) + apdu_len += len; + else { + *error_class = ERROR_CLASS_SERVICES; + *error_code = ERROR_CODE_NO_SPACE_FOR_OBJECT; + apdu_len = -1; + break; + } + } + } else { + object_index = Analog_Value_Instance_To_Index(object_instance); + if (array_index <= BACNET_MAX_PRIORITY) { + if (Present_Value[object_index][array_index - 1] == + ANALOG_LEVEL_NULL) + apdu_len = encode_application_null(&apdu[0]); + else { + real_value = + Present_Value[object_index][array_index - 1]; + apdu_len = + encode_application_real(&apdu[0], real_value); + } + } else { + *error_class = ERROR_CLASS_PROPERTY; + *error_code = ERROR_CODE_INVALID_ARRAY_INDEX; + apdu_len = -1; + } + } + + break; + case PROP_RELINQUISH_DEFAULT: + real_value = ANALOG_RELINQUISH_DEFAULT; + apdu_len = encode_application_real(&apdu[0], real_value); + break; +#endif + default: + rpdata->error_class = ERROR_CLASS_PROPERTY; + rpdata->error_code = ERROR_CODE_UNKNOWN_PROPERTY; + apdu_len = -1; + break; + } + /* only array properties can have array options */ + if ((apdu_len >= 0) && +#if 0 + (property != PROP_PRIORITY_ARRAY) && +#endif + (rpdata->array_index != BACNET_ARRAY_ALL)) { + rpdata->error_class = ERROR_CLASS_PROPERTY; + rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY; + apdu_len = -1; + } + + return apdu_len; +} + +/* returns true if successful */ +bool Analog_Value_Write_Property( + BACNET_WRITE_PROPERTY_DATA * wp_data) +{ + bool status = false; /* return value */ + unsigned int object_index = 0; + unsigned int priority = 0; + uint8_t level = ANALOG_LEVEL_NULL; + int len = 0; + BACNET_APPLICATION_DATA_VALUE value; + + Analog_Value_Init(); + if (!Analog_Value_Valid_Instance(wp_data->object_instance)) { + wp_data->error_class = ERROR_CLASS_OBJECT; + wp_data->error_code = ERROR_CODE_UNKNOWN_OBJECT; + return false; + } + /* decode the some of the request */ + len = + bacapp_decode_application_data(wp_data->application_data, + wp_data->application_data_len, &value); + /* FIXME: len < application_data_len: more data? */ + if (len < 0) { + /* error while decoding - a value larger than we can handle */ + wp_data->error_class = ERROR_CLASS_PROPERTY; + wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE; + return false; + } + if ((wp_data->object_property != PROP_PRIORITY_ARRAY) && + (wp_data->array_index != BACNET_ARRAY_ALL)) { + /* only array properties can have array options */ + wp_data->error_class = ERROR_CLASS_PROPERTY; + wp_data->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY; + return false; + } + switch (wp_data->object_property) { + case PROP_PRESENT_VALUE: + if (value.tag == BACNET_APPLICATION_TAG_REAL) { + priority = wp_data->priority; + /* Command priority 6 is reserved for use by Minimum On/Off + algorithm and may not be used for other purposes in any + object. */ + if (priority && (priority <= BACNET_MAX_PRIORITY) && + (priority != 6 /* reserved */ ) && + (value.type.Real >= 0.0) && (value.type.Real <= 100.0)) { + level = (uint8_t) value.type.Real; + object_index = + Analog_Value_Instance_To_Index + (wp_data->object_instance); + priority--; + Present_Value[object_index] = level; + /* Note: you could set the physical output here if we + are the highest priority. + However, if Out of Service is TRUE, then don't set the + physical output. This comment may apply to the + main loop (i.e. check out of service before changing output) */ + status = true; + } else if (priority == 6) { + /* Command priority 6 is reserved for use by Minimum On/Off + algorithm and may not be used for other purposes in any + object. */ + wp_data->error_class = ERROR_CLASS_PROPERTY; + wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED; + } else { + wp_data->error_class = ERROR_CLASS_PROPERTY; + wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE; + } +#if 0 + } else if (value.tag == BACNET_APPLICATION_TAG_NULL) { + level = ANALOG_LEVEL_NULL; + object_index = + Analog_Value_Instance_To_Index(wp_data->object_instance); + priority = wp_data->priority; + if (priority && (priority <= BACNET_MAX_PRIORITY)) { + priority--; + Present_Value[object_index][priority] = level; + /* Note: you could set the physical output here to the next + highest priority, or to the relinquish default if no + priorities are set. + However, if Out of Service is TRUE, then don't set the + physical output. This comment may apply to the + main loop (i.e. check out of service before changing output) */ + status = true; + } else { + *error_class = ERROR_CLASS_PROPERTY; + *error_code = ERROR_CODE_VALUE_OUT_OF_RANGE; + } +#endif + } else { + wp_data->error_class = ERROR_CLASS_PROPERTY; + wp_data->error_code = ERROR_CODE_INVALID_DATA_TYPE; + } + break; +#if 0 + case PROP_OUT_OF_SERVICE: + if (value.tag == BACNET_APPLICATION_TAG_BOOLEAN) { + object_index = + Analog_Value_Instance_To_Index(wp_data->object_instance); + Analog_Value_Out_Of_Service[object_index] = value.type.Boolean; + status = true; + } else { + *error_class = ERROR_CLASS_PROPERTY; + *error_code = ERROR_CODE_INVALID_DATA_TYPE; + } + break; +#endif + case PROP_OBJECT_IDENTIFIER: + case PROP_OBJECT_NAME: + case PROP_OBJECT_TYPE: + case PROP_STATUS_FLAGS: + case PROP_EVENT_STATE: + case PROP_OUT_OF_SERVICE: + case PROP_DESCRIPTION: + case PROP_PRIORITY_ARRAY: + wp_data->error_class = ERROR_CLASS_PROPERTY; + wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED; + break; + default: + wp_data->error_class = ERROR_CLASS_PROPERTY; + wp_data->error_code = ERROR_CODE_UNKNOWN_PROPERTY; + break; + } + + return status; +} diff --git a/bacnet-stack/ports/pic18f97j60/bi.c b/bacnet-stack/ports/pic18f97j60/bi.c new file mode 100644 index 00000000..50f6b7e1 --- /dev/null +++ b/bacnet-stack/ports/pic18f97j60/bi.c @@ -0,0 +1,197 @@ +/************************************************************************** +* +* Copyright (C) 2006 Steve Karg +* +* 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. +* +*********************************************************************/ + +/* Binary Input Objects customize for your use */ + +#include +#include +#include +#include "bacdef.h" +#include "bacdcode.h" +#include "bacenum.h" +#include "config.h" +#include "wp.h" +#include "rp.h" +#include "bi.h" + +#define MAX_BINARY_INPUTS 8 + +static BACNET_BINARY_PV Present_Value[MAX_BINARY_INPUTS]; + +static void Binary_Input_Initialize( + void) +{ + static bool initialized = false; + unsigned i; + + if (!initialized) { + initialized = true; + for (i = 0; i < MAX_BINARY_INPUTS; i++) { + Present_Value[i] = BINARY_INACTIVE; + } + } +} + +/* we simply have 0-n object instances. */ +bool Binary_Input_Valid_Instance( + uint32_t object_instance) +{ + if (object_instance < MAX_BINARY_INPUTS) + return true; + + return false; +} + +/* we simply have 0-n object instances. */ +unsigned Binary_Input_Count( + void) +{ + return MAX_BINARY_INPUTS; +} + +/* we simply have 0-n object instances.*/ +uint32_t Binary_Input_Index_To_Instance( + unsigned index) +{ + return index; +} + +/* we simply have 0-n object instances. Yours might be */ +/* more complex, and then you need to return the index */ +/* that correlates to the correct instance number */ +unsigned Binary_Input_Instance_To_Index( + uint32_t object_instance) +{ + unsigned index = MAX_BINARY_INPUTS; + + if (object_instance < MAX_BINARY_INPUTS) + index = object_instance; + + return index; +} + +BACNET_BINARY_PV Binary_Input_Present_Value( + uint32_t object_instance) +{ + BACNET_BINARY_PV value = BINARY_INACTIVE; + unsigned index = 0; + + Binary_Input_Initialize(); + index = Binary_Input_Instance_To_Index(object_instance); + if (index < MAX_BINARY_INPUTS) { + value = Present_Value[index]; + } + + return value; +} + +char *Binary_Input_Name( + uint32_t object_instance) +{ + static char text_string[16] = ""; /* okay for single thread */ + + if (object_instance < MAX_BINARY_INPUTS) { + sprintf(text_string, "BI-%lu", object_instance); + return text_string; + } + + return NULL; +} + +/* return apdu length, or -1 on error */ +/* assumption - object already exists, and has been bounds checked */ +int Binary_Input_Read_Property( + BACNET_READ_PROPERTY_DATA * rpdata) +{ + int apdu_len = 0; /* return value */ + BACNET_BIT_STRING bit_string; + BACNET_CHARACTER_STRING char_string; + BACNET_POLARITY polarity = POLARITY_NORMAL; + BACNET_BINARY_PV value = BINARY_INACTIVE; + uint8_t *apdu = NULL; + + Binary_Input_Initialize(); + if ((rpdata == NULL) || (rpdata->application_data == NULL) || + (rpdata->application_data_len == 0)) { + return 0; + } + apdu = rpdata->application_data; + switch (rpdata->object_property) { + case PROP_OBJECT_IDENTIFIER: + apdu_len = + encode_application_object_id(&apdu[0], OBJECT_BINARY_INPUT, + rpdata->object_instance); + break; + case PROP_OBJECT_NAME: + case PROP_DESCRIPTION: + /* note: object name must be unique in our device */ + characterstring_init_ansi(&char_string, + Binary_Input_Name(rpdata->object_instance)); + apdu_len = + encode_application_character_string(&apdu[0], &char_string); + break; + case PROP_OBJECT_TYPE: + apdu_len = + encode_application_enumerated(&apdu[0], OBJECT_BINARY_INPUT); + break; + case PROP_PRESENT_VALUE: + value = Binary_Input_Present_Value(rpdata->object_instance); + apdu_len = encode_application_enumerated(&apdu[0], value); + break; + case PROP_STATUS_FLAGS: + /* note: see the details in the standard on how to use these */ + bitstring_init(&bit_string); + bitstring_set_bit(&bit_string, STATUS_FLAG_IN_ALARM, false); + bitstring_set_bit(&bit_string, STATUS_FLAG_FAULT, false); + bitstring_set_bit(&bit_string, STATUS_FLAG_OVERRIDDEN, false); + bitstring_set_bit(&bit_string, STATUS_FLAG_OUT_OF_SERVICE, false); + apdu_len = encode_application_bitstring(&apdu[0], &bit_string); + break; + case PROP_EVENT_STATE: + /* note: see the details in the standard on how to use this */ + apdu_len = + encode_application_enumerated(&apdu[0], EVENT_STATE_NORMAL); + break; + case PROP_OUT_OF_SERVICE: + apdu_len = encode_application_boolean(&apdu[0], false); + break; + case PROP_POLARITY: + apdu_len = encode_application_enumerated(&apdu[0], polarity); + break; + default: + rpdata->error_class = ERROR_CLASS_PROPERTY; + rpdata->error_code = ERROR_CODE_UNKNOWN_PROPERTY; + apdu_len = -1; + break; + } + /* only array properties can have array options */ + if ((apdu_len >= 0) && (rpdata->array_index != BACNET_ARRAY_ALL)) { + rpdata->error_class = ERROR_CLASS_PROPERTY; + rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY; + apdu_len = -1; + } + + return apdu_len; +} diff --git a/bacnet-stack/ports/pic18f97j60/bv.c b/bacnet-stack/ports/pic18f97j60/bv.c new file mode 100644 index 00000000..1168f2f3 --- /dev/null +++ b/bacnet-stack/ports/pic18f97j60/bv.c @@ -0,0 +1,328 @@ +/************************************************************************** +* +* Copyright (C) 2006 Steve Karg +* +* 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. +* +*********************************************************************/ + +/* Binary Value Objects - customize for your use */ + +#include +#include +#include +#include "bacdef.h" +#include "bacdcode.h" +#include "bacenum.h" +#include "config.h" /* the custom stuff */ +#include "wp.h" +#include "rp.h" +#include "bv.h" + +#define MAX_BINARY_VALUES 8 + +static BACNET_BINARY_PV Present_Value[MAX_BINARY_VALUES]; + +static void Binary_Value_Initialize( + void) +{ + static bool initialized = false; + unsigned i; + + if (!initialized) { + initialized = true; + for (i = 0; i < MAX_BINARY_VALUES; i++) { + Present_Value[i] = BINARY_INACTIVE; + } + } +} + +/* we simply have 0-n object instances. */ +bool Binary_Value_Valid_Instance( + uint32_t object_instance) +{ + if (object_instance < MAX_BINARY_VALUES) + return true; + + return false; +} + +/* we simply have 0-n object instances. */ +unsigned Binary_Value_Count( + void) +{ + return MAX_BINARY_VALUES; +} + +/* we simply have 0-n object instances. */ +uint32_t Binary_Value_Index_To_Instance( + unsigned index) +{ + return index; +} + +/* we simply have 0-n object instances. */ +unsigned Binary_Value_Instance_To_Index( + uint32_t object_instance) +{ + unsigned index = MAX_BINARY_VALUES; + + if (object_instance < MAX_BINARY_VALUES) + index = object_instance; + + return index; +} + +BACNET_BINARY_PV Binary_Value_Present_Value( + uint32_t object_instance) +{ + BACNET_BINARY_PV value = BINARY_INACTIVE; + + Binary_Value_Initialize(); + if (object_instance < MAX_BINARY_VALUES) { + value = Present_Value[object_instance]; + } + + return value; +} + +/* note: the object name must be unique within this device */ +char *Binary_Value_Name( + uint32_t object_instance) +{ + static char text_string[16] = ""; /* okay for single thread */ + + if (object_instance < MAX_BINARY_VALUES) { + sprintf(text_string, "BV-%lu", object_instance); + return text_string; + } + + return NULL; +} + +/* return apdu len, or -1 on error */ +int Binary_Value_Read_Property( + BACNET_READ_PROPERTY_DATA * rpdata) +{ + int len = 0; + int apdu_len = 0; /* return value */ + BACNET_BIT_STRING bit_string; + BACNET_CHARACTER_STRING char_string; + BACNET_BINARY_PV present_value = BINARY_INACTIVE; + BACNET_POLARITY polarity = POLARITY_NORMAL; + unsigned object_index = 0; + unsigned i = 0; + bool state = false; + uint8_t *apdu = NULL; + + Binary_Value_Initialize(); + if ((rpdata == NULL) || (rpdata->application_data == NULL) || + (rpdata->application_data_len == 0)) { + return 0; + } + apdu = rpdata->application_data; + switch (rpdata->object_property) { + case PROP_OBJECT_IDENTIFIER: + apdu_len = + encode_application_object_id(&apdu[0], OBJECT_BINARY_VALUE, + rpdata->object_instance); + break; + /* note: Name and Description don't have to be the same. + You could make Description writable and different */ + case PROP_OBJECT_NAME: + case PROP_DESCRIPTION: + characterstring_init_ansi(&char_string, + Binary_Value_Name(rpdata->object_instance)); + apdu_len = + encode_application_character_string(&apdu[0], &char_string); + break; + case PROP_OBJECT_TYPE: + apdu_len = + encode_application_enumerated(&apdu[0], OBJECT_BINARY_VALUE); + break; + case PROP_PRESENT_VALUE: + present_value = + Binary_Value_Present_Value(rpdata->object_instance); + apdu_len = encode_application_enumerated(&apdu[0], present_value); + break; + case PROP_STATUS_FLAGS: + /* note: see the details in the standard on how to use these */ + bitstring_init(&bit_string); + bitstring_set_bit(&bit_string, STATUS_FLAG_IN_ALARM, false); + bitstring_set_bit(&bit_string, STATUS_FLAG_FAULT, false); + bitstring_set_bit(&bit_string, STATUS_FLAG_OVERRIDDEN, false); + bitstring_set_bit(&bit_string, STATUS_FLAG_OUT_OF_SERVICE, false); + apdu_len = encode_application_bitstring(&apdu[0], &bit_string); + break; + case PROP_EVENT_STATE: + /* note: see the details in the standard on how to use this */ + apdu_len = + encode_application_enumerated(&apdu[0], EVENT_STATE_NORMAL); + break; + case PROP_OUT_OF_SERVICE: + apdu_len = encode_application_boolean(&apdu[0], false); + break; + case PROP_POLARITY: + /* FIXME: figure out the polarity */ + apdu_len = encode_application_enumerated(&apdu[0], polarity); + break; + default: + rpdata->error_class = ERROR_CLASS_PROPERTY; + rpdata->error_code = ERROR_CODE_UNKNOWN_PROPERTY; + apdu_len = -1; + break; + } + /* only array properties can have array options */ + if ((apdu_len >= 0) && (rpdata->array_index != BACNET_ARRAY_ALL)) { + rpdata->error_class = ERROR_CLASS_PROPERTY; + rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY; + apdu_len = -1; + } + + return apdu_len; +} + +/* returns true if successful */ +bool Binary_Value_Write_Property( + BACNET_WRITE_PROPERTY_DATA * wp_data) +{ + bool status = false; /* return value */ + unsigned int object_index = 0; + unsigned int priority = 0; + BACNET_BINARY_PV level = BINARY_NULL; + int len = 0; + BACNET_APPLICATION_DATA_VALUE value; + + if (!Binary_Value_Valid_Instance(wp_data->object_instance)) { + wp_data->error_class = ERROR_CLASS_OBJECT; + wp_data->error_code = ERROR_CODE_UNKNOWN_OBJECT; + return false; + } + /* decode the some of the request */ + len = + bacapp_decode_application_data(wp_data->application_data, + wp_data->application_data_len, &value); + /* FIXME: len < application_data_len: more data? */ + if (len < 0) { + /* error while decoding - a value larger than we can handle */ + wp_data->error_class = ERROR_CLASS_PROPERTY; + wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE; + return false; + } + if ((wp_data->object_property != PROP_PRIORITY_ARRAY) && + (wp_data->array_index != BACNET_ARRAY_ALL)) { + /* only array properties can have array options */ + wp_data->error_class = ERROR_CLASS_PROPERTY; + wp_data->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY; + return false; + } + switch (wp_data->object_property) { + case PROP_PRESENT_VALUE: + if (value.tag == BACNET_APPLICATION_TAG_ENUMERATED) { + priority = wp_data->priority; + /* Command priority 6 is reserved for use by Minimum On/Off + algorithm and may not be used for other purposes in any + object. */ + if (priority && (priority <= BACNET_MAX_PRIORITY) && + (priority != 6 /* reserved */ ) && + (value.type.Enumerated >= MIN_BINARY_PV) && + (value.type.Enumerated <= MAX_BINARY_PV)) { + level = value.type.Enumerated; + object_index = + Binary_Value_Instance_To_Index + (wp_data->object_instance); + priority--; + /* NOTE: this Binary value has no priority array */ + Present_Value[object_index] = level; + /* Note: you could set the physical output here if we + are the highest priority. + However, if Out of Service is TRUE, then don't set the + physical output. */ + status = true; + } else if (priority == 6) { + /* Command priority 6 is reserved for use by Minimum On/Off + algorithm and may not be used for other purposes in any + object. */ + wp_data->error_class = ERROR_CLASS_PROPERTY; + wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED; + } else { + wp_data->error_class = ERROR_CLASS_PROPERTY; + wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE; + } + } else if (value.tag == BACNET_APPLICATION_TAG_NULL) { +#if 0 + /* NOTE: this Binary Value has no priority array */ + level = BINARY_NULL; + object_index = + Binary_Value_Instance_To_Index(wp_data->object_instance); + priority = wp_data->priority; + if (priority && (priority <= BACNET_MAX_PRIORITY)) { + priority--; + Binary_Value_Level[object_index][priority] = level; + /* Note: you could set the physical output here to the next + highest priority, or to the relinquish default if no + priorities are set. + However, if Out of Service is TRUE, then don't set the + physical output. This comment may apply to the + main loop (i.e. check out of service before changing output) */ + status = true; + } else { + wp_data->error_class = ERROR_CLASS_PROPERTY; + wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE; + } +#else + wp_data->error_class = ERROR_CLASS_PROPERTY; + wp_data->error_code = ERROR_CODE_INVALID_DATA_TYPE; +#endif + } else { + wp_data->error_class = ERROR_CLASS_PROPERTY; + wp_data->error_code = ERROR_CODE_INVALID_DATA_TYPE; + } + break; + case PROP_OUT_OF_SERVICE: +#if 0 + if (value.tag == BACNET_APPLICATION_TAG_BOOLEAN) { + object_index = + Binary_Value_Instance_To_Index(wp_data->object_instance); + Binary_Value_Out_Of_Service[object_index] = value.type.Boolean; + status = true; + } else { + wp_data->error_class = ERROR_CLASS_PROPERTY; + wp_data->error_code = ERROR_CODE_INVALID_DATA_TYPE; + } + break; +#endif + case PROP_OBJECT_IDENTIFIER: + case PROP_OBJECT_NAME: + case PROP_OBJECT_TYPE: + case PROP_STATUS_FLAGS: + case PROP_EVENT_STATE: + case PROP_POLARITY: + wp_data->error_class = ERROR_CLASS_PROPERTY; + wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED; + break; + default: + wp_data->error_class = ERROR_CLASS_PROPERTY; + wp_data->error_code = ERROR_CODE_UNKNOWN_PROPERTY; + break; + } + + return status; +} diff --git a/bacnet-stack/ports/pic18f97j60/device.c b/bacnet-stack/ports/pic18f97j60/device.c new file mode 100644 index 00000000..a69d46c1 --- /dev/null +++ b/bacnet-stack/ports/pic18f97j60/device.c @@ -0,0 +1,752 @@ +/************************************************************************** +* +* Copyright (C) 2007 Steve Karg +* +* 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 +#include +#include /* for memmove */ +#include "bacdef.h" +#include "bacdcode.h" +#include "bacstr.h" +#include "bacenum.h" +#include "config.h" /* the custom stuff */ +#include "apdu.h" +#include "dlmstp.h" +#include "rs485.h" +#include "ai.h" +#include "av.h" +#include "bi.h" +#include "bv.h" +#include "rp.h" +#include "wp.h" +#include "dcc.h" +#include "version.h" +#include "device.h" /* me */ + +/* note: you really only need to define variables for + properties that are writable or that may change. + The properties that are constant can be hard coded + into the read-property encoding. */ +static uint32_t Object_Instance_Number = 12345; +static BACNET_DEVICE_STATUS System_Status = STATUS_OPERATIONAL; +static uint8_t Database_Revision; +BACNET_REINITIALIZED_STATE Reinitialize_State = BACNET_REINIT_IDLE; + +bool Device_Reinitialize( + BACNET_REINITIALIZE_DEVICE_DATA * rd_data) +{ + bool status = false; + char password[16] = "filister"; + + if (characterstring_ansi_same(&rd_data->password, password)) { + Reinitialize_State = rd_data->state; + dcc_set_status_duration(COMMUNICATION_ENABLE, 0); + /* Note: you could use a mix of state + and password to multiple things */ + /* note: you probably want to restart *after* the + simple ack has been sent from the return handler + so just set a flag from here */ + status = true; + } else { + rd_data->error_class = ERROR_CLASS_SECURITY; + rd_data->error_code = ERROR_CODE_PASSWORD_FAILURE; + } + + return status; +} + +BACNET_REINITIALIZED_STATE Device_Reinitialized_State( + void) +{ + return Reinitialize_State; +} + +void Device_Init( + object_functions_t * object_table) +{ + (void) object_table; + Reinitialize_State = BACNET_REINIT_IDLE; + dcc_set_status_duration(COMMUNICATION_ENABLE, 0); + /* FIXME: Get the data from the eeprom */ + /* I2C_Read_Block(EEPROM_DEVICE_ADDRESS, + (char *)&Object_Instance_Number, + sizeof(Object_Instance_Number), + EEPROM_BACNET_ID_ADDR); */ +} + +/* methods to manipulate the data */ +uint32_t Device_Object_Instance_Number( + void) +{ + return Object_Instance_Number; +} + +bool Device_Set_Object_Instance_Number( + uint32_t object_id) +{ + bool status = true; /* return value */ + + if (object_id <= BACNET_MAX_INSTANCE) { + Object_Instance_Number = object_id; + Database_Revision++; + /* FIXME: Write the data to the eeprom */ + /* I2C_Write_Block( + EEPROM_DEVICE_ADDRESS, + (char *)&Object_Instance_Number, + sizeof(Object_Instance_Number), + EEPROM_BACNET_ID_ADDR); */ + } else + status = false; + + return status; +} + +bool Device_Valid_Object_Instance_Number( + uint32_t object_id) +{ + /* BACnet allows for a wildcard instance number */ + return (Object_Instance_Number == object_id); +} + +BACNET_DEVICE_STATUS Device_System_Status( + void) +{ + return System_Status; +} + +int Device_Set_System_Status( + BACNET_DEVICE_STATUS status, + bool local) +{ + if (status < MAX_DEVICE_STATUS) { + System_Status = status; + } +} + +uint16_t Device_Vendor_Identifier( + void) +{ + return BACNET_VENDOR_ID; +} + +uint8_t Device_Protocol_Version( + void) +{ + return BACNET_PROTOCOL_VERSION; +} + +uint8_t Device_Protocol_Revision( + void) +{ + return BACNET_PROTOCOL_REVISION; +} + +BACNET_SEGMENTATION Device_Segmentation_Supported( + void) +{ + return SEGMENTATION_NONE; +} + +uint32_t Device_Database_Revision( + void) +{ + return Database_Revision; +} + +/* Since many network clients depend on the object list */ +/* for discovery, it must be consistent! */ +unsigned Device_Object_List_Count( + void) +{ + unsigned count = 1; /* at least 1 for device object */ + +/* FIXME: add objects as needed */ + count += Binary_Value_Count(); + count += Analog_Input_Count(); + count += Binary_Input_Count(); + count += Analog_Value_Count(); + + return count; +} + +/* Since many network clients depend on the object list */ +/* for discovery, it must be consistent! */ +bool Device_Object_List_Identifier( + unsigned array_index, + int *object_type, + uint32_t * instance) +{ + bool status = false; + unsigned object_index = 0; + unsigned object_count = 0; + + /* device object */ + if (array_index == 1) { + *object_type = OBJECT_DEVICE; + *instance = Object_Instance_Number; + status = true; + } + /* normalize the index since + we know it is not the previous objects */ + /* array index starts at 1 */ + object_index = array_index - 1; + /* 1 for the device object */ + object_count = 1; + /* FIXME: add objects as needed */ + /* binary value objects */ + if (!status) { + object_index -= object_count; + object_count = Binary_Value_Count(); + /* is it a valid index for this object? */ + if (object_index < object_count) { + *object_type = OBJECT_BINARY_VALUE; + *instance = Binary_Value_Index_To_Instance(object_index); + status = true; + } + } + /* analog input objects */ + if (!status) { + /* array index starts at 1, and 1 for the device object */ + object_index -= object_count; + object_count = Analog_Value_Count(); + if (object_index < object_count) { + *object_type = OBJECT_ANALOG_VALUE; + *instance = Analog_Value_Index_To_Instance(object_index); + status = true; + } + } + /* analog input objects */ + if (!status) { + /* array index starts at 1, and 1 for the device object */ + object_index -= object_count; + object_count = Analog_Input_Count(); + if (object_index < object_count) { + *object_type = OBJECT_ANALOG_INPUT; + *instance = Analog_Input_Index_To_Instance(object_index); + status = true; + } + } + /* binary input objects */ + if (!status) { + /* normalize the index since + we know it is not the previous objects */ + object_index -= object_count; + object_count = Binary_Input_Count(); + /* is it a valid index for this object? */ + if (object_index < object_count) { + *object_type = OBJECT_BINARY_INPUT; + *instance = Binary_Input_Index_To_Instance(object_index); + status = true; + } + } + + return status; +} + +/* returns true if successful */ +int Device_Read_Property_Local( + BACNET_READ_PROPERTY_DATA * rpdata) +{ + int apdu_len = 0; /* return value */ + int len = 0; /* apdu len intermediate value */ + BACNET_BIT_STRING bit_string; + BACNET_CHARACTER_STRING char_string; + unsigned i = 0; + int object_type = 0; + uint32_t instance = 0; + unsigned count = 0; + BACNET_TIME local_time; + BACNET_DATE local_date; + uint8_t year = 0; + char string_buffer[28]; + int16_t TimeZone = 0; + uint8_t *apdu = NULL; + + if ((rpdata == NULL) || (rpdata->application_data == NULL) || + (rpdata->application_data_len == 0)) { + return 0; + } + apdu = rpdata->application_data; + /* FIXME: change the hardcoded names to suit your application */ + switch (rpdata->object_property) { + case PROP_OBJECT_IDENTIFIER: + apdu_len = + encode_application_object_id(&apdu[0], OBJECT_DEVICE, + Object_Instance_Number); + break; + case PROP_OBJECT_NAME: + (void) strcpypgm2ram(&string_buffer[0], "PIC18F6720 Device"); + characterstring_init_ansi(&char_string, string_buffer); + apdu_len = + encode_application_character_string(&apdu[0], &char_string); + break; + case PROP_OBJECT_TYPE: + apdu_len = encode_application_enumerated(&apdu[0], OBJECT_DEVICE); + break; + case PROP_DESCRIPTION: + (void) strcpypgm2ram(&string_buffer[0], "BACnet Demo"); + characterstring_init_ansi(&char_string, string_buffer); + apdu_len = + encode_application_character_string(&apdu[0], &char_string); + break; + case PROP_SYSTEM_STATUS: + apdu_len = + encode_application_enumerated(&apdu[0], + Device_System_Status()); + break; + case PROP_VENDOR_NAME: + (void) strcpypgm2ram(&string_buffer[0], BACNET_VENDOR_NAME); + characterstring_init_ansi(&char_string, string_buffer); + apdu_len = + encode_application_character_string(&apdu[0], &char_string); + break; + case PROP_VENDOR_IDENTIFIER: + apdu_len = + encode_application_unsigned(&apdu[0], + Device_Vendor_Identifier()); + break; + case PROP_MODEL_NAME: + (void) strcpypgm2ram(&string_buffer[0], "GNU Demo"); + characterstring_init_ansi(&char_string, string_buffer); + apdu_len = + encode_application_character_string(&apdu[0], &char_string); + break; + case PROP_FIRMWARE_REVISION: + (void) strcpypgm2ram(&string_buffer[0], BACNET_VERSION_TEXT); + characterstring_init_ansi(&char_string, string_buffer); + apdu_len = + encode_application_character_string(&apdu[0], &char_string); + break; + case PROP_APPLICATION_SOFTWARE_VERSION: + (void) strcpypgm2ram(&string_buffer[0], "1.0"); + characterstring_init_ansi(&char_string, string_buffer); + apdu_len = + encode_application_character_string(&apdu[0], &char_string); + break; + case PROP_LOCATION: + (void) strcpypgm2ram(&string_buffer[0], "USA"); + characterstring_init_ansi(&char_string, string_buffer); + apdu_len = + encode_application_character_string(&apdu[0], &char_string); + break; + case PROP_PROTOCOL_VERSION: + apdu_len = + encode_application_unsigned(&apdu[0], + Device_Protocol_Version()); + break; + case PROP_PROTOCOL_REVISION: + apdu_len = + encode_application_unsigned(&apdu[0], + Device_Protocol_Revision()); + break; + case PROP_PROTOCOL_SERVICES_SUPPORTED: + /* Note: list of services that are executed, not initiated. */ + bitstring_init(&bit_string); + for (i = 0; i < MAX_BACNET_SERVICES_SUPPORTED; i++) { + /* automatic lookup based on handlers set */ + bitstring_set_bit(&bit_string, (uint8_t) i, + apdu_service_supported(i)); + } + apdu_len = encode_application_bitstring(&apdu[0], &bit_string); + break; + case PROP_PROTOCOL_OBJECT_TYPES_SUPPORTED: + /* Note: this is the list of objects that can be in this device, + not a list of objects that this device can access */ + bitstring_init(&bit_string); + for (i = 0; i < MAX_ASHRAE_OBJECT_TYPE; i++) { + /* initialize all the object types to not-supported */ + bitstring_set_bit(&bit_string, (uint8_t) i, false); + } + /* FIXME: indicate the objects that YOU support */ + bitstring_set_bit(&bit_string, OBJECT_DEVICE, true); + bitstring_set_bit(&bit_string, OBJECT_ANALOG_VALUE, true); + bitstring_set_bit(&bit_string, OBJECT_BINARY_VALUE, true); + bitstring_set_bit(&bit_string, OBJECT_ANALOG_INPUT, true); + bitstring_set_bit(&bit_string, OBJECT_BINARY_INPUT, true); + apdu_len = encode_application_bitstring(&apdu[0], &bit_string); + break; + case PROP_OBJECT_LIST: + count = Device_Object_List_Count(); + /* Array element zero is the number of objects in the list */ + if (rpdata->array_index == 0) + apdu_len = encode_application_unsigned(&apdu[0], count); + /* if no index was specified, then try to encode the entire list */ + /* into one packet. Note that more than likely you will have */ + /* to return an error if the number of encoded objects exceeds */ + /* your maximum APDU size. */ + else if (rpdata->array_index == BACNET_ARRAY_ALL) { + for (i = 1; i <= count; i++) { + if (Device_Object_List_Identifier(i, &object_type, + &instance)) { + len = + encode_application_object_id(&apdu[apdu_len], + object_type, instance); + apdu_len += len; + /* assume next one is the same size as this one */ + /* can we all fit into the APDU? */ + if ((apdu_len + len) >= MAX_APDU) { + rpdata->error_code = + ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED; + apdu_len = BACNET_STATUS_ABORT; + break; + } + } else { + /* error: internal error? */ + rpdata->error_class = ERROR_CLASS_SERVICES; + rpdata->error_code = ERROR_CODE_OTHER; + apdu_len = BACNET_STATUS_ERROR; + break; + } + } + } else { + if (Device_Object_List_Identifier(rpdata->array_index, + &object_type, &instance)) + apdu_len = + encode_application_object_id(&apdu[0], object_type, + instance); + else { + rpdata->error_class = ERROR_CLASS_PROPERTY; + rpdata->error_code = ERROR_CODE_INVALID_ARRAY_INDEX; + apdu_len = BACNET_STATUS_ERROR; + } + } + break; + case PROP_MAX_APDU_LENGTH_ACCEPTED: + apdu_len = encode_application_unsigned(&apdu[0], MAX_APDU); + break; + case PROP_SEGMENTATION_SUPPORTED: + apdu_len = + encode_application_enumerated(&apdu[0], + Device_Segmentation_Supported()); + break; + case PROP_APDU_TIMEOUT: + apdu_len = encode_application_unsigned(&apdu[0], apdu_timeout()); + break; + case PROP_NUMBER_OF_APDU_RETRIES: + apdu_len = encode_application_unsigned(&apdu[0], apdu_retries()); + break; + case PROP_DEVICE_ADDRESS_BINDING: + /* FIXME: encode the list here, if it exists */ + break; + case PROP_DATABASE_REVISION: + apdu_len = + encode_application_unsigned(&apdu[0], + Device_Database_Revision()); + break; + case PROP_MAX_INFO_FRAMES: + apdu_len = + encode_application_unsigned(&apdu[0], + dlmstp_max_info_frames()); + break; + case PROP_MAX_MASTER: + apdu_len = + encode_application_unsigned(&apdu[0], dlmstp_max_master()); + break; + case PROP_LOCAL_TIME: + /* FIXME: if you support time */ + local_time.hour = 0; + local_time.min = 0; + local_time.sec = 0; + local_time.hundredths = 0; + apdu_len = encode_application_time(&apdu[0], &local_time); + break; + case PROP_UTC_OFFSET: + /* Note: BACnet Time Zone is offset of local time and UTC, + rather than offset of GMT. It is expressed in minutes */ + apdu_len = encode_application_signed(&apdu[0], 5 * 60 /* EST */ ); + break; + case PROP_LOCAL_DATE: + /* FIXME: if you support date */ + local_date.year = 2006; /* AD */ + local_date.month = 4; /* Jan=1..Dec=12 */ + local_date.day = 11; /* 1..31 */ + local_date.wday = 0; /* 1=Mon..7=Sun */ + apdu_len = encode_application_date(&apdu[0], &local_date); + break; + case PROP_DAYLIGHT_SAVINGS_STATUS: + /* FIXME: if you support time/date */ + apdu_len = encode_application_boolean(&apdu[0], false); + break; + case 9600: + apdu_len = + encode_application_unsigned(&apdu[0], RS485_Get_Baud_Rate()); + break; + default: + rpdata->error_class = ERROR_CLASS_PROPERTY; + rpdata->error_code = ERROR_CODE_UNKNOWN_PROPERTY; + apdu_len = -1; + break; + } + /* only array properties can have array options */ + if ((apdu_len >= 0) && (rpdata->object_property != PROP_OBJECT_LIST) && + (rpdata->array_index != BACNET_ARRAY_ALL)) { + rpdata->error_class = ERROR_CLASS_PROPERTY; + rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY; + apdu_len = BACNET_STATUS_ERROR; + } + + return apdu_len; +} + +int Device_Read_Property( + BACNET_READ_PROPERTY_DATA * rpdata) +{ + int apdu_len = BACNET_STATUS_ERROR; + + /* initialize the default return values */ + rpdata->error_class = ERROR_CLASS_OBJECT; + rpdata->error_code = ERROR_CODE_UNKNOWN_OBJECT; + switch (rpdata->object_type) { + case OBJECT_ANALOG_INPUT: + if (Analog_Input_Valid_Instance(rpdata->object_instance)) { + apdu_len = Analog_Input_Read_Property(rpdata); + } + break; + case OBJECT_ANALOG_VALUE: + if (Analog_Value_Valid_Instance(rpdata->object_instance)) { + apdu_len = Analog_Value_Read_Property(rpdata); + } + break; + case OBJECT_BINARY_INPUT: + if (Binary_Input_Valid_Instance(rpdata->object_instance)) { + apdu_len = Binary_Input_Read_Property(rpdata); + } + break; + case OBJECT_BINARY_VALUE: + if (Binary_Value_Valid_Instance(rpdata->object_instance)) { + apdu_len = Binary_Value_Read_Property(rpdata); + } + break; + case OBJECT_DEVICE: + if (Device_Valid_Object_Instance_Number(rpdata->object_instance)) { + apdu_len = Device_Read_Property_Local(rpdata); + } + break; + default: + break; + } + + return apdu_len; +} + +bool Device_Write_Property_Local( + BACNET_WRITE_PROPERTY_DATA * wp_data) +{ + bool status = false; /* return value */ + int len = 0; + BACNET_APPLICATION_DATA_VALUE value; + + if (!Device_Valid_Object_Instance_Number(wp_data->object_instance)) { + wp_data->error_class = ERROR_CLASS_OBJECT; + wp_data->error_code = ERROR_CODE_UNKNOWN_OBJECT; + return false; + } + /* decode the some of the request */ + len = + bacapp_decode_application_data(wp_data->application_data, + wp_data->application_data_len, &value); + /* FIXME: len < application_data_len: more data? */ + if (len < 0) { + /* error while decoding - a value larger than we can handle */ + wp_data->error_class = ERROR_CLASS_PROPERTY; + wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE; + return false; + } + if ((wp_data->object_property != PROP_OBJECT_LIST) && + (wp_data->array_index != BACNET_ARRAY_ALL)) { + /* only array properties can have array options */ + wp_data->error_class = ERROR_CLASS_PROPERTY; + wp_data->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY; + return false; + } + switch (wp_data->object_property) { + case PROP_OBJECT_IDENTIFIER: + if (value.tag == BACNET_APPLICATION_TAG_OBJECT_ID) { + if ((value.type.Object_Id.type == OBJECT_DEVICE) && + (Device_Set_Object_Instance_Number(value.type. + Object_Id.instance))) { + /* we could send an I-Am broadcast to let the world know */ + status = true; + } else { + wp_data->error_class = ERROR_CLASS_PROPERTY; + wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE; + } + } else { + wp_data->error_class = ERROR_CLASS_PROPERTY; + wp_data->error_code = ERROR_CODE_INVALID_DATA_TYPE; + } + break; + case PROP_MAX_INFO_FRAMES: + if (value.tag == BACNET_APPLICATION_TAG_UNSIGNED_INT) { + if (value.type.Unsigned_Int <= 255) { + dlmstp_set_max_info_frames(value.type.Unsigned_Int); + status = true; + } else { + wp_data->error_class = ERROR_CLASS_PROPERTY; + wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE; + } + } else { + wp_data->error_class = ERROR_CLASS_PROPERTY; + wp_data->error_code = ERROR_CODE_INVALID_DATA_TYPE; + } + break; + case PROP_MAX_MASTER: + if (value.tag == BACNET_APPLICATION_TAG_UNSIGNED_INT) { + if ((value.type.Unsigned_Int > 0) && + (value.type.Unsigned_Int <= 127)) { + dlmstp_set_max_master(value.type.Unsigned_Int); + status = true; + } else { + wp_data->error_class = ERROR_CLASS_PROPERTY; + wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE; + } + } else { + wp_data->error_class = ERROR_CLASS_PROPERTY; + wp_data->error_code = ERROR_CODE_INVALID_DATA_TYPE; + } + break; + case PROP_OBJECT_NAME: + if (value.tag == BACNET_APPLICATION_TAG_CHARACTER_STRING) { + uint8_t encoding; + size_t len; + + encoding = + characterstring_encoding(&value.type.Character_String); + len = characterstring_length(&value.type.Character_String); + if (encoding == CHARACTER_ANSI_X34) { + if (len <= 20) { + /* FIXME: set the name */ + /* Display_Set_Name( + characterstring_value(&value.type.Character_String)); */ + /* FIXME: All the object names in a device must be unique. + Disallow setting the Device Object Name to any objects in + the device. */ + } else { + wp_data->error_class = ERROR_CLASS_PROPERTY; + wp_data->error_code = + ERROR_CODE_NO_SPACE_TO_WRITE_PROPERTY; + } + } else { + wp_data->error_class = ERROR_CLASS_PROPERTY; + wp_data->error_code = + ERROR_CODE_CHARACTER_SET_NOT_SUPPORTED; + } + } else { + wp_data->error_class = ERROR_CLASS_PROPERTY; + wp_data->error_code = ERROR_CODE_INVALID_DATA_TYPE; + } + break; + case 9600: + if (value.tag == BACNET_APPLICATION_TAG_UNSIGNED_INT) { + if (value.type.Unsigned_Int > 115200) { + RS485_Set_Baud_Rate(value.type.Unsigned_Int); + status = true; + } else { + wp_data->error_class = ERROR_CLASS_PROPERTY; + wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE; + } + } else { + wp_data->error_class = ERROR_CLASS_PROPERTY; + wp_data->error_code = ERROR_CODE_INVALID_DATA_TYPE; + } + break; + case PROP_NUMBER_OF_APDU_RETRIES: + case PROP_APDU_TIMEOUT: + case PROP_VENDOR_IDENTIFIER: + case PROP_SYSTEM_STATUS: + case PROP_LOCATION: + case PROP_DESCRIPTION: + case PROP_MODEL_NAME: + case PROP_VENDOR_NAME: + case PROP_FIRMWARE_REVISION: + case PROP_APPLICATION_SOFTWARE_VERSION: + case PROP_LOCAL_TIME: + case PROP_UTC_OFFSET: + case PROP_LOCAL_DATE: + case PROP_DAYLIGHT_SAVINGS_STATUS: + case PROP_PROTOCOL_VERSION: + case PROP_PROTOCOL_REVISION: + case PROP_PROTOCOL_SERVICES_SUPPORTED: + case PROP_PROTOCOL_OBJECT_TYPES_SUPPORTED: + case PROP_OBJECT_LIST: + case PROP_MAX_APDU_LENGTH_ACCEPTED: + case PROP_SEGMENTATION_SUPPORTED: + case PROP_DEVICE_ADDRESS_BINDING: + case PROP_DATABASE_REVISION: + case PROP_ACTIVE_COV_SUBSCRIPTIONS: + wp_data->error_class = ERROR_CLASS_PROPERTY; + wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED; + break; + default: + wp_data->error_class = ERROR_CLASS_PROPERTY; + wp_data->error_code = ERROR_CODE_UNKNOWN_PROPERTY; + break; + } + + return status; +} + +bool Device_Write_Property( + BACNET_WRITE_PROPERTY_DATA * wp_data) +{ + bool status = false; /* Ever the pessamist! */ + struct object_functions *pObject = NULL; + + /* initialize the default return values */ + wp_data->error_class = ERROR_CLASS_OBJECT; + wp_data->error_code = ERROR_CODE_UNKNOWN_OBJECT; + switch (wp_data->object_type) { + case OBJECT_ANALOG_INPUT: + if (Analog_Input_Valid_Instance(wp_data->object_instance)) { + wp_data->error_class = ERROR_CLASS_PROPERTY; + wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED; + } + break; + case OBJECT_ANALOG_VALUE: + if (Analog_Value_Valid_Instance(wp_data->object_instance)) { + status = Analog_Value_Write_Property(wp_data); + } + break; + case OBJECT_BINARY_INPUT: + if (Binary_Input_Valid_Instance(wp_data->object_instance)) { + wp_data->error_class = ERROR_CLASS_PROPERTY; + wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED; + } + break; + case OBJECT_BINARY_VALUE: + if (Binary_Value_Valid_Instance(wp_data->object_instance)) { + status = Binary_Value_Write_Property(wp_data); + } + break; + case OBJECT_DEVICE: + if (Device_Valid_Object_Instance_Number(wp_data->object_instance)) { + status = Device_Write_Property_Local(wp_data); + } + break; + default: + break; + } + + return (status); +} diff --git a/bacnet-stack/ports/pic18f97j60/dlmstp.c b/bacnet-stack/ports/pic18f97j60/dlmstp.c new file mode 100644 index 00000000..58b1c0ac --- /dev/null +++ b/bacnet-stack/ports/pic18f97j60/dlmstp.c @@ -0,0 +1,319 @@ +/************************************************************************** +* +* Copyright (C) 2006 Steve Karg +* +* 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 +#include +#include +#include +#if PRINT_ENABLED +#include +#endif +#include "bacdef.h" +#include "mstp.h" +#include "dlmstp.h" +#include "rs485.h" +#include "npdu.h" +#include "handlers.h" + +/* Number of MS/TP Packets Rx/Tx */ +uint16_t MSTP_Packets = 0; + +/* receive buffer */ +#pragma udata MSTP_RxData +static DLMSTP_PACKET Receive_Buffer; +/* temp buffer for NPDU insertion */ +/* local MS/TP port data - shared with RS-485 */ +#pragma udata MSTP_PortData +volatile struct mstp_port_struct_t MSTP_Port; +#pragma udata + +#define INCREMENT_AND_LIMIT_UINT16(x) {if (x < 0xFFFF) x++;} + +void dlmstp_millisecond_timer( + void) +{ + INCREMENT_AND_LIMIT_UINT16(MSTP_Port.SilenceTimer); +} + +void dlmstp_reinit( + void) +{ + RS485_Reinit(); + dlmstp_set_my_address(DEFAULT_MAC_ADDRESS); + dlmstp_set_max_info_frames(DEFAULT_MAX_INFO_FRAMES); + dlmstp_set_max_master(DEFAULT_MAX_MASTER); +} + +void dlmstp_init( + void) +{ + uint8_t data; + + /* initialize buffer */ + Receive_Buffer.ready = false; + Receive_Buffer.pdu_len = 0; + /* initialize hardware */ + RS485_Initialize(); + MSTP_Port.InputBuffer = &Receive_Buffer.pdu[0]; + MSTP_Init(&MSTP_Port); +} + +void dlmstp_cleanup( + void) +{ + /* nothing to do for static buffers */ +} + +/* returns number of bytes sent on success, zero on failure */ +int dlmstp_send_pdu( + BACNET_ADDRESS * dest, /* destination address */ + BACNET_NPDU_DATA * npdu_data, /* network information */ + uint8_t * pdu, /* any data to be sent - may be null */ + unsigned pdu_len) +{ /* number of bytes of data */ + int bytes_sent = 0; + unsigned npdu_len = 0; + uint8_t frame_type = 0; + BACNET_ADDRESS src; + unsigned i = 0; /* loop counter */ + + if (MSTP_Port.TxReady == false) { + if (npdu_data->data_expecting_reply) + MSTP_Port.TxFrameType = FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY; + else + MSTP_Port.TxFrameType = FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY; + + /* load destination MAC address */ + if (dest && dest->mac_len) { + MSTP_Port.TxDestination = dest->mac[0]; + } else { + /* mac_len = 0 is a broadcast address */ + MSTP_Port.TxDestination = MSTP_BROADCAST_ADDRESS; + } + dlmstp_get_my_address(&src); + if ((MAX_HEADER + pdu_len) > MAX_MPDU) { + return -4; + } + bytes_sent = + MSTP_Create_Frame((uint8_t *) & MSTP_Port.TxBuffer[0], + sizeof(MSTP_Port.TxBuffer), MSTP_Port.TxFrameType, + MSTP_Port.TxDestination, MSTP_Port.This_Station, pdu, pdu_len); + MSTP_Port.TxLength = bytes_sent; + MSTP_Port.TxReady = true; + MSTP_Packets++; + } + + return bytes_sent; +} + +void dlmstp_task( + void) +{ + bool bytes_remaining; + bool received_frame; + + /* only do receive state machine while we don't have a frame */ + if ((MSTP_Port.ReceivedValidFrame == false) && + (MSTP_Port.ReceivedInvalidFrame == false)) { + do { + bytes_remaining = RS485_Check_UART_Data(&MSTP_Port); + MSTP_Receive_Frame_FSM(&MSTP_Port); + received_frame = MSTP_Port.ReceivedValidFrame || + MSTP_Port.ReceivedInvalidFrame; + if (received_frame) + break; + } while (bytes_remaining); + } + /* only do master state machine while rx is idle */ + if (MSTP_Port.receive_state == MSTP_RECEIVE_STATE_IDLE) { + if (MSTP_Port.This_Station <= DEFAULT_MAX_MASTER) { + while (MSTP_Master_Node_FSM(&MSTP_Port)) { + /* do nothing while some states fast transition */ + }; + } + } + /* see if there is a packet available, and a place + to put the reply (if necessary) and process it */ + if (Receive_Buffer.ready && !MSTP_Port.TxReady) { + if (Receive_Buffer.pdu_len) { + MSTP_Packets++; + npdu_handler(&Receive_Buffer.address, &Receive_Buffer.pdu[0], + Receive_Buffer.pdu_len); + } + Receive_Buffer.ready = false; + } + + return; +} + +void dlmstp_fill_bacnet_address( + BACNET_ADDRESS * src, + uint8_t mstp_address) +{ + int i = 0; + + if (mstp_address == MSTP_BROADCAST_ADDRESS) { + /* mac_len = 0 if broadcast address */ + src->mac_len = 0; + src->mac[0] = 0; + } else { + src->mac_len = 1; + src->mac[0] = mstp_address; + } + /* fill with 0's starting with index 1; index 0 filled above */ + for (i = 1; i < MAX_MAC_LEN; i++) { + src->mac[i] = 0; + } + src->net = 0; + src->len = 0; + for (i = 0; i < MAX_MAC_LEN; i++) { + src->adr[i] = 0; + } +} + +/* for the MS/TP state machine to use for putting received data */ +uint16_t dlmstp_put_receive( + uint8_t src, /* source MS/TP address */ + uint8_t * pdu, /* PDU data */ + uint16_t pdu_len) +{ /* amount of PDU data */ + /* PDU is already in the Receive_Buffer */ + dlmstp_fill_bacnet_address(&Receive_Buffer.address, src); + Receive_Buffer.pdu_len = pdu_len; + Receive_Buffer.ready = true; +} + +void dlmstp_set_my_address( + uint8_t mac_address) +{ + /* Master Nodes can only have address 0-127 */ + if (mac_address <= 127) { + MSTP_Port.This_Station = mac_address; + /* FIXME: implement your data storage */ + /* I2C_Write_Byte( + EEPROM_DEVICE_ADDRESS, + mac_address, + EEPROM_MSTP_MAC_ADDR); */ + if (mac_address > MSTP_Port.Nmax_master) + dlmstp_set_max_master(mac_address); + } + + return; +} + +uint8_t dlmstp_my_address( + void) +{ + return MSTP_Port.This_Station; +} + +/* This parameter represents the value of the Max_Info_Frames property of */ +/* the node's Device object. The value of Max_Info_Frames specifies the */ +/* maximum number of information frames the node may send before it must */ +/* pass the token. Max_Info_Frames may have different values on different */ +/* nodes. This may be used to allocate more or less of the available link */ +/* bandwidth to particular nodes. If Max_Info_Frames is not writable in a */ +/* node, its value shall be 1. */ +void dlmstp_set_max_info_frames( + uint8_t max_info_frames) +{ + if (max_info_frames >= 1) { + MSTP_Port.Nmax_info_frames = max_info_frames; + /* FIXME: implement your data storage */ + /* I2C_Write_Byte( + EEPROM_DEVICE_ADDRESS, + (uint8_t)max_info_frames, + EEPROM_MSTP_MAX_INFO_FRAMES_ADDR); */ + } + + return; +} + +unsigned dlmstp_max_info_frames( + void) +{ + return MSTP_Port.Nmax_info_frames; +} + +/* This parameter represents the value of the Max_Master property of the */ +/* node's Device object. The value of Max_Master specifies the highest */ +/* allowable address for master nodes. The value of Max_Master shall be */ +/* less than or equal to 127. If Max_Master is not writable in a node, */ +/* its value shall be 127. */ +void dlmstp_set_max_master( + uint8_t max_master) +{ + if (max_master <= 127) { + if (MSTP_Port.This_Station <= max_master) { + MSTP_Port.Nmax_master = max_master; + /* FIXME: implement your data storage */ + /* I2C_Write_Byte( + EEPROM_DEVICE_ADDRESS, + max_master, + EEPROM_MSTP_MAX_MASTER_ADDR); */ + } + } + + return; +} + +uint8_t dlmstp_max_master( + void) +{ + return MSTP_Port.Nmax_master; +} + +void dlmstp_get_my_address( + BACNET_ADDRESS * my_address) +{ + int i = 0; /* counter */ + + my_address->mac_len = 1; + my_address->mac[0] = MSTP_Port.This_Station; + my_address->net = 0; /* local only, no routing */ + my_address->len = 0; + for (i = 0; i < MAX_MAC_LEN; i++) { + my_address->adr[i] = 0; + } + + return; +} + +void dlmstp_get_broadcast_address( + BACNET_ADDRESS * dest) +{ /* destination address */ + int i = 0; /* counter */ + + if (dest) { + dest->mac_len = 1; + dest->mac[0] = MSTP_BROADCAST_ADDRESS; + dest->net = BACNET_BROADCAST_NETWORK; + dest->len = 0; /* always zero when DNET is broadcast */ + for (i = 0; i < MAX_MAC_LEN; i++) { + dest->adr[i] = 0; + } + } + + return; +} diff --git a/bacnet-stack/ports/pic18f97j60/dlmstp.h b/bacnet-stack/ports/pic18f97j60/dlmstp.h new file mode 100644 index 00000000..a1b76a88 --- /dev/null +++ b/bacnet-stack/ports/pic18f97j60/dlmstp.h @@ -0,0 +1,125 @@ +/*####COPYRIGHTBEGIN#### + ------------------------------------------- + Copyright (C) 2005 Steve Karg + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to: + The Free Software Foundation, Inc. + 59 Temple Place - Suite 330 + Boston, MA 02111-1307 + USA. + + As a special exception, if other files instantiate templates or + use macros or inline functions from this file, or you compile + this file and link it with other works to produce a work based + on this file, this file does not by itself cause the resulting + work to be covered by the GNU General Public License. However + the source code for this file must still be made available in + accordance with section (3) of the GNU General Public License. + + This exception does not invalidate any other reasons why a work + based on this file might be covered by the GNU General Public + License. + ------------------------------------------- +####COPYRIGHTEND####*/ +#ifndef DLMSTP_H +#define DLMSTP_H + +#include +#include +#include +#include "bacdef.h" +#include "npdu.h" + +/* defines specific to MS/TP */ +#define MAX_HEADER (2+1+1+1+2+1) +#define MAX_MPDU (MAX_HEADER+MAX_PDU) + +typedef struct dlmstp_packet { + bool ready; /* true if ready to be sent or received */ + BACNET_ADDRESS address; /* source address */ + uint8_t frame_type; /* type of message */ + unsigned pdu_len; /* packet length */ + uint8_t pdu[MAX_MPDU]; /* packet */ +} DLMSTP_PACKET; + +/* number of MS/TP tx/rx packets */ +extern uint16_t MSTP_Packets; + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + void dlmstp_reinit( + void); + void dlmstp_init( + void); + void dlmstp_cleanup( + void); + void dlmstp_millisecond_timer( + void); + void dlmstp_task( + void); + + /* returns number of bytes sent on success, negative on failure */ + int dlmstp_send_pdu( + BACNET_ADDRESS * dest, /* destination address */ + BACNET_NPDU_DATA * npdu_data, /* network information */ + uint8_t * pdu, /* any data to be sent - may be null */ + unsigned pdu_len); /* number of bytes of data */ + + /* This parameter represents the value of the Max_Info_Frames property of */ + /* the node's Device object. The value of Max_Info_Frames specifies the */ + /* maximum number of information frames the node may send before it must */ + /* pass the token. Max_Info_Frames may have different values on different */ + /* nodes. This may be used to allocate more or less of the available link */ + /* bandwidth to particular nodes. If Max_Info_Frames is not writable in a */ + /* node, its value shall be 1. */ + void dlmstp_set_max_info_frames( + uint8_t max_info_frames); + unsigned dlmstp_max_info_frames( + void); + + /* This parameter represents the value of the Max_Master property of the */ + /* node's Device object. The value of Max_Master specifies the highest */ + /* allowable address for master nodes. The value of Max_Master shall be */ + /* less than or equal to 127. If Max_Master is not writable in a node, */ + /* its value shall be 127. */ + void dlmstp_set_max_master( + uint8_t max_master); + uint8_t dlmstp_max_master( + void); + + /* MAC address for MS/TP */ + void dlmstp_set_my_address( + uint8_t my_address); + uint8_t dlmstp_my_address( + void); + + /* BACnet address used in datalink */ + void dlmstp_get_my_address( + BACNET_ADDRESS * my_address); + void dlmstp_get_broadcast_address( + BACNET_ADDRESS * dest); /* destination address */ + + /* MS/TP state machine functions */ + uint16_t dlmstp_put_receive( + uint8_t src, /* source MS/TP address */ + uint8_t * pdu, /* PDU data */ + uint16_t pdu_len); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ +#endif diff --git a/bacnet-stack/ports/pic18f97j60/hardware.h b/bacnet-stack/ports/pic18f97j60/hardware.h new file mode 100644 index 00000000..7c172e3b --- /dev/null +++ b/bacnet-stack/ports/pic18f97j60/hardware.h @@ -0,0 +1,128 @@ +/************************************************************************** +* +* Copyright (C) 2007 Steve Karg +* +* 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. +* +*********************************************************************/ +#ifndef HARDWARE_H +#define HARDWARE_H + +#include +#include +#include + +/* PORTA.0 Photocell Input PORTA.1 LED Row6 PORTA.2 LED Row5 PORTA.3 LED + * Row4 PORTA.4 Square Wave input from RTC PORTA.5 LCD RW PORTB.0 Zero + * Cross PORTB.1 USB RXF# PORTB.2 USB TXE# PORTB.3 Keypad Row Enable + * (74HC373 Output Control) PORTB.4 Keypad Row Gate (74HC373 Gate) + * PORTB.5 Switch Input Latch & Keypad Column Gate (74HC373 Gate) PORTB.6 + * ICD connection PORTB.7 ICD connection PORTC.0 Pilot Latch PORTC.1 + * Pilot Output Enable (low) PORTC.2 Piezo PORTC.3 I2C clock PORTC.4 I2C + * data PORTC.5 RS232 enable (low) PORTC.6 RS232 Tx PORTC.7 RS232 Rx + * PORTD.0 Data bus PORTD.1 Data bus PORTD.2 Data bus PORTD.3 Data bus + * PORTD.4 Data bus PORTD.5 Data bus PORTD.6 Data bus PORTD.7 Data bus + * PORTE.0 USB RD PORTE.1 USB WR PORTE.2 LCD RS PORTE.3 485 transmit + * enable PORTE.4 Relay data latch PORTE.5 Switch Input Clock PORTE.6 + * Switch Input High/Low PORTE.7 Switch Input Data PORTF.0 LED Row2 + * PORTF.1 LED Row1 PORTF.2 LED Col5 PORTF.3 LED Col4 PORTF.4 LED Col3 + * PORTF.5 LED Col2 PORTF.6 LED Col1 PORTF.7 LED Col0 PORTG.0 485 receive + * enable PORTG.1 485 Tx PORTG.2 485 Rx PORTG.3 LCD E PORTG.4 LED Row0 */ +#define RS485_TX_ENABLE PORTEbits.RE3 +#define RS485_RX_DISABLE PORTGbits.RG0 + +#define LEDPORT PORTG +#define LEDTRIS TRISG +#define LED_ROW1 PORTGbits.RG1 +#define LED_ROW2 PORTGbits.RG2 +#define LED_ROW3 PORTGbits.RG3 +#define LED_ROW4 PORTGbits.RG4 + +#define TURN_OFF_COMPARATORS() CMCON = 0x07 + +enum INT_STATE { INT_DISABLED, INT_ENABLED, INT_RESTORE }; + +#define RESTART_WDT() { _asm CLRWDT _endasm } + +/* ************************************************************************* + define ENABLE_GLOBAL_INT() INTCONbits.GIE = 1 £ + #define DISABLE_GLOBAL_INT() INTCONbits.GIE = 0 £ + #define ENABLE_PERIPHERAL_INT() INTCONbits.PEIE = 1 £ + #define DISABLE_PERIPHERAL_INT() INTCONbits.PEIE = 0 + *************************************************************************** */ +#define ENABLE_HIGH_INT() INTCONbits.GIE = 1 +#define DISABLE_HIGH_INT() INTCONbits.GIE = 0 + +#define ENABLE_LOW_INT() INTCONbits.PEIE = 1 +#define DISABLE_LOW_INT() INTCONbits.PEIE = 0 + +#define ENABLE_TIMER0_INT() INTCONbits.TMR0IE = 1 +#define DISABLE_TIMER0_INT() INTCONbits.TMR0IE = 0 + +#define ENABLE_TIMER2_INT() PIE1bits.TMR2IE = 1 +#define DISABLE_TIMER2_INT() PIE1bits.TMR2IE = 0 + +#define ENABLE_TIMER4_INT() PIE3bits.TMR4IE = 1 +#define DISABLE_TIMER4_INT() PIE3bits.TMR4IE = 0 + +#define ENABLE_CCP2_INT() PIE2bits.CCP2IE = 1 +#define DISABLE_CCP2_INT() PIE2bits.CCP2IE = 0 + +#define ENABLE_CCP1_INT() PIE1bits.CCP1IE = 1 +#define DISABLE_CCP1_INT() PIE1bits.CCP1IE = 0 + +#define ENABLE_ABUS_INT() PIE1bits.SSPIE = 1 +#define DISABLE_ABUS_INT() PIE1bits.SSPIE = 0 +#define CLEAR_ABUS_FLAG() PIR1bits.SSPIF = 0 + +#define SETUP_CCP1(x) CCP1CON = x +#define SETUP_CCP2(x) CCP2CON = x + +#define DISABLE_RX_INT() PIE1bits.RCIE = 0 +#define ENABLE_RX_INT() PIE1bits.RCIE = 1 + +#define DISABLE_TX_INT() PIE1bits.TXIE = 0 +#define ENABLE_TX_INT() PIE1bits.TXIE = 1 + +#if CLOCKSPEED == 20 +#define DELAY_US(x) { _asm \ + MOVLW x \ + LOOP: \ + NOP \ + NOP \ + DECFSZ WREG, 1, 0 \ + BRA LOOP \ + _endasm } +#endif + +#define setup_timer4(mode, period, postscale) \ + T4CON = (mode | (postscale - 1) << 3); \ + PR4 = period + +#define setup_timer2(mode, period, postscale) \ + T2CON = (mode | (postscale - 1) << 3); \ + PR2 = period + + +/* Global Vars */ +extern uint8_t Piezo_Timer; +extern volatile bool DataPortLocked; + +#endif /* HARDWARE_H */ diff --git a/bacnet-stack/ports/pic18f97j60/isr.c b/bacnet-stack/ports/pic18f97j60/isr.c new file mode 100644 index 00000000..6a8671ff --- /dev/null +++ b/bacnet-stack/ports/pic18f97j60/isr.c @@ -0,0 +1,206 @@ +/************************************************************************** +* +* Copyright (C) 2007 Steve Karg +* +* 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 "stdint.h" +#include "hardware.h" +#include "rs485.h" +#include "dlmstp.h" + +/* from main.c */ +extern volatile uint8_t Milliseconds; + +void InterruptHandlerHigh( + void); +void InterruptHandlerLow( + void); +void Interrupt_Timer2( + void); +void Interrupt_Timer3( + void); +void Interrupt_Timer4( + void); +void Interrupt_USART_Rx( + void); +void Interrupt_USART_Tx( + void); +void Interrupt_CCP2( + void); +void INT0_Interrupt( + void); + +#pragma code InterruptVectorHigh = 0x08 +void InterruptVectorHigh( + void) +{ + /* jump to interrupt routine */ +_asm goto InterruptHandlerHigh _endasm} +#pragma code +#pragma code InterruptVectorLow = 0x18 +void InterruptVectorLow( + void) +{ + /* jump to interrupt routine */ +_asm goto InterruptHandlerLow _endasm} +#pragma code +#pragma interrupt InterruptHandlerHigh +void InterruptHandlerHigh( + void) +{ +#if 0 + /* check for USART Rx int */ + if ((PIR1bits.RCIF) && (PIE1bits.RCIE)) { + if ((RCSTA1bits.FERR) || (RCSTA1bits.OERR)) { + Comstat.Rx_Bufferoverrun = TRUE; + PIE1bits.RC1IE = 0; /* Disable Interrupt on receipt */ + } else if (Comstat.Rx_Bytes++ < RX_BUFFER_SIZE - 1) { + Rx_Buffer[Comstat.RxHead++] = RCREG1; + + /* Stick a Null on the end to let us use str functions on our + * buffer */ + Rx_Buffer[Comstat.RxHead] = 0; + } else { + Comstat.Rx_Bufferoverrun = TRUE; + PIE1bits.RC1IE = 0; /* Disable Interrupt on receipt */ + } + } +#endif + + /* check for timer0 int */ + if ((INTCONbits.TMR0IF) && (INTCONbits.TMR0IE)) { + INTCONbits.TMR0IF = 0; + } +} + +#pragma interruptlow InterruptHandlerLow save = PROD, section(".tmpdata"), TABLAT, TBLPTR, section \ + ("MATH_DATA") + +void InterruptHandlerLow( + void) +{ + /* check for timer2 int */ + if ((PIR1bits.TMR2IF) && (PIE1bits.TMR2IE)) { + PIR1bits.TMR2IF = 0; + Interrupt_Timer2(); + } + + /* check for timer3 int */ + if ((PIR2bits.TMR3IF) && (PIE2bits.TMR3IE)) { + PIR2bits.TMR3IF = 0; + Interrupt_Timer3(); + } + + /* check for timer4 int */ + if ((PIR3bits.TMR4IF) && (PIE3bits.TMR4IE)) { + PIR3bits.TMR4IF = 0; + dlmstp_millisecond_timer(); + Interrupt_Timer4(); + } + + /* check for compare int */ + if ((PIR2bits.CCP2IF) && (PIE2bits.CCP2IE)) { + PIR2bits.CCP2IF = 0; + Interrupt_CCP2(); + } + + /* check for USART Tx int */ + if ((PIR3bits.TX2IF) && (PIE3bits.TX2IE)) { + RS485_Interrupt_Tx(); + } + + /* check for USART Rx int */ + if ((PIR3bits.RC2IF) && (PIE3bits.RC2IE)) { + RS485_Interrupt_Rx(); + } + +/* Unused Interrupts + //check for timer1 int + if ((PIR1bits.TMR1IF) && (PIE1bits.TMR1IE)) + { + PIR1bits.TMR1IF = 0; + Interrupt_Timer1(); + } + + //check for compare int + if ((PIR1bits.CCP1IF) && (PIE1bits.CCP1IE)) + { + PIR1bits.CCP1IF = 0; + Interrupt_CCP1(); + } + + //check for compare int + if ((PIR3bits.CCP3IF) && (PIE3bits.CCP3IE)) + { + PIR3bits.CCP3IF = 0; + Interrupt_CCP3(); + } + + //check for compare int + if ((PIR3bits.CCP4IF) && (PIE3bits.CCP4IE)) + { + PIR3bits.CCP4IF = 0; + + Interrupt_CCP4(); + } + + //check for AD int + if ((PIR1bits.ADIF) && (PIE1bits.ADIE)) + { + PIR1bits.ADIF = 0; + Interrupt_ADC(); + } + + //check for MSSP int + if ((PIR1bits.SSPIF) && (PIE1bits.SSPIE)) + { + PIR1bits.SSPIF = 0; + Interrupt_SSP(); + } + +*/ +} + +void Interrupt_Timer2( + void) +{ +} + +void Interrupt_Timer3( + void) +{ +} + +/* Timer4 is set to go off every 1ms. This is our system tick */ +void Interrupt_Timer4( + void) +{ + /* Milisecond is our system tick */ + if (Milliseconds < 0xFF) + ++Milliseconds; +} + +void Interrupt_CCP2( + void) +{ + +} diff --git a/bacnet-stack/ports/pic18f97j60/main.c b/bacnet-stack/ports/pic18f97j60/main.c new file mode 100644 index 00000000..ef3f6c3d --- /dev/null +++ b/bacnet-stack/ports/pic18f97j60/main.c @@ -0,0 +1,223 @@ +/************************************************************************** +* +* Copyright (C) 2007 Steve Karg +* +* 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 +#include +#include /* for memmove */ +#include +#include +#include "stdint.h" +#include "hardware.h" +/* BACnet */ +#include "apdu.h" +#include "datalink.h" +#include "dcc.h" +#include "handlers.h" +#include "client.h" +#include "txbuf.h" +#include "rs485.h" + +/* chip configuration data */ +/* define this to enable ICD */ +/* #define USE_ICD */ + +/* Configuration Bits */ +#pragma config FOSC = HSPLL +#pragma config FOSC2 = ON +#pragma config FCMEN = OFF +#pragma config XINST = OFF +#pragma config IESO = OFF +#pragma config CCP2MX = ON +#pragma config ECCPMX = ON +#pragma config STVR = OFF +#pragma config CP0 = OFF +#pragma config ETHLED = ON + +volatile uint8_t Milliseconds = 0; +volatile uint8_t Zero_Cross_Timeout = 0; + +void Reinitialize( + void) +{ + uint8_t i; + char name = 0; + + _asm reset _endasm return; +} + +void Global_Int( + enum INT_STATE state) +{ + static uint8_t intstate = 0; + + switch (state) { + case INT_DISABLED: + intstate >>= 2; + intstate |= (INTCON & 0xC0); + break; + case INT_ENABLED: + INTCONbits.GIE = 1; + INTCONbits.PEIE = 1; + intstate <<= 2; + break; + case INT_RESTORE: + INTCON |= (intstate & 0xC0); + intstate <<= 2; + break; + default: + break; + } +} + +void Hardware_Initialize( + void) +{ + /* PORTA.0 Input - Photocell PORTA.1 Output - LED Row6 PORTA.2 Output + * - LED Row5 PORTA.3 Output - LED Row4 PORTA.4 Input - Square Wave + * input from RTC PORTA.5 Output - LCD RW */ + TRISA = 0xD1; + + /* PORTB.0 Input - Zero Cross PORTB.1 Input - USB RXF# PORTB.2 Input + * USB TXE# PORTB.3 Output - Keypad Row Enable (74HC373 Output Control) + * PORTB.4 Output Keypad Row Gate (74HC373 Gate) PORTB.5 Output Switch + * Input Latch & Keypad Column Gate (74HC373 Gate) PORTB.6 Input - ICD + * connection PORTB.7 Input - ICD connection */ + TRISB = 0xC7; + + /* PORTC.0 Output - Pilot Latch PORTC.1 Output - Pilot Output Enable + * (low) PORTC.2 I/O - Piezo PORTC.3 Input - I2C clock PORTC.4 Input + * I2C data PORTC.5 Output RS232 enable (low) PORTC.6 Output - RS232 Tx + * PORTC.7 Input - RS232 Rx */ + TRISC = 0x9C; + + /* PORTD.0 I/O - Data bus PORTD.1 I/O - Data bus PORTD.2 I/O - Data + * bus PORTD.3 I/O - Data bus PORTD.4 I/O - Data bus PORTD.5 I/O - Data + * bus PORTD.6 I/O - Data bus PORTD.7 I/O - Data bus */ + TRISD = 0xFF; + + /* PORTE.0 Input - USB RD PORTE.1 Input - USB WR PORTE.2 Output - LCD + * RS PORTE.3 Output - 485 transmit enable PORTE.4 Output - Relay data + * latch PORTE.5 Output Switch Input Clock PORTE.6 Output - Switch + * Input High/Low PORTE.7 Input Switch Input Data */ + TRISE = 0x83; + + /* PORTF.0 Output - LED Row2 PORTF.1 Output - LED Row1 PORTF.2 Output + * - LED Col5 PORTF.3 Output - LED Col4 PORTF.4 Output - LED Col3 + * PORTF.5 Output - LED Col2 PORTF.6 Output - LED Col1 PORTF.7 Output + * LED Col0 */ + TRISF = 0x00; + + /* PORTG.0 Output - 485 receive enable PORTG.1 Output - 485 Tx PORTG.2 + * Input 485 Rx PORTG.3 Output - LCD E PORTG.4 Output - LED Row0 */ + TRISG = 0xE6; + + /* Turn all leds off. These are the hardware pins */ + LED_ROW1 = 1; + LED_ROW2 = 1; + LED_ROW3 = 1; + LED_ROW4 = 1; + LEDPORT = 0x03; + + /* The following gives us a PWM frequency of 1.990KHz with a 50% duty + * cycle It also serves to multiplex the LEDs. */ + CCPR1L = 0x4E; + CCP1CON = 0x2F; + setup_timer2(6, 156, 2); + PIE1bits.TMR2IE = 1; + + /* We will use Timer4 as our system tick timer. Our system tick is set + * to 1ms. Hold off on enabling the int. */ + setup_timer4(5, 250, 5); + + /* Setup our interrupt priorities */ + RCONbits.IPEN = 1; + IPR1 = 0; + IPR2 = 0; + IPR3 = 0; + + /* Setup TMR0 to be high priority */ + INTCON2 = 0xFC; + INTCON3 = 0; + + /* USART 1 high priority */ + IPR1bits.RC1IP = 1; + IPR1bits.TX1IP = 1; + + /* Finally enable our ints */ + Global_Int(INT_ENABLED); +} + +void Initialize_Variables( + void) +{ + /* Check to see if we need to initialize our eeproms */ + ENABLE_TIMER4_INT(); + /* interrupts must be enabled before we read our inputs */ + Global_Int(INT_ENABLED); + /* Start our time from now */ + Milliseconds = 0; +} + +void MainTasks( + void) +{ + static uint16_t millisecond_counter = 0; + /* Handle our millisecond counters */ + while (Milliseconds) { + millisecond_counter++; + --Milliseconds; + } + /* Handle our seconds counters */ + if (millisecond_counter > 1000) { + millisecond_counter -= 1000; + dcc_timer_seconds(1); + } +} + +void main( + void) +{ + RCONbits.NOT_POR = 1; + RCONbits.NOT_RI = 1; + Hardware_Initialize(); + Initialize_Variables(); + /* initialize BACnet Data Link Layer */ + dlmstp_set_my_address(42); + dlmstp_set_max_info_frames(1); + dlmstp_set_max_master(127); + RS485_Set_Baud_Rate(38400); + dlmstp_init(); + /* Handle anything that needs to be done on powerup */ + /* Greet the BACnet world! */ + Send_I_Am(&Handler_Transmit_Buffer[0]); + /* Main loop */ + while (TRUE) { + RESTART_WDT(); + dlmstp_task(); + MainTasks(); + Global_Int(INT_ENABLED); + ENABLE_TIMER4_INT(); + } +} diff --git a/bacnet-stack/ports/pic18f97j60/mstp.c b/bacnet-stack/ports/pic18f97j60/mstp.c new file mode 100644 index 00000000..c33b102e --- /dev/null +++ b/bacnet-stack/ports/pic18f97j60/mstp.c @@ -0,0 +1,1250 @@ +/*####COPYRIGHTBEGIN#### + ------------------------------------------- + Copyright (C) 2003 Steve Karg + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to: + The Free Software Foundation, Inc. + 59 Temple Place - Suite 330 + Boston, MA 02111-1307 + USA. + + As a special exception, if other files instantiate templates or + use macros or inline functions from this file, or you compile + this file and link it with other works to produce a work based + on this file, this file does not by itself cause the resulting + work to be covered by the GNU General Public License. However + the source code for this file must still be made available in + accordance with section (3) of the GNU General Public License. + + This exception does not invalidate any other reasons why a work + based on this file might be covered by the GNU General Public + License. + ------------------------------------------- +####COPYRIGHTEND####*/ + +/* This clause describes a Master-Slave/Token-Passing (MS/TP) data link */ +/* protocol, which provides the same services to the network layer as */ +/* ISO 8802-2 Logical Link Control. It uses services provided by the */ +/* EIA-485 physical layer. Relevant clauses of EIA-485 are deemed to be */ +/* included in this standard by reference. The following hardware is assumed: */ +/* (a) A UART (Universal Asynchronous Receiver/Transmitter) capable of */ +/* transmitting and receiving eight data bits with one stop bit */ +/* and no parity. */ +/* (b) An EIA-485 transceiver whose driver may be disabled. */ +/* (c) A timer with a resolution of five milliseconds or less */ + +#include +#include +#if PRINT_ENABLED +#include +#endif +#include "mstp.h" +#include "bytes.h" +#include "bits.h" +#include "crc.h" +#include "bacaddr.h" +#include "rs485.h" +#if PRINT_ENABLED +#include "mstptext.h" +#endif + +/* debug print statements */ +#if PRINT_ENABLED +#define PRINT_ENABLED_RECEIVE 0 +#define PRINT_ENABLED_RECEIVE_DATA 1 +#define PRINT_ENABLED_MASTER 0 +#else +#define PRINT_ENABLED_RECEIVE 0 +#define PRINT_ENABLED_RECEIVE_DATA 0 +#define PRINT_ENABLED_MASTER 0 +#endif + +/* MS/TP Frame Format */ +/* All frames are of the following format: */ +/* */ +/* Preamble: two octet preamble: X`55', X`FF' */ +/* Frame Type: one octet */ +/* Destination Address: one octet address */ +/* Source Address: one octet address */ +/* Length: two octets, most significant octet first, of the Data field */ +/* Header CRC: one octet */ +/* Data: (present only if Length is non-zero) */ +/* Data CRC: (present only if Length is non-zero) two octets, */ +/* least significant octet first */ +/* (pad): (optional) at most one octet of padding: X'FF' */ + +/* The number of tokens received or used before a Poll For Master cycle */ +/* is executed: 50. */ +#define Npoll 50 + +/* The number of retries on sending Token: 1. */ +#define Nretry_token 1 + +/* The minimum number of DataAvailable or ReceiveError events that must be */ +/* seen by a receiving node in order to declare the line "active": 4. */ +#define Nmin_octets 4 + +/* The minimum time without a DataAvailable or ReceiveError event within */ +/* a frame before a receiving node may discard the frame: 60 bit times. */ +/* (Implementations may use larger values for this timeout, */ +/* not to exceed 100 milliseconds.) */ +/* At 9600 baud, 60 bit times would be about 6.25 milliseconds */ +/* const uint16_t Tframe_abort = 1 + ((1000 * 60) / 9600); */ +#define Tframe_abort 30 + +/* The maximum idle time a sending node may allow to elapse between octets */ +/* of a frame the node is transmitting: 20 bit times. */ +#define Tframe_gap 20 + +/* The time without a DataAvailable or ReceiveError event before declaration */ +/* of loss of token: 500 milliseconds. */ +#define Tno_token 500 + +/* The maximum time after the end of the stop bit of the final */ +/* octet of a transmitted frame before a node must disable its */ +/* EIA-485 driver: 15 bit times. */ +#define Tpostdrive 15 + +/* The maximum time a node may wait after reception of a frame that expects */ +/* a reply before sending the first octet of a reply or Reply Postponed */ +/* frame: 250 milliseconds. */ +/* note: we always send a reply postponed since a message other than + the reply may be in the transmit queue */ +#define Treply_delay 10 + +/* The minimum time without a DataAvailable or ReceiveError event */ +/* that a node must wait for a station to begin replying to a */ +/* confirmed request: 255 milliseconds. (Implementations may use */ +/* larger values for this timeout, not to exceed 300 milliseconds.) */ +#define Treply_timeout 255 + +/* Repeater turnoff delay. The duration of a continuous logical one state */ +/* at the active input port of an MS/TP repeater after which the repeater */ +/* will enter the IDLE state: 29 bit times < Troff < 40 bit times. */ +#define Troff 30 + +/* The width of the time slot within which a node may generate a token: */ +/* 10 milliseconds. */ +#define Tslot 10 + +/* The maximum time a node may wait after reception of the token or */ +/* a Poll For Master frame before sending the first octet of a frame: */ +/* 15 milliseconds. */ +#define Tusage_delay 15 + +/* The minimum time without a DataAvailable or ReceiveError event that a */ +/* node must wait for a remote node to begin using a token or replying to */ +/* a Poll For Master frame: 20 milliseconds. (Implementations may use */ +/* larger values for this timeout, not to exceed 100 milliseconds.) */ +#define Tusage_timeout 20 + +/* we need to be able to increment without rolling over */ +#define INCREMENT_AND_LIMIT_UINT8(x) {if (x < 0xFF) x++;} + +bool MSTP_Line_Active( + volatile struct mstp_port_struct_t *mstp_port) +{ + return (mstp_port->EventCount > Nmin_octets); +} + +unsigned MSTP_Create_Frame( + uint8_t * buffer, /* where frame is loaded */ + unsigned buffer_len, /* amount of space available */ + uint8_t frame_type, /* type of frame to send - see defines */ + uint8_t destination, /* destination address */ + uint8_t source, /* source address */ + uint8_t * data, /* any data to be sent - may be null */ + unsigned data_len) +{ /* number of bytes of data (up to 501) */ + uint8_t crc8 = 0xFF; /* used to calculate the crc value */ + uint16_t crc16 = 0xFFFF; /* used to calculate the crc value */ + unsigned index = 0; /* used to load the data portion of the frame */ + + /* not enough to do a header */ + if (buffer_len < 8) + return 0; + + buffer[0] = 0x55; + buffer[1] = 0xFF; + buffer[2] = frame_type; + crc8 = CRC_Calc_Header(buffer[2], crc8); + buffer[3] = destination; + crc8 = CRC_Calc_Header(buffer[3], crc8); + buffer[4] = source; + crc8 = CRC_Calc_Header(buffer[4], crc8); + buffer[5] = HI_BYTE(data_len); + crc8 = CRC_Calc_Header(buffer[5], crc8); + buffer[6] = LO_BYTE(data_len); + crc8 = CRC_Calc_Header(buffer[6], crc8); + buffer[7] = ~crc8; + + index = 8; + while (data_len && data && (index < buffer_len)) { + buffer[index] = *data; + crc16 = CRC_Calc_Data(buffer[index], crc16); + data++; + index++; + data_len--; + } + /* append the data CRC if necessary */ + if (index > 8) { + if ((index + 2) <= buffer_len) { + crc16 = ~crc16; + buffer[index] = LO_BYTE(crc16); + index++; + buffer[index] = HI_BYTE(crc16); + index++; + } else + return 0; + } + + return index; /* returns the frame length */ +} + +void MSTP_Create_And_Send_Frame( + volatile struct mstp_port_struct_t *mstp_port, /* port to send from */ + uint8_t frame_type, /* type of frame to send - see defines */ + uint8_t destination, /* destination address */ + uint8_t source, /* source address */ + uint8_t * data, /* any data to be sent - may be null */ + unsigned data_len) +{ /* number of bytes of data (up to 501) */ + uint8_t buffer[MAX_MPDU] = { 0 }; /* buffer for sending */ + uint16_t len = 0; /* number of bytes to send */ + + len = (uint16_t) MSTP_Create_Frame(&buffer[0], /* where frame is loaded */ + sizeof(buffer), /* amount of space available */ + frame_type, /* type of frame to send - see defines */ + destination, /* destination address */ + source, /* source address */ + data, /* any data to be sent - may be null */ + data_len); /* number of bytes of data (up to 501) */ + + RS485_Send_Frame(mstp_port, &buffer[0], len); + /* FIXME: be sure to reset SilenceTimer after each octet is sent! */ +} + +void MSTP_Receive_Frame_FSM( + volatile struct mstp_port_struct_t *mstp_port) +{ +#if PRINT_ENABLED_RECEIVE_DATA + static MSTP_RECEIVE_STATE receive_state = MSTP_RECEIVE_STATE_IDLE; +#endif +#if PRINT_ENABLED_RECEIVE + fprintf(stderr, + "MSTP Rx: State=%s Data=%02X hCRC=%02X Index=%u EC=%u DateLen=%u Silence=%u\n", + mstptext_receive_state(mstp_port->receive_state), + mstp_port->DataRegister, mstp_port->HeaderCRC, mstp_port->Index, + mstp_port->EventCount, mstp_port->DataLength, mstp_port->SilenceTimer); +#endif + switch (mstp_port->receive_state) { + /* In the IDLE state, the node waits for the beginning of a frame. */ + case MSTP_RECEIVE_STATE_IDLE: + /* EatAnError */ + if (mstp_port->ReceiveError == true) { + mstp_port->ReceiveError = false; + mstp_port->SilenceTimer = 0; + INCREMENT_AND_LIMIT_UINT8(mstp_port->EventCount); + /* wait for the start of a frame. */ + mstp_port->receive_state = MSTP_RECEIVE_STATE_IDLE; + } else if (mstp_port->DataAvailable == true) { +#if PRINT_ENABLED_RECEIVE_DATA + fprintf(stderr, "MSTP Rx: %02X ", mstp_port->DataRegister); +#endif + /* Preamble1 */ + if (mstp_port->DataRegister == 0x55) { + mstp_port->DataAvailable = false; + mstp_port->SilenceTimer = 0; + INCREMENT_AND_LIMIT_UINT8(mstp_port->EventCount); + /* receive the remainder of the frame. */ + mstp_port->receive_state = MSTP_RECEIVE_STATE_PREAMBLE; + } + /* EatAnOctet */ + else { +#if PRINT_ENABLED_RECEIVE_DATA + fprintf(stderr, "\n"); +#endif + mstp_port->DataAvailable = false; + mstp_port->SilenceTimer = 0; + INCREMENT_AND_LIMIT_UINT8(mstp_port->EventCount); + /* wait for the start of a frame. */ + mstp_port->receive_state = MSTP_RECEIVE_STATE_IDLE; + } + } + break; + /* In the PREAMBLE state, the node waits for the second octet of the preamble. */ + case MSTP_RECEIVE_STATE_PREAMBLE: + /* Timeout */ + if (mstp_port->SilenceTimer > Tframe_abort) { + /* a correct preamble has not been received */ + /* wait for the start of a frame. */ + mstp_port->receive_state = MSTP_RECEIVE_STATE_IDLE; + } + /* Error */ + else if (mstp_port->ReceiveError == true) { + mstp_port->ReceiveError = false; + mstp_port->SilenceTimer = 0; + INCREMENT_AND_LIMIT_UINT8(mstp_port->EventCount); + /* wait for the start of a frame. */ + mstp_port->receive_state = MSTP_RECEIVE_STATE_IDLE; + } else if (mstp_port->DataAvailable == true) { +#if PRINT_ENABLED_RECEIVE_DATA + fprintf(stderr, "%02X ", mstp_port->DataRegister); +#endif + /* Preamble2 */ + if (mstp_port->DataRegister == 0xFF) { + mstp_port->DataAvailable = false; + mstp_port->SilenceTimer = 0; + INCREMENT_AND_LIMIT_UINT8(mstp_port->EventCount); + mstp_port->Index = 0; + mstp_port->HeaderCRC = 0xFF; + /* receive the remainder of the frame. */ + mstp_port->receive_state = MSTP_RECEIVE_STATE_HEADER; + } + /* ignore RepeatedPreamble1 */ + else if (mstp_port->DataRegister == 0x55) { + mstp_port->DataAvailable = false; + mstp_port->SilenceTimer = 0; + INCREMENT_AND_LIMIT_UINT8(mstp_port->EventCount); + /* wait for the second preamble octet. */ + mstp_port->receive_state = MSTP_RECEIVE_STATE_PREAMBLE; + } + /* NotPreamble */ + else { + mstp_port->DataAvailable = false; + mstp_port->SilenceTimer = 0; + INCREMENT_AND_LIMIT_UINT8(mstp_port->EventCount); + /* wait for the start of a frame. */ + mstp_port->receive_state = MSTP_RECEIVE_STATE_IDLE; + } + } + break; + /* In the HEADER state, the node waits for the fixed message header. */ + case MSTP_RECEIVE_STATE_HEADER: + /* Timeout */ + if (mstp_port->SilenceTimer > Tframe_abort) { + /* indicate that an error has occurred during the reception of a frame */ + mstp_port->ReceivedInvalidFrame = true; + /* wait for the start of a frame. */ + mstp_port->receive_state = MSTP_RECEIVE_STATE_IDLE; + } + /* Error */ + else if (mstp_port->ReceiveError == true) { + mstp_port->ReceiveError = false; + mstp_port->SilenceTimer = 0; + INCREMENT_AND_LIMIT_UINT8(mstp_port->EventCount); + /* indicate that an error has occurred during the reception of a frame */ + mstp_port->ReceivedInvalidFrame = true; + /* wait for the start of a frame. */ + mstp_port->receive_state = MSTP_RECEIVE_STATE_IDLE; + } else if (mstp_port->DataAvailable == true) { +#if PRINT_ENABLED_RECEIVE_DATA + fprintf(stderr, "%02X ", mstp_port->DataRegister); +#endif + /* FrameType */ + if (mstp_port->Index == 0) { + mstp_port->SilenceTimer = 0; + INCREMENT_AND_LIMIT_UINT8(mstp_port->EventCount); + mstp_port->HeaderCRC = + CRC_Calc_Header(mstp_port->DataRegister, + mstp_port->HeaderCRC); + mstp_port->FrameType = mstp_port->DataRegister; + mstp_port->DataAvailable = false; + mstp_port->Index = 1; + mstp_port->receive_state = MSTP_RECEIVE_STATE_HEADER; + } + /* Destination */ + else if (mstp_port->Index == 1) { + mstp_port->SilenceTimer = 0; + INCREMENT_AND_LIMIT_UINT8(mstp_port->EventCount); + mstp_port->HeaderCRC = + CRC_Calc_Header(mstp_port->DataRegister, + mstp_port->HeaderCRC); + mstp_port->DestinationAddress = mstp_port->DataRegister; + mstp_port->DataAvailable = false; + mstp_port->Index = 2; + mstp_port->receive_state = MSTP_RECEIVE_STATE_HEADER; + } + /* Source */ + else if (mstp_port->Index == 2) { + mstp_port->SilenceTimer = 0; + INCREMENT_AND_LIMIT_UINT8(mstp_port->EventCount); + mstp_port->HeaderCRC = + CRC_Calc_Header(mstp_port->DataRegister, + mstp_port->HeaderCRC); + mstp_port->SourceAddress = mstp_port->DataRegister; + mstp_port->DataAvailable = false; + mstp_port->Index = 3; + mstp_port->receive_state = MSTP_RECEIVE_STATE_HEADER; + } + /* Length1 */ + else if (mstp_port->Index == 3) { + mstp_port->SilenceTimer = 0; + INCREMENT_AND_LIMIT_UINT8(mstp_port->EventCount); + mstp_port->HeaderCRC = + CRC_Calc_Header(mstp_port->DataRegister, + mstp_port->HeaderCRC); + mstp_port->DataLength = mstp_port->DataRegister * 256; + mstp_port->DataAvailable = false; + mstp_port->Index = 4; + mstp_port->receive_state = MSTP_RECEIVE_STATE_HEADER; + } + /* Length2 */ + else if (mstp_port->Index == 4) { + mstp_port->SilenceTimer = 0; + INCREMENT_AND_LIMIT_UINT8(mstp_port->EventCount); + mstp_port->HeaderCRC = + CRC_Calc_Header(mstp_port->DataRegister, + mstp_port->HeaderCRC); + mstp_port->DataLength += mstp_port->DataRegister; + mstp_port->DataAvailable = false; + mstp_port->Index = 5; + mstp_port->receive_state = MSTP_RECEIVE_STATE_HEADER; + } + /* HeaderCRC */ + else if (mstp_port->Index == 5) { + mstp_port->SilenceTimer = 0; + INCREMENT_AND_LIMIT_UINT8(mstp_port->EventCount); + mstp_port->HeaderCRC = + CRC_Calc_Header(mstp_port->DataRegister, + mstp_port->HeaderCRC); + mstp_port->DataAvailable = false; + /* don't wait for next state - do it here */ + if (mstp_port->HeaderCRC != 0x55) { + /* BadCRC */ + /* indicate that an error has occurred during the reception of a frame */ + mstp_port->ReceivedInvalidFrame = true; + /* wait for the start of the next frame. */ + mstp_port->receive_state = MSTP_RECEIVE_STATE_IDLE; + } else { + if ((mstp_port->DestinationAddress == + mstp_port->This_Station) + || (mstp_port->DestinationAddress == + MSTP_BROADCAST_ADDRESS)) { + /* FrameTooLong */ + if (mstp_port->DataLength > MAX_MPDU) { + /* indicate that a frame with an illegal or */ + /* unacceptable data length has been received */ + mstp_port->ReceivedInvalidFrame = true; + /* wait for the start of the next frame. */ + mstp_port->receive_state = + MSTP_RECEIVE_STATE_IDLE; + } + /* NoData */ + else if (mstp_port->DataLength == 0) { + /* indicate that a frame with no data has been received */ + mstp_port->ReceivedValidFrame = true; + /* wait for the start of the next frame. */ + mstp_port->receive_state = + MSTP_RECEIVE_STATE_IDLE; + } + /* Data */ + else { + mstp_port->Index = 0; + mstp_port->DataCRC = 0xFFFF; + /* receive the data portion of the frame. */ + mstp_port->receive_state = + MSTP_RECEIVE_STATE_DATA; + } + } + /* NotForUs */ + else { + /* wait for the start of the next frame. */ + mstp_port->receive_state = MSTP_RECEIVE_STATE_IDLE; + } + } + + + } + /* not per MS/TP standard, but it is a case not covered */ + else { + mstp_port->ReceiveError = false; + mstp_port->SilenceTimer = 0; + INCREMENT_AND_LIMIT_UINT8(mstp_port->EventCount); + /* indicate that an error has occurred during */ + /* the reception of a frame */ + mstp_port->ReceivedInvalidFrame = true; + /* wait for the start of a frame. */ + mstp_port->receive_state = MSTP_RECEIVE_STATE_IDLE; + } + } + break; + /* In the DATA state, the node waits for the data portion of a frame. */ + case MSTP_RECEIVE_STATE_DATA: + /* Timeout */ + if (mstp_port->SilenceTimer > Tframe_abort) { + /* indicate that an error has occurred during the reception of a frame */ + mstp_port->ReceivedInvalidFrame = true; + /* wait for the start of the next frame. */ + mstp_port->receive_state = MSTP_RECEIVE_STATE_IDLE; + } + /* Error */ + else if (mstp_port->ReceiveError == true) { + mstp_port->ReceiveError = false; + mstp_port->SilenceTimer = 0; + /* indicate that an error has occurred during the reception of a frame */ + mstp_port->ReceivedInvalidFrame = true; + /* wait for the start of the next frame. */ + mstp_port->receive_state = MSTP_RECEIVE_STATE_IDLE; + } else if (mstp_port->DataAvailable == true) { +#if PRINT_ENABLED_RECEIVE_DATA + fprintf(stderr, "%02X ", mstp_port->DataRegister); +#endif + /* DataOctet */ + if (mstp_port->Index < mstp_port->DataLength) { + mstp_port->DataCRC = + CRC_Calc_Data(mstp_port->DataRegister, + mstp_port->DataCRC); + mstp_port->InputBuffer[mstp_port->Index] = + mstp_port->DataRegister; + mstp_port->Index++; + mstp_port->receive_state = MSTP_RECEIVE_STATE_DATA; + } + /* CRC1 */ + else if (mstp_port->Index == mstp_port->DataLength) { + mstp_port->DataCRC = + CRC_Calc_Data(mstp_port->DataRegister, + mstp_port->DataCRC); + mstp_port->Index++; + mstp_port->receive_state = MSTP_RECEIVE_STATE_DATA; + } + /* CRC2 */ + else if (mstp_port->Index == (mstp_port->DataLength + 1)) { + mstp_port->DataCRC = + CRC_Calc_Data(mstp_port->DataRegister, + mstp_port->DataCRC); + /* STATE DATA CRC - no need for new state */ + /* indicate the complete reception of a valid frame */ + if (mstp_port->DataCRC == 0xF0B8) + mstp_port->ReceivedValidFrame = true; + else + mstp_port->ReceivedInvalidFrame = true; + mstp_port->receive_state = MSTP_RECEIVE_STATE_IDLE; + } + mstp_port->DataAvailable = false; + mstp_port->SilenceTimer = 0; + } + break; + default: + /* shouldn't get here - but if we do... */ + mstp_port->receive_state = MSTP_RECEIVE_STATE_IDLE; + break; + } +#if PRINT_ENABLED_RECEIVE_DATA + if ((receive_state != MSTP_RECEIVE_STATE_IDLE) && + (mstp_port->receive_state == MSTP_RECEIVE_STATE_IDLE)) { + fprintf(stderr, "\n"); + fflush(stderr); + } + receive_state = mstp_port->receive_state; +#endif + + return; +} + +static bool mstp_compare_data_expecting_reply( + uint8_t * request_pdu, + uint16_t request_pdu_len, + uint8_t src_address, + uint8_t * reply_pdu, + uint16_t reply_pdu_len, + uint8_t dest_address) +{ + uint16_t offset; + /* One way to check the message is to compare NPDU + src, dest, along with the APDU type, invoke id. + Seems a bit overkill */ + struct DER_compare_t { + BACNET_NPDU_DATA npdu_data; + BACNET_ADDRESS address; + uint8_t pdu_type; + uint8_t invoke_id; + uint8_t service_choice; + }; + struct DER_compare_t request; + struct DER_compare_t reply; + + /* decode the request data */ + request.address.mac[0] = src_address; + request.address.mac_len = 1; + offset = + npdu_decode(&request_pdu[0], NULL, &request.address, + &request.npdu_data); + if (request.npdu_data.network_layer_message) { + return false; + } + request.pdu_type = request_pdu[offset] & 0xF0; + if (request.pdu_type != PDU_TYPE_CONFIRMED_SERVICE_REQUEST) { + return false; + } + request.invoke_id = request_pdu[offset + 2]; + /* segmented message? */ + if (request_pdu[offset] & BIT3) + request.service_choice = request_pdu[offset + 5]; + else + request.service_choice = request_pdu[offset + 3]; + /* decode the reply data */ + reply.address.mac[0] = dest_address; + reply.address.mac_len = 1; + offset = + npdu_decode(&reply_pdu[0], &reply.address, NULL, &reply.npdu_data); + if (reply.npdu_data.network_layer_message) { + return false; + } + /* reply could be a lot of things: + confirmed, simple ack, abort, reject, error */ + reply.pdu_type = reply_pdu[offset] & 0xF0; + switch (reply.pdu_type) { + case PDU_TYPE_CONFIRMED_SERVICE_REQUEST: + reply.invoke_id = reply_pdu[offset + 2]; + /* segmented message? */ + if (reply_pdu[offset] & BIT3) + reply.service_choice = reply_pdu[offset + 5]; + else + reply.service_choice = reply_pdu[offset + 3]; + break; + case PDU_TYPE_SIMPLE_ACK: + reply.invoke_id = reply_pdu[offset + 1]; + reply.service_choice = reply_pdu[offset + 2]; + break; + case PDU_TYPE_COMPLEX_ACK: + reply.invoke_id = reply_pdu[offset + 1]; + /* segmented message? */ + if (reply_pdu[offset] & BIT3) + reply.service_choice = reply_pdu[offset + 4]; + else + reply.service_choice = reply_pdu[offset + 2]; + break; + case PDU_TYPE_ERROR: + reply.invoke_id = reply_pdu[offset + 1]; + reply.service_choice = reply_pdu[offset + 2]; + break; + case PDU_TYPE_REJECT: + case PDU_TYPE_ABORT: + reply.invoke_id = reply_pdu[offset + 1]; + break; + default: + return false; + } + if (request.invoke_id != reply.invoke_id) { + return false; + } + /* these services don't have service choice included */ + if ((reply.pdu_type != PDU_TYPE_REJECT) && + (reply.pdu_type != PDU_TYPE_ABORT)) { + if (request.service_choice != reply.service_choice) { + return false; + } + } + if (request.npdu_data.protocol_version != reply.npdu_data.protocol_version) { + return false; + } +#if 0 + /* the NDPU priority doesn't get passed through the stack, and + all outgoing messages have NORMAL priority */ + if (request.npdu_data.priority != reply.npdu_data.priority) { + return false; + } +#endif + if (!bacnet_address_same(&request.address, &reply.address)) { + return false; + } + + return true; +} + +/* returns true if we need to transition immediately */ +bool MSTP_Master_Node_FSM( + volatile struct mstp_port_struct_t * mstp_port) +{ + int mtu_len = 0; + int frame_type = 0; + uint8_t next_poll_station = 0; + uint8_t next_this_station = 0; + uint8_t next_next_station = 0; + uint16_t my_timeout = 10, ns_timeout = 0; + /* transition immediately to the next state */ + bool transition_now = false; + bool matched = false; +#if PRINT_ENABLED_MASTER + static MSTP_MASTER_STATE master_state = MSTP_MASTER_STATE_INITIALIZE; +#endif + + /* some calculations that several states need */ + next_poll_station = + (mstp_port->Poll_Station + 1) % (mstp_port->Nmax_master + 1); + next_this_station = + (mstp_port->This_Station + 1) % (mstp_port->Nmax_master + 1); + next_next_station = + (mstp_port->Next_Station + 1) % (mstp_port->Nmax_master + 1); +#if PRINT_ENABLED_MASTER + if (mstp_port->master_state != master_state) { + master_state = mstp_port->master_state; + fprintf(stderr, + "MSTP: TS=%02X[%02X] NS=%02X[%02X] PS=%02X[%02X] EC=%u TC=%u ST=%u %s\n", + mstp_port->This_Station, next_this_station, + mstp_port->Next_Station, next_next_station, + mstp_port->Poll_Station, next_poll_station, mstp_port->EventCount, + mstp_port->TokenCount, mstp_port->SilenceTimer, + mstptext_master_state(mstp_port->master_state)); + } +#endif + + switch (mstp_port->master_state) { + case MSTP_MASTER_STATE_INITIALIZE: + /* DoneInitializing */ + /* indicate that the next station is unknown */ + mstp_port->Next_Station = mstp_port->This_Station; + mstp_port->Poll_Station = mstp_port->This_Station; + /* cause a Poll For Master to be sent when this node first */ + /* receives the token */ + mstp_port->TokenCount = Npoll; + mstp_port->SoleMaster = false; + mstp_port->master_state = MSTP_MASTER_STATE_IDLE; + transition_now = true; + break; + /* In the IDLE state, the node waits for a frame. */ + case MSTP_MASTER_STATE_IDLE: + /* LostToken */ + if (mstp_port->SilenceTimer >= Tno_token) { + /* assume that the token has been lost */ + mstp_port->EventCount = 0; /* Addendum 135-2004d-8 */ + mstp_port->master_state = MSTP_MASTER_STATE_NO_TOKEN; + /* set the receive frame flags to false in case we received + some bytes and had a timeout for some reason */ + mstp_port->ReceivedInvalidFrame = false; + mstp_port->ReceivedValidFrame = false; + transition_now = true; + } + /* ReceivedInvalidFrame */ + else if (mstp_port->ReceivedInvalidFrame == true) { + /* invalid frame was received */ + mstp_port->ReceivedInvalidFrame = false; + /* wait for the next frame - remain in IDLE */ + } else if (mstp_port->ReceivedValidFrame == true) { +#if PRINT_ENABLED_MASTER + fprintf(stderr, + "MSTP: ReceivedValidFrame Src=%02X Dest=%02X DataLen=%u FC=%u ST=%u Type=%s\n", + mstp_port->SourceAddress, mstp_port->DestinationAddress, + mstp_port->DataLength, mstp_port->FrameCount, + mstp_port->SilenceTimer, + mstptext_frame_type(mstp_port->FrameType)); +#endif + /* destined for me! */ + if ((mstp_port->DestinationAddress == mstp_port->This_Station) + || (mstp_port->DestinationAddress == + MSTP_BROADCAST_ADDRESS)) { + switch (mstp_port->FrameType) { + /* ReceivedToken */ + case FRAME_TYPE_TOKEN: + /* tokens can't be broadcast */ + if (mstp_port->DestinationAddress == + MSTP_BROADCAST_ADDRESS) + break; + mstp_port->ReceivedValidFrame = false; + mstp_port->FrameCount = 0; + mstp_port->SoleMaster = false; + mstp_port->master_state = + MSTP_MASTER_STATE_USE_TOKEN; + transition_now = true; + break; + /* ReceivedPFM */ + case FRAME_TYPE_POLL_FOR_MASTER: + MSTP_Create_And_Send_Frame(mstp_port, + FRAME_TYPE_REPLY_TO_POLL_FOR_MASTER, + mstp_port->SourceAddress, + mstp_port->This_Station, NULL, 0); + break; + case FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY: + /* indicate successful reception to the higher layers */ + dlmstp_put_receive(mstp_port->SourceAddress, + (uint8_t *) & mstp_port->InputBuffer[0], + mstp_port->DataLength); + break; + case FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY: + /*mstp_port->ReplyPostponedTimer = 0; */ + /* indicate successful reception to the higher layers */ + dlmstp_put_receive(mstp_port->SourceAddress, + (uint8_t *) & mstp_port->InputBuffer[0], + mstp_port->DataLength); + /* broadcast DER just remains IDLE */ + if (mstp_port->DestinationAddress != + MSTP_BROADCAST_ADDRESS) { + mstp_port->master_state = + MSTP_MASTER_STATE_ANSWER_DATA_REQUEST; + } + break; + case FRAME_TYPE_TEST_REQUEST: + MSTP_Create_And_Send_Frame(mstp_port, + FRAME_TYPE_TEST_RESPONSE, + mstp_port->SourceAddress, + mstp_port->This_Station, + (uint8_t *) & mstp_port->InputBuffer[0], + mstp_port->DataLength); + break; + case FRAME_TYPE_TEST_RESPONSE: + default: + break; + } + } + mstp_port->ReceivedValidFrame = false; + } + break; + /* In the USE_TOKEN state, the node is allowed to send one or */ + /* more data frames. These may be BACnet Data frames or */ + /* proprietary frames. */ + case MSTP_MASTER_STATE_USE_TOKEN: + if (!mstp_port->TxReady) { + /* NothingToSend */ + mstp_port->FrameCount = mstp_port->Nmax_info_frames; + mstp_port->master_state = MSTP_MASTER_STATE_DONE_WITH_TOKEN; + transition_now = true; + } else { + uint8_t destination = mstp_port->TxBuffer[3]; + RS485_Send_Frame(mstp_port, + (uint8_t *) & mstp_port->TxBuffer[0], mstp_port->TxLength); + mstp_port->FrameCount++; + switch (mstp_port->TxFrameType) { + case FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY: + /* SendAndWait */ + if (destination == MSTP_BROADCAST_ADDRESS) + mstp_port->master_state = + MSTP_MASTER_STATE_DONE_WITH_TOKEN; + else + mstp_port->master_state = + MSTP_MASTER_STATE_WAIT_FOR_REPLY; + break; + case FRAME_TYPE_TEST_REQUEST: + mstp_port->master_state = + MSTP_MASTER_STATE_WAIT_FOR_REPLY; + break; + case FRAME_TYPE_TEST_RESPONSE: + case FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY: + default: + /* SendNoWait */ + mstp_port->master_state = + MSTP_MASTER_STATE_DONE_WITH_TOKEN; + break; + } + mstp_port->TxReady = false; + } + break; + /* In the WAIT_FOR_REPLY state, the node waits for */ + /* a reply from another node. */ + case MSTP_MASTER_STATE_WAIT_FOR_REPLY: + if (mstp_port->SilenceTimer >= Treply_timeout) { + /* ReplyTimeout */ + /* assume that the request has failed */ + mstp_port->FrameCount = mstp_port->Nmax_info_frames; + mstp_port->master_state = MSTP_MASTER_STATE_DONE_WITH_TOKEN; + /* Any retry of the data frame shall await the next entry */ + /* to the USE_TOKEN state. (Because of the length of the timeout, */ + /* this transition will cause the token to be passed regardless */ + /* of the initial value of FrameCount.) */ + transition_now = true; + } else { + if (mstp_port->ReceivedInvalidFrame == true) { + /* InvalidFrame */ + /* error in frame reception */ + mstp_port->ReceivedInvalidFrame = false; + mstp_port->master_state = + MSTP_MASTER_STATE_DONE_WITH_TOKEN; + transition_now = true; + } else if (mstp_port->ReceivedValidFrame == true) { + if (mstp_port->DestinationAddress == + mstp_port->This_Station) { + switch (mstp_port->FrameType) { + case FRAME_TYPE_REPLY_POSTPONED: + /* ReceivedReplyPostponed */ + mstp_port->master_state = + MSTP_MASTER_STATE_DONE_WITH_TOKEN; + break; + case FRAME_TYPE_TEST_RESPONSE: + mstp_port->master_state = + MSTP_MASTER_STATE_IDLE; + break; + case FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY: + /* ReceivedReply */ + /* or a proprietary type that indicates a reply */ + /* indicate successful reception to the higher layers */ + dlmstp_put_receive(mstp_port->SourceAddress, /* source MS/TP address */ + (uint8_t *) & mstp_port->InputBuffer[0], + mstp_port->DataLength); + mstp_port->master_state = + MSTP_MASTER_STATE_DONE_WITH_TOKEN; + break; + default: + /* if proprietary frame was expected, you might + need to transition to DONE WITH TOKEN */ + mstp_port->master_state = + MSTP_MASTER_STATE_IDLE; + break; + } + } else { + /* ReceivedUnexpectedFrame */ + /* an unexpected frame was received */ + /* This may indicate the presence of multiple tokens. */ + /* Synchronize with the network. */ + /* This action drops the token. */ + mstp_port->master_state = MSTP_MASTER_STATE_IDLE; + } + mstp_port->ReceivedValidFrame = false; + transition_now = true; + } + } + break; + /* The DONE_WITH_TOKEN state either sends another data frame, */ + /* passes the token, or initiates a Poll For Master cycle. */ + case MSTP_MASTER_STATE_DONE_WITH_TOKEN: + /* SendAnotherFrame */ + if (mstp_port->FrameCount < mstp_port->Nmax_info_frames) { + /* then this node may send another information frame */ + /* before passing the token. */ + mstp_port->master_state = MSTP_MASTER_STATE_USE_TOKEN; + transition_now = true; + } else if ((mstp_port->SoleMaster == false) && + (mstp_port->Next_Station == mstp_port->This_Station)) { + /* NextStationUnknown - added in Addendum 135-2008v-1 */ + /* then the next station to which the token + should be sent is unknown - so PollForMaster */ + mstp_port->Poll_Station = next_this_station; + MSTP_Create_And_Send_Frame(mstp_port, + FRAME_TYPE_POLL_FOR_MASTER, mstp_port->Poll_Station, + mstp_port->This_Station, NULL, 0); + mstp_port->RetryCount = 0; + mstp_port->master_state = MSTP_MASTER_STATE_POLL_FOR_MASTER; + } + /* Npoll changed in Errata SSPC-135-2004 */ + else if (mstp_port->TokenCount < (Npoll - 1)) { + if ((mstp_port->SoleMaster == true) && + (mstp_port->Next_Station != next_this_station)) { + /* SoleMaster */ + /* there are no other known master nodes to */ + /* which the token may be sent (true master-slave operation). */ + mstp_port->FrameCount = 0; + mstp_port->TokenCount++; + mstp_port->master_state = MSTP_MASTER_STATE_USE_TOKEN; + transition_now = true; + } else { + /* SendToken */ + /* Npoll changed in Errata SSPC-135-2004 */ + /* The comparison of NS and TS+1 eliminates the Poll For Master */ + /* if there are no addresses between TS and NS, since there is no */ + /* address at which a new master node may be found in that case. */ + mstp_port->TokenCount++; + /* transmit a Token frame to NS */ + MSTP_Create_And_Send_Frame(mstp_port, FRAME_TYPE_TOKEN, + mstp_port->Next_Station, mstp_port->This_Station, NULL, + 0); + mstp_port->RetryCount = 0; + mstp_port->EventCount = 0; + mstp_port->master_state = MSTP_MASTER_STATE_PASS_TOKEN; + } + } else if (next_poll_station == mstp_port->Next_Station) { + if (mstp_port->SoleMaster == true) { + /* SoleMasterRestartMaintenancePFM */ + mstp_port->Poll_Station = next_next_station; + MSTP_Create_And_Send_Frame(mstp_port, + FRAME_TYPE_POLL_FOR_MASTER, mstp_port->Poll_Station, + mstp_port->This_Station, NULL, 0); + /* no known successor node */ + mstp_port->Next_Station = mstp_port->This_Station; + mstp_port->RetryCount = 0; + mstp_port->TokenCount = 1; /* changed in Errata SSPC-135-2004 */ + /* mstp_port->EventCount = 0; removed in Addendum 135-2004d-8 */ + /* find a new successor to TS */ + mstp_port->master_state = + MSTP_MASTER_STATE_POLL_FOR_MASTER; + } else { + /* ResetMaintenancePFM */ + mstp_port->Poll_Station = mstp_port->This_Station; + /* transmit a Token frame to NS */ + MSTP_Create_And_Send_Frame(mstp_port, FRAME_TYPE_TOKEN, + mstp_port->Next_Station, mstp_port->This_Station, NULL, + 0); + mstp_port->RetryCount = 0; + mstp_port->TokenCount = 1; /* changed in Errata SSPC-135-2004 */ + mstp_port->EventCount = 0; + mstp_port->master_state = MSTP_MASTER_STATE_PASS_TOKEN; + } + } else { + /* SendMaintenancePFM */ + mstp_port->Poll_Station = next_poll_station; + MSTP_Create_And_Send_Frame(mstp_port, + FRAME_TYPE_POLL_FOR_MASTER, mstp_port->Poll_Station, + mstp_port->This_Station, NULL, 0); + mstp_port->RetryCount = 0; + mstp_port->master_state = MSTP_MASTER_STATE_POLL_FOR_MASTER; + } + break; + /* The PASS_TOKEN state listens for a successor to begin using */ + /* the token that this node has just attempted to pass. */ + case MSTP_MASTER_STATE_PASS_TOKEN: + if (mstp_port->SilenceTimer < Tusage_timeout) { + if (mstp_port->EventCount > Nmin_octets) { + /* SawTokenUser */ + /* Assume that a frame has been sent by the new token user. */ + /* Enter the IDLE state to process the frame. */ + mstp_port->master_state = MSTP_MASTER_STATE_IDLE; + transition_now = true; + } + } else { + if (mstp_port->RetryCount < Nretry_token) { + /* RetrySendToken */ + mstp_port->RetryCount++; + /* Transmit a Token frame to NS */ + MSTP_Create_And_Send_Frame(mstp_port, FRAME_TYPE_TOKEN, + mstp_port->Next_Station, mstp_port->This_Station, NULL, + 0); + mstp_port->EventCount = 0; + /* re-enter the current state to listen for NS */ + /* to begin using the token. */ + } else { + /* FindNewSuccessor */ + /* Assume that NS has failed. */ + /* note: if NS=TS-1, this node could send PFM to self! */ + mstp_port->Poll_Station = next_next_station; + /* Transmit a Poll For Master frame to PS. */ + MSTP_Create_And_Send_Frame(mstp_port, + FRAME_TYPE_POLL_FOR_MASTER, mstp_port->Poll_Station, + mstp_port->This_Station, NULL, 0); + /* no known successor node */ + mstp_port->Next_Station = mstp_port->This_Station; + mstp_port->RetryCount = 0; + mstp_port->TokenCount = 0; + /* mstp_port->EventCount = 0; removed in Addendum 135-2004d-8 */ + /* find a new successor to TS */ + mstp_port->master_state = + MSTP_MASTER_STATE_POLL_FOR_MASTER; + } + } + break; + /* The NO_TOKEN state is entered if mstp_port->SilenceTimer becomes greater */ + /* than Tno_token, indicating that there has been no network activity */ + /* for that period of time. The timeout is continued to determine */ + /* whether or not this node may create a token. */ + case MSTP_MASTER_STATE_NO_TOKEN: + my_timeout = Tno_token + (Tslot * mstp_port->This_Station); + if (mstp_port->SilenceTimer < my_timeout) { + if (mstp_port->EventCount > Nmin_octets) { + /* SawFrame */ + /* Some other node exists at a lower address. */ + /* Enter the IDLE state to receive and process the incoming frame. */ + mstp_port->master_state = MSTP_MASTER_STATE_IDLE; + transition_now = true; + } + } else { + ns_timeout = + Tno_token + (Tslot * (mstp_port->This_Station + 1)); + if (mstp_port->SilenceTimer < ns_timeout) { + /* GenerateToken */ + /* Assume that this node is the lowest numerical address */ + /* on the network and is empowered to create a token. */ + mstp_port->Poll_Station = next_this_station; + /* Transmit a Poll For Master frame to PS. */ + MSTP_Create_And_Send_Frame(mstp_port, + FRAME_TYPE_POLL_FOR_MASTER, mstp_port->Poll_Station, + mstp_port->This_Station, NULL, 0); + /* indicate that the next station is unknown */ + mstp_port->Next_Station = mstp_port->This_Station; + mstp_port->RetryCount = 0; + mstp_port->TokenCount = 0; + /* mstp_port->EventCount = 0; removed Addendum 135-2004d-8 */ + /* enter the POLL_FOR_MASTER state to find a new successor to TS. */ + mstp_port->master_state = + MSTP_MASTER_STATE_POLL_FOR_MASTER; + } + } + break; + /* In the POLL_FOR_MASTER state, the node listens for a reply to */ + /* a previously sent Poll For Master frame in order to find */ + /* a successor node. */ + case MSTP_MASTER_STATE_POLL_FOR_MASTER: + if (mstp_port->ReceivedValidFrame == true) { + if ((mstp_port->DestinationAddress == mstp_port->This_Station) + && (mstp_port->FrameType == + FRAME_TYPE_REPLY_TO_POLL_FOR_MASTER)) { + /* ReceivedReplyToPFM */ + mstp_port->SoleMaster = false; + mstp_port->Next_Station = mstp_port->SourceAddress; + mstp_port->EventCount = 0; + /* Transmit a Token frame to NS */ + MSTP_Create_And_Send_Frame(mstp_port, FRAME_TYPE_TOKEN, + mstp_port->Next_Station, mstp_port->This_Station, NULL, + 0); + mstp_port->Poll_Station = mstp_port->This_Station; + mstp_port->TokenCount = 0; + mstp_port->RetryCount = 0; + mstp_port->master_state = MSTP_MASTER_STATE_PASS_TOKEN; + } else { + /* ReceivedUnexpectedFrame */ + /* An unexpected frame was received. */ + /* This may indicate the presence of multiple tokens. */ + /* enter the IDLE state to synchronize with the network. */ + /* This action drops the token. */ + mstp_port->master_state = MSTP_MASTER_STATE_IDLE; + transition_now = true; + } + mstp_port->ReceivedValidFrame = false; + } else if ((mstp_port->SilenceTimer >= Tusage_timeout) || + (mstp_port->ReceivedInvalidFrame == true)) { + if (mstp_port->SoleMaster == true) { + /* SoleMaster */ + /* There was no valid reply to the periodic poll */ + /* by the sole known master for other masters. */ + mstp_port->FrameCount = 0; + /* mstp_port->TokenCount++; removed in 2004 */ + mstp_port->master_state = MSTP_MASTER_STATE_USE_TOKEN; + transition_now = true; + } else { + if (mstp_port->Next_Station != mstp_port->This_Station) { + /* DoneWithPFM */ + /* There was no valid reply to the maintenance */ + /* poll for a master at address PS. */ + mstp_port->EventCount = 0; + /* transmit a Token frame to NS */ + MSTP_Create_And_Send_Frame(mstp_port, FRAME_TYPE_TOKEN, + mstp_port->Next_Station, mstp_port->This_Station, + NULL, 0); + mstp_port->RetryCount = 0; + mstp_port->master_state = MSTP_MASTER_STATE_PASS_TOKEN; + } else { + if (next_poll_station != mstp_port->This_Station) { + /* SendNextPFM */ + mstp_port->Poll_Station = next_poll_station; + /* Transmit a Poll For Master frame to PS. */ + MSTP_Create_And_Send_Frame(mstp_port, + FRAME_TYPE_POLL_FOR_MASTER, + mstp_port->Poll_Station, + mstp_port->This_Station, NULL, 0); + mstp_port->RetryCount = 0; + /* Re-enter the current state. */ + } else { + /* DeclareSoleMaster */ + /* to indicate that this station is the only master */ + mstp_port->SoleMaster = true; + mstp_port->FrameCount = 0; + mstp_port->master_state = + MSTP_MASTER_STATE_USE_TOKEN; + transition_now = true; + } + } + } + mstp_port->ReceivedInvalidFrame = false; + } + break; + /* The ANSWER_DATA_REQUEST state is entered when a */ + /* BACnet Data Expecting Reply, a Test_Request, or */ + /* a proprietary frame that expects a reply is received. */ + case MSTP_MASTER_STATE_ANSWER_DATA_REQUEST: + if (mstp_port->TxReady) { + /* Compare the APDU type received and + see if the message is that same APDU type + along with the matching src/dest and invoke ID */ + matched = + mstp_compare_data_expecting_reply(&mstp_port->InputBuffer + [0], mstp_port->DataLength, mstp_port->SourceAddress, + &mstp_port->TxBuffer[8], mstp_port->TxLength, + mstp_port->TxDestination); + } + if (matched && mstp_port->TxReady) { + /* Reply */ + /* If a reply is available from the higher layers */ + /* within Treply_delay after the reception of the */ + /* final octet of the requesting frame */ + /* (the mechanism used to determine this is a local matter), */ + /* then call MSTP_Create_And_Send_Frame to transmit the reply frame */ + /* and enter the IDLE state to wait for the next frame. */ + RS485_Send_Frame(mstp_port, + (uint8_t *) & mstp_port->TxBuffer[0], mstp_port->TxLength); + mstp_port->TxReady = false; + mstp_port->master_state = MSTP_MASTER_STATE_IDLE; + } else if (mstp_port->SilenceTimer > Treply_delay) { + /* DeferredReply */ + /* If no reply will be available from the higher layers */ + /* within Treply_delay after the reception of the */ + /* final octet of the requesting frame (the mechanism */ + /* used to determine this is a local matter), */ + /* then an immediate reply is not possible. */ + /* Any reply shall wait until this node receives the token. */ + /* Call MSTP_Create_And_Send_Frame to transmit a */ + /* Reply Postponed frame, and enter the IDLE state. */ + MSTP_Create_And_Send_Frame(mstp_port, + FRAME_TYPE_REPLY_POSTPONED, mstp_port->SourceAddress, + mstp_port->This_Station, NULL, 0); + mstp_port->master_state = MSTP_MASTER_STATE_IDLE; + } + break; + default: + mstp_port->master_state = MSTP_MASTER_STATE_IDLE; + break; + } + + return transition_now; +} + +/* note: This_Station should be set with the MAC address */ +/* note: Nmax_info_frames should be set */ +/* note: Nmax_master should be set */ +void MSTP_Init( + volatile struct mstp_port_struct_t *mstp_port) +{ + int i; /*loop counter */ + + if (mstp_port) { + mstp_port->receive_state = MSTP_RECEIVE_STATE_IDLE; + mstp_port->master_state = MSTP_MASTER_STATE_INITIALIZE; + mstp_port->ReceiveError = false; + mstp_port->DataAvailable = false; + mstp_port->DataRegister = 0; + mstp_port->DataCRC = 0; + mstp_port->DataCRC = 0; + mstp_port->DataLength = 0; + mstp_port->DestinationAddress = 0; + mstp_port->EventCount = 0; + mstp_port->FrameType = FRAME_TYPE_TOKEN; + mstp_port->FrameCount = 0; + mstp_port->HeaderCRC = 0; + mstp_port->Index = 0; + mstp_port->Index = 0; + for (i = 0; i < sizeof(mstp_port->InputBuffer); i++) { + mstp_port->InputBuffer[i] = 0; + } + mstp_port->Next_Station = mstp_port->This_Station; + mstp_port->Poll_Station = mstp_port->This_Station; + mstp_port->ReceivedInvalidFrame = false; + mstp_port->ReceivedValidFrame = false; + mstp_port->RetryCount = 0; + mstp_port->SilenceTimer = 0; +/* mstp_port->ReplyPostponedTimer = 0; */ + mstp_port->SoleMaster = false; + mstp_port->SourceAddress = 0; + mstp_port->TokenCount = 0; +#if 0 + /* these are adjustable, so should already be set */ + mstp_port->Nmax_info_frames = DEFAULT_MAX_INFO_FRAMES; + mstp_port->Nmax_master = DEFAULT_MAX_MASTER; +#endif + + /* An array of octets, used to store PDU octets prior to being transmitted. */ + /* This array is only used for APDU messages */ + for (i = 0; i < sizeof(mstp_port->TxBuffer); i++) { + mstp_port->TxBuffer[i] = 0; + } + mstp_port->TxLength = 0; + mstp_port->TxReady = false; + mstp_port->TxFrameType = 0; + + } +} diff --git a/bacnet-stack/ports/pic18f97j60/mstp.h b/bacnet-stack/ports/pic18f97j60/mstp.h new file mode 100644 index 00000000..b473ef43 --- /dev/null +++ b/bacnet-stack/ports/pic18f97j60/mstp.h @@ -0,0 +1,188 @@ +/*####COPYRIGHTBEGIN#### + ------------------------------------------- + Copyright (C) 2004 Steve Karg + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to: + The Free Software Foundation, Inc. + 59 Temple Place - Suite 330 + Boston, MA 02111-1307 + USA. + + As a special exception, if other files instantiate templates or + use macros or inline functions from this file, or you compile + this file and link it with other works to produce a work based + on this file, this file does not by itself cause the resulting + work to be covered by the GNU General Public License. However + the source code for this file must still be made available in + accordance with section (3) of the GNU General Public License. + + This exception does not invalidate any other reasons why a work + based on this file might be covered by the GNU General Public + License. + ------------------------------------------- +####COPYRIGHTEND####*/ + +#ifndef MSTP_H +#define MSTP_H + +#include +#include +#include +#include "bacdef.h" +#include "mstpdef.h" +#include "dlmstp.h" + +struct mstp_port_struct_t { + MSTP_RECEIVE_STATE receive_state; + /* When a master node is powered up or reset, */ + /* it shall unconditionally enter the INITIALIZE state. */ + MSTP_MASTER_STATE master_state; + /* A Boolean flag set to TRUE by the Receive State Machine */ + /* if an error is detected during the reception of a frame. */ + /* Set to FALSE by the main state machine. */ + unsigned ReceiveError:1; + /* There is data in the buffer */ + unsigned DataAvailable:1; + unsigned ReceivedInvalidFrame:1; + /* A Boolean flag set to TRUE by the Receive State Machine */ + /* if a valid frame is received. */ + /* Set to FALSE by the main state machine. */ + unsigned ReceivedValidFrame:1; + /* A Boolean flag set to TRUE by the master machine if this node is the */ + /* only known master node. */ + unsigned SoleMaster:1; + /* stores the latest received data */ + uint8_t DataRegister; + /* Used to accumulate the CRC on the data field of a frame. */ + uint16_t DataCRC; + /* Used to store the data length of a received frame. */ + unsigned DataLength; + /* Used to store the destination address of a received frame. */ + uint8_t DestinationAddress; + /* Used to count the number of received octets or errors. */ + /* This is used in the detection of link activity. */ + /* Compared to Nmin_octets */ + uint8_t EventCount; + /* Used to store the frame type of a received frame. */ + uint8_t FrameType; + /* The number of frames sent by this node during a single token hold. */ + /* When this counter reaches the value Nmax_info_frames, the node must */ + /* pass the token. */ + unsigned FrameCount; + /* Used to accumulate the CRC on the header of a frame. */ + uint8_t HeaderCRC; + /* Used as an index by the Receive State Machine, up to a maximum value of */ + /* InputBufferSize. */ + unsigned Index; + /* An array of octets, used to store octets as they are received. */ + /* InputBuffer is indexed from 0 to InputBufferSize-1. */ + /* The maximum size of a frame is 501 octets. */ + uint8_t *InputBuffer; + /* "Next Station," the MAC address of the node to which This Station passes */ + /* the token. If the Next_Station is unknown, Next_Station shall be equal to */ + /* This_Station. */ + uint8_t Next_Station; + /* "Poll Station," the MAC address of the node to which This Station last */ + /* sent a Poll For Master. This is used during token maintenance. */ + uint8_t Poll_Station; + /* A counter of transmission retries used for Token and Poll For Master */ + /* transmission. */ + unsigned RetryCount; + /* A timer with nominal 5 millisecond resolution used to measure and */ + /* generate silence on the medium between octets. It is incremented by a */ + /* timer process and is cleared by the Receive State Machine when activity */ + /* is detected and by the SendFrame procedure as each octet is transmitted. */ + /* Since the timer resolution is limited and the timer is not necessarily */ + /* synchronized to other machine events, a timer value of N will actually */ + /* denote intervals between N-1 and N */ + uint16_t SilenceTimer; + + /* A timer used to measure and generate Reply Postponed frames. It is */ + /* incremented by a timer process and is cleared by the Master Node State */ + /* Machine when a Data Expecting Reply Answer activity is completed. */ +/* note: we always send a reply postponed since a message other than + the reply may be in the transmit queue */ +/* uint16_t ReplyPostponedTimer; */ + + /* Used to store the Source Address of a received frame. */ + uint8_t SourceAddress; + + /* The number of tokens received by this node. When this counter reaches the */ + /* value Npoll, the node polls the address range between TS and NS for */ + /* additional master nodes. TokenCount is set to zero at the end of the */ + /* polling process. */ + unsigned TokenCount; + + /* "This Station," the MAC address of this node. TS is generally read from a */ + /* hardware DIP switch, or from nonvolatile memory. Valid values for TS are */ + /* 0 to 254. The value 255 is used to denote broadcast when used as a */ + /* destination address but is not allowed as a value for TS. */ + uint8_t This_Station; + + /* This parameter represents the value of the Max_Info_Frames property of */ + /* the node's Device object. The value of Max_Info_Frames specifies the */ + /* maximum number of information frames the node may send before it must */ + /* pass the token. Max_Info_Frames may have different values on different */ + /* nodes. This may be used to allocate more or less of the available link */ + /* bandwidth to particular nodes. If Max_Info_Frames is not writable in a */ + /* node, its value shall be 1. */ + unsigned Nmax_info_frames; + + /* This parameter represents the value of the Max_Master property of the */ + /* node's Device object. The value of Max_Master specifies the highest */ + /* allowable address for master nodes. The value of Max_Master shall be */ + /* less than or equal to 127. If Max_Master is not writable in a node, */ + /* its value shall be 127. */ + unsigned Nmax_master; + + /* An array of octets, used to store PDU octets prior to being transmitted. */ + /* This array is only used for APDU messages */ + uint8_t TxBuffer[MAX_MPDU]; + unsigned TxLength; + uint8_t TxDestination; + bool TxReady; /* true if ready to be sent or received */ + uint8_t TxFrameType; /* type of message - needed by MS/TP */ +}; + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + void MSTP_Init( + volatile struct mstp_port_struct_t *mstp_port); + void MSTP_Receive_Frame_FSM( + volatile struct mstp_port_struct_t + *mstp_port); + bool MSTP_Master_Node_FSM( + volatile struct mstp_port_struct_t + *mstp_port); + + /* returns true if line is active */ + bool MSTP_Line_Active( + volatile struct mstp_port_struct_t *mstp_port); + + unsigned MSTP_Create_Frame( + uint8_t * buffer, /* where frame is loaded */ + unsigned buffer_len, /* amount of space available */ + uint8_t frame_type, /* type of frame to send - see defines */ + uint8_t destination, /* destination address */ + uint8_t source, /* source address */ + uint8_t * data, /* any data to be sent - may be null */ + unsigned data_len); /* number of bytes of data (up to 501) */ + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ +#endif diff --git a/bacnet-stack/ports/pic18f97j60/readme.txt b/bacnet-stack/ports/pic18f97j60/readme.txt new file mode 100644 index 00000000..8692000e --- /dev/null +++ b/bacnet-stack/ports/pic18f97j60/readme.txt @@ -0,0 +1,44 @@ +BACnet Stack - SourceForge.net +Build for MPLAB IDE + +These are some settings that are important when building +the BACnet Stack using MPLAB IDE and MCC18 Compiler, + +1. Add the files to the project that you need: +abort.c, apdu.c, bacapp.c, bacdcode.c, bacerror.c, +bacstr.c, crc.c, datetime.c, dcc.c, iam.c, +npdu.c, rd.c, reject.c, rp.c, whois.c, wp.c + +From ports/picxx: isr.c, main.c, rs485.c, mstp.c, dlmstp.c + +From demo/object/: device.c or dev_tiny.c +objects as needed: ai.c, ao.c, etc. + +From demo/handler/: txbuf.c, h_dcc.c, h_rd.c, h_rp.c or h_rp_tiny.c +Additional handlers as needed: h_wp.c + +2. Project->Options->Project + +General Tab: Include Path: +C:\code\bacnet-stack\;C:\code\bacnet-stack\demo\handler\;C:\code\bacnet-stack\demo\object\;C:\code\bacnet-stack\ports\pic18f6720\ + +MPLAB C18 Tab: Memory Model: +Code: Large Code Model +Data: Large Data Model +Stack: Multi-bank Model + +MPLAB C18 Tab: General: Macro Definitions: +PRINT_ENABLED=0 +BACDL_MSTP=1 +TSM_ENABLED=0 +BIG_ENDIAN=0 + +3. The linker script must reserve some extra stack space. + +//DATABANK NAME=gpr12 START=0xC00 END=0xCFF +//DATABANK NAME=gpr13 START=0xD00 END=0xDFF +DATABANK NAME=stackreg START=0xC00 END=0xDFF PROTECTED + +//STACK SIZE=0x100 RAM=gpr13 +STACK SIZE=0x200 RAM=stackreg + diff --git a/bacnet-stack/ports/pic18f97j60/rs485.c b/bacnet-stack/ports/pic18f97j60/rs485.c new file mode 100644 index 00000000..f9113b71 --- /dev/null +++ b/bacnet-stack/ports/pic18f97j60/rs485.c @@ -0,0 +1,353 @@ +/************************************************************************** +* +* Copyright (C) 2005 Steve Karg +* +* 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. +* +*********************************************************************/ + +/* The module handles sending data out the RS-485 port */ +/* and handles receiving data from the RS-485 port. */ +/* Customize this file for your specific hardware */ +#include +#include +#include +#include +#include "hardware.h" +#include "mstp.h" +#include "rs485.h" +#include "fifo.h" + +/* public port info */ +extern volatile struct mstp_port_struct_t MSTP_Port; + +/* the baud rate is adjustable */ +uint32_t RS485_Baud_Rate = 38400; + +/* the FIFO structures for sending and receiving */ +FIFO_BUFFER FIFO_Rx; +FIFO_BUFFER FIFO_Tx; +#pragma udata MSTPPortData +/* the buffer for receiving data (size must be a power of 2) */ +volatile uint8_t RS485_Rx_Buffer[128]; +/* the buffer for sending data (size must be a power of 2) */ +volatile uint8_t RS485_Tx_Buffer[128]; +#pragma udata + +/**************************************************************************** +* DESCRIPTION: Transmits a frame using the UART +* RETURN: none +* ALGORITHM: none +* NOTES: none +*****************************************************************************/ +void RS485_Send_Frame( + volatile struct mstp_port_struct_t *mstp_port, /* port specific data */ + uint8_t * buffer, /* frame to send (up to 501 bytes of data) */ + uint16_t nbytes) +{ /* number of bytes of data (up to 501) */ + uint16_t i = 0; /* loop counter */ + uint8_t turnaround_time; + + if (!buffer) + return; + + while (!FIFO_Empty(&FIFO_Tx)) { + /* buffer is not empty. Wait for ISR to transmit. */ + }; + + /* wait 40 bit times since reception */ + if (RS485_Baud_Rate == 9600) + turnaround_time = 4; + else if (RS485_Baud_Rate == 19200) + turnaround_time = 2; + else + turnaround_time = 2; + + while (mstp_port->SilenceTimer < turnaround_time) { + /* The line has not been silent long enough, so wait. */ + }; + + if (FIFO_Add(&FIFO_Tx, buffer, nbytes)) { + /* disable the receiver */ + PIE3bits.RC2IE = 0; + RCSTA2bits.CREN = 0; + /* enable the transceiver */ + RS485_TX_ENABLE = 1; + RS485_RX_DISABLE = 1; + /* enable the transmitter */ + TXSTA2bits.TXEN = 1; + PIE3bits.TX2IE = 1; + /* reset the silence timer per MSTP spec, sort of */ + mstp_port->SilenceTimer = 0; + } + + return; +} + +/**************************************************************************** +* DESCRIPTION: Checks for data on the receive UART, and handles errors +* RETURN: none +* ALGORITHM: none +* NOTES: none +*****************************************************************************/ +bool RS485_Check_UART_Data( + volatile struct mstp_port_struct_t * mstp_port) +{ + /* check for data */ + if (!FIFO_Empty(&FIFO_Rx)) { + mstp_port->DataRegister = FIFO_Get(&FIFO_Rx); + mstp_port->DataAvailable = TRUE; + } + + return (!FIFO_Empty(&FIFO_Rx)); +} + +/* ************************************************************************* + DESCRIPTION: Receives RS485 data stream + + RETURN: none + + ALGORITHM: none + + NOTES: none + *************************************************************************** */ +void RS485_Interrupt_Rx( + void) +{ + uint8_t data_byte; + + if ((RCSTA2bits.FERR) || (RCSTA2bits.OERR)) { + /* Clear the error */ + RCSTA2bits.CREN = 0; + RCSTA2bits.CREN = 1; + /* FIXME: flag the MS/TP state machine on buffer overrun */ + data_byte = RCREG2; + } else { + data_byte = RCREG2; + FIFO_Put(&FIFO_Rx, data_byte); + } +} + +/* ************************************************************************* + DESCRIPTION: Transmits a byte using the UART out the RS485 port + + RETURN: none + + ALGORITHM: none + + NOTES: none + *************************************************************************** */ +void RS485_Interrupt_Tx( + void) +{ + if (!FIFO_Empty(&FIFO_Tx)) { + TXREG2 = FIFO_Get(&FIFO_Tx); + } else { + /* wait for the USART to be empty */ + while (!TXSTA2bits.TRMT); + /* disable this interrupt */ + PIE3bits.TX2IE = 0; + /* enable the receiver */ + RS485_TX_ENABLE = 0; + RS485_RX_DISABLE = 0; + /* enable the this interrupt */ + PIE3bits.RC2IE = 1; + RCSTA2bits.CREN = 1; + } +} + +/**************************************************************************** +* DESCRIPTION: Returns the baud rate that we are currently running at +* RETURN: none +* ALGORITHM: none +* NOTES: none +*****************************************************************************/ +uint32_t RS485_Get_Baud_Rate( + void) +{ + return RS485_Baud_Rate; +} + +/**************************************************************************** +* DESCRIPTION: Sets the baud rate for the chip USART +* RETURN: none +* ALGORITHM: none +* NOTES: none +*****************************************************************************/ +bool RS485_Set_Baud_Rate( + uint32_t baud) +{ + bool valid = true; + + switch (baud) { + case 9600: + case 19200: + case 38400: + case 57600: + case 76800: + case 115200: + RS485_Baud_Rate = baud; + break; + default: + valid = false; + break; + } + + if (valid) { + /* FIXME: store the baud rate */ + /* I2C_Write_Block( + EEPROM_DEVICE_ADDRESS, + (char *)&RS485_Baud_Rate, + sizeof(RS485_Baud_Rate), + EEPROM_MSTP_BAUD_RATE_ADDR); */ + } + + return valid; +} + +/**************************************************************************** +* DESCRIPTION: Initializes the RS485 hardware and variables, and starts in +* receive mode. +* RETURN: none +* ALGORITHM: none +* NOTES: none +*****************************************************************************/ +void RS485_Initialize_Port( + void) +{ + + /* Reset USART registers to POR state */ + TXSTA2 = 0; + RCSTA2 = 0; + /* configure USART for receiving */ + /* since the TX will handle setting up for transmit */ + RCSTA2bits.CREN = 1; + /* Interrupt on receipt */ + PIE3bits.RC2IE = 1; + /* enable the transmitter, disable its interrupt */ + TXSTA2bits.TXEN = 1; + PIE3bits.TX2IE = 0; + /* setup USART Baud Rate Generator */ + /* see BAUD RATES FOR ASYNCHRONOUS MODE in Data Book */ + /* Fosc=20MHz + BRGH=1 BRGH=0 + Rate SPBRG Rate SPBRG + ------- ----- ------- ----- + 9615 129 9469 32 + 19230 64 19530 15 + 37878 32 78130 3 + 56818 21 104200 2 + 113630 10 312500 0 + 250000 4 + 625000 1 + 1250000 0 + */ + switch (RS485_Baud_Rate) { + case 19200: + SPBRG2 = 64; + TXSTA2bits.BRGH = 1; + break; + case 38400: + SPBRG2 = 32; + TXSTA2bits.BRGH = 1; + break; + case 57600: + SPBRG2 = 21; + TXSTA2bits.BRGH = 1; + break; + case 76800: + SPBRG2 = 3; + TXSTA2bits.BRGH = 0; + break; + case 115200: + SPBRG2 = 10; + TXSTA2bits.BRGH = 1; + break; + case 9600: + SPBRG2 = 129; + TXSTA2bits.BRGH = 1; + break; + default: + SPBRG2 = 129; + TXSTA2bits.BRGH = 1; + RS485_Set_Baud_Rate(9600); + break; + } + /* select async mode */ + TXSTA2bits.SYNC = 0; + /* enable transmitter */ + TXSTA2bits.TXEN = 1; + /* serial port enable */ + RCSTA2bits.SPEN = 1; + /* since we are using RS485, + we need to explicitly say + transmit enable or not */ + RS485_RX_DISABLE = 0; + RS485_TX_ENABLE = 0; +} + +/**************************************************************************** +* DESCRIPTION: Disables the RS485 hardware +* RETURN: none +* ALGORITHM: none +* NOTES: none +*****************************************************************************/ +void RS485_Disable_Port( + void) +{ + RCSTA2 &= 0x4F; /* Disable the receiver */ + TXSTA2bits.TXEN = 0; /* and transmitter */ + PIE3 &= 0xCF; /* Disable both interrupts */ +} + +/**************************************************************************** +* DESCRIPTION: Reinitializes the port +* RETURN: none +* ALGORITHM: none +* NOTES: none +*****************************************************************************/ +void RS485_Reinit( + void) +{ + RS485_Set_Baud_Rate(38400); +} + +/**************************************************************************** +* DESCRIPTION: Initializes the data and the port +* RETURN: none +* ALGORITHM: none +* NOTES: none +*****************************************************************************/ +void RS485_Initialize( + void) +{ + /* Init the Rs485 buffers */ + FIFO_Init(&FIFO_Rx, RS485_Rx_Buffer, sizeof(RS485_Rx_Buffer)); + FIFO_Init(&FIFO_Tx, RS485_Tx_Buffer, sizeof(RS485_Tx_Buffer)); + + /* FIXME: read the stored baud rate */ + /* I2C_Read_Block( + EEPROM_DEVICE_ADDRESS, + (char *)&RS485_Baud_Rate, + sizeof(RS485_Baud_Rate), + EEPROM_MSTP_BAUD_RATE_ADDR); */ + + RS485_Initialize_Port(); +} diff --git a/bacnet-stack/ports/pic18f97j60/rs485.h b/bacnet-stack/ports/pic18f97j60/rs485.h new file mode 100644 index 00000000..689693aa --- /dev/null +++ b/bacnet-stack/ports/pic18f97j60/rs485.h @@ -0,0 +1,80 @@ +/*####COPYRIGHTBEGIN#### + ------------------------------------------- + Copyright (C) 2004 Steve Karg + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to: + The Free Software Foundation, Inc. + 59 Temple Place - Suite 330 + Boston, MA 02111-1307 + USA. + + As a special exception, if other files instantiate templates or + use macros or inline functions from this file, or you compile + this file and link it with other works to produce a work based + on this file, this file does not by itself cause the resulting + work to be covered by the GNU General Public License. However + the source code for this file must still be made available in + accordance with section (3) of the GNU General Public License. + + This exception does not invalidate any other reasons why a work + based on this file might be covered by the GNU General Public + License. + ------------------------------------------- +####COPYRIGHTEND####*/ + +#ifndef RS485_H +#define RS485_H + +#include +#include "mstp.h" + +extern uint32_t RS485_Baud_Rate; + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + void RS485_Reinit( + void); + void RS485_Initialize( + void); + + void RS485_Disable( + void); + + void RS485_Send_Frame( + volatile struct mstp_port_struct_t *mstp_port, /* port specific data */ + uint8_t * buffer, /* frame to send (up to 501 bytes of data) */ + uint16_t nbytes); /* number of bytes of data (up to 501) */ + + /* returns true if there is more data waiting */ + bool RS485_Check_UART_Data( + volatile struct mstp_port_struct_t *mstp_port); /* port specific data */ + + void RS485_Interrupt_Rx( + void); + + void RS485_Interrupt_Tx( + void); + + uint32_t RS485_Get_Baud_Rate( + void); + bool RS485_Set_Baud_Rate( + uint32_t baud); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ +#endif diff --git a/bacnet-stack/ports/pic18f97j60/stdbool.h b/bacnet-stack/ports/pic18f97j60/stdbool.h new file mode 100644 index 00000000..716b66e0 --- /dev/null +++ b/bacnet-stack/ports/pic18f97j60/stdbool.h @@ -0,0 +1,28 @@ +#ifndef STDBOOL_H +#define STDBOOL_H + +/* C99 Boolean types for compilers without C99 support */ + +#ifndef __cplusplus +typedef char _Bool; +#ifndef bool +#define bool _Bool +#endif +#ifndef true +#define true 1 +#endif +#ifndef false +#define false 0 +#endif +#define __bool_true_false_are_defined 1 +#endif + +#ifndef FALSE +#define FALSE 0 +#endif + +#ifndef TRUE +#define TRUE 1 +#endif + +#endif diff --git a/bacnet-stack/ports/pic18f97j60/stdint.h b/bacnet-stack/ports/pic18f97j60/stdint.h new file mode 100644 index 00000000..4dfd81c9 --- /dev/null +++ b/bacnet-stack/ports/pic18f97j60/stdint.h @@ -0,0 +1,18 @@ +/* Defines the standard integer types that are used in code */ + +#ifndef STDINT_H +#define STDINT_H 1 + +#include + +typedef unsigned char uint8_t; /* 1 byte 0 to 255 */ +typedef signed char int8_t; /* 1 byte -127 to 127 */ +typedef unsigned short uint16_t; /* 2 bytes 0 to 65535 */ +typedef signed short int16_t; /* 2 bytes -32767 to 32767 */ +/*typedef unsigned short long uint24_t; // 3 bytes 0 to 16777215 */ +typedef unsigned long uint32_t; /* 4 bytes 0 to 4294967295 */ +typedef signed long int32_t; /* 4 bytes -2147483647 to 2147483647 */ +/* typedef signed long long int64_t; */ +/* typedef unsigned long long uint64_t; */ + +#endif /* STDINT_H */