Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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.
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
15 changes: 15 additions & 0 deletions examples/unit-test/mbed-blink/platformio.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# ; 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
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

15 changes: 15 additions & 0 deletions examples/unit-test/mbed-blink/src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "mbed.h"

#ifndef UNIT_TEST
DigitalOut myled(PC_13);

int main(void)
{
while (1) {
myled = 1;
wait(1);
myled = 0;
wait(1);
}
}
#endif
34 changes: 34 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,34 @@
#include "mbed.h"
#include "unity.h"

#ifdef UNIT_TEST
DigitalOut myled(PC_13);

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