Modified for compilation under Linux.
This commit is contained in:
@@ -26,12 +26,15 @@ LINT = splint
|
||||
# jtag2fast = Atmel JTAG ICE mkII, running at 115200 Bd
|
||||
# jtag2slow = Atmel JTAG ICE mkII, running at 19200 Bd
|
||||
# avrispmkII = AVR ISP MKII
|
||||
AVRDUDE_PROGRAMMERID = avrispmkII
|
||||
# avr109 = bootloader
|
||||
AVRDUDE_PROGRAMMERID = jtag2fast
|
||||
#
|
||||
# # port--serial or parallel port to which your
|
||||
# # hardware programmer is attached
|
||||
# # usb can just be usb
|
||||
# port--serial or parallel port to which your
|
||||
# hardware programmer is attached
|
||||
# usb can just be usb
|
||||
AVRDUDE_PORT = usb
|
||||
#AVRDUDE_PORT = /dev/ttyUSB0
|
||||
|
||||
|
||||
# Source locations
|
||||
BACNET_CORE = ../../src
|
||||
@@ -40,6 +43,7 @@ BACNET_DEMO = ../../demo
|
||||
|
||||
# local files for this project
|
||||
CSRC = main.c \
|
||||
fuses.c \
|
||||
init.c \
|
||||
stack.c \
|
||||
adc.c \
|
||||
@@ -136,7 +140,7 @@ OPTIMIZATION = -Os $(OPTIMIZE_FLAGS)
|
||||
DEBUGGING =
|
||||
endif#
|
||||
|
||||
## Compile options common for all C compilation units.
|
||||
## BACnet options
|
||||
BFLAGS = -DBACDL_MSTP
|
||||
BFLAGS += -DMAX_APDU=128
|
||||
BFLAGS += -DBIG_ENDIAN=0
|
||||
@@ -149,12 +153,23 @@ BFLAGS += -DBACAPP_UNSIGNED
|
||||
BFLAGS += -DBACAPP_ENUMERATED
|
||||
BFLAGS += -DBACAPP_CHARACTER_STRING
|
||||
BFLAGS += -DWRITE_PROPERTY
|
||||
|
||||
## Compile options for C files
|
||||
CFLAGS = $(COMMON)
|
||||
CFLAGS += $(DEFINES)
|
||||
CFLAGS += $(DEBUGGING)
|
||||
# dead code removal
|
||||
CFLAGS += -ffunction-sections -fdata-sections
|
||||
CFLAGS += -Wall -gdwarf-2 $(BFLAGS) $(OPTIMIZATION) -fsigned-char
|
||||
# General flags
|
||||
CFLAGS += -funsigned-char
|
||||
CFLAGS += -funsigned-bitfields
|
||||
CFLAGS += -fpack-struct
|
||||
CFLAGS += -fshort-enums
|
||||
# warnings
|
||||
CFLAGS += -Wall
|
||||
CFLAGS += -Wstrict-prototypes
|
||||
# put it all together
|
||||
CFLAGS += -gdwarf-2 $(BFLAGS) $(OPTIMIZATION)
|
||||
CFLAGS += -MD -MP -MT $(*F).o -MF dep/$(@F).d
|
||||
|
||||
## Assembly specific flags
|
||||
@@ -177,6 +192,60 @@ 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
|
||||
|
||||
HEX_FUSE_FLAGS = -j .fuse
|
||||
HEX_FUSE_FLAGS += --change-section-lma .fuse=0 --no-change-warnings
|
||||
|
||||
AVRDUDE_FLAGS = -c $(AVRDUDE_PROGRAMMERID)
|
||||
AVRDUDE_FLAGS += -p $(AVRDUDE_MCU)
|
||||
AVRDUDE_FLAGS += -P $(AVRDUDE_PORT)
|
||||
|
||||
# Fuse high byte (0=enable,1=disable):
|
||||
# 0x92 = 1 0 0 1 0 0 1 0
|
||||
# ^ ^ ^ ^ ^ \+/ ^
|
||||
# | | | | | | |---- BOOTRST (Enable Bootloader Reset Vector)
|
||||
# | | | | | +------- BOOTSZ 1..0 (Select Boot Size)
|
||||
# | | | | | +------- [00=4k, 01=2k, 10=1k, 11=512]
|
||||
# | | | | +---------- EESAVE (Enable preserve EEPROM on Chip Erase)
|
||||
# | | | +-------------- WDTON (watchdog timer always on)
|
||||
# | | +---------------- SPIEN (Enable Serial Program and Data Downloading)
|
||||
# | +------------------ JTAGEN (Enable JTAG)
|
||||
# +-------------------- OCDEN (Enable OCD)
|
||||
#
|
||||
# Fuse low byte (0=enable,1=disable):
|
||||
# 0xC7 = 1 1 0 0 0 1 1 1
|
||||
# ^ ^ \+/ \--+--/
|
||||
# | | | +------- CKSEL 3..0 (Select Clock Source)
|
||||
# | | | +------- [1111-1000=Low Power Crystal Oscillator]
|
||||
# | | | +------- [0111-0110=Full Swing Crystal Oscillator]
|
||||
# | | | +------- [0101-0100=Low Frequency Crystal Oscillator]
|
||||
# | | | +------- [0011=Internal 128kHz RC Oscillator]
|
||||
# | | | +------- [0010=Calibrated Internal RC Oscillator]
|
||||
# | | | +------- [0000=External Clock]
|
||||
# | | +--------------- SUT 1..0 (Start up Time selection)
|
||||
# | | +--------------- [CKSEL=0:14CK+ 00=4.1ms,01=65ms,10=0ms,11=4.1ms]
|
||||
# | | +--------------- [CKSEL=1:14CK+ 00=65ms,01=0ms,10=4.1ms,11=65ms]
|
||||
# | +------------------ CKOUT (clock output on CKOUT pin)
|
||||
# +-------------------- CKDIV8 (divide clock by 8)
|
||||
#
|
||||
# Fuse extended byte (0=enable,1=disable):
|
||||
# 0xFC = 1 1 1 1 1 1 0 0
|
||||
# ^ ^ ^ ^ ^ \-+-/
|
||||
# | | | | | +------ BODLEVEL 2..0 (brownout trigger level)
|
||||
# | | | | | +------ [100=4.3V, 101=2.7V, 110=1.8V, 111=disabled]
|
||||
# | | | | +----------
|
||||
# | | | +--------------
|
||||
# | | +----------------
|
||||
# | +------------------
|
||||
# +--------------------
|
||||
AVRDUDE_WRITE_FUSES = -U hfuse:w:0x92:m -U lfuse:w:0xC7:m -U efuse:w:0xFC:m
|
||||
|
||||
AVRDUDE_READ_FUSES = -U lfuse:r:-:h -U hfuse:r:-:h -U efuse:r:-:h
|
||||
|
||||
AVRDUDE_WRITE_FLASH = -e -U flash:w:$(TARGET).hex
|
||||
|
||||
AVRDUDE_INSTALL = $(AVRDUDE_WRITE_FLASH)
|
||||
AVRDUDE_INSTALL += $(AVRDUDE_READ_FUSES)
|
||||
|
||||
## Objects that must be built in order to link
|
||||
OBJECTS = $(COBJ) $(DEMOOBJ)
|
||||
|
||||
@@ -219,10 +288,17 @@ size: ${TARGET_ELF}
|
||||
lint:
|
||||
$(LINT) $(BFLAGS) $(CSRC)
|
||||
|
||||
install: $(TARGET_ELF)
|
||||
$(AVRDUDE) -c $(AVRDUDE_PROGRAMMERID) \
|
||||
-p $(AVRDUDE_MCU) -P $(AVRDUDE_PORT) -e \
|
||||
-U flash:w:$(TARGET).hex
|
||||
install: $(TARGET_ELF)
|
||||
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_INSTALL)
|
||||
|
||||
writefuses:
|
||||
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FUSES)
|
||||
|
||||
showfuses:
|
||||
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_READ_FUSES)
|
||||
|
||||
bootloader:
|
||||
make -C bootloader all
|
||||
|
||||
## Clean target
|
||||
.PHONY: clean
|
||||
|
||||
@@ -28,7 +28,12 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h> /* for NAN */
|
||||
#if defined(__GNUC__) && (__GNUC__ > 4) && (__GNUC_MINOR__ > 2)
|
||||
#include <math.h> /* for NAN */
|
||||
#else
|
||||
#define NAN __builtin_nan("")
|
||||
#endif
|
||||
|
||||
#include "bacdef.h"
|
||||
#include "bacdcode.h"
|
||||
#include "bacenum.h"
|
||||
|
||||
@@ -87,9 +87,16 @@ LDFLAGS = -Ttext=$(BASEADDR) $(EXTMEMOPTS) $(LDMAP) $(PRINTF_LIB) $(SCANF_LIB) $
|
||||
|
||||
|
||||
# Programming support using avrdude. Settings and variables.
|
||||
|
||||
AVRDUDE_PROGRAMMER = stk500
|
||||
AVRDUDE_PORT = /dev/ttya
|
||||
# jtag2fast = Atmel JTAG ICE mkII, running at 115200 Bd
|
||||
# jtag2slow = Atmel JTAG ICE mkII, running at 19200 Bd
|
||||
# avrispmkII = AVR ISP MKII
|
||||
AVRDUDE_PROGRAMMER = jtag2fast
|
||||
#
|
||||
# # port--serial or parallel port to which your
|
||||
# # hardware programmer is attached
|
||||
# # usb can just be usb
|
||||
# # /dev/ttya
|
||||
AVRDUDE_PORT = usb
|
||||
|
||||
AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
|
||||
#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
|
||||
@@ -109,9 +116,16 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
|
||||
# to submit bug reports.
|
||||
#AVRDUDE_VERBOSE = -v -v
|
||||
|
||||
AVRDUDE_BASIC = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
|
||||
AVRDUDE_FLAGS = $(AVRDUDE_BASIC) $(AVRDUDE_NO_VERIFY) $(AVRDUDE_VERBOSE) $(AVRDUDE_ERASE_COUNTER)
|
||||
# Disable auto-erase so that the chip can be initially
|
||||
# programmed with application code, with the bootloader code added second
|
||||
AVRDUDE_AUTOERASE = -D
|
||||
|
||||
AVRDUDE_BASIC = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
|
||||
AVRDUDE_FLAGS = $(AVRDUDE_BASIC)
|
||||
AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
|
||||
AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
|
||||
AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
|
||||
AVRDUDE_FLAGS += $(AVRDUDE_AUTOERASE)
|
||||
|
||||
CC = avr-gcc
|
||||
OBJCOPY = avr-objcopy
|
||||
@@ -133,7 +147,6 @@ LST = $(ASRC:.S=.lst) $(SRC:.c=.lst)
|
||||
ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS)
|
||||
ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
|
||||
|
||||
|
||||
# Default target.
|
||||
all: build
|
||||
|
||||
@@ -147,12 +160,10 @@ sym: $(TARGET).sym
|
||||
|
||||
|
||||
# Program the device.
|
||||
program: $(TARGET).hex $(TARGET).eep
|
||||
install: $(TARGET).hex $(TARGET).eep
|
||||
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
||||
|
||||
|
||||
|
||||
|
||||
# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
|
||||
COFFCONVERT=$(OBJCOPY) --debugging \
|
||||
--change-section-address .data-0x800000 \
|
||||
|
||||
@@ -7,6 +7,18 @@
|
||||
#endif
|
||||
#if __GNUC__
|
||||
#include <avr/io.h>
|
||||
|
||||
#if (__GNUC__ <= 4) && (__GNUC_MINOR__ < 3)
|
||||
|
||||
#if !defined(EEWE) && defined(EEPE)
|
||||
# define EEWE EEPE
|
||||
#endif
|
||||
|
||||
#if !defined(EEMWE) && defined(EEMPE)
|
||||
# define EEMWE EEMPE
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* define pin for enter-self-prog-mode */
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
/************************************************************************
|
||||
*
|
||||
* Copyright (C) 2009 Steve Karg <skarg@users.sourceforge.net>
|
||||
*
|
||||
* 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 "hardware.h"
|
||||
|
||||
#if defined(__GNUC__) && (__GNUC__ > 4)
|
||||
/* AVR fuse settings for ATmega644P */
|
||||
FUSES = {
|
||||
/* External Ceramic Resonator - configuration */
|
||||
/* Full Swing Crystal Oscillator Clock Selection */
|
||||
/* Ceramic resonator, slowly rising power 1K CK 14CK + 65 ms */
|
||||
/* note: fuses are enabled by clearing the bit, so
|
||||
any fuses listed below are cleared fuses. */
|
||||
.low = (FUSE_CKSEL3 & FUSE_SUT0 & FUSE_SUT1),
|
||||
|
||||
/* BOOTSZ configuration:
|
||||
BOOTSZ1 BOOTSZ0 Boot Size
|
||||
------- ------- ---------
|
||||
1 1 512
|
||||
1 0 1024
|
||||
0 1 2048
|
||||
0 0 4096
|
||||
*/
|
||||
/* note: fuses are enabled by clearing the bit, so
|
||||
any fuses listed below are cleared fuses. */
|
||||
.high =
|
||||
(FUSE_BOOTSZ1 & FUSE_BOOTRST & FUSE_EESAVE & FUSE_SPIEN & FUSE_JTAGEN),
|
||||
/* Brown-out detection VCC=2.7V */
|
||||
/* BODLEVEL configuration
|
||||
BODLEVEL2 BODLEVEL1 BODLEVEL0 Voltage
|
||||
--------- --------- --------- --------
|
||||
1 1 1 disabled
|
||||
1 1 0 1.8V
|
||||
1 0 1 2.7V
|
||||
1 0 0 4.3V
|
||||
*/
|
||||
/* note: fuses are enabled by clearing the bit, so
|
||||
any fuses listed below are cleared fuses. */
|
||||
.extended = (FUSE_BODLEVEL1 & FUSE_BODLEVEL0)
|
||||
};
|
||||
|
||||
/* AVR lock bits - unlocked */
|
||||
LOCKBITS = LOCKBITS_DEFAULT;
|
||||
#endif
|
||||
@@ -57,44 +57,6 @@ static uint8_t MSTP_MAC_Address;
|
||||
/* For porting to IAR, see:
|
||||
http://www.avrfreaks.net/wiki/index.php/Documentation:AVR_GCC/IarToAvrgcc*/
|
||||
|
||||
#if defined(__GNUC__) && (__GNUC__ > 4)
|
||||
/* AVR fuse settings */
|
||||
FUSES = {
|
||||
/* External Ceramic Resonator - configuration */
|
||||
/* Full Swing Crystal Oscillator Clock Selection */
|
||||
/* Ceramic resonator, slowly rising power 1K CK 14CK + 65 ms */
|
||||
/* note: fuses are enabled by clearing the bit, so
|
||||
any fuses listed below are cleared fuses. */
|
||||
.low = (FUSE_CKSEL3 & FUSE_SUT0 & FUSE_SUT1),
|
||||
/* BOOTSZ configuration:
|
||||
BOOTSZ1 BOOTSZ0 Boot Size
|
||||
------- ------- ---------
|
||||
1 1 512
|
||||
1 0 1024
|
||||
0 1 2048
|
||||
0 0 4096
|
||||
*/
|
||||
/* note: fuses are enabled by clearing the bit, so
|
||||
any fuses listed below are cleared fuses. */
|
||||
.high =
|
||||
(FUSE_BOOTSZ1 & FUSE_BOOTRST & FUSE_EESAVE & FUSE_SPIEN & FUSE_JTAGEN),
|
||||
/* Brown-out detection VCC=2.7V */
|
||||
/* BODLEVEL configuration
|
||||
BODLEVEL2 BODLEVEL1 BODLEVEL0 Voltage
|
||||
--------- --------- --------- --------
|
||||
1 1 1 disabled
|
||||
1 1 0 1.8V
|
||||
1 0 1 2.7V
|
||||
1 0 0 4.3V
|
||||
*/
|
||||
/* note: fuses are enabled by clearing the bit, so
|
||||
any fuses listed below are cleared fuses. */
|
||||
.extended = (FUSE_BODLEVEL1 & FUSE_BODLEVEL0),};
|
||||
|
||||
/* AVR lock bits - unlocked */
|
||||
LOCKBITS = LOCKBITS_DEFAULT;
|
||||
#endif
|
||||
|
||||
bool seeprom_version_test(
|
||||
void)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user