void SPI1_1B_WR(uint32_t addr, uint32_t data) { uint32_t addr_real = addr << 8; //addr_real[31:0] = {addr[31:8], 8'h00} uint32_t wdata = 0x5a000000; //int32_t spi_setup_cmd_addr(SPI_TypeDef *spi, uint32_t cmd, uint32_t cmdlen, uint32_t addr, uint
时间: 2023-08-12 17:08:06 浏览: 163
32_t addrlen, uint32_t dummylen) {
uint32_t cmd = 0x02; // Write command
uint32_t cmdlen = 8; // Command length in bits
uint32_t addrlen = 24; // Address length in bits
uint32_t dummylen = 8; // Dummy length in bits
// Construct the command word
uint32_t cmd_word = (cmd << 24) | (cmdlen << 16) | (addrlen << 8) | dummylen;
// Send the command word
SPI_SendData(SPI1, cmd_word);
// Construct the address word
uint32_t addr_word = addr_real | (data & 0xFF);
// Send the address and data word
SPI_SendData(SPI1, addr_word);
// Wait for transfer to complete
while (SPI_GetFlagStatus(SPI1, SPI_FLAG_BSY));
// Clear the RX buffer
SPI_ReceiveData(SPI1);
}
阅读全文
相关推荐
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)