Corrected bug in ATmega168 demo in the RS-485 driver. Also updated the IAR project for Embedded workbench 5.10. Stats:
IAR Atmel AVR C/C++ Compiler V5.10A/W32 10191 bytes of CODE memory (+36 range fill) 775 bytes of DATA memory (+24 absolute) avr-gcc (GCC) 4.2.2 (WinAVR 20071221rc1) Program: 12052 bytes (73.6% Full) Data: 481 bytes (47.0% Full)
This commit is contained in:
@@ -34,8 +34,7 @@
|
||||
#include "bacapp.h"
|
||||
#include "config.h" /* the custom stuff */
|
||||
#include "wp.h"
|
||||
|
||||
#define MAX_ANALOG_VALUES 4
|
||||
#include "av.h"
|
||||
|
||||
/* we choose to have a NULL level in our system represented by */
|
||||
/* a particular value. When the priorities are not in use, they */
|
||||
|
||||
@@ -31,6 +31,10 @@
|
||||
#include "bacerror.h"
|
||||
#include "wp.h"
|
||||
|
||||
#ifndef MAX_ANALOG_VALUES
|
||||
#define MAX_ANALOG_VALUES 4
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "bacapp.h"
|
||||
#include "config.h" /* the custom stuff */
|
||||
#include "wp.h"
|
||||
#include "av.h"
|
||||
|
||||
#if (MAX_ANALOG_VALUES > 10)
|
||||
#error Modify the Analog_Value_Name to handle multiple digits
|
||||
|
||||
@@ -10,9 +10,9 @@
|
||||
<debug>1</debug>
|
||||
<settings>
|
||||
<name>General</name>
|
||||
<archiveVersion>3</archiveVersion>
|
||||
<archiveVersion>5</archiveVersion>
|
||||
<data>
|
||||
<version>6</version>
|
||||
<version>7</version>
|
||||
<wantNonLocal>1</wantNonLocal>
|
||||
<debug>1</debug>
|
||||
<option>
|
||||
@@ -63,7 +63,7 @@
|
||||
</option>
|
||||
<option>
|
||||
<name>SCCStackSize</name>
|
||||
<state>0x20</state>
|
||||
<state>0xff</state>
|
||||
</option>
|
||||
<option>
|
||||
<name>SCExtCStack</name>
|
||||
@@ -71,7 +71,7 @@
|
||||
</option>
|
||||
<option>
|
||||
<name>SCRStackSize</name>
|
||||
<state>16</state>
|
||||
<state>32</state>
|
||||
</option>
|
||||
<option>
|
||||
<name>SCExtRStack</name>
|
||||
@@ -127,8 +127,8 @@
|
||||
</option>
|
||||
<option>
|
||||
<name>New Variant Processor</name>
|
||||
<version>15</version>
|
||||
<state>41</state>
|
||||
<version>24</version>
|
||||
<state>45</state>
|
||||
</option>
|
||||
<option>
|
||||
<name>GRuntimeLibSelect</name>
|
||||
@@ -145,11 +145,11 @@
|
||||
</option>
|
||||
<option>
|
||||
<name>RTConfigPath</name>
|
||||
<state>$TOOLKIT_DIR$\LIB\DLIB\dlAVR-3s-ec-sf-n.h</state>
|
||||
<state>$TOOLKIT_DIR$\LIB\DLIB\dlAVR-3s-ec_mul-sf-n.h</state>
|
||||
</option>
|
||||
<option>
|
||||
<name>RTLibraryPath</name>
|
||||
<state>$TOOLKIT_DIR$\LIB\DLIB\dlAVR-3s-ec-sf-n.r90</state>
|
||||
<state>$TOOLKIT_DIR$\LIB\DLIB\dlAVR-3s-ec_mul-sf-n.r90</state>
|
||||
</option>
|
||||
<option>
|
||||
<name>Input variant</name>
|
||||
@@ -207,13 +207,17 @@
|
||||
<name>LCsHeapConfigText</name>
|
||||
<state>1</state>
|
||||
</option>
|
||||
<option>
|
||||
<name>GGNoMULInstruction</name>
|
||||
<state>0</state>
|
||||
</option>
|
||||
</data>
|
||||
</settings>
|
||||
<settings>
|
||||
<name>ICCAVR</name>
|
||||
<archiveVersion>3</archiveVersion>
|
||||
<archiveVersion>4</archiveVersion>
|
||||
<data>
|
||||
<version>12</version>
|
||||
<version>13</version>
|
||||
<wantNonLocal>1</wantNonLocal>
|
||||
<debug>1</debug>
|
||||
<option>
|
||||
@@ -468,13 +472,17 @@
|
||||
<name>CCRadioModuleTypeSlave</name>
|
||||
<state>1</state>
|
||||
</option>
|
||||
<option>
|
||||
<name>OCCAdditionalCommandLineOptionsSlave</name>
|
||||
<state>0</state>
|
||||
</option>
|
||||
</data>
|
||||
</settings>
|
||||
<settings>
|
||||
<name>AAVR</name>
|
||||
<archiveVersion>3</archiveVersion>
|
||||
<archiveVersion>4</archiveVersion>
|
||||
<data>
|
||||
<version>9</version>
|
||||
<version>10</version>
|
||||
<wantNonLocal>1</wantNonLocal>
|
||||
<debug>1</debug>
|
||||
<option>
|
||||
@@ -650,18 +658,6 @@
|
||||
<name>AsmOutputFile</name>
|
||||
<state>$FILE_BNAME$.r90</state>
|
||||
</option>
|
||||
<option>
|
||||
<name>AOverrideModuleTypeDefault</name>
|
||||
<state>0</state>
|
||||
</option>
|
||||
<option>
|
||||
<name>ARadioModuleType</name>
|
||||
<state>0</state>
|
||||
</option>
|
||||
<option>
|
||||
<name>ARadioModuleTypeSlave</name>
|
||||
<state>1</state>
|
||||
</option>
|
||||
</data>
|
||||
</settings>
|
||||
<settings>
|
||||
@@ -707,7 +703,7 @@
|
||||
</option>
|
||||
<option>
|
||||
<name>FormatVariant</name>
|
||||
<version>7</version>
|
||||
<version>8</version>
|
||||
<state>2</state>
|
||||
</option>
|
||||
<option>
|
||||
@@ -856,7 +852,7 @@
|
||||
</option>
|
||||
<option>
|
||||
<name>DebugInformation</name>
|
||||
<state>1</state>
|
||||
<state>0</state>
|
||||
</option>
|
||||
<option>
|
||||
<name>RuntimeControl</name>
|
||||
@@ -868,7 +864,7 @@
|
||||
</option>
|
||||
<option>
|
||||
<name>AllowExtraOutput</name>
|
||||
<state>0</state>
|
||||
<state>1</state>
|
||||
</option>
|
||||
<option>
|
||||
<name>GenerateExtraOutput</name>
|
||||
@@ -889,7 +885,7 @@
|
||||
</option>
|
||||
<option>
|
||||
<name>ExtraFormatVariant</name>
|
||||
<version>7</version>
|
||||
<version>8</version>
|
||||
<state>2</state>
|
||||
</option>
|
||||
<option>
|
||||
@@ -985,9 +981,9 @@
|
||||
<debug>0</debug>
|
||||
<settings>
|
||||
<name>General</name>
|
||||
<archiveVersion>3</archiveVersion>
|
||||
<archiveVersion>5</archiveVersion>
|
||||
<data>
|
||||
<version>6</version>
|
||||
<version>7</version>
|
||||
<wantNonLocal>1</wantNonLocal>
|
||||
<debug>0</debug>
|
||||
<option>
|
||||
@@ -1102,7 +1098,7 @@
|
||||
</option>
|
||||
<option>
|
||||
<name>New Variant Processor</name>
|
||||
<version>15</version>
|
||||
<version>24</version>
|
||||
<state>0</state>
|
||||
</option>
|
||||
<option>
|
||||
@@ -1178,13 +1174,17 @@
|
||||
<name>LCsHeapConfigText</name>
|
||||
<state>1</state>
|
||||
</option>
|
||||
<option>
|
||||
<name>GGNoMULInstruction</name>
|
||||
<state>0</state>
|
||||
</option>
|
||||
</data>
|
||||
</settings>
|
||||
<settings>
|
||||
<name>ICCAVR</name>
|
||||
<archiveVersion>3</archiveVersion>
|
||||
<archiveVersion>4</archiveVersion>
|
||||
<data>
|
||||
<version>12</version>
|
||||
<version>13</version>
|
||||
<wantNonLocal>1</wantNonLocal>
|
||||
<debug>0</debug>
|
||||
<option>
|
||||
@@ -1434,13 +1434,17 @@
|
||||
<name>CCRadioModuleTypeSlave</name>
|
||||
<state>1</state>
|
||||
</option>
|
||||
<option>
|
||||
<name>OCCAdditionalCommandLineOptionsSlave</name>
|
||||
<state>0</state>
|
||||
</option>
|
||||
</data>
|
||||
</settings>
|
||||
<settings>
|
||||
<name>AAVR</name>
|
||||
<archiveVersion>3</archiveVersion>
|
||||
<archiveVersion>4</archiveVersion>
|
||||
<data>
|
||||
<version>9</version>
|
||||
<version>10</version>
|
||||
<wantNonLocal>1</wantNonLocal>
|
||||
<debug>0</debug>
|
||||
<option>
|
||||
@@ -1616,18 +1620,6 @@
|
||||
<name>AsmOutputFile</name>
|
||||
<state></state>
|
||||
</option>
|
||||
<option>
|
||||
<name>AOverrideModuleTypeDefault</name>
|
||||
<state>0</state>
|
||||
</option>
|
||||
<option>
|
||||
<name>ARadioModuleType</name>
|
||||
<state>0</state>
|
||||
</option>
|
||||
<option>
|
||||
<name>ARadioModuleTypeSlave</name>
|
||||
<state>1</state>
|
||||
</option>
|
||||
</data>
|
||||
</settings>
|
||||
<settings>
|
||||
@@ -1673,7 +1665,7 @@
|
||||
</option>
|
||||
<option>
|
||||
<name>FormatVariant</name>
|
||||
<version>7</version>
|
||||
<version>8</version>
|
||||
<state>2</state>
|
||||
</option>
|
||||
<option>
|
||||
@@ -1857,7 +1849,7 @@
|
||||
</option>
|
||||
<option>
|
||||
<name>ExtraFormatVariant</name>
|
||||
<version>7</version>
|
||||
<version>8</version>
|
||||
<state>2</state>
|
||||
</option>
|
||||
<option>
|
||||
@@ -2026,9 +2018,6 @@
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\..\demo\handler\txbuf.c</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\..\src\version.c</name>
|
||||
</file>
|
||||
<file>
|
||||
<name>$PROJ_DIR$\..\..\src\whois.c</name>
|
||||
</file>
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
#if !defined(F_CPU)
|
||||
/* The processor clock frequency */
|
||||
#define F_CPU (7372800)
|
||||
#define F_CPU 7372800UL
|
||||
#endif
|
||||
|
||||
#if defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ASM__)
|
||||
|
||||
@@ -34,25 +34,26 @@
|
||||
#ifndef IAR2GCC_H
|
||||
#define IAR2GCC_H
|
||||
|
||||
#if !defined(F_CPU)
|
||||
#define F_CPU (7372800)
|
||||
#endif
|
||||
|
||||
#if defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ASM__)
|
||||
#include <inavr.h>
|
||||
#include <ioavr.h>
|
||||
#define _BV(bit_num) (1 << (bit_num))
|
||||
#define _delay_us(x) \
|
||||
|
||||
/* inline function */
|
||||
static inline void delay_us(
|
||||
static inline void _delay_us(
|
||||
uint8_t microseconds)
|
||||
{
|
||||
do {
|
||||
__delay_cycles(F_CPU / 1000000);
|
||||
__delay_cycles(F_CPU / 1000000UL);
|
||||
} while (microseconds--);
|
||||
}
|
||||
|
||||
#else
|
||||
#if !defined(F_CPU)
|
||||
#define F_CPU (7372800)
|
||||
#endif
|
||||
/* GCC */
|
||||
#include <avr/io.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include <util/delay.h>
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "txbuf.h"
|
||||
#include "iam.h"
|
||||
#include "device.h"
|
||||
#include "av.h"
|
||||
|
||||
const char *BACnet_Version = "1.0";
|
||||
|
||||
|
||||
@@ -56,13 +56,6 @@ static uint32_t RS485_Baud = 9600;
|
||||
#define Tturnaround (40UL)
|
||||
/* turnaround_time_milliseconds = (Tturnaround*1000UL)/RS485_Baud; */
|
||||
|
||||
/* 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. */
|
||||
/* NOTE: AVR lib delay_us limit is 768us; limit is 7bits/9600bps=729us */
|
||||
#define Tpostdrive1 (7UL)
|
||||
#define Tpostdrive2 (7UL)
|
||||
|
||||
/****************************************************************************
|
||||
* DESCRIPTION: Initializes the RS485 hardware and variables, and starts in
|
||||
* receive mode.
|
||||
@@ -176,12 +169,6 @@ void RS485_Transmitter_Enable(
|
||||
if (enable) {
|
||||
BIT_SET(PORTD, PD2);
|
||||
} else {
|
||||
#if Tpostdrive1
|
||||
_delay_us(Tpostdrive1 / RS485_Baud);
|
||||
#endif
|
||||
#if Tpostdrive2
|
||||
_delay_us(Tpostdrive2 / RS485_Baud);
|
||||
#endif
|
||||
BIT_CLEAR(PORTD, PD2);
|
||||
}
|
||||
}
|
||||
@@ -254,15 +241,13 @@ void RS485_Send_Data(
|
||||
buffer++;
|
||||
nbytes--;
|
||||
}
|
||||
while (!BIT_CHECK(UCSR0A, UDRE0)) {
|
||||
/* do nothing - wait until Tx buffer is empty */
|
||||
}
|
||||
/* is the frame sent? */
|
||||
/* Clear the Transmit Complete flag by writing a one to it. */
|
||||
BIT_SET(UCSR0A, TXC0);
|
||||
/* was the frame sent? */
|
||||
while (!BIT_CHECK(UCSR0A, TXC0)) {
|
||||
/* do nothing - wait until the entire frame in the
|
||||
/* do nothing - wait until the entire frame in the
|
||||
Transmit Shift Register has been shifted out */
|
||||
}
|
||||
BIT_CLEAR(UCSR0A, TXC0);
|
||||
/* per MSTP spec, sort of */
|
||||
Timer_Silence_Reset();
|
||||
}
|
||||
@@ -304,7 +289,7 @@ bool RS485_ReceiveError(
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* DESCRIPTION: Return true if data is available
|
||||
* DESCRIPTION: Return true if data is available
|
||||
* RETURN: true if data is available, with the data in the parameter set
|
||||
* ALGORITHM: none
|
||||
* NOTES: none
|
||||
|
||||
Reference in New Issue
Block a user