diff --git a/bacnet-stack/ports/atmega168/ai.c b/bacnet-stack/ports/atmega168/ai.c index 3acb2ebd..efbacc29 100644 --- a/bacnet-stack/ports/atmega168/ai.c +++ b/bacnet-stack/ports/atmega168/ai.c @@ -39,7 +39,7 @@ #error Modify the Analog_Input_Name to handle multiple digits #endif -static float Present_Value[MAX_ANALOG_INPUTS]; +float Present_Value[MAX_ANALOG_INPUTS]; /* we simply have 0-n object instances. Yours might be */ /* more complex, and then you need validate that the */ diff --git a/bacnet-stack/ports/atmega168/bacnet.aps b/bacnet-stack/ports/atmega168/bacnet.aps index 910da6f6..aaa27439 100644 --- a/bacnet-stack/ports/atmega168/bacnet.aps +++ b/bacnet-stack/ports/atmega168/bacnet.aps @@ -1 +1 @@ -13-Aug-2007 15:08:2715-Oct-2007 21:15:00013-Aug-2007 15:08:2744, 13, 0, 528AVR GCC241bacnet13-Aug-2007 15:11:0713-Aug-2007 15:11:07241013-Aug-2007 15:11:0744, 13, 0, 528AVR GCCbacnet.elfC:\code\bacnet-stack\ports\atmega168\ATmega168falseR00R01R02R03R04R05R06R07R08R09R10R11R12R13R14R15R16R17R18R19R20R21R22R23R24R25R26R27R28R29R30R31AVR DragonAVR SimulatorATmega168.xmlAuto000main.crs485.ctimer.cdlmstp.cC:\code\bacnet-stack\demo\handler\txbuf.cdevice.cC:\code\bacnet-stack\src\crc.cC:\code\bacnet-stack\src\iam\iam_server.cC:\code\bacnet-stack\src\npdu.cai.capdu.ch_rp.cavr035.hhardware.hrs485.htimer.hC:\code\bacnet-stack\include\crc.hC:\code\bacnet-stack\include\dlmstp.hC:\code\bacnet-stack\include\iam.hC:\code\bacnet-stack\include\npdu.hC:\code\bacnet-stack\include\txbuf.hMakefiledefaultYESMakefileatmega168100bacnet.elfdefault\1..\..\demo\handler\.\..\..\..\..\demo\object\-Wall -gdwarf-2 -DMAX_APDU=50 -DBACDL_MSTP -DBIG_ENDIAN=0 -DF_CPU=7372800UL -O0 -fsigned-chardefault1C:\WinAVR-20070525\bin\avr-gcc.exeC:\WinAVR-20070525\utils\bin\make.exe0282161937372800011000001920010000000001011main100000C:\WinAVR-20070525\avr\include\avr\eeprom.h100001C:\WinAVR-20070525\avr\include\avr\iomx8.h100002C:\WinAVR-20070525\examples\stdiodemo\uart.c100003main.c25900004C:\WinAVR-20070525\avr\include\avr\interrupt.h100005C:\WinAVR-20070525\avr\include\avr\io.h100006rs485.c25900007dlmstp.c25900008timer.c25900009device.c25700010C:\code\bacnet-stack\src\npdu.c25700011apdu.c25700012h_rp.c259271 848 431 8750 0523 608 683 6350 0358 582 518 6090 0287 141 1089 565149 0742 382 902 4090 0356 611 516 6380 0400 229 1450 7590 0510 339 1508 8690 0334 163 1332 6930 0466 295 1464 8250 0268 97 1266 6270 0290 119 1288 6490 0312 141 1310 6710 0 +13-Aug-2007 15:08:2716-Oct-2007 16:07:19013-Aug-2007 15:08:2744, 13, 0, 528AVR GCC241bacnet13-Aug-2007 15:11:0713-Aug-2007 15:11:07241013-Aug-2007 15:11:0744, 13, 0, 528AVR GCCbacnet.elfC:\code\bacnet-stack\ports\atmega168\ATmega168falseR00R01R02R03R04R05R06R07R08R09R10R11R12R13R14R15R16R17R18R19R20R21R22R23R24R25R26R27R28R29R30R31AVR DragonAVR SimulatorATmega168.xmlAuto000main.crs485.ctimer.cdlmstp.cC:\code\bacnet-stack\demo\handler\txbuf.cdevice.cC:\code\bacnet-stack\src\crc.cC:\code\bacnet-stack\src\iam\iam_server.cC:\code\bacnet-stack\src\npdu.cai.capdu.ch_rp.cavr035.hhardware.hrs485.htimer.hC:\code\bacnet-stack\include\crc.hC:\code\bacnet-stack\include\dlmstp.hC:\code\bacnet-stack\include\iam.hC:\code\bacnet-stack\include\npdu.hC:\code\bacnet-stack\include\txbuf.hC:\code\bacnet-stack\include\bacenum.hMakefiledefaultYESMakefileatmega168100bacnet.elfdefault\0..\..\demo\handler\.\..\..\..\..\demo\object\-Wall -gdwarf-2 -DMAX_APDU=50 -DBACDL_MSTP -DBIG_ENDIAN=0 -DF_CPU=7372800UL -O0 -fsigned-chardefault1C:\WinAVR-20070525\bin\avr-gcc.exeC:\WinAVR-20070525\utils\bin\make.exe0282161937372800011000001920010000000001011main100000C:\WinAVR-20070525\avr\include\avr\eeprom.h100001C:\WinAVR-20070525\avr\include\avr\iomx8.h100002C:\WinAVR-20070525\examples\stdiodemo\uart.c100003main.c25900004C:\WinAVR-20070525\avr\include\avr\interrupt.h100005C:\WinAVR-20070525\avr\include\avr\io.h100006rs485.c25900007dlmstp.c25900008timer.c25900009h_rp.c25800010avr035.h100011ai.c1576 906 736 9330 0816 246 1425 6810 0651 628 811 6550 0742 319 1472 701156 01035 428 1195 4550 0649 657 809 6840 0654 231 1652 7610 0803 385 1801 9150 0627 209 1625 7390 0566 143 1296 5250 0588 165 1318 5470 0 diff --git a/bacnet-stack/ports/atmega168/device.c b/bacnet-stack/ports/atmega168/device.c index 7797cbb4..2e1b819c 100644 --- a/bacnet-stack/ports/atmega168/device.c +++ b/bacnet-stack/ports/atmega168/device.c @@ -260,6 +260,11 @@ int Device_Encode_Property_APDU(uint8_t * apdu, /* 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); + /* must have the bit string as big as it can be */ + 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_INPUT, true); diff --git a/bacnet-stack/ports/atmega168/main.c b/bacnet-stack/ports/atmega168/main.c index f80726d9..521eaff0 100644 --- a/bacnet-stack/ports/atmega168/main.c +++ b/bacnet-stack/ports/atmega168/main.c @@ -32,6 +32,8 @@ #include "npdu.h" #include "txbuf.h" #include "iam.h" +#include "device.h" + /* For porting to IAR, see: http://www.avrfreaks.net/wiki/index.php/Documentation:AVR_GCC/IarToAvrgcc*/ @@ -114,13 +116,18 @@ static void NPDU_LED_On(void) NPDU_Timer = 20; } +extern float Present_Value[9]; void task_milliseconds(void) { + static uint16_t counter = 0; while (Timer_Milliseconds) { Timer_Milliseconds--; /* add other millisecond timer tasks here */ RS485_LED_Timers(); NDPU_Timers(); + counter++; + Present_Value[0] = counter; + Present_Value[1] = counter; } } diff --git a/bacnet-stack/ports/atmega168/rs485.c b/bacnet-stack/ports/atmega168/rs485.c index 94e34817..3e0664cf 100644 --- a/bacnet-stack/ports/atmega168/rs485.c +++ b/bacnet-stack/ports/atmega168/rs485.c @@ -272,19 +272,23 @@ bool RS485_ReceiveError(void) uint8_t dummy_data; /* check for framing error */ + #if 0 if (BIT_CHECK(UCSR0A,FE0)) { + /* FIXME: how do I clear the error flags? */ + BITMASK_CLEAR(UCSR0A,(_BV(FE0) | _BV(DOR0) | _BV(UPE0))); ReceiveError = true; } + #endif /* check for overrun error */ if (BIT_CHECK(UCSR0A,DOR0)) { - ReceiveError = true; - } - if (ReceiveError) { - RS485_LED1_On(); /* flush the receive buffer */ do { dummy_data = UDR0; } while (BIT_CHECK(UCSR0A,RXC0)); + ReceiveError = true; + } + if (ReceiveError) { + RS485_LED1_On(); } return ReceiveError;