Skip to content

Commit 02503d4

Browse files
chore(Documentation): Update for merge with main and address review feedback
Theme and Dependencies: - Update adi-mkdocs-harmonic to v0.7.1 (latest stable release) - Update pymdown-extensions requirement for compatibility Content Updates: - Add Unity Test Framework documentation to libraries.md - Ported from PR #1033 which was merged to main after original PR #1257 - Includes on-target testing and host machine testing examples - Documents test build target and FreeRTOS integration Link Fixes: - Fix broken anchor link in libraries.md (visual-studio-code.md reference) - Fix relative path in CONTRIBUTING.md (user-guide/index.md) - Change from Documentation/user-guide/index.md to user-guide/index.md (path is relative to Documentation folder after build.py copies it) Address Original PR #1257 Review Feedback: - Remove redundant 'typical' wording in getting-started.md development cycle - Changed 'The typical development cycle typically' to 'The development cycle typically' - Update Windows support from 'Windows 10 only' to 'Windows 10 and later' - Reflects current MSDK Windows 11 compatibility - Remove proprietary licensing statement from mkdocs.yml copyright line - Deleted 'This software is proprietary to Analog Devices, Inc. and its licensors.' - Aligns with MSDK's permissive licensing Cleanup: - Remove accidentally committed .DS_Store files (macOS system files) These changes ensure the resurrected PR builds cleanly, includes content added to main since Nov 2024, and addresses all review feedback from the original PR.
1 parent 815bbd9 commit 02503d4

6 files changed

Lines changed: 140 additions & 6 deletions

File tree

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ DoxyGen is automatically run across the MSDK code as part of the User Guide's bu
257257

258258
### User Guide
259259

260-
The [MSDK User Guide](Documentation/user-guide/index.md) is maintained in the `Documentation/user-guide` folder. This document contains higher-level usage info for the MSDK. If a part, IDE, or library is supported by the MSDK then there should be some relevant info in the User Guide covering its setup, configuration, and usage.
260+
The [MSDK User Guide](user-guide/index.md) is maintained in the `Documentation/user-guide` folder. This document contains higher-level usage info for the MSDK. If a part, IDE, or library is supported by the MSDK then there should be some relevant info in the User Guide covering its setup, configuration, and usage.
261261

262262
When writing markdown links, relative paths should always be used. Additionally, links to local files on the user's filesystem **cannot** be used, since the online copy of the docs will throw a 404 on them. See [Writing Your Docs](https://www.mkdocs.org/user-guide/writing-your-docs/) for more details.
263263

Documentation/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
mkdocs >= 1.4.2
2-
adi-mkdocs-harmonic >= 0.7.0
2+
adi-mkdocs-harmonic == 0.7.1
33
pymdown-extensions>=10.0.1

Documentation/user-guide/getting-started.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Getting Started
2-
3-
The MSDK is designed for both evaluation and end-application development. The typical **evaluation** cycle usually involves setting up the development environment, running demos, and exercising the peripheral driver API on an _evaluation platform_. The typical **development** cycle typically involves building a prototype application on an _evaluation platform_ first, then porting the application to a custom board. This section describes how to get started with the MSDK focusing on the _evaluation_ cycle.
2+
The MSDK is designed for both evaluation and end-application development. The typical **evaluation** cycle usually involves setting up the development environment, running demos, and exercising the peripheral driver API on an _evaluation platform_. The **development** cycle typically involves building a prototype application on an _evaluation platform_ first, then porting the application to a custom board. This section describes how to get started with the MSDK focusing on the _evaluation_ cycle.
43

54
**First**, review the [**Key Concepts**](#key-concepts) below. Then proceed to the section for your preferred IDE. Each subsection is a self-contained quick-start that includes links to additional documentation on important topics.
65

Documentation/user-guide/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This document describes the MSDK's installation, setup, and usage.
88

99
## Supported Operating Systems
1010

11-
* Windows (Windows 10 only)
11+
* Windows (Windows 10 and later)
1212

1313
* Linux (Ubuntu only)
1414

Documentation/user-guide/libraries.md

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,3 +242,138 @@ All parts in the MSDK support the Coremark library via a `Coremark` example appl
242242

243243
???+ note "ℹ️ **Note**"
244244
The source code of the `Coremark` examples are somewhat unique. They only contain a `core_portme.c`/`core_portme.h`. These files are provided by CoreMark libraries to give the MSDK an implementation layer for a few hardware-dependent functions. Otherwise, the remainder of the source code (located in `Libraries/Coremark`) must remain unmodified to comply with the CoreMark rules.
245+
246+
## Unity Test Framework
247+
248+
The [Unity Test Project](https://github.com/ThrowTheSwitch/Unity) is a simple unit testing framework for C. It can be used to run hardware-in-the-loop tests on MSDK microcontrollers, as well as more individual unit tests compiled and run on a developer's host machine to test less hardware-dependent software abstractions.
249+
250+
See [Build Variables for Toggling Libraries](build-system.md#build-variables-for-toggling-libraries) for instructions on enabling the Unity Test framework.
251+
252+
### Unity Test Supported Parts
253+
254+
- All
255+
256+
### Running Tests on a Target Micro
257+
258+
The following code snippet shows how a simple sequence of tests might be run on a target microcontroller using the Unity test library. Once unity is [enabled](build-system.md#build-variables-for-toggling-libraries), including the `"unity.h"` header file grants access to useful assertions and macros. The project can then be [built and run](visual-studio-code.md#flash-run) like any other MSDK project.
259+
260+
```C
261+
#include "unity.h"
262+
263+
// *****************************************************************************
264+
int main(void)
265+
{
266+
UnityBegin(__FILE__);
267+
268+
Unity.NumberOfTests++;
269+
TEST_ASSERT_EQUAL(1 + 1, 2);
270+
271+
Unity.NumberOfTests++;
272+
TEST_ASSERT_NOT_EQUAL(1 + 1, 0);
273+
274+
return (UnityEnd());
275+
}
276+
```
277+
278+
The results of the test will be sent to the microcontroller's serial console output (defined by `CONSOLE_UART` in the [BSP](board-support-pkgs.md)), and can be viewed from a serial terminal.
279+
280+
```serial
281+
-----------------------
282+
2 Tests 0 Failures 0 Ignored
283+
OK
284+
```
285+
286+
For a more comprehensive list of available assertions see the [Unity Assertions Documentation](https://github.com/ThrowTheSwitch/Unity/blob/master/docs/UnityAssertionsReference.md).
287+
288+
### Running Tests on a Host Machine
289+
290+
When the Unity Test framework is enabled, a new build target `test` becomes available. When `make test` is run, it compiles the source code in the `test` sub-folder of the current project into a single binary that will run on the developer's host PC. The test results are printed to the screen and a non-zero return code is passed to the host process in the case of any failures. Currently, the tools are set up to do this with GCC.
291+
292+
This is useful for developing unit-level testing for more abstract software.
293+
294+
For example, assume there is a simple function for adding two `uint8_t` in the current project that we would like to unit test.
295+
296+
```C
297+
// simple_code.c
298+
#include <stdint.h>
299+
300+
uint8_t simple_add(uint8_t x, uint8_t y)
301+
{
302+
return x + y;
303+
}
304+
```
305+
306+
In the `test` folder of our project, we can implement the following tests in a file called `test_functions.c`
307+
308+
```C
309+
// test/test_functions.c
310+
#include <stdint.h>
311+
#include "unity.h"
312+
313+
// Adding an 'extern' declaration of the function to test gets this file access to it
314+
extern uint8_t simple_add(uint8_t x, uint8_t y);
315+
316+
// Utility functions for unit testing setup/clean-up. Empty for this simple example.
317+
void setUp(void) {}
318+
void tearDown(void) {}
319+
320+
// Validate that 'simple_add' 3+4 == 7
321+
void test_simple_add_ok(void)
322+
{
323+
TEST_ASSERT_EQUAL(7, simple_add(3, 4));
324+
}
325+
326+
// Check if 'simple_add' 3+4 == -1
327+
// In this case, we expect this to fail since we are using uint8_t
328+
void test_simple_add_fail(void)
329+
{
330+
TEST_ASSERT_EQUAL(-1, simple_add(3, -4));
331+
}
332+
```
333+
334+
A top-level `main` function for driving these test functions also needs to be written. Unity features scripts for generating these top-level functions automagically (see the [Unity Helper Scripts Guide](https://github.com/ThrowTheSwitch/Unity/blob/master/docs/UnityHelperScriptsGuide.md)), or they can be written manually. For this example, the output of the helper script looks as follows and is saved to the `test/test_runner.c` file.
335+
336+
```C
337+
// test/test_runner.c
338+
// Test runner code
339+
// Header files
340+
#include "unity.h"
341+
342+
// Test functions
343+
extern void test_simple_add_ok(void);
344+
extern void test_simple_add_fail(void);
345+
346+
// Main function
347+
int main(void)
348+
{
349+
UnityBegin(__FILE__);
350+
351+
RUN_TEST(test_simple_add_ok);
352+
RUN_TEST(test_simple_add_fail);
353+
354+
return (UnityEnd());
355+
}
356+
```
357+
358+
The test plan above can then be run on the developer's host PC with:
359+
360+
```console
361+
$ make test
362+
363+
>> host pc gcc output here <<
364+
365+
running tests...
366+
test/test_runner.c:12:test_simple_add_ok:PASS
367+
test/test_runner.c:13:test_simple_add_fail:FAIL: Expected -1 Was 255
368+
369+
-----------------------
370+
2 Tests 1 Failures 0 Ignored
371+
FAIL
372+
373+
>> ...and returns error code <<
374+
```
375+
376+
Notice that the test returned a failure code as we expected (since the second test was intentionally broken to illustrate a unit test failure).
377+
378+
???+ note "ℹ️ **Note**"
379+
The test feature requires an OS-layer abstraction that provides functions like `malloc` and `free`. By default, the test feature will attempt to use the [FreeRTOS](#freertos) OS layer if it's available. Otherwise, it will use NewLib's implementation. Custom OS layers can be implemented, but are currently outside the scope of this document.

mkdocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
site_name: Analog Devices MSDK Documentation
22
site_author: Analog Devices, Inc.
3-
copyright: 'Copyright (C) 2022-2023 Maxim Integrated Products, Inc. All Rights Reserved. (now owned by Analog Devices, Inc.), Copyright (C) 2023-2024 Analog Devices, Inc. All Rights Reserved. This software is proprietary to Analog Devices, Inc. and its licensors.'
3+
copyright: 'Copyright (C) 2022-2023 Maxim Integrated Products, Inc. All Rights Reserved. (now owned by Analog Devices, Inc.), Copyright (C) 2023-2024 Analog Devices, Inc. All Rights Reserved.'
44
repo_url: https://github.com/analogdevicesinc/msdk
55
docs_dir: 'Documentation'
66
site_dir: 'docs'

0 commit comments

Comments
 (0)