请问大神们:
1、 我在做S5PV210开发板的SPI口自发自收数据时,用内核源码自带的spidev_test.c测试程序,串口工具能显示出数据,但是当MISO和MISI短接时显示的是全0的数据,断开时显示的是全F.
2、 我使用的是linux3.2的内核,make menuconfig配置选项中没有支持SPI驱动,所以修改了config文件添加了,
3、 在/linux-3.2/arch/arm/mach-s5pv210/mach-smdkv210.c添加了如下代码:
static struct s3c64xx_spi_csinfo smdk_spi0_csi[]
{
[SMDK_MMCSPI_CS] = {
.line = S5PV210_GPB(1),
.set_level = gpio_set_value,
.fb_delay = 0x2,
},
}
static struct s3c64xx_spi_csinfo smdk_spi1_csi[]
{
[SMDK_MMCSPI_CS] = {
.line = S5PV210_GPB(5),
.set_level = gpio_set_value,
.fb_delay = 0x2,
},
}
static struct spi_board_info s3c_spi_devs[] __initdata =
{
{
.modalias = "spidev", /* MMC SPI */
.mode = SPI_MODE_0, /* CPOL=0, CPHA=0 */
.max_speed_hz = 10000000,
/* Connected to SPI-0 as 1st Slave */
.bus_num = 0,
.chip_select = 0,
.controller_data = &smdk_spi0_csi[SMDK_MMCSPI_CS],
},
{
.modalias = "spidev", /* MMC SPI */
.mode = SPI_MODE_0, /* CPOL=0, CPHA=0 */
.max_speed_hz = 10000000,
/* Connected to SPI-0 as 1st Slave */
.bus_num = 1,
.chip_select = 0,
.controller_data = &smdk_spi1_csi[SMDK_MMCSPI_CS],
},
}
在static void __init smdkv210_machine_init(void)函数中添加了如下代码:
#ifdef CONFIG_SPI_S3C64XX
if (!gpio_request(S5PV210_GPB(1), "SPI_CS0")) {
gpio_direction_output(S5PV210_GPB(1), 1);
s3c_gpio_cfgpin(S5PV210_GPB(1), S3C_GPIO_SFN(1));
s3c_gpio_setpull(S5PV210_GPB(1), S3C_GPIO_PULL_UP);
s5pv210_spi_set_info(0, S5PV210_SPI_SRCCLK_PCLK,
ARRAY_SIZE(smdk_spi0_csi));
}
if (!gpio_request(S5PV210_GPB(5), "SPI_CS1")) {
gpio_direction_output(S5PV210_GPB(5), 1);
s3c_gpio_cfgpin(S5PV210_GPB(5), S3C_GPIO_SFN(1));
s3c_gpio_setpull(S5PV210_GPB(5), S3C_GPIO_PULL_UP);
s5pv210_spi_set_info(1, S5PV210_SPI_SRCCLK_PCLK,
ARRAY_SIZE(smdk_spi1_csi));
}
spi_register_board_info(s3c_spi_devs, ARRAY_SIZE(s3c_spi_devs));
#endif
有请各位大神抽空看看,这个项目花了我两周时间了,为什么在开发板里面运行,串口工具里面不显示spidev_test.c程序定义好的数据:
uint8_t tx[] = {
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0x40, 0x00, 0x00, 0x00, 0x00, 0x95,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xDE, 0xAD, 0xBE, 0xEF, 0xBA, 0xAD,
0xF0, 0x0D,
};
而是:
0x00, 0x00, 0x00, 0x00,0x00, 0x00,
0x00, 0x00, 0x00, 0x00,0x00, 0x00,
0x00, 0x00, 0x00, 0x00,0x00, 0x00,
0x00, 0x00, 0x00, 0x00,0x00, 0x00,
0x00, 0x00, 0x00, 0x00,0x00, 0x00,
0x00, 0x00, 0x00, 0x00,0x00, 0x00,
|