├── .gitignore ├── .github ├── ISSUE_TEMPLATE │ ├── question.md │ ├── feature_request.md │ └── bug_report.md └── workflows │ └── release.yaml ├── .vscode ├── extensions.json └── settings.json ├── CMakePresets.json ├── tests ├── unit │ ├── core │ │ ├── CMakeLists.txt │ │ ├── dict │ │ │ ├── CMakeLists.txt │ │ │ └── find │ │ │ │ └── CMakeLists.txt │ │ └── tmr │ │ │ ├── CMakeLists.txt │ │ │ ├── min_time │ │ │ └── CMakeLists.txt │ │ │ └── get_ticks │ │ │ └── CMakeLists.txt │ ├── object │ │ ├── CMakeLists.txt │ │ ├── basic │ │ │ ├── CMakeLists.txt │ │ │ ├── co_string │ │ │ │ └── CMakeLists.txt │ │ │ ├── co_domain │ │ │ │ └── CMakeLists.txt │ │ │ ├── co_signed8 │ │ │ │ └── CMakeLists.txt │ │ │ ├── co_signed16 │ │ │ │ └── CMakeLists.txt │ │ │ ├── co_signed32 │ │ │ │ └── CMakeLists.txt │ │ │ ├── co_unsigned8 │ │ │ │ └── CMakeLists.txt │ │ │ ├── co_unsigned16 │ │ │ │ └── CMakeLists.txt │ │ │ └── co_unsigned32 │ │ │ │ └── CMakeLists.txt │ │ └── cia301 │ │ │ ├── CMakeLists.txt │ │ │ ├── co_pdo_map │ │ │ └── CMakeLists.txt │ │ │ ├── co_pdo_num │ │ │ └── CMakeLists.txt │ │ │ ├── co_pdo_type │ │ │ └── CMakeLists.txt │ │ │ ├── co_sync_cycle │ │ │ └── CMakeLists.txt │ │ │ ├── co_hb_prod │ │ │ └── CMakeLists.txt │ │ │ ├── co_hb_cons │ │ │ └── CMakeLists.txt │ │ │ ├── co_pdo_id │ │ │ └── CMakeLists.txt │ │ │ ├── co_sdo_id │ │ │ └── CMakeLists.txt │ │ │ ├── co_emcy_id │ │ │ └── CMakeLists.txt │ │ │ ├── co_sync_id │ │ │ └── CMakeLists.txt │ │ │ ├── co_pdo_event │ │ │ └── CMakeLists.txt │ │ │ ├── co_emcy_hist │ │ │ └── CMakeLists.txt │ │ │ ├── co_para_restore │ │ │ └── CMakeLists.txt │ │ │ └── co_para_store │ │ │ └── CMakeLists.txt │ └── CMakeLists.txt ├── CMakeLists.txt └── integration │ ├── testfrm │ ├── ts_context.c │ ├── ts_output.h │ ├── ts_output.c │ └── ts_lock.c │ ├── driver │ ├── drv_nvm_sim.h │ ├── drv_timer_swcycle.h │ ├── drv_can_sim.h │ ├── drv_timer_swcycle.c │ └── drv_nvm_sim.c │ ├── app │ ├── app.h │ ├── app.c │ └── app_emcy.c │ └── CMakeLists.txt ├── examples ├── CMakeLists.txt ├── quickstart │ ├── CMakeLists.txt │ ├── driver │ │ ├── drv_nvm_sim.h │ │ ├── drv_timer_swcycle.h │ │ ├── drv_can_sim.h │ │ ├── drv_timer_swcycle.c │ │ └── drv_nvm_sim.c │ └── app │ │ └── clock_spec.h └── dynamic-od │ ├── CMakeLists.txt │ ├── driver │ ├── drv_nvm_sim.h │ ├── drv_timer_swcycle.h │ ├── drv_can_sim.h │ ├── drv_timer_swcycle.c │ └── drv_nvm_sim.c │ └── app │ ├── clock_spec.h │ └── clock_dict.h ├── src ├── hal │ ├── co_if.c │ ├── co_if_nvm.c │ ├── co_if_timer.c │ ├── co_if.h │ ├── co_if_can.c │ └── co_if_nvm.h ├── driver │ └── _template │ │ ├── drv_nvm_dummy.h │ │ ├── drv_can_dummy.h │ │ ├── drv_timer_dummy.h │ │ ├── drv_nvm_dummy.c │ │ └── drv_timer_dummy.c ├── object │ ├── basic │ │ ├── co_integer8.h │ │ ├── co_integer16.h │ │ ├── co_integer32.h │ │ ├── co_string.h │ │ └── co_domain.h │ └── cia301 │ │ ├── co_pdo_event.h │ │ ├── co_sync_cycle.h │ │ ├── co_pdo_map.h │ │ ├── co_pdo_id.h │ │ ├── co_pdo_num.h │ │ ├── co_pdo_type.h │ │ ├── co_hb_prod.h │ │ ├── co_sdo_id.h │ │ └── co_para.h ├── config │ └── co_cfg.h ├── CMakeLists.txt ├── core │ ├── co_types.h │ ├── co_ver.c │ └── co_ver.h └── service │ └── cia301 │ └── co_time.h └── CMakeLists.txt /.gitignore: -------------------------------------------------------------------------------- 1 | #ignore 2 | build/* 3 | out/* 4 | Testing/* 5 | .vscode/* 6 | 7 | #allow 8 | !.vscode/settings.json 9 | !.vscode/extensions.json 10 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/question.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Question 3 | about: Ask a question 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | Is your question related to a problem? Please describe. 11 | A clear and concise description of what the problem is. Ex. I'm don't understand how to [...] 12 | 13 | Additional context 14 | Add any other context or screenshots about the question here. 15 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | // List of extensions which should be recommended for users of this workspace. 3 | "recommendations": [ 4 | // programming in C 5 | "editorconfig.editorconfig", 6 | "ms-vscode.cpptools", 7 | "jbenden.c-cpp-flylint", 8 | // build environment 9 | "twxs.cmake", 10 | "ms-vscode.cmake-tools", 11 | "fredericbonnet.cmake-test-adapter", 12 | // version control 13 | "mhutchie.git-graph", 14 | "eamodio.gitlens", 15 | // documentation 16 | "yzhang.markdown-all-in-one", 17 | // target debugging Cortex-M 18 | "marus25.cortex-debug" 19 | ], 20 | // List of extensions recommended by VS Code that should not be recommended for users of this workspace. 21 | "unwantedRecommendations": [ 22 | 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /CMakePresets.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "configurePresets": [ 4 | { 5 | "name": "llvm-host", 6 | "displayName": "LLVM Compiler (Host)", 7 | "generator": "Ninja", 8 | "binaryDir": "build", 9 | "cacheVariables": { 10 | "CMAKE_C_COMPILER": "clang", 11 | "CMAKE_BUILD_TYPE": "Debug" 12 | } 13 | } 14 | ], 15 | "buildPresets": [ 16 | { 17 | "name": "debug", 18 | "configurePreset": "llvm-host", 19 | "displayName": "Debug Build (Host)", 20 | "targets": [ "all" ], 21 | "jobs": 5 22 | } 23 | ], 24 | "testPresets": [ 25 | { 26 | "name": "all", 27 | "displayName": "All Tests (Host)", 28 | "configurePreset": "llvm-host", 29 | "execution": { 30 | "jobs": 5 31 | } 32 | } 33 | ] 34 | } 35 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. setup object entry to '...' 16 | 2. send CAN request '....' 17 | 3. See error 18 | 19 | **Expected behavior** 20 | A clear and concise description of what you expected to happen. 21 | 22 | **Screenshots** 23 | If applicable, add screenshots to help explain your problem. 24 | 25 | **CANopen Stack (please complete the following information):** 26 | - Device: [e.g. STM32F429] 27 | - OS: [e.g. none] 28 | - Version [e.g. v1.2.3] 29 | 30 | **Additional context** 31 | Add any other context about the problem here. 32 | -------------------------------------------------------------------------------- /.github/workflows/release.yaml: -------------------------------------------------------------------------------- 1 | name: Release 2 | permissions: 3 | contents: write 4 | 5 | on: 6 | release: 7 | types: [published] 8 | 9 | jobs: 10 | release: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v3 14 | 15 | - name: Create build environment 16 | run: cmake -E make_directory build 17 | - name: Configure 18 | working-directory: build/ 19 | run: cmake $GITHUB_WORKSPACE 20 | - name: Package source code 21 | working-directory: build/ 22 | run: cmake --build . --target canopen-stack_package 23 | 24 | - name: Add packaged source code to release 25 | uses: svenstaro/upload-release-action@v2 26 | with: 27 | repo_token: ${{ secrets.GITHUB_TOKEN }} 28 | file: build/canopen-stack-src.zip 29 | tag: ${{ github.ref }} 30 | -------------------------------------------------------------------------------- /tests/unit/core/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************** 2 | # Copyright 2020 Embedded Office GmbH & Co. KG 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #****************************************************************************** 16 | 17 | add_subdirectory(dict) 18 | add_subdirectory(tmr) 19 | -------------------------------------------------------------------------------- /examples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************** 2 | # Copyright 2020 Embedded Office GmbH & Co. KG 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #****************************************************************************** 16 | 17 | add_subdirectory(quickstart) 18 | add_subdirectory(dynamic-od) 19 | -------------------------------------------------------------------------------- /tests/unit/core/dict/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************** 2 | # Copyright 2020 Embedded Office GmbH & Co. KG 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #****************************************************************************** 16 | 17 | # dictionary functions 18 | add_subdirectory(find) 19 | -------------------------------------------------------------------------------- /tests/unit/object/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************** 2 | # Copyright 2020 Embedded Office GmbH & Co. KG 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #****************************************************************************** 16 | 17 | add_subdirectory(basic) 18 | add_subdirectory(cia301) 19 | -------------------------------------------------------------------------------- /tests/unit/core/tmr/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************** 2 | # Copyright 2020 Embedded Office GmbH & Co. KG 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #****************************************************************************** 16 | 17 | # timer functions 18 | add_subdirectory(get_ticks) 19 | add_subdirectory(min_time) 20 | -------------------------------------------------------------------------------- /tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************** 2 | # Copyright 2020 Embedded Office GmbH & Co. KG 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #****************************************************************************** 16 | 17 | #--- 18 | # tests in different test depths: 19 | # 20 | add_subdirectory(unit) 21 | add_subdirectory(integration) 22 | -------------------------------------------------------------------------------- /tests/unit/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************** 2 | # Copyright 2020 Embedded Office GmbH & Co. KG 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #****************************************************************************** 16 | 17 | #--- 18 | # test environment library 19 | # 20 | add_library(ut-test-env INTERFACE) 21 | target_include_directories(ut-test-env 22 | INTERFACE 23 | env 24 | ) 25 | 26 | #--- 27 | # unit tests 28 | # 29 | add_subdirectory(core) 30 | add_subdirectory(object) 31 | -------------------------------------------------------------------------------- /tests/unit/object/basic/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************** 2 | # Copyright 2020 Embedded Office GmbH & Co. KG 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #****************************************************************************** 16 | 17 | # basic types 18 | add_subdirectory(co_domain) 19 | add_subdirectory(co_signed8) 20 | add_subdirectory(co_signed16) 21 | add_subdirectory(co_signed32) 22 | add_subdirectory(co_string) 23 | add_subdirectory(co_unsigned8) 24 | add_subdirectory(co_unsigned16) 25 | add_subdirectory(co_unsigned32) 26 | -------------------------------------------------------------------------------- /tests/unit/object/cia301/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************** 2 | # Copyright 2020 Embedded Office GmbH & Co. KG 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #****************************************************************************** 16 | 17 | # CiA301 types 18 | add_subdirectory(co_emcy_hist) 19 | add_subdirectory(co_emcy_id) 20 | add_subdirectory(co_hb_cons) 21 | add_subdirectory(co_hb_prod) 22 | add_subdirectory(co_para_store) 23 | add_subdirectory(co_para_restore) 24 | add_subdirectory(co_pdo_event) 25 | add_subdirectory(co_pdo_id) 26 | add_subdirectory(co_pdo_map) 27 | add_subdirectory(co_pdo_num) 28 | add_subdirectory(co_pdo_type) 29 | add_subdirectory(co_sdo_id) 30 | add_subdirectory(co_sync_cycle) 31 | add_subdirectory(co_sync_id) 32 | -------------------------------------------------------------------------------- /tests/integration/testfrm/ts_context.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2020 Embedded Office GmbH & Co. KG 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ******************************************************************************/ 16 | 17 | /****************************************************************************** 18 | * INCLUDES 19 | ******************************************************************************/ 20 | 21 | #include "ts_context.h" 22 | 23 | /****************************************************************************** 24 | * PUBLIC FUNCTIONS 25 | ******************************************************************************/ 26 | 27 | void TS_SaveMachineRegs(void) 28 | { 29 | /* not used */ 30 | } 31 | 32 | 33 | void TS_RestoreMachineRegs(void) 34 | { 35 | /* not used */ 36 | } 37 | -------------------------------------------------------------------------------- /examples/quickstart/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************** 2 | # Copyright 2020 Embedded Office GmbH & Co. KG 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #****************************************************************************** 16 | 17 | #--- 18 | # define the test application executable 19 | # 20 | add_executable(demo-quickstart) 21 | 22 | #--- 23 | # test application with test runner and supporting functions 24 | # 25 | target_sources(demo-quickstart 26 | PRIVATE 27 | # application 28 | app/clock_app.c 29 | app/clock_spec.c 30 | # driver 31 | driver/drv_can_sim.c 32 | driver/drv_nvm_sim.c 33 | driver/drv_timer_swcycle.c 34 | ) 35 | target_include_directories(demo-quickstart 36 | PRIVATE 37 | app 38 | driver 39 | ) 40 | 41 | #--- 42 | # specify the dependencies for this application 43 | # 44 | target_link_libraries(demo-quickstart canopen-stack) 45 | -------------------------------------------------------------------------------- /tests/unit/core/tmr/min_time/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************** 2 | # Copyright 2020 Embedded Office GmbH & Co. KG 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #****************************************************************************** 16 | 17 | add_executable(ut-tmr-min-time main.c) 18 | target_link_libraries(ut-tmr-min-time canopen-stack ut-test-env) 19 | 20 | 21 | #--- type function interface tests --- 22 | 23 | add_test(NAME unit/tmr/min_time/1MHz_1ms COMMAND ut-tmr-min-time 1MHz_1ms ) 24 | add_test(NAME unit/tmr/min_time/1MHz_100us COMMAND ut-tmr-min-time 1MHz_100us ) 25 | add_test(NAME unit/tmr/min_time/1kHz_1ms COMMAND ut-tmr-min-time 1kHz_1ms ) 26 | add_test(NAME unit/tmr/min_time/1kHz_100us COMMAND ut-tmr-min-time 1kHz_100us ) 27 | add_test(NAME unit/tmr/min_time/100Hz_1ms COMMAND ut-tmr-min-time 100Hz_1ms ) 28 | add_test(NAME unit/tmr/min_time/100Hz_100us COMMAND ut-tmr-min-time 100Hz_100us ) 29 | -------------------------------------------------------------------------------- /examples/dynamic-od/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************** 2 | # Copyright 2020 Embedded Office GmbH & Co. KG 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #****************************************************************************** 16 | 17 | #--- 18 | # define the test application executable 19 | # 20 | add_executable(demo-dynamic-od) 21 | 22 | #--- 23 | # test application with test runner and supporting functions 24 | # 25 | target_sources(demo-dynamic-od 26 | PRIVATE 27 | # application 28 | app/clock_dict.c 29 | app/clock_app.c 30 | app/clock_spec.c 31 | # driver 32 | driver/drv_can_sim.c 33 | driver/drv_nvm_sim.c 34 | driver/drv_timer_swcycle.c 35 | ) 36 | target_include_directories(demo-dynamic-od 37 | PRIVATE 38 | app 39 | driver 40 | ) 41 | 42 | #--- 43 | # specify the dependencies for this application 44 | # 45 | target_link_libraries(demo-dynamic-od canopen-stack) 46 | -------------------------------------------------------------------------------- /tests/unit/core/dict/find/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************** 2 | # Copyright 2020 Embedded Office GmbH & Co. KG 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #****************************************************************************** 16 | 17 | add_executable(ut-dict-find main.c) 18 | target_link_libraries(ut-dict-find canopen-stack ut-test-env) 19 | 20 | 21 | #--- type function interface tests --- 22 | 23 | add_test(NAME unit/dict/find/no_init COMMAND ut-dict-find no_init ) 24 | add_test(NAME unit/dict/find/empty COMMAND ut-dict-find empty ) 25 | add_test(NAME unit/dict/find/single COMMAND ut-dict-find single ) 26 | add_test(NAME unit/dict/find/first COMMAND ut-dict-find first ) 27 | add_test(NAME unit/dict/find/middle COMMAND ut-dict-find middle ) 28 | add_test(NAME unit/dict/find/last COMMAND ut-dict-find last ) 29 | add_test(NAME unit/dict/find/not_found COMMAND ut-dict-find not_found ) 30 | -------------------------------------------------------------------------------- /examples/dynamic-od/driver/drv_nvm_sim.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2020 Embedded Office GmbH & Co. KG 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ******************************************************************************/ 16 | 17 | #ifndef CO_NVM_SIM_H_ 18 | #define CO_NVM_SIM_H_ 19 | 20 | #ifdef __cplusplus /* for compatibility with C++ environments */ 21 | extern "C" { 22 | #endif 23 | 24 | /****************************************************************************** 25 | * INCLUDES 26 | ******************************************************************************/ 27 | 28 | #include "co_if.h" 29 | 30 | /****************************************************************************** 31 | * PUBLIC SYMBOLS 32 | ******************************************************************************/ 33 | 34 | extern const CO_IF_NVM_DRV SimNvmDriver; 35 | 36 | #ifdef __cplusplus /* for compatibility with C++ environments */ 37 | } 38 | #endif 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /examples/quickstart/driver/drv_nvm_sim.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2020 Embedded Office GmbH & Co. KG 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ******************************************************************************/ 16 | 17 | #ifndef CO_NVM_SIM_H_ 18 | #define CO_NVM_SIM_H_ 19 | 20 | #ifdef __cplusplus /* for compatibility with C++ environments */ 21 | extern "C" { 22 | #endif 23 | 24 | /****************************************************************************** 25 | * INCLUDES 26 | ******************************************************************************/ 27 | 28 | #include "co_if.h" 29 | 30 | /****************************************************************************** 31 | * PUBLIC SYMBOLS 32 | ******************************************************************************/ 33 | 34 | extern const CO_IF_NVM_DRV SimNvmDriver; 35 | 36 | #ifdef __cplusplus /* for compatibility with C++ environments */ 37 | } 38 | #endif 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /tests/integration/driver/drv_nvm_sim.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2020 Embedded Office GmbH & Co. KG 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ******************************************************************************/ 16 | 17 | #ifndef CO_NVM_SIM_H_ 18 | #define CO_NVM_SIM_H_ 19 | 20 | #ifdef __cplusplus /* for compatibility with C++ environments */ 21 | extern "C" { 22 | #endif 23 | 24 | /****************************************************************************** 25 | * INCLUDES 26 | ******************************************************************************/ 27 | 28 | #include "co_if.h" 29 | 30 | /****************************************************************************** 31 | * PUBLIC SYMBOLS 32 | ******************************************************************************/ 33 | 34 | extern const CO_IF_NVM_DRV SimNvmDriver; 35 | 36 | #ifdef __cplusplus /* for compatibility with C++ environments */ 37 | } 38 | #endif 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /examples/dynamic-od/driver/drv_timer_swcycle.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2020 Embedded Office GmbH & Co. KG 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ******************************************************************************/ 16 | 17 | #ifndef CO_TIMER_SWCYCLE_H_ 18 | #define CO_TIMER_SWCYCLE_H_ 19 | 20 | #ifdef __cplusplus /* for compatibility with C++ environments */ 21 | extern "C" { 22 | #endif 23 | 24 | /****************************************************************************** 25 | * INCLUDES 26 | ******************************************************************************/ 27 | 28 | #include "co_if.h" 29 | 30 | /****************************************************************************** 31 | * PUBLIC SYMBOLS 32 | ******************************************************************************/ 33 | 34 | extern const CO_IF_TIMER_DRV SwCycleTimerDriver; 35 | 36 | #ifdef __cplusplus /* for compatibility with C++ environments */ 37 | } 38 | #endif 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /examples/quickstart/driver/drv_timer_swcycle.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2020 Embedded Office GmbH & Co. KG 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ******************************************************************************/ 16 | 17 | #ifndef CO_TIMER_SWCYCLE_H_ 18 | #define CO_TIMER_SWCYCLE_H_ 19 | 20 | #ifdef __cplusplus /* for compatibility with C++ environments */ 21 | extern "C" { 22 | #endif 23 | 24 | /****************************************************************************** 25 | * INCLUDES 26 | ******************************************************************************/ 27 | 28 | #include "co_if.h" 29 | 30 | /****************************************************************************** 31 | * PUBLIC SYMBOLS 32 | ******************************************************************************/ 33 | 34 | extern const CO_IF_TIMER_DRV SwCycleTimerDriver; 35 | 36 | #ifdef __cplusplus /* for compatibility with C++ environments */ 37 | } 38 | #endif 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /tests/integration/driver/drv_timer_swcycle.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2020 Embedded Office GmbH & Co. KG 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ******************************************************************************/ 16 | 17 | #ifndef CO_TIMER_SWCYCLE_H_ 18 | #define CO_TIMER_SWCYCLE_H_ 19 | 20 | #ifdef __cplusplus /* for compatibility with C++ environments */ 21 | extern "C" { 22 | #endif 23 | 24 | /****************************************************************************** 25 | * INCLUDES 26 | ******************************************************************************/ 27 | 28 | #include "co_if.h" 29 | 30 | /****************************************************************************** 31 | * PUBLIC SYMBOLS 32 | ******************************************************************************/ 33 | 34 | extern const CO_IF_TIMER_DRV SwCycleTimerDriver; 35 | 36 | #ifdef __cplusplus /* for compatibility with C++ environments */ 37 | } 38 | #endif 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools", 3 | "cmake.configureOnOpen": true, 4 | 5 | "cmakeExplorer.suiteDelimiter": "/", 6 | 7 | "c-cpp-flylint.debug": true, 8 | "c-cpp-flylint.run": "onBuild", 9 | 10 | "c-cpp-flylint.clang.enable": false, 11 | "c-cpp-flylint.flawfinder.enable": false, 12 | "c-cpp-flylint.flexelint.enable": false, 13 | "c-cpp-flylint.lizard.enable": false, 14 | 15 | "c-cpp-flylint.cppcheck.enable": true, 16 | "c-cpp-flylint.cppcheck.language": "c", 17 | "c-cpp-flylint.cppcheck.standard": [ "c99" ], 18 | "c-cpp-flylint.cppcheck.force": true, 19 | "c-cpp-flylint.cppcheck.suppressions": [ 20 | "variableScope", // reason: we want to declare all used variables in a function at the top 21 | "unusedStructMember", // reason: we provide structures for use in the application 22 | "comparePointers", // reason: we need to loop through the testcase structures in the test section 23 | "constParameter", // reason: we want to avoid const parameters for easier function usage 24 | "ConfigurationNotChecked" // reason: we want to avoid problems with the C test framework 'acutest.h' 25 | ], 26 | "c-cpp-flylint.cppcheck.includePaths": [ 27 | // CANopen Library 28 | "src/config", 29 | "src/core", 30 | "src/hal", 31 | "src/object/basic", 32 | "src/object/cia301", 33 | "src/service/cia301", 34 | "src/service/cia305", 35 | // Library Testing 36 | "tests/integration/app", 37 | "tests/integration/driver", 38 | "tests/integration/testfrm", 39 | "tests/integration/tests", 40 | "tests/unit/env", 41 | ] 42 | } 43 | -------------------------------------------------------------------------------- /src/hal/co_if.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2020 Embedded Office GmbH & Co. KG 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ******************************************************************************/ 16 | 17 | /****************************************************************************** 18 | * INCLUDES 19 | ******************************************************************************/ 20 | 21 | #include "co_core.h" 22 | 23 | /****************************************************************************** 24 | * PUBLIC FUNCTIONS 25 | ******************************************************************************/ 26 | 27 | /* 28 | * see function definition 29 | */ 30 | void COIfInit(CO_IF *cif, struct CO_NODE_T *node, uint32_t freq) 31 | { 32 | const CO_IF_CAN_DRV *can = cif->Drv->Can; 33 | const CO_IF_TIMER_DRV *timer = cif->Drv->Timer; 34 | const CO_IF_NVM_DRV *nvm = cif->Drv->Nvm; 35 | 36 | /* initialize interface structure */ 37 | cif->Node = node; 38 | 39 | /* initialize hardware via drivers */ 40 | nvm->Init(); 41 | timer->Init(freq); 42 | can->Init(); 43 | } 44 | -------------------------------------------------------------------------------- /src/hal/co_if_nvm.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2020 Embedded Office GmbH & Co. KG 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ******************************************************************************/ 16 | 17 | /****************************************************************************** 18 | * INCLUDES 19 | ******************************************************************************/ 20 | 21 | #include "co_core.h" 22 | 23 | /****************************************************************************** 24 | * PUBLIC FUNCTIONS 25 | ******************************************************************************/ 26 | 27 | /* 28 | * see function definition 29 | */ 30 | uint32_t COIfNvmRead(struct CO_IF_T *cif, uint32_t start, uint8_t *buffer, uint32_t size) 31 | { 32 | const CO_IF_NVM_DRV *nvm = cif->Drv->Nvm; 33 | uint32_t num = nvm->Read(start, buffer, size); 34 | return (num); 35 | } 36 | 37 | /* 38 | * see function definition 39 | */ 40 | uint32_t COIfNvmWrite(struct CO_IF_T *cif, uint32_t start, uint8_t *buffer, uint32_t size) 41 | { 42 | const CO_IF_NVM_DRV *nvm = cif->Drv->Nvm; 43 | uint32_t num = nvm->Write(start, buffer, size); 44 | return (num); 45 | } 46 | -------------------------------------------------------------------------------- /tests/unit/object/basic/co_string/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************** 2 | # Copyright 2020 Embedded Office GmbH & Co. KG 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #****************************************************************************** 16 | 17 | add_executable(ut-string main.c) 18 | target_link_libraries(ut-string canopen-stack ut-test-env) 19 | 20 | 21 | #--- type function interface tests --- 22 | 23 | add_test(NAME unit/object/string/size/unknown COMMAND ut-string size_unknown ) 24 | add_test(NAME unit/object/string/size/known COMMAND ut-string size_known ) 25 | add_test(NAME unit/object/string/size/bad_size COMMAND ut-string bad_size ) 26 | add_test(NAME unit/object/string/read/ref COMMAND ut-string read_ref ) 27 | add_test(NAME unit/object/string/read/bad_node COMMAND ut-string read_bad_node ) 28 | add_test(NAME unit/object/string/write/ref COMMAND ut-string write_ref ) 29 | add_test(NAME unit/object/string/write/bad_node COMMAND ut-string write_bad_node) 30 | add_test(NAME unit/object/string/init/offset COMMAND ut-string init_offset ) 31 | add_test(NAME unit/object/string/reset/offset COMMAND ut-string reset_offset ) 32 | -------------------------------------------------------------------------------- /src/driver/_template/drv_nvm_dummy.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2020 Embedded Office GmbH & Co. KG 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ******************************************************************************/ 16 | 17 | /* TODO: rename the include protection to match the naming convention: 18 | * CO_NVM__H_ 19 | */ 20 | #ifndef CO_NVM_DUMMY_H_ 21 | #define CO_NVM_DUMMY_H_ 22 | 23 | #ifdef __cplusplus /* for compatibility with C++ environments */ 24 | extern "C" { 25 | #endif 26 | 27 | /****************************************************************************** 28 | * INCLUDES 29 | ******************************************************************************/ 30 | 31 | #include "co_if.h" 32 | 33 | /****************************************************************************** 34 | * PUBLIC SYMBOLS 35 | ******************************************************************************/ 36 | 37 | /* TODO: rename the extern variable declaration to match the naming convention: 38 | * NvmDriver 39 | */ 40 | extern const CO_IF_NVM_DRV DummyNvmDriver; 41 | 42 | #ifdef __cplusplus /* for compatibility with C++ environments */ 43 | } 44 | #endif 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /src/driver/_template/drv_can_dummy.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2020 Embedded Office GmbH & Co. KG 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ******************************************************************************/ 16 | 17 | /* TODO: rename the include protection to match the naming convention: 18 | * CO_CAN__H_ 19 | */ 20 | #ifndef CO_CAN_DUMMY_H_ 21 | #define CO_CAN_DUMMY_H_ 22 | 23 | #ifdef __cplusplus /* for compatibility with C++ environments */ 24 | extern "C" { 25 | #endif 26 | 27 | /****************************************************************************** 28 | * INCLUDES 29 | ******************************************************************************/ 30 | 31 | #include "co_if.h" 32 | 33 | /****************************************************************************** 34 | * PUBLIC SYMBOLS 35 | ******************************************************************************/ 36 | 37 | /* TODO: rename the extern variable declaration to match the naming convention: 38 | * CanDriver 39 | */ 40 | extern const CO_IF_CAN_DRV DummyCanDriver; 41 | 42 | #ifdef __cplusplus /* for compatibility with C++ environments */ 43 | } 44 | #endif 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /src/driver/_template/drv_timer_dummy.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2020 Embedded Office GmbH & Co. KG 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ******************************************************************************/ 16 | 17 | /* TODO: rename the include protection to match the naming convention: 18 | * CO_TIMER__H_ 19 | */ 20 | #ifndef CO_TIMER_DUMMY_H_ 21 | #define CO_TIMER_DUMMY_H_ 22 | 23 | #ifdef __cplusplus /* for compatibility with C++ environments */ 24 | extern "C" { 25 | #endif 26 | 27 | /****************************************************************************** 28 | * INCLUDES 29 | ******************************************************************************/ 30 | 31 | #include "co_if.h" 32 | 33 | /****************************************************************************** 34 | * PUBLIC SYMBOLS 35 | ******************************************************************************/ 36 | 37 | /* TODO: rename the extern variable declaration to match the naming convention: 38 | * TimerDriver 39 | */ 40 | extern const CO_IF_TIMER_DRV DummyTimerDriver; 41 | 42 | #ifdef __cplusplus /* for compatibility with C++ environments */ 43 | } 44 | #endif 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /tests/integration/testfrm/ts_output.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2020 Embedded Office GmbH & Co. KG 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ******************************************************************************/ 16 | 17 | #ifndef TS_OUTPUT_H_ 18 | #define TS_OUTPUT_H_ 19 | 20 | #ifdef __cplusplus /* for compatibility with C++ environments */ 21 | extern "C" { 22 | #endif 23 | 24 | /****************************************************************************** 25 | * PUBLIC FUNCTIONS 26 | ******************************************************************************/ 27 | 28 | /*------------------------------------------------------------------------------------------------*/ 29 | /*! 30 | * \details This function realizes the routing of printed character to the test report interface. 31 | * 32 | * \param arg 33 | * Not used, must be existing to cover callback interface 34 | * 35 | * \param character 36 | * Single character byte for output 37 | */ 38 | /*------------------------------------------------------------------------------------------------*/ 39 | void TS_PutChar(void *arg, char character); 40 | 41 | #ifdef __cplusplus /* for compatibility with C++ environments */ 42 | } 43 | #endif 44 | 45 | #endif /* TS_OUTPUT_H_ */ 46 | -------------------------------------------------------------------------------- /tests/unit/object/cia301/co_pdo_map/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************** 2 | # Copyright 2020 Embedded Office GmbH & Co. KG 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #****************************************************************************** 16 | 17 | add_executable(ut-pdo-map main.c) 18 | target_link_libraries(ut-pdo-map canopen-stack ut-test-env) 19 | 20 | 21 | #--- type function interface tests --- 22 | 23 | add_test(NAME unit/object/pdo-map/size/unknown COMMAND ut-pdo-map size_unknown ) 24 | add_test(NAME unit/object/pdo-map/size/known COMMAND ut-pdo-map size_known ) 25 | add_test(NAME unit/object/pdo-map/size/bad_size COMMAND ut-pdo-map size_bad_size ) 26 | add_test(NAME unit/object/pdo-map/read/ref COMMAND ut-pdo-map read_ref ) 27 | add_test(NAME unit/object/pdo-map/read/direct COMMAND ut-pdo-map read_direct ) 28 | add_test(NAME unit/object/pdo-map/read/bad_node COMMAND ut-pdo-map read_bad_node ) 29 | add_test(NAME unit/object/pdo-map/write/mapping COMMAND ut-pdo-map write_mapping ) 30 | add_test(NAME unit/object/pdo-map/write/bad_node COMMAND ut-pdo-map write_bad_node ) 31 | add_test(NAME unit/object/pdo-map/init/check COMMAND ut-pdo-map init_check ) 32 | add_test(NAME unit/object/pdo-map/init/bad_index COMMAND ut-pdo-map init_bad_index ) 33 | add_test(NAME unit/object/pdo-map/reset/unused COMMAND ut-pdo-map reset_unused ) 34 | -------------------------------------------------------------------------------- /examples/dynamic-od/app/clock_spec.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2020 Embedded Office GmbH & Co. KG 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ******************************************************************************/ 16 | 17 | #ifndef APP_CLOCK_H_ 18 | #define APP_CLOCK_H_ 19 | 20 | #ifdef __cplusplus /* for compatibility with C++ environments */ 21 | extern "C" { 22 | #endif 23 | 24 | /****************************************************************************** 25 | * INCLUDES 26 | ******************************************************************************/ 27 | 28 | #include "clock_dict.h" 29 | 30 | /****************************************************************************** 31 | * PUBLIC DEFINES 32 | ******************************************************************************/ 33 | 34 | /* Specify the EMCY-IDs for the application */ 35 | enum EMCY_CODES { 36 | APP_ERR_ID_SOMETHING = 0, 37 | APP_ERR_ID_HOT, 38 | 39 | APP_ERR_ID_NUM /* number of EMCY error codes in application */ 40 | }; 41 | 42 | /****************************************************************************** 43 | * PUBLIC FUNCTIONS 44 | ******************************************************************************/ 45 | 46 | void ClkStartNode(CO_NODE *node); 47 | 48 | #ifdef __cplusplus /* for compatibility with C++ environments */ 49 | } 50 | #endif 51 | 52 | #endif /* APP_CLOCK_H_ */ 53 | -------------------------------------------------------------------------------- /examples/quickstart/app/clock_spec.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2020 Embedded Office GmbH & Co. KG 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ******************************************************************************/ 16 | 17 | #ifndef APP_CLOCK_H_ 18 | #define APP_CLOCK_H_ 19 | 20 | #ifdef __cplusplus /* for compatibility with C++ environments */ 21 | extern "C" { 22 | #endif 23 | 24 | /****************************************************************************** 25 | * INCLUDES 26 | ******************************************************************************/ 27 | 28 | #include "co_core.h" 29 | 30 | /****************************************************************************** 31 | * PUBLIC DEFINES 32 | ******************************************************************************/ 33 | 34 | /* Specify the EMCY-IDs for the application */ 35 | enum EMCY_CODES { 36 | APP_ERR_ID_SOMETHING = 0, 37 | APP_ERR_ID_HOT, 38 | 39 | APP_ERR_ID_NUM /* number of EMCY error codes in application */ 40 | }; 41 | 42 | /****************************************************************************** 43 | * PUBLIC SYMBOLS 44 | ******************************************************************************/ 45 | 46 | extern struct CO_NODE_SPEC_T AppSpec; 47 | 48 | #ifdef __cplusplus /* for compatibility with C++ environments */ 49 | } 50 | #endif 51 | 52 | #endif /* APP_CLOCK_H_ */ 53 | -------------------------------------------------------------------------------- /tests/integration/testfrm/ts_output.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2020 Embedded Office GmbH & Co. KG 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ******************************************************************************/ 16 | 17 | /****************************************************************************** 18 | * INCLUDES 19 | ******************************************************************************/ 20 | 21 | #include "ts_output.h" 22 | #include 23 | 24 | /****************************************************************************** 25 | * PRIVATE FUNCTIONS 26 | ******************************************************************************/ 27 | 28 | /*------------------------------------------------------------------------------------------------*/ 29 | /*! 30 | * \details This function is the implementation for routing the output stream to the operating 31 | * system stdio terminal. 32 | */ 33 | /*------------------------------------------------------------------------------------------------*/ 34 | void TS_PutChar(void *arg, char character) 35 | { 36 | #if defined ( _MSC_VER ) 37 | (void)arg; 38 | putchar((int)character); 39 | #else 40 | /* 41 | * \note The testsuite is running with MSVC compiler on the windows host, only. You may 42 | * adjust the settings ts_types.h and provide an output channel here to get the tests 43 | * running on your target, too. 44 | */ 45 | (void)arg; 46 | (void)character; 47 | #endif 48 | } 49 | -------------------------------------------------------------------------------- /tests/unit/object/cia301/co_pdo_num/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************** 2 | # Copyright 2020 Embedded Office GmbH & Co. KG 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #****************************************************************************** 16 | 17 | add_executable(ut-pdo-num main.c) 18 | target_link_libraries(ut-pdo-num canopen-stack ut-test-env) 19 | 20 | 21 | #--- type function interface tests --- 22 | 23 | add_test(NAME unit/object/pdo-num/size/unknown COMMAND ut-pdo-num size_unknown ) 24 | add_test(NAME unit/object/pdo-num/size/known COMMAND ut-pdo-num size_known ) 25 | add_test(NAME unit/object/pdo-num/size/bad_size COMMAND ut-pdo-num size_bad_size ) 26 | add_test(NAME unit/object/pdo-num/read/ref COMMAND ut-pdo-num read_ref ) 27 | add_test(NAME unit/object/pdo-num/read/direct COMMAND ut-pdo-num read_direct ) 28 | add_test(NAME unit/object/pdo-num/read/bad_node COMMAND ut-pdo-num read_bad_node ) 29 | add_test(NAME unit/object/pdo-num/write/num COMMAND ut-pdo-num write_num ) 30 | add_test(NAME unit/object/pdo-num/write/bad_node COMMAND ut-pdo-num write_bad_node ) 31 | add_test(NAME unit/object/pdo-num/init/check COMMAND ut-pdo-num init_check ) 32 | add_test(NAME unit/object/pdo-num/init/bad_index COMMAND ut-pdo-num init_bad_index ) 33 | add_test(NAME unit/object/pdo-num/init/bad_sub COMMAND ut-pdo-num init_bad_sub ) 34 | add_test(NAME unit/object/pdo-num/reset/unused COMMAND ut-pdo-num reset_unused ) 35 | -------------------------------------------------------------------------------- /examples/dynamic-od/app/clock_dict.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2020 Embedded Office GmbH & Co. KG 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ******************************************************************************/ 16 | 17 | #ifndef APP_DICT_H_ 18 | #define APP_DICT_H_ 19 | 20 | #ifdef __cplusplus /* for compatibility with C++ environments */ 21 | extern "C" { 22 | #endif 23 | 24 | /****************************************************************************** 25 | * INCLUDES 26 | ******************************************************************************/ 27 | 28 | #include "co_core.h" 29 | 30 | /****************************************************************************** 31 | * PUBLIC TYPEDEF 32 | ******************************************************************************/ 33 | 34 | typedef struct { 35 | CO_OBJ *Root; 36 | uint32_t Length; 37 | uint32_t Used; 38 | } OD_DYN; 39 | 40 | /****************************************************************************** 41 | * PUBLIC FUNCTIONS 42 | ******************************************************************************/ 43 | 44 | void ODInit(OD_DYN *self, CO_OBJ *root, uint32_t length); 45 | void ODAddUpdate(OD_DYN *self, uint32_t key, const CO_OBJ_TYPE *type, CO_DATA data); 46 | void ODSetSpec(OD_DYN *self, CO_NODE_SPEC *spec); 47 | 48 | #ifdef __cplusplus /* for compatibility with C++ environments */ 49 | } 50 | #endif 51 | 52 | #endif /* APP_DICT_H_ */ 53 | -------------------------------------------------------------------------------- /tests/unit/object/cia301/co_pdo_type/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************** 2 | # Copyright 2020 Embedded Office GmbH & Co. KG 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #****************************************************************************** 16 | 17 | add_executable(ut-pdo-type main.c) 18 | target_link_libraries(ut-pdo-type canopen-stack ut-test-env) 19 | 20 | 21 | #--- type function interface tests --- 22 | 23 | add_test(NAME unit/object/pdo-type/size/unknown COMMAND ut-pdo-type size_unknown ) 24 | add_test(NAME unit/object/pdo-type/size/known COMMAND ut-pdo-type size_known ) 25 | add_test(NAME unit/object/pdo-type/size/bad_size COMMAND ut-pdo-type size_bad_size ) 26 | add_test(NAME unit/object/pdo-type/read/ref COMMAND ut-pdo-type read_ref ) 27 | add_test(NAME unit/object/pdo-type/read/direct COMMAND ut-pdo-type read_direct ) 28 | add_test(NAME unit/object/pdo-type/read/bad_node COMMAND ut-pdo-type read_bad_node ) 29 | add_test(NAME unit/object/pdo-type/write/num COMMAND ut-pdo-type write_num ) 30 | add_test(NAME unit/object/pdo-type/write/bad_node COMMAND ut-pdo-type write_bad_node ) 31 | add_test(NAME unit/object/pdo-type/init/check COMMAND ut-pdo-type init_check ) 32 | add_test(NAME unit/object/pdo-type/init/bad_index COMMAND ut-pdo-type init_bad_index ) 33 | add_test(NAME unit/object/pdo-type/init/bad_sub COMMAND ut-pdo-type init_bad_sub ) 34 | add_test(NAME unit/object/pdo-type/reset/unused COMMAND ut-pdo-type reset_unused ) 35 | -------------------------------------------------------------------------------- /tests/unit/object/basic/co_domain/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************** 2 | # Copyright 2020 Embedded Office GmbH & Co. KG 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #****************************************************************************** 16 | 17 | add_executable(ut-domain main.c) 18 | target_link_libraries(ut-domain canopen-stack ut-test-env) 19 | 20 | 21 | #--- type function interface tests --- 22 | 23 | add_test(NAME unit/object/domain/size/unknown COMMAND ut-domain size_unknown ) 24 | add_test(NAME unit/object/domain/size/known COMMAND ut-domain size_known ) 25 | add_test(NAME unit/object/domain/size/small COMMAND ut-domain size_small ) 26 | add_test(NAME unit/object/domain/size/large COMMAND ut-domain size_large ) 27 | add_test(NAME unit/object/domain/size/bad_size COMMAND ut-domain bad_size ) 28 | add_test(NAME unit/object/domain/read/all COMMAND ut-domain read_all ) 29 | add_test(NAME unit/object/domain/read/part COMMAND ut-domain read_part ) 30 | add_test(NAME unit/object/domain/read/bad_node COMMAND ut-domain read_bad_node ) 31 | add_test(NAME unit/object/domain/write/all COMMAND ut-domain write_all ) 32 | add_test(NAME unit/object/domain/write/part COMMAND ut-domain write_part ) 33 | add_test(NAME unit/object/domain/write/bad_node COMMAND ut-domain write_bad_node) 34 | add_test(NAME unit/object/domain/init/offset COMMAND ut-domain init_offset ) 35 | add_test(NAME unit/object/domain/reset/offset COMMAND ut-domain reset_offset ) 36 | -------------------------------------------------------------------------------- /tests/unit/object/cia301/co_sync_cycle/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************** 2 | # Copyright 2020 Embedded Office GmbH & Co. KG 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #****************************************************************************** 16 | 17 | add_executable(ut-sync-cycle main.c) 18 | target_link_libraries(ut-sync-cycle canopen-stack ut-test-env) 19 | 20 | 21 | #--- type function interface tests --- 22 | 23 | add_test(NAME unit/object/sync-cycle/size/unknown COMMAND ut-sync-cycle size_unknown ) 24 | add_test(NAME unit/object/sync-cycle/size/known COMMAND ut-sync-cycle size_known ) 25 | add_test(NAME unit/object/sync-cycle/size/bad_size COMMAND ut-sync-cycle size_bad_size ) 26 | add_test(NAME unit/object/sync-cycle/read/time COMMAND ut-sync-cycle read_time ) 27 | add_test(NAME unit/object/sync-cycle/read/bad_node COMMAND ut-sync-cycle read_bad_node ) 28 | add_test(NAME unit/object/sync-cycle/write/active COMMAND ut-sync-cycle write_active ) 29 | add_test(NAME unit/object/sync-cycle/write/inactive COMMAND ut-sync-cycle write_inactive ) 30 | add_test(NAME unit/object/sync-cycle/write/bad_node COMMAND ut-sync-cycle write_bad_node ) 31 | add_test(NAME unit/object/sync-cycle/init/check COMMAND ut-sync-cycle init_check ) 32 | add_test(NAME unit/object/sync-cycle/init/bad_index COMMAND ut-sync-cycle init_bad_index ) 33 | add_test(NAME unit/object/sync-cycle/init/bad_sub COMMAND ut-sync-cycle init_bad_sub ) 34 | add_test(NAME unit/object/sync-cycle/reset/unused COMMAND ut-sync-cycle reset_unused ) 35 | -------------------------------------------------------------------------------- /src/object/basic/co_integer8.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2020 Embedded Office GmbH & Co. KG 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ******************************************************************************/ 16 | 17 | #ifndef CO_INTEGER8_H_ 18 | #define CO_INTEGER8_H_ 19 | 20 | #ifdef __cplusplus /* for compatibility with C++ environments */ 21 | extern "C" { 22 | #endif 23 | 24 | /****************************************************************************** 25 | * INCLUDES 26 | ******************************************************************************/ 27 | 28 | #include "co_types.h" 29 | #include "co_err.h" 30 | #include "co_obj.h" 31 | 32 | /****************************************************************************** 33 | * PUBLIC DEFINES 34 | ******************************************************************************/ 35 | 36 | #define CO_TUNSIGNED8 ((const CO_OBJ_TYPE *)&COTInt8) 37 | #define CO_TSIGNED8 ((const CO_OBJ_TYPE *)&COTInt8) 38 | 39 | /****************************************************************************** 40 | * PUBLIC CONSTANTS 41 | ******************************************************************************/ 42 | 43 | /*! \brief OBJECT TYPE SIGNED8 / UNSIGNED8 44 | * 45 | * This type is a basic type for 8bit values, regardless of signed or 46 | * unsigned usage. 47 | */ 48 | extern const CO_OBJ_TYPE COTInt8; 49 | 50 | #ifdef __cplusplus /* for compatibility with C++ environments */ 51 | } 52 | #endif 53 | 54 | #endif /* #ifndef CO_INTEGER8_H_ */ 55 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************** 2 | # Copyright 2020 Embedded Office GmbH & Co. KG 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #****************************************************************************** 16 | 17 | #--- 18 | # preamble 19 | # 20 | cmake_minimum_required(VERSION 3.20) # buildPresets is introduced in 3.20 21 | project(canopen-stack) 22 | enable_language(C ASM) 23 | enable_testing() 24 | 25 | #--- 26 | # project wide setup 27 | # 28 | list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake) 29 | set(CMAKE_C_STANDARD 99) 30 | set(CMAKE_C_STANDARD_REQUIRED ON) 31 | set(CMAKE_C_EXTENSIONS OFF) 32 | 33 | #--- 34 | # main targets built by this project 35 | # 36 | add_subdirectory(src) 37 | 38 | #--- 39 | # typically needed only if we are the top level project 40 | # 41 | if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) 42 | add_subdirectory(examples) 43 | add_subdirectory(tests) 44 | 45 | # Setup target which creates a source package for efficient usage with Cmake CPM/FetchContent 46 | set(package_files 47 | src 48 | CMakeLists.txt 49 | LICENSE 50 | ) 51 | add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-src.zip 52 | COMMAND ${CMAKE_COMMAND} -E tar c ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-src.zip --format=zip -- ${package_files} 53 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} 54 | DEPENDS ${package_files} 55 | ) 56 | add_custom_target(${PROJECT_NAME}_package DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-src.zip) 57 | 58 | endif() 59 | -------------------------------------------------------------------------------- /src/object/basic/co_integer16.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2020 Embedded Office GmbH & Co. KG 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ******************************************************************************/ 16 | 17 | #ifndef CO_INTEGER16_H_ 18 | #define CO_INTEGER16_H_ 19 | 20 | #ifdef __cplusplus /* for compatibility with C++ environments */ 21 | extern "C" { 22 | #endif 23 | 24 | /****************************************************************************** 25 | * INCLUDES 26 | ******************************************************************************/ 27 | 28 | #include "co_types.h" 29 | #include "co_err.h" 30 | #include "co_obj.h" 31 | 32 | /****************************************************************************** 33 | * DEFINES 34 | ******************************************************************************/ 35 | 36 | #define CO_TUNSIGNED16 ((const CO_OBJ_TYPE *)&COTInt16) 37 | #define CO_TSIGNED16 ((const CO_OBJ_TYPE *)&COTInt16) 38 | 39 | /****************************************************************************** 40 | * PUBLIC CONSTANTS 41 | ******************************************************************************/ 42 | 43 | /*! \brief OBJECT TYPE SIGNED16 / UNSIGNED16 44 | * 45 | * This type is a basic type for 16bit values, regardless of signed or 46 | * unsigned usage. 47 | */ 48 | extern const CO_OBJ_TYPE COTInt16; 49 | 50 | #ifdef __cplusplus /* for compatibility with C++ environments */ 51 | } 52 | #endif 53 | 54 | #endif /* #ifndef CO_INTEGER16_H_ */ 55 | -------------------------------------------------------------------------------- /src/object/basic/co_integer32.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2020 Embedded Office GmbH & Co. KG 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ******************************************************************************/ 16 | 17 | #ifndef CO_INTEGER32_H_ 18 | #define CO_INTEGER32_H_ 19 | 20 | #ifdef __cplusplus /* for compatibility with C++ environments */ 21 | extern "C" { 22 | #endif 23 | 24 | /****************************************************************************** 25 | * INCLUDES 26 | ******************************************************************************/ 27 | 28 | #include "co_types.h" 29 | #include "co_err.h" 30 | #include "co_obj.h" 31 | 32 | /****************************************************************************** 33 | * DEFINES 34 | ******************************************************************************/ 35 | 36 | #define CO_TUNSIGNED32 ((const CO_OBJ_TYPE *)&COTInt32) 37 | #define CO_TSIGNED32 ((const CO_OBJ_TYPE *)&COTInt32) 38 | 39 | /****************************************************************************** 40 | * PUBLIC CONSTANTS 41 | ******************************************************************************/ 42 | 43 | /*! \brief OBJECT TYPE SIGNED32 / UNSIGNED32 44 | * 45 | * This type is a basic type for 32bit values, regardless of signed or 46 | * unsigned usage. 47 | */ 48 | extern const CO_OBJ_TYPE COTInt32; 49 | 50 | #ifdef __cplusplus /* for compatibility with C++ environments */ 51 | } 52 | #endif 53 | 54 | #endif /* #ifndef CO_INTEGER32_H_ */ 55 | -------------------------------------------------------------------------------- /tests/integration/app/app.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2020 Embedded Office GmbH & Co. KG 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ******************************************************************************/ 16 | 17 | #ifndef APP_H_ 18 | #define APP_H_ 19 | 20 | #ifdef __cplusplus /* for compatibility with C++ environments */ 21 | extern "C" { 22 | #endif 23 | 24 | /****************************************************************************** 25 | * INCLUDES 26 | ******************************************************************************/ 27 | 28 | #include "co_core.h" 29 | #include "co_cfg.h" 30 | 31 | /****************************************************************************** 32 | * PUBLIC FUNCTIONS 33 | ******************************************************************************/ 34 | 35 | /*---------------------------------------------------------------------------*/ 36 | /*! \brief TEST APPLICATION ENTRY 37 | * 38 | * \details The main-function is responsible for the test organization and 39 | * (optional) the pre-selection of a subset of tests for execution. 40 | * Per default are all existing test selected for execution. You may 41 | * limit the amount of running tests during the test development. 42 | * 43 | * \return 44 | * number of failed tests (matching the typical errorcode convention) 45 | */ 46 | /*---------------------------------------------------------------------------*/ 47 | int main(void); 48 | 49 | #ifdef __cplusplus /* for compatibility with C++ environments */ 50 | } 51 | #endif 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /tests/unit/object/cia301/co_hb_prod/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************** 2 | # Copyright 2020 Embedded Office GmbH & Co. KG 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #****************************************************************************** 16 | 17 | add_executable(ut-hb-prod main.c) 18 | target_link_libraries(ut-hb-prod canopen-stack ut-test-env) 19 | 20 | 21 | #--- type function interface tests --- 22 | 23 | add_test(NAME unit/object/hb-prod/size/unknown COMMAND ut-hb-prod size_unknown ) 24 | add_test(NAME unit/object/hb-prod/size/known COMMAND ut-hb-prod size_known ) 25 | add_test(NAME unit/object/hb-prod/size/bad_size COMMAND ut-hb-prod size_bad_size ) 26 | add_test(NAME unit/object/hb-prod/read/time COMMAND ut-hb-prod read_time ) 27 | add_test(NAME unit/object/hb-prod/read/bad_node COMMAND ut-hb-prod read_bad_node ) 28 | add_test(NAME unit/object/hb-prod/write/start COMMAND ut-hb-prod write_start ) 29 | add_test(NAME unit/object/hb-prod/write/restart COMMAND ut-hb-prod write_restart ) 30 | add_test(NAME unit/object/hb-prod/write/bad_index COMMAND ut-hb-prod write_bad_index ) 31 | add_test(NAME unit/object/hb-prod/write/bad_node COMMAND ut-hb-prod write_bad_node ) 32 | add_test(NAME unit/object/hb-prod/init/check COMMAND ut-hb-prod init_check ) 33 | add_test(NAME unit/object/hb-prod/init/start COMMAND ut-hb-prod init_start ) 34 | add_test(NAME unit/object/hb-prod/init/bad_index COMMAND ut-hb-prod init_bad_index ) 35 | add_test(NAME unit/object/hb-prod/reset/unused COMMAND ut-hb-prod reset_unused ) 36 | -------------------------------------------------------------------------------- /tests/unit/object/cia301/co_hb_cons/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************** 2 | # Copyright 2020 Embedded Office GmbH & Co. KG 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #****************************************************************************** 16 | 17 | add_executable(ut-hb-cons main.c) 18 | target_link_libraries(ut-hb-cons canopen-stack ut-test-env) 19 | 20 | 21 | #--- type function interface tests --- 22 | 23 | add_test(NAME unit/object/hb-cons/size/sub_0 COMMAND ut-hb-cons size_sub_0 ) 24 | add_test(NAME unit/object/hb-cons/size/consumer COMMAND ut-hb-cons size_consumer ) 25 | add_test(NAME unit/object/hb-cons/size/bad_size COMMAND ut-hb-cons size_bad_size ) 26 | add_test(NAME unit/object/hb-cons/read/sub_0 COMMAND ut-hb-cons read_sub_0 ) 27 | add_test(NAME unit/object/hb-cons/read/consumer COMMAND ut-hb-cons read_consumer ) 28 | add_test(NAME unit/object/hb-cons/read/bad_node COMMAND ut-hb-cons read_bad_node ) 29 | add_test(NAME unit/object/hb-cons/write/sub_0 COMMAND ut-hb-cons write_sub_0 ) 30 | add_test(NAME unit/object/hb-cons/write/consumer COMMAND ut-hb-cons write_consumer ) 31 | add_test(NAME unit/object/hb-cons/write/bad_node COMMAND ut-hb-cons write_bad_node ) 32 | add_test(NAME unit/object/hb-cons/init/single COMMAND ut-hb-cons init_single ) 33 | add_test(NAME unit/object/hb-cons/init/multiple COMMAND ut-hb-cons init_multiple ) 34 | add_test(NAME unit/object/hb-cons/init/bad_index COMMAND ut-hb-cons init_bad_index ) 35 | add_test(NAME unit/object/hb-cons/reset/unused COMMAND ut-hb-cons reset_unused ) 36 | -------------------------------------------------------------------------------- /src/object/cia301/co_pdo_event.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2020 Embedded Office GmbH & Co. KG 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ******************************************************************************/ 16 | 17 | #ifndef CO_PDO_EVENT_H_ 18 | #define CO_PDO_EVENT_H_ 19 | 20 | #ifdef __cplusplus /* for compatibility with C++ environments */ 21 | extern "C" { 22 | #endif 23 | 24 | /****************************************************************************** 25 | * INCLUDES 26 | ******************************************************************************/ 27 | 28 | #include "co_types.h" 29 | #include "co_err.h" 30 | #include "co_obj.h" 31 | #include "co_pdo.h" 32 | 33 | /****************************************************************************** 34 | * DEFINES 35 | ******************************************************************************/ 36 | 37 | #define CO_TPDO_EVENT ((const CO_OBJ_TYPE *)&COTPdoEvent) 38 | 39 | /****************************************************************************** 40 | * PUBLIC CONSTANTS 41 | ******************************************************************************/ 42 | 43 | /*! \brief OBJECT TYPE: TRANSMIT PDO EVENT TIMER 44 | * 45 | * This object type specializes the general handling of the event timer 46 | * object within the TPDO communication profile. 47 | */ 48 | extern const CO_OBJ_TYPE COTPdoEvent; /*!< PDO Event Type */ 49 | 50 | #ifdef __cplusplus /* for compatibility with C++ environments */ 51 | } 52 | #endif 53 | 54 | #endif /* #ifndef CO_PDO_EVENT_H_ */ 55 | -------------------------------------------------------------------------------- /src/object/cia301/co_sync_cycle.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2020 Embedded Office GmbH & Co. KG 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ******************************************************************************/ 16 | 17 | #ifndef CO_SYNC_CYCLE_H_ 18 | #define CO_SYNC_CYCLE_H_ 19 | 20 | #ifdef __cplusplus /* for compatibility with C++ environments */ 21 | extern "C" { 22 | #endif 23 | 24 | /****************************************************************************** 25 | * INCLUDES 26 | ******************************************************************************/ 27 | 28 | #include "co_types.h" 29 | #include "co_err.h" 30 | #include "co_obj.h" 31 | #include "co_emcy.h" 32 | 33 | /****************************************************************************** 34 | * PUBLIC DEFINES 35 | ******************************************************************************/ 36 | 37 | #define CO_TSYNC_CYCLE ((const CO_OBJ_TYPE *)&COTSyncCycle) 38 | 39 | /****************************************************************************** 40 | * PUBLIC CONSTANTS 41 | ******************************************************************************/ 42 | 43 | /*! \brief OBJECT TYPE SYNC COMMUNICATION CYCLE 44 | * 45 | * This object type specializes the general handling of object for the 46 | * object dictionary entry 0x1006. This entries is designed to provide 47 | * the sync communication cycle value. 48 | */ 49 | extern const CO_OBJ_TYPE COTSyncCycle; 50 | 51 | #ifdef __cplusplus /* for compatibility with C++ environments */ 52 | } 53 | #endif 54 | 55 | #endif /* #ifndef CO_SYNC_CYCLE_H_ */ 56 | -------------------------------------------------------------------------------- /src/hal/co_if_timer.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2020 Embedded Office GmbH & Co. KG 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ******************************************************************************/ 16 | 17 | /****************************************************************************** 18 | * INCLUDES 19 | ******************************************************************************/ 20 | 21 | #include "co_core.h" 22 | 23 | /****************************************************************************** 24 | * PUBLIC FUNCTIONS 25 | ******************************************************************************/ 26 | 27 | /* 28 | * see function definition 29 | */ 30 | void COIfTimerReload(CO_IF *cif, uint32_t reload) 31 | { 32 | const CO_IF_TIMER_DRV *timer = cif->Drv->Timer; 33 | timer->Reload(reload); 34 | } 35 | 36 | /* 37 | * see function definition 38 | */ 39 | uint32_t COIfTimerDelay(CO_IF *cif) 40 | { 41 | const CO_IF_TIMER_DRV *timer = cif->Drv->Timer; 42 | uint32_t delay = timer->Delay(); 43 | return (delay); 44 | } 45 | 46 | /* 47 | * see function definition 48 | */ 49 | void COIfTimerStop(CO_IF *cif) 50 | { 51 | const CO_IF_TIMER_DRV *timer = cif->Drv->Timer; 52 | timer->Stop(); 53 | } 54 | 55 | /* 56 | * see function definition 57 | */ 58 | void COIfTimerStart(CO_IF *cif) 59 | { 60 | const CO_IF_TIMER_DRV *timer = cif->Drv->Timer; 61 | timer->Start(); 62 | } 63 | 64 | /* 65 | * see function definition 66 | */ 67 | uint8_t COIfTimerUpdate(CO_IF *cif) 68 | { 69 | const CO_IF_TIMER_DRV *timer = cif->Drv->Timer; 70 | uint8_t result = timer->Update(); 71 | return (result); 72 | } 73 | -------------------------------------------------------------------------------- /tests/unit/object/cia301/co_pdo_id/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************** 2 | # Copyright 2020 Embedded Office GmbH & Co. KG 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #****************************************************************************** 16 | 17 | add_executable(ut-pdo-id main.c) 18 | target_link_libraries(ut-pdo-id canopen-stack ut-test-env) 19 | 20 | 21 | #--- type function interface tests --- 22 | 23 | add_test(NAME unit/object/pdo-id/size/unknown COMMAND ut-pdo-id size_unknown ) 24 | add_test(NAME unit/object/pdo-id/size/known COMMAND ut-pdo-id size_known ) 25 | add_test(NAME unit/object/pdo-id/size/size COMMAND ut-pdo-id bad_size ) 26 | add_test(NAME unit/object/pdo-id/read/ref COMMAND ut-pdo-id read_ref ) 27 | add_test(NAME unit/object/pdo-id/read/direct COMMAND ut-pdo-id read_direct ) 28 | add_test(NAME unit/object/pdo-id/read/bad_node COMMAND ut-pdo-id read_bad_node ) 29 | add_test(NAME unit/object/pdo-id/write/activate COMMAND ut-pdo-id write_activate ) 30 | add_test(NAME unit/object/pdo-id/write/deactivate COMMAND ut-pdo-id write_deactivate ) 31 | add_test(NAME unit/object/pdo-id/write/active COMMAND ut-pdo-id write_active ) 32 | add_test(NAME unit/object/pdo-id/write/bad_node COMMAND ut-pdo-id write_bad_node ) 33 | add_test(NAME unit/object/pdo-id/init/check COMMAND ut-pdo-id init_check ) 34 | add_test(NAME unit/object/pdo-id/init/bad_index COMMAND ut-pdo-id init_bad_index ) 35 | add_test(NAME unit/object/pdo-id/init/bad_sub COMMAND ut-pdo-id init_bad_sub ) 36 | add_test(NAME unit/object/pdo-id/reset/unused COMMAND ut-pdo-id reset_unused ) 37 | -------------------------------------------------------------------------------- /tests/unit/object/cia301/co_sdo_id/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************** 2 | # Copyright 2020 Embedded Office GmbH & Co. KG 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #****************************************************************************** 16 | 17 | add_executable(ut-sdo-id main.c) 18 | target_link_libraries(ut-sdo-id canopen-stack ut-test-env) 19 | 20 | 21 | #--- type function interface tests --- 22 | 23 | add_test(NAME unit/object/sdo-id/size/unknown COMMAND ut-sdo-id size_unknown ) 24 | add_test(NAME unit/object/sdo-id/size/known COMMAND ut-sdo-id size_known ) 25 | add_test(NAME unit/object/sdo-id/size/size COMMAND ut-sdo-id bad_size ) 26 | add_test(NAME unit/object/sdo-id/read/ref COMMAND ut-sdo-id read_ref ) 27 | add_test(NAME unit/object/sdo-id/read/direct COMMAND ut-sdo-id read_direct ) 28 | add_test(NAME unit/object/sdo-id/read/bad_node COMMAND ut-sdo-id read_bad_node ) 29 | add_test(NAME unit/object/sdo-id/write/activate COMMAND ut-sdo-id write_activate ) 30 | add_test(NAME unit/object/sdo-id/write/deactivate COMMAND ut-sdo-id write_deactivate ) 31 | add_test(NAME unit/object/sdo-id/write/active COMMAND ut-sdo-id write_active ) 32 | add_test(NAME unit/object/sdo-id/write/bad_node COMMAND ut-sdo-id write_bad_node ) 33 | add_test(NAME unit/object/sdo-id/init/check COMMAND ut-sdo-id init_check ) 34 | add_test(NAME unit/object/sdo-id/init/bad_index COMMAND ut-sdo-id init_bad_index ) 35 | add_test(NAME unit/object/sdo-id/init/bad_sub COMMAND ut-sdo-id init_bad_sub ) 36 | add_test(NAME unit/object/sdo-id/reset/unused COMMAND ut-sdo-id reset_unused ) 37 | -------------------------------------------------------------------------------- /tests/unit/object/cia301/co_emcy_id/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************** 2 | # Copyright 2020 Embedded Office GmbH & Co. KG 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #****************************************************************************** 16 | 17 | add_executable(ut-emcy-id main.c) 18 | target_link_libraries(ut-emcy-id canopen-stack ut-test-env) 19 | 20 | 21 | #--- type function interface tests --- 22 | 23 | add_test(NAME unit/object/emcy-id/size/unknown COMMAND ut-emcy-id size_unknown ) 24 | add_test(NAME unit/object/emcy-id/size/known COMMAND ut-emcy-id size_known ) 25 | add_test(NAME unit/object/emcy-id/size/size COMMAND ut-emcy-id bad_size ) 26 | add_test(NAME unit/object/emcy-id/read/ref COMMAND ut-emcy-id read_ref ) 27 | add_test(NAME unit/object/emcy-id/read/direct COMMAND ut-emcy-id read_direct ) 28 | add_test(NAME unit/object/emcy-id/read/bad_node COMMAND ut-emcy-id read_bad_node ) 29 | add_test(NAME unit/object/emcy-id/write/activate COMMAND ut-emcy-id write_activate ) 30 | add_test(NAME unit/object/emcy-id/write/deactivate COMMAND ut-emcy-id write_deactivate ) 31 | add_test(NAME unit/object/emcy-id/write/active COMMAND ut-emcy-id write_active ) 32 | add_test(NAME unit/object/emcy-id/write/bad_node COMMAND ut-emcy-id write_bad_node ) 33 | add_test(NAME unit/object/emcy-id/init/check COMMAND ut-emcy-id init_check ) 34 | add_test(NAME unit/object/emcy-id/init/bad_index COMMAND ut-emcy-id init_bad_index ) 35 | add_test(NAME unit/object/emcy-id/init/bad_sub COMMAND ut-emcy-id init_bad_sub ) 36 | add_test(NAME unit/object/emcy-id/reset/unused COMMAND ut-emcy-id reset_unused ) 37 | -------------------------------------------------------------------------------- /tests/unit/object/cia301/co_sync_id/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************** 2 | # Copyright 2020 Embedded Office GmbH & Co. KG 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #****************************************************************************** 16 | 17 | add_executable(ut-sync-id main.c) 18 | target_link_libraries(ut-sync-id canopen-stack ut-test-env) 19 | 20 | 21 | #--- type function interface tests --- 22 | 23 | add_test(NAME unit/object/sync-id/size/unknown COMMAND ut-sync-id size_unknown ) 24 | add_test(NAME unit/object/sync-id/size/known COMMAND ut-sync-id size_known ) 25 | add_test(NAME unit/object/sync-id/size/size COMMAND ut-sync-id bad_size ) 26 | add_test(NAME unit/object/sync-id/read/ref COMMAND ut-sync-id read_ref ) 27 | add_test(NAME unit/object/sync-id/read/direct COMMAND ut-sync-id read_direct ) 28 | add_test(NAME unit/object/sync-id/read/bad_node COMMAND ut-sync-id read_bad_node ) 29 | add_test(NAME unit/object/sync-id/write/activate COMMAND ut-sync-id write_activate ) 30 | add_test(NAME unit/object/sync-id/write/deactivate COMMAND ut-sync-id write_deactivate ) 31 | add_test(NAME unit/object/sync-id/write/active COMMAND ut-sync-id write_active ) 32 | add_test(NAME unit/object/sync-id/write/bad_node COMMAND ut-sync-id write_bad_node ) 33 | add_test(NAME unit/object/sync-id/init/check COMMAND ut-sync-id init_check ) 34 | add_test(NAME unit/object/sync-id/init/bad_index COMMAND ut-sync-id init_bad_index ) 35 | add_test(NAME unit/object/sync-id/init/bad_sub COMMAND ut-sync-id init_bad_sub ) 36 | add_test(NAME unit/object/sync-id/reset/unused COMMAND ut-sync-id reset_unused ) 37 | -------------------------------------------------------------------------------- /tests/unit/object/cia301/co_pdo_event/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************** 2 | # Copyright 2020 Embedded Office GmbH & Co. KG 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #****************************************************************************** 16 | 17 | add_executable(ut-pdo-event main.c) 18 | target_link_libraries(ut-pdo-event canopen-stack ut-test-env) 19 | 20 | 21 | #--- type function interface tests --- 22 | 23 | add_test(NAME unit/object/pdo-event/size/unknown COMMAND ut-pdo-event size_unknown ) 24 | add_test(NAME unit/object/pdo-event/size/known COMMAND ut-pdo-event size_known ) 25 | add_test(NAME unit/object/pdo-event/size/bad_size COMMAND ut-pdo-event size_bad_size ) 26 | add_test(NAME unit/object/pdo-event/read/ref COMMAND ut-pdo-event read_ref ) 27 | add_test(NAME unit/object/pdo-event/read/direct COMMAND ut-pdo-event read_direct ) 28 | add_test(NAME unit/object/pdo-event/read/bad_node COMMAND ut-pdo-event read_bad_node ) 29 | add_test(NAME unit/object/pdo-event/write/start COMMAND ut-pdo-event write_start ) 30 | add_test(NAME unit/object/pdo-event/write/change COMMAND ut-pdo-event write_change ) 31 | add_test(NAME unit/object/pdo-event/write/stop COMMAND ut-pdo-event write_stop ) 32 | add_test(NAME unit/object/pdo-event/write/bad_node COMMAND ut-pdo-event write_bad_node ) 33 | add_test(NAME unit/object/pdo-event/init/check COMMAND ut-pdo-event init_check ) 34 | add_test(NAME unit/object/pdo-event/init/bad_index COMMAND ut-pdo-event init_bad_index ) 35 | add_test(NAME unit/object/pdo-event/init/bad_sub COMMAND ut-pdo-event init_bad_sub ) 36 | add_test(NAME unit/object/pdo-event/reset/unused COMMAND ut-pdo-event reset_unused ) 37 | -------------------------------------------------------------------------------- /src/object/cia301/co_pdo_map.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2020 Embedded Office GmbH & Co. KG 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ******************************************************************************/ 16 | 17 | #ifndef CO_PDO_MAP_H_ 18 | #define CO_PDO_MAP_H_ 19 | 20 | #ifdef __cplusplus /* for compatibility with C++ environments */ 21 | extern "C" { 22 | #endif 23 | 24 | /****************************************************************************** 25 | * INCLUDES 26 | ******************************************************************************/ 27 | 28 | #include "co_types.h" 29 | #include "co_err.h" 30 | #include "co_obj.h" 31 | #include "co_emcy.h" 32 | 33 | /****************************************************************************** 34 | * PUBLIC DEFINES 35 | ******************************************************************************/ 36 | 37 | #define CO_TPDO_MAP ((const CO_OBJ_TYPE *)&COTPdoMap) 38 | 39 | /****************************************************************************** 40 | * PUBLIC CONSTANTS 41 | ******************************************************************************/ 42 | 43 | /*! \brief OBJECT TYPE: PDO MAPPING ENTRY 44 | * 45 | * This type is responsible for the access to the PDO mapping entries. Due 46 | * to the special handling of PDO mapping change accesses, only the write 47 | * access needs to be handled via the type structure; the read operation 48 | * can be performed directly. 49 | */ 50 | extern const CO_OBJ_TYPE COTPdoMap; /*!< PDO Mapping Type */ 51 | 52 | #ifdef __cplusplus /* for compatibility with C++ environments */ 53 | } 54 | #endif 55 | 56 | #endif /* #ifndef CO_PDO_MAP_H_ */ 57 | -------------------------------------------------------------------------------- /src/object/cia301/co_pdo_id.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2020 Embedded Office GmbH & Co. KG 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ******************************************************************************/ 16 | 17 | #ifndef CO_PDO_ID_H_ 18 | #define CO_PDO_ID_H_ 19 | 20 | #ifdef __cplusplus /* for compatibility with C++ environments */ 21 | extern "C" { 22 | #endif 23 | 24 | /****************************************************************************** 25 | * INCLUDES 26 | ******************************************************************************/ 27 | 28 | #include "co_types.h" 29 | #include "co_err.h" 30 | #include "co_obj.h" 31 | #include "co_emcy.h" 32 | 33 | /****************************************************************************** 34 | * PUBLIC DEFINES 35 | ******************************************************************************/ 36 | 37 | #define CO_TPDO_ID ((const CO_OBJ_TYPE *)&COTPdoId) 38 | 39 | /****************************************************************************** 40 | * PUBLIC CONSTANTS 41 | ******************************************************************************/ 42 | 43 | /*! \brief OBJECT TYPE: PDO IDENTIFIER 44 | * 45 | * This type is responsible for the access to the PDO communication 46 | * entries. Due to the special handling of PDO communication change 47 | * accesses, only the write access needs to be handled via the type 48 | * structure; the read operation can be performed directly. 49 | */ 50 | extern const CO_OBJ_TYPE COTPdoId; /*!< PDO Identifier Type */ 51 | 52 | #ifdef __cplusplus /* for compatibility with C++ environments */ 53 | } 54 | #endif 55 | 56 | #endif /* #ifndef CO_PDO_ID_H_ */ 57 | -------------------------------------------------------------------------------- /src/object/cia301/co_pdo_num.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2020 Embedded Office GmbH & Co. KG 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ******************************************************************************/ 16 | 17 | #ifndef CO_PDO_NUM_H_ 18 | #define CO_PDO_NUM_H_ 19 | 20 | #ifdef __cplusplus /* for compatibility with C++ environments */ 21 | extern "C" { 22 | #endif 23 | 24 | /****************************************************************************** 25 | * INCLUDES 26 | ******************************************************************************/ 27 | 28 | #include "co_types.h" 29 | #include "co_err.h" 30 | #include "co_obj.h" 31 | #include "co_emcy.h" 32 | 33 | /****************************************************************************** 34 | * PUBLIC DEFINES 35 | ******************************************************************************/ 36 | 37 | #define CO_TPDO_NUM ((const CO_OBJ_TYPE *)&COTPdoNum) 38 | 39 | /****************************************************************************** 40 | * PUBLIC CONSTANTS 41 | ******************************************************************************/ 42 | 43 | /*! \brief OBJECT TYPE: NUMBER OF PDO MAPPINGS 44 | * 45 | * This type is responsible for the access to the number of PDO mapping 46 | * entries. Due to the special handling of PDO mapping change accesses, only 47 | * the write access needs to be handled via the type structure; the read 48 | * operation can be performed directly. 49 | */ 50 | extern const CO_OBJ_TYPE COTPdoNum; /*!< PDO Map Numbers Type */ 51 | 52 | #ifdef __cplusplus /* for compatibility with C++ environments */ 53 | } 54 | #endif 55 | 56 | #endif /* #ifndef CO_PDO_NUM_H_ */ 57 | -------------------------------------------------------------------------------- /src/object/cia301/co_pdo_type.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2020 Embedded Office GmbH & Co. KG 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ******************************************************************************/ 16 | 17 | #ifndef CO_PDO_TYPE_H_ 18 | #define CO_PDO_TYPE_H_ 19 | 20 | #ifdef __cplusplus /* for compatibility with C++ environments */ 21 | extern "C" { 22 | #endif 23 | 24 | /****************************************************************************** 25 | * INCLUDES 26 | ******************************************************************************/ 27 | 28 | #include "co_types.h" 29 | #include "co_err.h" 30 | #include "co_obj.h" 31 | #include "co_emcy.h" 32 | 33 | /****************************************************************************** 34 | * PUBLIC DEFINES 35 | ******************************************************************************/ 36 | 37 | #define CO_TPDO_TYPE ((const CO_OBJ_TYPE *)&COTPdoType) 38 | 39 | /****************************************************************************** 40 | * PUBLIC CONSTANTS 41 | ******************************************************************************/ 42 | 43 | /*! \brief OBJECT TYPE: PDO TRANSMISSION TYPE 44 | * 45 | * This type is responsible for the access to the PDO communication 46 | * entries. Due to the special handling of PDO communication change 47 | * accesses, only the write access needs to be handled via the type 48 | * structure; the read operation can be performed directly. 49 | */ 50 | extern const CO_OBJ_TYPE COTPdoType; /*!< PDO Transmission Type */ 51 | 52 | #ifdef __cplusplus /* for compatibility with C++ environments */ 53 | } 54 | #endif 55 | 56 | #endif /* #ifndef CO_PDO_TYPE_H_ */ 57 | -------------------------------------------------------------------------------- /tests/unit/object/basic/co_signed8/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************** 2 | # Copyright 2020 Embedded Office GmbH & Co. KG 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #****************************************************************************** 16 | 17 | add_executable(ut-signed8 main.c) 18 | target_link_libraries(ut-signed8 canopen-stack ut-test-env) 19 | 20 | 21 | #--- type function interface tests --- 22 | 23 | add_test(NAME unit/object/signed8/size/unknown COMMAND ut-signed8 size_unknown ) 24 | add_test(NAME unit/object/signed8/size/known COMMAND ut-signed8 size_known ) 25 | add_test(NAME unit/object/signed8/size/bad_size COMMAND ut-signed8 bad_size ) 26 | add_test(NAME unit/object/signed8/read/ref COMMAND ut-signed8 read_ref ) 27 | add_test(NAME unit/object/signed8/read/direct COMMAND ut-signed8 read_direct ) 28 | add_test(NAME unit/object/signed8/read/nodeid COMMAND ut-signed8 read_nodeid ) 29 | add_test(NAME unit/object/signed8/read/bad_node COMMAND ut-signed8 read_bad_node ) 30 | add_test(NAME unit/object/signed8/write/ref COMMAND ut-signed8 write_ref ) 31 | add_test(NAME unit/object/signed8/write/direct COMMAND ut-signed8 write_direct ) 32 | add_test(NAME unit/object/signed8/write/nodeid COMMAND ut-signed8 write_nodeid ) 33 | add_test(NAME unit/object/signed8/write/pdo_async COMMAND ut-signed8 write_pdo_async ) 34 | add_test(NAME unit/object/signed8/write/pdo COMMAND ut-signed8 write_pdo ) 35 | add_test(NAME unit/object/signed8/write/bad_node COMMAND ut-signed8 write_bad_node ) 36 | add_test(NAME unit/object/signed8/init/unused COMMAND ut-signed8 init_unused ) 37 | add_test(NAME unit/object/signed8/reset/unused COMMAND ut-signed8 reset_unused ) 38 | -------------------------------------------------------------------------------- /tests/unit/object/basic/co_signed16/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************** 2 | # Copyright 2020 Embedded Office GmbH & Co. KG 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #****************************************************************************** 16 | 17 | add_executable(ut-signed16 main.c) 18 | target_link_libraries(ut-signed16 canopen-stack ut-test-env) 19 | 20 | 21 | #--- type function interface tests --- 22 | 23 | add_test(NAME unit/object/signed16/size/unknown COMMAND ut-signed16 size_unknown ) 24 | add_test(NAME unit/object/signed16/size/known COMMAND ut-signed16 size_known ) 25 | add_test(NAME unit/object/signed16/size/bad_size COMMAND ut-signed16 bad_size ) 26 | add_test(NAME unit/object/signed16/read/ref COMMAND ut-signed16 read_ref ) 27 | add_test(NAME unit/object/signed16/read/direct COMMAND ut-signed16 read_direct ) 28 | add_test(NAME unit/object/signed16/read/nodeid COMMAND ut-signed16 read_nodeid ) 29 | add_test(NAME unit/object/signed16/read/bad_node COMMAND ut-signed16 read_bad_node ) 30 | add_test(NAME unit/object/signed16/write/ref COMMAND ut-signed16 write_ref ) 31 | add_test(NAME unit/object/signed16/write/direct COMMAND ut-signed16 write_direct ) 32 | add_test(NAME unit/object/signed16/write/nodeid COMMAND ut-signed16 write_nodeid ) 33 | add_test(NAME unit/object/signed16/write/pdo_async COMMAND ut-signed16 write_pdo_async ) 34 | add_test(NAME unit/object/signed16/write/pdo COMMAND ut-signed16 write_pdo ) 35 | add_test(NAME unit/object/signed16/write/bad_node COMMAND ut-signed16 write_bad_node ) 36 | add_test(NAME unit/object/signed16/init/unused COMMAND ut-signed16 init_unused ) 37 | add_test(NAME unit/object/signed16/reset/unused COMMAND ut-signed16 reset_unused ) 38 | -------------------------------------------------------------------------------- /tests/unit/object/basic/co_signed32/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************** 2 | # Copyright 2020 Embedded Office GmbH & Co. KG 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #****************************************************************************** 16 | 17 | add_executable(ut-signed32 main.c) 18 | target_link_libraries(ut-signed32 canopen-stack ut-test-env) 19 | 20 | 21 | #--- type function interface tests --- 22 | 23 | add_test(NAME unit/object/signed32/size/unknown COMMAND ut-signed32 size_unknown ) 24 | add_test(NAME unit/object/signed32/size/known COMMAND ut-signed32 size_known ) 25 | add_test(NAME unit/object/signed32/size/bad_size COMMAND ut-signed32 bad_size ) 26 | add_test(NAME unit/object/signed32/read/ref COMMAND ut-signed32 read_ref ) 27 | add_test(NAME unit/object/signed32/read/direct COMMAND ut-signed32 read_direct ) 28 | add_test(NAME unit/object/signed32/read/nodeid COMMAND ut-signed32 read_nodeid ) 29 | add_test(NAME unit/object/signed32/read/bad_node COMMAND ut-signed32 read_bad_node ) 30 | add_test(NAME unit/object/signed32/write/ref COMMAND ut-signed32 write_ref ) 31 | add_test(NAME unit/object/signed32/write/direct COMMAND ut-signed32 write_direct ) 32 | add_test(NAME unit/object/signed32/write/nodeid COMMAND ut-signed32 write_nodeid ) 33 | add_test(NAME unit/object/signed32/write/pdo_async COMMAND ut-signed32 write_pdo_async ) 34 | add_test(NAME unit/object/signed32/write/pdo COMMAND ut-signed32 write_pdo ) 35 | add_test(NAME unit/object/signed32/write/bad_node COMMAND ut-signed32 write_bad_node ) 36 | add_test(NAME unit/object/signed32/init/unused COMMAND ut-signed32 init_unused ) 37 | add_test(NAME unit/object/signed32/reset/unused COMMAND ut-signed32 reset_unused ) 38 | -------------------------------------------------------------------------------- /tests/unit/object/basic/co_unsigned8/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************** 2 | # Copyright 2020 Embedded Office GmbH & Co. KG 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #****************************************************************************** 16 | 17 | add_executable(ut-unsigned8 main.c) 18 | target_link_libraries(ut-unsigned8 canopen-stack ut-test-env) 19 | 20 | 21 | #--- type function interface tests --- 22 | 23 | add_test(NAME unit/object/unsigned8/size/unknown COMMAND ut-unsigned8 size_unknown ) 24 | add_test(NAME unit/object/unsigned8/size/known COMMAND ut-unsigned8 size_known ) 25 | add_test(NAME unit/object/unsigned8/size/bad_size COMMAND ut-unsigned8 bad_size ) 26 | add_test(NAME unit/object/unsigned8/read/ref COMMAND ut-unsigned8 read_ref ) 27 | add_test(NAME unit/object/unsigned8/read/direct COMMAND ut-unsigned8 read_direct ) 28 | add_test(NAME unit/object/unsigned8/read/nodeid COMMAND ut-unsigned8 read_nodeid ) 29 | add_test(NAME unit/object/unsigned8/read/bad_node COMMAND ut-unsigned8 read_bad_node ) 30 | add_test(NAME unit/object/unsigned8/write/ref COMMAND ut-unsigned8 write_ref ) 31 | add_test(NAME unit/object/unsigned8/write/direct COMMAND ut-unsigned8 write_direct ) 32 | add_test(NAME unit/object/unsigned8/write/nodeid COMMAND ut-unsigned8 write_nodeid ) 33 | add_test(NAME unit/object/unsigned8/write/pdo_async COMMAND ut-unsigned8 write_pdo_async ) 34 | add_test(NAME unit/object/unsigned8/write/pdo COMMAND ut-unsigned8 write_pdo ) 35 | add_test(NAME unit/object/unsigned8/write/bad_node COMMAND ut-unsigned8 write_bad_node ) 36 | add_test(NAME unit/object/unsigned8/init/unused COMMAND ut-unsigned8 init_unused ) 37 | add_test(NAME unit/object/unsigned8/reset/unused COMMAND ut-unsigned8 reset_unused ) 38 | -------------------------------------------------------------------------------- /tests/unit/object/cia301/co_emcy_hist/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************** 2 | # Copyright 2020 Embedded Office GmbH & Co. KG 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #****************************************************************************** 16 | 17 | add_executable(ut-emcy-hist main.c) 18 | target_link_libraries(ut-emcy-hist canopen-stack ut-test-env) 19 | 20 | 21 | #--- type function interface tests --- 22 | 23 | add_test(NAME unit/object/emcy-hist/size/sub_0 COMMAND ut-emcy-hist size_sub_0 ) 24 | add_test(NAME unit/object/emcy-hist/size/sub_1 COMMAND ut-emcy-hist size_sub_1 ) 25 | add_test(NAME unit/object/emcy-hist/size/bad_size COMMAND ut-emcy-hist bad_size ) 26 | add_test(NAME unit/object/emcy-hist/read/sub_0 COMMAND ut-emcy-hist read_sub_0 ) 27 | add_test(NAME unit/object/emcy-hist/read/sub_1 COMMAND ut-emcy-hist read_sub_1 ) 28 | add_test(NAME unit/object/emcy-hist/read/bad_node COMMAND ut-emcy-hist read_bad_node ) 29 | add_test(NAME unit/object/emcy-hist/write/reset COMMAND ut-emcy-hist write_reset ) 30 | add_test(NAME unit/object/emcy-hist/write/no_reset COMMAND ut-emcy-hist write_no_reset ) 31 | add_test(NAME unit/object/emcy-hist/write/sub_1 COMMAND ut-emcy-hist write_sub_1 ) 32 | add_test(NAME unit/object/emcy-hist/write/bad_node COMMAND ut-emcy-hist write_bad_node ) 33 | add_test(NAME unit/object/emcy-hist/init/hist_min COMMAND ut-emcy-hist init_hist_min ) 34 | add_test(NAME unit/object/emcy-hist/init/hist_8 COMMAND ut-emcy-hist init_hist_8 ) 35 | add_test(NAME unit/object/emcy-hist/init/bad_index COMMAND ut-emcy-hist init_bad_index ) 36 | add_test(NAME unit/object/emcy-hist/init/bad_hist COMMAND ut-emcy-hist init_bad_hist ) 37 | add_test(NAME unit/object/emcy-hist/reset/unused COMMAND ut-emcy-hist reset_unused ) 38 | -------------------------------------------------------------------------------- /src/object/cia301/co_hb_prod.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2020 Embedded Office GmbH & Co. KG 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ******************************************************************************/ 16 | 17 | #ifndef CO_HB_PROD_H_ 18 | #define CO_HB_PROD_H_ 19 | 20 | #ifdef __cplusplus /* for compatibility with C++ environments */ 21 | extern "C" { 22 | #endif 23 | 24 | /****************************************************************************** 25 | * INCLUDES 26 | ******************************************************************************/ 27 | 28 | #include "co_types.h" 29 | #include "co_obj.h" 30 | 31 | /****************************************************************************** 32 | * PUBLIC DEFINES 33 | ******************************************************************************/ 34 | 35 | #define CO_THB_PROD ((const CO_OBJ_TYPE *)&COTNmtHbProd) 36 | 37 | /****************************************************************************** 38 | * PUBLIC TYPES 39 | ******************************************************************************/ 40 | 41 | typedef uint16_t CO_OBJ_HB_PROD; /*!< Heartbeat Producer Cycle Time */ 42 | 43 | /****************************************************************************** 44 | * PUBLIC CONSTANTS 45 | ******************************************************************************/ 46 | 47 | /*! \brief OBJECT TYPE HEARTBEAT PRODUCER 48 | * 49 | * This object type specializes the general handling of objects for the 50 | * object dictionary entry 0x1017. This entries is designed to provide 51 | * the heartbeat producer cycle time. 52 | */ 53 | extern const CO_OBJ_TYPE COTNmtHbProd; 54 | 55 | #ifdef __cplusplus /* for compatibility with C++ environments */ 56 | } 57 | #endif 58 | 59 | #endif /* #ifndef CO_HB_PROD_H_ */ 60 | -------------------------------------------------------------------------------- /tests/unit/object/basic/co_unsigned16/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************** 2 | # Copyright 2020 Embedded Office GmbH & Co. KG 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #****************************************************************************** 16 | 17 | add_executable(ut-unsigned16 main.c) 18 | target_link_libraries(ut-unsigned16 canopen-stack ut-test-env) 19 | 20 | 21 | #--- type function interface tests --- 22 | 23 | add_test(NAME unit/object/unsigned16/size/unknown COMMAND ut-unsigned16 size_unknown ) 24 | add_test(NAME unit/object/unsigned16/size/known COMMAND ut-unsigned16 size_known ) 25 | add_test(NAME unit/object/unsigned16/size/bad_size COMMAND ut-unsigned16 bad_size ) 26 | add_test(NAME unit/object/unsigned16/read/ref COMMAND ut-unsigned16 read_ref ) 27 | add_test(NAME unit/object/unsigned16/read/direct COMMAND ut-unsigned16 read_direct ) 28 | add_test(NAME unit/object/unsigned16/read/nodeid COMMAND ut-unsigned16 read_nodeid ) 29 | add_test(NAME unit/object/unsigned16/read/bad_node COMMAND ut-unsigned16 read_bad_node ) 30 | add_test(NAME unit/object/unsigned16/write/ref COMMAND ut-unsigned16 write_ref ) 31 | add_test(NAME unit/object/unsigned16/write/direct COMMAND ut-unsigned16 write_direct ) 32 | add_test(NAME unit/object/unsigned16/write/nodeid COMMAND ut-unsigned16 write_nodeid ) 33 | add_test(NAME unit/object/unsigned16/write/pdo_async COMMAND ut-unsigned16 write_pdo_async ) 34 | add_test(NAME unit/object/unsigned16/write/pdo COMMAND ut-unsigned16 write_pdo ) 35 | add_test(NAME unit/object/unsigned16/write/bad_node COMMAND ut-unsigned16 write_bad_node ) 36 | add_test(NAME unit/object/unsigned16/init/unused COMMAND ut-unsigned16 init_unused ) 37 | add_test(NAME unit/object/unsigned16/reset/unused COMMAND ut-unsigned16 reset_unused ) 38 | -------------------------------------------------------------------------------- /tests/unit/object/basic/co_unsigned32/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************** 2 | # Copyright 2020 Embedded Office GmbH & Co. KG 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #****************************************************************************** 16 | 17 | add_executable(ut-unsigned32 main.c) 18 | target_link_libraries(ut-unsigned32 canopen-stack ut-test-env) 19 | 20 | 21 | #--- type function interface tests --- 22 | 23 | add_test(NAME unit/object/unsigned32/size/unknown COMMAND ut-unsigned32 size_unknown ) 24 | add_test(NAME unit/object/unsigned32/size/known COMMAND ut-unsigned32 size_known ) 25 | add_test(NAME unit/object/unsigned32/size/bad_size COMMAND ut-unsigned32 bad_size ) 26 | add_test(NAME unit/object/unsigned32/read/ref COMMAND ut-unsigned32 read_ref ) 27 | add_test(NAME unit/object/unsigned32/read/direct COMMAND ut-unsigned32 read_direct ) 28 | add_test(NAME unit/object/unsigned32/read/nodeid COMMAND ut-unsigned32 read_nodeid ) 29 | add_test(NAME unit/object/unsigned32/read/bad_node COMMAND ut-unsigned32 read_bad_node ) 30 | add_test(NAME unit/object/unsigned32/write/ref COMMAND ut-unsigned32 write_ref ) 31 | add_test(NAME unit/object/unsigned32/write/direct COMMAND ut-unsigned32 write_direct ) 32 | add_test(NAME unit/object/unsigned32/write/nodeid COMMAND ut-unsigned32 write_nodeid ) 33 | add_test(NAME unit/object/unsigned32/write/pdo_async COMMAND ut-unsigned32 write_pdo_async ) 34 | add_test(NAME unit/object/unsigned32/write/pdo COMMAND ut-unsigned32 write_pdo ) 35 | add_test(NAME unit/object/unsigned32/write/bad_node COMMAND ut-unsigned32 write_bad_node ) 36 | add_test(NAME unit/object/unsigned32/init/unused COMMAND ut-unsigned32 init_unused ) 37 | add_test(NAME unit/object/unsigned32/reset/unused COMMAND ut-unsigned32 reset_unused ) 38 | -------------------------------------------------------------------------------- /src/config/co_cfg.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2020 Embedded Office GmbH & Co. KG 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ******************************************************************************/ 16 | 17 | #ifndef CO_CFG_H_ 18 | #define CO_CFG_H_ 19 | 20 | /*! \brief DEFAULT SDO SERVER 21 | * 22 | * This configuration define specifies how many SDO servers the library 23 | * will support. 24 | */ 25 | #ifndef CO_SSDO_N 26 | #define CO_SSDO_N 1 27 | #endif 28 | 29 | /*! \brief DEFAULT SDO CLIENT 30 | * 31 | * This configuration define specifies how many SDO clients the library 32 | * will support. 33 | */ 34 | #ifndef CO_CSDO_N 35 | #define CO_CSDO_N 1 36 | #endif 37 | 38 | /*! \brief DEFAULT EMERGENCY CODES 39 | * 40 | * This configuration define specifies how many emergency codes the library 41 | * will support. 42 | */ 43 | #ifndef CO_EMCY_N 44 | #define CO_EMCY_N 32 45 | #endif 46 | 47 | /*! \brief DEFAULT RECEIVE PDO 48 | * 49 | * This configuration define specifies how many receive PDOs the library 50 | * will support. 51 | */ 52 | #ifndef CO_RPDO_N 53 | #define CO_RPDO_N 4 54 | #endif 55 | 56 | /*! \brief DEFAULT TRANSMIT PDO 57 | * 58 | * This configuration define specifies how many transmit PDOs the library 59 | * will support. 60 | */ 61 | #ifndef CO_TPDO_N 62 | #define CO_TPDO_N 4 63 | #endif 64 | 65 | /*! \brief DEFAULT ENABLE LSS 66 | * 67 | * This configuration define specifies whether the LSS functionality will 68 | * be supported by the library. 69 | */ 70 | #ifndef USE_LSS 71 | #define USE_LSS 1 72 | #endif 73 | 74 | /*! \brief DEFAULT ENABLE SDO CLIENT 75 | * 76 | * This configuration define specifies whether SDO client will be supported 77 | * by the library. 78 | */ 79 | #ifndef USE_CSDO 80 | #define USE_CSDO 1 81 | #endif 82 | 83 | #endif /* #ifndef CO_CFG_H_ */ 84 | -------------------------------------------------------------------------------- /tests/unit/object/cia301/co_para_restore/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************** 2 | # Copyright 2020 Embedded Office GmbH & Co. KG 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #****************************************************************************** 16 | 17 | add_executable(ut-para-restore main.c) 18 | target_link_libraries(ut-para-restore canopen-stack ut-test-env) 19 | 20 | 21 | #--- type function interface tests --- 22 | 23 | add_test(NAME unit/object/para-restore/size/sub_0 COMMAND ut-para-restore size_sub_0 ) 24 | add_test(NAME unit/object/para-restore/size/sub_1 COMMAND ut-para-restore size_sub_1 ) 25 | add_test(NAME unit/object/para-restore/size/bad_size COMMAND ut-para-restore size_bad_size ) 26 | add_test(NAME unit/object/para-restore/read/enabled COMMAND ut-para-restore read_enabled ) 27 | add_test(NAME unit/object/para-restore/read/disabled COMMAND ut-para-restore read_disabled ) 28 | add_test(NAME unit/object/para-restore/read/bad_node COMMAND ut-para-restore read_bad_node ) 29 | add_test(NAME unit/object/para-restore/write/single COMMAND ut-para-restore write_single ) 30 | add_test(NAME unit/object/para-restore/write/all COMMAND ut-para-restore write_all ) 31 | add_test(NAME unit/object/para-restore/write/bad_signature COMMAND ut-para-restore write_bad_signature ) 32 | add_test(NAME unit/object/para-restore/write/bad_index COMMAND ut-para-restore write_bad_index ) 33 | add_test(NAME unit/object/para-restore/write/bad_node COMMAND ut-para-restore write_bad_node ) 34 | add_test(NAME unit/object/para-restore/init/check COMMAND ut-para-restore init_check ) 35 | add_test(NAME unit/object/para-restore/init/bad_index COMMAND ut-para-restore init_bad_index ) 36 | add_test(NAME unit/object/para-restore/reset/unused COMMAND ut-para-restore reset_unused ) 37 | -------------------------------------------------------------------------------- /examples/dynamic-od/driver/drv_can_sim.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2020 Embedded Office GmbH & Co. KG 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ******************************************************************************/ 16 | 17 | #ifndef CO_CAN_SIM_H_ 18 | #define CO_CAN_SIM_H_ 19 | 20 | #ifdef __cplusplus /* for compatibility with C++ environments */ 21 | extern "C" { 22 | #endif 23 | 24 | /****************************************************************************** 25 | * INCLUDES 26 | ******************************************************************************/ 27 | 28 | #include "co_if.h" 29 | 30 | /****************************************************************************** 31 | * PUBLIC TYPES 32 | ******************************************************************************/ 33 | 34 | typedef void (*SIM_CAN_IRQ)(void); 35 | 36 | /****************************************************************************** 37 | * PUBLIC SYMBOLS 38 | ******************************************************************************/ 39 | 40 | extern const CO_IF_CAN_DRV SimCanDriver; 41 | 42 | /****************************************************************************** 43 | * SPECIAL PUBLIC DRIVER FUNCTIONS 44 | ******************************************************************************/ 45 | 46 | /* CAN Bus Simulation Interface (for interfacing with automated tests only) */ 47 | int16_t SimCanGetFrm (uint8_t *buf, uint16_t size); 48 | int16_t SimCanSetFrm (uint32_t Identifier, uint8_t DLC, 49 | uint8_t Byte0, uint8_t Byte1, uint8_t Byte2, 50 | uint8_t Byte3, uint8_t Byte4, uint8_t Byte5, 51 | uint8_t Byte6, uint8_t Byte7); 52 | void SimCanSetIsr (SIM_CAN_IRQ handler); 53 | void SimCanRun (void); 54 | void SimCanFlush (void); 55 | 56 | #ifdef __cplusplus /* for compatibility with C++ environments */ 57 | } 58 | #endif 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /examples/quickstart/driver/drv_can_sim.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2020 Embedded Office GmbH & Co. KG 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ******************************************************************************/ 16 | 17 | #ifndef CO_CAN_SIM_H_ 18 | #define CO_CAN_SIM_H_ 19 | 20 | #ifdef __cplusplus /* for compatibility with C++ environments */ 21 | extern "C" { 22 | #endif 23 | 24 | /****************************************************************************** 25 | * INCLUDES 26 | ******************************************************************************/ 27 | 28 | #include "co_if.h" 29 | 30 | /****************************************************************************** 31 | * PUBLIC TYPES 32 | ******************************************************************************/ 33 | 34 | typedef void (*SIM_CAN_IRQ)(void); 35 | 36 | /****************************************************************************** 37 | * PUBLIC SYMBOLS 38 | ******************************************************************************/ 39 | 40 | extern const CO_IF_CAN_DRV SimCanDriver; 41 | 42 | /****************************************************************************** 43 | * SPECIAL PUBLIC DRIVER FUNCTIONS 44 | ******************************************************************************/ 45 | 46 | /* CAN Bus Simulation Interface (for interfacing with automated tests only) */ 47 | int16_t SimCanGetFrm (uint8_t *buf, uint16_t size); 48 | int16_t SimCanSetFrm (uint32_t Identifier, uint8_t DLC, 49 | uint8_t Byte0, uint8_t Byte1, uint8_t Byte2, 50 | uint8_t Byte3, uint8_t Byte4, uint8_t Byte5, 51 | uint8_t Byte6, uint8_t Byte7); 52 | void SimCanSetIsr (SIM_CAN_IRQ handler); 53 | void SimCanRun (void); 54 | void SimCanFlush (void); 55 | 56 | #ifdef __cplusplus /* for compatibility with C++ environments */ 57 | } 58 | #endif 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /tests/integration/driver/drv_can_sim.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2020 Embedded Office GmbH & Co. KG 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ******************************************************************************/ 16 | 17 | #ifndef CO_CAN_SIM_H_ 18 | #define CO_CAN_SIM_H_ 19 | 20 | #ifdef __cplusplus /* for compatibility with C++ environments */ 21 | extern "C" { 22 | #endif 23 | 24 | /****************************************************************************** 25 | * INCLUDES 26 | ******************************************************************************/ 27 | 28 | #include "co_if.h" 29 | 30 | /****************************************************************************** 31 | * PUBLIC TYPES 32 | ******************************************************************************/ 33 | 34 | typedef void (*SIM_CAN_IRQ)(void); 35 | 36 | /****************************************************************************** 37 | * PUBLIC SYMBOLS 38 | ******************************************************************************/ 39 | 40 | extern const CO_IF_CAN_DRV SimCanDriver; 41 | 42 | /****************************************************************************** 43 | * SPECIAL PUBLIC DRIVER FUNCTIONS 44 | ******************************************************************************/ 45 | 46 | /* CAN Bus Simulation Interface (for interfacing with automated tests only) */ 47 | int16_t SimCanGetFrm (uint8_t *buf, uint16_t size); 48 | int16_t SimCanSetFrm (uint32_t Identifier, uint8_t DLC, 49 | uint8_t Byte0, uint8_t Byte1, uint8_t Byte2, 50 | uint8_t Byte3, uint8_t Byte4, uint8_t Byte5, 51 | uint8_t Byte6, uint8_t Byte7); 52 | void SimCanSetIsr (SIM_CAN_IRQ handler); 53 | void SimCanRun (void); 54 | void SimCanFlush (void); 55 | 56 | #ifdef __cplusplus /* for compatibility with C++ environments */ 57 | } 58 | #endif 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /tests/unit/object/cia301/co_para_store/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************** 2 | # Copyright 2020 Embedded Office GmbH & Co. KG 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #****************************************************************************** 16 | 17 | add_executable(ut-para-store main.c) 18 | target_link_libraries(ut-para-store canopen-stack ut-test-env) 19 | 20 | 21 | #--- type function interface tests --- 22 | 23 | add_test(NAME unit/object/para-store/size/sub_0 COMMAND ut-para-store size_sub_0 ) 24 | add_test(NAME unit/object/para-store/size/sub_1 COMMAND ut-para-store size_sub_1 ) 25 | add_test(NAME unit/object/para-store/size/bad_size COMMAND ut-para-store size_bad_size ) 26 | add_test(NAME unit/object/para-store/read/enabled COMMAND ut-para-store read_enabled ) 27 | add_test(NAME unit/object/para-store/read/autonomous COMMAND ut-para-store read_autonomous ) 28 | add_test(NAME unit/object/para-store/read/bad_node COMMAND ut-para-store read_bad_node ) 29 | add_test(NAME unit/object/para-store/write/single COMMAND ut-para-store write_single ) 30 | add_test(NAME unit/object/para-store/write/all COMMAND ut-para-store write_all ) 31 | add_test(NAME unit/object/para-store/write/bad_signature COMMAND ut-para-store write_bad_signature ) 32 | add_test(NAME unit/object/para-store/write/bad_index COMMAND ut-para-store write_bad_index ) 33 | add_test(NAME unit/object/para-store/write/bad_node COMMAND ut-para-store write_bad_node ) 34 | add_test(NAME unit/object/para-store/init/check COMMAND ut-para-store init_check ) 35 | add_test(NAME unit/object/para-store/init/bad_index COMMAND ut-para-store init_bad_index ) 36 | add_test(NAME unit/object/para-store/reset/com COMMAND ut-para-store reset_com ) 37 | add_test(NAME unit/object/para-store/reset/node COMMAND ut-para-store reset_node ) 38 | -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************** 2 | # Copyright 2020 Embedded Office GmbH & Co. KG 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #****************************************************************************** 16 | 17 | #--- 18 | # define the canopen stack library 19 | # 20 | add_library(canopen-stack) 21 | 22 | #--- 23 | # define interface 24 | # 25 | target_include_directories(canopen-stack 26 | PUBLIC 27 | config 28 | core 29 | hal 30 | object/basic 31 | object/cia301 32 | service/cia301 33 | service/cia305 34 | ) 35 | 36 | #--- 37 | # specify the implementation files 38 | # 39 | target_sources(canopen-stack 40 | PRIVATE 41 | # config interface 42 | config/callbacks.c 43 | 44 | # core API 45 | core/co_core.c 46 | core/co_dict.c 47 | core/co_nmt.c 48 | core/co_obj.c 49 | core/co_tmr.c 50 | core/co_ver.c 51 | # hardware abstraction 52 | hal/co_if.c 53 | hal/co_if_can.c 54 | hal/co_if_nvm.c 55 | hal/co_if_timer.c 56 | 57 | # object type functions 58 | # - basic types 59 | object/basic/co_domain.c 60 | object/basic/co_string.c 61 | object/basic/co_integer8.c 62 | object/basic/co_integer16.c 63 | object/basic/co_integer32.c 64 | # - CiA301 types 65 | object/cia301/co_emcy_hist.c 66 | object/cia301/co_emcy_id.c 67 | object/cia301/co_hb_cons.c 68 | object/cia301/co_hb_prod.c 69 | object/cia301/co_para_store.c 70 | object/cia301/co_para_restore.c 71 | object/cia301/co_pdo_event.c 72 | object/cia301/co_pdo_id.c 73 | object/cia301/co_pdo_map.c 74 | object/cia301/co_pdo_num.c 75 | object/cia301/co_pdo_type.c 76 | object/cia301/co_sdo_id.c 77 | object/cia301/co_sync_cycle.c 78 | object/cia301/co_sync_id.c 79 | 80 | # network services 81 | # - CiA301 82 | service/cia301/co_csdo.c 83 | service/cia301/co_emcy.c 84 | service/cia301/co_pdo.c 85 | service/cia301/co_ssdo.c 86 | service/cia301/co_sync.c 87 | # - CiA305 88 | service/cia305/co_lss.c 89 | ) 90 | -------------------------------------------------------------------------------- /src/core/co_types.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2020 Embedded Office GmbH & Co. KG 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ******************************************************************************/ 16 | 17 | #ifndef CO_TYPES_H_ 18 | #define CO_TYPES_H_ 19 | 20 | /****************************************************************************** 21 | * INCLUDES 22 | ******************************************************************************/ 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | /****************************************************************************** 29 | * PUBLIC MACROS 30 | ******************************************************************************/ 31 | 32 | #ifdef _DEBUG 33 | /* For unit testing and debug builds, the marked implementation of functions 34 | * are included as weak symbol in the CANopen library. This weak symbols help 35 | * us to improve testability by allowing stubbing functions in the test cases 36 | * with stub functions of the same symbol name. 37 | */ 38 | #ifndef WEAK_TEST 39 | #define WEAK_TEST __attribute__((weak)) 40 | #endif 41 | #else 42 | #define WEAK_TEST 43 | #endif 44 | #define WEAK __attribute__((weak)) 45 | 46 | #define CO_UNUSED(var) (void)(var) 47 | 48 | #define ASSERT_PTR_ERR(ptr,err) \ 49 | if ((void*)(ptr) == NULL) { return (err); } 50 | 51 | #define ASSERT_EQU_ERR(var,val,err) \ 52 | if ((var) != (val)) { return (err); } 53 | 54 | #define ASSERT_LOWER(var,val) \ 55 | if ((var) >= (val)) { return; } 56 | 57 | #define ASSERT_LOWER_ERR(var, val, err) \ 58 | if ((var) >= (val)) { return (err); } 59 | 60 | #define ASSERT_NOT(var,val) \ 61 | if ((var) == (val)) { return; } 62 | 63 | #define ASSERT_NOT_ERR(var,val,err) \ 64 | if ((var) == (val)) { return (err); } 65 | 66 | #define ASSERT_PTR(ptr) \ 67 | if ((void*)(ptr) == NULL) { return; } 68 | 69 | #define ASSERT_PTR_FATAL(ptr) \ 70 | if ((void*)(ptr) == NULL) { CONodeFatalError(); return; } 71 | 72 | #define ASSERT_PTR_FATAL_ERR(ptr, err) \ 73 | if ((void*)(ptr) == NULL) { CONodeFatalError(); return(err); } 74 | 75 | #endif /* ifndef CO_TYPES_H_ */ 76 | -------------------------------------------------------------------------------- /src/hal/co_if.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2020 Embedded Office GmbH & Co. KG 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ******************************************************************************/ 16 | 17 | #ifndef CO_IF_H_ 18 | #define CO_IF_H_ 19 | 20 | #ifdef __cplusplus /* for compatibility with C++ environments */ 21 | extern "C" { 22 | #endif 23 | 24 | /****************************************************************************** 25 | * INCLUDES 26 | ******************************************************************************/ 27 | 28 | #include "co_types.h" 29 | #include "co_if_can.h" 30 | #include "co_if_timer.h" 31 | #include "co_if_nvm.h" 32 | 33 | /****************************************************************************** 34 | * PUBLIC TYPES 35 | ******************************************************************************/ 36 | 37 | struct CO_NODE_T; /* Declaration of canopen node structure */ 38 | 39 | typedef struct CO_IF_DRV_T { /*!< Type, which links driver functions */ 40 | const CO_IF_CAN_DRV *Can; /*!< Link to CAN driver functions */ 41 | const CO_IF_TIMER_DRV *Timer; /*!< Link to Timer driver functions */ 42 | const CO_IF_NVM_DRV *Nvm; /*!< Link to NVM driver functions */ 43 | } CO_IF_DRV; 44 | 45 | typedef struct CO_IF_T { /*!< Driver interface structure */ 46 | struct CO_NODE_T *Node; /*!< Link to parent node */ 47 | CO_IF_DRV *Drv; /*!< Link to hardware driver functions */ 48 | } CO_IF; 49 | 50 | /****************************************************************************** 51 | * PUBLIC FUNCTIONS 52 | ******************************************************************************/ 53 | 54 | /*! \brief INITIALIZE INTERFACES 55 | * 56 | * This function initialize all hardware interfaces. 57 | * 58 | * \param cif 59 | * pointer to the interface structure 60 | * 61 | * \param node 62 | * pointer to the parent node 63 | * 64 | * \param freq 65 | * timer clock frequency 66 | */ 67 | void COIfInit(CO_IF *cif, struct CO_NODE_T *node, uint32_t freq); 68 | 69 | #ifdef __cplusplus /* for compatibility with C++ environments */ 70 | } 71 | #endif 72 | 73 | #endif /* CO_IF_H_ */ 74 | -------------------------------------------------------------------------------- /src/object/basic/co_string.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2020 Embedded Office GmbH & Co. KG 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ******************************************************************************/ 16 | 17 | #ifndef CO_STRING_H_ 18 | #define CO_STRING_H_ 19 | 20 | #ifdef __cplusplus /* for compatibility with C++ environments */ 21 | extern "C" { 22 | #endif 23 | 24 | /****************************************************************************** 25 | * INCLUDES 26 | ******************************************************************************/ 27 | 28 | #include "co_types.h" 29 | #include "co_err.h" 30 | #include "co_obj.h" 31 | 32 | /****************************************************************************** 33 | * DEFINES 34 | ******************************************************************************/ 35 | 36 | #define CO_TSTRING ((const CO_OBJ_TYPE *)&COTString) 37 | 38 | /****************************************************************************** 39 | * PUBLIC TYPE DEFINITION 40 | ******************************************************************************/ 41 | 42 | /*! \brief STRING MANAGEMENT STRUCTURE 43 | * 44 | * This structure holds all data, which are needed for the string object 45 | * management within the object dictionary. 46 | */ 47 | typedef struct CO_OBJ_STR_T { 48 | uint32_t Offset; /*!< Internal offset information */ 49 | uint8_t *Start; /*!< String start address */ 50 | 51 | } CO_OBJ_STR; 52 | 53 | /****************************************************************************** 54 | * PUBLIC CONSTANTS 55 | ******************************************************************************/ 56 | 57 | /*! \brief OBJECT TYPE STRING 58 | * 59 | * This type is responsible for the access to unlimited string constants. 60 | * It is assumed, that the strings are declared in nonvolatile memory 61 | * (e.g. FLASH) and the string management structure is stored in the 62 | * object entry member 'Data'. 63 | */ 64 | extern const CO_OBJ_TYPE COTString; 65 | 66 | #ifdef __cplusplus /* for compatibility with C++ environments */ 67 | } 68 | #endif 69 | 70 | #endif /* #ifndef CO_STRING_H_ */ 71 | -------------------------------------------------------------------------------- /src/hal/co_if_can.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2020 Embedded Office GmbH & Co. KG 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ******************************************************************************/ 16 | 17 | /****************************************************************************** 18 | * INCLUDES 19 | ******************************************************************************/ 20 | 21 | #include "co_core.h" 22 | 23 | /****************************************************************************** 24 | * PUBLIC FUNCTIONS 25 | ******************************************************************************/ 26 | 27 | /* 28 | * see function definition 29 | */ 30 | void COIfCanInit(CO_IF *cif, struct CO_NODE_T *node) 31 | { 32 | const CO_IF_CAN_DRV *can = cif->Drv->Can; 33 | (void)node; 34 | can->Init(); 35 | } 36 | 37 | /* 38 | * see function definition 39 | */ 40 | int16_t COIfCanRead (CO_IF *cif, CO_IF_FRM *frm) 41 | { 42 | int16_t err; 43 | const CO_IF_CAN_DRV *can = cif->Drv->Can; 44 | 45 | err = can->Read(frm); 46 | if (err < (int16_t)0) { 47 | cif->Node->Error = CO_ERR_IF_CAN_READ; 48 | } 49 | return (err); 50 | } 51 | 52 | /* 53 | * see function definition 54 | */ 55 | int16_t COIfCanSend(CO_IF *cif, CO_IF_FRM *frm) 56 | { 57 | int16_t err; 58 | const CO_IF_CAN_DRV *can = cif->Drv->Can; 59 | 60 | err = can->Send(frm); 61 | if (err < (int16_t)0) { 62 | cif->Node->Error = CO_ERR_IF_CAN_SEND; 63 | } 64 | return (err); 65 | } 66 | 67 | /* 68 | * see function definition 69 | */ 70 | void COIfCanReset(CO_IF *cif) 71 | { 72 | const CO_IF_CAN_DRV *can = cif->Drv->Can; 73 | can->Reset(); 74 | } 75 | 76 | /* 77 | * see function definition 78 | */ 79 | void COIfCanClose(CO_IF *cif) 80 | { 81 | const CO_IF_CAN_DRV *can = cif->Drv->Can; 82 | can->Close(); 83 | } 84 | 85 | /* 86 | * see function definition 87 | */ 88 | void COIfCanEnable(CO_IF *cif, uint32_t baudrate) 89 | { 90 | const CO_IF_CAN_DRV *can = cif->Drv->Can; 91 | 92 | if (baudrate == (uint32_t)0) { 93 | baudrate = cif->Node->Baudrate; 94 | } else { 95 | cif->Node->Baudrate = baudrate; 96 | } 97 | 98 | can->Enable(baudrate); 99 | } 100 | -------------------------------------------------------------------------------- /tests/unit/core/tmr/get_ticks/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************** 2 | # Copyright 2020 Embedded Office GmbH & Co. KG 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #****************************************************************************** 16 | 17 | add_executable(ut-tmr-get-ticks main.c) 18 | target_link_libraries(ut-tmr-get-ticks canopen-stack ut-test-env) 19 | 20 | 21 | #--- type function interface tests --- 22 | 23 | add_test(NAME unit/tmr/get_ticks/1MHz_0ms COMMAND ut-tmr-get-ticks 1MHz_0ms ) 24 | add_test(NAME unit/tmr/get_ticks/1MHz_23ms COMMAND ut-tmr-get-ticks 1MHz_23ms ) 25 | add_test(NAME unit/tmr/get_ticks/1MHz_456ms COMMAND ut-tmr-get-ticks 1MHz_456ms ) 26 | add_test(NAME unit/tmr/get_ticks/1MHz_1000ms COMMAND ut-tmr-get-ticks 1MHz_1000ms ) 27 | add_test(NAME unit/tmr/get_ticks/1MHz_65535ms COMMAND ut-tmr-get-ticks 1MHz_65535ms ) 28 | add_test(NAME unit/tmr/get_ticks/1MHz_100us COMMAND ut-tmr-get-ticks 1MHz_100us ) 29 | add_test(NAME unit/tmr/get_ticks/1MHz_2300us COMMAND ut-tmr-get-ticks 1MHz_2300us ) 30 | add_test(NAME unit/tmr/get_ticks/1MHz_72500us COMMAND ut-tmr-get-ticks 1MHz_72500us ) 31 | add_test(NAME unit/tmr/get_ticks/1MHz_6553500us COMMAND ut-tmr-get-ticks 1MHz_6553500us ) 32 | add_test(NAME unit/tmr/get_ticks/1kHz_0ms COMMAND ut-tmr-get-ticks 1kHz_0ms ) 33 | add_test(NAME unit/tmr/get_ticks/1kHz_23ms COMMAND ut-tmr-get-ticks 1kHz_23ms ) 34 | add_test(NAME unit/tmr/get_ticks/1kHz_456ms COMMAND ut-tmr-get-ticks 1kHz_456ms ) 35 | add_test(NAME unit/tmr/get_ticks/1kHz_1000ms COMMAND ut-tmr-get-ticks 1kHz_1000ms ) 36 | add_test(NAME unit/tmr/get_ticks/1kHz_65535ms COMMAND ut-tmr-get-ticks 1kHz_65535ms ) 37 | add_test(NAME unit/tmr/get_ticks/1kHz_100us COMMAND ut-tmr-get-ticks 1kHz_100us ) 38 | add_test(NAME unit/tmr/get_ticks/100Hz_6ms COMMAND ut-tmr-get-ticks 100Hz_6ms ) 39 | add_test(NAME unit/tmr/get_ticks/100Hz_42ms COMMAND ut-tmr-get-ticks 100Hz_42ms ) 40 | add_test(NAME unit/tmr/get_ticks/100Hz_789ms COMMAND ut-tmr-get-ticks 100Hz_789ms ) 41 | add_test(NAME unit/tmr/get_ticks/100Hz_5000ms COMMAND ut-tmr-get-ticks 100Hz_5000ms ) 42 | add_test(NAME unit/tmr/get_ticks/100Hz_65535ms COMMAND ut-tmr-get-ticks 100Hz_65535ms ) 43 | add_test(NAME unit/tmr/get_ticks/100Hz_100us COMMAND ut-tmr-get-ticks 100Hz_100us ) 44 | -------------------------------------------------------------------------------- /tests/integration/testfrm/ts_lock.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2020 Embedded Office GmbH & Co. KG 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ******************************************************************************/ 16 | 17 | /****************************************************************************** 18 | * INCLUDES 19 | ******************************************************************************/ 20 | 21 | #include "ts_lock.h" 22 | #include "ts_printf.h" 23 | 24 | /****************************************************************************** 25 | * PRIVATE DEFINES 26 | ******************************************************************************/ 27 | 28 | #define TS_LOCK_UNBALANCED 1 29 | 30 | /*------------------------------------------------------------------------------------------------*/ 31 | /*! 32 | * \details This macro allows the definition of an activity when detecting an usage error. In the 33 | * test framework we print a message and stop executing the tests. 34 | */ 35 | /*------------------------------------------------------------------------------------------------*/ 36 | #define TS_LockError(code,line) \ 37 | TS_Printf("Abort Test: Lock Error %d in Line %d", code, line); \ 38 | while(1) 39 | 40 | /****************************************************************************** 41 | * PUBLIC FUNCTIONS 42 | ******************************************************************************/ 43 | 44 | void TS_LockSetup(TS_LOCK *lock, TS_LOCK_FUNC lockFunc, TS_UNLOCK_FUNC unlockFunc) 45 | { 46 | if (lockFunc == NULL) { 47 | unlockFunc = NULL; 48 | } else if (unlockFunc == NULL) { 49 | lockFunc = NULL; 50 | } 51 | 52 | lock->LockCnt = 0; 53 | lock->LockFunc = lockFunc; 54 | lock->UnlockFunc = unlockFunc; 55 | } 56 | 57 | TS_LOCK_SR TS_Lock(TS_LOCK *lock) 58 | { 59 | TS_LOCK_SR state = 0; 60 | 61 | if (lock->LockFunc != NULL) { 62 | if (lock->LockCnt == 0) { 63 | state = lock->LockFunc(); 64 | } 65 | lock->LockCnt++; 66 | } 67 | 68 | return (state); 69 | } 70 | 71 | void TS_Unlock(TS_LOCK *lock, TS_LOCK_SR state) 72 | { 73 | if (lock->UnlockFunc != NULL) { 74 | if (lock->LockCnt > 0) { 75 | lock->LockCnt--; 76 | if (lock->LockCnt == 0) { 77 | lock->UnlockFunc(state); 78 | } 79 | } else { 80 | TS_LockError(TS_LOCK_UNBALANCED, __LINE__); 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /tests/integration/app/app.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2020 Embedded Office GmbH & Co. KG 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ******************************************************************************/ 16 | 17 | /****************************************************************************** 18 | * INCLUDES 19 | ******************************************************************************/ 20 | 21 | #include "ts_env.h" 22 | #include "ts_version.h" 23 | #include "def_suite.h" 24 | #include "co_ver.h" 25 | 26 | /****************************************************************************** 27 | * PRIVATE FUNCTIONS 28 | ******************************************************************************/ 29 | 30 | /*---------------------------------------------------------------------------*/ 31 | /*! \brief REQ-TST-0100 32 | * 33 | * \details collect and report the environment identification information 34 | */ 35 | /*---------------------------------------------------------------------------*/ 36 | static void TS_IdentEnv(void); 37 | static void TS_IdentEnv(void) 38 | { 39 | TS_Printf("-----------------------\n"); 40 | TS_Printf(" E N V I R O N M E N T \n"); 41 | TS_Printf("-----------------------\n"); 42 | 43 | /*--- Framework ---*/ 44 | TS_Printf("%s V", TS_NAME); 45 | TS_PrintVersion(TS_VERSION, TS_VER_FORMAT, TS_VER_BASE); 46 | TS_Printf("\n"); 47 | 48 | /*--- Compiler ---*/ 49 | TS_Printf("%s V", TS_ENV_NAME); 50 | TS_PrintVersion(TS_ENV_VER, TS_ENV_VER_FORMAT, TS_ENV_VER_BASE); 51 | TS_Printf("\n"); 52 | 53 | /*--- Unit Under Test ---*/ 54 | TS_Printf("CANopen Stack V%d.%d.%d", 55 | CO_VER_MAJOR, CO_VER_MINOR, CO_VER_BUILD); 56 | TS_Printf("\n"); 57 | } 58 | 59 | /****************************************************************************** 60 | * PUBLIC FUNCTIONS 61 | ******************************************************************************/ 62 | 63 | /*---------------------------------------------------------------------------*/ 64 | /*! \brief REQ-TST-0110 65 | * 66 | * \details main entry function for the test application 67 | * 68 | * \return number of failed tests 69 | */ 70 | /*---------------------------------------------------------------------------*/ 71 | int main(void) 72 | { 73 | int result; 74 | 75 | TS_Init(); 76 | TS_SetupAll(TS_IdentEnv, NULL); 77 | 78 | result = (int)TS_Start(); 79 | 80 | return(result); 81 | } 82 | -------------------------------------------------------------------------------- /src/core/co_ver.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2020 Embedded Office GmbH & Co. KG 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ******************************************************************************/ 16 | 17 | /****************************************************************************** 18 | * INCLUDES 19 | ******************************************************************************/ 20 | 21 | #include "co_ver.h" 22 | 23 | /****************************************************************************** 24 | * PRIVATE TYPES 25 | ******************************************************************************/ 26 | 27 | typedef struct CO_VER_T { 28 | uint8_t Build; /*!< version build number */ 29 | uint8_t Minor; /*!< minor version number */ 30 | uint8_t Major; /*!< major version number */ 31 | 32 | } CO_VER; 33 | 34 | /****************************************************************************** 35 | * PRIVATE VARIABLES 36 | ******************************************************************************/ 37 | 38 | static CO_VER COVer = { 0L, 0, 0 }; 39 | 40 | /****************************************************************************** 41 | * FUNCTIONS 42 | ******************************************************************************/ 43 | 44 | /* 45 | * see function definition 46 | */ 47 | uint8_t COVerMajor(void) 48 | { 49 | if (COVer.Major == 0L) { 50 | CO_VerInit(); 51 | } 52 | 53 | return COVer.Major; 54 | } 55 | 56 | /* 57 | * see function definition 58 | */ 59 | uint8_t COVerMinor(void) 60 | { 61 | if (COVer.Major == 0L) { 62 | CO_VerInit(); 63 | } 64 | 65 | return COVer.Minor; 66 | } 67 | 68 | /* 69 | * see function definition 70 | */ 71 | uint8_t COVerBuild(void) 72 | { 73 | if (COVer.Major == 0L) { 74 | CO_VerInit(); 75 | } 76 | 77 | return COVer.Build; 78 | } 79 | 80 | /* 81 | * see function definition 82 | */ 83 | uint32_t COVersion(void) 84 | { 85 | uint32_t version; 86 | 87 | version = COVerMajor() * 10000 + 88 | COVerMinor() * 100 + 89 | COVerBuild(); 90 | 91 | return version; 92 | } 93 | 94 | /* 95 | * see function definition 96 | */ 97 | void CO_VerInit(void) 98 | { 99 | COVer.Major = CO_VER_MAJOR; 100 | COVer.Minor = CO_VER_MINOR; 101 | COVer.Build = CO_VER_BUILD; 102 | } 103 | -------------------------------------------------------------------------------- /src/object/cia301/co_sdo_id.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2020 Embedded Office GmbH & Co. KG 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ******************************************************************************/ 16 | 17 | #ifndef CO_SDO_ID_H_ 18 | #define CO_SDO_ID_H_ 19 | 20 | #ifdef __cplusplus /* for compatibility with C++ environments */ 21 | extern "C" { 22 | #endif 23 | 24 | /****************************************************************************** 25 | * INCLUDES 26 | ******************************************************************************/ 27 | 28 | #include "co_types.h" 29 | #include "co_err.h" 30 | #include "co_obj.h" 31 | #include "co_sync.h" 32 | 33 | /****************************************************************************** 34 | * PUBLIC DEFINES 35 | ******************************************************************************/ 36 | 37 | #define CO_TSDO_ID ((const CO_OBJ_TYPE *)&COTSdoId) 38 | 39 | /****************************************************************************** 40 | * PUBLIC CONSTANTS 41 | ******************************************************************************/ 42 | 43 | /*! \brief OBJECT TYPE SDO IDENTIFIER 44 | * 45 | * This object type specializes the general handling of objects for the 46 | * object dictionary entries holding a SDO identifier. These entries are 47 | * designed to provide the feature of changing a SDO identifier. 48 | */ 49 | extern const CO_OBJ_TYPE COTSdoId; 50 | 51 | /****************************************************************************** 52 | * PROTECTED HELBER FUNCTIONS 53 | ******************************************************************************/ 54 | 55 | /*! \brief ACTIVATE SYNC PRODUCER 56 | * 57 | * This function is used to activate SYNC producer functionality. 58 | * It's called on NMT Start Pre-Operational or sync COB-ID update 59 | * (1005h) with bit 30 set to 1. 60 | * 61 | * \param sync 62 | * Pointer to SYNC object 63 | */ 64 | void COSyncProdActivate(CO_SYNC *sync); 65 | 66 | /*! \brief ACTIVATE SYNC PRODUCER 67 | * 68 | * This function is used to deactivate SYNC producer functionality. 69 | * It's called on sync COB-ID update (1005h) with bit 30 set to 0. 70 | * 71 | * \param sync 72 | * Pointer to SYNC object 73 | */ 74 | void COSyncProdDeactivate(CO_SYNC *sync); 75 | 76 | #ifdef __cplusplus /* for compatibility with C++ environments */ 77 | } 78 | #endif 79 | 80 | #endif /* #ifndef CO_SDO_ID_H_ */ 81 | -------------------------------------------------------------------------------- /src/object/cia301/co_para.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2020 Embedded Office GmbH & Co. KG 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ******************************************************************************/ 16 | 17 | #ifndef CO_PARA_H_ 18 | #define CO_PARA_H_ 19 | 20 | #ifdef __cplusplus /* for compatibility with C++ environments */ 21 | extern "C" { 22 | #endif 23 | 24 | /****************************************************************************** 25 | * INCLUDES 26 | ******************************************************************************/ 27 | 28 | #include "co_types.h" 29 | #include "co_nmt.h" 30 | 31 | /****************************************************************************** 32 | * PUBLIC DEFINES 33 | ******************************************************************************/ 34 | 35 | #define CO_PARA____ 0x0000 /*!< disable */ 36 | #define CO_PARA___E 0x0001 /*!< enable (on command) */ 37 | #define CO_PARA__A_ 0x0002 /*!< enable (autonomously) */ 38 | #define CO_PARA__AE 0x0003 /*!< enable (autonomously and on command) */ 39 | 40 | /****************************************************************************** 41 | * PUBLIC TYPES 42 | ******************************************************************************/ 43 | 44 | /*! \brief PARAMETER GROUP INFO 45 | * 46 | * This structure holds the informations of a parameter group. The 47 | * parameter group is used within the special function objects in 48 | * an object dictionary for store and restore parameters. 49 | * 50 | * \note 51 | * This structure may be placed into ROM to reduce RAM usage. 52 | */ 53 | typedef struct CO_PARA_T { 54 | uint32_t Offset; /*!< Offset in non-volatile memory area */ 55 | uint32_t Size; /*!< Size of parameter memory block */ 56 | uint8_t *Start; /*!< Start of parameter memory block */ 57 | uint8_t *Default; /*!< Start of default memory block */ 58 | enum CO_NMT_RESET_T Type; /*!< Parameter reset type */ 59 | void *Ident; /*!< Ptr to User Ident-Code */ 60 | uint32_t Value; /*!< value when reading parameter object */ 61 | 62 | } CO_PARA; 63 | 64 | #ifdef __cplusplus /* for compatibility with C++ environments */ 65 | } 66 | #endif 67 | 68 | #endif /* #ifndef CO_PARA_H_ */ 69 | -------------------------------------------------------------------------------- /src/driver/_template/drv_nvm_dummy.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2020 Embedded Office GmbH & Co. KG 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ******************************************************************************/ 16 | 17 | /****************************************************************************** 18 | * INCLUDES 19 | ******************************************************************************/ 20 | 21 | /* TODO: rename the include file name to match the naming convention: 22 | * co_nvm_.h 23 | */ 24 | #include "co_nvm_dummy.h" 25 | 26 | /****************************************************************************** 27 | * PRIVATE DEFINES 28 | ******************************************************************************/ 29 | 30 | /* TODO: place here your timer register definitions */ 31 | 32 | /****************************************************************************** 33 | * PRIVATE FUNCTIONS 34 | ******************************************************************************/ 35 | 36 | static void DrvNvmInit (void); 37 | static uint32_t DrvNvmRead (uint32_t start, uint8_t *buffer, uint32_t size); 38 | static uint32_t DrvNvmWrite (uint32_t start, uint8_t *buffer, uint32_t size); 39 | 40 | 41 | /****************************************************************************** 42 | * PUBLIC VARIABLE 43 | ******************************************************************************/ 44 | 45 | /* TODO: rename the variable to match the naming convention: 46 | * NvmDriver 47 | */ 48 | const CO_IF_NVM_DRV DummyNvmDriver = { 49 | DrvNvmInit, 50 | DrvNvmRead, 51 | DrvNvmWrite 52 | }; 53 | 54 | /****************************************************************************** 55 | * PRIVATE FUNCTIONS 56 | ******************************************************************************/ 57 | 58 | static void DrvNvmInit(void) 59 | { 60 | /* TODO: initialize the non-volatile memory */ 61 | } 62 | 63 | static uint32_t DrvNvmRead(uint32_t start, uint8_t *buffer, uint32_t size) 64 | { 65 | (void)start; 66 | (void)buffer; 67 | (void)size; 68 | 69 | /* TODO: read a memory block from non-volatile memory into given buffer */ 70 | return (0u); 71 | } 72 | 73 | static uint32_t DrvNvmWrite(uint32_t start, uint8_t *buffer, uint32_t size) 74 | { 75 | (void)start; 76 | (void)buffer; 77 | (void)size; 78 | 79 | /* TODO: write content of given buffer into non-volatile memory */ 80 | return (0u); 81 | } 82 | -------------------------------------------------------------------------------- /examples/dynamic-od/driver/drv_timer_swcycle.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2020 Embedded Office GmbH & Co. KG 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ******************************************************************************/ 16 | 17 | /****************************************************************************** 18 | * INCLUDES 19 | ******************************************************************************/ 20 | 21 | #include "drv_timer_swcycle.h" 22 | 23 | /****************************************************************************** 24 | * PRIVATE VARIABLES 25 | ******************************************************************************/ 26 | 27 | static uint32_t TimerCounter = 0u; 28 | 29 | /****************************************************************************** 30 | * PRIVATE FUNCTIONS 31 | ******************************************************************************/ 32 | 33 | static void DrvTimerInit (uint32_t freq); 34 | static void DrvTimerStart (void); 35 | static uint8_t DrvTimerUpdate (void); 36 | static uint32_t DrvTimerDelay (void); 37 | static void DrvTimerReload (uint32_t reload); 38 | static void DrvTimerStop (void); 39 | 40 | /****************************************************************************** 41 | * PUBLIC VARIABLE 42 | ******************************************************************************/ 43 | 44 | const CO_IF_TIMER_DRV SwCycleTimerDriver = { 45 | DrvTimerInit, 46 | DrvTimerReload, 47 | DrvTimerDelay, 48 | DrvTimerStop, 49 | DrvTimerStart, 50 | DrvTimerUpdate 51 | }; 52 | 53 | /****************************************************************************** 54 | * PRIVATE FUNCTIONS 55 | ******************************************************************************/ 56 | 57 | static void DrvTimerInit(uint32_t freq) 58 | { 59 | (void)freq; 60 | TimerCounter = 0u; 61 | } 62 | 63 | static void DrvTimerStart(void) 64 | { 65 | } 66 | 67 | static uint8_t DrvTimerUpdate(void) 68 | { 69 | uint8_t result = 0u; 70 | 71 | if (TimerCounter > 0u) { 72 | TimerCounter--; 73 | if (TimerCounter == 0u) { 74 | result = 1u; 75 | } 76 | } 77 | 78 | return (result); 79 | } 80 | 81 | static uint32_t DrvTimerDelay(void) 82 | { 83 | return (TimerCounter); 84 | } 85 | 86 | static void DrvTimerReload(uint32_t reload) 87 | { 88 | TimerCounter = reload; 89 | } 90 | 91 | static void DrvTimerStop(void) 92 | { 93 | TimerCounter = 0u; 94 | } 95 | -------------------------------------------------------------------------------- /examples/quickstart/driver/drv_timer_swcycle.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2020 Embedded Office GmbH & Co. KG 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ******************************************************************************/ 16 | 17 | /****************************************************************************** 18 | * INCLUDES 19 | ******************************************************************************/ 20 | 21 | #include "drv_timer_swcycle.h" 22 | 23 | /****************************************************************************** 24 | * PRIVATE VARIABLES 25 | ******************************************************************************/ 26 | 27 | static uint32_t TimerCounter = 0u; 28 | 29 | /****************************************************************************** 30 | * PRIVATE FUNCTIONS 31 | ******************************************************************************/ 32 | 33 | static void DrvTimerInit (uint32_t freq); 34 | static void DrvTimerStart (void); 35 | static uint8_t DrvTimerUpdate (void); 36 | static uint32_t DrvTimerDelay (void); 37 | static void DrvTimerReload (uint32_t reload); 38 | static void DrvTimerStop (void); 39 | 40 | /****************************************************************************** 41 | * PUBLIC VARIABLE 42 | ******************************************************************************/ 43 | 44 | const CO_IF_TIMER_DRV SwCycleTimerDriver = { 45 | DrvTimerInit, 46 | DrvTimerReload, 47 | DrvTimerDelay, 48 | DrvTimerStop, 49 | DrvTimerStart, 50 | DrvTimerUpdate 51 | }; 52 | 53 | /****************************************************************************** 54 | * PRIVATE FUNCTIONS 55 | ******************************************************************************/ 56 | 57 | static void DrvTimerInit(uint32_t freq) 58 | { 59 | (void)freq; 60 | TimerCounter = 0u; 61 | } 62 | 63 | static void DrvTimerStart(void) 64 | { 65 | } 66 | 67 | static uint8_t DrvTimerUpdate(void) 68 | { 69 | uint8_t result = 0u; 70 | 71 | if (TimerCounter > 0u) { 72 | TimerCounter--; 73 | if (TimerCounter == 0u) { 74 | result = 1u; 75 | } 76 | } 77 | 78 | return (result); 79 | } 80 | 81 | static uint32_t DrvTimerDelay(void) 82 | { 83 | return (TimerCounter); 84 | } 85 | 86 | static void DrvTimerReload(uint32_t reload) 87 | { 88 | TimerCounter = reload; 89 | } 90 | 91 | static void DrvTimerStop(void) 92 | { 93 | TimerCounter = 0u; 94 | } 95 | -------------------------------------------------------------------------------- /tests/integration/driver/drv_timer_swcycle.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2020 Embedded Office GmbH & Co. KG 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ******************************************************************************/ 16 | 17 | /****************************************************************************** 18 | * INCLUDES 19 | ******************************************************************************/ 20 | 21 | #include "drv_timer_swcycle.h" 22 | 23 | /****************************************************************************** 24 | * PRIVATE VARIABLES 25 | ******************************************************************************/ 26 | 27 | static uint32_t TimerCounter = 0u; 28 | 29 | /****************************************************************************** 30 | * PRIVATE FUNCTIONS 31 | ******************************************************************************/ 32 | 33 | static void DrvTimerInit (uint32_t freq); 34 | static void DrvTimerStart (void); 35 | static uint8_t DrvTimerUpdate (void); 36 | static uint32_t DrvTimerDelay (void); 37 | static void DrvTimerReload (uint32_t reload); 38 | static void DrvTimerStop (void); 39 | 40 | /****************************************************************************** 41 | * PUBLIC VARIABLE 42 | ******************************************************************************/ 43 | 44 | const CO_IF_TIMER_DRV SwCycleTimerDriver = { 45 | DrvTimerInit, 46 | DrvTimerReload, 47 | DrvTimerDelay, 48 | DrvTimerStop, 49 | DrvTimerStart, 50 | DrvTimerUpdate 51 | }; 52 | 53 | /****************************************************************************** 54 | * PRIVATE FUNCTIONS 55 | ******************************************************************************/ 56 | 57 | static void DrvTimerInit(uint32_t freq) 58 | { 59 | (void)freq; 60 | TimerCounter = 0u; 61 | } 62 | 63 | static void DrvTimerStart(void) 64 | { 65 | } 66 | 67 | static uint8_t DrvTimerUpdate(void) 68 | { 69 | uint8_t result = 0u; 70 | 71 | if (TimerCounter > 0u) { 72 | TimerCounter--; 73 | if (TimerCounter == 0u) { 74 | result = 1u; 75 | } 76 | } 77 | 78 | return (result); 79 | } 80 | 81 | static uint32_t DrvTimerDelay(void) 82 | { 83 | return (TimerCounter); 84 | } 85 | 86 | static void DrvTimerReload(uint32_t reload) 87 | { 88 | TimerCounter = reload; 89 | } 90 | 91 | static void DrvTimerStop(void) 92 | { 93 | TimerCounter = 0u; 94 | } 95 | -------------------------------------------------------------------------------- /src/service/cia301/co_time.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2020 Embedded Office GmbH & Co. KG 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ******************************************************************************/ 16 | 17 | #ifndef CO_TIME_H_ 18 | #define CO_TIME_H_ 19 | 20 | #ifdef __cplusplus /* for compatibility with C++ environments */ 21 | extern "C" { 22 | #endif 23 | 24 | /****************************************************************************** 25 | * INCLUDES 26 | ******************************************************************************/ 27 | 28 | /****************************************************************************** 29 | * PUBLIC DEFINES 30 | ******************************************************************************/ 31 | 32 | /*! \brief COB-ID time stamp object 33 | * 34 | * These macros constructs the COB-ID for usage in object entry 35 | * index 1012: COB-ID time stamp object. The standard defines the 36 | * following encoding: 37 | * - bit31: consume: device consumes time stamp objects (1) or not (0) 38 | * - bit30: produce: device produces time stamp objects (1) or not (0) 39 | * - bit29: frame = 11bit standard CAN-ID (0) or 29bit extended CAN-ID (1) 40 | * - bit28-0: CAN-ID 41 | * 42 | * \param consume 43 | * the device consumes time stamp objects (1), or not (0) 44 | * 45 | * \param produce 46 | * the device produces time stamp objects (1); or not (0) 47 | * 48 | * \param id 49 | * the CAN-ID (standard or extended format) 50 | * \{ 51 | */ 52 | #define CO_COBID_TIME_STD(consume, produce, id) \ 53 | (uint32_t)(((uint32_t)(id) & 0x7ffuL) | \ 54 | (((uint32_t)(consume) & 0x1uL) << 31u) | \ 55 | (((uint32_t)(produce) & 0x1uL) << 30u)) 56 | 57 | #define CO_COBID_TIME_EXT(consume, produce, id) \ 58 | (uint32_t)(((uint32_t)(id) & 0x1fffffffuL) | \ 59 | ((uint32_t)0x1uL << 29u) | \ 60 | (((uint32_t)(consume) & 0x1uL) << 31u) | \ 61 | (((uint32_t)(produce) & 0x1uL) << 30u)) 62 | /*! \} */ 63 | 64 | /****************************************************************************** 65 | * PUBLIC TYPES 66 | ******************************************************************************/ 67 | 68 | /****************************************************************************** 69 | * PRIVATE FUNCTIONS 70 | ******************************************************************************/ 71 | 72 | #ifdef __cplusplus /* for compatibility with C++ environments */ 73 | } 74 | #endif 75 | 76 | #endif /* #ifndef CO_TIME_H_ */ 77 | -------------------------------------------------------------------------------- /src/object/basic/co_domain.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2020 Embedded Office GmbH & Co. KG 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ******************************************************************************/ 16 | 17 | #ifndef CO_DOMAIN_H_ 18 | #define CO_DOMAIN_H_ 19 | 20 | #ifdef __cplusplus /* for compatibility with C++ environments */ 21 | extern "C" { 22 | #endif 23 | 24 | /****************************************************************************** 25 | * INCLUDES 26 | ******************************************************************************/ 27 | 28 | #include "co_types.h" 29 | #include "co_err.h" 30 | #include "co_obj.h" 31 | 32 | /****************************************************************************** 33 | * DEFINES 34 | ******************************************************************************/ 35 | 36 | #define CO_TDOMAIN ((const CO_OBJ_TYPE *)&COTDomain) 37 | 38 | /****************************************************************************** 39 | * PUBLIC TYPE DEFINITION 40 | ******************************************************************************/ 41 | 42 | /*! \brief DOMAIN MANAGEMENT STRUCTURE 43 | * 44 | * This structure holds all data, which are needed for the domain object 45 | * management within the object dictionary. 46 | */ 47 | typedef struct CO_OBJ_DOM_T { 48 | uint32_t Offset; /*!< Internal offset information */ 49 | uint32_t Size; /*!< Domain size information */ 50 | uint8_t *Start; /*!< Domain start address */ 51 | 52 | } CO_OBJ_DOM; 53 | 54 | /****************************************************************************** 55 | * PUBLIC CONSTANTS 56 | ******************************************************************************/ 57 | 58 | /*! \brief OBJECT TYPE DOMAIN 59 | * 60 | * This type is responsible for the access to domain memory areas. It is 61 | * assumed, that the memory is declared in random accessible memory 62 | * (e.g. RAM, FLASH, etc..) and the domain management structure is stored 63 | * in the object entry member 'Data'. 64 | * 65 | * \note 66 | * This exemplary implementation is usable for reading and writing in 67 | * direct accessible memory (e.g. RAM). The reading from FLASH memory is 68 | * no problem, but for the write access to FLASH memory, there should be 69 | * a special DOMAIN implementation for each media. 70 | */ 71 | extern const CO_OBJ_TYPE COTDomain; 72 | 73 | #ifdef __cplusplus /* for compatibility with C++ environments */ 74 | } 75 | #endif 76 | 77 | #endif /* #ifndef CO_DOMAIN_H_ */ 78 | -------------------------------------------------------------------------------- /tests/integration/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #****************************************************************************** 2 | # Copyright 2020 Embedded Office GmbH & Co. KG 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #****************************************************************************** 16 | 17 | #--- 18 | # define the test application executable 19 | # 20 | add_executable(it-canopen-stack) 21 | 22 | #--- 23 | # test application with test runner and supporting functions 24 | # 25 | target_sources(it-canopen-stack 26 | PRIVATE 27 | app/app_dict.c 28 | app/app_dom.c 29 | app/app_emcy.c 30 | app/app_env.c 31 | app/app_hooks.c 32 | app/app.c 33 | ) 34 | target_include_directories(it-canopen-stack 35 | PRIVATE 36 | app 37 | ) 38 | 39 | #--- 40 | # add the host drivers 41 | # 42 | target_sources(it-canopen-stack 43 | PRIVATE 44 | driver/drv_can_sim.c 45 | driver/drv_nvm_sim.c 46 | driver/drv_timer_swcycle.c 47 | ) 48 | target_include_directories(it-canopen-stack 49 | PRIVATE 50 | driver 51 | ) 52 | 53 | #--- 54 | # add the test framework 55 | # 56 | target_sources(it-canopen-stack 57 | PRIVATE 58 | testfrm/ts_context.c 59 | testfrm/ts_env.c 60 | testfrm/ts_list.c 61 | testfrm/ts_lock.c 62 | testfrm/ts_mem.c 63 | testfrm/ts_output.c 64 | testfrm/ts_pipe.c 65 | testfrm/ts_printf.c 66 | testfrm/ts_version.c 67 | ) 68 | target_include_directories(it-canopen-stack 69 | PRIVATE 70 | testfrm 71 | ) 72 | 73 | #--- 74 | # select the test-suite files 75 | # 76 | target_sources(it-canopen-stack 77 | PRIVATE 78 | tests/core_tmr.c 79 | tests/emcy_api.c 80 | tests/emcy_err.c 81 | tests/emcy_hist.c 82 | tests/emcy_state.c 83 | tests/nmt_hbc.c 84 | tests/nmt_hbp.c 85 | tests/nmt_lss.c 86 | tests/nmt_mgr.c 87 | tests/od_api.c 88 | tests/pdo_dyn.c 89 | tests/pdo_rx.c 90 | tests/pdo_tx.c 91 | tests/sdoc_exp_down.c 92 | tests/sdoc_exp_up.c 93 | tests/sdoc_seg_down.c 94 | tests/sdoc_seg_up.c 95 | tests/sdos_blk_down.c 96 | tests/sdos_blk_up.c 97 | tests/sdos_exp_down.c 98 | tests/sdos_exp_up.c 99 | tests/sdos_seg_down.c 100 | tests/sdos_seg_up.c 101 | tests/sync_prod.c 102 | ) 103 | target_include_directories(it-canopen-stack 104 | PRIVATE 105 | tests 106 | ) 107 | 108 | #--- 109 | # specify the dependencies for this application 110 | # 111 | target_link_libraries(it-canopen-stack canopen-stack) 112 | 113 | #--- integration tests --- 114 | 115 | add_test(NAME integration/all COMMAND it-canopen-stack) 116 | -------------------------------------------------------------------------------- /src/hal/co_if_nvm.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2020 Embedded Office GmbH & Co. KG 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ******************************************************************************/ 16 | 17 | #ifndef CO_IF_NVM_H_ 18 | #define CO_IF_NVM_H_ 19 | 20 | #ifdef __cplusplus /* for compatibility with C++ environments */ 21 | extern "C" { 22 | #endif 23 | 24 | /****************************************************************************** 25 | * INCLUDES 26 | ******************************************************************************/ 27 | 28 | #include "co_types.h" 29 | 30 | /****************************************************************************** 31 | * PUBLIC TYPES 32 | ******************************************************************************/ 33 | 34 | struct CO_IF_T; /* Declaration of interface structure */ 35 | 36 | typedef void (*CO_IF_NVM_INIT_FUNC )(void); 37 | typedef uint32_t (*CO_IF_NVM_READ_FUNC )(uint32_t, uint8_t *, uint32_t); 38 | typedef uint32_t (*CO_IF_NVM_WRITE_FUNC)(uint32_t, uint8_t *, uint32_t); 39 | 40 | typedef struct CO_IF_NVM_DRV_T { 41 | CO_IF_NVM_INIT_FUNC Init; 42 | CO_IF_NVM_READ_FUNC Read; 43 | CO_IF_NVM_WRITE_FUNC Write; 44 | } CO_IF_NVM_DRV; 45 | 46 | /****************************************************************************** 47 | * PUBLIC FUNCTIONS 48 | ******************************************************************************/ 49 | 50 | /*! \brief READ NVM CONTENT 51 | * 52 | * This function reads the content of the non-volatile memory from the 53 | * given address into the given buffer. 54 | * 55 | * \param cif 56 | * pointer to the interface structure 57 | * 58 | * \param start 59 | * start address in non-volatile memory 60 | * 61 | * \param buffer 62 | * pointer to destination buffer 63 | * 64 | * \param size 65 | * size of data in bytes 66 | * 67 | * \return 68 | * number of read bytes 69 | */ 70 | uint32_t COIfNvmRead(struct CO_IF_T *cif, uint32_t start, uint8_t *buffer, uint32_t size); 71 | 72 | /*! \brief WRITE NVM CONTENT 73 | * 74 | * This function writes the content of the buffer to the non-volatile memory 75 | * at the given address. 76 | * 77 | * \param cif 78 | * pointer to the interface structure 79 | * 80 | * \param start 81 | * start address in non-volatile memory 82 | * 83 | * \param buffer 84 | * pointer to source buffer 85 | * 86 | * \param size 87 | * size of data in bytes 88 | * 89 | * \return 90 | * number of written bytes 91 | */ 92 | uint32_t COIfNvmWrite(struct CO_IF_T *cif, uint32_t start, uint8_t *buffer, uint32_t size); 93 | 94 | #ifdef __cplusplus /* for compatibility with C++ environments */ 95 | } 96 | #endif 97 | 98 | #endif /* CO_IF_NVM_H_ */ 99 | -------------------------------------------------------------------------------- /tests/integration/driver/drv_nvm_sim.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2020 Embedded Office GmbH & Co. KG 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ******************************************************************************/ 16 | 17 | /****************************************************************************** 18 | * INCLUDES 19 | ******************************************************************************/ 20 | 21 | #include "drv_nvm_sim.h" 22 | 23 | /****************************************************************************** 24 | * PRIVATE DEFINES 25 | ******************************************************************************/ 26 | 27 | #define NVM_SIM_SIZE 128 28 | 29 | /****************************************************************************** 30 | * PRIVATE VARIABLES 31 | ******************************************************************************/ 32 | 33 | static uint8_t NvmMemory[NVM_SIM_SIZE]; 34 | 35 | /****************************************************************************** 36 | * PRIVATE FUNCTIONS 37 | ******************************************************************************/ 38 | 39 | static void DrvNvmInit (void); 40 | static uint32_t DrvNvmRead (uint32_t start, uint8_t *buffer, uint32_t size); 41 | static uint32_t DrvNvmWrite (uint32_t start, uint8_t *buffer, uint32_t size); 42 | 43 | 44 | /****************************************************************************** 45 | * PUBLIC VARIABLE 46 | ******************************************************************************/ 47 | 48 | const CO_IF_NVM_DRV SimNvmDriver = { 49 | DrvNvmInit, 50 | DrvNvmRead, 51 | DrvNvmWrite 52 | }; 53 | 54 | /****************************************************************************** 55 | * PRIVATE FUNCTIONS 56 | ******************************************************************************/ 57 | 58 | static void DrvNvmInit(void) 59 | { 60 | uint32_t idx; 61 | 62 | for (idx = 0; idx < NVM_SIM_SIZE; idx++) { 63 | NvmMemory[idx] = 0xffu; 64 | } 65 | } 66 | 67 | static uint32_t DrvNvmRead(uint32_t start, uint8_t *buffer, uint32_t size) 68 | { 69 | uint32_t idx = 0; 70 | uint32_t pos; 71 | 72 | idx = 0; 73 | pos = start; 74 | while ((pos < NVM_SIM_SIZE) && (idx < size)) { 75 | buffer[idx] = NvmMemory[pos]; 76 | idx++; 77 | pos++; 78 | } 79 | 80 | return (idx); 81 | } 82 | 83 | static uint32_t DrvNvmWrite(uint32_t start, uint8_t *buffer, uint32_t size) 84 | { 85 | uint32_t idx = 0; 86 | uint32_t pos; 87 | 88 | idx = 0; 89 | pos = start; 90 | while ((pos < NVM_SIM_SIZE) && (idx < size)) { 91 | NvmMemory[pos] = buffer[idx]; 92 | idx++; 93 | pos++; 94 | } 95 | 96 | return (idx); 97 | } 98 | -------------------------------------------------------------------------------- /examples/dynamic-od/driver/drv_nvm_sim.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2020 Embedded Office GmbH & Co. KG 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ******************************************************************************/ 16 | 17 | /****************************************************************************** 18 | * INCLUDES 19 | ******************************************************************************/ 20 | 21 | #include "drv_nvm_sim.h" 22 | 23 | /****************************************************************************** 24 | * PRIVATE DEFINES 25 | ******************************************************************************/ 26 | 27 | #define NVM_SIM_SIZE 128 28 | 29 | /****************************************************************************** 30 | * PRIVATE VARIABLES 31 | ******************************************************************************/ 32 | 33 | static uint8_t NvmMemory[NVM_SIM_SIZE]; 34 | 35 | /****************************************************************************** 36 | * PRIVATE FUNCTIONS 37 | ******************************************************************************/ 38 | 39 | static void DrvNvmInit (void); 40 | static uint32_t DrvNvmRead (uint32_t start, uint8_t *buffer, uint32_t size); 41 | static uint32_t DrvNvmWrite (uint32_t start, uint8_t *buffer, uint32_t size); 42 | 43 | 44 | /****************************************************************************** 45 | * PUBLIC VARIABLE 46 | ******************************************************************************/ 47 | 48 | const CO_IF_NVM_DRV SimNvmDriver = { 49 | DrvNvmInit, 50 | DrvNvmRead, 51 | DrvNvmWrite 52 | }; 53 | 54 | /****************************************************************************** 55 | * PRIVATE FUNCTIONS 56 | ******************************************************************************/ 57 | 58 | static void DrvNvmInit(void) 59 | { 60 | uint32_t idx; 61 | 62 | for (idx = 0; idx < NVM_SIM_SIZE; idx++) { 63 | NvmMemory[idx] = 0xffu; 64 | } 65 | } 66 | 67 | static uint32_t DrvNvmRead(uint32_t start, uint8_t *buffer, uint32_t size) 68 | { 69 | uint32_t idx = 0; 70 | uint32_t pos; 71 | 72 | idx = 0; 73 | pos = start; 74 | while ((pos < NVM_SIM_SIZE) && (idx < size)) { 75 | buffer[idx] = NvmMemory[pos]; 76 | idx++; 77 | pos++; 78 | } 79 | 80 | return (idx); 81 | } 82 | 83 | static uint32_t DrvNvmWrite(uint32_t start, uint8_t *buffer, uint32_t size) 84 | { 85 | uint32_t idx = 0; 86 | uint32_t pos; 87 | 88 | idx = 0; 89 | pos = start; 90 | while ((pos < NVM_SIM_SIZE) && (idx < size)) { 91 | NvmMemory[pos] = buffer[idx]; 92 | idx++; 93 | pos++; 94 | } 95 | 96 | return (idx); 97 | } 98 | -------------------------------------------------------------------------------- /examples/quickstart/driver/drv_nvm_sim.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2020 Embedded Office GmbH & Co. KG 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ******************************************************************************/ 16 | 17 | /****************************************************************************** 18 | * INCLUDES 19 | ******************************************************************************/ 20 | 21 | #include "drv_nvm_sim.h" 22 | 23 | /****************************************************************************** 24 | * PRIVATE DEFINES 25 | ******************************************************************************/ 26 | 27 | #define NVM_SIM_SIZE 128 28 | 29 | /****************************************************************************** 30 | * PRIVATE VARIABLES 31 | ******************************************************************************/ 32 | 33 | static uint8_t NvmMemory[NVM_SIM_SIZE]; 34 | 35 | /****************************************************************************** 36 | * PRIVATE FUNCTIONS 37 | ******************************************************************************/ 38 | 39 | static void DrvNvmInit (void); 40 | static uint32_t DrvNvmRead (uint32_t start, uint8_t *buffer, uint32_t size); 41 | static uint32_t DrvNvmWrite (uint32_t start, uint8_t *buffer, uint32_t size); 42 | 43 | 44 | /****************************************************************************** 45 | * PUBLIC VARIABLE 46 | ******************************************************************************/ 47 | 48 | const CO_IF_NVM_DRV SimNvmDriver = { 49 | DrvNvmInit, 50 | DrvNvmRead, 51 | DrvNvmWrite 52 | }; 53 | 54 | /****************************************************************************** 55 | * PRIVATE FUNCTIONS 56 | ******************************************************************************/ 57 | 58 | static void DrvNvmInit(void) 59 | { 60 | uint32_t idx; 61 | 62 | for (idx = 0; idx < NVM_SIM_SIZE; idx++) { 63 | NvmMemory[idx] = 0xffu; 64 | } 65 | } 66 | 67 | static uint32_t DrvNvmRead(uint32_t start, uint8_t *buffer, uint32_t size) 68 | { 69 | uint32_t idx = 0; 70 | uint32_t pos; 71 | 72 | idx = 0; 73 | pos = start; 74 | while ((pos < NVM_SIM_SIZE) && (idx < size)) { 75 | buffer[idx] = NvmMemory[pos]; 76 | idx++; 77 | pos++; 78 | } 79 | 80 | return (idx); 81 | } 82 | 83 | static uint32_t DrvNvmWrite(uint32_t start, uint8_t *buffer, uint32_t size) 84 | { 85 | uint32_t idx = 0; 86 | uint32_t pos; 87 | 88 | idx = 0; 89 | pos = start; 90 | while ((pos < NVM_SIM_SIZE) && (idx < size)) { 91 | NvmMemory[pos] = buffer[idx]; 92 | idx++; 93 | pos++; 94 | } 95 | 96 | return (idx); 97 | } 98 | -------------------------------------------------------------------------------- /src/driver/_template/drv_timer_dummy.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2020 Embedded Office GmbH & Co. KG 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ******************************************************************************/ 16 | 17 | /****************************************************************************** 18 | * INCLUDES 19 | ******************************************************************************/ 20 | 21 | /* TODO: rename the include file name to match the naming convention: 22 | * co_timer_.h 23 | */ 24 | #include "co_timer_dummy.h" 25 | 26 | /****************************************************************************** 27 | * PRIVATE DEFINES 28 | ******************************************************************************/ 29 | 30 | /* TODO: place here your timer register definitions */ 31 | 32 | /****************************************************************************** 33 | * PRIVATE FUNCTIONS 34 | ******************************************************************************/ 35 | 36 | static void DrvTimerInit (uint32_t freq); 37 | static void DrvTimerStart (void); 38 | static uint8_t DrvTimerUpdate (void); 39 | static uint32_t DrvTimerDelay (void); 40 | static void DrvTimerReload (uint32_t reload); 41 | static void DrvTimerStop (void); 42 | 43 | /****************************************************************************** 44 | * PUBLIC VARIABLE 45 | ******************************************************************************/ 46 | 47 | /* TODO: rename the variable to match the naming convention: 48 | * TimerDriver 49 | */ 50 | const CO_IF_TIMER_DRV DummyTimerDriver = { 51 | DrvTimerInit, 52 | DrvTimerReload, 53 | DrvTimerDelay, 54 | DrvTimerStop, 55 | DrvTimerStart, 56 | DrvTimerUpdate 57 | }; 58 | 59 | /****************************************************************************** 60 | * PRIVATE FUNCTIONS 61 | ******************************************************************************/ 62 | 63 | static void DrvTimerInit(uint32_t freq) 64 | { 65 | (void)freq; 66 | 67 | /* TODO: initialize timer, clear counter and keep timer stopped */ 68 | } 69 | 70 | static void DrvTimerStart(void) 71 | { 72 | /* TODO: start hardware timer */ 73 | } 74 | 75 | static uint8_t DrvTimerUpdate(void) 76 | { 77 | /* TODO: return 1 if timer event is elapsed, otherwise 0 */ 78 | return (0u); 79 | } 80 | 81 | static uint32_t DrvTimerDelay(void) 82 | { 83 | /* TODO: return current timer counter value */ 84 | return (0u); 85 | } 86 | 87 | static void DrvTimerReload(uint32_t reload) 88 | { 89 | (void)reload; 90 | 91 | /* TODO: reload timer counter value with given reload value */ 92 | } 93 | 94 | static void DrvTimerStop(void) 95 | { 96 | /* TODO: stop timer and clear counter value */ 97 | } 98 | -------------------------------------------------------------------------------- /src/core/co_ver.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2020 Embedded Office GmbH & Co. KG 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ******************************************************************************/ 16 | 17 | #ifndef CO_VER_H_ 18 | #define CO_VER_H_ 19 | 20 | /****************************************************************************** 21 | * INCLUDES 22 | ******************************************************************************/ 23 | 24 | #include "co_types.h" 25 | 26 | /****************************************************************************** 27 | * DEFINES 28 | ******************************************************************************/ 29 | 30 | #define CO_VER_MAJOR 4 31 | #define CO_VER_MINOR 3 32 | #define CO_VER_BUILD 1 33 | 34 | /****************************************************************************** 35 | * PUBLIC FUNCTIONS 36 | ******************************************************************************/ 37 | 38 | #ifdef __cplusplus /* for compatibility with C++ environments */ 39 | extern "C" { 40 | #endif 41 | 42 | /*! \brief GET MAJOR VERSION VALUE 43 | * 44 | * This function returns the major version value of the encoded version 45 | * information: 46 | * 47 | * Version .. 48 | * 49 | * \return 50 | * The major version value. 51 | */ 52 | uint8_t COVerMajor(void); 53 | 54 | /*! \brief GET MINOR VERSION VALUE 55 | * 56 | * This function returns the minor version value of the encoded version 57 | * information: 58 | * 59 | * Version .. 60 | * 61 | * \return 62 | * The minor version value. 63 | */ 64 | uint8_t COVerMinor(void); 65 | 66 | /*! \brief GET BUILD VERSION VALUE 67 | * 68 | * This function returns the build version value of the encoded version 69 | * information: 70 | * 71 | * Version .. 72 | * 73 | * \return 74 | * The build version value. 75 | */ 76 | uint8_t COVerBuild(void); 77 | 78 | /*! \brief GET VERSION INFORMATION 79 | * 80 | * This function returns the compact version information of the encoded 81 | * version information: 82 | * 83 | * Version .. 84 | * 85 | * in the following way: 86 | * 87 | * Version Information = * 10000 + * 100 + 88 | * 89 | * For example the version 3.1.0 is encoded as decimal value: 30100. 90 | * 91 | * \return 92 | * The calculated version information value. 93 | */ 94 | uint32_t COVersion(void); 95 | 96 | /*! \brief INITIALIZE VERSION INFORMATIONS 97 | * 98 | * This function initializes the version information values in the local 99 | * version object. 100 | */ 101 | void CO_VerInit(void); 102 | 103 | #ifdef __cplusplus /* for compatibility with C++ environments */ 104 | } 105 | #endif 106 | 107 | #endif /* ifndef CO_VER_H_ */ 108 | -------------------------------------------------------------------------------- /tests/integration/app/app_emcy.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright 2020 Embedded Office GmbH & Co. KG 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ******************************************************************************/ 16 | 17 | /****************************************************************************** 18 | * INCLUDES 19 | ******************************************************************************/ 20 | 21 | #include "app_emcy.h" 22 | #include "app_env.h" 23 | 24 | /****************************************************************************** 25 | * PRIVATE VARIABLES 26 | ******************************************************************************/ 27 | 28 | /* allocate memory for the emergency code mapping table */ 29 | static CO_EMCY_TBL EmcyCode[EMCY_CODE_MAX]; 30 | /* allocate memory for the number of registered emergency codes */ 31 | static uint8_t EmcyNum; 32 | 33 | /****************************************************************************** 34 | * PUBLIC FUNCTIONS 35 | ******************************************************************************/ 36 | 37 | /*---------------------------------------------------------------------------*/ 38 | /*! \brief REQ-TEM-0100 39 | * 40 | * \details The test emergency code definition table is hold in RAM to get 41 | * most flexibility for tests. We initialise all emergency object 42 | * variables with 0 to operate like a powerup with BSS clearing. 43 | */ 44 | /*---------------------------------------------------------------------------*/ 45 | void EmcyResetTable(void) 46 | { 47 | uint32_t idx; 48 | 49 | for (idx = 0; idx < EMCY_CODE_MAX; idx++) { 50 | EmcyCode[idx].Code = 0; 51 | EmcyCode[idx].Reg = 0; 52 | } 53 | EmcyNum = 0; 54 | } 55 | 56 | /*---------------------------------------------------------------------------*/ 57 | /*! \brief REQ-TEM-0110 58 | * 59 | * \details Return the pointer to the first entry of the emergency map table. 60 | */ 61 | /*---------------------------------------------------------------------------*/ 62 | CO_EMCY_TBL *EmcyGetTable(void) 63 | { 64 | CO_EMCY_TBL *result = NULL; 65 | 66 | if (EmcyNum > 0) { 67 | result = &EmcyCode[0]; 68 | } 69 | return (result); 70 | } 71 | 72 | /*---------------------------------------------------------------------------*/ 73 | /*! \brief REQ-TEM-0120 74 | * 75 | * \details Fill the emergency map table from start to end without sorting. 76 | * If table is full, return the table size as indication. 77 | */ 78 | /*---------------------------------------------------------------------------*/ 79 | uint32_t EmcyAddCode(int16_t code, uint8_t reg) 80 | { 81 | uint32_t n; 82 | 83 | for (n = 0; n < EMCY_CODE_MAX; n++) { 84 | if (EmcyCode[n].Code == 0) { 85 | EmcyCode[n].Code = code; 86 | EmcyCode[n].Reg = reg; 87 | EmcyNum++; 88 | break; 89 | } 90 | } 91 | 92 | return (n); 93 | } 94 | --------------------------------------------------------------------------------