I2C initialization function */
| 228 | |
| 229 | /* I2C initialization function */ |
| 230 | int rt_soft_i2c_init(void) |
| 231 | { |
| 232 | int err = RT_EOK; |
| 233 | struct rt_soft_i2c *obj; |
| 234 | int i; |
| 235 | |
| 236 | for(i = 0; i < sizeof(i2c_bus_obj) / sizeof(i2c_bus_obj[0]); i++) |
| 237 | { |
| 238 | struct soft_i2c_config *cfg = &i2c_cfg[i]; |
| 239 | |
| 240 | pin_init(cfg); |
| 241 | |
| 242 | obj = &i2c_bus_obj[i]; |
| 243 | obj->ops = soft_i2c_ops; |
| 244 | obj->ops.data = cfg; |
| 245 | obj->i2c_bus.priv = &obj->ops; |
| 246 | obj->ops.delay_us = cfg->timing_delay; |
| 247 | obj->ops.timeout = cfg->timing_timeout; |
| 248 | if(rt_i2c_bit_add_bus(&obj->i2c_bus, cfg->bus_name) == RT_EOK) |
| 249 | { |
| 250 | i2c_bus_unlock(cfg); |
| 251 | LOG_D("Software simulation %s init done" |
| 252 | ", SCL pin: 0x%02X, SDA pin: 0x%02X" |
| 253 | , cfg->bus_name |
| 254 | , cfg->scl_pin |
| 255 | , cfg->sda_pin |
| 256 | ); |
| 257 | } |
| 258 | else |
| 259 | { |
| 260 | err++; |
| 261 | LOG_E("Software simulation %s init fail" |
| 262 | ", SCL pin: 0x%02X, SDA pin: 0x%02X" |
| 263 | , cfg->bus_name |
| 264 | , cfg->scl_pin |
| 265 | , cfg->sda_pin |
| 266 | ); |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | return err; |
| 271 | } |
| 272 | INIT_PREV_EXPORT(rt_soft_i2c_init); |
| 273 | |
| 274 | #endif // RT_USING_SOFT_I2C |
nothing calls this directly
no test coverage detected