Skip to content

Commit d976305

Browse files
v2.02: Generalise the 'I2C secondary' and 'KL27' references as 'Interface'.
1 parent 1ec35f6 commit d976305

1 file changed

Lines changed: 53 additions & 43 deletions

File tree

spec/index.md

Lines changed: 53 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ lang: en
1010

1111
# micro:bit I2C Protocol Specification
1212

13-
This is version 2.01 of the specification.
13+
This is version 2.02 of the specification.
1414

1515
- [Glossary](#glossary)
1616
- [Versioning](#versioning)
1717
- [Introduction](#introduction)
1818
- [I2C Secondary addresses](#i2c-secondary-addresses)
19-
- [I2C nRF - KL27 config/comms interface](#i2c-nrf--kl27-configcomms-interface)
20-
- [I2C Flash interface](#i2c-flash-interface)
19+
- [I2C Interface MCU config/comms interface](#i2c-interface-mcu-configcomms-interface)
20+
- [I2C Flash Storage Interface](#i2c-flash-storage-interface)
2121
- [I2C HID Interface](#i2c-hid-interface)
2222
- [Doc Updates](#doc-updates)
2323

@@ -30,7 +30,9 @@ This is version 2.01 of the specification.
3030
| I2C | [Inter-Integrated Circuit](https://en.wikipedia.org/wiki/I%C2%B2C) bus |
3131
| I2C main | I2C node in control of the clock and initiating transactions |
3232
| I2C secondary | I2C peripheral that responds to the I2C main |
33-
| Storage | Flash available in the KL27 for micro:bit data and config storage |
33+
| Target MCU | The micro:bit microcontroller that runs the user code. The I2C main role in the I2C bus. |
34+
| Interface MCU | The micro:bit microcontroller that provides USB functionality and the I2C secondary role described in this protocol. |
35+
| Storage | Flash available in the Interface MCU for micro:bit data and config storage |
3436
| SWD | [Serial Wire Debug](https://developer.arm.com/architectures/cpu-architecture/debug-visibility-and-trace/coresight-architecture/serial-wire-debug) |
3537
| UART | [Universal asynchronous receiver-transmitter](https://en.wikipedia.org/wiki/Universal_asynchronous_receiver-transmitter) |
3638

@@ -39,7 +41,7 @@ This is version 2.01 of the specification.
3941

4042
The version follows a `major.minor` configuration.
4143

42-
- `major`: Indicates a change or addition to the procotol, this is usually accompanied by a new DAPLink release.
44+
- `major`: Indicates a change or addition to the protocol, this is usually accompanied by a new DAPLink release.
4345
- `minor`: Indicates an update, fix, or clarification to the documentation **only**. No changes required to the protocol implementations.
4446

4547
The `I2C protocol version` property returns only the major version.
@@ -52,33 +54,38 @@ More information can be found in the [Tech Site DAPLink page](https://tech.micro
5254

5355
In micro:bit V1 there are UART and SWD signals connecting the Interface MCU (KL26) and the Target MCU (nRF51). These are used to program the Target MCU (nRF51) and to provide serial communication between the Target (nRF51) and the computer.
5456

55-
The micro:bit V2 adds an internal I2C bus connected to the Interface MCU (KL27), the Target MCU (nRF52), and the motion sensors (in V1 the motions sensors are connected to the external I2C bus, connected only to the Target MCU (nRF51), more info in the [Tech Site I2C page](https://tech.microbit.org/hardware/i2c-shared/)).
56-
This new I2C bus allows the Interface (KL27) to provide additional features to the Target (nRF52), and to co-operate to set the board into different power modes (more info in the [Power Management Spec](https://github.com/microbit-foundation/spec-power-management/)).
57+
The micro:bit V2 adds an internal I2C bus connected to:
58+
- The Interface MCU (KL27 in micro:bit V2.0 or nRF52 in micro:bit V2.2)
59+
- The Target MCU (nRF52)
60+
- The motion sensors
61+
- In micro:bit V1 the motions sensors are connected to the external I2C bus, only connected to the Target MCU, more info in the [Tech Site I2C page](https://tech.microbit.org/hardware/i2c-shared/)
62+
63+
This new internal I2C bus allows the Interface MCU to provide additional features to the Target MCU, and to co-operate to set the board into different power modes (more info in the [Power Management Spec](https://github.com/microbit-foundation/spec-power-management/)).
5764

5865
![I2C Diagram](https://tech.microbit.org/docs/software/spec-i2c-protocol/spec/img/i2c-diagram.png)
5966

60-
The additional features provided by the Interface (KL27) via I2C are:
67+
The additional features provided by the Interface MCU via I2C are:
6168
- Device Information
6269
- Board ID, DAPLink version, and more
6370
- Power Management
6471
- As defined in the [Power Management Spec](https://github.com/microbit-foundation/spec-power-management/)
6572
- I2C Flash Storage
66-
- The Interface (KL27) flash is 256 KBs, where 128KBs are reserved for non-volatile storage accessible to the Target (nRF52)
73+
- The Interface MCU flash is 256 KBs, where 128KBs are reserved for non-volatile storage accessible to the Target MCU
6774

6875

6976
## I2C Secondary addresses
7077

7178
| I2C Secondary | 7-bit address |
7279
| -------------------------------------------- | ------------- |
73-
| KL27 (I2C nRF – KL27 config/comms interface) | 0x70 |
74-
| KL27 (I2C USB/HID interface) | 0x71 |
75-
| KL27 (I2C Flash interface) | 0x72 |
76-
| FXOS8700CQ | 0x1F |
80+
| Interface MCU (I2C config/comms interface) | 0x70 |
81+
| Interface MCU reserved (unused) | 0x71 |
82+
| Interface MCU (I2C Flash Storage interface) | 0x72 |
83+
| FXOS8700CQ Combined motion sensor | 0x1F |
7784
| LSM303AGR Accelerometer | 0x19 |
7885
| LSM303AGR Magnetometer | 0x1E |
7986

8087

81-
## I2C nRF – KL27 config/comms interface
88+
## I2C Interface MCU config/comms interface
8289

8390
### Types of commands
8491

@@ -193,10 +200,12 @@ Value only includes major version
193200
} main_usb_connect_t;</pre></td>
194201
</tr>
195202
<tr class="odd">
196-
<td>KL27 Power mode (W)</td>
203+
<td>Interface Power mode (W)</td>
197204
<td>0x07</td>
198205
<td>Size 1B e.g. 0x08<br />
199-
<pre>kAPP_PowerModeVlls0 = 0x08</pre></td>
206+
<pre>Power Down = 0x08</pre>
207+
For more info: <a href="https://tech.microbit.org/software/spec-power-management/" target="_blank">Power Management Spec</a>
208+
</td>
200209
</tr>
201210
<tr class="even">
202211
<td>Power LED Sleep state (W)</td>
@@ -242,31 +251,31 @@ Value only includes major version
242251

243252
### Examples
244253

245-
- Read DAPLink Board version (nRF I2C main)
246-
1. `read_request` (cmd id + property) I2C Write: 0x10 0x01
247-
2. (KL27 processes cmd and asserts `COMBINED_SENSOR_INT` signal when response is ready)
248-
3. `read_response` (cmd id + property + size + data) I2C Read: 0x11 0x01 0x02 0x04 0x99
249-
4. (KL27 releases `COMBINED_SENSOR_INT` signal)
254+
- Read DAPLink Board version (Target I2C main)
255+
1. `read_request` (cmd id + property) I2C Write: `0x10` `0x01`
256+
2. (Interface processes cmd and asserts `COMBINED_SENSOR_INT` signal when response is ready)
257+
3. `read_response` (cmd id + property + size + data) I2C Read: `0x11` `0x01` `0x02` `0x04` `0x99`
258+
4. (Interface releases `COMBINED_SENSOR_INT` signal)
250259

251260
### Considerations
252261

253-
- `read_request` can only be sent by the I2C main (nrf)
254-
- The main (nRF) must wait for the `COMBINED_SENSOR_INT` signal to be asserted by the secondary (KL27)
262+
- `read_request` can only be sent by the Target I2C main
263+
- The I2C main (Target) must wait for the `COMBINED_SENSOR_INT` signal to be asserted by the secondary (Interface)
255264
- `write_request` can be sent by both secondary and main.
256265
- For the secondary to initiate this, it must assert the interrupt signal first and then the main must poll (i2c read) the device for data.
257-
- I2C transactions must not overlap. Every I2C Write, must be followed by an I2C Read.
258-
- I2C Reads can be triggered by other I2C devices activating the shared `COMBINED_SENSOR_INT` interrupt signal. In case a response is not ready by the secondary (KL27), the busy error code will be returned and the main (nRF) should re-attempt to read the response when the `COMBINED_SENSOR_INT` signal is asserted.
266+
- I2C transactions must not overlap. Every I2C Write, must be followed by an I2C Read.
267+
- I2C Reads can be triggered by other I2C devices activating the shared `COMBINED_SENSOR_INT` interrupt signal. In case a response is not ready by the secondary (Interface), the busy error code will be returned and the main (Target) should re-attempt to read the response when the `COMBINED_SENSOR_INT` signal is asserted.
259268

260269

261-
## I2C Flash interface
270+
## I2C Flash Storage Interface
262271

263-
KL27 storage memory layout:
272+
Interface storage memory layout:
264273

265274
```
266-
KL27 flash address 0x20000 ↓ KL27 flash address 0x40000
267-
↓ ↓ KL27 flash address 0x20400
275+
Interface flash address 0x20000 ↓ Interface flash address 0x40000
276+
↓ ↓ Interface flash address 0x20400 ↓
268277
┌---------┬-------------------------------------------------┐
269-
| KL27 | storage data |
278+
| Interf. | storage data |
270279
| config |[ file.ext -------------------- ][ DAL’s config ]|
271280
└---------┴-------------------------------------------------┘
272281
↑ storage address 0x0000 ↑ address set by file size
@@ -275,20 +284,20 @@ KL27 storage memory layout:
275284
```
276285

277286
- config
278-
- Controlled by KL27
279-
- nRF reads/write data fields via I2C commands
287+
- Controlled by the Interface MCU
288+
- Target MCU reads/write data fields via I2C commands
280289
- data
281-
- Controlled by nRF
282-
- nRF reads/write bytes via I2C commands
283-
- Storage address range: 0x00000-max_size
290+
- Controlled by Target MCU
291+
- Target MCU reads/write bytes via I2C commands
292+
- Storage address range: 0x00000 to max_size
284293

285294
### Protocol
286295

287296
- Word (4 Bytes) align transactions
288297
- All transactions start with:
289298
- 1 byte command ID
290299
- N byte data depending on command
291-
- For KL27 responses, KL27 to hold interrupt until success/error messages have been served
300+
- For Interface responses, the Interface will hold interrupt until success/error messages have been served
292301

293302
### Commands
294303

@@ -341,7 +350,7 @@ KL27 storage memory layout:
341350
- Size has to be a multiple of 4 bytes
342351
- Address has to be aligned to a 4 byte boundary
343352
- Bound check
344-
- KL27 can clock stretch
353+
- Interface can clock stretch
345354

346355
#### Read storage data
347356

@@ -360,17 +369,17 @@ KL27 storage memory layout:
360369
- Addresses have to be sector align
361370
- End address >= Start address
362371
- Bound check
363-
- On errors KL27 to trigger interrupt and send error code
364-
- On success KL27 to trigger interrupt and send success message
372+
- On errors Interface to trigger interrupt and send error code
373+
- On success Interface to trigger interrupt and send success message
365374
- KL to provide some kind of status read command
366375

367-
### KL27 behaviour
376+
### Interface I2C secondary behaviour
368377

369378
- Before enumeration it checks if it should show the file on the MSD
370379
- It sets the file name from the config
371380
- It sets the file size from the config
372-
- KL27 I2C buffer size: 1KB + 4 bytes
373-
- Storage writes should not trigger "hidden" sector erases, the nRF is
381+
- Interface I2C buffer size: 1KB + 4 bytes
382+
- Storage writes should not trigger "hidden" sector erases, the Target MCU is
374383
responsible to write and erase
375384
- When writing to the config data first check if the data to be written is
376385
different than present, avoid an erase-and-write operation if it's the same
@@ -430,7 +439,7 @@ KL27 storage memory layout:
430439

431440
### Universal Hex
432441

433-
KL27 storage area should be writeable via Universal Hex.
442+
Interface Storage area should be writeable via Universal Hex.
434443

435444
This is not yet implemented.
436445

@@ -452,3 +461,4 @@ This is not yet implemented.
452461
| | Add "Set encoding window" command to the I2C Flash interface [PR #9](https://github.com/microbit-foundation/spec-i2c-protocol/pull/9) |
453462
| 2.01 | Fix documentation bug where commands were marked as bidirectional |
454463
| | Removed "success" error code as it is unused |
464+
| 2.02 | Generalise the "I2C secondary" and "KL27" references as "Interface", as V2.0 and V2.2 use different MCUs (KL27 and nRF52) |

0 commit comments

Comments
 (0)