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