Commit Graph

57 Commits

Author SHA1 Message Date
Michal Moskal 9330b401d5 Move RefCounted class to a separate file 2015-10-24 20:30:15 -07:00
Michal Moskal 5a10bda561 First stab at more memory efficient strings 2015-10-24 19:34:04 -07:00
Michal Moskal 057158c9f3 Cache getSerial(); otherwise BLE information device initalization may crash 2015-10-24 19:28:36 -07:00
Joe Finney 613f524bab microbit: BUGFIX: micro:bit not entering BLUEZONE mode cleanly
Fixed bug in GAP advertisement configuration.
2015-10-19 14:42:13 +01:00
Joe Finney 80f79f7faf Merge branch 'master' into ble-profile
Conflicts:
	source/CMakeLists.txt
	source/MicroBit.cpp
	source/MicroBitFiber.cpp
	source/MicroBitMessageBus.cpp
	source/MicroBitSuperMain.cpp
2015-10-18 17:54:37 +01:00
Joe Finney db3eccf6ff microbit: Final updates to BLE profile
Minor changes to BLE profile services (cleanup prior to merge with master branch):

  - Added temperature period characteristic to match design pattern of other sensors.
  - Updated endinaness of MicroBitLEDService Matrix to be more intuitive.
  - Cleaned up Microbit.cpp by removing unused reference to BLE services.
  - Exposed serial number and naming information thr BLE DeviceInformation and API.
  - Updated BLE advertisement period to be alightly more repsonsive (200ms vs 1000ms).
  - BUGFIX: micro:bit name is now always generated, regardless of BLE services.
  - BUGFIX: Scroll Period data length.
2015-10-18 14:46:42 +01:00
Joe Finney 068822ff12 Merge branch 'matrix-point-optimisation' of https://github.com/dpgeorge/microbit-dal into dpgeorge-matrix-point-optimisation 2015-10-14 09:38:13 +01:00
Joe Finney 2011886e64 microbot: Cleanup of #ifdef in MicroBitHeapAllocator
Removed compiler warning if MICROBIT_HEAP_REUSE_SD is not defined.
2015-10-09 16:58:10 +01:00
Joe Finney 6764c732ea microbit: BUGFIX to MicroBtDFU Service
- Updates to UI handling to avoid starving out the processor.
  - Clears screen before entering DFU bootloader
2015-10-09 01:14:36 +01:00
Joe Finney 122d885ee8 microbit: Updated Bluetooth device name from MicroBit to micro:bit to match brand guidelines 2015-10-09 00:03:01 +01:00
Joe Finney ce2cc57bf1 microbit: Optimisation of internal Message Bus listeners
All message bus listeners with the micro:bit runtie are non blocking, and safe to be called
in an interrupt context. As such, these have now all been declared MESSAGE_BUS_LISTENER_IMMEDIATE
which should mitigate all unbounded event queueing effects.
2015-10-08 23:49:14 +01:00
Joe Finney 1d76def8fa microbit: BLE service bugfixes
Updates to BLE interface to match specification following testing by Bluetooth SIG.

Accelerometer Period: now supports READ and WRITE
Magnetometer Period: now supports READ and WRITE
LED Matrix State: now supports READ and WRITE.

UUIDs of Temperature Service characteristic corrected.
2015-10-08 23:23:00 +01:00
Joe Finney 85a26dc8e1 microbit: Updates to enable semantic versioning of the micro:bit runtime DAL
More specifically, the build system now uses the semantic versioning meta-data
held in module.json to define a major.minor.patch version. Additionally, is the branch
being compiled is *not* the master branch, the version is appended with <branchname><githash>.

Specific updates:

- Updates to CMake files to expose this to the micro:bit runtime code.
- Addition of uBit.systemVersion() to expose this to application code.
- Displaying of version string over serial if MICROBIT_DBG is enabled.
- Distribution of version string over BLE via the firmware revision characteristic.
2015-10-08 14:37:35 +01:00
Joe Finney 2230e39340 microbit: BUGFIX: #1291 ManagedString(INT_MIN) does not work properly
Corner case error in serialization code for INT_MIN only - corrected.
2015-09-29 23:51:20 +01:00
Joe Finney 18236810a3 microbit: BLE Profile Beta 1
First functionally complete BLE profile, matching BLE speicfication v1.6.
More specifically, the following services are now functional:

  - AccelerometerService
  - MeganetometerService
  - EventService
  - TemperatureServide
  - IOPinService
  - DFUService
  - ButtonService
  - LEDService

Also, updates to underlying device drivers to enable greater configurability:

  - MicroBitCompass now supports variable sample rates and temperature sensing
  - MicroBitAccelerometer now supports variable sample rates and ranges
  - MicroBitThermometer introduced
  - MicroBitMessageBus adapted to permit enumeration and block removal of listeners

Finally, MicroBit DFU Service has been changed to the new UUIDs specificed in v1.6 of BLE spec.
2015-09-28 21:40:44 +01:00
Damien George 0dcb6834ec microbit: Use default constructor for MatrixPoint so data is ROMable.
Previous to this patch an explicit constructor was provided for creating
MatrixPoint instances, which meant that such objects could not be put in
ROM (since they needed to be constructed at runtime).

By using the defualt construction method for structs the MatrixPoint map
is now compiled into the rodata section, hence freeing up RAM.

Saves: 4 bytes data, 56 bytes bss, 148 bytes code.
2015-09-25 21:19:10 +01:00
Joe Finney 4314b68643 microbit: First implementation of Temperature Service 2015-09-23 22:15:44 +01:00
Joe Finney eb5ed28f74 microbit: First cut at MicroBitButtonService and microBitIOPinService
Strictly still development - untested code.
2015-09-22 16:13:08 +01:00
Joe Finney ef613e9d86 microbit: Added BLE Magnetometer service compilation, initialization and configuration options 2015-09-19 22:19:57 +01:00
Joe Finney 3cfc7ec6e7 microbit: Ammendments to ensure fiber is never pages out due to eventing and minor cleanups
- renamed fiber flag to be more general.
- renamed idle to idleFiber to be consistent with the rest of the code.
- factored content of idle() into a funciton to avoid dupication.
- added test case to MessageBus::process() to avoid forking fibers if not requested.
- removed fiber_allow_run_idle_within mutator in favour of exposing currentFiber, as a more general solution.
2015-09-19 21:44:58 +01:00
Joe Finney 1e71169550 microbit: First draft of Magnetometer BLE service 2015-09-19 21:03:36 +01:00
Joe Finney ae0e5611c3 microbit: First draft of reconfigurable frequencies of MicroBitCompass 2015-09-19 21:00:38 +01:00
Damien George 9ccdd25e9f microbit: Allow to run the idle task within the current fiber's stack.
If there is only 1 main fiber (plus the idle fiber) then enabling this
new feature for the main fiber (using fiber_allow_run_idle_within())
will mean that no heap is needed to swap the stack out.
2015-09-19 11:45:45 +01:00
Joe Finney 2c9f63902c microbit: Message Bus updates to support URGENT events queue optimisations
Added new URGENT listener type, that ensures immediate, non queuing delivery of events.
Introduced two-pass algorithm into message bus. Only events with an event listener are now
queued at ingress - this reduces unecessary memory usage for 'uninteresting' events.
2015-09-18 23:20:44 +01:00
Joe Finney 058f73ede1 microbit: Moved MicroBitDFUService UUIDs to match BLE profile specification 2015-09-18 18:48:27 +01:00
Joe Finney ec30695d7d microbit: BUGFIX MicroBit::reset() now operates correctly 2015-09-17 23:32:40 +01:00
Jonathan Protzenko 78ad8a1646 Small tweak for the new ignore function. 2015-09-16 12:08:09 -07:00
Jonathan Protzenko 3158445208 New setAnalogPeriodUs function.
Fixes bbc/microbit-extras#1389.
2015-09-16 11:52:25 -07:00
Joe Finney a17830030e microbit: HOTFIX: BLE Notification bug in MicroBitDFUService
Hotfix of a minor bug in the MicroBitDFU Service that prevented BLE notifications
from being sent on the FlashCode characterisitic. Needed as the Samsung companion
app is dependent on this functionality to enable BLE programmming of the micro:bit.
2015-09-15 17:03:36 +01:00
Joe Finney 037ef999eb microbit: Merge branch 'master' into ble-profile
Pulled in changes from MessageBusExtensions to support development of ble profiles.
2015-09-15 15:17:21 +01:00
Joe Finney ccd351a4ed microbit: Added explicit notify() operation to MicroBitDFUService 2015-09-15 14:34:25 +01:00
Joe Finney 3395f66d3d microbit: Added configurable event processing options into MicroBitEvent
Events in the micro:bit runtime are normally launched through making an instance
of the MicroBitEvent class. This update added configuration support to all the
code creating the MicroBitEvent decide if the newly created event should then be
automatically queued on the MessageBus or processed immediately by event handlers.
2015-09-12 11:34:16 +01:00
Joe Finney a875d5fccd microbit: Added configurable concurrency modes for MicroBitMessageBus handlers.
MessageBus handlers can now have one of four concurrency modes for the eventuality
of an event being raised whilst a previous event is still being processed. An additional
(optional) parameter is provided to the listen() functions to allow this to be selected
on a per event handler basis. The permissable options are:

MESSAGE_BUS_LISTENER_REENTRANT:
The event handler is fired with the new event, regardless of whether or not
a previous event is still be processed by that handler.

MESSAGE_BUS_LISTENER_QUEUE_IF_BUSY:
The new event is queued until such a time as the previous event has completed
execution. The new event is then processed. This option does not preclude the
processing of the new event by other event handlers.

MESSAGE_BUS_LISTENER_DROP_IF_BUSY:
The new event is dropped, and will never be processed the the event handler.
This option does not preclude the processing of the new event by other event handlers.

MESSAGE_BUS_LISTENER_NONBLOCKING:
The event handler is self-declaring that it never blocks. This flag is used purely
for optimisation, as it permits direct execution of the event hadnelr without inducing
any overhead from the scheduler.

In addition, the following minor revisions were made in this release:

* Cleanup of the #include dependencies contained in the microbit-dal .h files
* Bugfix to the scheduler block on event matching code.
* Introduced a MICROBIT_ID_ALERT MessageBus channel, for general purpose eventing using nonces.
2015-09-11 16:39:38 +01:00
Joe Finney 51493092ff microbit: Added support to remove MicroBitListener event handlers. 2015-09-10 12:53:39 +01:00
Joe Finney 8ea2e953c8 microbit: Added C++ member function callback support into MicroBitMessageBus
Event callbacks can now be transparently added to any C++ member function
matching the MicroBitMessageBud signature:  void fn(MicroBitEvent e)
2015-09-10 00:04:27 +01:00
Joe Finney 609cb6f2d8 microbit: Added first draft of BLE Accelerometer service
n.b. this code is as yet untested.
2015-09-09 15:16:11 +01:00
Joe Finney 9ccf0a7688 microbit: Added configuration support for accelerometer sample rate and range
MicroBitAccelerometer now contans methods to allow dynamic selection of sample range
(from +/-2g to +/-8g) and sample frequency (up to 800Hz). The default settings and behaviour
remain consistent.
2015-09-08 23:16:15 +01:00
Joe Finney 380b999440 microbit: BUGFIX: read callbacks on working
Changes to MicroBitLEDService class to ensure matrixCharacteristic remains
persistent. Needed to allow mbed read callbacks.
2015-09-08 13:55:15 +01:00
Joe Finney 7e18131849 microbit: Added MicroBitLEDService
One of the standard services defiend with the Bluetooth SIG. Allows remote control
of the LED matrix display over BLE.
2015-09-07 17:09:17 +01:00
Joe Finney 574b408cd1 microbit: Code Structure Cleanup
Create subdirectories for assembler code and BLE specific functionality
2015-09-07 10:26:48 +01:00
Joe Finney 8e1a15c79f microbit: Added support for custom configuration files through yotta
A header file containing custom configuration options for the microbit:runtime can
now be defined through a yotaa configuration option.

For example, including the following inside a top level config.json file
will load configuration options from a file called "MicroBitCustomConfig.h" that is stored
alongside an application's main.cpp. Any options defined there will override the defaults
defined in microbit-dal/inc/MicroBitConfig.h :

{
   "microbit" :{
      "configfile" : "source/MicroBitCustomConfig.h"
   }
}
2015-09-04 00:08:20 +01:00
Joe Finney f616011ac1 microbit: Integrate support for transparent gcc compiles
Custom CMakefile added to microbit-dal to automatically assemble the correct
version of CortexContextSwitch.s accordiong to the current build target.
2015-09-02 18:54:31 +01:00
Joe Finney cbaec38d06 Merge branch 'gcc' 2015-09-02 18:40:26 +01:00
Joe Finney 6470b71b1d microbit: Conditional compilation on MicroBitConfig
All options defined in MicroBitConfig are now set IFF they already do not have a value.
This allows external configuration of these options much more cleanly. Additional macros
also defined to provide clean implementation for boolean configuration switches.

Also some minor bugfixes:

  - Correction of typo of "Microbit.h" => "MicroBit.h"
  - Fixed heap corruption bug on gcc as a result of a debug printf in an unsafe context.
2015-09-02 12:42:24 +01:00
Joe Finney 857a626ed0 microbit: Memory Optimisation Mega Update
This release contains a widespread set of updates and optimisations to the micro:bit
runtime, with a view to reducing the SRAM footprint of the whole system. This is to
provide as much usable HEAP storage for application programs as possible.

Specific updates and optimisations include:

  - Additional compilation flags to allow the core micro:bit runtime to be configured.
    These are defined in MicroBitConfig.h

  - A custom heap allocator. This is now included for two reasons:

    1) To provide a simple mechanism to to utilise both the mbed heap space and other memory
       regions (such as unused memory in the SoftDevice region) as a single virtual heap.
    2) To address some issues that have been noted that are attributable to heap fragmentation.
       The micro:bit heap allocator has a simple algorithm, but one that is chosen to respond
       well to the relativelt high 'heap churn' found in the micro:bit environment.

    All micro:bit components and user programs now use this heap allocator trasparently.

  - Updates to BLE services to remove persistent references to their GATT services. This consumes
    vast amounts SRAM, rather unecessarily. Instead only handles to the relevant GATT characteristics
    are now stored. This specifically includes:
      + MicroBitDFUService
      + MicroBitEventService
      + DeviceInformationService

  - Updates to the Fiber scheduler to save SRAM. More specifically:
      + Removed the need to hold an empty processor context to intialise fibers.
      + The IDLE fiber now runs without a stack
      + fiber stacks are now only created when a fiber is descheduled for the first time, thereby reducing heap churn.
      + the 'main' fiber is now recycled into the fiber_pool if it leaves app_main()
      + fibers created through invoke() now only maintains the necessary part of teh parent stack that is needed, thereby
        reducing the stack size of spawned fibers.

  - Updates to the Message Bus to reduce the overall memory footprint of processing events. More specifically:
      + Event handlers are now always called using invoke(), such that non-blocking event handlers no longer need
        a dedicated fiber to execute - thereby saving SRAM and processor time.
      + Processing of events from the event queue is now rate paced. Events only continue to be processed as long as there
        are no fibers on the run queue. i.e. event processing is no longer greedy, thereby reducing the number of fibers
        created on the runqueue.

  - Updates to BLUEZOENE code to bring up core BLE services even if they are not enabled by default. This allows
    programs that do not require BLE to operate to benefit from the full range of SRAM, whilst still allowing the
    device to be programmed over BLE.

  - Updates to the Soft Device initialisation configuration, reducing the size of the GATT table held in the top 1.8K
    of its 8K memory region to around 800 bytes. This is sufficient to run the default set of BLE services on the micro:bit
    so the additional memory is configured as HEAP storage by MicroBitHeapAllocator.

  - Minor changes to a range of components to integrate with the above changes.
    + rename of free() to release() in DynamicPWM to avoid namespace collision with MicroBitHeap free()
    + rename of fork_on_block to invoke() to enhance readbility.

  - Many code cleanups and updates to out of date comments.
2015-08-31 23:25:10 +01:00
Jonathan Protzenko e258a52c79 My CMake skills are weak... properly implement the GCC/ARMCC switch for the S
file.
2015-08-24 10:55:22 -07:00
Jonathan Protzenko 8491b558e0 CMake tweak 2015-08-24 10:49:25 -07:00
Jonathan Protzenko 63b62e533f A version of microbit-dal that builds with both gcc and armcc.
Check in the CMakeLists.txt with a custom hook so that the library can build
with both compilers regardless.
2015-08-24 10:33:30 -07:00
Joe Finney 42f43b2255 Merge branch 'master' of https://github.com/lancaster-university/microbit-dal 2015-08-19 23:48:36 +01:00
Joe Finney 0fec4ae87c microbit: BUGFIX - Input validation in MicroBitDisplay::setBrightness()
Updates to MicroBitDisplay::setBrightness() to perform a NOP for out of bound parameters.
This aligns the functionality of the runtime with the TD simulator.
2015-08-19 23:36:17 +01:00