mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
drivers/pn532: adapt to new i2c API
This commit is contained in:
parent
3ff45726a8
commit
dd852a2b53
@ -120,15 +120,7 @@ int pn532_init(pn532_t *dev, const pn532_params_t *params, pn532_mode_t mode)
|
||||
gpio_init(dev->conf->reset, GPIO_OUT);
|
||||
gpio_set(dev->conf->reset);
|
||||
dev->mode = mode;
|
||||
if (mode == PN532_I2C) {
|
||||
#ifdef PN532_SUPPORT_I2C
|
||||
if (i2c_init_master(dev->conf->i2c, I2C_SPEED_FAST) != 0) {
|
||||
DEBUG("pn532: initialization of I2C bus failed\n");
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
if (mode == PN532_SPI) {
|
||||
#ifdef PN532_SUPPORT_SPI
|
||||
/* we handle the CS line manually... */
|
||||
gpio_init(dev->conf->nss, GPIO_OUT);
|
||||
@ -175,7 +167,10 @@ static int _write(const pn532_t *dev, uint8_t *buff, unsigned len)
|
||||
if (dev->mode == PN532_I2C) {
|
||||
#ifdef PN532_SUPPORT_I2C
|
||||
i2c_acquire(dev->conf->i2c);
|
||||
ret = i2c_write_bytes(dev->conf->i2c, PN532_I2C_ADDRESS, buff, len);
|
||||
ret = i2c_write_bytes(dev->conf->i2c, PN532_I2C_ADDRESS, buff, len, 0);
|
||||
if (ret == 0) {
|
||||
ret = (int)len;
|
||||
}
|
||||
i2c_release(dev->conf->i2c);
|
||||
#endif
|
||||
}
|
||||
@ -208,7 +203,10 @@ static int _read(const pn532_t *dev, uint8_t *buff, unsigned len)
|
||||
#ifdef PN532_SUPPORT_I2C
|
||||
i2c_acquire(dev->conf->i2c);
|
||||
/* len+1 for RDY after read is accepted */
|
||||
ret = i2c_read_bytes(dev->conf->i2c, PN532_I2C_ADDRESS, buff, len + 1);
|
||||
ret = i2c_read_bytes(dev->conf->i2c, PN532_I2C_ADDRESS, buff, len + 1, 0);
|
||||
if (ret == 0) {
|
||||
ret = (int)len + 1;
|
||||
}
|
||||
i2c_release(dev->conf->i2c);
|
||||
#endif
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user