Skip to content

drivers/pn532: adapted to SPI interface changes#6478

Merged
cgundogan merged 2 commits intoRIOT-OS:masterfrom
haukepetersen:fix_pm532_spiadapt
Jan 27, 2017
Merged

drivers/pn532: adapted to SPI interface changes#6478
cgundogan merged 2 commits intoRIOT-OS:masterfrom
haukepetersen:fix_pm532_spiadapt

Conversation

@haukepetersen
Copy link
Copy Markdown
Contributor

missed in #4780: driver needed adaption to SPI interface changes for its SPI mode.

@haukepetersen haukepetersen added Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors) Area: drivers Area: Device drivers labels Jan 26, 2017
@haukepetersen haukepetersen added this to the Release 2017.01 milestone Jan 26, 2017
@haukepetersen
Copy link
Copy Markdown
Contributor Author

haukepetersen commented Jan 26, 2017

build the test-app with PN532_MODE=spi BOARD=xxx make ...

@cgundogan cgundogan self-assigned this Jan 26, 2017
}
else {
#ifdef PN532_SUPPORT_SPI
ret = spi_init_master(dev->conf->spi, SPI_CONF_FIRST_RISING,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ret is initially set to -1 and this function returns ret => pn532_init always returns -1 this way and thusly fails

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ups...

@cgundogan
Copy link
Copy Markdown
Member

cf. haukepetersen#36 some fixes to get the pn532 driver working again (SPI_MODE)

@haukepetersen
Copy link
Copy Markdown
Contributor Author

fixed init function and removed debug output from test makefile

@cgundogan
Copy link
Copy Markdown
Member

@haukepetersen please look at haukepetersen#36 there is another bug

@cgundogan
Copy link
Copy Markdown
Member

ACK works as expected now. Please squash 👍

@cgundogan cgundogan added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Jan 26, 2017
@haukepetersen
Copy link
Copy Markdown
Contributor Author

squashed.

}

buff[0] = 0x80;
reverse(buff, ret);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no idea what happened, but this fix didn't survive the squash operation (: please replace ret with len.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be ok now.

Copy link
Copy Markdown
Member

@lebrush lebrush left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good except these two small comments. Thanks for the effort @haukepetersen :-) and thanks @cgundogan for testing !!!

#elif defined(PN532_SUPPORT_SPI)
ret = pn532_init_spi(&pn532, &pn532_conf[0]);
#else
#error "Error: bus mode not defined"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check is already included in pn532.h :-)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true

else {
#ifdef PN532_SUPPORT_SPI
spi_acquire(dev->conf->spi);
spi_acquire(dev->conf->spi, GPIO_UNDEF, SPI_MODE, SPI_CLK);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Documentation in spi.h says cs shall be set to SPI_CS_UNDEF instead of GPIO_UNDEF

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(also in the other places)

@lebrush
Copy link
Copy Markdown
Member

lebrush commented Jan 26, 2017

Btw, I really like that the test application now supports spi too :-)

@haukepetersen
Copy link
Copy Markdown
Contributor Author

Comments are addressed.

(also in the other places)

you are absolutely right, will propose a fix.

Copy link
Copy Markdown
Member

@cgundogan cgundogan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK from my side. @lebrush do you have any further comments on this one?

@lebrush
Copy link
Copy Markdown
Member

lebrush commented Jan 26, 2017

Nope codewise looks fine :-) but now some boards are not happy about SPI... maybe make i2c or spi the default one for the test application to solve this this is already the case

/data/riotbuild/drivers/include/pn532.h:33:2: error: #error Please define PN532_SUPPORT_I2C and/or PN532_SUPPORT_SPI to enable the functionality on this device
 #error Please define PN532_SUPPORT_I2C and/or PN532_SUPPORT_SPI to enable \
  ^~~~~
/data/riotbuild/Makefile.base:64: recipe for target '/data/riotbuild/tests/driver_pn532/bin/calliope-mini/tests_driver_pn532/main.o' failed
make[1]: *** [/data/riotbuild/tests/driver_pn532/bin/calliope-mini/tests_driver_pn532/main.o] Error 1
make[1]: *** Waiting for unfinished jobs....
In file included from /data/riotbuild/drivers/pn532/pn532.c:26:0:
/data/riotbuild/drivers/include/pn532.h:33:2: error: #error Please define PN532_SUPPORT_I2C and/or PN532_SUPPORT_SPI to enable the functionality on this device
 #error Please define PN532_SUPPORT_I2C and/or PN532_SUPPORT_SPI to enable \
  ^~~~~
/data/riotbuild/Makefile.base:64: recipe for target '/data/riotbuild/tests/driver_pn532/bin/calliope-mini/pn532/pn532.o' failed
make[3]: *** [/data/riotbuild/tests/driver_pn532/bin/calliope-mini/pn532/pn532.o] Error 1
/data/riotbuild/Makefile.base:20: recipe for target 'ALL--/data/riotbuild/drivers/pn532' failed
make[2]: *** [ALL--/data/riotbuild/drivers/pn532] Error 2
/data/riotbuild/Makefile.base:20: recipe for target 'ALL--/data/riotbuild/drivers' failed
make[1]: *** [ALL--/data/riotbuild/drivers] Error 2
/data/riotbuild/Makefile.include:275: recipe for target 'all' failed
make: *** [all] Error 2


# select if you want to build the SPI or the I2C version of the driver:
# set PN532_MODE to `i2c` or to `spi`
TPN532_MODE ?= i2c
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/TPN532_MODE/PN532_MODE

@PeterKietzmann PeterKietzmann added the Process: needs backport Integration Process: The PR is required to be backported to a release or feature branch label Jan 26, 2017
@haukepetersen
Copy link
Copy Markdown
Contributor Author

hm, that capital T must have accidentally slipped in. Buildtest now runs fine again locally...

@cgundogan
Copy link
Copy Markdown
Member

tested again with my local setup. looks fine and both CIs agree => GO

@cgundogan cgundogan merged commit 9f1721a into RIOT-OS:master Jan 27, 2017
@PeterKietzmann
Copy link
Copy Markdown
Member

@lebrush can you please provide a backport to the 2017.01 release branch?

@haukepetersen haukepetersen deleted the fix_pm532_spiadapt branch January 27, 2017 10:19
@lebrush
Copy link
Copy Markdown
Member

lebrush commented Jan 27, 2017

👍 will do

PeterKietzmann added a commit that referenced this pull request Jan 27, 2017
@PeterKietzmann PeterKietzmann removed the Process: needs backport Integration Process: The PR is required to be backported to a release or feature branch label Jan 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: drivers Area: Device drivers CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants