├── .github
├── pull_request_template.md
└── workflows
│ ├── ci.yml
│ └── release.yml
├── .gitignore
├── .gitmodules
├── CMakeLists.txt
├── README.md
├── README_TEMPLATE.md
├── cmake
├── arm-gcc-toolchain.cmake
├── debug_jlink.cmake
├── debug_pyocd.cmake
└── flags.cmake
├── doc
├── .gitkeep
├── DEVELOP_STRATEGY.md
├── DOCUMENTATION_STYLE.md
└── img
│ └── git_workflow.png
├── project.yml
├── setup.ps1
├── setup.sh
├── src
├── board
│ ├── board.c
│ └── board.h
├── error.h
├── main.c
└── version.h
├── test
└── support
│ └── .gitkeep
└── vendor
├── .gitkeep
└── ceedling
└── template
├── inc_boilerplate.h
└── src_boilerplate.c
/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | **Pull Request Pre-Flight Checklist**
2 | - [ ] Did you add new unit tests for all applicable source code?
3 | - [ ] Did you run through a basic set of functional tests to prove out these changes?
4 | - [ ] If this is a "release" (aka a PR into the ```main``` branch), did you increment/set the version in ```version.h``` accordingly?
5 |
6 | **What issues does this close? (The keyword ```closes``` followed by a #ISSUE_NUMBER will automatically close the issue when this PR is completed. i.e ```closes #10```)**
--------------------------------------------------------------------------------
/.github/workflows/ci.yml:
--------------------------------------------------------------------------------
1 | name: CI - Compile & Test
2 |
3 | on:
4 | pull_request:
5 | branches: [ main, develop ]
6 |
7 | jobs:
8 | build:
9 | runs-on: ubuntu-latest
10 | steps:
11 | - uses: actions/checkout@v3
12 | with:
13 | submodules: recursive
14 |
15 | - name: Install Ruby & Ceedling
16 | run: |
17 | sudo apt-get install ruby
18 | sudo gem install ceedling
19 | sudo python -m pip install gcovr
20 |
21 | - name: Download GNU ARM embedded toolchain
22 | run: >-
23 | wget --no-check-certificate -O ~/gcc_toolchain.tar.bz2
24 | 'https://developer.arm.com/-/media/Files/downloads/gnu-rm/10-2020q4/gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz'
25 |
26 | - name: Extract the toolchain
27 | run: tar -xjf ~/gcc_toolchain.tar.bz2 -C ~/
28 |
29 | - name: Setup & Build - RELEASE
30 | run: |
31 | export PATH=$PATH:~/gcc-arm-none-eabi-10-2020-q4-major/bin
32 | ./setup.sh release
33 | cd build && make -j8
34 |
35 | - name: Setup & Build - DEBUG
36 | run: |
37 | export PATH=$PATH:~/gcc-arm-none-eabi-10-2020-q4-major/bin
38 | ./setup.sh
39 | cd build && make -j8
40 |
41 | - name: Run Unit tests
42 | run: cd build && make test
43 |
44 | - uses: codecov/codecov-action@v1
45 | with:
46 | token: ${{ secrets.CODECOV_REPO_TOKEN }}
47 | files: ./build/artifacts/gcov/GcovCoverageCobertura.xml
48 | fail_ci_if_error: true # optional (default = false)
49 | verbose: true # optional (default = false)
50 |
--------------------------------------------------------------------------------
/.github/workflows/release.yml:
--------------------------------------------------------------------------------
1 | name: Release - Build, Tag and Upload artifacts
2 |
3 | on:
4 | push:
5 | branches:
6 | - main
7 |
8 | jobs:
9 | build:
10 | runs-on: ubuntu-latest
11 | steps:
12 | - uses: actions/checkout@v3
13 | with:
14 | submodules: recursive
15 |
16 | - name: Download GNU ARM embedded toolchain
17 | run: >-
18 | wget --no-check-certificate -O ~/gcc_toolchain.tar.bz2
19 | 'https://developer.arm.com/-/media/Files/downloads/gnu-rm/10-2020q4/gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz'
20 |
21 | - name: Extract the toolchain
22 | run: |
23 | tar -xjf ~/gcc_toolchain.tar.bz2 -C ~/
24 |
25 | - name: Setup & Build - RELEASE
26 | run: |
27 | export PATH=$PATH:~/gcc-arm-none-eabi-10-2020-q4-major/bin
28 | ./setup.sh release
29 | cd build && make -j8
30 |
31 | - name: Setup & Build - DEBUG
32 | run: |
33 | export PATH=$PATH:~/gcc-arm-none-eabi-10-2020-q4-major/bin
34 | ./setup.sh
35 | cd build && make -j8
36 |
37 | - name: Extract Firmware Version
38 | run: |
39 | echo "VERSION_MAJOR=$(cat src/version.h | grep VERSION_MAJOR | awk '{print $3}')" >> $GITHUB_ENV
40 | echo "VERSION_MINOR=$(cat src/version.h | grep VERSION_MINOR | awk '{print $3}')" >> $GITHUB_ENV
41 | echo "VERSION_PATCH=$(cat src/version.h | grep VERSION_PATCH | awk '{print $3}')" >> $GITHUB_ENV
42 |
43 | - uses: ncipollo/release-action@v1
44 | with:
45 | artifacts: "output/release/*.bin,output/release/*.hex,
46 | output/debug/*.bin,output/debug/*.hex"
47 | token: ${{ secrets.GITHUB_TOKEN }}
48 | tag: ${{env.VERSION_MAJOR}}.${{env.VERSION_MINOR}}.${{env.VERSION_PATCH}}
49 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Cmake Files
2 | CMakeLists.txt.user
3 | CMakeCache.txt
4 | CMakeFiles
5 | CMakeScripts
6 | Testing
7 | Makefile
8 | cmake_install.cmake
9 | install_manifest.txt
10 | compile_commands.json
11 | CTestTestfile.cmake
12 | _deps
13 |
14 | # Build artifacts
15 | *.hex
16 | *.bin
17 | *.elf
18 | build/
19 | out/
20 | output/
21 | *.o
22 | *.map
23 | build_log.txt
24 |
25 | # VScode settings
26 | .vscode/*cortex-debug*
27 | .vscode/settings.json
28 | .vscode/*_properties.json
29 | .vscode/launch.json
30 |
31 | *.jlink
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "vendor/segger/segger-rtt"]
2 | path = vendor/segger/segger-rtt
3 | url = https://github.com/stephendpmurphy/segger-rtt.git
4 |
--------------------------------------------------------------------------------
/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Set our minimum required CMake Version
2 | cmake_minimum_required(VERSION 3.13)
3 |
4 | #####################################################################################
5 | # Set our project and CPU specific flags, options, definitions and Linker Settings
6 | #####################################################################################
7 | # Project name
8 | set(PROJECT_NAME "NEW_PROJECT")
9 |
10 | # Desired executable name
11 | set(EXECUTABLE_NAME ${PROJECT_NAME})
12 |
13 | # Set your desired flash and debug toolset - Options are PYOCD (default) or JLINK
14 | set(DEBUG_TOOLSET "PYOCD")
15 | # set(DEBUG_TOOLSET "JLINK")
16 |
17 | # Build in the Segger RTT library (set to true to include the Segger RTT library in the application)
18 | # Default configuration generated will output data to a console in ASCII format
19 | # THIS OPTION IS ONLY SUPPORTED WITH THE JLINK TOOLSET
20 | set(ENABLE_SEGGER_RTT false)
21 |
22 | # MCU Target name as seen in debug toolset
23 | set(MCU_TARGET LPC5526)
24 |
25 | # Set our specific CPU compiler flags
26 | set(COMPILER_CPU_FLAGS "-mcpu=cortex-m33 -mfloat-abi=hard -mfpu=fpv5-sp-d16")
27 |
28 | # Set any libraries you would need to link against (.a libs, gcc, c, m, nosys as examples)
29 | # NOT TO BE CONFUSED WITH LINKER FLAGS. FLAGS BELONG IN the flags.cmake file
30 | set(LINKER_STATIC_LIBRARIES
31 | )
32 |
33 | # Specify the location of our Linker file
34 | set(CPU_LINKER_FILE ${CMAKE_CURRENT_SOURCE_DIR}/src/board/LINKER_FILE.ld)
35 |
36 | # Set debug build specific definitions
37 | set(DEBUG_BUILD_DEFINITIONS -DDEBUG_BUILD)
38 |
39 | # Set release build specific definitions
40 | set(RELEASE_BUILD_DEFINITIONS -DRELEASE_BUILD)
41 |
42 | # Create a list of our APP source
43 | set(APP_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
44 | ${CMAKE_CURRENT_SOURCE_DIR}/src/board/board.c
45 | )
46 |
47 | # Glob together a list of our SDK source
48 | FILE(GLOB SDK_SRC
49 | # ${CMAKE_CURRENT_SOURCE_DIR}/vendor/MANUF/src/*.c
50 | )
51 |
52 | # Set all of our application and SDK include paths
53 | set(INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src/
54 | ${CMAKE_CURRENT_SOURCE_DIR}/src/board
55 | )
56 |
57 | # Add any subdirectories with CMake projects that should be added
58 | set(CMAKE_SUBDIRS
59 | # ${CMAKE_CURRENT_SOURCE_DIR}/vendor/glasslabs/DAC757x
60 | )
61 |
62 | #####################################################################################
63 | # End of project and CPU specific items - DO NOT EDIT ANYTING BELOW THIS POINT
64 | #####################################################################################
65 |
66 | # ENABLE ASM
67 | ENABLE_LANGUAGE(ASM)
68 |
69 | # Include our flags for compilation and linking
70 | include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/flags.cmake)
71 |
72 | # Set the project name and desired Language - This will set he base output executable name
73 | project(${PROJECT_NAME} VERSION 1.0 LANGUAGES C)
74 |
75 | # Set the C standard and executable suffix
76 | set(CMAKE_EXECUTABLE_SUFFIX ".elf")
77 | set(CMAKE_C_STANDARD 11)
78 | set(CMAKE_C_STANDARD_REQUIRED ON)
79 |
80 | # Set our executable output path to the 'output/' folder
81 | SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/output/${CMAKE_BUILD_TYPE})
82 | SET(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/output/${CMAKE_BUILD_TYPE})
83 |
84 | # Include the specified paths
85 | include_directories(${INCLUDE_DIRS})
86 |
87 | # Generate our executable using the app/sdk source and includes
88 | add_executable(${EXECUTABLE_NAME}
89 | ${APP_SRC}
90 | ${SDK_SRC}
91 | )
92 |
93 | # Link against any specificed libs
94 | target_link_libraries(${EXECUTABLE_NAME} PRIVATE ${LINKER_STATIC_LIBRARIES})
95 |
96 | # Append our CPU specific flags to our Compiler and Linker flags
97 | set(CMAKE_ASM_FLAGS_DEBUG "${CMAKE_ASM_FLAGS_DEBUG} ${COMPILER_CPU_FLAGS}")
98 | set(CMAKE_ASM_FLAGS_RELEASE "${CMAKE_ASM_FLAGS_RELEASE} ${COMPILER_CPU_FLAGS}")
99 | set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${COMPILER_CPU_FLAGS}")
100 | set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${COMPILER_CPU_FLAGS}")
101 | set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} ${COMPILER_CPU_FLAGS}")
102 | set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} ${COMPILER_CPU_FLAGS}")
103 |
104 | # Add in our build specific compile definitions/macros
105 | if(CMAKE_BUILD_TYPE STREQUAL debug)
106 | target_compile_definitions(${EXECUTABLE_NAME} PUBLIC ${DEBUG_BUILD_DEFINITIONS})
107 | endif()
108 |
109 | if(CMAKE_BUILD_TYPE STREQUAL release)
110 | target_compile_definitions(${EXECUTABLE_NAME} PUBLIC ${RELEASE_BUILD_DEFINITIONS})
111 | endif()
112 |
113 | if(ENABLE_SEGGER_RTT)
114 | message(STATUS "Adding the Segger RTT library")
115 | # Include our Segger RTT include directory
116 | set(INCLUDE_DIRS ${INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/vendor/segger/segger-rtt/RTT)
117 | # Add the segger-rtt subdirectory so CMake builds the lib
118 | set(CMAKE_SUBDIRS ${CMAKE_SUBDIRS} ${CMAKE_CURRENT_SOURCE_DIR}/vendor/segger/segger-rtt)
119 | # Add the linker target for the segger RTT static lib
120 | target_link_libraries(${EXECUTABLE_NAME} PRIVATE seggerRTT)
121 | endif()
122 |
123 | # Add all of our CMake Subdirectories
124 | foreach(subdir ${CMAKE_SUBDIRS})
125 | add_subdirectory(${subdir})
126 | endforeach()
127 |
128 | # Setup our debug toolset
129 | if(DEBUG_TOOLSET STREQUAL JLINK)
130 | include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/debug_jlink.cmake)
131 | message(STATUS "Using the JLINK toolset")
132 | else()
133 | include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/debug_pyocd.cmake)
134 | message(STATUS "Using the PYOCD toolset")
135 | endif()
136 |
137 | # Extract the current firmware version
138 | file(READ ${CMAKE_CURRENT_SOURCE_DIR}/src/version.h ver)
139 | # Major
140 | string(REGEX MATCH "VERSION_MAJOR([ \t]+[0-9]*)" _ ${ver})
141 | string(REPLACE " " "" ver_major ${CMAKE_MATCH_1})
142 | # Minor
143 | string(REGEX MATCH "VERSION_MINOR([ \t]+[0-9]*)" _ ${ver})
144 | string(REPLACE " " "" ver_minor ${CMAKE_MATCH_1})
145 | # Patch
146 | string(REGEX MATCH "VERSION_PATCH([ \t]+[0-9]*)" _ ${ver})
147 | string(REPLACE " " "" ver_patch ${CMAKE_MATCH_1})
148 | # Set the final firmware version string
149 | set(firmware_version "v${ver_major}_${ver_minor}_${ver_patch}")
150 |
151 | # Convert the elf into an intel hex file
152 | add_custom_target(elfToHex ALL ${CMAKE_OBJCOPY} -O ihex ${EXECUTABLE_OUTPUT_PATH}/${EXECUTABLE_NAME}.elf ${EXECUTABLE_OUTPUT_PATH}/${EXECUTABLE_NAME}-${CMAKE_BUILD_TYPE}-${firmware_version}.hex DEPENDS ${EXECUTABLE_NAME})
153 | add_custom_target(elfToHexVer ALL ${CMAKE_OBJCOPY} -O ihex ${EXECUTABLE_OUTPUT_PATH}/${EXECUTABLE_NAME}.elf ${EXECUTABLE_OUTPUT_PATH}/${EXECUTABLE_NAME}.hex DEPENDS elfToHex)
154 |
155 | # Convert the elf into a binary file
156 | add_custom_target(elfToBin ALL ${CMAKE_OBJCOPY} -O binary ${EXECUTABLE_OUTPUT_PATH}/${EXECUTABLE_NAME}.elf ${EXECUTABLE_OUTPUT_PATH}/${EXECUTABLE_NAME}-${CMAKE_BUILD_TYPE}-${firmware_version}.bin DEPENDS elfToHexVer)
157 |
158 | # Add a makefile "target" to erase our part
159 | add_custom_target(erase ${DEBUG_ERASE_CMD})
160 |
161 | # Add a makefile "target" to flash the micro
162 | add_custom_target(flash ${DEBUG_FLASH_CMD})
163 |
164 | # Add a makefile "target" for running unit tests
165 | add_custom_target(test cd ../ && ceedling gcov:all utils:gcov)
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # VSCode ARM M-Core Project Template
2 | At first clone, you should ensure that you have all of the tools installed for your OS as detailed in the Software section of the [README_TEMPLATE](./README_TEMPLATE.md) file. After initially cloning this repo, run through each folder/file and ensure the following tasks are completed.
3 | ## New repo checklist
4 | - [ ] **doc**
5 | - [ ] Place any relevant reference material (Reference manuals/data sheets) in the ```doc``` folder
6 | - [ ] **src**
7 | - [ ] Add any project specific source (written by Glassboard developer) into the src folder using the ```ceedling module:create[FILENAME]``` from the root directory command. This will create the file in the src folder as well as add a new unit test file in the ```test/``` folder
8 | - [ ] ```ceedling module:create[FILENAME]```
9 | - [ ] **src/version.h**
10 | - [ ] Set your projects initial Major, Minor and Patch version numbers. You can conditionally use the DEBUG version to indicate a build is release or debug within your application
11 | - [ ] **vendor**
12 | - [ ] Add project specific submodules and SDKs into the vendor folder
13 | - [ ] i.e. - If the project uses the Glasslabs AT24Cx submodule. You would create a new folder under ```vendor/glasslabs``` and then add your submodule
14 | - [ ] ```cd vendor/glasslabs && git submodule add https://github.com/glassboard-dev/AT24Cx```
15 | - [ ] When adding a staticly downloaded SDK, you would create a new folder under ```vendor/{MICRO_MANUF}``` and then add your SDK files there
16 | - [ ] **project.yml**
17 | - [ ] Update/add any project specific defines needed for compilation of test cases - This likely includes a macro defining the mico PN (Search for CPU_DEFINE_PN)
18 | ```yml
19 | :common: &common_defines
20 | - CPU_DEFINE_PN
21 | ```
22 | - [ ] Update/add any new source paths needed for Vendor and Application source files - Example being a manufacturer provided SDK located at: ```vendor/nxp/SDK/devices/LPC5526/**```
23 | ```yml
24 | :paths:
25 | :source:
26 | - src/**
27 | - [ ] **cmake/flags.cmake**
28 | - [ ] Add all of your needed C, C++ and assembly compiler and linker flags for both debug and release variants here. The current file is full of common and usefull flags for most ARM-Core targets
29 | - [ ] **CMakeLists.txt**
30 | - [ ] Update the CMake variables for your specific project, MCU, sources, etc. All of the user settings that need updating are located at the top of the file. A complete list is below. DO NOT EDIT ANYTHING BELOW THESE CONFIGURATION VARIABLES - If a gap or issue is found, please report back [here](https://github.com/glassboard-dev/gl-arm-vscode-template/issues) so accomodations can be made for the missing config.
31 | - [ ] PROJECT_NAME
32 | - [ ] EXECUTABLE_NAME
33 | - [ ] DEBUG_TOOLSET
34 | - [ ] ENABLE_SEGGER_RTT
35 | - [ ] MCU_TARGET
36 | - [ ] COMPILER_CPU_FLAGS
37 | - [ ] LINKER_STATIC_LIBRARIES
38 | - [ ] CPU_LINKER_FILE
39 | - [ ] DEBUG_BUILD_DEFINITIONS
40 | - [ ] RELEASE_BUILD_DEFINITIONS
41 | - [ ] APP_SRC
42 | - [ ] SDK_SRC
43 | - [ ] INCLUDE_DIRS
44 | - [ ] CMAKE_SUBDIRS
45 | - [ ] **README_TEMPLATE**
46 | - [ ] Update the PROJECT_NAME in the header to your project name
47 | - [ ] Add project specific software or hardware setup instructions
48 |
49 | ## When complete with checklist
50 | - [ ] Remove this README and rename the README_TEMPLATE to README to replace this checklist.
51 | - [ ] ```mv README_TEMPLATE.md README.md```
52 |
--------------------------------------------------------------------------------
/README_TEMPLATE.md:
--------------------------------------------------------------------------------
1 |
2 |
{PROJECT_NAME}
3 |
4 |
5 | ### Tools Setup ✔️
6 | At a minium you will need the ARM GNU GCC Toolchain, Make and CMake to compile the source and generate executable artifacts.
7 | - [ARM GNU GCC Toolchain - 10-2020-q4-major](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads) - Other versions can be used but the current source is actively developed and tested using the 10-2020-q4-major release
8 | - Make - Make is shipped with Linux and should already be present on the developers system. If the developer is running Windows they can either use WSL to run a Linux instance or install Make on Windows via [MinGW](https://sourceforge.net/projects/mingw/)
9 | - [CMake](https://cmake.org/download/)
10 |
11 | To flash and debug the target this project uses a couple of different tools. PyOCD or Segger JLink can be used as the programming/debugging medium, and a VScode extension called Cortex-Debug gives a user interface within VScode for stepping through the source, settings breakpoints and viewing registers/variables within the target.
12 | - [PyOCD](https://github.com/pyocd/pyOCD#installing)
13 | - [JLink](https://www.segger.com/downloads/jlink/)
14 | - [VScode](https://code.visualstudio.com/)
15 | - [ARM Developer Extension Pack for VScode](https://marketplace.visualstudio.com/items?itemName=Glasslabs.arm-developer-toolkit)
16 |
17 | ***NOTE: After installing your desired debug toolset, please ensure the chosen application is accessible from the command line (pyocd or JLinkExe)***
18 |
19 | To write and execute unit tests on the firmware source, you will need to install the Ceedling unit test framework and the Python package gcovr to generate Cobertura html reports. Ceedling is a Ruby Gem, so Ruby must first be installed on your system. GCC and Make are also needed. If the developer is on Windows, you can find install instructions above.
20 | - [Ruby](https://www.ruby-lang.org)
21 | - Windows - [RubyInstaller 2.7.3-1](https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.7.3-1/rubyinstaller-2.7.3-1-x64.exe)
22 | - Linux - ```sudo apt-get install ruby```
23 | - [Ceedling](http://www.throwtheswitch.org/ceedling)
24 | - [Python](https://www.python.org/downloads/)
25 | - [gcovr](https://gcovr.com/en/stable/)
26 | - ```python -m pip install gcovr```
27 |
28 | ### Adding new source files 📁
29 | To add a new source file to the ```src/``` folder: From the root directory, use the Ceedling command below to create a new source ```.c``` and ```.h``` file. This will also create a unit test file in the ```test/``` folder for you.
30 | ```c
31 | // Don't include a .c or .h in the filename
32 | $ ceedling module:create[FILENAME]
33 | ```
34 |
35 | ### Compiling, Flashing & Testing ✨
36 | After a fresh clone, the ```setup``` scripts can be used to initialize the project. Passing ```release``` as an argument will generate a release build. Otherwise a ```debug``` build is generated.
37 | ##### Windows
38 | ```console
39 | setup.ps1
40 | ```
41 | ##### Linux
42 | ```console
43 | ./setup.sh
44 | ```
45 |
46 | Once a project has been initialized, the following commands should be ran from the ```build/``` folder
47 |
48 | To clean the working directory:
49 | ```console
50 | make clean
51 | ```
52 |
53 | To compile the source:
54 | ```console
55 | make -j8
56 | ```
57 |
58 | To erase the connected target:
59 | ```console
60 | make erase
61 | ```
62 |
63 | To flash the connected target:
64 | ```console
65 | make flash
66 | ```
67 |
68 | To execute unit tests:
69 | ```console
70 | make test
71 | ```
72 |
73 | ### Source Documentation Style 📃
74 | Read more about the Source documentation style [here](./doc/DOCUMENTATION_STYLE.md)
75 |
76 | ### Develop Strategy 📖
77 | Read more about the Git develop strategy used [here](./doc/DEVELOP_STRATEGY.md)
78 |
--------------------------------------------------------------------------------
/cmake/arm-gcc-toolchain.cmake:
--------------------------------------------------------------------------------
1 | set(CMAKE_SYSTEM_NAME Linux)
2 | set(CMAKE_SYSTEM_PROCESSOR ARM)
3 |
4 | if(MINGW OR CYGWIN OR WIN32)
5 | set(UTIL_SEARCH_CMD where)
6 | elseif(UNIX OR APPLE)
7 | set(UTIL_SEARCH_CMD which)
8 | endif()
9 |
10 | set(TOOLCHAIN_PREFIX arm-none-eabi-)
11 |
12 | execute_process(
13 | COMMAND ${UTIL_SEARCH_CMD} ${TOOLCHAIN_PREFIX}gcc
14 | OUTPUT_VARIABLE BINUTILS_PATH
15 | OUTPUT_STRIP_TRAILING_WHITESPACE
16 | )
17 |
18 | get_filename_component(ARM_TOOLCHAIN_DIR ${BINUTILS_PATH} DIRECTORY)
19 | # Without that flag CMake is not able to pass test compilation check
20 | if (${CMAKE_VERSION} VERSION_EQUAL "3.6.0" OR ${CMAKE_VERSION} VERSION_GREATER "3.6")
21 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
22 | else()
23 | set(CMAKE_EXE_LINKER_FLAGS_INIT "--specs=nosys.specs")
24 | endif()
25 |
26 | set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}gcc)
27 | set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER})
28 | set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}g++)
29 |
30 | # Default C compiler flags
31 | set(CMAKE_C_FLAGS_DEBUG_INIT "-g3 -Og -Wall -pedantic -DDEBUG")
32 | set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG_INIT}" CACHE STRING "" FORCE)
33 | set(CMAKE_C_FLAGS_RELEASE_INIT "-O3 -Wall")
34 | set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE_INIT}" CACHE STRING "" FORCE)
35 | set(CMAKE_C_FLAGS_MINSIZEREL_INIT "-Os -Wall")
36 | set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL_INIT}" CACHE STRING "" FORCE)
37 | set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-O2 -g -Wall")
38 | set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO_INIT}" CACHE STRING "" FORCE)
39 | # Default C++ compiler flags
40 | set(CMAKE_CXX_FLAGS_DEBUG_INIT "-g3 -Og -Wall -pedantic -DDEBUG")
41 | set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG_INIT}" CACHE STRING "" FORCE)
42 | set(CMAKE_CXX_FLAGS_RELEASE_INIT "-O3 -Wall")
43 | set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE_INIT}" CACHE STRING "" FORCE)
44 | set(CMAKE_CXX_FLAGS_MINSIZEREL_INIT "-Os -Wall")
45 | set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL_INIT}" CACHE STRING "" FORCE)
46 | set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-O2 -g -Wall")
47 | set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT}" CACHE STRING "" FORCE)
48 |
49 | set(CMAKE_OBJCOPY ${ARM_TOOLCHAIN_DIR}/${TOOLCHAIN_PREFIX}objcopy CACHE INTERNAL "objcopy tool")
50 | set(CMAKE_SIZE_UTIL ${ARM_TOOLCHAIN_DIR}/${TOOLCHAIN_PREFIX}size CACHE INTERNAL "size tool")
51 |
52 | set(CMAKE_SYSROOT ${ARM_TOOLCHAIN_DIR}/../arm-none-eabi)
53 | set(CMAKE_FIND_ROOT_PATH ${BINUTILS_PATH})
54 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
55 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
56 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
--------------------------------------------------------------------------------
/cmake/debug_jlink.cmake:
--------------------------------------------------------------------------------
1 | set(DEBUG_ERASE_CMD "JLinkExe" "-commanderscript" "${CMAKE_CURRENT_SOURCE_DIR}/Erase.jlink")
2 | set(DEBUG_FLASH_CMD "JLinkExe" "-commanderscript" "${CMAKE_CURRENT_SOURCE_DIR}/Flash.jlink")
3 |
4 | write_file(${CMAKE_CURRENT_SOURCE_DIR}/Erase.jlink
5 | "device ${MCU_TARGET}
6 | speed 4000
7 | r
8 | erase
9 | r
10 | exit"
11 | )
12 |
13 | write_file(${CMAKE_CURRENT_SOURCE_DIR}/Flash.jlink
14 | "device ${MCU_TARGET}
15 | speed 4000
16 | r
17 | loadfile ${EXECUTABLE_OUTPUT_PATH}/${EXECUTABLE_NAME}.hex
18 | r
19 | g
20 | exit"
21 | )
22 |
23 | write_file(${CMAKE_CURRENT_SOURCE_DIR}/.vscode/launch.json
24 | {\n
25 | \t\"version\": \"0.2.0\",\n
26 | \t\"configurations\": [\n
27 | \t{\n
28 | \t\t\"name\": \"${MCU_TARGET}\",\n
29 | \t\t\"type\": \"cortex-debug\",\n
30 | \t\t\"request\": \"launch\",\n
31 | \t\t\"servertype\":\"jlink\",\n
32 | \t\t\"cwd\": \"${workspaceRoot}\",\n
33 | \t\t\"executable\": \"${EXECUTABLE_OUTPUT_PATH}/${EXECUTABLE_NAME}.elf\",\n
34 | \t\t\"device\": \"${MCU_TARGET}\",\n
35 | \t\t\"runToMain\": true,\n
36 | \t\t\"v1\": false,\n
37 | \t\t\"serverArgs\": [\n
38 | \t\t\t\"--target\",\n
39 | \t\t\t\"${MCU_TARGET}\"\n
40 | \t\t],
41 | )
42 |
43 | if(${ENABLE_SEGGER_RTT})
44 |
45 | write_file(${CMAKE_CURRENT_SOURCE_DIR}/.vscode/launch.json
46 | \t\t"rttConfig":{\n
47 | \t\t\t"enabled":true,\n
48 | \t\t\t"address":"auto",\n
49 | \t\t\t"decoders":[{\n
50 | \t\t\t\t"port":0,\n
51 | \t\t\t\t"type":"console"\n
52 | \t\t\t}]\n
53 | \t\t}\n
54 | \t}]\n
55 | }
56 | APPEND)
57 |
58 | else()
59 |
60 | write_file(${CMAKE_CURRENT_SOURCE_DIR}/.vscode/launch.json
61 | \t}]\n
62 | }
63 | APPEND)
64 |
65 | endif()
--------------------------------------------------------------------------------
/cmake/debug_pyocd.cmake:
--------------------------------------------------------------------------------
1 | set(DEBUG_ERASE_CMD "pyocd" "erase" "-t${MCU_TARGET}" "--chip")
2 | set(DEBUG_FLASH_CMD "pyocd" "flash" "-t${MCU_TARGET}" "-f20000khz" "${EXECUTABLE_OUTPUT_PATH}/${EXECUTABLE_NAME}.elf")
3 |
4 | write_file(${CMAKE_CURRENT_SOURCE_DIR}/.vscode/launch.json
5 | {\n
6 | \t\"version\": \"0.2.0\",\n
7 | \t\"configurations\": [\n
8 | \t{\n
9 | \t\t\"name\": \"${MCU_TARGET}\",\n
10 | \t\t\"type\": \"cortex-debug\",\n
11 | \t\t\"request\": \"launch\",\n
12 | \t\t\"servertype\":\"pyocd\",\n
13 | \t\t\"cwd\": \"${workspaceRoot}\",\n
14 | \t\t\"executable\": \"${EXECUTABLE_OUTPUT_PATH}/${EXECUTABLE_NAME}.elf\",\n
15 | \t\t\"device\": \"${MCU_TARGET}\",\n
16 | \t\t\"runToMain\": true,\n
17 | \t\t\"v1\": false,\n
18 | \t\t\"serverArgs\": [\n
19 | \t\t\t\"--target\",\n
20 | \t\t\t\"${MCU_TARGET}\"\n
21 | \t\t]\n
22 | \t}]\n
23 | })
--------------------------------------------------------------------------------
/cmake/flags.cmake:
--------------------------------------------------------------------------------
1 | SET(CMAKE_ASM_FLAGS_DEBUG " \
2 | -g \
3 | -Wall \
4 | -mthumb \
5 | -fno-common \
6 | -ffunction-sections \
7 | -fdata-sections \
8 | -ffreestanding \
9 | -fno-builtin \
10 | -mapcs \
11 | -std=gnu99 \
12 | ")
13 |
14 | SET(CMAKE_ASM_FLAGS_RELEASE " \
15 | -Wall \
16 | -mthumb \
17 | -fno-common \
18 | -ffunction-sections \
19 | -fdata-sections \
20 | -ffreestanding \
21 | -fno-builtin \
22 | -mapcs \
23 | -std=gnu99 \
24 | ")
25 |
26 | SET(CMAKE_C_FLAGS_DEBUG " \
27 | -g \
28 | -O0 \
29 | -Wall \
30 | -mthumb \
31 | -MMD \
32 | -MP \
33 | -fno-common \
34 | -ffunction-sections \
35 | -fdata-sections \
36 | -ffreestanding \
37 | -fno-builtin \
38 | -mapcs \
39 | -std=gnu99 \
40 | ")
41 |
42 | SET(CMAKE_C_FLAGS_RELEASE " \
43 | -O0 \
44 | -Wall \
45 | -mthumb \
46 | -MMD \
47 | -MP \
48 | -fno-common \
49 | -ffunction-sections \
50 | -fdata-sections \
51 | -ffreestanding \
52 | -fno-builtin \
53 | -mapcs \
54 | -std=gnu99 \
55 | ")
56 |
57 | SET(CMAKE_EXE_LINKER_FLAGS_DEBUG " \
58 | -g \
59 | -Wall \
60 | --specs=nano.specs \
61 | --specs=nosys.specs \
62 | -fno-common \
63 | -ffunction-sections \
64 | -fdata-sections \
65 | -ffreestanding \
66 | -fno-builtin \
67 | -mthumb \
68 | -mapcs \
69 | -Xlinker \
70 | --gc-sections \
71 | -Xlinker \
72 | -static \
73 | -Xlinker \
74 | -z \
75 | -Xlinker \
76 | muldefs \
77 | -Xlinker \
78 | -Map=output.map \
79 | -Wl,--print-memory-usage \
80 | -T${CPU_LINKER_FILE} -static \
81 | ")
82 |
83 | SET(CMAKE_EXE_LINKER_FLAGS_RELEASE " \
84 | -Wall \
85 | --specs=nano.specs \
86 | --specs=nosys.specs \
87 | -fno-common \
88 | -ffunction-sections \
89 | -fdata-sections \
90 | -ffreestanding \
91 | -fno-builtin \
92 | -mthumb \
93 | -mapcs \
94 | -Xlinker \
95 | --gc-sections \
96 | -Xlinker \
97 | -static \
98 | -Xlinker \
99 | -z \
100 | -Xlinker \
101 | muldefs \
102 | -Xlinker \
103 | -Map=output.map \
104 | -Wl,--print-memory-usage \
105 | -T${CPU_LINKER_FILE} -static \
106 | ")
--------------------------------------------------------------------------------
/doc/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/glassboard-dev/gl-vscode-template-arm/ba131956f4200abce4e258c2f8402c21762aa7a8/doc/.gitkeep
--------------------------------------------------------------------------------
/doc/DEVELOP_STRATEGY.md:
--------------------------------------------------------------------------------
1 | ### Develop Strategy
2 | Github CI is utilized for Continuous Integration/Deployment and requires a specific branching strategy to be followed. All final release source can be found on the ```main``` branch. Any pull request into the ```main``` branch will have compilation and unit tests ran against it. When a PR into ```main``` completes, a "release" will be made where the final artifacts are published to Github and a new tag is created. Any ongoing developer changes should be made on a feature branch created from the ```develop``` branch. PRs are then made from the feature branch back into the ```develop``` branch where the source will be tested and compiled before completion. When the developer has completed several features and is ready to create a release, a PR from ```develop``` into ```main``` is created.
3 |
4 |
--------------------------------------------------------------------------------
/doc/DOCUMENTATION_STYLE.md:
--------------------------------------------------------------------------------
1 | ### Documentation Style
2 | All of the source files should be commented/documented using Doxygen style comments. This has two benefits: 1.) The code is well documented and more friendly for new developers to come along and understand the code. 2.) VScode can parse these comments and provide hints/tooltips when hovering a mouse over a function, variable or macro name.
3 |
4 | #### File Headers
5 | When documenting a File. A ```@file``` keyword is used for the Filename folowed by a ```@brief``` for a quick file description
6 | ```c
7 | /*! @file mcp342x.h
8 | * @brief Public header file for the MCP342x 16-Bit, ADC C driver.
9 | */
10 | ```
11 |
12 | #### Variables & Macros
13 | When documenting a variable or macro the comment should be placed on the same line following the definition using the ```@brief``` keyword
14 | ```c
15 | #define MCP342x_LSB_VAL (0.0000625) /*! @brief LSB Value in Volts of a sampled output code */
16 | ```
17 |
18 | #### Typedef Enums, Structs and Unions
19 | When documenting a typedef enum or struct a brief header is placed above the definition to give a description of the Typedef and a single comment is placed on each line of a member.
20 | ```c
21 | /*!
22 | * @brief MCP342x Conversion Modes
23 | */
24 | typedef enum {
25 | MCP342x_CM_ONE_SHOT = 0x00, /* One Shot Conversion */
26 | MCP342x_CM_CONT = 0x01, /* Continuous Conversion */
27 | MCP342x_CM__MAX__ = 0x02, /* Conversion Mode Max */
28 | } mcp342x_conversion_mode_enum;
29 |
30 | /*!
31 | * @brief MCP342x ADC Results
32 | */
33 | typedef struct
34 | {
35 | uint16_t outputCode; /* 16-bit Output Code */
36 | float voltage; /* Sampled Voltage */
37 | } mcp342x_results_t;
38 |
39 | /*!
40 | * @brief MCP342x Configuration Register
41 | */
42 | typedef union
43 | {
44 | struct
45 | {
46 | uint8_t gain : 2; /* Gain */
47 | uint8_t sample_rate : 2; /* Sample Rate */
48 | uint8_t conv_mode : 1; /* Conversion Mode */
49 | uint8_t channel : 2; /* Channel */
50 | uint8_t ready : 1; /* Ready Bit */
51 | } bits;
52 | uint8_t byte;
53 | } mcp342x_config_t;
54 |
55 | ```
56 |
57 | #### Functions
58 | When documenting a function in your source file (```.c```), you simply need to place a single brief statement. Below is an example of documenting an I2C Read interface
59 | ```c
60 | /*!
61 | * @brief This function pointer API reads I2C data from the specified
62 | * device on the bus.
63 | */
64 | int8_t i2c_read(const uint8_t busAddr, uint8_t *data, const uint32_t len) {
65 | app_return_code_t ret = APP_RET_OK;
66 |
67 | // I2c read function code here
68 |
69 | return ret;
70 | }
71 | ```
72 | When documenting the API in your header file (```.h```), the documentation is a bit more involved. Here you will place a brief, as well as defining the parameters and a description of what the return value pertains to. Take note of the ```@param``` variables and their directions (```in/out```). Notice that even though the ```data``` parameter is an input argument, we documented it as an output since we expect the function to manipulate something that the data pointer points to.
73 | ```c
74 | /*!
75 | * @brief This function pointer API reads I2C data from the specified
76 | * device on the bus.
77 | *
78 | * @param[in] busAddr: Address of the device to be read from
79 | * @param[out] *data: Pointer to the where we should store the read data
80 | * @param[in] len: Length of data to be read
81 | *
82 | * @return The result of reading I2C data
83 | */
84 | int8_t i2c_read(const uint8_t busAddr, uint8_t *data, const uint32_t len);
85 | ```
86 |
--------------------------------------------------------------------------------
/doc/img/git_workflow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/glassboard-dev/gl-vscode-template-arm/ba131956f4200abce4e258c2f8402c21762aa7a8/doc/img/git_workflow.png
--------------------------------------------------------------------------------
/project.yml:
--------------------------------------------------------------------------------
1 | ---
2 |
3 | # Notes:
4 | # Sample project C code is not presently written to produce a release artifact.
5 | # As such, release build options are disabled.
6 | # This sample, therefore, only demonstrates running a collection of unit tests.
7 |
8 | :project:
9 | :use_exceptions: FALSE
10 | :use_test_preprocessor: TRUE
11 | :use_auxiliary_dependencies: TRUE
12 | :build_root: build
13 | # :release_build: TRUE
14 | :test_file_prefix: test_
15 | :which_ceedling: gem
16 | :ceedling_version: 0.31.0
17 | :default_tasks:
18 | - test:all
19 |
20 | #:test_build:
21 | # :use_assembly: TRUE
22 |
23 | #:release_build:
24 | # :output: MyApp.out
25 | # :use_assembly: FALSE
26 |
27 | :environment:
28 |
29 | :extension:
30 | :executable: .out
31 |
32 | :paths:
33 | :test:
34 | - +:test/**
35 | - -:test/support
36 | :source:
37 | - src/**
38 | - vendor/**
39 |
40 | :support:
41 | - test/support
42 | :libraries: []
43 |
44 | :defines:
45 | # in order to add common defines:
46 | # 1) remove the trailing [] from the :common: section
47 | # 2) add entries to the :common: section (e.g. :test: has TEST defined)
48 | :common: &common_defines
49 | - CPU_DEFINE_PN
50 |
51 | :test:
52 | - *common_defines
53 | - TEST
54 | :test_preprocess:
55 | - *common_defines
56 | - TEST
57 |
58 | :cmock:
59 | :mock_prefix: mock_
60 | :when_no_prototypes: :warn
61 | :enforce_strict_ordering: TRUE
62 | :plugins:
63 | - :ignore
64 | - :callback
65 | :treat_as:
66 | uint8: HEX8
67 | uint16: HEX16
68 | uint32: UINT32
69 | int8: INT8
70 | bool: UINT8
71 |
72 | # Add -gcov to the plugins list to make sure of the gcov plugin
73 | # You will need to have gcov and gcovr both installed to make it work.
74 | # For more information on these options, see docs in plugins/gcov
75 | :gcov:
76 | :utilities:
77 | - gcovr
78 | :reports:
79 | - HtmlBasic
80 | - HtmlDetailed
81 | - Xml
82 | :xml_report: true
83 | :gcovr:
84 | :html_medium_threshold: 75
85 | :html_high_threshold: 90
86 |
87 | #:tools:
88 | # Ceedling defaults to using gcc for compiling, linking, etc.
89 | # As [:tools] is blank, gcc will be used (so long as it's in your system path)
90 | # See documentation to configure a given toolchain for use
91 |
92 | # LIBRARIES
93 | # These libraries are automatically injected into the build process. Those specified as
94 | # common will be used in all types of builds. Otherwise, libraries can be injected in just
95 | # tests or releases. These options are MERGED with the options in supplemental yaml files.
96 | :libraries:
97 | :placement: :end
98 | :flag: "-l${1}"
99 | :path_flag: "-L ${1}"
100 | :system: [] # for example, you might list 'm' to grab the math library
101 | :test: []
102 | :release: []
103 |
104 | :module_generator:
105 | :boilerplate_files:
106 | :src: './vendor/ceedling/template/src_boilerplate.c'
107 | :inc: './vendor/ceedling/template/inc_boilerplate.h'
108 |
109 | :plugins:
110 | :load_paths:
111 | - "#{Ceedling.load_path}"
112 | :enabled:
113 | - xml_tests_report
114 | - stdout_pretty_tests_report
115 | - module_generator
116 | - gcov
117 | ...
118 |
--------------------------------------------------------------------------------
/setup.ps1:
--------------------------------------------------------------------------------
1 | # Cleanup any old Cmake artifacts
2 | if( Test-Path -Path './build' ) {Remove-Item './build' -Recurse}
3 |
4 | # Store the build type
5 | $buildType=$args[0];
6 |
7 | if( $buildType -eq $null ) {
8 | Write-Output "Generating Makefile for DEBUG build"
9 | New-Item -Path './build' -ItemType Directory
10 | Set-Location './build'
11 | cmake -G "MinGW Makefiles" -DCMAKE_TOOLCHAIN_FILE="../cmake/arm-gcc-toolchain.cmake" -DCMAKE_BUILD_TYPE=debug ..
12 | }
13 | else {
14 | Write-Output "Generating Makefile for RELEASE build"
15 | New-Item -Path './build' -ItemType Directory
16 | Set-Location './build'
17 | cmake -G "MinGW Makefiles" -DCMAKE_TOOLCHAIN_FILE="../cmake/arm-gcc-toolchain.cmake" -DCMAKE_BUILD_TYPE=release ..
18 | }
19 |
20 | exit 0
--------------------------------------------------------------------------------
/setup.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # Cleanup any old Cmake artifacts
3 | if [ -d "build" ];then rm -rf build; fi
4 |
5 | # Check if a build type was specified. If so, it's a debug build. Otherwise its release.
6 | if [ -z $1 ]
7 | then
8 | # Generate a makefile for the Debug variant
9 | echo "Generating Makefile for DEBUG build"
10 | mkdir -p build
11 | cd build
12 | cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE="../cmake/arm-gcc-toolchain.cmake" -DCMAKE_BUILD_TYPE=debug ..
13 | else
14 | # Generate a makefile for the Release variant
15 | echo "Generating Makefile for RELEASE build"
16 | mkdir -p build
17 | cd build
18 | cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE="../cmake/arm-gcc-toolchain.cmake" -DCMAKE_BUILD_TYPE=release ..
19 | fi;
20 |
21 | exit 0
--------------------------------------------------------------------------------
/src/board/board.c:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | Board level init and utility functions
3 | Copyright (c) 2022 ENTITY NAME
4 | board.c
5 | *******************************************************************************/
6 | #include
7 | #include "board.h"
8 |
9 | volatile static uint32_t g_systickCounter; /*! @brief Counter accumulating the systick count value */
10 | volatile static uint32_t g_delayCounter; /*! @brief Delay counter value used to store the current delay value */
11 |
12 | /*!
13 | * @brief SysTick Handler expected to tick every 1ms. Decrementing
14 | * a global delay counter until it reaches zero and incremnting
15 | * a global tick counter
16 | */
17 | void SysTick_Handler(void)
18 | {
19 | if (g_delayCounter != 0U)
20 | {
21 | g_delayCounter--;
22 | }
23 |
24 | g_systickCounter++;
25 | }
26 |
27 | /*!
28 | * @brief Execute all board specific initialization and setup
29 | */
30 | void BOARD_Init(void) {
31 | // Clock init
32 | // Peripheral Init
33 | }
34 |
35 | /*!
36 | * @brief Delay the specified number of ticks
37 | */
38 | void BOARD_DelayTicks(uint32_t n)
39 | {
40 | g_delayCounter = n;
41 | while (g_delayCounter != 0U)
42 | {
43 | }
44 | }
45 |
46 | /*!
47 | * @brief Retrieve the current global tick counter value
48 | */
49 | uint32_t BOARD_GetTick(void) {
50 | return g_systickCounter;
51 | }
--------------------------------------------------------------------------------
/src/board/board.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | Board level definitions
3 | Copyright (c) 2022 ENTITY NAME
4 | board.h
5 | *******************************************************************************/
6 |
7 | #ifndef _BOARD_H_
8 | #define _BOARD_H_
9 |
10 | #include
11 |
12 | /*!
13 | * @brief Execute all board specific initialization and setup
14 | */
15 | void BOARD_Init(void);
16 |
17 | /*!
18 | * @brief Delay the specified number of ticks
19 | * @param[in] n: Number of ticks to delay
20 | */
21 | void BOARD_DelayTicks(uint32_t n);
22 |
23 | /*!
24 | * @brief Retrieve the current global tick counter value
25 | * @return Return the current global tick counter
26 | */
27 | uint32_t BOARD_GetTick(void);
28 |
29 | #endif /* _BOARD_H_ */
--------------------------------------------------------------------------------
/src/error.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | Standard return code enum
3 | Copyright (c) 2022 ENTITY NAME
4 | error.h
5 | *******************************************************************************/
6 |
7 | #ifndef _ERROR_H_
8 | #define _ERROR_H_
9 |
10 | /*!
11 | * @brief Standard App return codes
12 | */
13 | typedef enum {
14 | APP_RET_OK = 0, /* OK */
15 | APP_RET_ERROR = -1, /* Error */
16 | APP_RET_BUSY = -2, /* Interface Busy */
17 | APP_RET_TIMEOUT = -3, /* Timeout */
18 | APP_RET_INV_PARAM = -4, /* Invalid Parameter */
19 | APP_RET_NULL_PTR = -5, /* NULL Pointer */
20 | } app_return_code_t;
21 |
22 | #endif // _ERROR_H_
--------------------------------------------------------------------------------
/src/main.c:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | Main program entry point
3 | Copyright (c) 2022 ENTITY NAME
4 | main.c
5 | *******************************************************************************/
6 |
7 | #include
8 | #include "error.h"
9 | #include "board.h"
10 |
11 | void main(void) {
12 | app_return_code_t ret = APP_RET_OK;
13 |
14 | // Initialze the board peripherals
15 | BOARD_Init();
16 |
17 | // Other init code
18 |
19 | // Start running the application code
20 | while(1) {
21 | BOARD_DelayTicks(1000);
22 | }
23 | }
--------------------------------------------------------------------------------
/src/version.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | Header file for application version and debug/release flag
3 | Copyright (c) 2022 ENTITY NAME
4 | version.h
5 | *******************************************************************************/
6 |
7 | #ifndef _VERSION_H_
8 | #define _VERSION_H_
9 |
10 | // https://semver.org/
11 | #define VERSION_MAJOR 0 /*! @brief Major Version Number */
12 | #define VERSION_MINOR 1 /*! @brief Minor Version Number */
13 | #define VERSION_PATCH 0 /*! @brief Patch Version Number */
14 |
15 | // If applicable a DEBUG version can be used
16 | #ifdef DEBUG_BUILD
17 | #define VERSION_DEBUG 1 /*! @brief Debug Version */
18 | #else
19 | #define VERSION_DEBUG 0 /*! @brief NON Debug Version */
20 | #endif
21 |
22 | #endif // _VERSION_H_
--------------------------------------------------------------------------------
/test/support/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/glassboard-dev/gl-vscode-template-arm/ba131956f4200abce4e258c2f8402c21762aa7a8/test/support/.gitkeep
--------------------------------------------------------------------------------
/vendor/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/glassboard-dev/gl-vscode-template-arm/ba131956f4200abce4e258c2f8402c21762aa7a8/vendor/.gitkeep
--------------------------------------------------------------------------------
/vendor/ceedling/template/inc_boilerplate.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | FILE DESCRIPTION
3 | Copyright (c) 2022 ENTITY_NAME
4 | FILENAME.h
5 | *******************************************************************************/
6 |
7 | /*! @file FILENAME.h
8 | * @brief Brief file description
9 | */
10 |
--------------------------------------------------------------------------------
/vendor/ceedling/template/src_boilerplate.c:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | FILE DESCRIPTION
3 | Copyright (c) 2022 ENTITY_NAME
4 | FILENAME.c
5 | *******************************************************************************/
6 |
7 | /*! @file FILENAME.c
8 | * @brief Brief file description
9 | */
10 |
11 | #include
12 | #include "error.h"
13 | #include "version.h"
--------------------------------------------------------------------------------