From 44da26484d2facf48e219374de6770da2549a80a Mon Sep 17 00:00:00 2001 From: skarg Date: Tue, 1 Jun 2010 19:58:52 +0000 Subject: [PATCH] Fixed EEPROM macro. Added Max_Master get/save from EEPROM. --- bacnet-stack/ports/bdk-atxx4-mstp/dlmstp.c | 13 ++++++++----- bacnet-stack/ports/bdk-atxx4-mstp/iar2gcc.h | 3 ++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/bacnet-stack/ports/bdk-atxx4-mstp/dlmstp.c b/bacnet-stack/ports/bdk-atxx4-mstp/dlmstp.c index ffd35c9a..ad8ace63 100644 --- a/bacnet-stack/ports/bdk-atxx4-mstp/dlmstp.c +++ b/bacnet-stack/ports/bdk-atxx4-mstp/dlmstp.c @@ -45,6 +45,8 @@ #include "bytes.h" #include "bacaddr.h" #include "timer.h" +#include "eeprom.h" +#include "nvdata.h" /* This file has been customized for use with small microprocessors */ /* Assumptions: @@ -242,6 +244,11 @@ bool dlmstp_init( { ifname = ifname; + eeprom_bytes_read(NV_EEPROM_MAX_MASTER, &Nmax_master, 1); + if (Nmax_master > 127) { + Nmax_master = 127; + } + return true; } @@ -1303,11 +1310,7 @@ void dlmstp_set_max_master( if (max_master <= 127) { if (This_Station <= max_master) { Nmax_master = max_master; - /* FIXME: implement your data storage */ - /* I2C_Write_Byte( - EEPROM_DEVICE_ADDRESS, - max_master, - EEPROM_MSTP_MAX_MASTER_ADDR); */ + eeprom_bytes_write(NV_EEPROM_MAX_MASTER, &max_master, 1); } } diff --git a/bacnet-stack/ports/bdk-atxx4-mstp/iar2gcc.h b/bacnet-stack/ports/bdk-atxx4-mstp/iar2gcc.h index c908c3f0..4554012c 100644 --- a/bacnet-stack/ports/bdk-atxx4-mstp/iar2gcc.h +++ b/bacnet-stack/ports/bdk-atxx4-mstp/iar2gcc.h @@ -211,7 +211,8 @@ typedef struct { #if defined(__GNUC__) #include #define EEPROM_DECLARE(x) x __attribute__((section (".eeprom"))) -#if ((__GNUC__ < 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ < 3))) +#if ((__GNUC__ < 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ < 3)) || \ + ((__GNUC__ == 4) && (__GNUC_MINOR__ == 3) && (__GNUC_PATCHLEVEL__ < 4))) /* bug in WinAVR - not quite IAR compatible */ #define __EEPUT _EEPUT #define __EEGET _EEGET