Skip to content

Commit 494fc47

Browse files
committed
SPI : uart can be read and write
1 parent e73b9e2 commit 494fc47

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

debug/spi/README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
# SPI
22

3-
spi_transfer数据结构
3+
## 数据结构
4+
5+
spi_transfer
46

57
struct spi_transfer - a read/write buffer pair
68
@tx_buf: data to be written (dma-safe memory), or NULL
79
@rx_buf: data to be read (dma-safe memory), or NULL
810
@len: size of rx and tx buffers (in bytes)
911
@cs_change: affects chipselect after this transfer completes
12+
13+
## Debug
14+
15+
read and write test
16+
17+
cat /dev/ttysWK0
18+
echo 1 > /dev/ttysWK0

debug/spi/spi2uart.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,16 +122,22 @@ static void wk2xxx_release_port(struct uart_port *port)
122122
printk("%s, %d\n", __FUNCTION__, __LINE__);
123123
}
124124

125+
/* Request the memory region(s) being used by port */
125126
static int wk2xxx_request_port(struct uart_port *port)
126127
{
127128
printk("%s, %d\n", __FUNCTION__, __LINE__);
128129

129130
return 0;
130131
}
131132

133+
/* 配置串口 */
132134
static void wk2xxx_config_port(struct uart_port *port, int flags)
133135
{
136+
struct wk2xxx_port *chip = container_of(port,struct wk2xxx_port,port);
137+
134138
printk("%s, %d\n", __FUNCTION__, __LINE__);
139+
if (flags & UART_CONFIG_TYPE && wk2xxx_request_port(port) == 0)
140+
chip->port.type = PORT_WK2XXX;
135141
}
136142

137143
static int wk2xxx_verify_port(struct uart_port *port, struct serial_struct *ser)
@@ -349,6 +355,7 @@ static int wk2xxx_probe(struct spi_device *spidev)
349355

350356
printk("%s, %d\n", __FUNCTION__, __LINE__);
351357

358+
#ifdef TEST_DRIVER
352359
for (i = 0; i < 10; i++)
353360
{
354361
/* do 10 time read write */
@@ -358,6 +365,7 @@ static int wk2xxx_probe(struct spi_device *spidev)
358365
printk("Nice, :) SPI OK %d time %d\n", val, i);
359366
wk2xxx_write_reg(spidev, WK2XXX_GPORT, WK2XXX_GENA, i);
360367
}
368+
#endif
361369

362370
/* 注册串口驱动 */
363371
status = uart_register_driver(&wk2xxx_uart_driver);

0 commit comments

Comments
 (0)