深圳王城 发表于 2020-7-13 14:49:37

BitserialOpen()返回值

static bitserial_handle i2cPioInit(uint16 address){    bitserial_config bsconfig;#if 1    uint32 i;    uint16 bank;    uint16 mask;    struct    {      uint16 pio;      pin_function_id func;    }i2c_pios[] = {{i2cClockPio,BITSERIAL_1_CLOCK_OUT},                   {i2cClockPio,BITSERIAL_1_CLOCK_IN},                   {i2cDataPio,BITSERIAL_1_DATA_OUT},                   {i2cDataPio,BITSERIAL_1_DATA_IN}};
    for (i = 0; i < ARRAY_DIM(i2c_pios); i++)    {      uint16 pio = i2c_pios[i].pio;      bank = PIO2BANK(pio);      mask = PIO2MASK(pio);
      /* Setup I2C PIOs with strong pull-up */      PanicNotZero(PioSetMapPins32Bank(bank, mask, 0));      //PanicFalse(PioSetFunction(pio, i2c_pios.func));      PanicNotZero(PioSetDir32Bank(bank, mask, 0));      PanicNotZero(PioSet32Bank(bank, mask, mask));      PanicNotZero(PioSetStrongBias32Bank(bank, mask, mask));    }#endif    /* Configure Bitserial to work with vncl3020 proximity sensor */    memset(&bsconfig, 0, sizeof(bsconfig));    bsconfig.mode = BITSERIAL_MODE_I2C_MASTER;    bsconfig.clock_frequency_khz = i2cClockKhz;    bsconfig.u.i2c_cfg.i2c_address = address;    bsconfig.timeout_ms = 50;    bsconfig.u.i2c_cfg.flags = BITSERIAL_I2C_ACT_ON_NAK_STOP;    return BitserialOpen((bitserial_block_index)BITSERIAL_BLOCK_1, &bsconfig);
}#endif
I2C 初始化过程中没有建立成功。单步调试BitserialOpen()的handler返回值是1.

423165987 发表于 2020-7-13 15:06:28

你这个代码放的没办法看哦,还不如截图。

深圳王城 发表于 2020-8-5 10:51:46

了解,非常感谢!
页: [1]
查看完整版本: BitserialOpen()返回值