Skip to content

Commit

Permalink
Update formate and comments
Browse files Browse the repository at this point in the history
Change-Id: Ic382bcb3d488e7e685ea934b22dd60f8fa84e8fb
  • Loading branch information
wschang0 committed May 9, 2024
1 parent d452921 commit 57c0f61
Show file tree
Hide file tree
Showing 9 changed files with 313 additions and 316 deletions.
19 changes: 19 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${default}"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"configurationProvider": "ms-vscode.cmake-tools",
"compilerPath": "c:/Keil_v5/ARM/ARMCLANG/bin/armclang.exe",
"intelliSenseMode": "windows-gcc-arm"
}
],
"version": 4
}
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"files.associations": {
"dfu_transfer.h": "c"
"dfu_transfer.h": "c",
"stdio.h": "c",
"numicro.h": "c"
},
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools"
}
46 changes: 15 additions & 31 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
cmake_minimum_required(VERSION 3.21)
cmake_policy(SET CMP0123 NEW)


# Create a symbolic link from ${base_name} in the binary directory
# to the corresponding path in the source directory.
function(link_to_source base_name)
# Get OS dependent path to use in `execute_process`
if (CMAKE_HOST_WIN32)
#mklink is an internal command of cmd.exe it can only work with \
if(CMAKE_HOST_WIN32)
# mklink is an internal command of cmd.exe it can only work with \
string(REPLACE "/" "\\" link "${CMAKE_CURRENT_BINARY_DIR}/${base_name}")
string(REPLACE "/" "\\" target "${CMAKE_CURRENT_SOURCE_DIR}/${base_name}")
else()
set(link "${CMAKE_CURRENT_BINARY_DIR}/${base_name}")
set(target "${CMAKE_CURRENT_SOURCE_DIR}/${base_name}")
endif()

if (NOT EXISTS ${link})
if (CMAKE_HOST_UNIX)
if(NOT EXISTS ${link})
if(CMAKE_HOST_UNIX)
set(command ln -s ${target} ${link})
else()
if (IS_DIRECTORY ${target})
if(IS_DIRECTORY ${target})
set(command cmd.exe /c mklink /j ${link} ${target})
else()
set(command cmd.exe /c mklink /h ${link} ${target})
Expand All @@ -30,7 +29,7 @@ function(link_to_source base_name)
RESULT_VARIABLE result
ERROR_VARIABLE output)

if (NOT ${result} EQUAL 0)
if(NOT ${result} EQUAL 0)
message(FATAL_ERROR "Could not create symbolic link for: ${target} --> ${output}")
endif()
endif()
Expand All @@ -41,8 +40,8 @@ set(CMAKE_SYSTEM_VERSION "5")
set(CMAKE_SYSTEM_PROCESSOR ARM)

set(TOOLCHAIN_PATH C:/Keil_v5/ARM/ARMCLANG)
find_program(ARM_CC NAMES armclang PATHS ${TOOLCHAIN_PATH}/bin REQUIRED NO_DEFAULT_PATH)
find_program(ARM_CXX NAMES armclang PATHS ${TOOLCHAIN_PATH}/bin REQUIRED NO_DEFAULT_PATH)
find_program(ARM_CC NAMES armclang PATHS ${TOOLCHAIN_PATH}/bin REQUIRED NO_DEFAULT_PATH)
find_program(ARM_CXX NAMES armclang PATHS ${TOOLCHAIN_PATH}/bin REQUIRED NO_DEFAULT_PATH)
find_program(ARM_ASM NAMES armasm PATHS ${TOOLCHAIN_PATH}/bin REQUIRED NO_DEFAULT_PATH)
find_program(ARM_AR NAMES armar PATHS ${TOOLCHAIN_PATH}/bin REQUIRED NO_DEFAULT_PATH)
find_program(ARM_LINK NAMES armlink PATHS ${TOOLCHAIN_PATH}/bin REQUIRED NO_DEFAULT_PATH)
Expand All @@ -64,24 +63,22 @@ set(LINK_MCU_CORE "Cortex-M4.fp.sp")
set(STACK_SIZE 0x4000)
set(HEAP_SIZE 0x20000)

#SET(CMAKE_C_FLAGS "-mcpu=cortex-m4 -Wno-ignored-optimization-argument -Wno-unused-command-line-argument -Wall -Wno-error=cpp -c -fdata-sections -ffunction-sections -fshort-enums -fshort-wchar -funsigned-char -masm=auto -nostdlib -mfpu=none -g -std=c99 -D__MICROLIB")
#SET(CMAKE_CXX_FLAGS "-mcpu=cortex-m4 -Wno-ignored-optimization-argument -Wno-unused-command-line-argument -Wall -Wno-error=cpp -c -fdata-sections -ffunction-sections -fshort-enums -fshort-wchar -funsigned-char -masm=auto -nostdlib -mfpu=none -g -D__MICROLIB")
# SET(CMAKE_C_FLAGS "-mcpu=cortex-m4 -Wno-ignored-optimization-argument -Wno-unused-command-line-argument -Wall -Wno-error=cpp -c -fdata-sections -ffunction-sections -fshort-enums -fshort-wchar -funsigned-char -masm=auto -nostdlib -mfpu=none -g -std=c99 -D__MICROLIB")
# SET(CMAKE_CXX_FLAGS "-mcpu=cortex-m4 -Wno-ignored-optimization-argument -Wno-unused-command-line-argument -Wall -Wno-error=cpp -c -fdata-sections -ffunction-sections -fshort-enums -fshort-wchar -funsigned-char -masm=auto -nostdlib -mfpu=none -g -D__MICROLIB")
set(C_FLAGS "--target=arm-arm-none-eabi -mcpu=cortex-m4+fp -mfloat-abi=hard -c -fno-rtti -funsigned-char -fshort-enums -fshort-wchar -D__MICROLIB -gdwarf-3 -O2 -fno-function-sections -Wno-packed -Wno-missing-variable-declarations -Wno-missing-prototypes -Wno-missing-noreturn -Wno-sign-conversion -Wno-nonportable-include-path -Wno-reserved-id-macro -Wno-unused-macros -Wno-documentation-unknown-command -Wno-documentation -Wno-license-management -Wno-parentheses-equality -D__MICROLIB -DMBEDTLS_CONFIG_FILE=mbedtls_config.h -Ic:/Keil_v5/ARM/ARMCLANG/include")
set(CMAKE_C_FLAGS "-xc -std=c99 ${C_FLAGS}")
set(CMAKE_CXX_FLAGS ${C_FLAGS})
set(CMAKE_ASM_FLAGS "--cpu Cortex-M4.fp.sp -g --16 --apcs=interwork --pd \"__MICROLIB SETA 1\" --pd \"Stack_Size SETA ${STACK_SIZE}\" --pd \"Heap_Size SETA ${HEAP_SIZE}\"" )
set(CMAKE_ASM_FLAGS "--cpu Cortex-M4.fp.sp -g --16 --apcs=interwork --pd \"__MICROLIB SETA 1\" --pd \"Stack_Size SETA ${STACK_SIZE}\" --pd \"Heap_Size SETA ${HEAP_SIZE}\"")
set(CMAKE_EXECUTABLE_SUFFIX ".axf")


project(m460bsp)


function(create_project PRJ)
add_executable(${PRJ} ${ARGN})
target_link_libraries(${PRJ} system_startup standard_driver)

target_link_options(${PRJ}
PUBLIC
PUBLIC
--cpu=Cortex-M4.fp.sp
--library_type=microlib
--ro-base 0x00000000
Expand All @@ -108,10 +105,7 @@ function(create_project PRJ)
)
endfunction()




set(BSP_DIR ${CMAKE_CURRENT_LIST_DIR})
set(BSP_DIR ${CMAKE_CURRENT_LIST_DIR})

include_directories(${TOOLCHAIN_PATH}/include)
include_directories(${BSP_DIR}/Library/CMSIS/Include)
Expand All @@ -130,35 +124,25 @@ add_subdirectory(${BSP_DIR}/Library/NuMaker/xmodem)
add_subdirectory(${BSP_DIR}/ThirdParty/mbedtls-3.1.0/library)

target_include_directories(mbedcrypto
PUBLIC
PUBLIC
${TOOLCHAIN_PATH}/include
)


# Library for mbedtls test
add_library(test_lib
${BSP_DIR}/ThirdParty/mbedtls-3.1.0/tests/src/helpers.c
${BSP_DIR}/ThirdParty/mbedtls-3.1.0/tests/src/random.c
${BSP_DIR}/ThirdParty/mbedtls-3.1.0/tests/src/psa_crypto_helpers.c
)
target_include_directories(test_lib
PUBLIC
PUBLIC
${BSP_DIR}/ThirdParty/mbedtls-3.1.0/tests/include

)



# Build sample code
add_subdirectory(${BSP_DIR}/SampleCode/CortexM4)
add_subdirectory(${BSP_DIR}/SampleCode/StdDriver)
add_subdirectory(${BSP_DIR}/SampleCode/ISP)
add_subdirectory(${BSP_DIR}/SampleCode/PowerManagement)
create_project(Hard_Fault_Sample ${BSP_DIR}/SampleCode/Hard_Fault_Sample/main.c)
create_project(Template ${BSP_DIR}/SampleCode/Template/main.c)






8 changes: 3 additions & 5 deletions SampleCode/CortexM4/BitBand/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* @version V1.00
* @brief Demonstrate the usage of CortexM4 BitBand.
*
*
* @copyright (C) 2016 Nuvoton Technology Corp. All rights reserved.
* @copyright SPDX-License-Identifier: Apache-2.0
* @copyright Copyright (C) 2016 Nuvoton Technology Corp. All rights reserved.
*****************************************************************************/
#include <stdio.h>
#include "NuMicro.h"
Expand Down Expand Up @@ -96,6 +96,4 @@ int main()
BitBand_Test();

while(1);
}

/*** (C) COPYRIGHT 2016 Nuvoton Technology Corp. ***/
}
Loading

0 comments on commit 57c0f61

Please sign in to comment.