static void test_spi(void)
{
#define TEST_SPI_NAME "spi10"
struct rt_spi_device *spi_dev_test = RT_NULL;
struct rt_spi_message msg1;
struct rt_spi_configuration cfg;
//rt_uint8_t msg = 0x0a;
spi_dev_test = (struct rt_spi_device *)rt_device_find(TEST_SPI_NAME);
if(spi_dev_test == RT_NULL)
{
rt_kprintf("test spi error\n");
return;
}
cfg.data_width = 8;
cfg.mode = RT_SPI_MODE_0 | RT_SPI_MSB; /* SPI Compatible Modes 0 and 3 */
cfg.max_hz = 500000; /* Atmel RapidS Serial Interface: 66MHz Maximum Clock Frequency */
rt_spi_configure(spi_dev_test, &cfg);
msg1.send_buf = "lmnb66";
msg1.recv_buf = RT_NULL;
msg1.length = 6;
msg1.cs_take = 1;
msg1.cs_release = 1;
msg1.next = RT_NULL;
rt_kprintf("test spi\n");
rt_spi_transfer_message(spi_dev_test, &msg1);
}
离线