-
-
Notifications
You must be signed in to change notification settings - Fork 280
Description
Hello! I am going through trying to disable the SPI bus and am diving into the SPI control and enable registers. I am using the SPIClass.end() function as my reference for what I need to do to accomplish this. I am trying to understand what bits are being changed and have confused myself... can anyone clarify this for me? Thanks in advance!
scss_registers.h
#define PERIPH_CLK_GATE_CTRL (SCSS_REGISTER_BASE + 0x018)
/* SPI */
#define SOC_MST_SPI1_REGISTER_BASE (0xB0001400)
SPIClass.h only touches SPI1 so I am assuming that SPI0 is what the BMI160 is using.
So if we look at the bit that the clock gate control is being defined as it is 0x018 = 24. However, the documentation shows that it should be at bit 28 (or 29 if we are starting at 1).
2.1.6.86 CREG register detailed description
2.1.6.87 IO_CREG_MST0_CTRL (IO_CREG_MST0_CTRL)
MEM Offset(80018000)31 AD_CLK_GATE
30 I2C1_CLK_GATE
29 I2C0_CLK_GATE
28 SPI1_CLK_GATE
27 SPI0_CLK_GATE
26:20 ADC CALIBRATION VALUE
The specific code that I am looking at lives in SPI.cpp (SPIClass.end())
SPI1_M_REG_VAL(SPIEN) &= SPI_DISABLE;
MMIO_REG_VAL(PERIPH_CLK_GATE_CTRL) &= DISABLE_SPI_MASTER_1;
Disabling the SPI seems ok, but when we disable the clock, I'm confused as to what bit is being changed. Am I missing something obvious here?