Skip to content

Commit f088166

Browse files
committed
style: reformat code with prettier
1 parent 61e1d2c commit f088166

File tree

8 files changed

+61
-47
lines changed

8 files changed

+61
-47
lines changed

jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module.exports = {
22
preset: 'ts-jest',
33
testEnvironment: 'node',
4-
};
4+
};

src/interpolator.ts

Lines changed: 46 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -16,36 +16,36 @@ export class InterpolatorConfig {
1616
overf = false;
1717

1818
constructor(value: number) {
19-
this.shift = (value >>> 0) & 0b11111;
20-
this.maskLSB = (value >>> 5) & 0b11111;
21-
this.maskMSB = (value >>> 10) & 0b11111;
22-
this.signed = Boolean((value >>> 15) & 1);
23-
this.crossInput = Boolean((value >>> 16) & 1);
19+
this.shift = (value >>> 0) & 0b11111;
20+
this.maskLSB = (value >>> 5) & 0b11111;
21+
this.maskMSB = (value >>> 10) & 0b11111;
22+
this.signed = Boolean((value >>> 15) & 1);
23+
this.crossInput = Boolean((value >>> 16) & 1);
2424
this.crossResult = Boolean((value >>> 17) & 1);
25-
this.addRaw = Boolean((value >>> 18) & 1);
26-
this.forceMSB = (value >>> 19) & 0b11;
27-
this.blend = Boolean((value >>> 21) & 1);
28-
this.clamp = Boolean((value >>> 22) & 1);
29-
this.overf0 = Boolean((value >>> 23) & 1);
30-
this.overf1 = Boolean((value >>> 24) & 1);
31-
this.overf = Boolean((value >>> 25) & 1);
25+
this.addRaw = Boolean((value >>> 18) & 1);
26+
this.forceMSB = (value >>> 19) & 0b11;
27+
this.blend = Boolean((value >>> 21) & 1);
28+
this.clamp = Boolean((value >>> 22) & 1);
29+
this.overf0 = Boolean((value >>> 23) & 1);
30+
this.overf1 = Boolean((value >>> 24) & 1);
31+
this.overf = Boolean((value >>> 25) & 1);
3232
}
3333

3434
toUint32() {
3535
return (
36-
((this.shift & 0b11111) << 0) |
37-
((this.maskLSB & 0b11111) << 5) |
38-
((this.maskMSB & 0b11111) << 10) |
39-
((Number(this.signed) & 1) << 15) |
40-
((Number(this.crossInput) & 1) << 16) |
41-
((Number(this.crossResult) & 1) << 17) |
42-
((Number(this.addRaw) & 1) << 18) |
43-
((this.forceMSB & 0b11) << 19) |
44-
((Number(this.blend) & 1) << 21) |
45-
((Number(this.clamp) & 1) << 22) |
46-
((Number(this.overf0) & 1) << 23) |
47-
((Number(this.overf1) & 1) << 24) |
48-
((Number(this.overf) & 1) << 25)
36+
((this.shift & 0b11111) << 0) |
37+
((this.maskLSB & 0b11111) << 5) |
38+
((this.maskMSB & 0b11111) << 10) |
39+
((Number(this.signed) & 1) << 15) |
40+
((Number(this.crossInput) & 1) << 16) |
41+
((Number(this.crossResult) & 1) << 17) |
42+
((Number(this.addRaw) & 1) << 18) |
43+
((this.forceMSB & 0b11) << 19) |
44+
((Number(this.blend) & 1) << 21) |
45+
((Number(this.clamp) & 1) << 22) |
46+
((Number(this.overf0) & 1) << 23) |
47+
((Number(this.overf1) & 1) << 24) |
48+
((Number(this.overf) & 1) << 25)
4949
);
5050
}
5151
}
@@ -99,8 +99,8 @@ export class Interpolator {
9999
const overf1 = Boolean((input1 >>> ctrl1.shift) & ~msbmask1);
100100
const overf = overf0 || overf1;
101101

102-
const sextmask0 = (uresult0 & (1 << ctrl0.maskMSB)) ? (-1 << ctrl0.maskMSB) : 0;
103-
const sextmask1 = (uresult1 & (1 << ctrl1.maskMSB)) ? (-1 << ctrl1.maskMSB) : 0;
102+
const sextmask0 = uresult0 & (1 << ctrl0.maskMSB) ? -1 << ctrl0.maskMSB : 0;
103+
const sextmask1 = uresult1 & (1 << ctrl1.maskMSB) ? -1 << ctrl1.maskMSB : 0;
104104

105105
const sresult0 = uresult0 | sextmask0;
106106
const sresult1 = uresult1 | sextmask1;
@@ -112,18 +112,32 @@ export class Interpolator {
112112
const addresult1 = this.base1 + (ctrl1.addRaw ? input1 : result1);
113113
const addresult2 = this.base2 + result0 + (do_blend ? 0 : result1);
114114

115-
const uclamp0 = u32(result0) < u32(this.base0) ? this.base0 : (u32(result0) > u32(this.base1) ? this.base1 : result0);
116-
const sclamp0 = s32(result0) < s32(this.base0) ? this.base0 : (s32(result0) > s32(this.base1) ? this.base1 : result0);
115+
const uclamp0 =
116+
u32(result0) < u32(this.base0)
117+
? this.base0
118+
: u32(result0) > u32(this.base1)
119+
? this.base1
120+
: result0;
121+
const sclamp0 =
122+
s32(result0) < s32(this.base0)
123+
? this.base0
124+
: s32(result0) > s32(this.base1)
125+
? this.base1
126+
: result0;
117127
const clamp0 = ctrl0.signed ? sclamp0 : uclamp0;
118128

119129
const alpha1 = result1 & 0xff;
120-
const ublend1 = u32(this.base0) + (Math.floor((alpha1 * (u32(this.base1) - u32(this.base0))) / 256) | 0);
121-
const sblend1 = s32(this.base0) + (Math.floor((alpha1 * (s32(this.base1) - s32(this.base0))) / 256) | 0);
130+
const ublend1 =
131+
u32(this.base0) + (Math.floor((alpha1 * (u32(this.base1) - u32(this.base0))) / 256) | 0);
132+
const sblend1 =
133+
s32(this.base0) + (Math.floor((alpha1 * (s32(this.base1) - s32(this.base0))) / 256) | 0);
122134
const blend1 = ctrl1.signed ? sblend1 : ublend1;
123135

124136
this.smresult0 = u32(result0);
125137
this.smresult1 = u32(result1);
126-
this.result0 = u32(do_blend ? alpha1 : (do_clamp ? clamp0 : addresult0) | (ctrl0.forceMSB << 28));
138+
this.result0 = u32(
139+
do_blend ? alpha1 : (do_clamp ? clamp0 : addresult0) | (ctrl0.forceMSB << 28)
140+
);
127141
this.result1 = u32((do_blend ? blend1 : addresult1) | (ctrl0.forceMSB << 28));
128142
this.result2 = u32(addresult2);
129143

src/peripherals/adc.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ export class RPADC extends BasePeripheral implements Peripheral {
186186
value &= 0xfff; // 12 bits
187187
if (this.fcs & FCS_SHIFT) {
188188
value >>= 4;
189-
}
189+
}
190190
if (error && this.fcs & FCS_ERR) {
191191
value |= FIFO_ERR;
192192
}

src/peripherals/rtc.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ export class RP2040RTC extends BasePeripheral implements Peripheral {
5353
}
5454
if (value & RTC_ENABLE_BITS) {
5555
this.ctrl |= RTC_ENABLE_BITS;
56-
this.ctrl |= RTC_ACTIVE_BITS
56+
this.ctrl |= RTC_ACTIVE_BITS;
5757
if (this.ctrl & RTC_LOAD_BITS) {
5858
this.rtc1 = this.setup0;
5959
this.rtc0 = this.setup1;
6060
this.ctrl &= ~RTC_LOAD_BITS;
6161
}
6262
} else {
63-
this.ctrl &= ~RTC_ENABLE_BITS
64-
this.ctrl &= ~RTC_ACTIVE_BITS
63+
this.ctrl &= ~RTC_ENABLE_BITS;
64+
this.ctrl &= ~RTC_ACTIVE_BITS;
6565
}
6666
break;
6767
default:

src/peripherals/tbman.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ export class RPTBMAN extends BasePeripheral implements Peripheral {
1111
return super.readUint32(offset);
1212
}
1313
}
14-
}
14+
}

src/peripherals/usb.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ export class RPUSBController extends BasePeripheral {
226226
}
227227
}
228228

229-
if (doubleBuffer && ((value >> USB_BUF1_SHIFT) & USB_BUF_CTRL_AVAILABLE)) {
229+
if (doubleBuffer && (value >> USB_BUF1_SHIFT) & USB_BUF_CTRL_AVAILABLE) {
230230
const bufferLength = (value >> USB_BUF1_SHIFT) & USB_BUF_CTRL_LEN_MASK;
231231
const bufferOffset = this.getEndpointBufferOffset(endpoint, bufferOut) + USB_BUF1_OFFSET;
232232
this.debug(

src/sio.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ export class RPSIO {
179179
case INTERP0_BASE1:
180180
return this.interp0.base1;
181181
case INTERP0_BASE2:
182-
return this.interp0.base2
182+
return this.interp0.base2;
183183
case INTERP0_CTRL_LANE0:
184184
return this.interp0.ctrl0;
185185
case INTERP0_CTRL_LANE1:
@@ -191,12 +191,12 @@ export class RPSIO {
191191
case INTERP0_PEEK_FULL:
192192
return this.interp0.result2;
193193
case INTERP0_POP_LANE0: {
194-
const value = this.interp0.result0;
194+
const value = this.interp0.result0;
195195
this.interp0.writeback();
196196
return value;
197197
}
198198
case INTERP0_POP_LANE1: {
199-
const value = this.interp0.result1;
199+
const value = this.interp0.result1;
200200
this.interp0.writeback();
201201
return value;
202202
}
@@ -218,7 +218,7 @@ export class RPSIO {
218218
case INTERP1_BASE1:
219219
return this.interp1.base1;
220220
case INTERP1_BASE2:
221-
return this.interp1.base2
221+
return this.interp1.base2;
222222
case INTERP1_CTRL_LANE0:
223223
return this.interp1.ctrl0;
224224
case INTERP1_CTRL_LANE1:
@@ -230,12 +230,12 @@ export class RPSIO {
230230
case INTERP1_PEEK_FULL:
231231
return this.interp1.result2;
232232
case INTERP1_POP_LANE0: {
233-
const value = this.interp1.result0;
233+
const value = this.interp1.result0;
234234
this.interp1.writeback();
235235
return value;
236236
}
237237
case INTERP1_POP_LANE1: {
238-
const value = this.interp1.result1;
238+
const value = this.interp1.result1;
239239
this.interp1.writeback();
240240
return value;
241241
}

src/utils/bit.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ export function bit(n: number) {
33
}
44

55
export function s32(n: number) {
6-
return n | 0;
6+
return n | 0;
77
}
88

99
export function u32(n: number) {
10-
return n >>> 0;
10+
return n >>> 0;
1111
}

0 commit comments

Comments
 (0)