MOSI和SCK测出来都是浮空的
但如果模式改为输出的话又正常
实在想不出哪有问题了
RCC->AHB2ENR|=RCC_AHB2ENR_GPIOAEN;//GPIOA ENABLE
RCC->AHB2RSTR|=0x1<<RCC_AHB2RSTR_GPIOARST_Pos;//GPIOA RST
RCC->AHB2RSTR&=~(0x1<<RCC_AHB2RSTR_GPIOARST_Pos);
//MODE AF
GPIOA->MODER&=~(0x3<<GPIO_MODER_MODE5_Pos);
GPIOA->MODER&=~(0x3<<GPIO_MODER_MODE7_Pos);
GPIOA->MODER|=0x2<<GPIO_MODER_MODE5_Pos;
GPIOA->MODER|=0x2<<GPIO_MODER_MODE7_Pos;
//OUT PUT TYPE PP
GPIOA->OTYPER&=~(0x1<<(GPIO_OTYPER_OT5_Pos));
GPIOA->OTYPER&=~(0x1<<(GPIO_OTYPER_OT7_Pos));
GPIOA->OTYPER|=0x0<<(GPIO_OTYPER_OT5_Pos);
GPIOA->OTYPER|=0x0<<(GPIO_OTYPER_OT7_Pos);
//SPEED VERY HIGH
GPIOA->OSPEEDR&=~(0x3<<(GPIO_OSPEEDR_OSPEED5_Pos));
GPIOA->OSPEEDR&=~(0x3<<(GPIO_OSPEEDR_OSPEED7_Pos));
GPIOA->OSPEEDR|=0x3<<(GPIO_OSPEEDR_OSPEED5_Pos);
GPIOA->OSPEEDR|=0x3<<(GPIO_OSPEEDR_OSPEED7_Pos);
//NO PULL
GPIOA->PUPDR&=~(0x3<<(GPIO_PUPDR_PUPD5_Pos));
GPIOA->PUPDR&=~(0x3<<(GPIO_PUPDR_PUPD7_Pos));
GPIOA->PUPDR|=0x0<<(GPIO_PUPDR_PUPD5_Pos);
GPIOA->PUPDR|=0x0<<(GPIO_PUPDR_PUPD7_Pos);
//AF config
GPIOA->AFR[0]&=~(0xF<<GPIO_AFRL_AFSEL5_Pos);
GPIOA->AFR[0]&=~(0xF<<GPIO_AFRL_AFSEL7_Pos);
GPIOA->AFR[0]|=0x5<<GPIO_AFRL_AFSEL5_Pos;
GPIOA->AFR[0]|=0x5<<GPIO_AFRL_AFSEL7_Pos;
//SPI_INIT
RCC->APB2ENR |= 0x1<<RCC_APB2ENR_SPI1EN_Pos;//Enable SPI1
RCC->APB2RSTR|=0x1<<RCC_APB2RSTR_SPI1RST_Pos;//SPI1 RST
RCC->APB2RSTR&=~(0x1<<RCC_APB2RSTR_SPI1RST_Pos);
SPI1->CR1=0x00000000;//Clear the register
SPI1->CR2=0x00000000;//Clear the register
SPI1->CR1|=0x0<<SPI_CR1_BIDIMODE_Pos;//2 Line Mode
SPI1->CR1|=0x1<<SPI_CR1_BIDIOE_Pos;//transmit-only mode
SPI1->CR1|=0x0<<SPI_CR1_CRCEN_Pos;//disable CRC
SPI1->CR1|=0x1<<SPI_CR1_SSM_Pos;//Software slave management enabled
SPI1->CR1|=0x0<<SPI_CR1_LSBFIRST_Pos;// transmitted / received with the MSB first
SPI1->CR1|=0x0<<SPI_CR1_BR_Pos;//Speed = APB2CLK/2^(BR+1)
SPI1->CR1|=0x1<<SPI_CR1_MSTR_Pos;//Master Mode
SPI1->CR1|=0x0<<SPI_CR1_CPOL_Pos;
SPI1->CR1|=0x0<<SPI_CR1_CPHA_Pos;
SPI1->CR2|=0x7<<SPI_CR2_DS_Pos;//Data length 8 bits
SPI1->CR2|=0x0<<SPI_CR2_FRF_Pos;//Motorola mode
SPI1->CR1|=0x1<<SPI_CR1_SPE_Pos;;//SPI ENABLE
|