Skip to content

Commit e3894e2

Browse files
author
Amanda Butler
authored
Copy edit NFCEEPROMDriver.md
Copy edit file, mostly for active voice and U.S. spelling
1 parent e27d9c7 commit e3894e2

File tree

1 file changed

+33
-27
lines changed

1 file changed

+33
-27
lines changed
Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,81 @@
1-
## NFC EEPROM Driver porting guide
1+
## NFC EEPROM driver porting guide
22

3-
NFC EEPROM provides low level operations needed to create an NFC TAG. The device usually allows for reading and writing into a shared memory by one device at a time through one of two channels. One is the radio channel used by external devices interacting with the device. The other is wired to the MCU. Either device needs to obtain a session before performing its operations. Session is released as the last step or through a timeout.
3+
NFC EEPROM provides low level operations needed to create an NFC TAG. The device usually allows one device at a time to read and write into a shared memory through one of two channels. One is the radio channel that external devices interacting with the device use. The other is wired to the MCU. Either device needs to obtain a session before performing its operations. The session is released as the last step or through a timeout.
44

55
### Class hierarchy
66

7-
The `NFCTarget` uses an implementation of `NFCEEPROMDriver` as the backend that delivers the fundamental operations needed to access and modify the memory containing the NDEF messages. The instance of the class is created by the target implementation of `NFCTarget`.
7+
The `NFCTarget` uses an implementation of `NFCEEPROMDriver` as the backend that delivers the fundamental operations needed to access and modify the memory containing the NDEF messages. The target implementation of `NFCTarget` creates the instance of the class.
88

9-
Your implementation will inherit from `NFCEEPROMDriver` and implement all the public methods therein.
9+
Your implementation inherits from `NFCEEPROMDriver` and implements all the public methods therein.
1010

1111
### Required methods
1212

1313
`NFCEEPROMDriver` defines the following pure virtual methods.
1414

1515
These must return synchronously:
16-
- `void reset()`
17-
- `size_t read_max_size()`
16+
17+
- `void reset()`.
18+
- `size_t read_max_size()`.
1819

1920
These must return their results through calling methods in the `Delegate`:
20-
- `void start_session(bool force = false)`
21-
- `void end_session()`
22-
- `void read_bytes(uint32_t address, uint8_t* bytes, size_t count)`
23-
- `void write_bytes(uint32_t address, const uint8_t* bytes, size_t count)`
24-
- `void write_size(size_t count)`
25-
- `void read_size()`
26-
- `void erase_bytes(uint32_t address, size_t size)`
21+
22+
- `void start_session(bool force = false)`.
23+
- `void end_session()`.
24+
- `void read_bytes(uint32_t address, uint8_t* bytes, size_t count)`.
25+
- `void write_bytes(uint32_t address, const uint8_t* bytes, size_t count)`.
26+
- `void write_size(size_t count)`.
27+
- `void read_size()`.
28+
- `void erase_bytes(uint32_t address, size_t size)`.
2729

2830
#### Implementing `reset`
2931

30-
This will be called during initialisation and may be called repeatedly. This must be safe to be called at any time and should return when the device is ready for operation.
32+
`reset` is called during initialization and may be called repeatedly. This must be safe to be called at any time and should return when the device is ready for operation.
3133

3234
#### Implementing `read_max_size`
3335

3436
This must synchronously return the (effective) size of the EEPROM memory available to NDEF messages (not including the memory required by other files or headers).
3537

3638
#### Implementing `start_session` and `end_session`
3739

38-
These open and close the communication with the device. The `start_session` has an extra parameter that indicates the session should be started even if it would kill the RF session in the process. Otherwise the `open_session` should trigger the `on_session_opened` with the parameter set to false (failure) if an RF session is already opened.
40+
`start_session` and `end_session` open and close the communication with the device. `start_session` has an extra parameter that indicates the session should be started even if it would kill the RF session in the process. Otherwise, the `open_session` triggers the `on_session_opened` with the parameter set to false (failure) if an RF session is already opened.
3941

4042
#### Implementing `read_bytes` and `write_bytes`
4143

42-
Both methods contain the `address` which is to be used as the starting offset in the file. This starts at the beginning of the body of the file where NDEF messages may be written. Any headers must be accounted for in the offset and size calculations. The `count` parameters are the maximum sizes of the operations but the operation may return less than the requested counts.
44+
Both methods contain the `address`, which is to be used as the starting offset in the file. This starts at the beginning of the body of the file where NDEF messages may be written. You must account for any headers in the offset and size calculations. The `count` parameters are the maximum sizes of the operations, but the operation may return less than the requested counts.
4345

4446
The events `on_bytes_read` and `on_bytes_written` must return the number of bytes successfully read or written in case the maximum size of the operation the device allows is smaller than the request operation. It's up to the caller to call these methods multiple times with appropriate offsets as required.
4547

4648
#### Implementing `read_size` and `write_size`
4749

48-
These read and write the limits used by the write and read operations. Writing or reading beyond the set size must be truncated to the current size.
50+
`read_size` and `write_size` read and write the limits the write and read operations use. Writing or reading beyond the set size must be truncated to the current size.
4951

5052
#### Implementing `erase_bytes`
5153

52-
This is the equivalent of calling `write_bytes` with a buffer filled with `0`. Like `write_bytes` it must return the number of bytes successfully set to `0`.
54+
This is the equivalent of calling `write_bytes` with a buffer filled with `0`. Like `write_bytes`, it must return the number of bytes successfully set to `0`.
5355

5456
### Asynchronous operation
5557

56-
Depending on your hardware you may support synchronous or asynchronous operation.
58+
Depending on your hardware, you may support synchronous or asynchronous operation.
59+
60+
We designed the `NFCEEPROMDriver` with asynchronous operation, and the results of long operations are communicated through events. You must use these events, even if your implementation is synchronous.
5761

58-
The `NFCEEPROMDriver` is designed with asynchronous operation in mind and the results of long operations are communicated through events. These must be used even if your implementation is synchronous.
62+
In asynchronous implementations, you may use an `EventQueue` to schedule processing caused by interrupts. The `NFCTarget` has set up your event queue, which you can get by calling:
5963

60-
In asynchronous implementations you may use an `EventQueue` to schedule processing caused by interrupts. The `NFCTarget` has set up your event queue which you can get by calling:
6164
`EventQueue* event_queue()`
6265

6366
You may initiate your event processing by calling `call()` on the event queue.
6467

6568
For example:
6669

67-
if your event management is done in a function called `manage_event` then you should call:
68-
`event_queue()->call(&manage_event);`.
69-
The `EventQueue` also accepts passed in parameters and objects for non-static method calls - please see the `EventQueue` documentation for details on calling functions on the queue.
70+
If your event management occurs in a function called `manage_event`, you should call:
71+
72+
`event_queue()->call(&manage_event);`
73+
74+
The `EventQueue` also accepts passed in parameters and objects for nonstatic method calls. Please see the `EventQueue` documentation for details on calling functions on the queue.
7075

7176
#### Communicating events back to the NFCTarget
7277

73-
All events shall call methods in the `Delegate` class object that has been set by the `NFCTarget`. Delegate is accessible through:
78+
All events call methods in the `Delegate` class object that has been set by the `NFCTarget`. Delegate is accessible through:
7479
`Delegate* delegate()`
7580

7681
It implements the following methods:
@@ -83,11 +88,11 @@ It implements the following methods:
8388
- `void on_size_read(bool success, size_t size)`
8489
- `void on_bytes_erased(size_t count)`
8590

86-
These must be used to communicate the results of all asynchronous calls.
91+
You must use these to communicate the results of all asynchronous calls.
8792

8893
### Testing
8994

90-
A macro `NFCEEPROM` is required for the test to be built. The module containing your driver should comtain `mbed_lib.json`. Add a configuration option for the build system to convert into a macro. Your `mbed_lib.json` could look like this:
95+
A macro `NFCEEPROM` is required for the test to build. The module containing your driver should contain `mbed_lib.json`. Add a configuration option for the build system to convert into a macro. Your `mbed_lib.json` could look like this:
9196

9297
```javascript
9398
{
@@ -103,4 +108,5 @@ A macro `NFCEEPROM` is required for the test to be built. The module containing
103108
```
104109

105110
Run the tests with:
111+
106112
`mbed test -m [mcu] -t [toolchain] -n tests-nfc-eeprom*`.

0 commit comments

Comments
 (0)