This commit is contained in:
Joe Finney 2015-08-19 23:48:36 +01:00
commit 42f43b2255
8 changed files with 125 additions and 10 deletions

72
README.md Normal file
View file

@ -0,0 +1,72 @@
# microbit-dal
## Building a project for the micro:bit using Yotta
Instead of using the online IDE, Yotta can be used to provide an equivalent offline experience. The current compilers that are available are:
* GCC
* ARMCC
## Getting Started
### 1. Install Yotta
The first step is to get Yotta onto your machine, to do this follow the install guide [here](http://docs.yottabuild.org/#installing)
**Note: if you are on windows, dependencies will be missed as of 8/8/15, please use the helper script located [here](https://github.com/ARMmbed/yotta/blob/master/get_yotta.py).**
### 2. Fetch the example project
If your install has gone correctly, and you have all dependencies installed, the next step is to fetch the example project using the runtime from GitHub.
```
git clone https://github.com/lancaster-university/microbit
```
**Note: To successfully build this project you will need access to the microbit-dal private repository, if you need access please email me at j.devine@lancaster.ac.uk.**
### 3. Try to build
Building rarely works first time due to dependencies currently not being installed by Yotta, so the next step is to **try** to build.
The default yotta target you will receive when you pull the aforementioned repo is bbc-microbit-classic-armcc, you can use the following command to print your current target in Yotta:
```
yt target
bbc-microbit-classic-armcc 0.0.5
mbed-armcc 0.0.8
```
If you do not have armcc installed (or don't have a license for Keil), then you will need to use GCC. To swap to the GCC target run:
```
yt target bbc-microbit-classic-gcc
```
Then you should **try** to build using the following command:
```
yt build
```
For GCC, you will have to swap the CortexContextSwitch.s file with the file CortexContextSwitch.s.gcc which will be located in `/yotta_modules/microbit-dal/source`. For an example of how to do this, look below:
```
#first rename the existing one
mv yotta_modules/microbit-dal/source/CortexContextSwitch.s yotta_modules/microbit-dal/source/CortexContextSwitch.s.armcc
#then rename gcc version so that it is included by cmake
mv yotta_modules/microbit-dal/source/CortexContextSwitch.s.gcc yotta_modules/microbit-dal/source/CortexContextSwitch.s
```
This is a temporary measure until Yotta supports assembly preprocessing for armcc.
**NOTE:
To build the final hex files for the micro:bit, you will need to install the srec which can be installed via brew (`brew install srecord`), or you can install it manually from [here](http://srecord.sourceforge.net/).**
### 4. Flash your micro:bit
The final step is to check your hex works.
The yotta build command will place files in `/build/<TARGET_NAME>/source`. The file you will need to flash will be microbit-combined.hex. Simply drag and drop the hex.
The expected result will be that the micro:bit will scroll `BELLO! :)` on its display.

View file

@ -80,6 +80,9 @@ public:
*/
int getReferences();
T* operator->() {
return object;
}
};
/**

View file

@ -5,7 +5,11 @@
//#define MICROBIT_DBG
#include "mbed.h"
#ifndef NO_BLE
#include "ble/BLE.h"
#endif
#include "ble/services/DeviceInformationService.h"
//error number enumeration
@ -17,6 +21,9 @@
*/
void panic(int statusCode);
void reset(int statusCode);
#include "MicroBitMalloc.h"
#include "MicroBitCompat.h"
#include "MicroBitFiber.h"
@ -183,6 +190,16 @@ class MicroBit
*/
void init();
/**
* Will reset the micro:bit when called.
*
* Example:
* @code
* uBit.reset();
* @endcode
*/
void reset();
/**
* Delay for the given amount of time.
* If the scheduler is running, this will deschedule the current fiber and perform

View file

@ -61,7 +61,6 @@ class MicroBitPin : public MicroBitComponent
*/
void *pin; // The mBed object looking after this pin at any point in time (may change!).
PinName name; // mBed pin name of this pin.
PinCapability capability;
/**
@ -71,6 +70,7 @@ class MicroBitPin : public MicroBitComponent
void disconnect();
public:
PinName name; // mBed pin name of this pin.
/**
* Constructor.

View file

@ -5,13 +5,13 @@
"description": "The runtime library for the BBC micro:bit, developed by Lancaster University",
"keywords": ["mbed-classic", "microbit", "runtime", "library", "lancaster", "University"],
"author": "James Devine <j.devine@lancaster.ac.uk (mailto:j.devine@lancaster.ac.uk) >",
"homepage": "https://jamesadevine@developer.mbed.org/teams/Lancaster-University/code/microbit/",
"homepage": "https://developer.mbed.org/teams/Lancaster-University/code/microbit/",
"dependencies":{
"mbed-classic": "~0.0.4",
"ble": "jamesadevine/BLE_API#master",
"ble-nrf51822": "jamesadevine/nrf51822#master"
"ble": "lancaster-university/BLE_API#master",
"ble-nrf51822": "lancaster-university/nrf51822#master"
},
"extraIncludes":[
"inc"
]
}
}

View file

@ -24,7 +24,6 @@ void bleDisconnectionCallback(Gap::Handle_t handle, Gap::DisconnectionReason_t r
uBit.ble->startAdvertising(); // restart advertising!
}
/**
* Constructor.
* Create a representation of a MicroBit device as a global singleton.
@ -89,6 +88,7 @@ void MicroBit::init()
// Seed our random number generator
seedRandom();
#ifndef NO_BLE
// Start the BLE stack.
ble = new BLEDevice();
@ -109,11 +109,30 @@ void MicroBit::init()
ble->setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED);
ble->setAdvertisingInterval(Gap::MSEC_TO_ADVERTISEMENT_DURATION_UNITS(1000));
ble->startAdvertising();
#else
ble = NULL;
ble_firmware_update_service = NULL;
ble_device_information_service = NULL;
ble_event_service = NULL;
#endif
// Start refreshing the Matrix Display
systemTicker.attach(this, &MicroBit::systemTick, MICROBIT_DISPLAY_REFRESH_PERIOD);
}
/**
* Will reset the micro:bit when called.
*
* Example:
* @code
* uBit.reset();
* @endcode
*/
void MicroBit::reset()
{
reset();
}
/**
* Delay for the given amount of time.
* If the scheduler is running, this will deschedule the current fiber and perform

View file

@ -232,8 +232,10 @@ MicroBitDisplay::animationUpdate()
this->updateAnimateImage();
if(animationMode == ANIMATION_MODE_PRINT_CHARACTER)
{
animationMode = ANIMATION_MODE_NONE;
this->sendEvent(MICROBIT_DISPLAY_EVT_ANIMATION_COMPLETE);
}
}
}

View file

@ -8,7 +8,7 @@ MicroBit uBit;
InterruptIn resetButton(MICROBIT_PIN_BUTTON_RESET);
void
onResetButtonPressed()
reset()
{
NVIC_SystemReset();
}
@ -17,7 +17,7 @@ int main()
{
// Bring up soft reset button.
resetButton.mode(PullUp);
resetButton.fall(onResetButtonPressed);
resetButton.fall(reset);
#ifdef MICROBIT_DBG
pc.baud(115200);
@ -54,7 +54,8 @@ int main()
uBit.init();
uBit.sleep(100);
#ifndef NO_BLE
// Test if we need to enter BLE pairing mode...
int i=0;
while (uBit.buttonA.isPressed() && uBit.buttonB.isPressed() && i<10)
@ -65,6 +66,7 @@ int main()
if (i == 10 && uBit.ble_firmware_update_service != NULL)
uBit.ble_firmware_update_service->pair();
}
#endif
app_main();