Wim Huiskamp
/
mbed_nucleo_swo
Test for SWO viewer library.
See here for more information.
flip.cpp@3:3d2422feccb5, 2017-08-24 (annotated)
- Committer:
- wim
- Date:
- Thu Aug 24 18:16:36 2017 +0000
- Revision:
- 3:3d2422feccb5
Added stream claim demo for stdout, proposed by Pavel Sorejs. Added example of SWO in a function other than main.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
wim | 3:3d2422feccb5 | 1 | /* mbed SWO Library |
wim | 3:3d2422feccb5 | 2 | * Copyright (c) 2017, v01: WH. External declared swo |
wim | 3:3d2422feccb5 | 3 | * |
wim | 3:3d2422feccb5 | 4 | * Simple implementation for tracing via Serial Wire Output(SWO) for Cortex-M processors. |
wim | 3:3d2422feccb5 | 5 | * It can be used with Host PC software such as ST-LINK Utility or Segger J-Link SWO viewer. |
wim | 3:3d2422feccb5 | 6 | * This sample implementation ensures that output via SWO is enabled in order to guarantee |
wim | 3:3d2422feccb5 | 7 | * that the application does not hang. |
wim | 3:3d2422feccb5 | 8 | * |
wim | 3:3d2422feccb5 | 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
wim | 3:3d2422feccb5 | 10 | * of this software and associated documentation files (the "Software"), to deal |
wim | 3:3d2422feccb5 | 11 | * in the Software without restriction, including without limitation the rights |
wim | 3:3d2422feccb5 | 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
wim | 3:3d2422feccb5 | 13 | * copies of the Software, and to permit persons to whom the Software is |
wim | 3:3d2422feccb5 | 14 | * furnished to do so, subject to the following conditions: |
wim | 3:3d2422feccb5 | 15 | * |
wim | 3:3d2422feccb5 | 16 | * The above copyright notice and this permission notice shall be included in |
wim | 3:3d2422feccb5 | 17 | * all copies or substantial portions of the Software. |
wim | 3:3d2422feccb5 | 18 | * |
wim | 3:3d2422feccb5 | 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
wim | 3:3d2422feccb5 | 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
wim | 3:3d2422feccb5 | 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
wim | 3:3d2422feccb5 | 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
wim | 3:3d2422feccb5 | 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
wim | 3:3d2422feccb5 | 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
wim | 3:3d2422feccb5 | 25 | * THE SOFTWARE. |
wim | 3:3d2422feccb5 | 26 | */ |
wim | 3:3d2422feccb5 | 27 | |
wim | 3:3d2422feccb5 | 28 | #include "mbed.h" |
wim | 3:3d2422feccb5 | 29 | #include "flip.h" |
wim | 3:3d2422feccb5 | 30 | #include "SWO.h" |
wim | 3:3d2422feccb5 | 31 | |
wim | 3:3d2422feccb5 | 32 | extern SWO_Channel swo; |
wim | 3:3d2422feccb5 | 33 | |
wim | 3:3d2422feccb5 | 34 | /** |
wim | 3:3d2422feccb5 | 35 | * flip() |
wim | 3:3d2422feccb5 | 36 | * |
wim | 3:3d2422feccb5 | 37 | * @brief invert value and print a string via SWO. |
wim | 3:3d2422feccb5 | 38 | * @param int value The value to be printed. |
wim | 3:3d2422feccb5 | 39 | */ |
wim | 3:3d2422feccb5 | 40 | int flip(int value) { |
wim | 3:3d2422feccb5 | 41 | swo.printf(" value=%d\n\r", value); |
wim | 3:3d2422feccb5 | 42 | return -value; |
wim | 3:3d2422feccb5 | 43 | } |