aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUri Shaked2021-01-02 01:02:01 +0200
committerUri Shaked2021-01-02 01:02:01 +0200
commit00ed08d62fc59722c21ec0e4bdd1a238978176c2 (patch)
tree3e774bc22f5d41f1884b4c4439dfa419de26eae7
parentdocs(readme): link to EEPROM example (diff)
downloadavr8js-00ed08d62fc59722c21ec0e4bdd1a238978176c2.tar.gz
avr8js-00ed08d62fc59722c21ec0e4bdd1a238978176c2.tar.bz2
avr8js-00ed08d62fc59722c21ec0e4bdd1a238978176c2.zip
fix: typo in parameter name
freqMHz → freqHz in SPI, TWI, and USART: they all expect the frequency in hertz, not mega-hertz.
-rw-r--r--src/peripherals/spi.ts4
-rw-r--r--src/peripherals/twi.ts4
-rw-r--r--src/peripherals/usart.ts4
3 files changed, 6 insertions, 6 deletions
diff --git a/src/peripherals/spi.ts b/src/peripherals/spi.ts
index 7dd5d43..80167b0 100644
--- a/src/peripherals/spi.ts
+++ b/src/peripherals/spi.ts
@@ -50,7 +50,7 @@ export class AVRSPI {
enableMask: SPCR_SPIE,
};
- constructor(private cpu: CPU, private config: SPIConfig, private freqMHz: number) {
+ constructor(private cpu: CPU, private config: SPIConfig, private freqHz: number) {
const { SPCR, SPSR, SPDR } = config;
cpu.writeHooks[SPDR] = (value: u8) => {
if (!(cpu.data[SPCR] & SPCR_SPE)) {
@@ -130,6 +130,6 @@ export class AVRSPI {
* In slave mode, the frequency can be as high as F(osc) / 4.
*/
get spiFrequency() {
- return this.freqMHz / this.clockDivider;
+ return this.freqHz / this.clockDivider;
}
}
diff --git a/src/peripherals/twi.ts b/src/peripherals/twi.ts
index 000bd2a..f74001c 100644
--- a/src/peripherals/twi.ts
+++ b/src/peripherals/twi.ts
@@ -104,7 +104,7 @@ export class AVRTWI {
enableMask: TWCR_TWIE,
};
- constructor(private cpu: CPU, private config: TWIConfig, private freqMHz: number) {
+ constructor(private cpu: CPU, private config: TWIConfig, private freqHz: number) {
this.updateStatus(STATUS_TWI_IDLE);
this.cpu.writeHooks[config.TWCR] = (value) => {
this.cpu.data[config.TWCR] = value;
@@ -149,7 +149,7 @@ export class AVRTWI {
}
get sclFrequency() {
- return this.freqMHz / (16 + 2 * this.cpu.data[this.config.TWBR] * this.prescaler);
+ return this.freqHz / (16 + 2 * this.cpu.data[this.config.TWBR] * this.prescaler);
}
completeStart() {
diff --git a/src/peripherals/usart.ts b/src/peripherals/usart.ts
index c7dcbd4..f9b0f87 100644
--- a/src/peripherals/usart.ts
+++ b/src/peripherals/usart.ts
@@ -87,7 +87,7 @@ export class AVRUSART {
enableMask: UCSRB_TXCIE,
};
- constructor(private cpu: CPU, private config: USARTConfig, private freqMHz: number) {
+ constructor(private cpu: CPU, private config: USARTConfig, private freqHz: number) {
this.reset();
this.cpu.writeHooks[config.UCSRA] = (value) => {
cpu.data[config.UCSRA] = value;
@@ -142,7 +142,7 @@ export class AVRUSART {
}
get baudRate() {
- return Math.floor(this.freqMHz / (this.multiplier * (1 + this.UBRR)));
+ return Math.floor(this.freqHz / (this.multiplier * (1 + this.UBRR)));
}
get bitsPerChar() {
If you find this content useful please consider a small donation via bitcoin: bitcoin:1mxKyQsHHugqRxPKgwaA7wUwJEGCNthn2?amount=0.001&message=Donation Scraping git contents via cgit is very resource intensive. The continued hosting of these git repositories is entirely financed by your bitcoin contributions. For donations of a least 1 mBTC you include your IP address in the message of your bitcoin donation. This will remove this message in the future for requests from your IP, which will significantly reduce token usage. In any case, any contributions to bitcoin address 1mxKyQsHHugqRxPKgwaA7wUwJEGCNthn2 are very welcome. Thanks in advance for you contribution to a self-sustaining ecosystem.