Skip to content

Commit 00ed08d

Browse files
committed
fix: typo in parameter name
freqMHz → freqHz in SPI, TWI, and USART: they all expect the frequency in hertz, not mega-hertz.
1 parent d243aef commit 00ed08d

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/peripherals/spi.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export class AVRSPI {
5050
enableMask: SPCR_SPIE,
5151
};
5252

53-
constructor(private cpu: CPU, private config: SPIConfig, private freqMHz: number) {
53+
constructor(private cpu: CPU, private config: SPIConfig, private freqHz: number) {
5454
const { SPCR, SPSR, SPDR } = config;
5555
cpu.writeHooks[SPDR] = (value: u8) => {
5656
if (!(cpu.data[SPCR] & SPCR_SPE)) {
@@ -130,6 +130,6 @@ export class AVRSPI {
130130
* In slave mode, the frequency can be as high as F(osc) / 4.
131131
*/
132132
get spiFrequency() {
133-
return this.freqMHz / this.clockDivider;
133+
return this.freqHz / this.clockDivider;
134134
}
135135
}

src/peripherals/twi.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export class AVRTWI {
104104
enableMask: TWCR_TWIE,
105105
};
106106

107-
constructor(private cpu: CPU, private config: TWIConfig, private freqMHz: number) {
107+
constructor(private cpu: CPU, private config: TWIConfig, private freqHz: number) {
108108
this.updateStatus(STATUS_TWI_IDLE);
109109
this.cpu.writeHooks[config.TWCR] = (value) => {
110110
this.cpu.data[config.TWCR] = value;
@@ -149,7 +149,7 @@ export class AVRTWI {
149149
}
150150

151151
get sclFrequency() {
152-
return this.freqMHz / (16 + 2 * this.cpu.data[this.config.TWBR] * this.prescaler);
152+
return this.freqHz / (16 + 2 * this.cpu.data[this.config.TWBR] * this.prescaler);
153153
}
154154

155155
completeStart() {

src/peripherals/usart.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export class AVRUSART {
8787
enableMask: UCSRB_TXCIE,
8888
};
8989

90-
constructor(private cpu: CPU, private config: USARTConfig, private freqMHz: number) {
90+
constructor(private cpu: CPU, private config: USARTConfig, private freqHz: number) {
9191
this.reset();
9292
this.cpu.writeHooks[config.UCSRA] = (value) => {
9393
cpu.data[config.UCSRA] = value;
@@ -142,7 +142,7 @@ export class AVRUSART {
142142
}
143143

144144
get baudRate() {
145-
return Math.floor(this.freqMHz / (this.multiplier * (1 + this.UBRR)));
145+
return Math.floor(this.freqHz / (this.multiplier * (1 + this.UBRR)));
146146
}
147147

148148
get bitsPerChar() {

0 commit comments

Comments
 (0)