Fix a bug when value is larger than mask.
This commit is contained in:
parent
93c56a4b44
commit
71c400ae14
1 changed files with 2 additions and 2 deletions
|
@ -203,13 +203,13 @@ pn53x_read_register (nfc_device_t * pnd, uint16_t ui16Reg, uint8_t * ui8Value)
|
||||||
bool
|
bool
|
||||||
pn53x_write_register (nfc_device_t * pnd, const uint16_t ui16Reg, const uint8_t ui8SymbolMask, const uint8_t ui8Value)
|
pn53x_write_register (nfc_device_t * pnd, const uint16_t ui16Reg, const uint8_t ui8SymbolMask, const uint8_t ui8Value)
|
||||||
{
|
{
|
||||||
uint8_t ui8Current;
|
|
||||||
byte_t abtCmd[] = { WriteRegister, ui16Reg >> 8, ui16Reg & 0xff, 0x00 };
|
byte_t abtCmd[] = { WriteRegister, ui16Reg >> 8, ui16Reg & 0xff, 0x00 };
|
||||||
|
|
||||||
if (ui8SymbolMask != 0xff) {
|
if (ui8SymbolMask != 0xff) {
|
||||||
|
uint8_t ui8Current;
|
||||||
if (!pn53x_read_register (pnd, ui16Reg, &ui8Current))
|
if (!pn53x_read_register (pnd, ui16Reg, &ui8Current))
|
||||||
return false;
|
return false;
|
||||||
abtCmd[3] = ui8Value | (ui8Current & (~ui8SymbolMask));
|
abtCmd[3] = ((ui8Value & ui8SymbolMask) | (ui8Current & (~ui8SymbolMask)));
|
||||||
return (abtCmd[3] != ui8Current) ? pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL) : true;
|
return (abtCmd[3] != ui8Current) ? pn53x_transceive (pnd, abtCmd, sizeof (abtCmd), NULL, NULL) : true;
|
||||||
} else {
|
} else {
|
||||||
abtCmd[3] = ui8Value;
|
abtCmd[3] = ui8Value;
|
||||||
|
|
Loading…
Reference in a new issue