- 論壇徽章:
- 0
|
大家好!
我的設(shè)計中使用了I2C總線控制器。程序包括應(yīng)用程序和驅(qū)動。
應(yīng)用程序中,定義了下面的數(shù)組(數(shù)組的偶數(shù)項(0開始)表示I2C設(shè)備的地址。奇數(shù)項表示數(shù)據(jù)。):
unsigned char startRA[]={
STA_REG_SOFT_RESET, 0x01,
STA_REG_SOFT_RESET, 0x00,
STA_REG_MUTE, 0x01,
STA_REG_PCMDIVIDER, 0x01,
STA_REG_PCMCONF, 0x31,
STA_REG_PLLFRAC_441_H, 0x67,
STA_REG_PLLFRAC_441_L, 0x77,
STA_REG_PLLFRAC_H, 0xbb,
STA_REG_PLLFRAC_L, 0x3a,
STA_REG_MFSDF_441, 0x10,
STA_REG_MFSDF, 0x0F,
STA_REG_PLLCTL_2, 0x0C,
STA_REG_PLLCTL_3, 0x00,
STA_REG_PLLCTL_1, 0xA1,
STA_REG_SCLK_POL, 0x00,
STA_REG_REQ_POL, 0x01,
STA_REG_DATA_REQ_ENABLE, 0x04,
STA_REG_PLLCTL_1, 0xA1,
STA_REG_RUN, 0x01,
STA_REG_PLAY, 0x01,
STA_REG_MUTE, 0x00,
0xff, 0xff };//0xff作為終止符號,沒有傳入內(nèi)核
然后調(diào)用write函數(shù)把數(shù)組寫入I2C總線內(nèi)核驅(qū)動。傳遞給write函數(shù)的數(shù)據(jù)的類型為unsigned char。
可是,內(nèi)核中的i2cdev_write是char:
static ssize_t i2cdev_write (struct file *file, const char __user *buf, size_t count,
loff_t *offset)
在測試中,我們在內(nèi)核中把應(yīng)用程序輸入的數(shù)據(jù)打印出來如下:
i2cdev_write Kernel: 16
i2cdev_write Kernel: 16
i2cdev_write Kernel: 20
i2cdev_write Kernel: 84
i2cdev_write Kernel: 85
i2cdev_write Kernel: 82
i2cdev_write Kernel: 81
i2cdev_write Kernel: 101
i2cdev_write Kernel: 100
i2cdev_write Kernel: 80
i2cdev_write Kernel: 97
i2cdev_write Kernel: 6
i2cdev_write Kernel: 7
i2cdev_write Kernel: 5
i2cdev_write Kernel: 13
i2cdev_write Kernel: 12
i2cdev_write Kernel: 24
i2cdev_write Kernel: 5
i2cdev_write Kernel: 114
i2cdev_write Kernel: 19
i2cdev_write Kernel: 20
請問這個是怎么解釋的?
把應(yīng)用程序的所有數(shù)據(jù)都改寫為int類型呢?哪位提供方法解決一下? |
|