[bsp/ls1cdev]SPI0添加CS0支持,移除drv_spi.c中的msd_init。SPI00可用于注册NORFLASH驱动
This commit is contained in:
parent
6724fb3994
commit
b05a5a6f3d
|
@ -20,6 +20,7 @@
|
||||||
* Change Logs:
|
* Change Logs:
|
||||||
* Date Author Notes
|
* Date Author Notes
|
||||||
* 2017-11-02 ÇÚΪ±¾ first version
|
* 2017-11-02 ÇÚΪ±¾ first version
|
||||||
|
* 2018-06-09 zhuangwei add spi0 cs0 support,remove msd_init
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <rtthread.h>
|
#include <rtthread.h>
|
||||||
|
@ -236,12 +237,14 @@ int ls1c_hw_spi_init(void)
|
||||||
pin_set_purpose(80, PIN_PURPOSE_OTHER);
|
pin_set_purpose(80, PIN_PURPOSE_OTHER);
|
||||||
pin_set_purpose(83, PIN_PURPOSE_OTHER);//cs2 - SD card
|
pin_set_purpose(83, PIN_PURPOSE_OTHER);//cs2 - SD card
|
||||||
pin_set_purpose(82, PIN_PURPOSE_OTHER);//cs1
|
pin_set_purpose(82, PIN_PURPOSE_OTHER);//cs1
|
||||||
|
pin_set_purpose(81, PIN_PURPOSE_OTHER);//cs0
|
||||||
|
|
||||||
pin_set_remap(78, PIN_REMAP_FOURTH);
|
pin_set_remap(78, PIN_REMAP_DEFAULT);
|
||||||
pin_set_remap(79, PIN_REMAP_FOURTH);
|
pin_set_remap(79, PIN_REMAP_DEFAULT);
|
||||||
pin_set_remap(80, PIN_REMAP_FOURTH);
|
pin_set_remap(80, PIN_REMAP_DEFAULT);
|
||||||
pin_set_remap(83, PIN_REMAP_FOURTH);//cs2 - SD card
|
pin_set_remap(83, PIN_REMAP_DEFAULT);//cs2 - SD card
|
||||||
pin_set_remap(82, PIN_REMAP_FOURTH);//cs1
|
pin_set_remap(82, PIN_REMAP_DEFAULT);//CS1
|
||||||
|
pin_set_remap(81, PIN_REMAP_DEFAULT);//cs0
|
||||||
ls1c_spi_bus_register(LS1C_SPI_0,"spi0");
|
ls1c_spi_bus_register(LS1C_SPI_0,"spi0");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -262,8 +265,10 @@ int ls1c_hw_spi_init(void)
|
||||||
#ifdef RT_USING_SPI0
|
#ifdef RT_USING_SPI0
|
||||||
/* attach cs */
|
/* attach cs */
|
||||||
{
|
{
|
||||||
|
static struct rt_spi_device spi_device0;
|
||||||
static struct rt_spi_device spi_device1;
|
static struct rt_spi_device spi_device1;
|
||||||
static struct rt_spi_device spi_device2;
|
static struct rt_spi_device spi_device2;
|
||||||
|
static struct ls1c_spi_cs spi_cs0;
|
||||||
static struct ls1c_spi_cs spi_cs1;
|
static struct ls1c_spi_cs spi_cs1;
|
||||||
static struct ls1c_spi_cs spi_cs2;
|
static struct ls1c_spi_cs spi_cs2;
|
||||||
|
|
||||||
|
@ -272,7 +277,8 @@ int ls1c_hw_spi_init(void)
|
||||||
rt_spi_bus_attach_device(&spi_device2, "spi02", "spi0", (void*)&spi_cs2);
|
rt_spi_bus_attach_device(&spi_device2, "spi02", "spi0", (void*)&spi_cs2);
|
||||||
spi_cs1.cs = LS1C_SPI_CS_1;
|
spi_cs1.cs = LS1C_SPI_CS_1;
|
||||||
rt_spi_bus_attach_device(&spi_device1, "spi01", "spi0", (void*)&spi_cs1);
|
rt_spi_bus_attach_device(&spi_device1, "spi01", "spi0", (void*)&spi_cs1);
|
||||||
msd_init("sd0", "spi02");
|
spi_cs0.cs = LS1C_SPI_CS_0;
|
||||||
|
rt_spi_bus_attach_device(&spi_device0, "spi00", "spi0", (void*)&spi_cs0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef RT_USING_SPI1
|
#ifdef RT_USING_SPI1
|
||||||
|
@ -287,6 +293,7 @@ int ls1c_hw_spi_init(void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
INIT_BOARD_EXPORT(ls1c_hw_spi_init);
|
INIT_BOARD_EXPORT(ls1c_hw_spi_init);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -260,7 +260,7 @@ inline void ls1c_spi_clear(void *spi_base)
|
||||||
val = reg_read_8(spi_base + LS1C_SPI_SPSR_OFFSET);
|
val = reg_read_8(spi_base + LS1C_SPI_SPSR_OFFSET);
|
||||||
if (LS1C_SPI_SPSR_WCOL_MASK & val)
|
if (LS1C_SPI_SPSR_WCOL_MASK & val)
|
||||||
{
|
{
|
||||||
rt_kprintf("[%s] clear register SPSR's wcol!\r\n"); // 手册和linux源码中不一样,加个打印看看
|
rt_kprintf("[%s] clear register SPSR's wcol!\r\n",__FUNCTION__); // 手册和linux源码中不一样,加个打印看看
|
||||||
reg_write_8(val & ~LS1C_SPI_SPSR_WCOL_MASK, spi_base + LS1C_SPI_SPSR_OFFSET); // 写0,linux源码中是写0
|
reg_write_8(val & ~LS1C_SPI_SPSR_WCOL_MASK, spi_base + LS1C_SPI_SPSR_OFFSET); // 写0,linux源码中是写0
|
||||||
// reg_write_8(val | LS1C_SPI_SPSR_WCOL_MASK, spi_base + LS1C_SPI_SPSR_OFFSET); // 写1,按照1c手册,应该写1
|
// reg_write_8(val | LS1C_SPI_SPSR_WCOL_MASK, spi_base + LS1C_SPI_SPSR_OFFSET); // 写1,按照1c手册,应该写1
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue