From 5e8f976845a18c19ea3f8772036781e380d5cfbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Castellucci=20Vidal?= Date: Sun, 16 Oct 2016 19:08:48 -0300 Subject: [PATCH] Added support for C++ projects. --- Makefile | 27 ++++-- etc/ld/lpc11u68_lib.ld | 1 + etc/ld/lpc1769_lib.ld | 1 + etc/ld/lpc4337_m0_lib.ld | 1 + etc/ld/lpc4337_m4_lib.ld | 1 + etc/ld/lpc54102_m0_lib.ld | 1 + etc/ld/lpc54102_m4_lib.ld | 1 + etc/target/lpc11u68.mk | 5 ++ etc/target/lpc1769.mk | 6 ++ etc/target/lpc4337_m0.mk | 5 ++ etc/target/lpc4337_m4.mk | 6 ++ etc/target/lpc54102_m0.mk | 5 ++ etc/target/lpc54102_m4.mk | 6 ++ examples/blinky_cpp/Makefile | 54 ++++++++++++ examples/blinky_cpp/inc/main.h | 75 +++++++++++++++++ examples/blinky_cpp/src/main.cpp | 109 +++++++++++++++++++++++++ modules/lpc4337_m4/ciaa/inc/ciaaAIN.h | 8 ++ modules/lpc4337_m4/ciaa/inc/ciaaAOUT.h | 8 ++ modules/lpc4337_m4/ciaa/inc/ciaaI2C.h | 8 ++ modules/lpc4337_m4/ciaa/inc/ciaaIO.h | 8 ++ modules/lpc4337_m4/ciaa/inc/ciaaNVM.h | 8 ++ modules/lpc4337_m4/ciaa/inc/ciaaUART.h | 8 ++ 22 files changed, 346 insertions(+), 6 deletions(-) create mode 100644 examples/blinky_cpp/Makefile create mode 100644 examples/blinky_cpp/inc/main.h create mode 100644 examples/blinky_cpp/src/main.cpp diff --git a/Makefile b/Makefile index 59e1bcc..8e61d2b 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,10 @@ # Copyright 2016, Pablo Ridolfi # All rights reserved. # +# Changes: +# 2016-10-16: Iván Castellucci Vidal +# Added support for C++ projects. +# # This file is part of Workspace. # # Redistribution and use in source and binary forms, with or without @@ -34,6 +38,8 @@ PROJECT ?= examples/blinky TARGET ?= lpc4337_m4 BOARD ?= edu_ciaa_nxp +CC := gcc +CXX := g++ include $(PROJECT)/Makefile @@ -47,6 +53,8 @@ PROJECT_OBJ_FILES := $(addprefix $(OBJ_PATH)/,$(notdir $(PROJECT_C_FILES:.c=.o)) PROJECT_OBJ_FILES += $(addprefix $(OBJ_PATH)/,$(notdir $(PROJECT_ASM_FILES:.S=.o))) +PROJECT_OBJ_FILES += $(addprefix $(OBJ_PATH)/,$(notdir $(PROJECT_CXX_FILES:.cpp=.o))) + PROJECT_OBJS := $(notdir $(PROJECT_OBJ_FILES)) INCLUDES := $(addprefix -I,$(PROJECT_INC_FOLDERS)) \ @@ -54,6 +62,7 @@ INCLUDES := $(addprefix -I,$(PROJECT_INC_FOLDERS)) \ vpath %.o $(OBJ_PATH) vpath %.c $(PROJECT_SRC_FOLDERS) $(foreach MOD,$(notdir $(PROJECT_MODULES)),$($(MOD)_SRC_FOLDERS)) +vpath %.cpp $(PROJECT_SRC_FOLDERS) $(foreach MOD,$(notdir $(PROJECT_MODULES)),$($(MOD)_SRC_FOLDERS)) vpath %.S $(PROJECT_SRC_FOLDERS) $(foreach MOD,$(notdir $(PROJECT_MODULES)),$($(MOD)_SRC_FOLDERS)) vpath %.a $(OUT_PATH) @@ -66,17 +75,23 @@ lib$(1).a: $(2) @$(CROSS_PREFIX)size $(OUT_PATH)/lib$(1).a endef -$(foreach MOD,$(notdir $(PROJECT_MODULES)), $(eval $(call makemod,$(MOD),$(notdir $(patsubst %.c,%.o,$(patsubst %.S,%.o,$($(MOD)_SRC_FILES))))))) +$(foreach MOD,$(notdir $(PROJECT_MODULES)), $(eval $(call makemod,$(MOD),$(notdir $(patsubst %.c,%.o,$(patsubst %.S,%.o,$(patsubst %.cpp,%.o,$($(MOD)_SRC_FILES)))))))) %.o: %.c @echo "*** compiling C file $< ***" - @$(CROSS_PREFIX)gcc $(SYMBOLS) $(CFLAGS) $(INCLUDES) -c $< -o $(OBJ_PATH)/$@ - @$(CROSS_PREFIX)gcc $(SYMBOLS) $(CFLAGS) $(INCLUDES) -c $< -MM > $(OBJ_PATH)/$(@:.o=.d) + @$(CROSS_PREFIX)$(CC) $(SYMBOLS) $(CFLAGS) $(INCLUDES) -c $< -o $(OBJ_PATH)/$@ + @$(CROSS_PREFIX)$(CC) $(SYMBOLS) $(CFLAGS) $(INCLUDES) -c $< -MM > $(OBJ_PATH)/$(@:.o=.d) %.o: %.S @echo "*** compiling asm file $< ***" - @$(CROSS_PREFIX)gcc $(SYMBOLS) $(CFLAGS) $(INCLUDES) -c $< -o $(OBJ_PATH)/$@ - @$(CROSS_PREFIX)gcc $(SYMBOLS) $(CFLAGS) $(INCLUDES) -c $< -MM > $(OBJ_PATH)/$(@:.o=.d) + @$(CROSS_PREFIX)$(CC) $(SYMBOLS) $(CFLAGS) $(INCLUDES) -c $< -o $(OBJ_PATH)/$@ + @$(CROSS_PREFIX)$(CC) $(SYMBOLS) $(CFLAGS) $(INCLUDES) -c $< -MM > $(OBJ_PATH)/$(@:.o=.d) + +%.o: %.cpp + @echo "*** compiling C++ file $< ***" + @$(CROSS_PREFIX)$(CXX) $(XSYMBOLS) $(CXXFLAGS) $(INCLUDES) -c $< -o $(OBJ_PATH)/$@ + @$(CROSS_PREFIX)$(CXX) $(XSYMBOLS) $(CXXFLAGS) $(INCLUDES) -c $< -MM > $(OBJ_PATH)/$(@:.o=.d) + -include $(wildcard $(OBJ_PATH)/*.d) @@ -84,7 +99,7 @@ all : $(PROJECT_NAME) $(PROJECT_NAME): $(foreach MOD,$(notdir $(PROJECT_MODULES)),lib$(MOD).a) $(PROJECT_OBJS) @echo "*** linking project $@ ***" - @$(CROSS_PREFIX)gcc $(LFLAGS) $(LD_FILE) -o $(OUT_PATH)/$(PROJECT_NAME).axf $(PROJECT_OBJ_FILES) $(SLAVE_OBJ_FILE) -L$(OUT_PATH) $(addprefix -l,$(notdir $(PROJECT_MODULES))) $(addprefix -L,$(EXTERN_LIB_FOLDERS)) $(addprefix -l,$(notdir $(EXTERN_LIBS))) + @$(CROSS_PREFIX)$(CXX) $(LFLAGS) $(LD_FILE) -o $(OUT_PATH)/$(PROJECT_NAME).axf $(PROJECT_OBJ_FILES) $(SLAVE_OBJ_FILE) -L$(OUT_PATH) $(addprefix -l,$(notdir $(PROJECT_MODULES))) $(addprefix -L,$(EXTERN_LIB_FOLDERS)) $(addprefix -l,$(notdir $(EXTERN_LIBS))) @$(CROSS_PREFIX)size $(OUT_PATH)/$(PROJECT_NAME).axf @$(CROSS_PREFIX)objcopy -v -O binary $(OUT_PATH)/$(PROJECT_NAME).axf $(OUT_PATH)/$(PROJECT_NAME).bin @echo "*** post-build ***" diff --git a/etc/ld/lpc11u68_lib.ld b/etc/ld/lpc11u68_lib.ld index 9a845ff..b06e28d 100644 --- a/etc/ld/lpc11u68_lib.ld +++ b/etc/ld/lpc11u68_lib.ld @@ -9,6 +9,7 @@ */ GROUP( + librdimon.a libgcc.a libc.a libm.a diff --git a/etc/ld/lpc1769_lib.ld b/etc/ld/lpc1769_lib.ld index 711c00f..9c07eaa 100644 --- a/etc/ld/lpc1769_lib.ld +++ b/etc/ld/lpc1769_lib.ld @@ -9,6 +9,7 @@ GROUP( + librdimon.a libgcc.a libc.a libm.a diff --git a/etc/ld/lpc4337_m0_lib.ld b/etc/ld/lpc4337_m0_lib.ld index 39785a9..bcf6bb3 100644 --- a/etc/ld/lpc4337_m0_lib.ld +++ b/etc/ld/lpc4337_m0_lib.ld @@ -8,6 +8,7 @@ */ GROUP( + librdimon.a libgcc.a libc.a libm.a diff --git a/etc/ld/lpc4337_m4_lib.ld b/etc/ld/lpc4337_m4_lib.ld index 8a9df12..4f25858 100644 --- a/etc/ld/lpc4337_m4_lib.ld +++ b/etc/ld/lpc4337_m4_lib.ld @@ -9,6 +9,7 @@ GROUP( + librdimon.a libgcc.a libc.a libm.a diff --git a/etc/ld/lpc54102_m0_lib.ld b/etc/ld/lpc54102_m0_lib.ld index 4e9a641..3020324 100644 --- a/etc/ld/lpc54102_m0_lib.ld +++ b/etc/ld/lpc54102_m0_lib.ld @@ -9,6 +9,7 @@ */ GROUP( + librdimon.a libgcc.a libc.a libm.a diff --git a/etc/ld/lpc54102_m4_lib.ld b/etc/ld/lpc54102_m4_lib.ld index 14e3542..7d47a28 100644 --- a/etc/ld/lpc54102_m4_lib.ld +++ b/etc/ld/lpc54102_m4_lib.ld @@ -9,6 +9,7 @@ */ GROUP( + librdimon.a libgcc.a libc.a libm.a diff --git a/etc/target/lpc11u68.mk b/etc/target/lpc11u68.mk index 4589e45..7321a5b 100644 --- a/etc/target/lpc11u68.mk +++ b/etc/target/lpc11u68.mk @@ -46,9 +46,14 @@ OBJ_PATH = $(OUT_PATH)/obj SYMBOLS += -DDEBUG -DCORE_M0PLUS -D__USE_LPCOPEN -D__CODE_RED \ -D__MTB_BUFFER_SIZE=256 -D__USE_ROMDIVIDE +XSYMBOLS += $(SYMBOLS) -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS + # Compilation flags CFLAGS := -Wall -ggdb3 -mcpu=cortex-m0 -mthumb -fdata-sections -ffunction-sections -fmessage-length=0 -fno-builtin +# Compilation CXX flags +CXXFLAGS := -Wall -ggdb3 -mcpu=cortex-m0 -mthumb -fdata-sections -ffunction-sections -fmessage-length=0 -fno-builtin + # Linking flags LFLAGS := -nostdlib -fno-builtin -mcpu=cortex-m0 -mthumb \ -Xlinker -Map=$(OUT_PATH)/$(PROY_NOMBRE).map \ diff --git a/etc/target/lpc1769.mk b/etc/target/lpc1769.mk index 9fd2306..88e5c45 100644 --- a/etc/target/lpc1769.mk +++ b/etc/target/lpc1769.mk @@ -44,10 +44,16 @@ CROSS_PREFIX ?= arm-none-eabi- # Defined symbols SYMBOLS := -DDEBUG -DCORE_M3 -D__USE_LPCOPEN -D__LPC17XX__ -D__CODE_RED +XSYMBOLS += $(SYMBOLS) -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS + # Compilation flags CFLAGS := -Wall -ggdb3 -mcpu=cortex-m3 -mthumb -fdata-sections \ -ffunction-sections -c +# Compilation CXX flags +CXXFLAGS := -Wall -ggdb3 -mcpu=cortex-m3 -mthumb -fdata-sections \ + -ffunction-sections -c + # Linking flags LFLAGS := -nostdlib -fno-builtin -mcpu=cortex-m3 -mthumb -Xlinker \ -Map=$(OUT_PATH)/$(PROJECT_NAME).map -Wl,--gc-sections diff --git a/etc/target/lpc4337_m0.mk b/etc/target/lpc4337_m0.mk index 3c53aa9..a07c6e2 100644 --- a/etc/target/lpc4337_m0.mk +++ b/etc/target/lpc4337_m0.mk @@ -46,9 +46,14 @@ OBJ_PATH = $(OUT_PATH)/obj SYMBOLS += -DDEBUG -DCORE_M0 -D__USE_LPCOPEN -D__LPC43XX__ -D__CODE_RED \ -D__MULTICORE_M0APP -DCORE_M0APP +XSYMBOLS += $(SYMBOLS) -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS + # Compilation flags CFLAGS := -Wall -ggdb3 -mcpu=cortex-m0 -mthumb -fdata-sections -ffunction-sections +# Compilation CXX flags +CXXFLAGS := -Wall -ggdb3 -mcpu=cortex-m0 -mthumb -fdata-sections -ffunction-sections + # Linking flags LFLAGS := -nostdlib -fno-builtin -mcpu=cortex-m0 -mthumb \ -Xlinker -Map=$(OUT_PATH)/$(PROJECT_NAME).map \ diff --git a/etc/target/lpc4337_m4.mk b/etc/target/lpc4337_m4.mk index 5d8f9a0..e388d38 100644 --- a/etc/target/lpc4337_m4.mk +++ b/etc/target/lpc4337_m4.mk @@ -47,10 +47,16 @@ SYMBOLS += -DDEBUG -DCORE_M4 -D__USE_LPCOPEN -D__LPC43XX__ -D__CODE_RED \ -DLPC43_MULTICORE_M0APP -D__MULTICORE_MASTER \ -D__MULTICORE_MASTER_SLAVE_M0APP +XSYMBOLS += $(SYMBOLS) -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS + # Compilation flags CFLAGS := -Wall -ggdb3 -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 \ -mfloat-abi=softfp -fdata-sections -ffunction-sections +# Compliation CXX flags +CXXFLAGS := -Wall -ggdb3 -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 \ + -mfloat-abi=softfp -fdata-sections -ffunction-sections + # Linking flags LFLAGS := -nostdlib -fno-builtin -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 \ -mfloat-abi=softfp -Xlinker -Map=$(OUT_PATH)/$(PROJECT_NAME).map \ diff --git a/etc/target/lpc54102_m0.mk b/etc/target/lpc54102_m0.mk index 4108686..b7734d6 100644 --- a/etc/target/lpc54102_m0.mk +++ b/etc/target/lpc54102_m0.mk @@ -46,9 +46,14 @@ OBJ_PATH = $(OUT_PATH)/obj SYMBOLS += -DDEBUG -DCORE_M0PLUS -D__USE_LPCOPEN -D__LPC5410X__ -D__CODE_RED \ -D__MULTICORE_M0SLAVE +XSYMBOLS += $(SYMBOLS) -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS + # Compilation flags CFLAGS := -Wall -ggdb3 -mcpu=cortex-m0 -mthumb -fdata-sections -ffunction-sections -fmessage-length=0 -fno-builtin +# Compilation CXX flags +CXXFLAGS := -Wall -ggdb3 -mcpu=cortex-m0 -mthumb -fdata-sections -ffunction-sections -fmessage-length=0 -fno-builtin + # Linking flags LFLAGS := -nostdlib -fno-builtin -mcpu=cortex-m0 -mthumb \ -Xlinker -Map=$(OUT_PATH)/$(PROY_NOMBRE).map \ diff --git a/etc/target/lpc54102_m4.mk b/etc/target/lpc54102_m4.mk index f3e7bdf..8cba4bd 100644 --- a/etc/target/lpc54102_m4.mk +++ b/etc/target/lpc54102_m4.mk @@ -46,10 +46,16 @@ OBJ_PATH = $(OUT_PATH)/obj SYMBOLS += -DDEBUG -DCORE_M4 -D__USE_LPCOPEN -D__LPC5410X__ -D__CODE_RED \ -D__MULTICORE_MASTER -D__MULTICORE_MASTER_SLAVE_M0SLAVE +XSYMBOLS += $(SYMBOLS) -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS + # Compilation flags CFLAGS := -Wall -ggdb3 -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 \ -mfloat-abi=softfp -fdata-sections -ffunction-sections +# Compilation CXX flags +CXXFLAGS := -Wall -ggdb3 -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 \ + -mfloat-abi=softfp -fdata-sections -ffunction-sections + # Linking flags LFLAGS := -nostdlib -fno-builtin -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 \ -mfloat-abi=softfp -Xlinker -Map=$(OUT_PATH)/$(PROJECT_NAME).map \ diff --git a/examples/blinky_cpp/Makefile b/examples/blinky_cpp/Makefile new file mode 100644 index 0000000..4a29f7d --- /dev/null +++ b/examples/blinky_cpp/Makefile @@ -0,0 +1,54 @@ +# Copyright 2016, Pablo Ridolfi +# All rights reserved. +# +# This file is part of Workspace. +# Changes: +# 2016-10-16: Iván Castellucci Vidal +# Added C++ sources to compilation process +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived from this +# software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + +# application name +PROJECT_NAME := $(notdir $(PROJECT)) + +# Modules needed by the application +PROJECT_MODULES := modules/$(TARGET)/base \ + modules/$(TARGET)/board \ + modules/$(TARGET)/chip + +# source files folder +PROJECT_SRC_FOLDERS := $(PROJECT)/src + +# header files folder +PROJECT_INC_FOLDERS := $(PROJECT)/inc + +# source files +PROJECT_C_FILES := $(wildcard $(PROJECT)/src/*.c) + +# Don't forget to add your CPP files to any C++ project +PROJECT_CXX_FILES := $(wildcard $(PROJECT)/src/*.cpp) +PROJECT_ASM_FILES := $(wildcard $(PROJECT)/src/*.S) diff --git a/examples/blinky_cpp/inc/main.h b/examples/blinky_cpp/inc/main.h new file mode 100644 index 0000000..d70e037 --- /dev/null +++ b/examples/blinky_cpp/inc/main.h @@ -0,0 +1,75 @@ +/* Copyright 2016, Pablo Ridolfi + * All rights reserved. + * + * This file is part of Workspace. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _MAIN_H_ +#define _MAIN_H_ + +/** \addtogroup blink Bare-metal blink example + ** @{ */ + +/*==================[inclusions]=============================================*/ + +/*==================[cplusplus]==============================================*/ + +#ifdef __cplusplus +extern "C" { +#endif + +/*==================[macros]=================================================*/ + +/** delay in milliseconds */ +#define DELAY_MS 500 + +/** led number to toggle */ +#define LED 0 + +/*==================[typedef]================================================*/ + +/*==================[external data declaration]==============================*/ + +/*==================[external functions declaration]=========================*/ + +/** @brief main function + * @return main function should never return + */ +int main(void); + +/*==================[cplusplus]==============================================*/ + +#ifdef __cplusplus +} +#endif + +/** @} doxygen end group definition */ +/*==================[end of file]============================================*/ +#endif /* #ifndef _MAIN_H_ */ diff --git a/examples/blinky_cpp/src/main.cpp b/examples/blinky_cpp/src/main.cpp new file mode 100644 index 0000000..31f5ae0 --- /dev/null +++ b/examples/blinky_cpp/src/main.cpp @@ -0,0 +1,109 @@ +/* Copyright 2016, Pablo Ridolfi + * All rights reserved. + * + * This file is part of Workspace. + * + * Changes: + * 2016-10-16: Iván Castellucci Vidal + * Blinky as a C++ project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ + +/** @brief This is a simple blink example. + */ + +/** \addtogroup blink Bare-metal blink example + ** @{ */ + +/*==================[inclusions]=============================================*/ + +#include "main.h" +#include "board.h" + +/*==================[macros and definitions]=================================*/ + +/*==================[internal data declaration]==============================*/ + +/*==================[internal functions declaration]=========================*/ + +/** @brief hardware initialization function + * @return none + */ +static void initHardware(void); + +/** @brief delay function + * @param t desired milliseconds to wait + */ +static void pausems(uint32_t t); + +/*==================[internal data definition]===============================*/ + +/** @brief used for delay counter */ +static uint32_t pausems_count; + +/*==================[external data definition]===============================*/ + +/*==================[internal functions definition]==========================*/ + +static void initHardware(void) +{ + Board_Init(); + SystemCoreClockUpdate(); + SysTick_Config(SystemCoreClock / 1000); +} + +static void pausems(uint32_t t) +{ + pausems_count = t; + while (pausems_count != 0) { + __WFI(); + } +} + +/*==================[external functions definition]==========================*/ + +void SysTick_Handler(void) +{ + if(pausems_count > 0) pausems_count--; +} + +int main(void) +{ + initHardware(); + + while (1) + { + Board_LED_Toggle(LED); + pausems(DELAY_MS); + } +} + +/** @} doxygen end group definition */ + +/*==================[end of file]============================================*/ diff --git a/modules/lpc4337_m4/ciaa/inc/ciaaAIN.h b/modules/lpc4337_m4/ciaa/inc/ciaaAIN.h index 6e2d2c0..97620d5 100644 --- a/modules/lpc4337_m4/ciaa/inc/ciaaAIN.h +++ b/modules/lpc4337_m4/ciaa/inc/ciaaAIN.h @@ -36,7 +36,15 @@ #include "chip.h" +#ifdef __cplusplus +extern "C" { +#endif + void ciaaAINInit(void); uint16_t ciaaAINRead(uint8_t input); +#ifdef __cplusplus +} +#endif + #endif /* CIAAAIN_H_ */ diff --git a/modules/lpc4337_m4/ciaa/inc/ciaaAOUT.h b/modules/lpc4337_m4/ciaa/inc/ciaaAOUT.h index 5678526..7787842 100644 --- a/modules/lpc4337_m4/ciaa/inc/ciaaAOUT.h +++ b/modules/lpc4337_m4/ciaa/inc/ciaaAOUT.h @@ -36,7 +36,15 @@ #include "chip.h" +#ifdef __cplusplus +extern "C" { +#endif + void ciaaAOUTInit(void); void ciaaAOUTSet(float level); +#ifdef __cplusplus +} +#endif + #endif /* CIAAAOUT_H_ */ diff --git a/modules/lpc4337_m4/ciaa/inc/ciaaI2C.h b/modules/lpc4337_m4/ciaa/inc/ciaaI2C.h index b33e2ab..9db7598 100644 --- a/modules/lpc4337_m4/ciaa/inc/ciaaI2C.h +++ b/modules/lpc4337_m4/ciaa/inc/ciaaI2C.h @@ -36,8 +36,16 @@ #include "chip.h" +#ifdef __cplusplus +extern "C" { +#endif + void ciaaI2CInit(void); Status ciaaI2CWrite(uint8_t sl_addr, uint8_t * buffer, int len); Status ciaaI2CRead(uint8_t sl_addr, uint8_t * buffer, int len); +#ifdef __cplusplus +} +#endif + #endif /* CIAAI2C_H_ */ diff --git a/modules/lpc4337_m4/ciaa/inc/ciaaIO.h b/modules/lpc4337_m4/ciaa/inc/ciaaIO.h index c9462d9..07dac14 100644 --- a/modules/lpc4337_m4/ciaa/inc/ciaaIO.h +++ b/modules/lpc4337_m4/ciaa/inc/ciaaIO.h @@ -36,6 +36,10 @@ #include "chip.h" +#ifdef __cplusplus +extern "C" { +#endif + #define ciaaDigitalInputs() ((uint8_t)((Chip_GPIO_ReadValue(LPC_GPIO_PORT,3) & (0x0F<<11))>>7)|(Chip_GPIO_ReadValue(LPC_GPIO_PORT,2) & 0x0F)) typedef struct @@ -49,4 +53,8 @@ uint32_t ciaaWriteOutput(uint32_t outputNumber, uint32_t value); uint32_t ciaaReadInput(uint32_t inputNumber); void ciaaToggleOutput(uint32_t outputNumber); +#ifdef __cplusplus +} +#endif + #endif /* CIAAIO_H_ */ diff --git a/modules/lpc4337_m4/ciaa/inc/ciaaNVM.h b/modules/lpc4337_m4/ciaa/inc/ciaaNVM.h index 2595183..f75547e 100644 --- a/modules/lpc4337_m4/ciaa/inc/ciaaNVM.h +++ b/modules/lpc4337_m4/ciaa/inc/ciaaNVM.h @@ -37,10 +37,18 @@ #include "chip.h" #include "ciaaI2C.h" +#ifdef __cplusplus +extern "C" { +#endif + void mem48Read(uint8_t addr, void * buffer, int len); void mem48Write(uint8_t addr, void * buffer, int len); void memRead(uint16_t addr, void * buffer, int len); void memWrite(uint16_t addr, void * buffer, int len); void ciaaNVMInit(void); +#ifdef __cplusplus +} +#endif + #endif /* CIAANVM_H_ */ diff --git a/modules/lpc4337_m4/ciaa/inc/ciaaUART.h b/modules/lpc4337_m4/ciaa/inc/ciaaUART.h index 7b61725..436a10f 100644 --- a/modules/lpc4337_m4/ciaa/inc/ciaaUART.h +++ b/modules/lpc4337_m4/ciaa/inc/ciaaUART.h @@ -37,6 +37,10 @@ #include "chip.h" #include "string.h" +#ifdef __cplusplus +extern "C" { +#endif + typedef enum _ciaaUarts_e { CIAA_UART_485 = 0, @@ -62,4 +66,8 @@ void ciaaUARTInit(void); int uartSend(ciaaUART_e nUART, void * data, int datalen); int uartRecv(ciaaUART_e nUART, void * data, int datalen); +#ifdef __cplusplus +} +#endif + #endif /* CIAAUART_H_ */