Skip to content

Commit 567dbdf

Browse files
Add additional background info to spec.
1 parent caa9a7c commit 567dbdf

File tree

2 files changed

+57
-27
lines changed

2 files changed

+57
-27
lines changed

spec/img/i2c-diagram.png

35.2 KB
Loading

spec/index.md

Lines changed: 57 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,52 @@
1-
# I2C Protocol specification for nRF and KL27 communication (draft)
1+
# micro:bit I2C Protocol Specification
22

3-
This is version 0.9.0 of the specification.
3+
This is version 0.9.1 of the specification.
44

5-
- [Glosary](#glosary)
6-
- [I2C Slave addresses](#i2c-slave-addresses)
5+
- [Glossary](#glosary)
6+
- [Introduction](#introduction)
7+
- [I2C Secondary addresses](#i2c-secondary-addresses)
78
- [I2C nRF - KL27 config/comms interface](#i2c-nrf--kl27-configcomms-interface)
89
- [I2C Flash interface](#i2c-flash-interface)
910
- [HID Interface](#hid-interface)
1011

1112

12-
## Glosary
13+
## Glossary
1314

14-
- Storage: Flash available in the KL27 for micro:bit data and config storage
15+
| Term | Definition |
16+
| ------------- | ---------- |
17+
| DAPLink | [Interface firmware](https://github.com/ARMmbed/DAPLink) providing USB and programming capabilities |
18+
| I2C | [Inter-Integrated Circuit](https://en.wikipedia.org/wiki/I%C2%B2C) bus |
19+
| I2C main | I2C node in control of the clock and initiating transactions |
20+
| I2C secondary | I2C peripheral that responds to the I2C main |
21+
| Storage | Flash available in the KL27 for micro:bit data and config storage |
22+
| SWD | [Serial Wire Debug](https://developer.arm.com/architectures/cpu-architecture/debug-visibility-and-trace/coresight-architecture/serial-wire-debug) |
23+
| UART | [Universal asynchronous receiver-transmitter](https://en.wikipedia.org/wiki/Universal_asynchronous_receiver-transmitter) |
1524

1625

17-
## I2C Slave addresses
26+
## Introduction
1827

19-
| I2C Slave | 7-bit address |
28+
The micro:bit contains two microcontrollers, the Interface MCU which provides the USB functionality, and the Target MCU where the user code runs.
29+
More information can be found in the [Tech Site DAPLink page](https://tech.microbit.org/software/daplink-interface/).
30+
31+
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.
32+
33+
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/)).
34+
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/)).
35+
36+
![I2C Diagram](img/i2c-diagram.png)
37+
38+
The additional features provided by the Interface (KL27) via I2C are:
39+
- Device Information
40+
- Board ID, DAPLink version, and more
41+
- Power Management
42+
- As defined in the [Power Management Spec](https://github.com/microbit-foundation/spec-power-management/)
43+
- I2C Flash Storage
44+
- The Interface (KL27) flash is 256 KBs, where 128KBs are reserved for non-volatile storage accessible to the Target (nRF52)
45+
46+
47+
## I2C Secondary addresses
48+
49+
| I2C Secondary | 7-bit address |
2050
| -------------------------------------------- | ------------- |
2151
| KL27 (I2C nRF – KL27 config/comms interface) | 0x70 |
2252
| KL27 (I2C USB/HID interface) | 0x71 |
@@ -30,14 +60,14 @@ This is version 0.9.0 of the specification.
3060

3161
### Types of commands
3262

33-
| Command | CMD ID | Used by |
34-
| ---------------- | ------ | -------------- |
35-
| `nop_cmd` | 0x00 | master only |
36-
| `read_request` | 0x10 | master only |
37-
| `read_response` | 0x11 | slave only |
38-
| `write_request` | 0x12 | master & slave |
39-
| `write_response` | 0x13 | master & slave |
40-
| `error_response` | 0x20 | master & slave |
63+
| Command | CMD ID | Used by |
64+
| ---------------- | ------ | ---------------- |
65+
| `nop_cmd` | 0x00 | main only |
66+
| `read_request` | 0x10 | main only |
67+
| `read_response` | 0x11 | secondary only |
68+
| `write_request` | 0x12 | main & secondary |
69+
| `write_response` | 0x13 | main & secondary |
70+
| `error_response` | 0x20 | main & secondary |
4171

4272
### Packet format for each command
4373

@@ -182,18 +212,18 @@ This is version 0.9.0 of the specification.
182212

183213
### Examples
184214

185-
- Read DAPLink Board version (nRF I2C master)
215+
- Read DAPLink Board version (nRF I2C main)
186216
1. `read_request` (cmd id + property) I2C Write: 0x10 0x01
187217
2. (KL27 processes cmd and asserts `COMBINED_SENSOR_INT` signal when response is ready)
188218
3. `read_response` (cmd id + property + size + data) I2C Read: 0x11 0x01 0x02 0x04 0x99
189219
4. (KL27 releases `COMBINED_SENSOR_INT` signal)
190220

191221
### Considerations
192222

193-
- `read_request` can only be sent by the I2C master (nrf)
194-
- The master (nRF) must wait for the `COMBINED_SENSOR_INT` signal to be asserted by the slave (KL27)
195-
- `write_request` can be sent by both slave and master.
196-
- For the slave to initiate this, it must assert the interrupt signal first and then the master must poll (i2c read) the device for data.
223+
- `read_request` can only be sent by the I2C main (nrf)
224+
- The main (nRF) must wait for the `COMBINED_SENSOR_INT` signal to be asserted by the secondary (KL27)
225+
- `write_request` can be sent by both secondary and main.
226+
- 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.
197227

198228

199229
## I2C Flash interface
@@ -252,9 +282,9 @@ KL27 storage memory layout:
252282
### Flash Operations
253283

254284
#### Reading/writing config data
255-
- For writing the config data (file name, file size and file visibility), the I2C Master has to send the 1B command ID followed by the corresponding config data. If the data size is unexpected, an error will be returned in the I2C response.
256-
- The I2C Response after a sucessful write opeartion will contain the corresponding command ID followed by the written config data which can be used as confirmation by the I2C master.
257-
- For reading the config data, the I2C Master has to send only the 1B command ID with no further data. The I2C response will then contain the config data.
285+
- For writing the config data (file name, file size and file visibility), the I2C main has to send the 1B command ID followed by the corresponding config data. If the data size is unexpected, an error will be returned in the I2C response.
286+
- The I2C Response after a successful write operation will contain the corresponding command ID followed by the written config data which can be used as confirmation by the I2C main.
287+
- For reading the config data, the I2C main has to send only the 1B command ID with no further data. The I2C response will then contain the config data.
258288

259289
#### Write storage data
260290

@@ -297,8 +327,8 @@ KL27 storage memory layout:
297327
- KL27 I2C buffer size: 1KB + 4 bytes
298328
- Storage writes should not trigger "hidden" sector erases, the nRF is
299329
responsible to write and erase
300-
- When writting to the config data first check if the data to be written is
301-
different than present, avoid an erase-and-write opertion if it's the same
330+
- When writing to the config data first check if the data to be written is
331+
different than present, avoid an erase-and-write operation if it's the same
302332
- USB should have higher priority than any I2C transaction
303333

304334
### Examples
@@ -346,7 +376,7 @@ KL27 storage memory layout:
346376

347377
### Universal Hex
348378

349-
KL27 storage area should be writable via Universal Hex.
379+
KL27 storage area should be writeable via Universal Hex.
350380

351381

352382
## HID Interface

0 commit comments

Comments
 (0)