瀏覽代碼

Merge pull request #44 from FrankBoesing/patch-1

Use PFD setting to prevent wrong calculation (needed for high SPI-Clo…
main
Paul Stoffregen 5 年之前
父節點
當前提交
aac5e5cbdc
沒有連結到貢獻者的電子郵件帳戶。
共有 1 個檔案被更改,包括 9 行新增3 行删除
  1. +9
    -3
      SPI.h

+ 9
- 3
SPI.h 查看文件

@@ -1055,9 +1055,15 @@ private:
void init_AlwaysInline(uint32_t clock, uint8_t bitOrder, uint8_t dataMode)
__attribute__((__always_inline__)) {
// TODO: Need to check timings as related to chip selects?

uint32_t d, div;
uint32_t clkhz = 528000000u / (((CCM_CBCMR >> 26 ) & 0x07 ) + 1); // LPSPI peripheral clock
const uint32_t clk_sel[4] = {664615384, // PLL3 PFD1
720000000, // PLL3 PFD0
528000000, // PLL2
396000000}; // PLL2 PFD2
uint32_t cbcmr = CCM_CBCMR;
uint32_t clkhz = clk_sel[(cbcmr >> 4) & 0x03] / (((cbcmr >> 26 ) & 0x07 ) + 1); // LPSPI peripheral clock
uint32_t d, div;
if (clock == 0) clock =1;
d= clkhz/clock;
if (d && clkhz/d > clock) d++;

Loading…
取消
儲存