-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
182 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# Appendix: Types of `svd-viewer` | ||
|
||
Types could be imported from `svd-viewer` like the code below: | ||
|
||
```js | ||
import { | ||
AccessType, | ||
PeripheralOptions, | ||
PeripheralRegisterOptions, | ||
ClusterOptions, | ||
FieldOptions | ||
} from "svd-viewer"; | ||
``` | ||
|
||
## Enum: AccessType | ||
|
||
AccessType enum defines the type of the access to the related peripheral item. | ||
|
||
```js | ||
enum AccessType { | ||
ReadOnly = 1, | ||
ReadWrite, | ||
WriteOnly | ||
} | ||
``` | ||
|
||
## Interface: PeripheralOptions | ||
|
||
The definition of the PeripheralOptions interface is shown below: | ||
|
||
```js | ||
interface PeripheralOptions { | ||
name: string; | ||
baseAddress: number; | ||
totalLength: number; | ||
description: string; | ||
groupName?: string; | ||
accessType?: AccessType; | ||
size?: number; | ||
resetValue?: number; | ||
registers?: PeripheralRegisterOptions[]; | ||
clusters?: ClusterOptions[]; | ||
} | ||
``` | ||
## Interface: PeripheralRegisterOptions | ||
|
||
The definition of the PeripheralRegisterOptions interface is shown below: | ||
|
||
```js | ||
interface PeripheralRegisterOptions { | ||
name: string; | ||
description?: string; | ||
addressOffset: number; | ||
accessType?: AccessType; | ||
size?: number; | ||
resetValue?: number; | ||
fields?: FieldOptions[]; | ||
} | ||
``` | ||
|
||
## Interface: ClusterOptions Interface | ||
|
||
The definition of the ClusterOptions interface is shown below: | ||
|
||
```js | ||
interface ClusterOptions { | ||
name: string; | ||
description?: string; | ||
addressOffset: number; | ||
accessType?: AccessType; | ||
size?: number; | ||
resetValue?: number; | ||
registers?: PeripheralRegisterOptions[]; | ||
clusters?: ClusterOptions[]; | ||
} | ||
``` | ||
|
||
## Interface: FieldOptions Interface | ||
|
||
The definition of the FieldOptions interface is shown below: | ||
|
||
```js | ||
interface FieldOptions { | ||
name: string; | ||
description: string; | ||
offset: number; | ||
width: number; | ||
enumeration?: EnumerationMap; | ||
accessType?: AccessType; | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# Extending SVD Viewer | ||
|
||
It is possible to extend the SVD Viewer and register new file extension providers with your VSCode extension. This method will provide reading non-svd formats and load the peripherals information in SVD Viewer. | ||
|
||
## Building your VSCode Extension to extend SVD Viewer | ||
|
||
This is a guide about how you can register new peripheral providers to SVD Viewer in your VSCode extension. Please refer to [VSCode Extension API](https://code.visualstudio.com/api) for more information about developing VSCode extensions. | ||
|
||
### Adding peripheral-viewer to your VSCode extension | ||
|
||
You need to install eclipse-cdt-cloud/vscode-svd-viewer to access the types information. You can use `npm` or `yarn` with the following arguments described below: | ||
|
||
Using with npm: | ||
```bash | ||
npm install github:eclipse-cdt-cloud/vscode-svd-viewer | ||
``` | ||
Using with yarn: | ||
```bash | ||
yarn add github:eclipse-cdt-cloud/vscode-svd-viewer | ||
``` | ||
|
||
### Developing your extension | ||
|
||
To provide the peripherals information to SVD Viewer on debug session time, you need register your command which is going construct the peripherals information. The command will receive `DebugSession` object as an input parameter and expects to return array of type `PeripheralOptions[]`. | ||
|
||
You can find the example command implementation below: | ||
|
||
```js | ||
import { ExtensionContext } from 'vscode'; | ||
import { | ||
PeripheralOptions, | ||
PeripheralRegisterOptions, | ||
ClusterOptions, | ||
FieldOptions, | ||
AccessType, | ||
IGetPeripheralsArguments, | ||
IPeripheralsProvider | ||
} from "svd-viewer"; | ||
|
||
|
||
class MyExtensionProvider implements IPeripheralsProvider { | ||
public async getPeripherals (data: string, options: IGetPeripheralsArguments): Promise<PeripheralOptions[]> { | ||
// Load your peripherals data | ||
const peripherals: PeripheralOptions[] = ... | ||
return peripherals; | ||
} | ||
} | ||
|
||
export async function activate(context: ExtensionContext) { | ||
... | ||
// Get the eclipse-cdt.svd-viewer extension | ||
const svdViewerExtension = extensions.getExtension('eclipse-cdt.svd-viewer'); | ||
|
||
// Invoke registerPeripheralsProvider method in eclipse-cdt.svd-viewer extension api | ||
// Register 'MyExtensionProvider' for files *.myext | ||
svdViewerExtension?.exports?.registerPeripheralsProvider('myext', new MyExtensionProvider()); | ||
... | ||
} | ||
``` | ||
You can check the type definitions (`PeripheralOptions`, `PeripheralRegisterOptions`, `ClusterOptions`, `FieldOptions`, `AccessType`) from [this document](./appendix-types.md). | ||
### Modifying your package.json | ||
In `package.json` of your VSCode extension project, you need to define the dependency between svd-viewer and your extension. | ||
You need to define SVD Viewer in the `extensionDependencies` as shown below: | ||
```json | ||
{ | ||
... | ||
"extensionDependencies": [ | ||
"eclipse-cdt.svd-viewer" | ||
], | ||
... | ||
} | ||
``` |