Closed OwenBrotherwood closed 7 years ago
works with this:
include "mbed.h"
/*
- All the LEDs on the micro:bit are part of the LED Matrix,
- In order to get simple blinking behaviour, we set column 0
- to be permanently at ground. If you want to use the LEDs as
- a screen, there is a display driver in the micro:bit 'DAL', */ DigitalOut col0(P0_4, 0);
DigitalOut myled(P0_13);
int main() { while(1) { myled = 1; wait(0.2); myled = 0; wait(0.2); } }
oops: I have to make a change to define target as micro:bit with possible include's for defining which led(s) are used as different for microbit and nrf52_dk
config.vm.provision "shell", inline: <<-SHELL
apt-get -y update \
&& apt-get -y upgrade \
&& apt-get -y install \
cmake gcc-arm-none-eabi python-pip
pip install --upgrade pip \
&& pip install mbed-cli \
&& mbed import mbed-os-example-blinky \
&& chown -R ubuntu mbed-os-example-blinky \
&& cd mbed-os-example-blinky \
&& mbed compile -t GCC_ARM -m NRF51_MICROBIT \
&& mbed compile -t GCC_ARM -m NRF52_DK
SHELL
I do a full test with micro:bit and nrf52DK and put the completed work "here" with ram usage for both as a start point in relation to https://github.com/lancaster-university/microbit-dal/issues/224
I have to have one main.cpp that contains logic for the blinky micro:bit
DigitalOut col0(P0_4, 0);
DigitalOut myled(P0_13);
int main() {
while(1) {
myled = 1;
wait(0.2);
myled = 0;
wait(0.2);
}
}
Standard mbed blinky
#include "mbed.h"
DigitalOut led1(LED1);
// main() runs in its own thread in the OS
// (note the calls to wait below for delays)
int main() {
while (true) {
led1 = !led1;
wait(0.5);
}
}
and ensure the correct led1 is used with nfc52 dk
micro:bit
#include "mbed.h"
DigitalOut col0(P0_4, 0);
DigitalOut myled(P0_13);
int main() {
while(1) {
myled = 1;
wait(0.2);
myled = 0;
wait(0.2);
}
}
Compile [100.0%]: main.cpp
Link: mbed-os-example-blinky
Elf2Bin: mbed-os-example-blinky
+-----------------------+-------+-------+------+
| Module | .text | .data | .bss |
+-----------------------+-------+-------+------+
| Fill | 65 | 0 | 20 |
| Misc | 8456 | 116 | 88 |
| drivers | 347 | 0 | 0 |
| features/FEATURE_BLE | 757 | 4 | 73 |
| hal | 460 | 0 | 8 |
| platform | 1085 | 4 | 264 |
| rtos | 46 | 4 | 4 |
| rtos/rtx | 5271 | 20 | 3074 |
| targets/TARGET_NORDIC | 2754 | 8 | 209 |
| Subtotals | 19241 | 156 | 3740 |
+-----------------------+-------+-------+------+
Allocated Heap: 2240 bytes
Allocated Stack: 2048 bytes
Total Static RAM memory (data + bss): 3896 bytes
Total RAM memory (data + bss + heap + stack): 8184 bytes
Total Flash memory (text + data + misc): 19397 bytes
Object file sleep.o is not unique! It could be made from: ./mbed-os/features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/hal_patch/sleep.c ./mbed-os/targets/TARGET_NORDIC/TARGET_MCU_NRF51822/sleep.c
Object file test_env.o is not unique! It could be made from: ./mbed-os/features/frameworks/greentea-client/source/test_env.cpp /home/ubuntu/mbed-os-example-blinky/mbed-os/features/unsupported/tests/mbed/env/test_env.cpp
Image: ./BUILD/NRF51_MICROBIT/GCC_ARM/mbed-os-example-blinky.hex
The vagrant seem ok At some stage, I will see what main.cpp should be to provide a reference build of the two platforms
not fully tested but a basic one main.cpp for both platforms i have not found a target definition for NRF52_DK so it is assumed
#include "mbed.h"
#if defined(TARGET_NRF51_MICROBIT)
DigitalOut col0(P0_4, 0);
DigitalOut myled(P0_13);
#else
DigitalOut myled(P0_17);
#endif
int main() {
while(1) {
myled = 1;
wait(0.2);
myled = 0;
wait(0.2);
}
}
Testing:
#include "mbed.h"
#if defined(TARGET_NRF51_MICROBIT)
DigitalOut col0(P0_4, 0);
DigitalOut myled(P0_13);
#else if defined(TARGET_NRF52_DK)
DigitalOut myled(P0_17);
#endif
int main() {
while(1) {
myled = 1;
wait(0.2);
myled = 0;
wait(0.2);
}
}
was unable to repeat sucess: hmmm :(
status is I cannot confirm the programming of the micro:bit with the main.cc but as such, nfr52-DK works so I would suggest it comes in now.
the micro:bit is something to be worked on
Again, check to see what you think. Note that as yet I have not had a sucessful hex program of micro:bit as I have concentrated on quickly making this that and the other