博创平台UPNET2410-S 键盘由MEGA8控制,MEGA8接IIC总线。
- #define I2COWNER_ADDRESS (0x10>>1)
- #define MEGA8_I2CADDRESS (0x60)
- #define CMD_CTRL_BASE 0x0
- #define CMD_CTRL (CMD_CTRL_BASE+0) //控制字
- #define CMD_MST_ADDR (CMD_CTRL_BASE+1) //主控端地址
- #define CMD_GET_MKEY (CMD_CTRL_BASE+2) //读取扫描键盘码
- #define CMD_GET_TEST1 (CMD_CTRL_BASE+0xa) //读取测试寄存器
- typedef __packed struct{
- unsigned char cmd;
- unsigned char ctrl;
- }I2C_control;
- void Key_Init(void)
- {
- I2C_control i2c_ctrl;
- IIC_init();
- Set_IIC_mode(MCU_IICCON, NULL);
- [color=#FF0000] i2c_ctrl.cmd=CMD_MST_ADDR;
- i2c_ctrl.ctrl=I2COWNER_ADDRESS;
- IIC_Send(MEGA8_I2CADDRESS, (const char*)&i2c_ctrl, sizeof(i2c_ctrl));
- i2c_ctrl.cmd=CMD_CTRL;
- i2c_ctrl.ctrl = CTRL_MKEn;
- IIC_Send(MEGA8_I2CADDRESS, (const char*)&i2c_ctrl, sizeof(i2c_ctrl));[/color]
- INTS_OFF();
- SetISR_Interrupt(IRQ_KBD, Key_ISR, NULL);
- INTS_ON();
- }
问题:IIC工作流程应该是先发送地址,然后发送数据。那个第一个IIC_Send发送主控端地址是什么意思?而且还发送两个字节?这两个IIC_Send发送的数据有什么意义?望赐教。。。