0

我已经设置了一个非常简单的 spi master 示例,但是查看逻辑分析仪没有 spi 时钟线。那么我在 spi 的配置中做错了什么。

#include "mbed.h"
#include <stdio.h>

SPI spi(D4, D5, D3); // mosi, miso, sclk
DigitalOut cs(A2);

Serial pc(USBTX, USBRX); // tx, rx

int main() {
    cs = 1;
    spi.format(8,3);
    spi.frequency(1000000);

    // Select the spi by seting chip select low
    cs = 0;

    // Send some data
    spi.write(0xFA);

    // Send a dummy byte to receive the contents of the WHOAMI register
    int whoami = spi.write(0x00);
    pc.printf("WHOAMI register = 0x%X\n", whoami);

}
4

0 回答 0