make style
This commit is contained in:
parent
2ac7963076
commit
cd98a4ac87
2 changed files with 29 additions and 27 deletions
|
@ -181,26 +181,28 @@ spi_send_receive(spi_port sp, const uint8_t *pbtTx, const size_t szTx, uint8_t *
|
||||||
pbtTx = pbtTxLSB;
|
pbtTx = pbtTxLSB;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct spi_ioc_transfer tr_send = { .tx_buf = (unsigned long) pbtTx,
|
struct spi_ioc_transfer tr_send = {
|
||||||
.rx_buf = 0,
|
.tx_buf = (unsigned long) pbtTx,
|
||||||
.len = szTx ,
|
.rx_buf = 0,
|
||||||
.delay_usecs = 0,
|
.len = szTx ,
|
||||||
.speed_hz = 0,
|
.delay_usecs = 0,
|
||||||
.bits_per_word = 0,
|
.speed_hz = 0,
|
||||||
};
|
.bits_per_word = 0,
|
||||||
|
};
|
||||||
tr[transfers] = tr_send;
|
tr[transfers] = tr_send;
|
||||||
|
|
||||||
++transfers;
|
++transfers;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (szRx) {
|
if (szRx) {
|
||||||
struct spi_ioc_transfer tr_receive = { .tx_buf = 0,
|
struct spi_ioc_transfer tr_receive = {
|
||||||
.rx_buf = (unsigned long) pbtRx,
|
.tx_buf = 0,
|
||||||
.len = szRx,
|
.rx_buf = (unsigned long) pbtRx,
|
||||||
.delay_usecs = 0,
|
.len = szRx,
|
||||||
.speed_hz = 0,
|
.delay_usecs = 0,
|
||||||
.bits_per_word = 0,
|
.speed_hz = 0,
|
||||||
};
|
.bits_per_word = 0,
|
||||||
|
};
|
||||||
tr[transfers] = tr_receive;
|
tr[transfers] = tr_receive;
|
||||||
++transfers;
|
++transfers;
|
||||||
}
|
}
|
||||||
|
@ -213,7 +215,7 @@ spi_send_receive(spi_port sp, const uint8_t *pbtTx, const size_t szTx, uint8_t *
|
||||||
free(pbtTxLSB);
|
free(pbtTxLSB);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret != (int) (szRx + szTx)) {
|
if (ret != (int)(szRx + szTx)) {
|
||||||
return NFC_EIO;
|
return NFC_EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -287,20 +287,20 @@ pn532_spi_wakeup(nfc_device *pnd)
|
||||||
uint8_t spi_byte = 0;
|
uint8_t spi_byte = 0;
|
||||||
res = spi_receive(DRIVER_DATA(pnd)->port, &spi_byte, 1, true);
|
res = spi_receive(DRIVER_DATA(pnd)->port, &spi_byte, 1, true);
|
||||||
if (res != NFC_SUCCESS) {
|
if (res != NFC_SUCCESS) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "Got %x byte from SPI line before wakeup", spi_byte);
|
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "Got %x byte from SPI line before wakeup", spi_byte);
|
||||||
|
|
||||||
CHIP_DATA(pnd)->power_mode = NORMAL; // PN532 will be awake soon
|
CHIP_DATA(pnd)->power_mode = NORMAL; // PN532 will be awake soon
|
||||||
|
|
||||||
if(spi_byte == 0xff) {
|
if (spi_byte == 0xff) {
|
||||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "%s", "Wakeup is needed");
|
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "%s", "Wakeup is needed");
|
||||||
spi_set_speed(DRIVER_DATA(pnd)->port, 5000); // set slow speed
|
spi_set_speed(DRIVER_DATA(pnd)->port, 5000); // set slow speed
|
||||||
|
|
||||||
res = pn532_SAMConfiguration(pnd, PSM_NORMAL, 1000); // wakeup by sending SAMConfiguration, which works just fine
|
res = pn532_SAMConfiguration(pnd, PSM_NORMAL, 1000); // wakeup by sending SAMConfiguration, which works just fine
|
||||||
|
|
||||||
spi_set_speed(DRIVER_DATA(pnd)->port, prev_port_speed);
|
spi_set_speed(DRIVER_DATA(pnd)->port, prev_port_speed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -320,14 +320,14 @@ pn532_spi_wait_for_data(nfc_device *pnd, int timeout)
|
||||||
int timer = 0;
|
int timer = 0;
|
||||||
|
|
||||||
int ret;
|
int ret;
|
||||||
while ( (ret = pn532_spi_read_spi_status(pnd, timeout)) != pn532_spi_ready) {
|
while ((ret = pn532_spi_read_spi_status(pnd, timeout)) != pn532_spi_ready) {
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DRIVER_DATA(pnd)->abort_flag) {
|
if (DRIVER_DATA(pnd)->abort_flag) {
|
||||||
DRIVER_DATA(pnd)->abort_flag = false;
|
DRIVER_DATA(pnd)->abort_flag = false;
|
||||||
return NFC_EOPABORTED;
|
return NFC_EOPABORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (timeout > 0) {
|
if (timeout > 0) {
|
||||||
|
@ -415,7 +415,7 @@ pn532_spi_receive(nfc_device *pnd, uint8_t *pbtData, const size_t szDataLen, int
|
||||||
// long preamble
|
// long preamble
|
||||||
|
|
||||||
// omit first byte
|
// omit first byte
|
||||||
for (size_t i = 0; i < 3; ++i){
|
for (size_t i = 0; i < 3; ++i) {
|
||||||
abtRxBuf[i] = abtRxBuf[i + 1];
|
abtRxBuf[i] = abtRxBuf[i + 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -626,7 +626,7 @@ static int
|
||||||
pn532_spi_abort_command(nfc_device *pnd)
|
pn532_spi_abort_command(nfc_device *pnd)
|
||||||
{
|
{
|
||||||
if (pnd) {
|
if (pnd) {
|
||||||
DRIVER_DATA(pnd)->abort_flag = true;
|
DRIVER_DATA(pnd)->abort_flag = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NFC_SUCCESS;
|
return NFC_SUCCESS;
|
||||||
|
|
Loading…
Reference in a new issue