Kendryte K210 using spi on freertos

This article is about the use of the standard spi interface of K210, but in the official routine, the cs foot is simulated by gpio. In fact, there is a special cs foot. It is not clear why it is used in this way. The documents are different again, here I will summarize the use of spi

The first is the pin configuration, as follows:

project_cfg.h

const fpioa_cfg_t g_fpioa_cfg = 
{
    .version = PIN_CFG_VERSION,
    .functions_count =5,
    .functions =
    {       
        {SPI_MASTER_CLK_PIN, FUNC_SPI0_SCLK},
        {SPI_MASTER_MOSI_PIN, FUNC_SPI0_D0},
        {SPI_MASTER_MISO_PIN, FUNC_SPI0_D1},
        {SPI_MASTER_CS_PIN, FUNC_SPI0_SS0},
        {SPI_MASTER_INT_PIN, FUNC_GPIOHS0 + SPI_MASTER_INT_IO},
    }
};

The PIN is defined by yourself, as for INT_PIN, if it is a normal four-wire, you can ignore it, because this pin has a special purpose, I don’t bother to delete it.

main.c :

    int i;
    printf("hello spi\n");
    handle_t spi = io_open ("/dev/spi0");
    handle_t dev0 = spi_get_device(spi, SPI_MODE_0, SPI_FF_STANDARD, 1, 8);
    spi_dev_set_clock_rate(dev0,

Guess you like

Origin blog.csdn.net/smile_5me/article/details/115319591