From afd8687519c463909725bd55c3d06df6da210300 Mon Sep 17 00:00:00 2001 From: skarg Date: Thu, 10 May 2018 18:34:19 +0000 Subject: [PATCH] Updated Makefile GCC ARM build for STM32F10x port. --- bacnet-stack/Makefile | 7 ++-- bacnet-stack/ports/stm32f10x/Makefile | 5 +++ bacnet-stack/ports/stm32f10x/device.c | 33 ++++++++++++++++--- bacnet-stack/ports/stm32f10x/stm32f10x_conf.h | 3 +- 4 files changed, 40 insertions(+), 8 deletions(-) diff --git a/bacnet-stack/Makefile b/bacnet-stack/Makefile index 221049b6..ffa7d44b 100644 --- a/bacnet-stack/Makefile +++ b/bacnet-stack/Makefile @@ -103,15 +103,18 @@ router-ipv6: $(MAKE) -B -s -C demo router-ipv6 # Add "ports" to the build, if desired -ports: atmega168 bdk-atxx4-mstp at91sam7s +ports: atmega168 bdk-atxx4-mstp at91sam7s stm32f10x @echo "Built the ARM7 and AVR ports" atmega168: ports/atmega168/Makefile $(MAKE) -s -C ports/atmega168 clean all -at91sam7s: ports/at91sam7s/makefile +at91sam7s: ports/at91sam7s/Makefile $(MAKE) -s -C ports/at91sam7s clean all +stm32f10x: ports/stm32f10x/Makefile + $(MAKE) -s -C ports/stm32f10x clean all + mstpsnap: ports/linux/mstpsnap.mak $(MAKE) -s -C ports/linux -f mstpsnap.mak clean all diff --git a/bacnet-stack/ports/stm32f10x/Makefile b/bacnet-stack/ports/stm32f10x/Makefile index 2a025535..d488f107 100644 --- a/bacnet-stack/ports/stm32f10x/Makefile +++ b/bacnet-stack/ports/stm32f10x/Makefile @@ -138,6 +138,9 @@ BACNET_FLAGS += -DBIG_ENDIAN=0 BACNET_FLAGS += -DMAX_TSM_TRANSACTIONS=0 BACNET_FLAGS += -DMAX_CHARACTER_STRING_BYTES=64 BACNET_FLAGS += -DMAX_OCTET_STRING_BYTES=64 +# if called from root Makefile, PRINT was already defined +BACNET_FLAGS += -UPRINT_ENABLED +BACNET_FLAGS += -DPRINT_ENABLED=0 CFLAGS += $(MCU_FLAGS) CFLAGS += $(OPTIMIZE_FLAGS) @@ -153,6 +156,8 @@ CFLAGS += -fno-common CFLAGS += -Wall # don't warn about missing braces since GCC is over-achiever for this CFLAGS += -Wno-missing-braces +# don't warn about missing prototypes since STM32 library doesn't have some +CFLAGS += -Wno-missing-prototypes # -Wa, Pass comma-separated on to the assembler AFLAGS = -Wa,-ahls,-mapcs-32,-adhlns=$(<:.s=.lst) diff --git a/bacnet-stack/ports/stm32f10x/device.c b/bacnet-stack/ports/stm32f10x/device.c index f4cc9851..f6afbe33 100644 --- a/bacnet-stack/ports/stm32f10x/device.c +++ b/bacnet-stack/ports/stm32f10x/device.c @@ -80,6 +80,7 @@ static BACNET_DEVICE_STATUS System_Status = STATUS_OPERATIONAL; static BACNET_CHARACTER_STRING My_Object_Name; static uint32_t Database_Revision; static BACNET_REINITIALIZED_STATE Reinitialize_State = BACNET_REINIT_IDLE; +static const char *Reinit_Password = "stm32-challenge"; /* These three arrays are used by the ReadPropertyMultiple handler */ static const int Device_Properties_Required[] = { @@ -362,15 +363,37 @@ bool Device_Reinitialize( { bool status = false; - if (characterstring_ansi_same(&rd_data->password, "stm32-challenge")) { - Reinitialize_State = rd_data->state; + /* Note: you could use a mix of state and password to multiple things */ + if (characterstring_ansi_same(&rd_data->password, Reinit_Password)) { + switch (rd_data->state) { + case BACNET_REINIT_COLDSTART: + case BACNET_REINIT_WARMSTART: dcc_set_status_duration(COMMUNICATION_ENABLE, 0); - /* Note: you could use a mix of state - and password to multiple things */ /* note: you probably want to restart *after* the simple ack has been sent from the return handler so just set a flag from here */ - status = true; + Reinitialize_State = rd_data->state; + status = true; + break; + case BACNET_REINIT_STARTBACKUP: + case BACNET_REINIT_ENDBACKUP: + case BACNET_REINIT_STARTRESTORE: + case BACNET_REINIT_ENDRESTORE: + case BACNET_REINIT_ABORTRESTORE: + if (dcc_communication_disabled()) { + rd_data->error_class = ERROR_CLASS_SERVICES; + rd_data->error_code = ERROR_CODE_COMMUNICATION_DISABLED; + } else { + rd_data->error_class = ERROR_CLASS_SERVICES; + rd_data->error_code = + ERROR_CODE_OPTIONAL_FUNCTIONALITY_NOT_SUPPORTED; + } + break; + default: + rd_data->error_class = ERROR_CLASS_SERVICES; + rd_data->error_code = ERROR_CODE_PARAMETER_OUT_OF_RANGE; + break; + } } else { rd_data->error_class = ERROR_CLASS_SECURITY; rd_data->error_code = ERROR_CODE_PASSWORD_FAILURE; diff --git a/bacnet-stack/ports/stm32f10x/stm32f10x_conf.h b/bacnet-stack/ports/stm32f10x/stm32f10x_conf.h index ac874601..d8f8c9cd 100644 --- a/bacnet-stack/ports/stm32f10x/stm32f10x_conf.h +++ b/bacnet-stack/ports/stm32f10x/stm32f10x_conf.h @@ -46,7 +46,8 @@ #include "stm32f10x_tim.h" #include "stm32f10x_usart.h" #include "stm32f10x_wwdg.h" -#include "stm32f10x_misc.h" /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */ +/* High level functions for NVIC and SysTick (add-on to CMSIS functions) */ +#include "stm32f10x_misc.h" /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/