0

Hi
我有個應用需要RTL8710當做slave的角色,
參考sdk-ameba1-v3.4b3_without_NDA\project\realtek_ameba1_va0_example\example_sources\i2c的範例,
把I2C1(GPIOC_4,GPIOC_5)設定成slave
程式改下面這樣

#include "device.h"
#include "serial_api.h"
#include "main.h"
#include "build_info.h"
#include "i2c_api.h"
#include "ex_api.h"

#define MBED_I2C_SDA    PC_4
#define MBED_I2C_SCL    PC_5
#define MBED_I2C_BUS_CLK        100000  //hz

i2c_t i2cslave;

#define I2C_DATA_LENGTH         3
char  i2cdatadst[I2C_DATA_LENGTH];

void i2c_callback_rx(void *userdata)
{
DiagPrintf("%s\r\n", __FUNCTION__);
}

void i2c_callback_tx(void *userdata)
{
DiagPrintf("%s\r\n", __FUNCTION__);
}

void i2c_callback_err(void *userdata)
{
DiagPrintf("%s\r\n", __FUNCTION__);
}

void main(void) {
i2c_init(&i2cslave, MBED_I2C_SDA ,MBED_I2C_SCL);
i2c_frequency(&i2cslave,MBED_I2C_BUS_CLK);
i2c_slave_address(&i2cslave, 0, 0x18, 0xFF);
i2c_slave_mode(&i2cslave, 1);
i2c_set_user_callback(&i2cslave, I2C_RX_COMPLETE, i2c_callback_rx);
i2c_set_user_callback(&i2cslave, I2C_TX_COMPLETE, i2c_callback_tx);
i2c_set_user_callback(&i2cslave, I2C_ERR_OCCURRED, i2c_callback_err);

DiagPrintf("slave read\n");
i2c_slave_read(&i2cslave, &i2cdatadst[0], I2C_DATA_LENGTH);

while (1)
{
}
}

然後從另一個MCU傳送3 byte的資料,
但是i2c_callback_rx都沒有產生反應,
示波器解碼是RTL8710這端沒有ACK
程式還要做哪些設定嗎?
thx~

hayami 回答了