sen data via radio to other microbits accept command via radio bufixes
Dependencies: BLE_API nRF51822 mbed-dev-bin
inc/core/MicroBitConfig.h@1:8aa5cdb4ab67, 2016-04-07 (annotated)
- Committer:
- Jonathan Austin
- Date:
- Thu Apr 07 01:33:22 2016 +0100
- Revision:
- 1:8aa5cdb4ab67
- Child:
- 27:2f494ead23de
Synchronized with git rev 55cb9199
Who changed what in which revision?
User | Revision | Line number | New 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" |
Jonathan Austin |
1:8aa5cdb4ab67 | 34 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 35 | // |
Jonathan Austin |
1:8aa5cdb4ab67 | 36 | // Memory configuration |
Jonathan Austin |
1:8aa5cdb4ab67 | 37 | // |
Jonathan Austin |
1:8aa5cdb4ab67 | 38 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 39 | // The start address of usable RAM memory. |
Jonathan Austin |
1:8aa5cdb4ab67 | 40 | #ifndef MICROBIT_SRAM_BASE |
Jonathan Austin |
1:8aa5cdb4ab67 | 41 | #define MICROBIT_SRAM_BASE 0x20000008 |
Jonathan Austin |
1:8aa5cdb4ab67 | 42 | #endif |
Jonathan Austin |
1:8aa5cdb4ab67 | 43 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 44 | // Physical address of the top of SRAM. |
Jonathan Austin |
1:8aa5cdb4ab67 | 45 | #ifndef MICROBIT_SRAM_END |
Jonathan Austin |
1:8aa5cdb4ab67 | 46 | #define MICROBIT_SRAM_END 0x20004000 |
Jonathan Austin |
1:8aa5cdb4ab67 | 47 | #endif |
Jonathan Austin |
1:8aa5cdb4ab67 | 48 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 49 | // The end address of memory normally reserved for Soft Device. |
Jonathan Austin |
1:8aa5cdb4ab67 | 50 | #ifndef MICROBIT_SD_LIMIT |
Jonathan Austin |
1:8aa5cdb4ab67 | 51 | #define MICROBIT_SD_LIMIT 0x20002000 |
Jonathan Austin |
1:8aa5cdb4ab67 | 52 | #endif |
Jonathan Austin |
1:8aa5cdb4ab67 | 53 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 54 | // The physical address in memory of the Soft Device GATT table. |
Jonathan Austin |
1:8aa5cdb4ab67 | 55 | #ifndef MICROBIT_SD_GATT_TABLE_START |
Jonathan Austin |
1:8aa5cdb4ab67 | 56 | #define MICROBIT_SD_GATT_TABLE_START 0x20001900 |
Jonathan Austin |
1:8aa5cdb4ab67 | 57 | #endif |
Jonathan Austin |
1:8aa5cdb4ab67 | 58 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 59 | // Physical address of the top of the system stack (on mbed-classic this is the top of SRAM) |
Jonathan Austin |
1:8aa5cdb4ab67 | 60 | #ifndef CORTEX_M0_STACK_BASE |
Jonathan Austin |
1:8aa5cdb4ab67 | 61 | #define CORTEX_M0_STACK_BASE MICROBIT_SRAM_END |
Jonathan Austin |
1:8aa5cdb4ab67 | 62 | #endif |
Jonathan Austin |
1:8aa5cdb4ab67 | 63 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 64 | // Amount of memory reserved for the stack at the end of memory (bytes). |
Jonathan Austin |
1:8aa5cdb4ab67 | 65 | #ifndef MICROBIT_STACK_SIZE |
Jonathan Austin |
1:8aa5cdb4ab67 | 66 | #define MICROBIT_STACK_SIZE 2048 |
Jonathan Austin |
1:8aa5cdb4ab67 | 67 | #endif |
Jonathan Austin |
1:8aa5cdb4ab67 | 68 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 69 | // Physical address of the end of mbed heap space. |
Jonathan Austin |
1:8aa5cdb4ab67 | 70 | #ifndef MICROBIT_HEAP_END |
Jonathan Austin |
1:8aa5cdb4ab67 | 71 | #define MICROBIT_HEAP_END (CORTEX_M0_STACK_BASE - MICROBIT_STACK_SIZE) |
Jonathan Austin |
1:8aa5cdb4ab67 | 72 | #endif |
Jonathan Austin |
1:8aa5cdb4ab67 | 73 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 74 | // Enables or disables the MicroBitHeapllocator. Note that if disabled, no reuse of the SRAM normally |
Jonathan Austin |
1:8aa5cdb4ab67 | 75 | // reserved for SoftDevice is possible, and out of memory condition will no longer be trapped... |
Jonathan Austin |
1:8aa5cdb4ab67 | 76 | // i.e. panic() will no longer be triggered on memory full conditions. |
Jonathan Austin |
1:8aa5cdb4ab67 | 77 | #ifndef MICROBIT_HEAP_ALLOCATOR |
Jonathan Austin |
1:8aa5cdb4ab67 | 78 | #define MICROBIT_HEAP_ALLOCATOR 1 |
Jonathan Austin |
1:8aa5cdb4ab67 | 79 | #endif |
Jonathan Austin |
1:8aa5cdb4ab67 | 80 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 81 | // Block size used by the allocator in bytes. |
Jonathan Austin |
1:8aa5cdb4ab67 | 82 | // n.b. Currently only 32 bits (4 bytes) is supported. |
Jonathan Austin |
1:8aa5cdb4ab67 | 83 | #ifndef MICROBIT_HEAP_BLOCK_SIZE |
Jonathan Austin |
1:8aa5cdb4ab67 | 84 | #define MICROBIT_HEAP_BLOCK_SIZE 4 |
Jonathan Austin |
1:8aa5cdb4ab67 | 85 | #endif |
Jonathan Austin |
1:8aa5cdb4ab67 | 86 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 87 | // The proportion of SRAM available on the mbed heap to reserve for the micro:bit heap. |
Jonathan Austin |
1:8aa5cdb4ab67 | 88 | #ifndef MICROBIT_NESTED_HEAP_SIZE |
Jonathan Austin |
1:8aa5cdb4ab67 | 89 | #define MICROBIT_NESTED_HEAP_SIZE 0.75 |
Jonathan Austin |
1:8aa5cdb4ab67 | 90 | #endif |
Jonathan Austin |
1:8aa5cdb4ab67 | 91 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 92 | // If defined, reuse any unused SRAM normally reserved for SoftDevice (Nordic's memory resident BLE stack) as heap memory. |
Jonathan Austin |
1:8aa5cdb4ab67 | 93 | // The amount of memory reused depends upon whether or not BLE is enabled using MICROBIT_BLE_ENABLED. |
Jonathan Austin |
1:8aa5cdb4ab67 | 94 | // Set '1' to enable. |
Jonathan Austin |
1:8aa5cdb4ab67 | 95 | #ifndef MICROBIT_HEAP_REUSE_SD |
Jonathan Austin |
1:8aa5cdb4ab67 | 96 | #define MICROBIT_HEAP_REUSE_SD 1 |
Jonathan Austin |
1:8aa5cdb4ab67 | 97 | #endif |
Jonathan Austin |
1:8aa5cdb4ab67 | 98 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 99 | // The amount of memory allocated to Soft Device to hold its BLE GATT table. |
Jonathan Austin |
1:8aa5cdb4ab67 | 100 | // For standard S110 builds, this should be word aligned and in the range 0x300 - 0x700. |
Jonathan Austin |
1:8aa5cdb4ab67 | 101 | // 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 | 102 | #ifndef MICROBIT_SD_GATT_TABLE_SIZE |
Jonathan Austin |
1:8aa5cdb4ab67 | 103 | #define MICROBIT_SD_GATT_TABLE_SIZE 0x300 |
Jonathan Austin |
1:8aa5cdb4ab67 | 104 | #endif |
Jonathan Austin |
1:8aa5cdb4ab67 | 105 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 106 | // |
Jonathan Austin |
1:8aa5cdb4ab67 | 107 | // Fiber scheduler configuration |
Jonathan Austin |
1:8aa5cdb4ab67 | 108 | // |
Jonathan Austin |
1:8aa5cdb4ab67 | 109 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 110 | // Scheduling quantum (milliseconds) |
Jonathan Austin |
1:8aa5cdb4ab67 | 111 | // Also used to drive the micro:bit runtime system ticker. |
Jonathan Austin |
1:8aa5cdb4ab67 | 112 | #ifndef SYSTEM_TICK_PERIOD_MS |
Jonathan Austin |
1:8aa5cdb4ab67 | 113 | #define SYSTEM_TICK_PERIOD_MS 6 |
Jonathan Austin |
1:8aa5cdb4ab67 | 114 | #endif |
Jonathan Austin |
1:8aa5cdb4ab67 | 115 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 116 | // |
Jonathan Austin |
1:8aa5cdb4ab67 | 117 | // Message Bus: |
Jonathan Austin |
1:8aa5cdb4ab67 | 118 | // Default behaviour for event handlers, if not specified in the listen() call |
Jonathan Austin |
1:8aa5cdb4ab67 | 119 | // |
Jonathan Austin |
1:8aa5cdb4ab67 | 120 | // Permissable values are: |
Jonathan Austin |
1:8aa5cdb4ab67 | 121 | // MESSAGE_BUS_LISTENER_REENTRANT |
Jonathan Austin |
1:8aa5cdb4ab67 | 122 | // MESSAGE_BUS_LISTENER_QUEUE_IF_BUSY |
Jonathan Austin |
1:8aa5cdb4ab67 | 123 | // MESSAGE_BUS_LISTENER_DROP_IF_BUSY |
Jonathan Austin |
1:8aa5cdb4ab67 | 124 | // MESSAGE_BUS_LISTENER_IMMEDIATE |
Jonathan Austin |
1:8aa5cdb4ab67 | 125 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 126 | #ifndef EVENT_LISTENER_DEFAULT_FLAGS |
Jonathan Austin |
1:8aa5cdb4ab67 | 127 | #define EVENT_LISTENER_DEFAULT_FLAGS MESSAGE_BUS_LISTENER_QUEUE_IF_BUSY |
Jonathan Austin |
1:8aa5cdb4ab67 | 128 | #endif |
Jonathan Austin |
1:8aa5cdb4ab67 | 129 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 130 | // |
Jonathan Austin |
1:8aa5cdb4ab67 | 131 | // Maximum event queue depth. If a queue exceeds this depth, further events will be dropped. |
Jonathan Austin |
1:8aa5cdb4ab67 | 132 | // Used to prevent message queues growing uncontrollably due to badly behaved user code and causing panic conditions. |
Jonathan Austin |
1:8aa5cdb4ab67 | 133 | // |
Jonathan Austin |
1:8aa5cdb4ab67 | 134 | #ifndef MESSAGE_BUS_LISTENER_MAX_QUEUE_DEPTH |
Jonathan Austin |
1:8aa5cdb4ab67 | 135 | #define MESSAGE_BUS_LISTENER_MAX_QUEUE_DEPTH 10 |
Jonathan Austin |
1:8aa5cdb4ab67 | 136 | #endif |
Jonathan Austin |
1:8aa5cdb4ab67 | 137 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 138 | // |
Jonathan Austin |
1:8aa5cdb4ab67 | 139 | // Core micro:bit services |
Jonathan Austin |
1:8aa5cdb4ab67 | 140 | // |
Jonathan Austin |
1:8aa5cdb4ab67 | 141 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 142 | // To reduce memory cost and complexity, the micro:bit allows components to register for |
Jonathan Austin |
1:8aa5cdb4ab67 | 143 | // periodic callback events during interrupt context, which occur every scheduling quantum (FIBER_TICK_PERIOD_MS) |
Jonathan Austin |
1:8aa5cdb4ab67 | 144 | // This defines the maximum size of interrupt callback list. |
Jonathan Austin |
1:8aa5cdb4ab67 | 145 | #ifndef MICROBIT_SYSTEM_COMPONENTS |
Jonathan Austin |
1:8aa5cdb4ab67 | 146 | #define MICROBIT_SYSTEM_COMPONENTS 10 |
Jonathan Austin |
1:8aa5cdb4ab67 | 147 | #endif |
Jonathan Austin |
1:8aa5cdb4ab67 | 148 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 149 | // To reduce memory cost and complexity, the micro:bit allows components to register for |
Jonathan Austin |
1:8aa5cdb4ab67 | 150 | // periodic callback events when the processor is idle. |
Jonathan Austin |
1:8aa5cdb4ab67 | 151 | // This defines the maximum size of the idle callback list. |
Jonathan Austin |
1:8aa5cdb4ab67 | 152 | #ifndef MICROBIT_IDLE_COMPONENTS |
Jonathan Austin |
1:8aa5cdb4ab67 | 153 | #define MICROBIT_IDLE_COMPONENTS 6 |
Jonathan Austin |
1:8aa5cdb4ab67 | 154 | #endif |
Jonathan Austin |
1:8aa5cdb4ab67 | 155 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 156 | // |
Jonathan Austin |
1:8aa5cdb4ab67 | 157 | // BLE options |
Jonathan Austin |
1:8aa5cdb4ab67 | 158 | // |
Jonathan Austin |
1:8aa5cdb4ab67 | 159 | // The BLE stack is very memory hungry. Each service can therefore be compiled in or out |
Jonathan Austin |
1:8aa5cdb4ab67 | 160 | // by enabling/disabling the options below. |
Jonathan Austin |
1:8aa5cdb4ab67 | 161 | // |
Jonathan Austin |
1:8aa5cdb4ab67 | 162 | // n.b. The minimum set of services to enable over the air programming of the device will |
Jonathan Austin |
1:8aa5cdb4ab67 | 163 | // still be brought up in pairing mode regardless of the settings below. |
Jonathan Austin |
1:8aa5cdb4ab67 | 164 | // |
Jonathan Austin |
1:8aa5cdb4ab67 | 165 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 166 | // Enable/Disable BLE during normal operation. |
Jonathan Austin |
1:8aa5cdb4ab67 | 167 | // Set '1' to enable. |
Jonathan Austin |
1:8aa5cdb4ab67 | 168 | #ifndef MICROBIT_BLE_ENABLED |
Jonathan Austin |
1:8aa5cdb4ab67 | 169 | #define MICROBIT_BLE_ENABLED 1 |
Jonathan Austin |
1:8aa5cdb4ab67 | 170 | #endif |
Jonathan Austin |
1:8aa5cdb4ab67 | 171 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 172 | // Enable/Disable BLE pairing mode mode at power up. |
Jonathan Austin |
1:8aa5cdb4ab67 | 173 | // Set '1' to enable. |
Jonathan Austin |
1:8aa5cdb4ab67 | 174 | #ifndef MICROBIT_BLE_PAIRING_MODE |
Jonathan Austin |
1:8aa5cdb4ab67 | 175 | #define MICROBIT_BLE_PAIRING_MODE 1 |
Jonathan Austin |
1:8aa5cdb4ab67 | 176 | #endif |
Jonathan Austin |
1:8aa5cdb4ab67 | 177 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 178 | // Enable/Disable the use of private resolvable addresses. |
Jonathan Austin |
1:8aa5cdb4ab67 | 179 | // Set '1' to enable. |
Jonathan Austin |
1:8aa5cdb4ab67 | 180 | // n.b. This is known to be a feature that suffers compatibility issues with many BLE central devices. |
Jonathan Austin |
1:8aa5cdb4ab67 | 181 | #ifndef MICROBIT_BLE_PRIVATE_ADDRESSES |
Jonathan Austin |
1:8aa5cdb4ab67 | 182 | #define MICROBIT_BLE_PRIVATE_ADDRESSES 0 |
Jonathan Austin |
1:8aa5cdb4ab67 | 183 | #endif |
Jonathan Austin |
1:8aa5cdb4ab67 | 184 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 185 | // Convenience option to enable / disable BLE security entirely |
Jonathan Austin |
1:8aa5cdb4ab67 | 186 | // Open BLE links are not secure, but commonly used during the development of BLE services |
Jonathan Austin |
1:8aa5cdb4ab67 | 187 | // Set '1' to disable all secuity |
Jonathan Austin |
1:8aa5cdb4ab67 | 188 | #ifndef MICROBIT_BLE_OPEN |
Jonathan Austin |
1:8aa5cdb4ab67 | 189 | #define MICROBIT_BLE_OPEN 0 |
Jonathan Austin |
1:8aa5cdb4ab67 | 190 | #endif |
Jonathan Austin |
1:8aa5cdb4ab67 | 191 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 192 | // Configure for open BLE operation if so configured |
Jonathan Austin |
1:8aa5cdb4ab67 | 193 | #if (MICROBIT_BLE_OPEN == 1) |
Jonathan Austin |
1:8aa5cdb4ab67 | 194 | #define MICROBIT_BLE_SECURITY_LEVEL SECURITY_MODE_ENCRYPTION_OPEN_LINK |
Jonathan Austin |
1:8aa5cdb4ab67 | 195 | #define MICROBIT_BLE_WHITELIST 0 |
Jonathan Austin |
1:8aa5cdb4ab67 | 196 | #define MICROBIT_BLE_ADVERTISING_TIMEOUT 0 |
Jonathan Austin |
1:8aa5cdb4ab67 | 197 | #define MICROBIT_BLE_DEFAULT_TX_POWER 6 |
Jonathan Austin |
1:8aa5cdb4ab67 | 198 | #endif |
Jonathan Austin |
1:8aa5cdb4ab67 | 199 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 200 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 201 | // Define the default, global BLE security requirements for MicroBit BLE services |
Jonathan Austin |
1:8aa5cdb4ab67 | 202 | // May be one of the following options (see mbed's SecurityManager class implementaiton detail) |
Jonathan Austin |
1:8aa5cdb4ab67 | 203 | // SECURITY_MODE_ENCRYPTION_OPEN_LINK: No bonding, encryption, or whitelisting required. |
Jonathan Austin |
1:8aa5cdb4ab67 | 204 | // SECURITY_MODE_ENCRYPTION_NO_MITM: Bonding, encyption and whitelisting but no passkey. |
Jonathan Austin |
1:8aa5cdb4ab67 | 205 | // SECURITY_MODE_ENCRYPTION_WITH_MITM: Bonding, encrytion and whitelisting with passkey authentication. |
Jonathan Austin |
1:8aa5cdb4ab67 | 206 | // |
Jonathan Austin |
1:8aa5cdb4ab67 | 207 | #ifndef MICROBIT_BLE_SECURITY_LEVEL |
Jonathan Austin |
1:8aa5cdb4ab67 | 208 | #define MICROBIT_BLE_SECURITY_LEVEL SECURITY_MODE_ENCRYPTION_WITH_MITM |
Jonathan Austin |
1:8aa5cdb4ab67 | 209 | #endif |
Jonathan Austin |
1:8aa5cdb4ab67 | 210 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 211 | // Enable/Disable the use of BLE whitelisting. |
Jonathan Austin |
1:8aa5cdb4ab67 | 212 | // If enabled, the micro:bit will only respond to connection requests from |
Jonathan Austin |
1:8aa5cdb4ab67 | 213 | // known, bonded devices. |
Jonathan Austin |
1:8aa5cdb4ab67 | 214 | #ifndef MICROBIT_BLE_WHITELIST |
Jonathan Austin |
1:8aa5cdb4ab67 | 215 | #define MICROBIT_BLE_WHITELIST 1 |
Jonathan Austin |
1:8aa5cdb4ab67 | 216 | #endif |
Jonathan Austin |
1:8aa5cdb4ab67 | 217 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 218 | // Define the period of time for which the BLE stack will advertise (seconds) |
Jonathan Austin |
1:8aa5cdb4ab67 | 219 | // Afer this period, advertising will cease. Set to '0' for no timeout (always advertise). |
Jonathan Austin |
1:8aa5cdb4ab67 | 220 | #ifndef MICROBIT_BLE_ADVERTISING_TIMEOUT |
Jonathan Austin |
1:8aa5cdb4ab67 | 221 | #define MICROBIT_BLE_ADVERTISING_TIMEOUT 0 |
Jonathan Austin |
1:8aa5cdb4ab67 | 222 | #endif |
Jonathan Austin |
1:8aa5cdb4ab67 | 223 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 224 | // Defines default power level of the BLE radio transmitter. |
Jonathan Austin |
1:8aa5cdb4ab67 | 225 | // Valid values are in the range 0..7 inclusive, with 0 being the lowest power and 7 the highest power. |
Jonathan Austin |
1:8aa5cdb4ab67 | 226 | // Based on trials undertaken by the BBC, the radio is normally set to its lowest power level |
Jonathan Austin |
1:8aa5cdb4ab67 | 227 | // to best protect children's privacy. |
Jonathan Austin |
1:8aa5cdb4ab67 | 228 | #ifndef MICROBIT_BLE_DEFAULT_TX_POWER |
Jonathan Austin |
1:8aa5cdb4ab67 | 229 | #define MICROBIT_BLE_DEFAULT_TX_POWER 0 |
Jonathan Austin |
1:8aa5cdb4ab67 | 230 | #endif |
Jonathan Austin |
1:8aa5cdb4ab67 | 231 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 232 | // Enable/Disable BLE Service: MicroBitDFU |
Jonathan Austin |
1:8aa5cdb4ab67 | 233 | // This allows over the air programming during normal operation. |
Jonathan Austin |
1:8aa5cdb4ab67 | 234 | // Set '1' to enable. |
Jonathan Austin |
1:8aa5cdb4ab67 | 235 | #ifndef MICROBIT_BLE_DFU_SERVICE |
Jonathan Austin |
1:8aa5cdb4ab67 | 236 | #define MICROBIT_BLE_DFU_SERVICE 1 |
Jonathan Austin |
1:8aa5cdb4ab67 | 237 | #endif |
Jonathan Austin |
1:8aa5cdb4ab67 | 238 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 239 | // Enable/Disable BLE Service: MicroBitEventService |
Jonathan Austin |
1:8aa5cdb4ab67 | 240 | // This allows routing of events from the micro:bit message bus over BLE. |
Jonathan Austin |
1:8aa5cdb4ab67 | 241 | // Set '1' to enable. |
Jonathan Austin |
1:8aa5cdb4ab67 | 242 | #ifndef MICROBIT_BLE_EVENT_SERVICE |
Jonathan Austin |
1:8aa5cdb4ab67 | 243 | #define MICROBIT_BLE_EVENT_SERVICE 1 |
Jonathan Austin |
1:8aa5cdb4ab67 | 244 | #endif |
Jonathan Austin |
1:8aa5cdb4ab67 | 245 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 246 | // Enable/Disable BLE Service: MicroBitDeviceInformationService |
Jonathan Austin |
1:8aa5cdb4ab67 | 247 | // This enables the standard BLE device information service. |
Jonathan Austin |
1:8aa5cdb4ab67 | 248 | // Set '1' to enable. |
Jonathan Austin |
1:8aa5cdb4ab67 | 249 | #ifndef MICROBIT_BLE_DEVICE_INFORMATION_SERVICE |
Jonathan Austin |
1:8aa5cdb4ab67 | 250 | #define MICROBIT_BLE_DEVICE_INFORMATION_SERVICE 1 |
Jonathan Austin |
1:8aa5cdb4ab67 | 251 | #endif |
Jonathan Austin |
1:8aa5cdb4ab67 | 252 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 253 | // |
Jonathan Austin |
1:8aa5cdb4ab67 | 254 | // Accelerometer options |
Jonathan Austin |
1:8aa5cdb4ab67 | 255 | // |
Jonathan Austin |
1:8aa5cdb4ab67 | 256 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 257 | // Enable this to read 10 bits of data from the acclerometer. |
Jonathan Austin |
1:8aa5cdb4ab67 | 258 | // Otherwise, 8 bits are used. |
Jonathan Austin |
1:8aa5cdb4ab67 | 259 | // Set '1' to enable. |
Jonathan Austin |
1:8aa5cdb4ab67 | 260 | #ifndef USE_ACCEL_LSB |
Jonathan Austin |
1:8aa5cdb4ab67 | 261 | #define USE_ACCEL_LSB 0 |
Jonathan Austin |
1:8aa5cdb4ab67 | 262 | #endif |
Jonathan Austin |
1:8aa5cdb4ab67 | 263 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 264 | // |
Jonathan Austin |
1:8aa5cdb4ab67 | 265 | // Display options |
Jonathan Austin |
1:8aa5cdb4ab67 | 266 | // |
Jonathan Austin |
1:8aa5cdb4ab67 | 267 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 268 | // Selects the matrix configuration for the display driver. |
Jonathan Austin |
1:8aa5cdb4ab67 | 269 | // Known, acceptable options are: |
Jonathan Austin |
1:8aa5cdb4ab67 | 270 | // |
Jonathan Austin |
1:8aa5cdb4ab67 | 271 | #define MICROBUG_REFERENCE_DEVICE 1 |
Jonathan Austin |
1:8aa5cdb4ab67 | 272 | #define MICROBIT_3X9 2 |
Jonathan Austin |
1:8aa5cdb4ab67 | 273 | #define MICROBIT_SB1 3 |
Jonathan Austin |
1:8aa5cdb4ab67 | 274 | #define MICROBIT_SB2 4 |
Jonathan Austin |
1:8aa5cdb4ab67 | 275 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 276 | #ifndef MICROBIT_DISPLAY_TYPE |
Jonathan Austin |
1:8aa5cdb4ab67 | 277 | #define MICROBIT_DISPLAY_TYPE MICROBIT_SB2 |
Jonathan Austin |
1:8aa5cdb4ab67 | 278 | #endif |
Jonathan Austin |
1:8aa5cdb4ab67 | 279 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 280 | // Selects the minimum permissable brightness level for the device |
Jonathan Austin |
1:8aa5cdb4ab67 | 281 | // in the region of 0 (off) to 255 (full brightness) |
Jonathan Austin |
1:8aa5cdb4ab67 | 282 | #ifndef MICROBIT_DISPLAY_MINIMUM_BRIGHTNESS |
Jonathan Austin |
1:8aa5cdb4ab67 | 283 | #define MICROBIT_DISPLAY_MINIMUM_BRIGHTNESS 1 |
Jonathan Austin |
1:8aa5cdb4ab67 | 284 | #endif |
Jonathan Austin |
1:8aa5cdb4ab67 | 285 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 286 | // Selects the maximum permissable brightness level for the device |
Jonathan Austin |
1:8aa5cdb4ab67 | 287 | // in the region of 0 (off) to 255 (full brightness) |
Jonathan Austin |
1:8aa5cdb4ab67 | 288 | #ifndef MICROBIT_DISPLAY_MAXIMUM_BRIGHTNESS |
Jonathan Austin |
1:8aa5cdb4ab67 | 289 | #define MICROBIT_DISPLAY_MAXIMUM_BRIGHTNESS 255 |
Jonathan Austin |
1:8aa5cdb4ab67 | 290 | #endif |
Jonathan Austin |
1:8aa5cdb4ab67 | 291 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 292 | // Selects the default brightness for the display |
Jonathan Austin |
1:8aa5cdb4ab67 | 293 | // in the region of zero (off) to 255 (full brightness) |
Jonathan Austin |
1:8aa5cdb4ab67 | 294 | #ifndef MICROBIT_DISPLAY_DEFAULT_BRIGHTNESS |
Jonathan Austin |
1:8aa5cdb4ab67 | 295 | #define MICROBIT_DISPLAY_DEFAULT_BRIGHTNESS MICROBIT_DISPLAY_MAXIMUM_BRIGHTNESS |
Jonathan Austin |
1:8aa5cdb4ab67 | 296 | #endif |
Jonathan Austin |
1:8aa5cdb4ab67 | 297 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 298 | // Selects the default scroll speed for the display. |
Jonathan Austin |
1:8aa5cdb4ab67 | 299 | // The time taken to move a single pixel (ms). |
Jonathan Austin |
1:8aa5cdb4ab67 | 300 | #ifndef MICROBIT_DEFAULT_SCROLL_SPEED |
Jonathan Austin |
1:8aa5cdb4ab67 | 301 | #define MICROBIT_DEFAULT_SCROLL_SPEED 120 |
Jonathan Austin |
1:8aa5cdb4ab67 | 302 | #endif |
Jonathan Austin |
1:8aa5cdb4ab67 | 303 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 304 | // Selects the number of pixels a scroll will move in each quantum. |
Jonathan Austin |
1:8aa5cdb4ab67 | 305 | #ifndef MICROBIT_DEFAULT_SCROLL_STRIDE |
Jonathan Austin |
1:8aa5cdb4ab67 | 306 | #define MICROBIT_DEFAULT_SCROLL_STRIDE -1 |
Jonathan Austin |
1:8aa5cdb4ab67 | 307 | #endif |
Jonathan Austin |
1:8aa5cdb4ab67 | 308 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 309 | // Selects the time each character will be shown on the display during print operations. |
Jonathan Austin |
1:8aa5cdb4ab67 | 310 | // The time each character is shown on the screen (ms). |
Jonathan Austin |
1:8aa5cdb4ab67 | 311 | #ifndef MICROBIT_DEFAULT_PRINT_SPEED |
Jonathan Austin |
1:8aa5cdb4ab67 | 312 | #define MICROBIT_DEFAULT_PRINT_SPEED 400 |
Jonathan Austin |
1:8aa5cdb4ab67 | 313 | #endif |
Jonathan Austin |
1:8aa5cdb4ab67 | 314 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 315 | //Configures the default serial mode used by serial read and send calls. |
Jonathan Austin |
1:8aa5cdb4ab67 | 316 | #ifndef MICROBIT_DEFAULT_SERIAL_MODE |
Jonathan Austin |
1:8aa5cdb4ab67 | 317 | #define MICROBIT_DEFAULT_SERIAL_MODE SYNC_SLEEP |
Jonathan Austin |
1:8aa5cdb4ab67 | 318 | #endif |
Jonathan Austin |
1:8aa5cdb4ab67 | 319 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 320 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 321 | // |
Jonathan Austin |
1:8aa5cdb4ab67 | 322 | // Panic options |
Jonathan Austin |
1:8aa5cdb4ab67 | 323 | // |
Jonathan Austin |
1:8aa5cdb4ab67 | 324 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 325 | // Enable this to invoke a panic on out of memory conditions. |
Jonathan Austin |
1:8aa5cdb4ab67 | 326 | // Set '1' to enable. |
Jonathan Austin |
1:8aa5cdb4ab67 | 327 | #ifndef MICROBIT_PANIC_HEAP_FULL |
Jonathan Austin |
1:8aa5cdb4ab67 | 328 | #define MICROBIT_PANIC_HEAP_FULL 1 |
Jonathan Austin |
1:8aa5cdb4ab67 | 329 | #endif |
Jonathan Austin |
1:8aa5cdb4ab67 | 330 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 331 | // |
Jonathan Austin |
1:8aa5cdb4ab67 | 332 | // Debug options |
Jonathan Austin |
1:8aa5cdb4ab67 | 333 | // |
Jonathan Austin |
1:8aa5cdb4ab67 | 334 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 335 | // Enable this to route debug messages through the USB serial interface. |
Jonathan Austin |
1:8aa5cdb4ab67 | 336 | // n.b. This also disables the user serial port 'uBit.serial'. |
Jonathan Austin |
1:8aa5cdb4ab67 | 337 | // Set '1' to enable. |
Jonathan Austin |
1:8aa5cdb4ab67 | 338 | #ifndef MICROBIT_DBG |
Jonathan Austin |
1:8aa5cdb4ab67 | 339 | #define MICROBIT_DBG 0 |
Jonathan Austin |
1:8aa5cdb4ab67 | 340 | #endif |
Jonathan Austin |
1:8aa5cdb4ab67 | 341 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 342 | // Enable this to receive diagnostic messages from the heap allocator via the USB serial interface. |
Jonathan Austin |
1:8aa5cdb4ab67 | 343 | // n.b. This requires MICROBIT_DBG to be defined. |
Jonathan Austin |
1:8aa5cdb4ab67 | 344 | // Set '1' to enable. |
Jonathan Austin |
1:8aa5cdb4ab67 | 345 | #ifndef MICROBIT_HEAP_DBG |
Jonathan Austin |
1:8aa5cdb4ab67 | 346 | #define MICROBIT_HEAP_DBG 0 |
Jonathan Austin |
1:8aa5cdb4ab67 | 347 | #endif |
Jonathan Austin |
1:8aa5cdb4ab67 | 348 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 349 | // Versioning options. |
Jonathan Austin |
1:8aa5cdb4ab67 | 350 | // We use semantic versioning (http://semver.org/) to identify differnet versions of the micro:bit runtime. |
Jonathan Austin |
1:8aa5cdb4ab67 | 351 | // Where possible we use yotta (an ARM mbed build tool) to help us track versions. |
Jonathan Austin |
1:8aa5cdb4ab67 | 352 | // if this isn't available, it can be defined manually as a configuration option. |
Jonathan Austin |
1:8aa5cdb4ab67 | 353 | // |
Jonathan Austin |
1:8aa5cdb4ab67 | 354 | #ifndef MICROBIT_DAL_VERSION |
Jonathan Austin |
1:8aa5cdb4ab67 | 355 | #define MICROBIT_DAL_VERSION "unknown" |
Jonathan Austin |
1:8aa5cdb4ab67 | 356 | #endif |
Jonathan Austin |
1:8aa5cdb4ab67 | 357 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 358 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 359 | // |
Jonathan Austin |
1:8aa5cdb4ab67 | 360 | // Helper macro used by the micro:bit runtime to determine if a boolean configuration option is set. |
Jonathan Austin |
1:8aa5cdb4ab67 | 361 | // |
Jonathan Austin |
1:8aa5cdb4ab67 | 362 | #define CONFIG_ENABLED(X) (X == 1) |
Jonathan Austin |
1:8aa5cdb4ab67 | 363 | #define CONFIG_DISABLED(X) (X != 1) |
Jonathan Austin |
1:8aa5cdb4ab67 | 364 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 365 | #if CONFIG_ENABLED(MICROBIT_HEAP_ALLOCATOR) |
Jonathan Austin |
1:8aa5cdb4ab67 | 366 | #include "MicroBitHeapAllocator.h" |
Jonathan Austin |
1:8aa5cdb4ab67 | 367 | #endif |
Jonathan Austin |
1:8aa5cdb4ab67 | 368 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 369 | #if CONFIG_ENABLED(MICROBIT_DBG) |
Jonathan Austin |
1:8aa5cdb4ab67 | 370 | extern RawSerial* SERIAL_DEBUG; |
Jonathan Austin |
1:8aa5cdb4ab67 | 371 | #endif |
Jonathan Austin |
1:8aa5cdb4ab67 | 372 | |
Jonathan Austin |
1:8aa5cdb4ab67 | 373 | #endif |