Sfoglia il codice sorgente

Merge pull request #10195 from Bob-the-Kuhn/DUE-hw-SPI-to-mode-0

[2.0.x] DUE - change hardware SPI to mode 0change to mode 0
Bob-the-Kuhn 7 anni fa
parent
commit
81d68b2180
Nessun account collegato all'indirizzo email del committer
1 ha cambiato i file con 6 aggiunte e 1 eliminazioni
  1. 6
    1
      Marlin/src/HAL/HAL_DUE/HAL_spi_Due.cpp

+ 6
- 1
Marlin/src/HAL/HAL_DUE/HAL_spi_Due.cpp Vedi File

@@ -825,6 +825,11 @@
825 825
 
826 826
   #else  // U8G compatible hardware SPI
827 827
 
828
+    #define SPI_MODE_0_DUE_HW 2  // DUE CPHA control bit is inverted
829
+    #define SPI_MODE_1_DUE_HW 3
830
+    #define SPI_MODE_2_DUE_HW 0
831
+    #define SPI_MODE_3_DUE_HW 1
832
+
828 833
     void spiInit(uint8_t spiRate = 6 ) {  // default to slowest rate if not specified)
829 834
       // 8.4 MHz, 4 MHz, 2 MHz, 1 MHz, 0.5 MHz, 0.329 MHz, 0.329 MHz
830 835
       int spiDueDividors[] = { 10, 21, 42, 84, 168, 255, 255 };
@@ -848,7 +853,7 @@
848 853
       SPI0->SPI_MR = SPI_MR_MSTR | SPI_MR_PCSDEC | SPI_MR_MODFDIS;
849 854
 
850 855
       /* SPI mode 0, 8 Bit data transfer, baud rate */
851
-      SPI0->SPI_CSR[0] = SPI_CSR_SCBR(spiDueDividors[spiRate]) | 1;
856
+      SPI0->SPI_CSR[0] = SPI_CSR_SCBR(spiDueDividors[spiRate]) | SPI_MODE_0_DUE_HW;
852 857
     }
853 858
 
854 859
     static uint8_t spiTransfer(uint8_t data) {

Loading…
Annulla
Salva