-
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
19 changed files
with
281 additions
and
96 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 @@ | ||
export * from './src/api-types'; |
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,74 @@ | ||
# Extending Peripheral Inspector | ||
|
||
It is possible to extend the Peripheral Inspector with new file extension providers in your VSCode extension. This method will provide reading new file formats and load the peripherals information into the Peripheral Inspector. | ||
|
||
## Building your VSCode Extension to extend Peripheral Inspector | ||
|
||
This is a guide about how you can register new peripheral providers to Peripheral Inspector in your VSCode extension. Please refer to [VSCode Extension API](https://code.visualstudio.com/api) for more information about developing VSCode extensions. | ||
|
||
### Adding Peripheral Inspector to your VSCode extension | ||
|
||
You need to install eclipse-cdt-cloud/vscode-peripheral-inspector 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-peripheral-inspector | ||
``` | ||
Using with yarn: | ||
```bash | ||
yarn add github:eclipse-cdt-cloud/vscode-peripheral-inspector | ||
``` | ||
|
||
### Developing your extension | ||
|
||
To provide the peripherals information to Peripheral Inspector on debug session time, you need register your command which is going to 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 type * as api from "peripheral-inspector/api"; | ||
|
||
|
||
class MyExtensionProvider implements api.IPeripheralsProvider { | ||
public async getPeripherals (data: string, options: api.IGetPeripheralsArguments): Promise<api.PeripheralOptions[]> { | ||
// Load your peripherals data | ||
const peripherals: api.PeripheralOptions[] = ... | ||
return peripherals; | ||
} | ||
} | ||
|
||
export async function activate(context: ExtensionContext) { | ||
... | ||
// Get the eclipse-cdt.peripheral-inspector extension | ||
const peripheralInspectorExtention = extensions.getExtension<api.IPeripheralInspectorAPI>('eclipse-cdt.peripheral-inspector'); | ||
|
||
// Check if the eclipse-cdt.peripheral-inspector extension is installed | ||
if (peripheralInspectorExtention) { | ||
const peripheralInspectorAPI = await peripheralInspectorExtention.activate(); | ||
|
||
// Invoke registerPeripheralsProvider method in eclipse-cdt.peripheral-inspector extension api | ||
// Register 'MyExtensionProvider' for files *.myext | ||
peripheralInspectorAPI.registerPeripheralsProvider('myext', new MyExtensionProvider()); | ||
} | ||
... | ||
} | ||
``` | ||
|
||
For further information about the api definitions, review the [Peripheral Inspector API Definitions](../src/api-types.ts). | ||
|
||
### Modifying your package.json | ||
|
||
In `package.json` of your VSCode extension project, you need to define the dependency between Peripheral Inspector and your extension. | ||
|
||
You need to define Peripheral Inspector in the `extensionDependencies` as shown below: | ||
|
||
```json | ||
{ | ||
... | ||
"extensionDependencies": [ | ||
"eclipse-cdt.peripheral-inspector" | ||
], | ||
... | ||
} | ||
``` |
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,83 @@ | ||
// Peripheral Inspector API | ||
export interface IPeripheralInspectorAPI { | ||
registerSVDFile: (expression: RegExp | string, path: string) => void; | ||
getSVDFile: (device: string) => string | undefined; | ||
getSVDFileFromCortexDebug: (device: string) => Promise<string | undefined>; | ||
registerPeripheralsProvider: (fileExtension: string, provider: IPeripheralsProvider) => void; | ||
} | ||
|
||
export interface IPeripheralsProvider { | ||
getPeripherals: (data: string, options: IGetPeripheralsArguments) => Promise<PeripheralOptions[]>; | ||
} | ||
|
||
export interface IGetPeripheralsArguments { | ||
gapThreshold: number; | ||
} | ||
|
||
export interface PeripheralOptions { | ||
name: string; | ||
baseAddress: number; | ||
totalLength: number; | ||
description: string; | ||
groupName?: string; | ||
accessType?: AccessType; | ||
size?: number; | ||
resetValue?: number; | ||
registers?: PeripheralRegisterOptions[]; | ||
clusters?: ClusterOptions[]; | ||
} | ||
|
||
export interface PeripheralRegisterOptions { | ||
name: string; | ||
description?: string; | ||
addressOffset: number; | ||
accessType?: AccessType; | ||
size?: number; | ||
resetValue?: number; | ||
fields?: FieldOptions[]; | ||
} | ||
|
||
export interface ClusterOptions { | ||
name: string; | ||
description?: string; | ||
addressOffset: number; | ||
accessType?: AccessType; | ||
size?: number; | ||
resetValue?: number; | ||
registers?: PeripheralRegisterOptions[]; | ||
clusters?: ClusterOptions[]; | ||
} | ||
|
||
export interface FieldOptions { | ||
name: string; | ||
description: string; | ||
offset: number; | ||
width: number; | ||
enumeration?: EnumerationMap; | ||
derivedFrom?: string; // Set this if unresolved | ||
accessType?: AccessType; | ||
} | ||
|
||
export interface IGetPeripheralsArguments { | ||
gapThreshold: number; | ||
} | ||
|
||
export interface IPeripheralsProvider { | ||
getPeripherals: (data: string, options: IGetPeripheralsArguments) => Promise<PeripheralOptions[]>; | ||
} | ||
|
||
export declare enum AccessType { | ||
ReadOnly = 1, | ||
ReadWrite = 2, | ||
WriteOnly = 3 | ||
} | ||
|
||
export interface EnumerationMap { | ||
[value: number]: IEnumeratedValue; | ||
} | ||
|
||
export interface IEnumeratedValue { | ||
name: string; | ||
description: string; | ||
value: number; | ||
} |
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
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,3 @@ | ||
export class EnumeratedValue { | ||
constructor(public name: string, public description: string, public value: number) {} | ||
} |
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
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
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
Oops, something went wrong.