Skip to content

Commit 559e987

Browse files
committedMar 7, 2018
Added skeleton for Cortex-M0 of LPC43S37
1 parent 22c7c5a commit 559e987

File tree

19 files changed

+1587
-3
lines changed

19 files changed

+1587
-3
lines changed
 

‎.cproject

+139
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
####################################################################################################
2+
# \file makefile
3+
# \brief Makefile for demo_lpc43s37-m0 application
4+
# \author C. Jimenez
5+
# \copyright Copyright(c) 2017 Cedric Jimenez
6+
#
7+
# This file is part of Nano-OS.
8+
#
9+
# Nano-OS is free software: you can redistribute it and/or modify
10+
# it under the terms of the GNU Lesser General Public License as published by
11+
# the Free Software Foundation, either version 3 of the License, or
12+
# (at your option) any later version.
13+
#
14+
# Nano-OS is distributed in the hope that it will be useful,
15+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
# GNU Lesser General Public License for more details.
18+
#
19+
# You should have received a copy of the GNU Lesser General Public License
20+
# along with Nano-OS. If not, see <http://www.gnu.org/licenses/>.
21+
####################################################################################################
22+
23+
# Locating the root directory
24+
ROOT_DIR := ../../../..
25+
26+
# Project name
27+
PROJECT_NAME := demo_lpc43s37-m0
28+
29+
# Build type
30+
BUILD_TYPE := APP
31+
32+
# Projects that need to be build before the project or containing necessary include paths
33+
PROJECT_DEPENDENCIES :=
34+
35+
# Libraries needed by the project
36+
PROJECT_LIBS = libs/nano-os \
37+
$(TARGET_BSP) \
38+
$(TARGET_DEPENDENCIES) \
39+
libs/nano-os-segger-rtt-link
40+
41+
42+
# Including common makefile definitions
43+
include $(ROOT_DIR)/build/make/generic_makefile
44+
45+
46+
# Rules for building the source files
47+
$(BIN_DIR)/$(OUTPUT_NAME): $(BIN_DEPENDENCIES)
48+
@echo "Linking $(notdir $@)..."
49+
$(DISP)$(LD) $(LINK_OUTPUT_CMD) $@ $(LDFLAGS) $(OBJECT_FILES) $(LIBS) $(TARGET_LIB_DIRS) $(TARGET_LIBS)
50+
51+
52+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
####################################################################################################
2+
# \file makefile.inc
3+
# \brief Makefile for the include files of demo_lpc43s37-m0 application
4+
# \author C. Jimenez
5+
# \copyright Copyright(c) 2017 Cedric Jimenez
6+
#
7+
# This file is part of Nano-OS.
8+
#
9+
# Nano-OS is free software: you can redistribute it and/or modify
10+
# it under the terms of the GNU Lesser General Public License as published by
11+
# the Free Software Foundation, either version 3 of the License, or
12+
# (at your option) any later version.
13+
#
14+
# Nano-OS is distributed in the hope that it will be useful,
15+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
# GNU Lesser General Public License for more details.
18+
#
19+
# You should have received a copy of the GNU Lesser General Public License
20+
# along with Nano-OS. If not, see <http://www.gnu.org/licenses/>.
21+
####################################################################################################
22+
23+
# Application directory
24+
APPLICATION_DIR := $(ROOT_DIR)/src/apps/demo_lpc43s37
25+
26+
# Source directories
27+
SOURCE_DIRS := $(APPLICATION_DIR)/demo_lpc43s37-m0 \
28+
$(APPLICATION_DIR)/common
29+
30+
# Project specific include directories
31+
PROJECT_INC_DIRS := $(PROJECT_INC_DIRS) \
32+
$(SOURCE_DIRS)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
####################################################################################################
2+
# \file makefile
3+
# \brief Makefile for bsp_lpc43s37-m0 BSP
4+
# \author C. Jimenez
5+
# \copyright Copyright(c) 2017 Cedric Jimenez
6+
#
7+
# This file is part of Nano-OS.
8+
#
9+
# Nano-OS is free software: you can redistribute it and/or modify
10+
# it under the terms of the GNU Lesser General Public License as published by
11+
# the Free Software Foundation, either version 3 of the License, or
12+
# (at your option) any later version.
13+
#
14+
# Nano-OS is distributed in the hope that it will be useful,
15+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
# GNU Lesser General Public License for more details.
18+
#
19+
# You should have received a copy of the GNU Lesser General Public License
20+
# along with Nano-OS. If not, see <http://www.gnu.org/licenses/>.
21+
####################################################################################################
22+
23+
# Locating the root directory
24+
ROOT_DIR := ../../../..
25+
26+
# Project name
27+
PROJECT_NAME := bsp_lpc43s37-m0
28+
29+
# Build type
30+
BUILD_TYPE := LIB
31+
32+
# Projects that need to be build before the project or containing necessary include paths
33+
PROJECT_DEPENDENCIES := libs/nano-os
34+
35+
36+
# Including common makefile definitions
37+
include $(ROOT_DIR)/build/make/generic_makefile
38+
39+
40+
# Rules for building the source files
41+
$(BIN_DIR)/$(OUTPUT_NAME): $(BIN_DEPENDENCIES)
42+
@echo "Creating archive $(notdir $@)..."
43+
$(DISP)$(AR) $(ARFLAGS) $@ $(OBJECT_FILES)
44+
45+
46+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
####################################################################################################
2+
# \file makefile.inc
3+
# \brief Makefile for the include files of bsp_lpc43s37-m0 BSP
4+
# \author C. Jimenez
5+
# \copyright Copyright(c) 2017 Cedric Jimenez
6+
#
7+
# This file is part of Nano-OS.
8+
#
9+
# Nano-OS is free software: you can redistribute it and/or modify
10+
# it under the terms of the GNU Lesser General Public License as published by
11+
# the Free Software Foundation, either version 3 of the License, or
12+
# (at your option) any later version.
13+
#
14+
# Nano-OS is distributed in the hope that it will be useful,
15+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
# GNU Lesser General Public License for more details.
18+
#
19+
# You should have received a copy of the GNU Lesser General Public License
20+
# along with Nano-OS. If not, see <http://www.gnu.org/licenses/>.
21+
####################################################################################################
22+
23+
# Library directory
24+
BSP_DIR := $(ROOT_DIR)/src/bsps
25+
LIBRARY_DIR := $(BSP_DIR)/bsp_lpc43s37/bsp_lpc43s37-m0
26+
27+
# Source directories
28+
SOURCE_DIRS := $(LIBRARY_DIR) \
29+
$(LIBRARY_DIR)/$(COMPILER_NAME) \
30+
$(LIBRARY_DIR)/../common \
31+
$(LIBRARY_DIR)/../common/device
32+
33+
# Project specific include directories
34+
PROJECT_INC_DIRS := $(PROJECT_INC_DIRS) \
35+
$(BSP_DIR) \
36+
$(foreach LIB_DIR, $(SOURCE_DIRS), $(LIB_DIR))
37+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
####################################################################################################
2+
# \file arm-gcc-lpc43s37-m0.target
3+
# \brief LPC43S37 (M0 Core) with ARM GCC target definition
4+
# \author C. Jimenez
5+
# \copyright Copyright(c) 2017 Cedric Jimenez
6+
#
7+
# This file is part of Nano-OS.
8+
#
9+
# Nano-OS is free software: you can redistribute it and/or modify
10+
# it under the terms of the GNU Lesser General Public License as published by
11+
# the Free Software Foundation, either version 3 of the License, or
12+
# (at your option) any later version.
13+
#
14+
# Nano-OS is distributed in the hope that it will be useful,
15+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
# GNU Lesser General Public License for more details.
18+
#
19+
# You should have received a copy of the GNU Lesser General Public License
20+
# along with Nano-OS. If not, see <http://www.gnu.org/licenses/>.
21+
####################################################################################################
22+
23+
# Include toolchain
24+
include $(ROOT_DIR)/build/make/compilers/arm-gcc-cortex-m.compiler
25+
26+
27+
# Target ARCH and CPU
28+
TARGET_ARCH=cortex-m0
29+
TARGET_CPU=
30+
31+
# Target BSP
32+
TARGET_BSP=bsps/bsp_lpc43s37/bsp_lpc43s37-m0
33+
34+
# Target lib dependencies
35+
TARGET_DEPENDENCIES=
36+
37+
# Target specific include directories
38+
TARGET_INC_DIRS=
39+
40+
# Target specific lib directories
41+
TARGET_LIB_DIRS=-L$(TOOLCHAIN_PATH)/arm-none-eabi/lib/thumb/v6-m -L$(TOOLCHAIN_PATH)/lib/gcc/arm-none-eabi/7.2.1/thumb/v6-m
42+
43+
# Target specific libraries
44+
TARGET_LIBS=-lgcc -lc -lnosys
45+
46+
# Target implementation for the project defines
47+
TARGET_PROJECT_DEFINES=$(foreach PROJECT_DEFINE, $(PROJECT_DEFINES), -D$(PROJECT_DEFINE))
48+
49+
# Nano OS configuration file directory
50+
NANO_OS_CONFIG_FILE_DIR=$(ROOT_DIR)/src/$(TARGET_BSP)/nano_os_config
51+
52+
53+
# Optimisation level
54+
OPTIMIZATION_LEVEL = -O0
55+
56+
# Disabled warnings
57+
DISABLED_WARNINGS =
58+
59+
# Toolchain flags
60+
COMMON_FLAGS = -g -Wall -mthumb -mcpu=cortex-m0 -march=armv6-m -mapcs-frame -mlittle-endian $(OPTIMIZATION_LEVEL) $(TARGET_PROJECT_DEFINES)
61+
CFLAGS = -DCORE_M0 -DLPC43XX_CORE_M0APP -Wno-main $(COMMON_FLAGS) -fsigned-char $(PROJECT_CFLAGS)
62+
CXXFLAGS = $(COMMON_FLAGS) $(DISABLED_WARNINGS) -fsigned-char $(PROJECT_CXXFLAGS) -std=c++14 -pedantic -fno-exceptions -fno-unwind-tables -fno-rtti -fno-gnu-keywords -fno-use-cxa-atexit
63+
ASFLAGS = $(COMMON_FLAGS) $(OPTIMIZATION_LEVEL) $(PROJECT_ASFLAGS)
64+
LDFLAGS = -e _start -Map $(patsubst /cygdrive/$(DRIVE_LETTER)%,$(DRIVE_LETTER):%, $(abspath $(patsubst %.elf, %.map, $(BIN_DIR)/$(OUTPUT_NAME)))) -EL -g --gc-sections -dT $(ROOT_DIR)/src/bsps/bsp_lpc43s37/bsp_lpc43s37-m0/gcc/lpc43s37-m0.ld $(PROJECT_LDFLAGS)
65+
ARFLAGS = -c -r $(PROJECT_ARFLAGS)
66+
67+
# Number of times the libraries names shall be duplicated in the command line
68+
TARGET_DUP_COUNT := 1 2

‎src/apps/demo_lpc43s37/common/heartbeat_task.c

+2
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ nano_os_error_t HEARTBEAT_TASK_Init(void)
8686
task_init_data.stack_size = TASK_STACK_SIZE;
8787
task_init_data.task_func = HEARTBEAT_TASK_Task;
8888
task_init_data.param = NULL;
89+
#if CORE_M4
8990
task_init_data.port_init_data.is_priviledged = true;
91+
#endif /* CORE_M4 */
9092
ret = NANO_OS_TASK_Create(&heartbeat_task, &task_init_data);
9193

9294
/* Register commands to the console module */

‎src/apps/demo_lpc43s37/common/ipc_task.c

+2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ nano_os_error_t IPC_TASK_Init(void)
5656
task_init_data.stack_size = TASK_STACK_SIZE;
5757
task_init_data.task_func = IPC_TASK_Task;
5858
task_init_data.param = NULL;
59+
#ifdef CORE_M4
5960
task_init_data.port_init_data.is_priviledged = true;
61+
#endif /* CORE_M4 */
6062
ret = NANO_OS_TASK_Create(&ipc_task, &task_init_data);
6163

6264
return ret;

‎src/apps/demo_lpc43s37/demo_lpc43s37-m4/main.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ static void* MAIN_Task(void* param)
6262

6363
/* Release reset on Cortex-M0 */
6464
LPC_RGU->RESET_CTRL[1u] = (1u << 24u);
65-
LPC_CREG->M0APPMEMMAP = 0x00080000u;
65+
LPC_CREG->M0APPMEMMAP = 0x1B000000;
6666
LPC_RGU->RESET_CTRL[1u] = 0u;
6767

6868

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
/*
2+
Copyright(c) 2017 Cedric Jimenez
3+
4+
This file is part of Nano-OS.
5+
6+
Nano-OS is free software: you can redistribute it and/or modify
7+
it under the terms of the GNU Lesser General Public License as published by
8+
the Free Software Foundation, either version 3 of the License, or
9+
(at your option) any later version.
10+
11+
Nano-OS is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
GNU Lesser General Public License for more details.
15+
16+
You should have received a copy of the GNU Lesser General Public License
17+
along with Nano-OS. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
20+
#include "bsp.h"
21+
#include "chip_lpc43xx.h"
22+
23+
24+
/** \brief Get the SYSTICK input clock frequency in Hz */
25+
uint32_t NANO_OS_PORT_USER_GetSystickInputClockFreq(void)
26+
{
27+
/* 204 MHz */
28+
return 204000000u;
29+
}
30+
31+
32+
/** \brief Initialize the board */
33+
nano_os_error_t NANO_OS_BSP_Init(void)
34+
{
35+
uint8_t i;
36+
nano_os_error_t ret = NOS_ERR_SUCCESS;
37+
38+
/* Turn on power on GPIO */
39+
LPC_CCU1->CLKCCU[CLK_MX_SCU].CFG = (1u << 0u);
40+
LPC_CCU1->CLKCCU[CLK_MX_GPIO].CFG = (1u << 0u);
41+
42+
/* Leds 0,1,2 =>
43+
* P6_9 : GPIO3[5]
44+
* P6_11 : GPIO3[7]
45+
* P2_7 : GPIO0[7] */
46+
LPC_SCU->SFSP[3u][5u] = (1u << 7u);
47+
LPC_SCU->SFSP[3u][7u] = (1u << 7u);
48+
LPC_SCU->SFSP[0u][7u] = (1u << 7u);
49+
LPC_GPIO_PORT->DIR[3u] |= (1u << 5u) | (1u << 7u);
50+
LPC_GPIO_PORT->DIR[0u] |= (1u << 7u);
51+
52+
/* Turn all leds off */
53+
for (i = 0; i < 3u; i++)
54+
{
55+
NANO_OS_BSP_LedOff(i);
56+
}
57+
58+
return ret;
59+
}
60+
61+
/** \brief Get the number of LEDs available */
62+
uint8_t NANO_OS_BSP_GetLedCount(void)
63+
{
64+
return 3u;
65+
}
66+
67+
68+
/** \brief Turn ON the specified LED */
69+
void NANO_OS_BSP_LedOn(const uint8_t led)
70+
{
71+
switch(led)
72+
{
73+
case 0:
74+
LPC_GPIO_PORT->CLR[3u] = NANO_OS_CAST(uint32_t, (1u << 5u));
75+
break;
76+
case 1:
77+
LPC_GPIO_PORT->CLR[3u] = NANO_OS_CAST(uint32_t, (1u << 7u));
78+
break;
79+
case 2:
80+
LPC_GPIO_PORT->CLR[0u] = NANO_OS_CAST(uint32_t, (1u << 7u));
81+
break;
82+
83+
default:
84+
/* Do nothing */
85+
break;
86+
}
87+
}
88+
89+
/** \brief Turn OFF the specified LED */
90+
void NANO_OS_BSP_LedOff(const uint8_t led)
91+
{
92+
switch(led)
93+
{
94+
case 0:
95+
LPC_GPIO_PORT->SET[3u] = NANO_OS_CAST(uint32_t, (1u << 5u));
96+
break;
97+
case 1:
98+
LPC_GPIO_PORT->SET[3u] = NANO_OS_CAST(uint32_t, (1u << 7u));
99+
break;
100+
case 2:
101+
LPC_GPIO_PORT->SET[0u] = NANO_OS_CAST(uint32_t, (1u << 7u));
102+
break;
103+
104+
default:
105+
/* Do nothing */
106+
break;
107+
}
108+
}
109+
110+
/** \brief Get the LED I/O registers memory area description */
111+
void NANO_OS_BSP_GetLedIoRegistersMem(uint32_t* const start_address, uint32_t* const size)
112+
{
113+
/* Check parameters */
114+
if ((start_address != NULL) && (size != NULL))
115+
{
116+
(*start_address) = LPC_GPIO_PORT_BASE;
117+
(*size) = 0xC000u;
118+
}
119+
}
120+
121+
/** \brief Get the UART registers memory area description */
122+
void NANO_OS_BSP_GetUartIoRegistersMem(uint32_t* const start_address, uint32_t* const size)
123+
{
124+
/* Check parameters */
125+
if ((start_address != NULL) && (size != NULL))
126+
{
127+
(*start_address) = LPC_USART0_BASE;
128+
(*size) = 0x40000u;
129+
}
130+
}

0 commit comments

Comments
 (0)