Skip to content

Commit

Permalink
changed the spi speed table back to where it was
Browse files Browse the repository at this point in the history
A change about 8 years ago made the SPI speed table incompatible
with the flashrom tool. flashrom thinks it set 8MHz SPI speed when in
reality it was only 2.6MHz. Changing the table back to the state
it was make it (again) compatible with the flashrom tool.
  • Loading branch information
denis2342 committed Mar 31, 2024
1 parent d95f66b commit 9dac9c6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion Firmware/messages_v3.s
Original file line number Diff line number Diff line change
Expand Up @@ -1526,7 +1526,8 @@ _MSG_SPI_SAMPLE_PROMPT_str:
.section .text.MSG_SPI_SPEED_PROMPT, code
.global _MSG_SPI_SPEED_PROMPT_str
_MSG_SPI_SPEED_PROMPT_str:
.pasciz "Set speed:\r\n 1. 30KHz\r\n 2. 125KHz\r\n 3. 250KHz\r\n 4. 1MHz\r\n 5. 50KHz\r\n 6. 1.3MHz\r\n 7. 2MHz\r\n 8. 2.6MHz\r\n 9. 3.2MHz\r\n10. 4MHz\r\n11. 5.3MHz\r\n12. 8MHz"
.pasciz "Set speed:\r\n 1. 30kHz\r\n 2. 125kHz\r\n 3. 250kHz\r\n 4. 1MHz\r\n 5. 2MHz\r\n 6. 2.6MHz\r\n 7. 4MHz\r\n 8. 8MHz\r\n 9. 50KHz\r\n10. 1.3MHz\r\n11. 3.2MHz\r\n12. 5.3MHz"


; MSG_UART_BAUD_CALCULATED
.section .text.MSG_UART_BAUD_CALCULATED, code
Expand Down
2 changes: 1 addition & 1 deletion Firmware/messages_v4.s
Original file line number Diff line number Diff line change
Expand Up @@ -1622,7 +1622,7 @@ _MSG_SPI_SAMPLE_PROMPT_str:
.section .text.MSG_SPI_SPEED_PROMPT, code
.global _MSG_SPI_SPEED_PROMPT_str
_MSG_SPI_SPEED_PROMPT_str:
.pasciz "Set speed:\r\n 1. 30KHz\r\n 2. 125KHz\r\n 3. 250KHz\r\n 4. 1MHz\r\n 5. 50KHz\r\n 6. 1.3MHz\r\n 7. 2MHz\r\n 8. 2.6MHz\r\n 9. 3.2MHz\r\n10. 4MHz\r\n11. 5.3MHz\r\n12. 8MHz"
.pasciz "Set speed:\r\n 1. 30kHz\r\n 2. 125kHz\r\n 3. 250kHz\r\n 4. 1MHz\r\n 5. 2MHz\r\n 6. 2.6MHz\r\n 7. 4MHz\r\n 8. 8MHz\r\n 9. 50KHz\r\n10. 1.3MHz\r\n11. 3.2MHz\r\n12. 5.3MHz"

; MSG_UART_BAUD_CALCULATED
.section .text.MSG_UART_BAUD_CALCULATED, code
Expand Down
10 changes: 5 additions & 5 deletions Firmware/spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,14 +257,14 @@ static const uint8_t spi_bus_speed[] = {
0b00011000, /* 125 kHz - Primary prescaler 64:1 / Secondary prescaler 2:1 */
0b00011100, /* 250 kHz - Primary prescaler 64:1 / Secondary prescaler 1:1 */
0b00011101, /* 1 MHz - Primary prescaler 16:1 / Secondary prescaler 1:1 */
0b00001100, /* 50 kHz - Primary prescaler 64:1 / Secondary prescaler 5:1 */
0b00010110, /* 1.3 MHz - Primary prescaler 4:1 / Secondary prescaler 3:1 */
0b00011010, /* 2 MHz - Primary prescaler 4:1 / Secondary prescaler 2:1 */
0b00001011, /* 2.6 MHz - Primary prescaler 1:1 / Secondary prescaler 6:1 */
0b00001111, /* 3.2 MHz - Primary prescaler 1:1 / Secondary prescaler 5:1 */
0b00011110, /* 4 MHz - Primary prescaler 4:1 / Secondary prescaler 1:1 */
0b00010111, /* 5.3 MHz - Primary prescaler 1:1 / Secondary prescaler 3:1 */
0b00011011 /* 8 MHz - Primary prescaler 1:1 / Secondary prescaler 2:1 */
0b00011011, /* 8 MHz - Primary prescaler 1:1 / Secondary prescaler 2:1 */
0b00001100, /* 50 kHz - Primary prescaler 64:1 / Secondary prescaler 5:1 */
0b00010110, /* 1.3 MHz - Primary prescaler 4:1 / Secondary prescaler 3:1 */
0b00001111, /* 3.2 MHz - Primary prescaler 1:1 / Secondary prescaler 5:1 */
0b00010111 /* 5.3 MHz - Primary prescaler 1:1 / Secondary prescaler 3:1 */
};

void engage_spi_cs(bool write_with_read) {
Expand Down

0 comments on commit 9dac9c6

Please sign in to comment.