|
| 1 | +# Mbed-OS Design Document |
| 2 | +Write your feature title above, in this case its "Mbed-OS Design Document" |
| 3 | + |
| 4 | +# Table of Contents |
| 5 | +- [Mbed-OS Design Document](#mbed-os-design-document) |
| 6 | +- [Table of Contents](#table-of-contents) |
| 7 | + - [Revision history](#revision-history) |
| 8 | +- [Introduction](#introduction) |
| 9 | + - [Overview and Background](#overview-and-background) |
| 10 | + - [Requirements and Assumptions](#requirements-and-assumptions) |
| 11 | +- [System Architecture and High-Level Design](#system-architecture-and-high-level-design) |
| 12 | + - [System Architecture and Component Interaction](#system-architecture-and-component-interaction) |
| 13 | +- [Detailed Design](#detailed-design) |
| 14 | +- [Usage Scenarios and Examples](#usage-scenarios-and-examples) |
| 15 | +- [Tools and Configuration Changes](#tools-and-configuration-changes) |
| 16 | +- [Other Information](#other-information) |
| 17 | + - [Reusability](#reusability) |
| 18 | + - [Deprecations](#deprecations) |
| 19 | + - [References](#references) |
| 20 | + - [Custom Headings Here](#custom-headings-here) |
| 21 | + |
| 22 | +### Revision history |
| 23 | +1.0 - A brief description for this version, e.g. Initial revision - Author name - Date |
| 24 | +1.1 - Added new section - Author name - Date |
| 25 | + |
| 26 | +# Introduction |
| 27 | +### Overview and Background |
| 28 | +Provide a background of this feature. Briefly explain why this feature is needed, what is it accomplishing, what problem its solving. If you already have a requirement written for this feature you may also use the contents of the requirement to provide user with overall context of why this feature is needed. |
| 29 | +For example:- This document provides a template for writing software design documents for Mbed-OS features. |
| 30 | + |
| 31 | +### Requirements and Assumptions |
| 32 | +Capture the requirements for this feature to work and other assumptions made. For example, if you are assuming specific |
| 33 | +hw capabilities, memory requirements, security assets like presence of RoT infrastructure, then capture those here. |
| 34 | +For example:- This feature requires QuadSPI interface on the target as it implements block device driver over QuadSPI |
| 35 | +interface. It also assumes the system can provide 16K of memory for buffering. |
| 36 | + |
| 37 | +# System Architecture and High-Level Design |
| 38 | +This section provides high level information on areas or components needing changes or new development to implement this |
| 39 | +feature. The idea here is to capture the high level design goals of this feature for the target reader, the focus here should |
| 40 | +be what functionality it provides and not the actual implementation. For example, if you are implementing a new device driver |
| 41 | +for a communication peripheral/device then the high level design goals could be as below. Add more descrption to each high level design goal if required. |
| 42 | + |
| 43 | +* `Configuring the device` - The driver should provide a specific interface to configure the communication paramaters for the device. |
| 44 | +* `Starting and stopping the device` - The driver should provide interfaces to start and stop all the communications. |
| 45 | +* `Reading from and Writing to the device` - Read and Write interfaces should be implemented to support sending single/multiple bytes. |
| 46 | +* `Resetting the device` - Functionality to reset the device should be provided. |
| 47 | + |
| 48 | +**NOTE: If you already have supporting architecture documentation in the form of technology documents or other existing documents |
| 49 | +feel free to link them here and use that, you don't have to replicate the same documentation here.** |
| 50 | + |
| 51 | +For each high level design goal, provide detailed software design under [Detailed Design](#detailed-design) section providing more details on implementation. |
| 52 | + |
| 53 | +### System Architecture and Component Interaction |
| 54 | +Description and diagrams showing overall architecture of how the above-mentioned components/resources interface with each other. |
| 55 | +For, example if the new feature is to implement a driver and if it provides interfaces with application and uses memory subsystem in OS |
| 56 | +to talk to the device the diagram may look something like below. The goal here is to capture high level components and their interaction and not the |
| 57 | +minute details. |
| 58 | + |
| 59 | + |
| 60 | + |
| 61 | +# Detailed Design |
| 62 | +This section provides detailed design on implementation of each of the high level design goal mentioned above. |
| 63 | +Each components/modules needing changes are also captured in details. The target audience here is a developer |
| 64 | +who can read this section and start the real implemention. You can capture things like signature of interfaces, |
| 65 | +flow charts showing how the APIs work, data flow diagrams etc. The headings for each detailed design section |
| 66 | +should match the headings in high level design goals. For example, based on the example provided above, |
| 67 | +the headings for details design sections should be `Configuring the device`, `Starting and stopping the device`, |
| 68 | +`Reading from and Writing to the device`, `Resetting the device`. |
| 69 | + |
| 70 | +### Detailed Design 1 - e.g, `Configuring the device` |
| 71 | + |
| 72 | +**API Description** |
| 73 | +Detailed API Description like signature of interface, explanation of arguments, return codes etc. |
| 74 | +For example, if you are trying to define an interface for configuring the device, you may describe |
| 75 | +the API as below. |
| 76 | + |
| 77 | + `Configure API should have following signature: |
| 78 | + mbed_error_status_t configure(int speed, enum flow_control_t flow_control, int parity_bits);` |
| 79 | + where:` |
| 80 | + speed - is an integer value representing the target communication speed |
| 81 | + flow_control - is the enum value representing the flow control to be used |
| 82 | + parity_bits - is an integer value indicating the parity_bits to be used |
| 83 | + |
| 84 | + And the function should return mbed_error_status_t value indicating the result of the call as below: |
| 85 | + MBED_SUCCESS if the call is successful. |
| 86 | + MBED_ERROR_INVALID_ARGUMENT if input values are invalid.` |
| 87 | + MBED_ERROR_CONFIG_UNSUPPORTED if the device doesnt support the requested configuration.` |
| 88 | + |
| 89 | +**Configuration Sequence Diagram** |
| 90 | + |
| 91 | +Sequence Diagrams, Data flow diagrams etc. For example, the flow chart for configure device API above may |
| 92 | +be something like below. |
| 93 | + |
| 94 | + |
| 95 | + |
| 96 | +### Detailed Design 2 - e.g, `Starting and stopping the device` |
| 97 | + |
| 98 | +**API Description** |
| 99 | +Detailed API Description like signature of interface, explanation of arguments, return codes etc |
| 100 | +For example, for start and stop functions exported by the driver. |
| 101 | + |
| 102 | +**Sequence Diagrams for `Starting and stopping the device`** |
| 103 | +Sequence Diagrams, Data flow diagrams etc. For example, the sequence digram for stopping the device may look |
| 104 | +something like below. |
| 105 | + |
| 106 | + |
| 107 | + |
| 108 | +### Detailed Design 3 - e.g, `Reading from and Writing to the device` |
| 109 | + |
| 110 | +**API Description** |
| 111 | +Detailed API Description like signature of interface, explanation of arguments, return codes etc |
| 112 | + |
| 113 | +**Sequence Diagram for `Reading from and Writing to the device`** |
| 114 | +Sequence Diagrams, Data flow diagrams etc. |
| 115 | + |
| 116 | +### Detailed Design N - e.g, `Resetting the device` |
| 117 | + |
| 118 | +**API Description** |
| 119 | +Detailed API Description like signature of interface, explanation of arguments, return codes etc |
| 120 | + |
| 121 | +**Sequence Diagram for `Resetting the device`** |
| 122 | +Sequence Diagrams, Data flow diagrams etc. |
| 123 | + |
| 124 | +# Usage Scenarios and Examples |
| 125 | +Show pseudo-code or flowcharts explaining the usage of the feature. For example you may want to include |
| 126 | +some pseudo code to demonstrate how the read functionality is used with the new driver design you are |
| 127 | +proposing. |
| 128 | + |
| 129 | +### Scenario 1 - e.g, `Reading from the device` |
| 130 | +Mention the specific usage scenarios here. For example, the below examples shows how to read data from |
| 131 | +device using the new APIs. |
| 132 | + |
| 133 | +**Scenario 1 Example 1. - e.g, `Reading a byte from device`** |
| 134 | +Mention the specific usage here. For example, the below example shows pseudo-code for how to read a single byte data from |
| 135 | +the device using the new APIs. |
| 136 | + |
| 137 | +```C |
| 138 | +char in_byte = 0; |
| 139 | +int num_bytes_read = read(&in_byte, 1); |
| 140 | +if(num_bytes_read == 1) { |
| 141 | + //do something |
| 142 | + ... |
| 143 | +} |
| 144 | +``` |
| 145 | +**Scenario 1 Example 2. - e.g, `Reading multiple bytes from device`** |
| 146 | +In this example, the pseudo-code below shows how to read multiple bytes of data from the device using the new APIs. |
| 147 | + |
| 148 | +```C |
| 149 | +char in_bytes[NUM_BYTES]; |
| 150 | +int num_bytes_read = read(in_bytes, NUM_BYTES); |
| 151 | +if(num_bytes_read == NUM_BYTES) { |
| 152 | + //process bytes read |
| 153 | + ... |
| 154 | +} |
| 155 | +``` |
| 156 | +### Scenario 2 - e.g, `Writing to the device` |
| 157 | +Mention another usage scenarios here. For example, you can demostrate how to write to the device |
| 158 | +and few examples of usage. |
| 159 | + |
| 160 | +**Scenario 2 Example 1. - e.g, `Writing a byte to device`** |
| 161 | +Demonstrate the specific example here. For example, how to write a byte of data to device. |
| 162 | + |
| 163 | +**Scenario 2 Example 2. - e.g, `Writing multiple bytes to device`** |
| 164 | +Demonstrate another specific example here. For example, how to write mutiple bytes of data to device. |
| 165 | + |
| 166 | +# Tools and Configuration Changes |
| 167 | +Explain which tools needs to be changed and the nature of changes. |
| 168 | +For example, if the feature requires adding a new sub-command to mbed-cli capture |
| 169 | +the details of changes and usage here. Each tool change can be captured under its own |
| 170 | +sub-heading as below. You can also capture new configuration values which needs to be |
| 171 | +added to mbed json based configuration system. For each, config value added explan |
| 172 | +the name of the config value and how to use it and its relation to any pre-processor |
| 173 | +defines in the implementation. |
| 174 | + |
| 175 | +### Tool Change 1 - e.g: - Command line additions/changes |
| 176 | + |
| 177 | +### Configuration Changes e.g: - Configuration changes in Json files etc |
| 178 | + |
| 179 | +# Other Information |
| 180 | +Add other relevant information you would like to capture. Add custom headings if required. |
| 181 | + |
| 182 | +### Reusability |
| 183 | +List the components or pieces of implementation which can be re-used for specific |
| 184 | +design patterns/other implementations. |
| 185 | + |
| 186 | +### Deprecations |
| 187 | +List the APIs which may be deprecated as part of this feature. |
| 188 | + |
| 189 | +### References |
| 190 | +Capture information such as specifications, other design docs, other implementations Urls etc. |
| 191 | + |
| 192 | +### Custom Headings Here |
| 193 | +Add your custom headings here, for example security impacts of this feature can be put |
| 194 | +under the heading `Security Impacts`. |
0 commit comments