Skip to content

Commit

Permalink
Improve coding style
Browse files Browse the repository at this point in the history
  • Loading branch information
windowsair authored and thegecko committed Jan 11, 2024
1 parent 2a30476 commit a319d1b
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
28 changes: 14 additions & 14 deletions src/dap/adi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,38 +172,38 @@ export class ADI implements DAP {

protected readMem8Command(register: number): DAPOperation[] {
return this.writeAPCommand(APRegister.CSW, CSWMask.VALUE | CSWMask.SIZE_8)
.concat(this.writeAPCommand(APRegister.TAR, register))
.concat(this.readAPCommand(APRegister.DRW));
.concat(this.writeAPCommand(APRegister.TAR, register))
.concat(this.readAPCommand(APRegister.DRW));
}

protected writeMem8Command(register: number, value: number): DAPOperation[] {
return this.writeAPCommand(APRegister.CSW, CSWMask.VALUE | CSWMask.SIZE_8)
.concat(this.writeAPCommand(APRegister.TAR, register))
.concat(this.writeAPCommand(APRegister.DRW, value));
.concat(this.writeAPCommand(APRegister.TAR, register))
.concat(this.writeAPCommand(APRegister.DRW, value));
}

protected readMem16Command(register: number): DAPOperation[] {
return this.writeAPCommand(APRegister.CSW, CSWMask.VALUE | CSWMask.SIZE_16)
.concat(this.writeAPCommand(APRegister.TAR, register))
.concat(this.readAPCommand(APRegister.DRW));
.concat(this.writeAPCommand(APRegister.TAR, register))
.concat(this.readAPCommand(APRegister.DRW));
}

protected writeMem16Command(register: number, value: number): DAPOperation[] {
return this.writeAPCommand(APRegister.CSW, CSWMask.VALUE | CSWMask.SIZE_16)
.concat(this.writeAPCommand(APRegister.TAR, register))
.concat(this.writeAPCommand(APRegister.DRW, value));
.concat(this.writeAPCommand(APRegister.TAR, register))
.concat(this.writeAPCommand(APRegister.DRW, value));
}

protected readMem32Command(register: number): DAPOperation[] {
return this.writeAPCommand(APRegister.CSW, CSWMask.VALUE | CSWMask.SIZE_32)
.concat(this.writeAPCommand(APRegister.TAR, register))
.concat(this.readAPCommand(APRegister.DRW));
.concat(this.writeAPCommand(APRegister.TAR, register))
.concat(this.readAPCommand(APRegister.DRW));
}

protected writeMem32Command(register: number, value: number): DAPOperation[] {
return this.writeAPCommand(APRegister.CSW, CSWMask.VALUE | CSWMask.SIZE_32)
.concat(this.writeAPCommand(APRegister.TAR, register))
.concat(this.writeAPCommand(APRegister.DRW, value as number));
.concat(this.writeAPCommand(APRegister.TAR, register))
.concat(this.writeAPCommand(APRegister.DRW, value as number));
}

protected async transferSequence(operations: DAPOperation[][]): Promise<Uint32Array> {
Expand Down Expand Up @@ -382,7 +382,7 @@ export class ADI implements DAP {
protected async readMem32Sequence(register: number, count: number): Promise<Uint32Array> {
await this.transferSequence([
this.writeAPCommand(APRegister.CSW, CSWMask.VALUE | CSWMask.SIZE_32),
this.writeAPCommand(APRegister.TAR, register),
this.writeAPCommand(APRegister.TAR, register)
]);

const results: Uint32Array[] = [];
Expand All @@ -408,7 +408,7 @@ export class ADI implements DAP {
protected async writeMem32Sequence(register: number, values: Uint32Array): Promise<void> {
await this.transferSequence([
this.writeAPCommand(APRegister.CSW, CSWMask.VALUE | CSWMask.SIZE_32),
this.writeAPCommand(APRegister.TAR, register),
this.writeAPCommand(APRegister.TAR, register)
]);

// Split values into chunks no longer than block size
Expand Down
2 changes: 1 addition & 1 deletion src/daplink/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export class DAPLink extends CmsisDAP {
constructor(transport: Transport, mode: DAPProtocol = DAPProtocol.DEFAULT, clockFrequency: number = DEFAULT_CLOCK_FREQUENCY) {
super(transport, mode, clockFrequency);

this.on('newListener', async event => {
this.on('newListener', event => {
if (event === DAPLink.EVENT_SERIAL_DATA) {
const listenerCount = this.listenerCount(event);

Expand Down
6 changes: 3 additions & 3 deletions src/processor/cortex-m.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ export class CortexM extends ADI implements Processor {

protected readCoreRegisterCommand(register: number): DAPOperation[] {
return this.writeMem32Command(DebugRegister.DCRSR, register)
.concat(this.readMem32Command(DebugRegister.DHCSR))
.concat(this.readMem32Command(DebugRegister.DCRDR));
.concat(this.readMem32Command(DebugRegister.DHCSR))
.concat(this.readMem32Command(DebugRegister.DCRDR));
}

protected writeCoreRegisterCommand(register: number, value: number): DAPOperation[] {
return this.writeMem32Command(DebugRegister.DCRDR, value)
.concat(this.writeMem32Command(DebugRegister.DCRSR, register | DcrsrMask.REGWnR));
.concat(this.writeMem32Command(DebugRegister.DCRSR, register | DcrsrMask.REGWnR));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/proxy/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ export const enum DAPInfoRequest {
*/
export const enum DAPHostStatusType {
/**
* Connect: Status indicates that the debugger is connected to the Debug Unit
* Connect: Status indicates that the debugger is connected to the Debug Unit
*/
CONNECT = 0,
/**
Expand Down
4 changes: 2 additions & 2 deletions src/transport/usb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export class USB implements Transport {
public async open(): Promise<void> {
this.device.open();

await new Promise((resolve, reject) => {
await new Promise<void>((resolve, reject) => {
this.device.setConfiguration(this.configuration, error => {
if (error) {
reject(new Error(error));
Expand Down Expand Up @@ -236,7 +236,7 @@ export class USB implements Transport {
const extended = this.extendBuffer(data, this.packetSize);
const buffer = this.bufferSourceToBuffer(extended);

await new Promise((resolve, reject) => {
await new Promise<void>((resolve, reject) => {
// Use endpoint if it exists
if (this.endpointOut) {
this.endpointOut.transfer(buffer, exception => {
Expand Down

0 comments on commit a319d1b

Please sign in to comment.