5c2c8ec3c4
- Config for devcontainer - Config for git to ignore crlf change if on windows |
||
---|---|---|
.devcontainer | ||
.vscode | ||
source | ||
.gitattributes | ||
.gitignore | ||
.yotta.json | ||
.yotta_ignore | ||
debugOnVisualStudioCode.gif | ||
LICENSE | ||
Makefile | ||
module.json | ||
README.md |
microbit-samples
A collection of example programs using the micro:bit runtime.
The source/examples folder contains a selection of samples demonstrating the capabilities and usage of the runtime APIs. To select a sample, simply copy the .cpp files from the relevant folder into the source/ folder.
e.g. to select the "invaders" example:
cp source/examples/invaders/* source
and then to compile your sample:
yt clean
yt build
The HEX file for you micro:bit with then be generated and stored in build\bbc-microbit-classic-gcc\source\microbit-samples-combined.hex
n.b. Any samples using the low level RADIO APIs (such as simple-radio-rx and simple-radio-tx) require the bluetooth capabilities of the micro:bit to be disabled. To do this, simply copy the config.json file from the sample to the top level of your project. Don't forget to remove this file again later if you then want to use Bluetooth! For example:
cp source/examples/simple-radio-rx/config.json .
Overview
The micro:bit runtime provides an easy to use environment for programming the BBC micro:bit in the C/C++ language, written by Lancaster University. It contains device drivers for all the hardware capabilities of the micro:bit, and also a suite of runtime mechanisms to make programming the micro:bit easier and more flexible. These range from control of the LED matrix display to peer-to-peer radio communication and secure Bluetooth Low Energy services. The micro:bit runtime is proudly built on the ARM mbed and Nordic nrf51 platforms.
In addition to supporting development in C/C++, the runtime is also designed specifically to support higher level languages provided by our partners that target the micro:bit. It is currently used as a support library for all the languages on the BBC www.microbit.co.uk website, including Microsoft Block, Microsoft TouchDevelop, Code Kingdoms JavaScript and Micropython languages.
Links
micro:bit runtime docs | microbit-dal | uBit
Build Environments
Build Environment | Documentation |
---|---|
ARM mbed online | http://lancaster-university.github.io/microbit-docs/online-toolchains/#mbed |
yotta | http://lancaster-university.github.io/microbit-docs/offline-toolchains/#yotta |
microbit-dal Configuration
The DAL also contains a number of compile time options can be modified. A full list and explanation can be found in our documentation.
Alternately, yotta
can be used to configure the dal regardless of module/folder structure, through providing a
config.json
in this directory.
Here is an example of config.json
with all available options configured:
{
"microbit-dal":{
"bluetooth":{
"enabled": 1,
"pairing_mode": 1,
"private_addressing": 0,
"open": 0,
"whitelist": 1,
"advertising_timeout": 0,
"tx_power": 0,
"dfu_service": 1,
"event_service": 1,
"device_info_service": 1
},
"reuse_sd": 1,
"default_pullmode":"PullDown",
"gatt_table_size": "0x300",
"heap_allocator": 1,
"nested_heap_proportion": 0.75,
"system_tick_period": 6,
"system_components": 10,
"idle_components": 6,
"use_accel_lsb": 0,
"min_display_brightness": 1,
"max_display_brightness": 255,
"display_scroll_speed": 120,
"display_scroll_stride": -1,
"display_print_speed": 400,
"panic_on_heap_full": 1,
"debug": 0,
"heap_debug": 0,
"stack_size":2048,
"sram_base":"0x20000008",
"sram_end":"0x20004000",
"sd_limit":"0x20002000",
"gatt_table_start":"0x20001900"
"radio_max_packet_size":248,
"radio_max_rx_buffers":4
}
}
Debug on Visual Studio Code (Windows)
- build sample. You can build "HELLO WORLD! :)" program.
- Copy microbit-samples\build\bbc-microbit-classic-gcc\source\microbit-samples-combined.hex to micro:bit.
- Launch the Visual Studio Code
- File -> Open Folder... and select "microbit-samples" folder.
- Set break point to "main()" function.
- View -> Debug (Ctrl + Shift + D)
- Debug -> Start Debugging (F5)