Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
Binary file added examples/.DS_Store
Binary file not shown.
Binary file added examples/unit-test/.DS_Store
Binary file not shown.
5 changes: 5 additions & 0 deletions examples/unit-test/mbed-blink/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.pioenvs
.clang_complete
.gcc-flags.json
.piolibdeps
.DS_Store
65 changes: 65 additions & 0 deletions examples/unit-test/mbed-blink/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Continuous Integration (CI) is the practice, in software
# engineering, of merging all developer working copies with a shared mainline
# several times a day < http://docs.platformio.org/en/stable/ci/index.html >
#
# Documentation:
#
# * Travis CI Embedded Builds with PlatformIO
# < https://docs.travis-ci.com/user/integration/platformio/ >
#
# * PlatformIO integration with Travis CI
# < http://docs.platformio.org/en/stable/ci/travis.html >
#
# * User Guide for `platformio ci` command
# < http://docs.platformio.org/en/stable/userguide/cmd_ci.html >
#
#
# Please choice one of the following templates (proposed below) and uncomment
# it (remove "# " before each line) or use own configuration according to the
# Travis CI documentation (see above).
#


#
# Template #1: General project. Test it using existing `platformio.ini`.
#

# language: python
# python:
# - "2.7"
#
# sudo: false
# cache:
# directories:
# - "~/.platformio"
#
# install:
# - pip install -U platformio
#
# script:
# - platformio run


#
# Template #2: The project is intended to by used as a library with examples
#

# language: python
# python:
# - "2.7"
#
# sudo: false
# cache:
# directories:
# - "~/.platformio"
#
# env:
# - PLATFORMIO_CI_SRC=path/to/test/file.c
# - PLATFORMIO_CI_SRC=examples/file.ino
# - PLATFORMIO_CI_SRC=path/to/test/directory
#
# install:
# - pip install -U platformio
#
# script:
# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N
36 changes: 36 additions & 0 deletions examples/unit-test/mbed-blink/lib/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@

This directory is intended for the project specific (private) libraries.
PlatformIO will compile them to static libraries and link to executable file.

The source code of each library should be placed in separate directory, like
"lib/private_lib/[here are source files]".

For example, see how can be organized `Foo` and `Bar` libraries:

|--lib
| |--Bar
| | |--docs
| | |--examples
| | |--src
| | |- Bar.c
| | |- Bar.h
| |--Foo
| | |- Foo.c
| | |- Foo.h
| |- readme.txt --> THIS FILE
|- platformio.ini
|--src
|- main.c

Then in `src/main.c` you should use:

#include <Foo.h>
#include <Bar.h>

// rest H/C/CPP code

PlatformIO will find your libraries automatically, configure preprocessor's
include paths and build them.

More information about PlatformIO Library Dependency Finder
- http://docs.platformio.org/en/stable/librarymanager/ldf.html
40 changes: 40 additions & 0 deletions examples/unit-test/mbed-blink/platformio.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# ; PlatformIO Project Configuration File
# ;
# ; Build options: build flags, source filter, extra scripting
# ; Upload options: custom port, speed and extra flags
# ; Library options: dependencies, extra library storages
# ;
# ; Please visit documentation for the other options and examples
# ; http://docs.platformio.org/en/stable/projectconf.html

[env:bluepill_f103c8]
platform = ststm32
board = bluepill_f103c8
framework = mbed
upload_protocol = gdb
#This is the built in Serial passthrough for the Blackmagic Probe
test_port = /dev/cu.usbmodemBFDEA5F3
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What to do with this port? I'm not sure that each bluepill_f103c8 board has "2 Serial Ports"

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ll comment about the test_port and push again.
and explain about the st-link

build_flags = -DSTM32F1

[env:nucleo_f030r8]
platform = ststm32
board = nucleo_f030r8
framework = mbed
upload_protocol = stlink
build_flags = -DSTM32F0
#This is a FT232 USB Serial Converter
test_port = /dev/cu.usbserial-A900ZD1K

#Run "pio device list" to get a list of available serial ports
#in the system. Connect the TX,RX to the RX,TX of USART1 in the target

#The build flags are specified to allow for conditional compilation
#of the program to allow for differences between different dev boards

#The STM32F030R8 discovery uses the Nucleo F030R8 template and
#specifies "stlink" as the upload protocol, removing the need for
#any external programmer

#Also need to correct the correct clock source and frequency
#in the STM32F030R8 discovery board. The program functions
#but blinks much faster than the specified 1 second delay
25 changes: 25 additions & 0 deletions examples/unit-test/mbed-blink/src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include "mbed.h"

#ifndef UNIT_TEST

/*The leds are connected to different port pins on the
bluepill F103C8 and Disco F030R8 boards
*/

#ifdef STM32F1
DigitalOut myled(PC_13);
#endif
#ifdef STM32F0
DigitalOut myled(PC_9);
#endif

int main(void)
{
while (1) {
myled = 1;
wait(1);
myled = 0;
wait(1);
}
}
#endif
41 changes: 41 additions & 0 deletions examples/unit-test/mbed-blink/test/test_main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#include "mbed.h"
#include "unity.h"

#ifdef UNIT_TEST

#ifdef STM32F1
DigitalOut myled(PC_13);
#endif
#ifdef STM32F0
DigitalOut myled(PC_9);
#endif


void test_led_write_high(void)
{
myled.write(1);
TEST_ASSERT_EQUAL(myled.read(), 1);
}

void test_led_write_low(void)
{
myled.write(0);
TEST_ASSERT_EQUAL(myled.read(), 0);
}

int main(void)
{
UNITY_BEGIN();

wait(1);
// Without the above delay, the console does not print the PASS/FAIL message
// for the first couple of unit tests
RUN_TEST(test_led_write_high);
wait(0.5);
RUN_TEST(test_led_write_low);
wait(0.5);
UNITY_END();
}


#endif
6 changes: 6 additions & 0 deletions examples/unit-test/mbed-blink/upload.gdb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
target extended-remote /dev/cu.usbmodemBFDEA5F1
monitor swdp_scan
attach 1
load
quit
yes