[bsp/ls1cdev]drv_spi.c astyle格式化代码
This commit is contained in:
parent
b05a5a6f3d
commit
e7f78855bd
|
@ -19,7 +19,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
|
* 2018-06-09 zhuangwei add spi0 cs0 support,remove msd_init
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -70,28 +70,28 @@ static rt_err_t configure(struct rt_spi_device *device,
|
||||||
spi_base = ls1c_spi_get_base(SPIx);
|
spi_base = ls1c_spi_get_base(SPIx);
|
||||||
|
|
||||||
{
|
{
|
||||||
// 使能SPI控制器,master模式,关闭中断
|
// 使能SPI控制器,master模式,关闭中断
|
||||||
reg_write_8(0x53, spi_base + LS1C_SPI_SPCR_OFFSET);
|
reg_write_8(0x53, spi_base + LS1C_SPI_SPCR_OFFSET);
|
||||||
|
|
||||||
// 清空状态寄存器
|
// 清空状态寄存器
|
||||||
reg_write_8(0xc0, spi_base + LS1C_SPI_SPSR_OFFSET);
|
reg_write_8(0xc0, spi_base + LS1C_SPI_SPSR_OFFSET);
|
||||||
|
|
||||||
// 1字节产生中断,采样(读)与发送(写)时机同时
|
// 1字节产生中断,采样(读)与发送(写)时机同时
|
||||||
reg_write_8(0x03, spi_base + LS1C_SPI_SPER_OFFSET);
|
reg_write_8(0x03, spi_base + LS1C_SPI_SPER_OFFSET);
|
||||||
|
|
||||||
// 关闭SPI flash
|
// 关闭SPI flash
|
||||||
val = reg_read_8(spi_base + LS1C_SPI_SFC_PARAM_OFFSET);
|
val = reg_read_8(spi_base + LS1C_SPI_SFC_PARAM_OFFSET);
|
||||||
val &= 0xfe;
|
val &= 0xfe;
|
||||||
reg_write_8(val, spi_base + LS1C_SPI_SFC_PARAM_OFFSET);
|
reg_write_8(val, spi_base + LS1C_SPI_SFC_PARAM_OFFSET);
|
||||||
|
|
||||||
// spi flash时序控制寄存器
|
// spi flash时序控制寄存器
|
||||||
reg_write_8(0x05, spi_base + LS1C_SPI_SFC_TIMING_OFFSET);
|
reg_write_8(0x05, spi_base + LS1C_SPI_SFC_TIMING_OFFSET);
|
||||||
}
|
}
|
||||||
|
|
||||||
// baudrate
|
// baudrate
|
||||||
ls1c_spi_set_clock(spi_base, configuration->max_hz);
|
ls1c_spi_set_clock(spi_base, configuration->max_hz);
|
||||||
|
|
||||||
// 设置通信模式(时钟极性和相位)
|
// 设置通信模式(时钟极性和相位)
|
||||||
if (configuration->mode & RT_SPI_CPOL) // cpol
|
if (configuration->mode & RT_SPI_CPOL) // cpol
|
||||||
{
|
{
|
||||||
cpol = SPI_CPOL_1;
|
cpol = SPI_CPOL_1;
|
||||||
|
@ -149,7 +149,7 @@ static rt_uint32_t xfer(struct rt_spi_device *device,
|
||||||
ls1c_spi_set_cs(spi_base, cs, 0);
|
ls1c_spi_set_cs(spi_base, cs, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 收发数据
|
// 收发数据
|
||||||
send_ptr = message->send_buf;
|
send_ptr = message->send_buf;
|
||||||
recv_ptr = message->recv_buf;
|
recv_ptr = message->recv_buf;
|
||||||
while (size--)
|
while (size--)
|
||||||
|
@ -201,9 +201,9 @@ static struct rt_spi_bus spi1_bus;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 初始化并注册龙芯1c的spi总线
|
* 初始化并注册龙芯1c的spi总线
|
||||||
* @SPI SPI总线,比如LS1C_SPI_0, LS1C_SPI_1
|
* @SPI SPI总线,比如LS1C_SPI_0, LS1C_SPI_1
|
||||||
* @spi_bus_name 总线名字
|
* @spi_bus_name 总线名字
|
||||||
* @ret
|
* @ret
|
||||||
*/
|
*/
|
||||||
rt_err_t ls1c_spi_bus_register(rt_uint8_t SPI, const char *spi_bus_name)
|
rt_err_t ls1c_spi_bus_register(rt_uint8_t SPI, const char *spi_bus_name)
|
||||||
|
|
Loading…
Reference in New Issue