Essai d'application Lycée Malraux NSI

Dependencies:   BLE_API nRF51822 mbed-dev-bin

Dependents:   microbit

Committer:
LancasterUniversity
Date:
Wed Jul 13 12:18:46 2016 +0100
Revision:
66:2fc7d7c2fffc
Parent:
65:f7ebabf23e15
Synchronized with git rev a962befe
Author: Joe Finney
Merge pull request #159 from lancaster-university/bugfix-145-shake-hard-to-trigger

Bugfix 145 shake hard to trigger

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Jonathan Austin 1:8aa5cdb4ab67 1 /*
Jonathan Austin 1:8aa5cdb4ab67 2 The MIT License (MIT)
Jonathan Austin 1:8aa5cdb4ab67 3
Jonathan Austin 1:8aa5cdb4ab67 4 Copyright (c) 2016 British Broadcasting Corporation.
Jonathan Austin 1:8aa5cdb4ab67 5 This software is provided by Lancaster University by arrangement with the BBC.
Jonathan Austin 1:8aa5cdb4ab67 6
Jonathan Austin 1:8aa5cdb4ab67 7 Permission is hereby granted, free of charge, to any person obtaining a
Jonathan Austin 1:8aa5cdb4ab67 8 copy of this software and associated documentation files (the "Software"),
Jonathan Austin 1:8aa5cdb4ab67 9 to deal in the Software without restriction, including without limitation
Jonathan Austin 1:8aa5cdb4ab67 10 the rights to use, copy, modify, merge, publish, distribute, sublicense,
Jonathan Austin 1:8aa5cdb4ab67 11 and/or sell copies of the Software, and to permit persons to whom the
Jonathan Austin 1:8aa5cdb4ab67 12 Software is furnished to do so, subject to the following conditions:
Jonathan Austin 1:8aa5cdb4ab67 13
Jonathan Austin 1:8aa5cdb4ab67 14 The above copyright notice and this permission notice shall be included in
Jonathan Austin 1:8aa5cdb4ab67 15 all copies or substantial portions of the Software.
Jonathan Austin 1:8aa5cdb4ab67 16
Jonathan Austin 1:8aa5cdb4ab67 17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
Jonathan Austin 1:8aa5cdb4ab67 18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Jonathan Austin 1:8aa5cdb4ab67 19 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
Jonathan Austin 1:8aa5cdb4ab67 20 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
Jonathan Austin 1:8aa5cdb4ab67 21 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
Jonathan Austin 1:8aa5cdb4ab67 22 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
Jonathan Austin 1:8aa5cdb4ab67 23 DEALINGS IN THE SOFTWARE.
Jonathan Austin 1:8aa5cdb4ab67 24 */
Jonathan Austin 1:8aa5cdb4ab67 25
Jonathan Austin 1:8aa5cdb4ab67 26 /**
Jonathan Austin 1:8aa5cdb4ab67 27 * Compile time configuration options for the micro:bit runtime.
Jonathan Austin 1:8aa5cdb4ab67 28 */
Jonathan Austin 1:8aa5cdb4ab67 29
Jonathan Austin 1:8aa5cdb4ab67 30 #ifndef MICROBIT_CONFIG_H
Jonathan Austin 1:8aa5cdb4ab67 31 #define MICROBIT_CONFIG_H
Jonathan Austin 1:8aa5cdb4ab67 32
Jonathan Austin 1:8aa5cdb4ab67 33 #include "mbed.h"
LancasterUniversity 27:2f494ead23de 34 #include "yotta_cfg_mappings.h"
Jonathan Austin 1:8aa5cdb4ab67 35
Jonathan Austin 1:8aa5cdb4ab67 36 //
Jonathan Austin 1:8aa5cdb4ab67 37 // Memory configuration
Jonathan Austin 1:8aa5cdb4ab67 38 //
Jonathan Austin 1:8aa5cdb4ab67 39
Jonathan Austin 1:8aa5cdb4ab67 40 // The start address of usable RAM memory.
Jonathan Austin 1:8aa5cdb4ab67 41 #ifndef MICROBIT_SRAM_BASE
Jonathan Austin 1:8aa5cdb4ab67 42 #define MICROBIT_SRAM_BASE 0x20000008
Jonathan Austin 1:8aa5cdb4ab67 43 #endif
Jonathan Austin 1:8aa5cdb4ab67 44
Jonathan Austin 1:8aa5cdb4ab67 45 // Physical address of the top of SRAM.
Jonathan Austin 1:8aa5cdb4ab67 46 #ifndef MICROBIT_SRAM_END
Jonathan Austin 1:8aa5cdb4ab67 47 #define MICROBIT_SRAM_END 0x20004000
Jonathan Austin 1:8aa5cdb4ab67 48 #endif
Jonathan Austin 1:8aa5cdb4ab67 49
Jonathan Austin 1:8aa5cdb4ab67 50 // The end address of memory normally reserved for Soft Device.
Jonathan Austin 1:8aa5cdb4ab67 51 #ifndef MICROBIT_SD_LIMIT
Jonathan Austin 1:8aa5cdb4ab67 52 #define MICROBIT_SD_LIMIT 0x20002000
Jonathan Austin 1:8aa5cdb4ab67 53 #endif
Jonathan Austin 1:8aa5cdb4ab67 54
Jonathan Austin 1:8aa5cdb4ab67 55 // The physical address in memory of the Soft Device GATT table.
Jonathan Austin 1:8aa5cdb4ab67 56 #ifndef MICROBIT_SD_GATT_TABLE_START
Jonathan Austin 1:8aa5cdb4ab67 57 #define MICROBIT_SD_GATT_TABLE_START 0x20001900
Jonathan Austin 1:8aa5cdb4ab67 58 #endif
Jonathan Austin 1:8aa5cdb4ab67 59
Jonathan Austin 1:8aa5cdb4ab67 60 // Physical address of the top of the system stack (on mbed-classic this is the top of SRAM)
Jonathan Austin 1:8aa5cdb4ab67 61 #ifndef CORTEX_M0_STACK_BASE
Jonathan Austin 1:8aa5cdb4ab67 62 #define CORTEX_M0_STACK_BASE MICROBIT_SRAM_END
Jonathan Austin 1:8aa5cdb4ab67 63 #endif
Jonathan Austin 1:8aa5cdb4ab67 64
Jonathan Austin 1:8aa5cdb4ab67 65 // Amount of memory reserved for the stack at the end of memory (bytes).
Jonathan Austin 1:8aa5cdb4ab67 66 #ifndef MICROBIT_STACK_SIZE
Jonathan Austin 1:8aa5cdb4ab67 67 #define MICROBIT_STACK_SIZE 2048
Jonathan Austin 1:8aa5cdb4ab67 68 #endif
Jonathan Austin 1:8aa5cdb4ab67 69
Jonathan Austin 1:8aa5cdb4ab67 70 // Physical address of the end of mbed heap space.
Jonathan Austin 1:8aa5cdb4ab67 71 #ifndef MICROBIT_HEAP_END
Jonathan Austin 1:8aa5cdb4ab67 72 #define MICROBIT_HEAP_END (CORTEX_M0_STACK_BASE - MICROBIT_STACK_SIZE)
Jonathan Austin 1:8aa5cdb4ab67 73 #endif
Jonathan Austin 1:8aa5cdb4ab67 74
Jonathan Austin 1:8aa5cdb4ab67 75 // Enables or disables the MicroBitHeapllocator. Note that if disabled, no reuse of the SRAM normally
Jonathan Austin 1:8aa5cdb4ab67 76 // reserved for SoftDevice is possible, and out of memory condition will no longer be trapped...
Jonathan Austin 1:8aa5cdb4ab67 77 // i.e. panic() will no longer be triggered on memory full conditions.
Jonathan Austin 1:8aa5cdb4ab67 78 #ifndef MICROBIT_HEAP_ALLOCATOR
Jonathan Austin 1:8aa5cdb4ab67 79 #define MICROBIT_HEAP_ALLOCATOR 1
Jonathan Austin 1:8aa5cdb4ab67 80 #endif
Jonathan Austin 1:8aa5cdb4ab67 81
Jonathan Austin 1:8aa5cdb4ab67 82 // Block size used by the allocator in bytes.
Jonathan Austin 1:8aa5cdb4ab67 83 // n.b. Currently only 32 bits (4 bytes) is supported.
Jonathan Austin 1:8aa5cdb4ab67 84 #ifndef MICROBIT_HEAP_BLOCK_SIZE
Jonathan Austin 1:8aa5cdb4ab67 85 #define MICROBIT_HEAP_BLOCK_SIZE 4
Jonathan Austin 1:8aa5cdb4ab67 86 #endif
Jonathan Austin 1:8aa5cdb4ab67 87
Jonathan Austin 1:8aa5cdb4ab67 88 // The proportion of SRAM available on the mbed heap to reserve for the micro:bit heap.
Jonathan Austin 1:8aa5cdb4ab67 89 #ifndef MICROBIT_NESTED_HEAP_SIZE
Jonathan Austin 1:8aa5cdb4ab67 90 #define MICROBIT_NESTED_HEAP_SIZE 0.75
Jonathan Austin 1:8aa5cdb4ab67 91 #endif
Jonathan Austin 1:8aa5cdb4ab67 92
Jonathan Austin 1:8aa5cdb4ab67 93 // If defined, reuse any unused SRAM normally reserved for SoftDevice (Nordic's memory resident BLE stack) as heap memory.
Jonathan Austin 1:8aa5cdb4ab67 94 // The amount of memory reused depends upon whether or not BLE is enabled using MICROBIT_BLE_ENABLED.
Jonathan Austin 1:8aa5cdb4ab67 95 // Set '1' to enable.
Jonathan Austin 1:8aa5cdb4ab67 96 #ifndef MICROBIT_HEAP_REUSE_SD
Jonathan Austin 1:8aa5cdb4ab67 97 #define MICROBIT_HEAP_REUSE_SD 1
Jonathan Austin 1:8aa5cdb4ab67 98 #endif
Jonathan Austin 1:8aa5cdb4ab67 99
Jonathan Austin 1:8aa5cdb4ab67 100 // The amount of memory allocated to Soft Device to hold its BLE GATT table.
Jonathan Austin 1:8aa5cdb4ab67 101 // For standard S110 builds, this should be word aligned and in the range 0x300 - 0x700.
Jonathan Austin 1:8aa5cdb4ab67 102 // Any unused memory will be automatically reclaimed as HEAP memory if both MICROBIT_HEAP_REUSE_SD and MICROBIT_HEAP_ALLOCATOR are enabled.
Jonathan Austin 1:8aa5cdb4ab67 103 #ifndef MICROBIT_SD_GATT_TABLE_SIZE
Jonathan Austin 1:8aa5cdb4ab67 104 #define MICROBIT_SD_GATT_TABLE_SIZE 0x300
Jonathan Austin 1:8aa5cdb4ab67 105 #endif
Jonathan Austin 1:8aa5cdb4ab67 106
Jonathan Austin 1:8aa5cdb4ab67 107 //
Jonathan Austin 1:8aa5cdb4ab67 108 // Fiber scheduler configuration
Jonathan Austin 1:8aa5cdb4ab67 109 //
Jonathan Austin 1:8aa5cdb4ab67 110
Jonathan Austin 1:8aa5cdb4ab67 111 // Scheduling quantum (milliseconds)
Jonathan Austin 1:8aa5cdb4ab67 112 // Also used to drive the micro:bit runtime system ticker.
Jonathan Austin 1:8aa5cdb4ab67 113 #ifndef SYSTEM_TICK_PERIOD_MS
Jonathan Austin 1:8aa5cdb4ab67 114 #define SYSTEM_TICK_PERIOD_MS 6
Jonathan Austin 1:8aa5cdb4ab67 115 #endif
Jonathan Austin 1:8aa5cdb4ab67 116
Jonathan Austin 1:8aa5cdb4ab67 117 //
Jonathan Austin 1:8aa5cdb4ab67 118 // Message Bus:
Jonathan Austin 1:8aa5cdb4ab67 119 // Default behaviour for event handlers, if not specified in the listen() call
Jonathan Austin 1:8aa5cdb4ab67 120 //
Jonathan Austin 1:8aa5cdb4ab67 121 // Permissable values are:
Jonathan Austin 1:8aa5cdb4ab67 122 // MESSAGE_BUS_LISTENER_REENTRANT
Jonathan Austin 1:8aa5cdb4ab67 123 // MESSAGE_BUS_LISTENER_QUEUE_IF_BUSY
Jonathan Austin 1:8aa5cdb4ab67 124 // MESSAGE_BUS_LISTENER_DROP_IF_BUSY
Jonathan Austin 1:8aa5cdb4ab67 125 // MESSAGE_BUS_LISTENER_IMMEDIATE
Jonathan Austin 1:8aa5cdb4ab67 126
Jonathan Austin 1:8aa5cdb4ab67 127 #ifndef EVENT_LISTENER_DEFAULT_FLAGS
Jonathan Austin 1:8aa5cdb4ab67 128 #define EVENT_LISTENER_DEFAULT_FLAGS MESSAGE_BUS_LISTENER_QUEUE_IF_BUSY
Jonathan Austin 1:8aa5cdb4ab67 129 #endif
Jonathan Austin 1:8aa5cdb4ab67 130
Jonathan Austin 1:8aa5cdb4ab67 131 //
Jonathan Austin 1:8aa5cdb4ab67 132 // Maximum event queue depth. If a queue exceeds this depth, further events will be dropped.
Jonathan Austin 1:8aa5cdb4ab67 133 // Used to prevent message queues growing uncontrollably due to badly behaved user code and causing panic conditions.
Jonathan Austin 1:8aa5cdb4ab67 134 //
Jonathan Austin 1:8aa5cdb4ab67 135 #ifndef MESSAGE_BUS_LISTENER_MAX_QUEUE_DEPTH
Jonathan Austin 1:8aa5cdb4ab67 136 #define MESSAGE_BUS_LISTENER_MAX_QUEUE_DEPTH 10
Jonathan Austin 1:8aa5cdb4ab67 137 #endif
Jonathan Austin 1:8aa5cdb4ab67 138
Jonathan Austin 1:8aa5cdb4ab67 139 //
Jonathan Austin 1:8aa5cdb4ab67 140 // Core micro:bit services
Jonathan Austin 1:8aa5cdb4ab67 141 //
Jonathan Austin 1:8aa5cdb4ab67 142
Jonathan Austin 1:8aa5cdb4ab67 143 // To reduce memory cost and complexity, the micro:bit allows components to register for
Jonathan Austin 1:8aa5cdb4ab67 144 // periodic callback events during interrupt context, which occur every scheduling quantum (FIBER_TICK_PERIOD_MS)
Jonathan Austin 1:8aa5cdb4ab67 145 // This defines the maximum size of interrupt callback list.
Jonathan Austin 1:8aa5cdb4ab67 146 #ifndef MICROBIT_SYSTEM_COMPONENTS
Jonathan Austin 1:8aa5cdb4ab67 147 #define MICROBIT_SYSTEM_COMPONENTS 10
Jonathan Austin 1:8aa5cdb4ab67 148 #endif
Jonathan Austin 1:8aa5cdb4ab67 149
Jonathan Austin 1:8aa5cdb4ab67 150 // To reduce memory cost and complexity, the micro:bit allows components to register for
Jonathan Austin 1:8aa5cdb4ab67 151 // periodic callback events when the processor is idle.
Jonathan Austin 1:8aa5cdb4ab67 152 // This defines the maximum size of the idle callback list.
Jonathan Austin 1:8aa5cdb4ab67 153 #ifndef MICROBIT_IDLE_COMPONENTS
Jonathan Austin 1:8aa5cdb4ab67 154 #define MICROBIT_IDLE_COMPONENTS 6
Jonathan Austin 1:8aa5cdb4ab67 155 #endif
Jonathan Austin 1:8aa5cdb4ab67 156
Jonathan Austin 1:8aa5cdb4ab67 157 //
Jonathan Austin 1:8aa5cdb4ab67 158 // BLE options
Jonathan Austin 1:8aa5cdb4ab67 159 //
Jonathan Austin 1:8aa5cdb4ab67 160 // The BLE stack is very memory hungry. Each service can therefore be compiled in or out
Jonathan Austin 1:8aa5cdb4ab67 161 // by enabling/disabling the options below.
Jonathan Austin 1:8aa5cdb4ab67 162 //
Jonathan Austin 1:8aa5cdb4ab67 163 // n.b. The minimum set of services to enable over the air programming of the device will
Jonathan Austin 1:8aa5cdb4ab67 164 // still be brought up in pairing mode regardless of the settings below.
Jonathan Austin 1:8aa5cdb4ab67 165 //
Jonathan Austin 1:8aa5cdb4ab67 166
Jonathan Austin 1:8aa5cdb4ab67 167 // Enable/Disable BLE during normal operation.
Jonathan Austin 1:8aa5cdb4ab67 168 // Set '1' to enable.
Jonathan Austin 1:8aa5cdb4ab67 169 #ifndef MICROBIT_BLE_ENABLED
Jonathan Austin 1:8aa5cdb4ab67 170 #define MICROBIT_BLE_ENABLED 1
Jonathan Austin 1:8aa5cdb4ab67 171 #endif
Jonathan Austin 1:8aa5cdb4ab67 172
Jonathan Austin 1:8aa5cdb4ab67 173 // Enable/Disable BLE pairing mode mode at power up.
Jonathan Austin 1:8aa5cdb4ab67 174 // Set '1' to enable.
Jonathan Austin 1:8aa5cdb4ab67 175 #ifndef MICROBIT_BLE_PAIRING_MODE
Jonathan Austin 1:8aa5cdb4ab67 176 #define MICROBIT_BLE_PAIRING_MODE 1
Jonathan Austin 1:8aa5cdb4ab67 177 #endif
Jonathan Austin 1:8aa5cdb4ab67 178
Jonathan Austin 1:8aa5cdb4ab67 179 // Enable/Disable the use of private resolvable addresses.
Jonathan Austin 1:8aa5cdb4ab67 180 // Set '1' to enable.
Jonathan Austin 1:8aa5cdb4ab67 181 // n.b. This is known to be a feature that suffers compatibility issues with many BLE central devices.
Jonathan Austin 1:8aa5cdb4ab67 182 #ifndef MICROBIT_BLE_PRIVATE_ADDRESSES
Jonathan Austin 1:8aa5cdb4ab67 183 #define MICROBIT_BLE_PRIVATE_ADDRESSES 0
Jonathan Austin 1:8aa5cdb4ab67 184 #endif
Jonathan Austin 1:8aa5cdb4ab67 185
Jonathan Austin 1:8aa5cdb4ab67 186 // Convenience option to enable / disable BLE security entirely
Jonathan Austin 1:8aa5cdb4ab67 187 // Open BLE links are not secure, but commonly used during the development of BLE services
Jonathan Austin 1:8aa5cdb4ab67 188 // Set '1' to disable all secuity
Jonathan Austin 1:8aa5cdb4ab67 189 #ifndef MICROBIT_BLE_OPEN
Jonathan Austin 1:8aa5cdb4ab67 190 #define MICROBIT_BLE_OPEN 0
Jonathan Austin 1:8aa5cdb4ab67 191 #endif
Jonathan Austin 1:8aa5cdb4ab67 192
Jonathan Austin 1:8aa5cdb4ab67 193 // Configure for open BLE operation if so configured
Jonathan Austin 1:8aa5cdb4ab67 194 #if (MICROBIT_BLE_OPEN == 1)
Jonathan Austin 1:8aa5cdb4ab67 195 #define MICROBIT_BLE_SECURITY_LEVEL SECURITY_MODE_ENCRYPTION_OPEN_LINK
Jonathan Austin 1:8aa5cdb4ab67 196 #define MICROBIT_BLE_WHITELIST 0
Jonathan Austin 1:8aa5cdb4ab67 197 #define MICROBIT_BLE_ADVERTISING_TIMEOUT 0
Jonathan Austin 1:8aa5cdb4ab67 198 #define MICROBIT_BLE_DEFAULT_TX_POWER 6
Jonathan Austin 1:8aa5cdb4ab67 199 #endif
Jonathan Austin 1:8aa5cdb4ab67 200
Jonathan Austin 1:8aa5cdb4ab67 201
Jonathan Austin 1:8aa5cdb4ab67 202 // Define the default, global BLE security requirements for MicroBit BLE services
Jonathan Austin 1:8aa5cdb4ab67 203 // May be one of the following options (see mbed's SecurityManager class implementaiton detail)
Jonathan Austin 1:8aa5cdb4ab67 204 // SECURITY_MODE_ENCRYPTION_OPEN_LINK: No bonding, encryption, or whitelisting required.
Jonathan Austin 1:8aa5cdb4ab67 205 // SECURITY_MODE_ENCRYPTION_NO_MITM: Bonding, encyption and whitelisting but no passkey.
Jonathan Austin 1:8aa5cdb4ab67 206 // SECURITY_MODE_ENCRYPTION_WITH_MITM: Bonding, encrytion and whitelisting with passkey authentication.
Jonathan Austin 1:8aa5cdb4ab67 207 //
Jonathan Austin 1:8aa5cdb4ab67 208 #ifndef MICROBIT_BLE_SECURITY_LEVEL
Jonathan Austin 1:8aa5cdb4ab67 209 #define MICROBIT_BLE_SECURITY_LEVEL SECURITY_MODE_ENCRYPTION_WITH_MITM
Jonathan Austin 1:8aa5cdb4ab67 210 #endif
Jonathan Austin 1:8aa5cdb4ab67 211
Jonathan Austin 1:8aa5cdb4ab67 212 // Enable/Disable the use of BLE whitelisting.
Jonathan Austin 1:8aa5cdb4ab67 213 // If enabled, the micro:bit will only respond to connection requests from
Jonathan Austin 1:8aa5cdb4ab67 214 // known, bonded devices.
Jonathan Austin 1:8aa5cdb4ab67 215 #ifndef MICROBIT_BLE_WHITELIST
Jonathan Austin 1:8aa5cdb4ab67 216 #define MICROBIT_BLE_WHITELIST 1
Jonathan Austin 1:8aa5cdb4ab67 217 #endif
Jonathan Austin 1:8aa5cdb4ab67 218
Jonathan Austin 1:8aa5cdb4ab67 219 // Define the period of time for which the BLE stack will advertise (seconds)
Jonathan Austin 1:8aa5cdb4ab67 220 // Afer this period, advertising will cease. Set to '0' for no timeout (always advertise).
Jonathan Austin 1:8aa5cdb4ab67 221 #ifndef MICROBIT_BLE_ADVERTISING_TIMEOUT
Jonathan Austin 1:8aa5cdb4ab67 222 #define MICROBIT_BLE_ADVERTISING_TIMEOUT 0
Jonathan Austin 1:8aa5cdb4ab67 223 #endif
Jonathan Austin 1:8aa5cdb4ab67 224
Jonathan Austin 1:8aa5cdb4ab67 225 // Defines default power level of the BLE radio transmitter.
Jonathan Austin 1:8aa5cdb4ab67 226 // Valid values are in the range 0..7 inclusive, with 0 being the lowest power and 7 the highest power.
Jonathan Austin 1:8aa5cdb4ab67 227 // Based on trials undertaken by the BBC, the radio is normally set to its lowest power level
Jonathan Austin 1:8aa5cdb4ab67 228 // to best protect children's privacy.
Jonathan Austin 1:8aa5cdb4ab67 229 #ifndef MICROBIT_BLE_DEFAULT_TX_POWER
Jonathan Austin 1:8aa5cdb4ab67 230 #define MICROBIT_BLE_DEFAULT_TX_POWER 0
Jonathan Austin 1:8aa5cdb4ab67 231 #endif
Jonathan Austin 1:8aa5cdb4ab67 232
Jonathan Austin 1:8aa5cdb4ab67 233 // Enable/Disable BLE Service: MicroBitDFU
Jonathan Austin 1:8aa5cdb4ab67 234 // This allows over the air programming during normal operation.
Jonathan Austin 1:8aa5cdb4ab67 235 // Set '1' to enable.
Jonathan Austin 1:8aa5cdb4ab67 236 #ifndef MICROBIT_BLE_DFU_SERVICE
Jonathan Austin 1:8aa5cdb4ab67 237 #define MICROBIT_BLE_DFU_SERVICE 1
Jonathan Austin 1:8aa5cdb4ab67 238 #endif
Jonathan Austin 1:8aa5cdb4ab67 239
Jonathan Austin 1:8aa5cdb4ab67 240 // Enable/Disable BLE Service: MicroBitEventService
Jonathan Austin 1:8aa5cdb4ab67 241 // This allows routing of events from the micro:bit message bus over BLE.
Jonathan Austin 1:8aa5cdb4ab67 242 // Set '1' to enable.
Jonathan Austin 1:8aa5cdb4ab67 243 #ifndef MICROBIT_BLE_EVENT_SERVICE
Jonathan Austin 1:8aa5cdb4ab67 244 #define MICROBIT_BLE_EVENT_SERVICE 1
Jonathan Austin 1:8aa5cdb4ab67 245 #endif
Jonathan Austin 1:8aa5cdb4ab67 246
Jonathan Austin 1:8aa5cdb4ab67 247 // Enable/Disable BLE Service: MicroBitDeviceInformationService
Jonathan Austin 1:8aa5cdb4ab67 248 // This enables the standard BLE device information service.
Jonathan Austin 1:8aa5cdb4ab67 249 // Set '1' to enable.
Jonathan Austin 1:8aa5cdb4ab67 250 #ifndef MICROBIT_BLE_DEVICE_INFORMATION_SERVICE
Jonathan Austin 1:8aa5cdb4ab67 251 #define MICROBIT_BLE_DEVICE_INFORMATION_SERVICE 1
Jonathan Austin 1:8aa5cdb4ab67 252 #endif
Jonathan Austin 1:8aa5cdb4ab67 253
Jonathan Austin 1:8aa5cdb4ab67 254 //
Jonathan Austin 1:8aa5cdb4ab67 255 // Accelerometer options
Jonathan Austin 1:8aa5cdb4ab67 256 //
Jonathan Austin 1:8aa5cdb4ab67 257
Jonathan Austin 1:8aa5cdb4ab67 258 // Enable this to read 10 bits of data from the acclerometer.
Jonathan Austin 1:8aa5cdb4ab67 259 // Otherwise, 8 bits are used.
Jonathan Austin 1:8aa5cdb4ab67 260 // Set '1' to enable.
Jonathan Austin 1:8aa5cdb4ab67 261 #ifndef USE_ACCEL_LSB
Jonathan Austin 1:8aa5cdb4ab67 262 #define USE_ACCEL_LSB 0
Jonathan Austin 1:8aa5cdb4ab67 263 #endif
Jonathan Austin 1:8aa5cdb4ab67 264
Jonathan Austin 1:8aa5cdb4ab67 265 //
Jonathan Austin 1:8aa5cdb4ab67 266 // Display options
Jonathan Austin 1:8aa5cdb4ab67 267 //
Jonathan Austin 1:8aa5cdb4ab67 268
Jonathan Austin 1:8aa5cdb4ab67 269 // Selects the matrix configuration for the display driver.
Jonathan Austin 1:8aa5cdb4ab67 270 // Known, acceptable options are:
Jonathan Austin 1:8aa5cdb4ab67 271 //
Jonathan Austin 1:8aa5cdb4ab67 272 #define MICROBUG_REFERENCE_DEVICE 1
Jonathan Austin 1:8aa5cdb4ab67 273 #define MICROBIT_3X9 2
Jonathan Austin 1:8aa5cdb4ab67 274 #define MICROBIT_SB1 3
Jonathan Austin 1:8aa5cdb4ab67 275 #define MICROBIT_SB2 4
Jonathan Austin 1:8aa5cdb4ab67 276
Jonathan Austin 1:8aa5cdb4ab67 277 #ifndef MICROBIT_DISPLAY_TYPE
Jonathan Austin 1:8aa5cdb4ab67 278 #define MICROBIT_DISPLAY_TYPE MICROBIT_SB2
Jonathan Austin 1:8aa5cdb4ab67 279 #endif
Jonathan Austin 1:8aa5cdb4ab67 280
Jonathan Austin 1:8aa5cdb4ab67 281 // Selects the minimum permissable brightness level for the device
Jonathan Austin 1:8aa5cdb4ab67 282 // in the region of 0 (off) to 255 (full brightness)
Jonathan Austin 1:8aa5cdb4ab67 283 #ifndef MICROBIT_DISPLAY_MINIMUM_BRIGHTNESS
Jonathan Austin 1:8aa5cdb4ab67 284 #define MICROBIT_DISPLAY_MINIMUM_BRIGHTNESS 1
Jonathan Austin 1:8aa5cdb4ab67 285 #endif
Jonathan Austin 1:8aa5cdb4ab67 286
Jonathan Austin 1:8aa5cdb4ab67 287 // Selects the maximum permissable brightness level for the device
Jonathan Austin 1:8aa5cdb4ab67 288 // in the region of 0 (off) to 255 (full brightness)
Jonathan Austin 1:8aa5cdb4ab67 289 #ifndef MICROBIT_DISPLAY_MAXIMUM_BRIGHTNESS
Jonathan Austin 1:8aa5cdb4ab67 290 #define MICROBIT_DISPLAY_MAXIMUM_BRIGHTNESS 255
Jonathan Austin 1:8aa5cdb4ab67 291 #endif
Jonathan Austin 1:8aa5cdb4ab67 292
Jonathan Austin 1:8aa5cdb4ab67 293 // Selects the default brightness for the display
Jonathan Austin 1:8aa5cdb4ab67 294 // in the region of zero (off) to 255 (full brightness)
Jonathan Austin 1:8aa5cdb4ab67 295 #ifndef MICROBIT_DISPLAY_DEFAULT_BRIGHTNESS
Jonathan Austin 1:8aa5cdb4ab67 296 #define MICROBIT_DISPLAY_DEFAULT_BRIGHTNESS MICROBIT_DISPLAY_MAXIMUM_BRIGHTNESS
Jonathan Austin 1:8aa5cdb4ab67 297 #endif
Jonathan Austin 1:8aa5cdb4ab67 298
Jonathan Austin 1:8aa5cdb4ab67 299 // Selects the default scroll speed for the display.
Jonathan Austin 1:8aa5cdb4ab67 300 // The time taken to move a single pixel (ms).
Jonathan Austin 1:8aa5cdb4ab67 301 #ifndef MICROBIT_DEFAULT_SCROLL_SPEED
Jonathan Austin 1:8aa5cdb4ab67 302 #define MICROBIT_DEFAULT_SCROLL_SPEED 120
Jonathan Austin 1:8aa5cdb4ab67 303 #endif
Jonathan Austin 1:8aa5cdb4ab67 304
Jonathan Austin 1:8aa5cdb4ab67 305 // Selects the number of pixels a scroll will move in each quantum.
Jonathan Austin 1:8aa5cdb4ab67 306 #ifndef MICROBIT_DEFAULT_SCROLL_STRIDE
Jonathan Austin 1:8aa5cdb4ab67 307 #define MICROBIT_DEFAULT_SCROLL_STRIDE -1
Jonathan Austin 1:8aa5cdb4ab67 308 #endif
Jonathan Austin 1:8aa5cdb4ab67 309
Jonathan Austin 1:8aa5cdb4ab67 310 // Selects the time each character will be shown on the display during print operations.
Jonathan Austin 1:8aa5cdb4ab67 311 // The time each character is shown on the screen (ms).
Jonathan Austin 1:8aa5cdb4ab67 312 #ifndef MICROBIT_DEFAULT_PRINT_SPEED
Jonathan Austin 1:8aa5cdb4ab67 313 #define MICROBIT_DEFAULT_PRINT_SPEED 400
Jonathan Austin 1:8aa5cdb4ab67 314 #endif
Jonathan Austin 1:8aa5cdb4ab67 315
Jonathan Austin 1:8aa5cdb4ab67 316 //Configures the default serial mode used by serial read and send calls.
Jonathan Austin 1:8aa5cdb4ab67 317 #ifndef MICROBIT_DEFAULT_SERIAL_MODE
Jonathan Austin 1:8aa5cdb4ab67 318 #define MICROBIT_DEFAULT_SERIAL_MODE SYNC_SLEEP
Jonathan Austin 1:8aa5cdb4ab67 319 #endif
Jonathan Austin 1:8aa5cdb4ab67 320
Jonathan Austin 1:8aa5cdb4ab67 321
Jonathan Austin 1:8aa5cdb4ab67 322 //
LancasterUniversity 66:2fc7d7c2fffc 323 // I/O Options
LancasterUniversity 66:2fc7d7c2fffc 324 //
LancasterUniversity 66:2fc7d7c2fffc 325
LancasterUniversity 66:2fc7d7c2fffc 326
LancasterUniversity 66:2fc7d7c2fffc 327 //
LancasterUniversity 66:2fc7d7c2fffc 328 // Define the default mode in which the digital input pins are configured.
LancasterUniversity 66:2fc7d7c2fffc 329 // valid options are PullDown, PullUp and PullNone.
LancasterUniversity 66:2fc7d7c2fffc 330 //
LancasterUniversity 66:2fc7d7c2fffc 331 #ifndef MICROBIT_DEFAULT_PULLMODE
LancasterUniversity 66:2fc7d7c2fffc 332 #define MICROBIT_DEFAULT_PULLMODE PullDown
LancasterUniversity 66:2fc7d7c2fffc 333 #endif
LancasterUniversity 66:2fc7d7c2fffc 334
LancasterUniversity 66:2fc7d7c2fffc 335 //
Jonathan Austin 1:8aa5cdb4ab67 336 // Panic options
Jonathan Austin 1:8aa5cdb4ab67 337 //
Jonathan Austin 1:8aa5cdb4ab67 338
Jonathan Austin 1:8aa5cdb4ab67 339 // Enable this to invoke a panic on out of memory conditions.
Jonathan Austin 1:8aa5cdb4ab67 340 // Set '1' to enable.
Jonathan Austin 1:8aa5cdb4ab67 341 #ifndef MICROBIT_PANIC_HEAP_FULL
Jonathan Austin 1:8aa5cdb4ab67 342 #define MICROBIT_PANIC_HEAP_FULL 1
Jonathan Austin 1:8aa5cdb4ab67 343 #endif
Jonathan Austin 1:8aa5cdb4ab67 344
Jonathan Austin 1:8aa5cdb4ab67 345 //
Jonathan Austin 1:8aa5cdb4ab67 346 // Debug options
Jonathan Austin 1:8aa5cdb4ab67 347 //
Jonathan Austin 1:8aa5cdb4ab67 348
Jonathan Austin 1:8aa5cdb4ab67 349 // Enable this to route debug messages through the USB serial interface.
Jonathan Austin 1:8aa5cdb4ab67 350 // n.b. This also disables the user serial port 'uBit.serial'.
Jonathan Austin 1:8aa5cdb4ab67 351 // Set '1' to enable.
Jonathan Austin 1:8aa5cdb4ab67 352 #ifndef MICROBIT_DBG
Jonathan Austin 1:8aa5cdb4ab67 353 #define MICROBIT_DBG 0
Jonathan Austin 1:8aa5cdb4ab67 354 #endif
Jonathan Austin 1:8aa5cdb4ab67 355
Jonathan Austin 1:8aa5cdb4ab67 356 // Enable this to receive diagnostic messages from the heap allocator via the USB serial interface.
Jonathan Austin 1:8aa5cdb4ab67 357 // n.b. This requires MICROBIT_DBG to be defined.
Jonathan Austin 1:8aa5cdb4ab67 358 // Set '1' to enable.
Jonathan Austin 1:8aa5cdb4ab67 359 #ifndef MICROBIT_HEAP_DBG
Jonathan Austin 1:8aa5cdb4ab67 360 #define MICROBIT_HEAP_DBG 0
Jonathan Austin 1:8aa5cdb4ab67 361 #endif
Jonathan Austin 1:8aa5cdb4ab67 362
Jonathan Austin 1:8aa5cdb4ab67 363 // Versioning options.
Jonathan Austin 1:8aa5cdb4ab67 364 // We use semantic versioning (http://semver.org/) to identify differnet versions of the micro:bit runtime.
Jonathan Austin 1:8aa5cdb4ab67 365 // Where possible we use yotta (an ARM mbed build tool) to help us track versions.
Jonathan Austin 1:8aa5cdb4ab67 366 // if this isn't available, it can be defined manually as a configuration option.
Jonathan Austin 1:8aa5cdb4ab67 367 //
Jonathan Austin 1:8aa5cdb4ab67 368 #ifndef MICROBIT_DAL_VERSION
Jonathan Austin 1:8aa5cdb4ab67 369 #define MICROBIT_DAL_VERSION "unknown"
Jonathan Austin 1:8aa5cdb4ab67 370 #endif
Jonathan Austin 1:8aa5cdb4ab67 371
Jonathan Austin 1:8aa5cdb4ab67 372
Jonathan Austin 1:8aa5cdb4ab67 373 //
Jonathan Austin 1:8aa5cdb4ab67 374 // Helper macro used by the micro:bit runtime to determine if a boolean configuration option is set.
Jonathan Austin 1:8aa5cdb4ab67 375 //
Jonathan Austin 1:8aa5cdb4ab67 376 #define CONFIG_ENABLED(X) (X == 1)
Jonathan Austin 1:8aa5cdb4ab67 377 #define CONFIG_DISABLED(X) (X != 1)
Jonathan Austin 1:8aa5cdb4ab67 378
Jonathan Austin 1:8aa5cdb4ab67 379 #if CONFIG_ENABLED(MICROBIT_HEAP_ALLOCATOR)
Jonathan Austin 1:8aa5cdb4ab67 380 #include "MicroBitHeapAllocator.h"
Jonathan Austin 1:8aa5cdb4ab67 381 #endif
Jonathan Austin 1:8aa5cdb4ab67 382
Jonathan Austin 1:8aa5cdb4ab67 383 #if CONFIG_ENABLED(MICROBIT_DBG)
Jonathan Austin 1:8aa5cdb4ab67 384 extern RawSerial* SERIAL_DEBUG;
Jonathan Austin 1:8aa5cdb4ab67 385 #endif
Jonathan Austin 1:8aa5cdb4ab67 386
LancasterUniversity 27:2f494ead23de 387 #endif