49 #include "NFCEEPROMDriver.h" 50 #include "EventQueue.h" 52 #if defined TARGET_DISCO_L475VG_IOT01A 54 #define M24SR_I2C_SDA_PIN PB_11 55 #define M24SR_I2C_SCL_PIN PB_10 56 #define M24SR_GPO_PIN PE_4 57 #define M24SR_RF_DISABLE_PIN PE_2 59 #elif MBED_CONF_X_NUCLEO_NFC01A1 61 #define M24SR_I2C_SDA_PIN D14 62 #define M24SR_I2C_SCL_PIN D15 63 #define M24SR_GPO_PIN D12 64 #define M24SR_RF_DISABLE_PIN D11 68 #define M24SR_I2C_SDA_PIN NC 69 #define M24SR_I2C_SCL_PIN NC 70 #define M24SR_GPO_PIN NC 71 #define M24SR_RF_DISABLE_PIN NC 80 #define OPEN_SESSION_RETRIES 5 81 #define CC_FILE_LENGTH 15 82 #define NDEF_FILE_HEADER_SIZE 2 83 #define MAX_NDEF_SIZE 0x1FFF 113 C_APDU(uint8_t cla, uint8_t ins, uint16_t p1p2, uint8_t
length,
const uint8_t *
data, uint8_t expected)
117 header.P1 = (uint8_t)((p1p2 & 0xFF00) >> 8);
118 header.P2 = (uint8_t)(p1p2 & 0x00FF);
137 enum M24srError_t : uint16_t {
139 M24SR_ERROR = 0x6F00,
140 M24SR_FILE_OVERFLOW_LE = 0x6280,
142 M24SR_PASSWORD_REQUIRED = 0x6300,
143 M24SR_PASSWORD_INCORRECT = 0x63C0,
144 M24SR_PASSWORD_INCORRECT1RETRY = 0x63C1,
145 M24SR_PASSWORD_INCORRECT2RETRY = 0x63C2,
146 M24SR_WRONG_LENGHT = 0x6700,
147 M24SR_UNSUCESSFUL_UPDATING = 0x6581,
148 M24SR_INCOPATIBLE_COMMAND = 0x6981,
149 M24SR_SECURITY_UNSATISFIED = 0x6982,
150 M24SR_REFERENCE_DATA_NOT_USABLE = 0x6984,
152 M24SR_INCORRECT_PARAMETER = 0x6a80,
153 M24SR_FILE_NOT_FOUND = 0x6a82,
154 M24SR_FILE_OVERFLOW_LC = 0x6A84,
156 M24SR_INCORRECT_P1_OR_P2 = 0x6A86,
157 M24SR_RF_SESSION_KILLED = 0x6500,
158 M24SR_INS_NOT_SUPPORTED = 0x6D00,
159 M24SR_CLASS_NOT_SUPPORTED = 0x6E00,
161 M24SR_IO_ERROR_I2CTIMEOUT = 0x0011,
162 M24SR_IO_ERROR_CRC = 0x0012,
163 M24SR_IO_ERROR_NACK = 0x0013,
164 M24SR_IO_ERROR_PARAMETER = 0x0014,
165 M24SR_IO_ERROR_NBATEMPT = 0x0015,
166 M24SR_IO_NOACKNOWLEDGE = 0x0016,
167 M24SR_IO_PIN_NOT_CONNECTED = 0x0017
177 I2C_ANSWER_READY = 3,
185 enum PasswordType_t {
186 READ_PASSWORD = 0x01,
187 WRITE_PASSWORD = 0x02,
206 CHANGE_REFERENCE_DATA,
207 ENABLE_VERIFICATION_REQUIREMENT,
208 DISABLE_VERIFICATION_REQUIREMENT,
209 ENABLE_PERMANET_STATE,
210 DISABLE_PERMANET_STATE,
216 enum Communication_t {
295 uint16_t write_count)
299 (void) bytes_written;
309 (void) password_type;
454 M24srDriver(PinName i2c_data_pin = M24SR_I2C_SDA_PIN, PinName i2c_clock_pin = M24SR_I2C_SCL_PIN,
455 PinName gpo_pin = M24SR_GPO_PIN, PinName rf_disable_pin = M24SR_RF_DISABLE_PIN);
463 set_callback(&_default_cb);
465 manage_i2c_gpo(I2C_ANSWER_READY);
472 return MAX_NDEF_SIZE;
479 if (_is_session_open) {
480 delegate()->on_session_started(
true);
484 set_callback(&_open_session_cb);
493 set_callback(&_close_session_cb);
499 virtual void read_bytes(uint32_t address, uint8_t *bytes,
size_t count)
501 if (!_is_session_open) {
502 delegate()->on_bytes_read(0);
506 if (address > _ndef_size) {
507 delegate()->on_bytes_read(0);
511 set_callback(&_read_byte_cb);
513 if (count > _max_read_bytes) {
514 count = _max_read_bytes;
517 if (address + count > _ndef_size) {
518 count = _ndef_size - address;
522 delegate()->on_bytes_read(0);
527 address += NDEF_FILE_HEADER_SIZE;
529 read_binary((uint16_t) address, (uint8_t) count, bytes);
534 virtual void write_bytes(uint32_t address,
const uint8_t *bytes,
size_t count)
536 if (!_is_session_open) {
537 delegate()->on_bytes_written(0);
541 if (address > _ndef_size) {
542 delegate()->on_bytes_written(0);
547 set_callback(&_write_byte_cb);
549 set_callback(&_erase_bytes_cb);
552 if (count > _max_write_bytes) {
553 count = _max_write_bytes;
556 if (address + count > _ndef_size) {
557 count = _ndef_size - address;
561 delegate()->on_bytes_written(0);
566 address += NDEF_FILE_HEADER_SIZE;
568 update_binary((uint16_t) address, (uint8_t) count, bytes);
575 if (!_is_session_open) {
576 delegate()->on_size_read(
false, 0);
580 if (count > MAX_NDEF_SIZE - NDEF_FILE_HEADER_SIZE) {
581 delegate()->on_size_read(
false, 0);
585 set_callback(&_set_size_cb);
587 _ndef_size = (uint16_t)count;
590 uint8_t *bytes = (uint8_t *)&_ndef_size;
591 _ndef_size_buffer[0] = bytes[1];
592 _ndef_size_buffer[1] = bytes[0];
594 update_binary(0, NDEF_FILE_HEADER_SIZE, (
const uint8_t *)&_ndef_size_buffer);
601 if (!_is_session_open) {
602 delegate()->on_size_read(
false, 0);
606 set_callback(&_get_size_cb);
608 read_binary(0, NDEF_FILE_HEADER_SIZE, (uint8_t *)&_ndef_size_buffer);
615 write_bytes(address, NULL, size);
628 _command_cb = &_default_cb;
640 if (_subcommand_cb) {
641 return _subcommand_cb;
646 void nfc_interrupt_callback()
648 if (_communication_type == ASYNC) {
649 event_queue()->call(
this, &M24srDriver::manage_event);
660 M24srError_t enable_read_password(
const uint8_t *current_write_password,
const uint8_t *new_password)
662 _subcommand_cb = &_change_password_request_status_cb;
663 _change_password_request_status_cb.set_task(READ_PASSWORD, new_password);
665 return verify(WRITE_PASSWORD, current_write_password);
674 M24srError_t disable_read_password(
const uint8_t *current_write_password)
676 _subcommand_cb = &_change_password_request_status_cb;
677 _change_password_request_status_cb.set_task(READ_PASSWORD, NULL);
679 return verify(WRITE_PASSWORD, current_write_password);
689 M24srError_t enable_write_password(
const uint8_t *current_write_password, uint8_t *new_password)
691 _subcommand_cb = &_change_password_request_status_cb;
692 _change_password_request_status_cb.set_task(WRITE_PASSWORD, new_password);
694 return verify(WRITE_PASSWORD, current_write_password);
703 M24srError_t disable_write_password(
const uint8_t *current_write_password)
705 _subcommand_cb = &_change_password_request_status_cb;
706 _change_password_request_status_cb.set_task(WRITE_PASSWORD, NULL);
708 return verify(WRITE_PASSWORD, current_write_password);
717 M24srError_t disable_all_password(
const uint8_t *super_user_password)
719 _subcommand_cb = &_remove_password_cb;
720 return verify(I2C_PASSWORD, super_user_password);
729 M24srError_t enable_read_only(
const uint8_t *current_write_password)
731 _subcommand_cb = &_change_access_state_cb;
732 _change_access_state_cb.change_access_state(ChangeAccessStateCallback::WRITE,
false);
734 return verify(WRITE_PASSWORD, current_write_password);
743 M24srError_t disable_read_only(
const uint8_t *current_write_password)
745 _subcommand_cb = &_change_access_state_cb;
746 _change_access_state_cb.change_access_state(ChangeAccessStateCallback::WRITE,
true);
748 return verify(I2C_PASSWORD, current_write_password);
757 M24srError_t enable_write_only(
const uint8_t *current_write_password)
759 _subcommand_cb = &_change_access_state_cb;
760 _change_access_state_cb.change_access_state(ChangeAccessStateCallback::READ,
false);
762 return verify(WRITE_PASSWORD, current_write_password);
771 M24srError_t disable_write_only(
const uint8_t *current_write_password)
773 _subcommand_cb = &_change_access_state_cb;
774 _change_access_state_cb.change_access_state(ChangeAccessStateCallback::READ,
true);
776 return verify(I2C_PASSWORD, current_write_password);
781 M24srError_t read_id(uint8_t *nfc_id);
782 M24srError_t get_session(
bool force =
false);
784 M24srError_t deselect();
785 M24srError_t receive_deselect();
787 M24srError_t select_application();
788 M24srError_t receive_select_application();
790 M24srError_t select_cc_file();
791 M24srError_t receive_select_cc_file();
793 M24srError_t select_ndef_file(uint16_t ndef_file_id);
794 M24srError_t receive_select_ndef_file();
796 M24srError_t select_system_file();
797 M24srError_t receive_select_system_file();
799 M24srError_t read_binary(uint16_t
offset, uint8_t
length, uint8_t *buffer);
800 M24srError_t st_read_binary(uint16_t offset, uint8_t length, uint8_t *buffer);
801 M24srError_t receive_read_binary();
803 M24srError_t update_binary(uint16_t offset, uint8_t length,
const uint8_t *
data);
804 M24srError_t receive_update_binary();
806 M24srError_t verify(PasswordType_t password_type,
const uint8_t *password);
807 M24srError_t receive_verify();
809 M24srError_t change_reference_data(PasswordType_t password_type,
const uint8_t *password);
810 M24srError_t receive_change_reference_data();
812 M24srError_t enable_verification_requirement(PasswordType_t password_type);
813 M24srError_t receive_enable_verification_requirement();
815 M24srError_t disable_verification_requirement(PasswordType_t password_type);
816 M24srError_t receive_disable_verification_requirement();
818 M24srError_t enable_permanent_state(PasswordType_t password_type);
819 M24srError_t receive_enable_permanent_state();
821 M24srError_t disable_permanent_state(PasswordType_t password_type);
822 M24srError_t receive_disable_permanent_state();
824 M24srError_t send_interrupt();
825 M24srError_t state_control(
bool gpo_reset);
827 M24srError_t manage_i2c_gpo(NfcGpoState_t gpo_i2c_config);
828 M24srError_t manage_rf_gpo(NfcGpoState_t gpo_rf_config);
830 M24srError_t rf_config(
bool enable);
831 M24srError_t send_fwt_extension(uint8_t fwt_byte);
833 M24srError_t send_receive_i2c(uint16_t length, uint8_t *command);
839 M24srError_t manage_event();
847 M24srError_t io_send_i2c_command(uint8_t length,
const uint8_t *command);
855 M24srError_t io_receive_i2c_response(uint8_t length, uint8_t *command);
861 M24srError_t io_poll_i2c();
863 bool manage_sync_communication(M24srError_t *status);
869 class ChangePasswordRequestStatusCallback :
public Callbacks {
874 ChangePasswordRequestStatusCallback()
875 : _new_password(NULL),
896 void set_task(PasswordType_t type,
const uint8_t *new_password)
898 _new_password = new_password;
900 _enable = (new_password != NULL);
903 virtual void on_verified(
M24srDriver *nfc, M24srError_t status, PasswordType_t,
const uint8_t *)
905 if (status != M24SR_SUCCESS) {
906 return on_finish_command(nfc, status);
909 nfc->change_reference_data(_type, _new_password);
911 nfc->disable_verification_requirement(_type);
915 virtual void on_disable_verification_requirement(
M24srDriver *nfc, M24srError_t status, PasswordType_t)
917 on_finish_command(nfc, status);
920 virtual void on_change_reference_data(
M24srDriver *nfc, M24srError_t status, PasswordType_t type,
const uint8_t *)
922 if (status == M24SR_SUCCESS) {
923 nfc->enable_permanent_state(type);
925 on_finish_command(nfc, status);
929 virtual void on_enable_permanent_state(
M24srDriver *nfc, M24srError_t status, PasswordType_t)
931 on_finish_command(nfc, status);
940 void on_finish_command(
M24srDriver *nfc, M24srError_t status)
942 nfc->_subcommand_cb = NULL;
945 if (_type == READ_PASSWORD) {
951 if (_type == READ_PASSWORD) {
960 const uint8_t *_new_password;
961 PasswordType_t _type;
968 class RemoveAllPasswordCallback :
public Callbacks {
973 RemoveAllPasswordCallback()
974 : _password(NULL) { }
986 virtual void on_verified(
M24srDriver *nfc, M24srError_t status, PasswordType_t,
const uint8_t *data)
988 if (status != M24SR_SUCCESS) {
989 return on_finish_command(nfc, status);
992 nfc->disable_permanent_state(READ_PASSWORD);
995 virtual void on_disable_permanent_state(
M24srDriver *nfc, M24srError_t status, PasswordType_t type)
997 if (status != M24SR_SUCCESS) {
998 return on_finish_command(nfc, status);
1000 if (type == READ_PASSWORD) {
1001 nfc->disable_permanent_state(WRITE_PASSWORD);
1003 nfc->disable_verification_requirement(READ_PASSWORD);
1007 virtual void on_disable_verification_requirement(
M24srDriver *nfc, M24srError_t status, PasswordType_t type)
1009 if (status != M24SR_SUCCESS) {
1010 return on_finish_command(nfc, status);
1012 if (type == READ_PASSWORD) {
1013 nfc->disable_verification_requirement(WRITE_PASSWORD);
1015 nfc->change_reference_data(READ_PASSWORD, _password);
1019 virtual void on_change_reference_data(
M24srDriver *nfc, M24srError_t status, PasswordType_t type,
1020 const uint8_t *data)
1022 if (status != M24SR_SUCCESS) {
1023 return on_finish_command(nfc, status);
1025 if (type == READ_PASSWORD) {
1026 nfc->change_reference_data(WRITE_PASSWORD, data);
1028 on_finish_command(nfc, status);
1038 void on_finish_command(
M24srDriver *nfc, M24srError_t status)
1040 nfc->_subcommand_cb = NULL;
1050 const uint8_t *_password;
1056 class ChangeAccessStateCallback :
public Callbacks {
1066 ChangeAccessStateCallback()
1084 void change_access_state(AccessType_t type,
bool enable)
1090 virtual void on_verified(
M24srDriver *nfc, M24srError_t status, PasswordType_t,
const uint8_t *)
1092 if (status != M24SR_SUCCESS) {
1093 return on_finish_command(nfc, status);
1097 nfc->disable_permanent_state(_type == WRITE ? WRITE_PASSWORD : READ_PASSWORD);
1099 nfc->enable_permanent_state(_type == WRITE ? WRITE_PASSWORD : READ_PASSWORD);
1104 virtual void on_disable_permanent_state(
M24srDriver *nfc, M24srError_t status, PasswordType_t type)
1106 if (status != M24SR_SUCCESS) {
1107 return on_finish_command(nfc, status);
1110 nfc->disable_verification_requirement(type);
1113 virtual void on_disable_verification_requirement(
M24srDriver *nfc, M24srError_t status, PasswordType_t)
1115 on_finish_command(nfc, status);
1118 virtual void on_enable_permanent_state(
M24srDriver *nfc, M24srError_t status, PasswordType_t)
1120 on_finish_command(nfc, status);
1129 void on_finish_command(
M24srDriver *nfc, M24srError_t status)
1131 nfc->_subcommand_cb = NULL;
1133 if (_type == READ) {
1141 if (_type == WRITE) {
1158 class ManageGPOCallback :
public Callbacks {
1166 : _new_gpo_config(HIGH_IMPEDANCE),
1167 _read_gpo_config(0),
1168 _change_i2c_gpo(
true) { }
1183 void set_new_gpo_config(
bool i2cGpo, NfcGpoState_t new_config)
1185 _new_gpo_config = new_config;
1186 _change_i2c_gpo = i2cGpo;
1189 virtual void on_selected_application(
M24srDriver *nfc, M24srError_t status)
1191 if (status == M24SR_SUCCESS) {
1192 nfc->select_system_file();
1194 on_finish_command(nfc, status);
1198 virtual void on_selected_system_file(
M24srDriver *nfc, M24srError_t status)
1200 if (status == M24SR_SUCCESS) {
1201 nfc->read_binary(0x0004, 0x01, &_read_gpo_config);
1203 on_finish_command(nfc, status);
1207 virtual void on_read_byte(
M24srDriver *nfc, M24srError_t status, uint16_t, uint8_t *, uint16_t)
1209 if (status == M24SR_SUCCESS) {
1210 nfc->verify(I2C_PASSWORD, default_password);
1212 on_finish_command(nfc, status);
1216 virtual void on_verified(
M24srDriver *nfc, M24srError_t status, PasswordType_t,
const uint8_t *)
1218 if (status != M24SR_SUCCESS) {
1219 return on_finish_command(nfc, status);
1222 if (_change_i2c_gpo) {
1223 _read_gpo_config = (_read_gpo_config & 0xF0) | (uint8_t) _new_gpo_config;
1225 _read_gpo_config = (_read_gpo_config & 0x0F) | (((uint8_t) _new_gpo_config) << 4);
1228 nfc->update_binary(0x0004, 0x01, &_read_gpo_config);
1231 virtual void on_updated_binary(
M24srDriver *nfc, M24srError_t status, uint16_t, uint8_t *, uint16_t)
1234 if (status == M24SR_SUCCESS) {
1235 if (_new_gpo_config == I2C_ANSWER_READY) {
1236 nfc->_communication_type = ASYNC;
1238 nfc->_communication_type = SYNC;
1241 on_finish_command(nfc, status);
1250 void on_finish_command(
M24srDriver *nfc, M24srError_t status)
1252 nfc->_subcommand_cb = NULL;
1253 if (_change_i2c_gpo) {
1262 NfcGpoState_t _new_gpo_config;
1265 uint8_t _read_gpo_config;
1268 bool _change_i2c_gpo;
1274 class ReadIDCallback :
public Callbacks {
1280 ReadIDCallback() : _id(NULL) { }
1292 void set_task(uint8_t *
id)
1297 virtual void on_selected_application(
M24srDriver *nfc, M24srError_t status)
1299 if (status == M24SR_SUCCESS) {
1300 nfc->select_system_file();
1302 on_finish_command(nfc, status);
1307 virtual void on_selected_system_file(
M24srDriver *nfc, M24srError_t status)
1309 if (status == M24SR_SUCCESS) {
1310 nfc->read_binary(0x0011, 0x01, _id);
1312 on_finish_command(nfc, status);
1316 virtual void on_read_byte(
M24srDriver *nfc, M24srError_t status, uint16_t, uint8_t *, uint16_t)
1318 on_finish_command(nfc, status);
1327 void on_finish_command(
M24srDriver *nfc, M24srError_t status)
1329 nfc->_subcommand_cb = NULL;
1330 nfc->get_callback()->
on_read_id(nfc, status, _id);
1342 class OpenSessionCallBack :
public Callbacks {
1344 OpenSessionCallBack()
1345 : _retries(OPEN_SESSION_RETRIES) { }
1347 void on_session_open(
M24srDriver *nfc, M24srError_t status)
1349 if (status == M24SR_SUCCESS) {
1350 nfc->select_application();
1356 void on_selected_application(
M24srDriver *nfc, M24srError_t status)
1358 if (status == M24SR_SUCCESS) {
1359 nfc->select_cc_file();
1361 if (_retries == 0) {
1365 nfc->select_application();
1370 void on_selected_cc_file(
M24srDriver *nfc, M24srError_t status)
1372 if (status == M24SR_SUCCESS) {
1373 nfc->read_binary(0x0000, CC_FILE_LENGTH, CCFile);
1379 void on_read_byte(
M24srDriver *nfc, M24srError_t status, uint16_t, uint8_t *bytes_read,
1380 uint16_t read_count)
1382 if (status != M24SR_SUCCESS || read_count != CC_FILE_LENGTH) {
1385 uint16_t ndef_file_id = (uint16_t)((bytes_read[0x09] << 8) | bytes_read[0x0A]);
1386 nfc->_max_read_bytes = (uint16_t)((bytes_read[0x03] << 8) | bytes_read[0x04]);
1387 nfc->_max_write_bytes = (uint16_t)((bytes_read[0x05] << 8) | bytes_read[0x06]);
1388 nfc->select_ndef_file(ndef_file_id);
1391 void on_selected_ndef_file(
M24srDriver *nfc, M24srError_t status)
1393 nfc->_is_session_open = (status == M24SR_SUCCESS);
1408 class CloseSessionCallBack :
public Callbacks {
1410 CloseSessionCallBack() { }
1412 virtual void on_deselect(
M24srDriver *nfc, M24srError_t status)
1414 if (status == M24SR_SUCCESS) {
1415 nfc->_is_session_open =
false;
1426 class WriteByteCallback :
public Callbacks {
1428 WriteByteCallback() { }
1430 virtual void on_updated_binary(
M24srDriver *nfc, M24srError_t status, uint16_t offset, uint8_t *bytes_written,
1431 uint16_t write_count)
1433 if (status != M24SR_SUCCESS) {
1445 class ReadByteCallback :
public Callbacks {
1447 ReadByteCallback() { }
1449 virtual void on_read_byte(
M24srDriver *nfc, M24srError_t status, uint16_t offset, uint8_t *bytes_read,
1450 uint16_t read_count)
1452 if (status != M24SR_SUCCESS) {
1461 class SetSizeCallback :
public Callbacks {
1463 SetSizeCallback() { }
1465 virtual void on_updated_binary(
M24srDriver *nfc, M24srError_t status, uint16_t offset, uint8_t *bytes_written,
1466 uint16_t write_count)
1468 if (status != M24SR_SUCCESS) {
1477 class GetSizeCallback :
public Callbacks {
1479 GetSizeCallback() { }
1481 virtual void on_read_byte(
M24srDriver *nfc, M24srError_t status, uint16_t offset, uint8_t *bytes_read,
1482 uint16_t read_count)
1484 if (status != M24SR_SUCCESS) {
1490 nfc->_ndef_size = (((uint16_t) nfc->_ndef_size_buffer[0]) << 8 | nfc->_ndef_size_buffer[1]);
1496 class EraseBytesCallback :
public Callbacks {
1498 EraseBytesCallback() { }
1500 virtual void on_updated_binary(
M24srDriver *nfc, M24srError_t status, uint16_t offset, uint8_t *bytes_written,
1501 uint16_t write_count)
1503 if (status != M24SR_SUCCESS) {
1514 static const uint8_t default_password[16];
1534 ManageGPOCallback _manage_gpo_cb;
1535 ReadIDCallback _read_id_cb;
1536 ChangePasswordRequestStatusCallback _change_password_request_status_cb;
1537 RemoveAllPasswordCallback _remove_password_cb;
1538 ChangeAccessStateCallback _change_access_state_cb;
1539 OpenSessionCallBack _open_session_cb;
1540 CloseSessionCallBack _close_session_cb;
1541 WriteByteCallback _write_byte_cb;
1542 ReadByteCallback _read_byte_cb;
1543 SetSizeCallback _set_size_cb;
1544 GetSizeCallback _get_size_cb;
1545 EraseBytesCallback _erase_bytes_cb;
1548 uint8_t _buffer[0xFF];
1551 Communication_t _communication_type;
1553 Command_t _last_command;
1557 uint16_t _ndef_size;
1558 uint8_t _ndef_size_buffer[NDEF_FILE_HEADER_SIZE];
1559 uint8_t _max_read_bytes;
1560 uint8_t _max_write_bytes;
1563 bool _is_session_open;
virtual void on_disable_write_password(M24srDriver *nfc, M24srError_t status)
called when disable_write_password completes
virtual void on_selected_system_file(M24srDriver *nfc, M24srError_t status)
called when select_system_file completes
virtual void on_disable_write_only(M24srDriver *nfc, M24srError_t status)
called when disable_write_only completes
virtual void on_session_ended(bool success)=0
Completion of session end operation.
virtual void erase_bytes(uint32_t address, size_t size)
virtual void on_enable_write_only(M24srDriver *nfc, M24srError_t status)
called when enable_write_only completes
virtual void on_session_started(bool success)=0
Completion of session start operation.
virtual void on_deselect(M24srDriver *nfc, M24srError_t status)
called when deselect completes
virtual void on_size_written(bool success)=0
Completion of size setting operation.
virtual void on_disable_read_password(M24srDriver *nfc, M24srError_t status)
called when disable_read_password completes
virtual void on_selected_ndef_file(M24srDriver *nfc, M24srError_t status)
called when select_ndef_file completes
Object that contains all the callbacks fired by this class, each command has its own callback...
Class representing a M24SR component.
The abstraction for a NFC EEPROM driver.
virtual void on_session_open(M24srDriver *nfc, M24srError_t status)
called when get_session completes
An I2C Master, used for communicating with I2C slave devices.
virtual void on_manage_i2c_gpo(M24srDriver *nfc, M24srError_t status, NfcGpoState_t new_status)
called when manage_i2c_gpo completes
virtual void on_updated_binary(M24srDriver *nfc, M24srError_t status, uint16_t offset, uint8_t *bytes_written, uint16_t write_count)
called when update_binary completes
virtual void write_size(size_t count)
virtual void on_enable_write_password(M24srDriver *nfc, M24srError_t status, const uint8_t *new_password)
called when oenable_write_password completes
uint16_t length
number of bytes in the data array
virtual void end_session()
uint8_t LC
Data field length.
uint8_t SW1
Command Processing status.
virtual void on_selected_cc_file(M24srDriver *nfc, M24srError_t status)
called when select_cc_file completes
virtual size_t read_max_size()
virtual void on_bytes_written(size_t count)=0
Completion of write operation.
virtual void on_verified(M24srDriver *nfc, M24srError_t status, PasswordType_t password_type, const uint8_t *pwd)
called when verify completes
virtual void on_enable_read_password(M24srDriver *nfc, M24srError_t status, const uint8_t *new_password)
called when enable_read_password completes
const uint8_t * data
Command parameters.
virtual void on_manage_rf_gpo(M24srDriver *nfc, M24srError_t status, NfcGpoState_t new_status)
called when manage_rf_gpo completes
uint8_t SW2
Command Processing qualification.
virtual void write_bytes(uint32_t address, const uint8_t *bytes, size_t count)
virtual void on_disable_permanent_state(M24srDriver *nfc, M24srError_t status, PasswordType_t type)
called when disable_permanent_state completes
A digital interrupt input, used to call a function on a rising or falling edge.
virtual void on_enable_read_only(M24srDriver *nfc, M24srError_t status)
called when enable_read_only completes
virtual void on_selected_application(M24srDriver *nfc, M24srError_t status)
called when select_application completes
A digital output, used for setting the state of a pin.
virtual void on_read_byte(M24srDriver *nfc, M24srError_t status, uint16_t offset, uint8_t *bytes_read, uint16_t read_count)
called when read_binary completes
virtual void on_disable_verification_requirement(M24srDriver *nfc, M24srError_t status, PasswordType_t type)
called when disable_verification_requirement completes
uint16_t offset
offset parameter used in the read/write command
virtual void on_read_id(M24srDriver *nfc, M24srError_t status, uint8_t *id)
called when read_id completes
virtual void on_change_reference_data(M24srDriver *nfc, M24srError_t status, PasswordType_t type, const uint8_t *data)
called when change_reference_data completes
virtual void on_enable_verification_requirement(M24srDriver *nfc, M24srError_t status, PasswordType_t type)
called when enable_verification_requirement completes
virtual void on_bytes_erased(size_t count)=0
Completion of erasing operation.
uint8_t * data
Data returned from the card.
virtual void on_bytes_read(size_t count)=0
Completion of read operation.
A digital input, used for reading the state of a pin.
virtual void start_session(bool force=true)
virtual void on_size_read(bool success, size_t size)=0
Completion of size retrieval operation.
virtual void on_disable_all_password(M24srDriver *nfc, M24srError_t status)
called when disable_all_password completes
virtual void read_bytes(uint32_t address, uint8_t *bytes, size_t count)
virtual void on_disable_read_only(M24srDriver *nfc, M24srError_t status)
called when disable_read_only completes
virtual void on_enable_permanent_state(M24srDriver *nfc, M24srError_t status, PasswordType_t type)
called when enable_permanent_state completes
User parameter used to invoke a command, it is used to provide the data back with the response...
uint8_t LE
Expected length of data to be returned.