3 Commits
Author SHA1 Message Date
veroxzik 70b3a745ab Updated donation link 2025-05-31 19:49:02 -04:00
veroxzik 9524fc0acd Merge pull request #6 from Lay31415/Lay31415-patch-1
Fix SPR2 register compilation error for 8MHz ATmega32U4 boards
2025-05-31 19:22:52 -04:00
Lay31415 83c8651158 Fix SPR2 register error for ATmega32U4 compatibility
- Replace non-existent SPR2 with correct SPR1 and SPI2X combination
- SPR1=1, SPR0=0, SPI2X=1 achieves Fosc/32 = 250kHz at 8MHz
- Resolves compilation error on SparkFun Pro Micro and other ATmega32U4 boards
2025-06-01 00:57:38 +09:00
2 changed files with 4 additions and 3 deletions
+1 -1
View File
@@ -196,4 +196,4 @@ Additional suggestions and feedback from [progmem](https://github.com/progmem).
If you appreciate this library or the other projects I do, you can make a monetary donation below. Thanks!
[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif)](https://www.paypal.com/donate/?business=6M7ENNVE2ZP5Q&no_recurring=1&currency_code=USD)
[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/vxzk/tip)
+3 -2
View File
@@ -30,7 +30,8 @@ void PSX_::init(int ackPin = 8, bool invACK = false, bool invCIPO = true) {
#if (F_CPU == 16000000L)
SPCR |= (1 << SPR1); // Fosc/64 @16MHz==250KHz
#elif (F_CPU == 8000000L)
SPCR |= (1 << SPR2) | (1 << SPR1); // Fosc/32 @8MHz==250KHz
SPCR |= (1 << SPR1); // SPR1=1, SPR0=0 for Fosc/64 base
SPSR |= (1 << SPI2X); // SPI2X=1 for double speed -> Fosc/32 @8MHz==250KHz
#endif
SPCR |= (1 << CPHA); // Setup @ leading edge, sample @ falling edge
SPCR |= (1 << CPOL); // Leading edge is falling edge, trailing edge is rising edge
@@ -110,4 +111,4 @@ void PSX_::isr() {
}
}
PSX_ PSX;
PSX_ PSX;