updates

Dependencies:   BLE_API mbed-dev-bin nRF51822

Fork of microbit-dal-eddystone by Martin Woolley

Committer:
wwbluetooth
Date:
Mon Jul 17 21:32:11 2017 +0000
Revision:
77:151a3b864991
Parent:
74:a8f5674a0079
updates

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
bluetooth_mdw 74:a8f5674a0079 75 // Defines the size of a physical FLASH page in RAM.
bluetooth_mdw 74:a8f5674a0079 76 #ifndef PAGE_SIZE
bluetooth_mdw 74:a8f5674a0079 77 #define PAGE_SIZE 1024
bluetooth_mdw 74:a8f5674a0079 78 #endif
bluetooth_mdw 74:a8f5674a0079 79
bluetooth_mdw 74:a8f5674a0079 80 // Defines where in memory persistent data is stored.
bluetooth_mdw 74:a8f5674a0079 81 #ifndef KEY_VALUE_STORE_PAGE
bluetooth_mdw 74:a8f5674a0079 82 #define KEY_VALUE_STORE_PAGE (PAGE_SIZE * (NRF_FICR->CODESIZE - 17))
bluetooth_mdw 74:a8f5674a0079 83 #endif
bluetooth_mdw 74:a8f5674a0079 84
bluetooth_mdw 74:a8f5674a0079 85 #ifndef BLE_BOND_DATA_PAGE
bluetooth_mdw 74:a8f5674a0079 86 #define BLE_BOND_DATA_PAGE (PAGE_SIZE * (NRF_FICR->CODESIZE - 18))
bluetooth_mdw 74:a8f5674a0079 87 #endif
bluetooth_mdw 74:a8f5674a0079 88
bluetooth_mdw 74:a8f5674a0079 89 #ifndef DEFAULT_SCRATCH_PAGE
bluetooth_mdw 74:a8f5674a0079 90 #define DEFAULT_SCRATCH_PAGE (PAGE_SIZE * (NRF_FICR->CODESIZE - 19))
bluetooth_mdw 74:a8f5674a0079 91 #endif
bluetooth_mdw 74:a8f5674a0079 92
bluetooth_mdw 74:a8f5674a0079 93 // Address of the end of the current program in FLASH memory.
bluetooth_mdw 74:a8f5674a0079 94 // This is recorded by the C/C++ linker, but the symbol name varies depending on which compiler is used.
bluetooth_mdw 74:a8f5674a0079 95 #if defined(__arm)
bluetooth_mdw 74:a8f5674a0079 96 extern uint32_t Image$$ER_IROM1$$RO$$Limit;
bluetooth_mdw 74:a8f5674a0079 97 #define FLASH_PROGRAM_END (uint32_t) (&Image$$ER_IROM1$$RO$$Limit)
bluetooth_mdw 74:a8f5674a0079 98 #else
bluetooth_mdw 74:a8f5674a0079 99 extern uint32_t __etext;
bluetooth_mdw 74:a8f5674a0079 100 #define FLASH_PROGRAM_END (uint32_t) (&__etext)
bluetooth_mdw 74:a8f5674a0079 101 #endif
bluetooth_mdw 74:a8f5674a0079 102
bluetooth_mdw 74:a8f5674a0079 103
Jonathan Austin 1:8aa5cdb4ab67 104 // Enables or disables the MicroBitHeapllocator. Note that if disabled, no reuse of the SRAM normally
Jonathan Austin 1:8aa5cdb4ab67 105 // reserved for SoftDevice is possible, and out of memory condition will no longer be trapped...
Jonathan Austin 1:8aa5cdb4ab67 106 // i.e. panic() will no longer be triggered on memory full conditions.
Jonathan Austin 1:8aa5cdb4ab67 107 #ifndef MICROBIT_HEAP_ALLOCATOR
Jonathan Austin 1:8aa5cdb4ab67 108 #define MICROBIT_HEAP_ALLOCATOR 1
Jonathan Austin 1:8aa5cdb4ab67 109 #endif
Jonathan Austin 1:8aa5cdb4ab67 110
Jonathan Austin 1:8aa5cdb4ab67 111 // Block size used by the allocator in bytes.
Jonathan Austin 1:8aa5cdb4ab67 112 // n.b. Currently only 32 bits (4 bytes) is supported.
Jonathan Austin 1:8aa5cdb4ab67 113 #ifndef MICROBIT_HEAP_BLOCK_SIZE
Jonathan Austin 1:8aa5cdb4ab67 114 #define MICROBIT_HEAP_BLOCK_SIZE 4
Jonathan Austin 1:8aa5cdb4ab67 115 #endif
Jonathan Austin 1:8aa5cdb4ab67 116
Jonathan Austin 1:8aa5cdb4ab67 117 // The proportion of SRAM available on the mbed heap to reserve for the micro:bit heap.
Jonathan Austin 1:8aa5cdb4ab67 118 #ifndef MICROBIT_NESTED_HEAP_SIZE
Jonathan Austin 1:8aa5cdb4ab67 119 #define MICROBIT_NESTED_HEAP_SIZE 0.75
Jonathan Austin 1:8aa5cdb4ab67 120 #endif
Jonathan Austin 1:8aa5cdb4ab67 121
Jonathan Austin 1:8aa5cdb4ab67 122 // If defined, reuse any unused SRAM normally reserved for SoftDevice (Nordic's memory resident BLE stack) as heap memory.
Jonathan Austin 1:8aa5cdb4ab67 123 // The amount of memory reused depends upon whether or not BLE is enabled using MICROBIT_BLE_ENABLED.
Jonathan Austin 1:8aa5cdb4ab67 124 // Set '1' to enable.
Jonathan Austin 1:8aa5cdb4ab67 125 #ifndef MICROBIT_HEAP_REUSE_SD
Jonathan Austin 1:8aa5cdb4ab67 126 #define MICROBIT_HEAP_REUSE_SD 1
Jonathan Austin 1:8aa5cdb4ab67 127 #endif
Jonathan Austin 1:8aa5cdb4ab67 128
Jonathan Austin 1:8aa5cdb4ab67 129 // The amount of memory allocated to Soft Device to hold its BLE GATT table.
Jonathan Austin 1:8aa5cdb4ab67 130 // For standard S110 builds, this should be word aligned and in the range 0x300 - 0x700.
Jonathan Austin 1:8aa5cdb4ab67 131 // 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 132 #ifndef MICROBIT_SD_GATT_TABLE_SIZE
Jonathan Austin 1:8aa5cdb4ab67 133 #define MICROBIT_SD_GATT_TABLE_SIZE 0x300
Jonathan Austin 1:8aa5cdb4ab67 134 #endif
Jonathan Austin 1:8aa5cdb4ab67 135
Jonathan Austin 1:8aa5cdb4ab67 136 //
Jonathan Austin 1:8aa5cdb4ab67 137 // Fiber scheduler configuration
Jonathan Austin 1:8aa5cdb4ab67 138 //
Jonathan Austin 1:8aa5cdb4ab67 139
Jonathan Austin 1:8aa5cdb4ab67 140 // Scheduling quantum (milliseconds)
Jonathan Austin 1:8aa5cdb4ab67 141 // Also used to drive the micro:bit runtime system ticker.
Jonathan Austin 1:8aa5cdb4ab67 142 #ifndef SYSTEM_TICK_PERIOD_MS
Jonathan Austin 1:8aa5cdb4ab67 143 #define SYSTEM_TICK_PERIOD_MS 6
Jonathan Austin 1:8aa5cdb4ab67 144 #endif
Jonathan Austin 1:8aa5cdb4ab67 145
Jonathan Austin 1:8aa5cdb4ab67 146 //
Jonathan Austin 1:8aa5cdb4ab67 147 // Message Bus:
Jonathan Austin 1:8aa5cdb4ab67 148 // Default behaviour for event handlers, if not specified in the listen() call
Jonathan Austin 1:8aa5cdb4ab67 149 //
Jonathan Austin 1:8aa5cdb4ab67 150 // Permissable values are:
Jonathan Austin 1:8aa5cdb4ab67 151 // MESSAGE_BUS_LISTENER_REENTRANT
Jonathan Austin 1:8aa5cdb4ab67 152 // MESSAGE_BUS_LISTENER_QUEUE_IF_BUSY
Jonathan Austin 1:8aa5cdb4ab67 153 // MESSAGE_BUS_LISTENER_DROP_IF_BUSY
Jonathan Austin 1:8aa5cdb4ab67 154 // MESSAGE_BUS_LISTENER_IMMEDIATE
Jonathan Austin 1:8aa5cdb4ab67 155
Jonathan Austin 1:8aa5cdb4ab67 156 #ifndef EVENT_LISTENER_DEFAULT_FLAGS
Jonathan Austin 1:8aa5cdb4ab67 157 #define EVENT_LISTENER_DEFAULT_FLAGS MESSAGE_BUS_LISTENER_QUEUE_IF_BUSY
Jonathan Austin 1:8aa5cdb4ab67 158 #endif
Jonathan Austin 1:8aa5cdb4ab67 159
Jonathan Austin 1:8aa5cdb4ab67 160 //
Jonathan Austin 1:8aa5cdb4ab67 161 // Maximum event queue depth. If a queue exceeds this depth, further events will be dropped.
Jonathan Austin 1:8aa5cdb4ab67 162 // Used to prevent message queues growing uncontrollably due to badly behaved user code and causing panic conditions.
Jonathan Austin 1:8aa5cdb4ab67 163 //
Jonathan Austin 1:8aa5cdb4ab67 164 #ifndef MESSAGE_BUS_LISTENER_MAX_QUEUE_DEPTH
Jonathan Austin 1:8aa5cdb4ab67 165 #define MESSAGE_BUS_LISTENER_MAX_QUEUE_DEPTH 10
Jonathan Austin 1:8aa5cdb4ab67 166 #endif
Jonathan Austin 1:8aa5cdb4ab67 167
Jonathan Austin 1:8aa5cdb4ab67 168 //
Jonathan Austin 1:8aa5cdb4ab67 169 // Core micro:bit services
Jonathan Austin 1:8aa5cdb4ab67 170 //
Jonathan Austin 1:8aa5cdb4ab67 171
Jonathan Austin 1:8aa5cdb4ab67 172 // To reduce memory cost and complexity, the micro:bit allows components to register for
Jonathan Austin 1:8aa5cdb4ab67 173 // periodic callback events during interrupt context, which occur every scheduling quantum (FIBER_TICK_PERIOD_MS)
Jonathan Austin 1:8aa5cdb4ab67 174 // This defines the maximum size of interrupt callback list.
Jonathan Austin 1:8aa5cdb4ab67 175 #ifndef MICROBIT_SYSTEM_COMPONENTS
Jonathan Austin 1:8aa5cdb4ab67 176 #define MICROBIT_SYSTEM_COMPONENTS 10
Jonathan Austin 1:8aa5cdb4ab67 177 #endif
Jonathan Austin 1:8aa5cdb4ab67 178
Jonathan Austin 1:8aa5cdb4ab67 179 // To reduce memory cost and complexity, the micro:bit allows components to register for
Jonathan Austin 1:8aa5cdb4ab67 180 // periodic callback events when the processor is idle.
Jonathan Austin 1:8aa5cdb4ab67 181 // This defines the maximum size of the idle callback list.
Jonathan Austin 1:8aa5cdb4ab67 182 #ifndef MICROBIT_IDLE_COMPONENTS
Jonathan Austin 1:8aa5cdb4ab67 183 #define MICROBIT_IDLE_COMPONENTS 6
Jonathan Austin 1:8aa5cdb4ab67 184 #endif
Jonathan Austin 1:8aa5cdb4ab67 185
Jonathan Austin 1:8aa5cdb4ab67 186 //
Jonathan Austin 1:8aa5cdb4ab67 187 // BLE options
Jonathan Austin 1:8aa5cdb4ab67 188 //
Jonathan Austin 1:8aa5cdb4ab67 189 // The BLE stack is very memory hungry. Each service can therefore be compiled in or out
Jonathan Austin 1:8aa5cdb4ab67 190 // by enabling/disabling the options below.
Jonathan Austin 1:8aa5cdb4ab67 191 //
Jonathan Austin 1:8aa5cdb4ab67 192 // n.b. The minimum set of services to enable over the air programming of the device will
Jonathan Austin 1:8aa5cdb4ab67 193 // still be brought up in pairing mode regardless of the settings below.
Jonathan Austin 1:8aa5cdb4ab67 194 //
Jonathan Austin 1:8aa5cdb4ab67 195
Jonathan Austin 1:8aa5cdb4ab67 196 // Enable/Disable BLE during normal operation.
Jonathan Austin 1:8aa5cdb4ab67 197 // Set '1' to enable.
Jonathan Austin 1:8aa5cdb4ab67 198 #ifndef MICROBIT_BLE_ENABLED
Jonathan Austin 1:8aa5cdb4ab67 199 #define MICROBIT_BLE_ENABLED 1
Jonathan Austin 1:8aa5cdb4ab67 200 #endif
Jonathan Austin 1:8aa5cdb4ab67 201
Jonathan Austin 1:8aa5cdb4ab67 202 // Enable/Disable BLE pairing mode mode at power up.
Jonathan Austin 1:8aa5cdb4ab67 203 // Set '1' to enable.
Jonathan Austin 1:8aa5cdb4ab67 204 #ifndef MICROBIT_BLE_PAIRING_MODE
Jonathan Austin 1:8aa5cdb4ab67 205 #define MICROBIT_BLE_PAIRING_MODE 1
Jonathan Austin 1:8aa5cdb4ab67 206 #endif
Jonathan Austin 1:8aa5cdb4ab67 207
Jonathan Austin 1:8aa5cdb4ab67 208 // Enable/Disable the use of private resolvable addresses.
Jonathan Austin 1:8aa5cdb4ab67 209 // Set '1' to enable.
Jonathan Austin 1:8aa5cdb4ab67 210 // n.b. This is known to be a feature that suffers compatibility issues with many BLE central devices.
Jonathan Austin 1:8aa5cdb4ab67 211 #ifndef MICROBIT_BLE_PRIVATE_ADDRESSES
Jonathan Austin 1:8aa5cdb4ab67 212 #define MICROBIT_BLE_PRIVATE_ADDRESSES 0
Jonathan Austin 1:8aa5cdb4ab67 213 #endif
Jonathan Austin 1:8aa5cdb4ab67 214
Jonathan Austin 1:8aa5cdb4ab67 215 // Convenience option to enable / disable BLE security entirely
Jonathan Austin 1:8aa5cdb4ab67 216 // Open BLE links are not secure, but commonly used during the development of BLE services
Jonathan Austin 1:8aa5cdb4ab67 217 // Set '1' to disable all secuity
Jonathan Austin 1:8aa5cdb4ab67 218 #ifndef MICROBIT_BLE_OPEN
Jonathan Austin 1:8aa5cdb4ab67 219 #define MICROBIT_BLE_OPEN 0
Jonathan Austin 1:8aa5cdb4ab67 220 #endif
Jonathan Austin 1:8aa5cdb4ab67 221
Jonathan Austin 1:8aa5cdb4ab67 222 // Configure for open BLE operation if so configured
Jonathan Austin 1:8aa5cdb4ab67 223 #if (MICROBIT_BLE_OPEN == 1)
Jonathan Austin 1:8aa5cdb4ab67 224 #define MICROBIT_BLE_SECURITY_LEVEL SECURITY_MODE_ENCRYPTION_OPEN_LINK
Jonathan Austin 1:8aa5cdb4ab67 225 #define MICROBIT_BLE_WHITELIST 0
Jonathan Austin 1:8aa5cdb4ab67 226 #define MICROBIT_BLE_ADVERTISING_TIMEOUT 0
Jonathan Austin 1:8aa5cdb4ab67 227 #define MICROBIT_BLE_DEFAULT_TX_POWER 6
Jonathan Austin 1:8aa5cdb4ab67 228 #endif
Jonathan Austin 1:8aa5cdb4ab67 229
Jonathan Austin 1:8aa5cdb4ab67 230
Jonathan Austin 1:8aa5cdb4ab67 231 // Define the default, global BLE security requirements for MicroBit BLE services
Jonathan Austin 1:8aa5cdb4ab67 232 // May be one of the following options (see mbed's SecurityManager class implementaiton detail)
Jonathan Austin 1:8aa5cdb4ab67 233 // SECURITY_MODE_ENCRYPTION_OPEN_LINK: No bonding, encryption, or whitelisting required.
Jonathan Austin 1:8aa5cdb4ab67 234 // SECURITY_MODE_ENCRYPTION_NO_MITM: Bonding, encyption and whitelisting but no passkey.
Jonathan Austin 1:8aa5cdb4ab67 235 // SECURITY_MODE_ENCRYPTION_WITH_MITM: Bonding, encrytion and whitelisting with passkey authentication.
Jonathan Austin 1:8aa5cdb4ab67 236 //
Jonathan Austin 1:8aa5cdb4ab67 237 #ifndef MICROBIT_BLE_SECURITY_LEVEL
Jonathan Austin 1:8aa5cdb4ab67 238 #define MICROBIT_BLE_SECURITY_LEVEL SECURITY_MODE_ENCRYPTION_WITH_MITM
Jonathan Austin 1:8aa5cdb4ab67 239 #endif
Jonathan Austin 1:8aa5cdb4ab67 240
Jonathan Austin 1:8aa5cdb4ab67 241 // Enable/Disable the use of BLE whitelisting.
Jonathan Austin 1:8aa5cdb4ab67 242 // If enabled, the micro:bit will only respond to connection requests from
Jonathan Austin 1:8aa5cdb4ab67 243 // known, bonded devices.
Jonathan Austin 1:8aa5cdb4ab67 244 #ifndef MICROBIT_BLE_WHITELIST
Jonathan Austin 1:8aa5cdb4ab67 245 #define MICROBIT_BLE_WHITELIST 1
Jonathan Austin 1:8aa5cdb4ab67 246 #endif
Jonathan Austin 1:8aa5cdb4ab67 247
Jonathan Austin 1:8aa5cdb4ab67 248 // Define the period of time for which the BLE stack will advertise (seconds)
Jonathan Austin 1:8aa5cdb4ab67 249 // Afer this period, advertising will cease. Set to '0' for no timeout (always advertise).
Jonathan Austin 1:8aa5cdb4ab67 250 #ifndef MICROBIT_BLE_ADVERTISING_TIMEOUT
Jonathan Austin 1:8aa5cdb4ab67 251 #define MICROBIT_BLE_ADVERTISING_TIMEOUT 0
Jonathan Austin 1:8aa5cdb4ab67 252 #endif
Jonathan Austin 1:8aa5cdb4ab67 253
Jonathan Austin 1:8aa5cdb4ab67 254 // Defines default power level of the BLE radio transmitter.
Jonathan Austin 1:8aa5cdb4ab67 255 // Valid values are in the range 0..7 inclusive, with 0 being the lowest power and 7 the highest power.
Jonathan Austin 1:8aa5cdb4ab67 256 // Based on trials undertaken by the BBC, the radio is normally set to its lowest power level
Jonathan Austin 1:8aa5cdb4ab67 257 // to best protect children's privacy.
Jonathan Austin 1:8aa5cdb4ab67 258 #ifndef MICROBIT_BLE_DEFAULT_TX_POWER
Jonathan Austin 1:8aa5cdb4ab67 259 #define MICROBIT_BLE_DEFAULT_TX_POWER 0
Jonathan Austin 1:8aa5cdb4ab67 260 #endif
Jonathan Austin 1:8aa5cdb4ab67 261
Jonathan Austin 1:8aa5cdb4ab67 262 // Enable/Disable BLE Service: MicroBitDFU
Jonathan Austin 1:8aa5cdb4ab67 263 // This allows over the air programming during normal operation.
Jonathan Austin 1:8aa5cdb4ab67 264 // Set '1' to enable.
Jonathan Austin 1:8aa5cdb4ab67 265 #ifndef MICROBIT_BLE_DFU_SERVICE
Jonathan Austin 1:8aa5cdb4ab67 266 #define MICROBIT_BLE_DFU_SERVICE 1
Jonathan Austin 1:8aa5cdb4ab67 267 #endif
Jonathan Austin 1:8aa5cdb4ab67 268
bluetooth_mdw 74:a8f5674a0079 269 // Enable/Disable availability of Eddystone URL APIs
bluetooth_mdw 74:a8f5674a0079 270 // Set '1' to enable.
bluetooth_mdw 74:a8f5674a0079 271 #ifndef MICROBIT_BLE_EDDYSTONE_URL
bluetooth_mdw 74:a8f5674a0079 272 #define MICROBIT_BLE_EDDYSTONE_URL 1
bluetooth_mdw 74:a8f5674a0079 273 #endif
bluetooth_mdw 74:a8f5674a0079 274
bluetooth_mdw 74:a8f5674a0079 275 // Enable/Disable availability of Eddystone UID APIs
bluetooth_mdw 74:a8f5674a0079 276 // Set '1' to enable.
bluetooth_mdw 74:a8f5674a0079 277 #ifndef MICROBIT_BLE_EDDYSTONE_UID
bluetooth_mdw 74:a8f5674a0079 278 #define MICROBIT_BLE_EDDYSTONE_UID 0
bluetooth_mdw 74:a8f5674a0079 279 #endif
bluetooth_mdw 74:a8f5674a0079 280
Jonathan Austin 1:8aa5cdb4ab67 281 // Enable/Disable BLE Service: MicroBitEventService
Jonathan Austin 1:8aa5cdb4ab67 282 // This allows routing of events from the micro:bit message bus over BLE.
Jonathan Austin 1:8aa5cdb4ab67 283 // Set '1' to enable.
Jonathan Austin 1:8aa5cdb4ab67 284 #ifndef MICROBIT_BLE_EVENT_SERVICE
Jonathan Austin 1:8aa5cdb4ab67 285 #define MICROBIT_BLE_EVENT_SERVICE 1
Jonathan Austin 1:8aa5cdb4ab67 286 #endif
Jonathan Austin 1:8aa5cdb4ab67 287
Jonathan Austin 1:8aa5cdb4ab67 288 // Enable/Disable BLE Service: MicroBitDeviceInformationService
Jonathan Austin 1:8aa5cdb4ab67 289 // This enables the standard BLE device information service.
Jonathan Austin 1:8aa5cdb4ab67 290 // Set '1' to enable.
Jonathan Austin 1:8aa5cdb4ab67 291 #ifndef MICROBIT_BLE_DEVICE_INFORMATION_SERVICE
Jonathan Austin 1:8aa5cdb4ab67 292 #define MICROBIT_BLE_DEVICE_INFORMATION_SERVICE 1
Jonathan Austin 1:8aa5cdb4ab67 293 #endif
Jonathan Austin 1:8aa5cdb4ab67 294
Jonathan Austin 1:8aa5cdb4ab67 295 //
Jonathan Austin 1:8aa5cdb4ab67 296 // Accelerometer options
Jonathan Austin 1:8aa5cdb4ab67 297 //
Jonathan Austin 1:8aa5cdb4ab67 298
Jonathan Austin 1:8aa5cdb4ab67 299 // Enable this to read 10 bits of data from the acclerometer.
Jonathan Austin 1:8aa5cdb4ab67 300 // Otherwise, 8 bits are used.
Jonathan Austin 1:8aa5cdb4ab67 301 // Set '1' to enable.
Jonathan Austin 1:8aa5cdb4ab67 302 #ifndef USE_ACCEL_LSB
Jonathan Austin 1:8aa5cdb4ab67 303 #define USE_ACCEL_LSB 0
Jonathan Austin 1:8aa5cdb4ab67 304 #endif
Jonathan Austin 1:8aa5cdb4ab67 305
Jonathan Austin 1:8aa5cdb4ab67 306 //
Jonathan Austin 1:8aa5cdb4ab67 307 // Display options
Jonathan Austin 1:8aa5cdb4ab67 308 //
Jonathan Austin 1:8aa5cdb4ab67 309
Jonathan Austin 1:8aa5cdb4ab67 310 // Selects the matrix configuration for the display driver.
Jonathan Austin 1:8aa5cdb4ab67 311 // Known, acceptable options are:
Jonathan Austin 1:8aa5cdb4ab67 312 //
Jonathan Austin 1:8aa5cdb4ab67 313 #define MICROBUG_REFERENCE_DEVICE 1
Jonathan Austin 1:8aa5cdb4ab67 314 #define MICROBIT_3X9 2
Jonathan Austin 1:8aa5cdb4ab67 315 #define MICROBIT_SB1 3
Jonathan Austin 1:8aa5cdb4ab67 316 #define MICROBIT_SB2 4
Jonathan Austin 1:8aa5cdb4ab67 317
Jonathan Austin 1:8aa5cdb4ab67 318 #ifndef MICROBIT_DISPLAY_TYPE
Jonathan Austin 1:8aa5cdb4ab67 319 #define MICROBIT_DISPLAY_TYPE MICROBIT_SB2
Jonathan Austin 1:8aa5cdb4ab67 320 #endif
Jonathan Austin 1:8aa5cdb4ab67 321
Jonathan Austin 1:8aa5cdb4ab67 322 // Selects the minimum permissable brightness level for the device
Jonathan Austin 1:8aa5cdb4ab67 323 // in the region of 0 (off) to 255 (full brightness)
Jonathan Austin 1:8aa5cdb4ab67 324 #ifndef MICROBIT_DISPLAY_MINIMUM_BRIGHTNESS
Jonathan Austin 1:8aa5cdb4ab67 325 #define MICROBIT_DISPLAY_MINIMUM_BRIGHTNESS 1
Jonathan Austin 1:8aa5cdb4ab67 326 #endif
Jonathan Austin 1:8aa5cdb4ab67 327
Jonathan Austin 1:8aa5cdb4ab67 328 // Selects the maximum permissable brightness level for the device
Jonathan Austin 1:8aa5cdb4ab67 329 // in the region of 0 (off) to 255 (full brightness)
Jonathan Austin 1:8aa5cdb4ab67 330 #ifndef MICROBIT_DISPLAY_MAXIMUM_BRIGHTNESS
Jonathan Austin 1:8aa5cdb4ab67 331 #define MICROBIT_DISPLAY_MAXIMUM_BRIGHTNESS 255
Jonathan Austin 1:8aa5cdb4ab67 332 #endif
Jonathan Austin 1:8aa5cdb4ab67 333
Jonathan Austin 1:8aa5cdb4ab67 334 // Selects the default brightness for the display
Jonathan Austin 1:8aa5cdb4ab67 335 // in the region of zero (off) to 255 (full brightness)
Jonathan Austin 1:8aa5cdb4ab67 336 #ifndef MICROBIT_DISPLAY_DEFAULT_BRIGHTNESS
Jonathan Austin 1:8aa5cdb4ab67 337 #define MICROBIT_DISPLAY_DEFAULT_BRIGHTNESS MICROBIT_DISPLAY_MAXIMUM_BRIGHTNESS
Jonathan Austin 1:8aa5cdb4ab67 338 #endif
Jonathan Austin 1:8aa5cdb4ab67 339
Jonathan Austin 1:8aa5cdb4ab67 340 // Selects the default scroll speed for the display.
Jonathan Austin 1:8aa5cdb4ab67 341 // The time taken to move a single pixel (ms).
Jonathan Austin 1:8aa5cdb4ab67 342 #ifndef MICROBIT_DEFAULT_SCROLL_SPEED
Jonathan Austin 1:8aa5cdb4ab67 343 #define MICROBIT_DEFAULT_SCROLL_SPEED 120
Jonathan Austin 1:8aa5cdb4ab67 344 #endif
Jonathan Austin 1:8aa5cdb4ab67 345
Jonathan Austin 1:8aa5cdb4ab67 346 // Selects the number of pixels a scroll will move in each quantum.
Jonathan Austin 1:8aa5cdb4ab67 347 #ifndef MICROBIT_DEFAULT_SCROLL_STRIDE
Jonathan Austin 1:8aa5cdb4ab67 348 #define MICROBIT_DEFAULT_SCROLL_STRIDE -1
Jonathan Austin 1:8aa5cdb4ab67 349 #endif
Jonathan Austin 1:8aa5cdb4ab67 350
Jonathan Austin 1:8aa5cdb4ab67 351 // Selects the time each character will be shown on the display during print operations.
Jonathan Austin 1:8aa5cdb4ab67 352 // The time each character is shown on the screen (ms).
Jonathan Austin 1:8aa5cdb4ab67 353 #ifndef MICROBIT_DEFAULT_PRINT_SPEED
Jonathan Austin 1:8aa5cdb4ab67 354 #define MICROBIT_DEFAULT_PRINT_SPEED 400
Jonathan Austin 1:8aa5cdb4ab67 355 #endif
Jonathan Austin 1:8aa5cdb4ab67 356
Jonathan Austin 1:8aa5cdb4ab67 357 //Configures the default serial mode used by serial read and send calls.
Jonathan Austin 1:8aa5cdb4ab67 358 #ifndef MICROBIT_DEFAULT_SERIAL_MODE
Jonathan Austin 1:8aa5cdb4ab67 359 #define MICROBIT_DEFAULT_SERIAL_MODE SYNC_SLEEP
Jonathan Austin 1:8aa5cdb4ab67 360 #endif
Jonathan Austin 1:8aa5cdb4ab67 361
bluetooth_mdw 74:a8f5674a0079 362 //
bluetooth_mdw 74:a8f5674a0079 363 // File System configuration defaults
bluetooth_mdw 74:a8f5674a0079 364 //
bluetooth_mdw 74:a8f5674a0079 365
bluetooth_mdw 74:a8f5674a0079 366 //
bluetooth_mdw 74:a8f5674a0079 367 // Defines the logical block size for the file system.
bluetooth_mdw 74:a8f5674a0079 368 // Must be a factor of the physical PAGE_SIZE (ideally a power of two less).
bluetooth_mdw 74:a8f5674a0079 369 //
bluetooth_mdw 74:a8f5674a0079 370 #ifndef MBFS_BLOCK_SIZE
bluetooth_mdw 74:a8f5674a0079 371 #define MBFS_BLOCK_SIZE 256
bluetooth_mdw 74:a8f5674a0079 372 #endif
bluetooth_mdw 74:a8f5674a0079 373
bluetooth_mdw 74:a8f5674a0079 374 //
bluetooth_mdw 74:a8f5674a0079 375 // FileSystem writeback cache size, in bytes. Defines how many bytes will be stored
bluetooth_mdw 74:a8f5674a0079 376 // in RAM before being written back to FLASH. Set to zero to disable this feature.
bluetooth_mdw 74:a8f5674a0079 377 // Should be <= MBFS_BLOCK_SIZE.
bluetooth_mdw 74:a8f5674a0079 378 //
bluetooth_mdw 74:a8f5674a0079 379 #ifndef MBFS_CACHE_SIZE
bluetooth_mdw 74:a8f5674a0079 380 #define MBFS_CACHE_SIZE 16
bluetooth_mdw 74:a8f5674a0079 381 #endif
Jonathan Austin 1:8aa5cdb4ab67 382
Jonathan Austin 1:8aa5cdb4ab67 383 //
LancasterUniversity 66:2fc7d7c2fffc 384 // I/O Options
LancasterUniversity 66:2fc7d7c2fffc 385 //
LancasterUniversity 66:2fc7d7c2fffc 386
LancasterUniversity 66:2fc7d7c2fffc 387
LancasterUniversity 66:2fc7d7c2fffc 388 //
LancasterUniversity 66:2fc7d7c2fffc 389 // Define the default mode in which the digital input pins are configured.
LancasterUniversity 66:2fc7d7c2fffc 390 // valid options are PullDown, PullUp and PullNone.
LancasterUniversity 66:2fc7d7c2fffc 391 //
LancasterUniversity 66:2fc7d7c2fffc 392 #ifndef MICROBIT_DEFAULT_PULLMODE
LancasterUniversity 66:2fc7d7c2fffc 393 #define MICROBIT_DEFAULT_PULLMODE PullDown
LancasterUniversity 66:2fc7d7c2fffc 394 #endif
LancasterUniversity 66:2fc7d7c2fffc 395
LancasterUniversity 66:2fc7d7c2fffc 396 //
Jonathan Austin 1:8aa5cdb4ab67 397 // Panic options
Jonathan Austin 1:8aa5cdb4ab67 398 //
Jonathan Austin 1:8aa5cdb4ab67 399
Jonathan Austin 1:8aa5cdb4ab67 400 // Enable this to invoke a panic on out of memory conditions.
Jonathan Austin 1:8aa5cdb4ab67 401 // Set '1' to enable.
Jonathan Austin 1:8aa5cdb4ab67 402 #ifndef MICROBIT_PANIC_HEAP_FULL
Jonathan Austin 1:8aa5cdb4ab67 403 #define MICROBIT_PANIC_HEAP_FULL 1
Jonathan Austin 1:8aa5cdb4ab67 404 #endif
Jonathan Austin 1:8aa5cdb4ab67 405
Jonathan Austin 1:8aa5cdb4ab67 406 //
Jonathan Austin 1:8aa5cdb4ab67 407 // Debug options
Jonathan Austin 1:8aa5cdb4ab67 408 //
Jonathan Austin 1:8aa5cdb4ab67 409
Jonathan Austin 1:8aa5cdb4ab67 410 // Enable this to route debug messages through the USB serial interface.
Jonathan Austin 1:8aa5cdb4ab67 411 // n.b. This also disables the user serial port 'uBit.serial'.
Jonathan Austin 1:8aa5cdb4ab67 412 // Set '1' to enable.
Jonathan Austin 1:8aa5cdb4ab67 413 #ifndef MICROBIT_DBG
Jonathan Austin 1:8aa5cdb4ab67 414 #define MICROBIT_DBG 0
Jonathan Austin 1:8aa5cdb4ab67 415 #endif
Jonathan Austin 1:8aa5cdb4ab67 416
Jonathan Austin 1:8aa5cdb4ab67 417 // Enable this to receive diagnostic messages from the heap allocator via the USB serial interface.
Jonathan Austin 1:8aa5cdb4ab67 418 // n.b. This requires MICROBIT_DBG to be defined.
Jonathan Austin 1:8aa5cdb4ab67 419 // Set '1' to enable.
Jonathan Austin 1:8aa5cdb4ab67 420 #ifndef MICROBIT_HEAP_DBG
Jonathan Austin 1:8aa5cdb4ab67 421 #define MICROBIT_HEAP_DBG 0
Jonathan Austin 1:8aa5cdb4ab67 422 #endif
Jonathan Austin 1:8aa5cdb4ab67 423
Jonathan Austin 1:8aa5cdb4ab67 424 // Versioning options.
Jonathan Austin 1:8aa5cdb4ab67 425 // We use semantic versioning (http://semver.org/) to identify differnet versions of the micro:bit runtime.
Jonathan Austin 1:8aa5cdb4ab67 426 // Where possible we use yotta (an ARM mbed build tool) to help us track versions.
Jonathan Austin 1:8aa5cdb4ab67 427 // if this isn't available, it can be defined manually as a configuration option.
Jonathan Austin 1:8aa5cdb4ab67 428 //
Jonathan Austin 1:8aa5cdb4ab67 429 #ifndef MICROBIT_DAL_VERSION
Jonathan Austin 1:8aa5cdb4ab67 430 #define MICROBIT_DAL_VERSION "unknown"
Jonathan Austin 1:8aa5cdb4ab67 431 #endif
Jonathan Austin 1:8aa5cdb4ab67 432
Jonathan Austin 1:8aa5cdb4ab67 433
Jonathan Austin 1:8aa5cdb4ab67 434 //
Jonathan Austin 1:8aa5cdb4ab67 435 // Helper macro used by the micro:bit runtime to determine if a boolean configuration option is set.
Jonathan Austin 1:8aa5cdb4ab67 436 //
Jonathan Austin 1:8aa5cdb4ab67 437 #define CONFIG_ENABLED(X) (X == 1)
Jonathan Austin 1:8aa5cdb4ab67 438 #define CONFIG_DISABLED(X) (X != 1)
Jonathan Austin 1:8aa5cdb4ab67 439
Jonathan Austin 1:8aa5cdb4ab67 440 #if CONFIG_ENABLED(MICROBIT_HEAP_ALLOCATOR)
Jonathan Austin 1:8aa5cdb4ab67 441 #include "MicroBitHeapAllocator.h"
Jonathan Austin 1:8aa5cdb4ab67 442 #endif
Jonathan Austin 1:8aa5cdb4ab67 443
Jonathan Austin 1:8aa5cdb4ab67 444 #if CONFIG_ENABLED(MICROBIT_DBG)
Jonathan Austin 1:8aa5cdb4ab67 445 extern RawSerial* SERIAL_DEBUG;
Jonathan Austin 1:8aa5cdb4ab67 446 #endif
Jonathan Austin 1:8aa5cdb4ab67 447
bluetooth_mdw 74:a8f5674a0079 448 #endif