Skip to content

Commit

Permalink
drivers/pn532: fix cppcheck style warning
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Blue committed May 21, 2018
1 parent 164e587 commit d52d234
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions drivers/pn532/pn532.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,21 +123,21 @@ 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 (mode == PN532_I2C) {
if (i2c_init_master(dev->conf->i2c, I2C_SPEED_FAST) != 0) {
DEBUG("pn532: initialization of I2C bus failed\n");
return -1;
}
#endif
}
else {
#endif
#ifdef PN532_SUPPORT_SPI
if (mode != PN532_I2C) {
/* we handle the CS line manually... */
gpio_init(dev->conf->nss, GPIO_OUT);
gpio_set(dev->conf->nss);
#endif
}
#endif

pn532_reset(dev);

Expand Down Expand Up @@ -175,15 +175,15 @@ static int _write(const pn532_t *dev, uint8_t *buff, unsigned len)
(void)buff;
(void)len;

if (dev->mode == PN532_I2C) {
#ifdef PN532_SUPPORT_I2C
if (dev->mode == PN532_I2C) {
i2c_acquire(dev->conf->i2c);
ret = i2c_write_bytes(dev->conf->i2c, PN532_I2C_ADDRESS, buff, len);
i2c_release(dev->conf->i2c);
#endif
}
else {
#endif
#ifdef PN532_SUPPORT_SPI
if (dev->mode != PN532_I2C) {
spi_acquire(dev->conf->spi, SPI_CS_UNDEF, SPI_MODE, SPI_CLK);
gpio_clear(dev->conf->nss);
xtimer_usleep(SPI_WRITE_DELAY_US);
Expand All @@ -193,8 +193,8 @@ static int _write(const pn532_t *dev, uint8_t *buff, unsigned len)
gpio_set(dev->conf->nss);
spi_release(dev->conf->spi);
ret = (int)len;
#endif
}
#endif
DEBUG("pn532: -> ");
PRINTBUFF(buff, len);
return ret;
Expand All @@ -207,16 +207,16 @@ static int _read(const pn532_t *dev, uint8_t *buff, unsigned len)
(void)buff;
(void)len;

if (dev->mode == PN532_I2C) {
#ifdef PN532_SUPPORT_I2C
if (dev->mode == PN532_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);
i2c_release(dev->conf->i2c);
#endif
}
else {
#endif
#ifdef PN532_SUPPORT_SPI
if (dev->mode != PN532_I2C) {
spi_acquire(dev->conf->spi, SPI_CS_UNDEF, SPI_MODE, SPI_CLK);
gpio_clear(dev->conf->nss);
spi_transfer_byte(dev->conf->spi, SPI_CS_UNDEF, true, SPI_DATA_READ);
Expand All @@ -227,8 +227,8 @@ static int _read(const pn532_t *dev, uint8_t *buff, unsigned len)
buff[0] = 0x80;
reverse(buff, len);
ret = (int)len + 1;
#endif
}
#endif
DEBUG("pn532: <- ");
PRINTBUFF(buff, len);
return ret;
Expand Down

0 comments on commit d52d234

Please sign in to comment.