.
EEPROM4UID.h@0:c8ec63cf1007, 2022-01-23 (annotated)
- Committer:
- anyela
- Date:
- Sun Jan 23 05:06:09 2022 +0000
- Revision:
- 0:c8ec63cf1007
V
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
anyela | 0:c8ec63cf1007 | 1 | #include "mbed.h" |
anyela | 0:c8ec63cf1007 | 2 | #ifndef EEPROM4UID_H |
anyela | 0:c8ec63cf1007 | 3 | typedef union{ // creamos una estructura por facilidad |
anyela | 0:c8ec63cf1007 | 4 | uint8_t uidn_hl[2]; |
anyela | 0:c8ec63cf1007 | 5 | uint16_t uidn; |
anyela | 0:c8ec63cf1007 | 6 | }NUID; // nombre de la estructura |
anyela | 0:c8ec63cf1007 | 7 | |
anyela | 0:c8ec63cf1007 | 8 | |
anyela | 0:c8ec63cf1007 | 9 | typedef union{ |
anyela | 0:c8ec63cf1007 | 10 | uint8_t bytes[4]; |
anyela | 0:c8ec63cf1007 | 11 | uint32_t key; |
anyela | 0:c8ec63cf1007 | 12 | |
anyela | 0:c8ec63cf1007 | 13 | }UID; |
anyela | 0:c8ec63cf1007 | 14 | |
anyela | 0:c8ec63cf1007 | 15 | // se hace como una clase |
anyela | 0:c8ec63cf1007 | 16 | class EEPROM4UID{ |
anyela | 0:c8ec63cf1007 | 17 | public: |
anyela | 0:c8ec63cf1007 | 18 | EEPROM4UID (PinName SDA, PinName SCL, uint16_t epraddr); // constructor |
anyela | 0:c8ec63cf1007 | 19 | int8_t writeStr_EEPROM(uint16_t mem_addr, uint8_t* str); |
anyela | 0:c8ec63cf1007 | 20 | int8_t readByte_EEPROM(uint16_t mem_addr, uint8_t* byte); |
anyela | 0:c8ec63cf1007 | 21 | uint16_t wrt_newUID(UID &newUID);// |
anyela | 0:c8ec63cf1007 | 22 | void updt_uidn(NUID &num); // actualizar el numero de IDs |
anyela | 0:c8ec63cf1007 | 23 | // le entra la nueva cantidad de UIDs |
anyela | 0:c8ec63cf1007 | 24 | uint16_t read_uidn(); // función para leer los UIDS |
anyela | 0:c8ec63cf1007 | 25 | void read_database(UID* dtbse); |
anyela | 0:c8ec63cf1007 | 26 | private: |
anyela | 0:c8ec63cf1007 | 27 | I2C eeprom; |
anyela | 0:c8ec63cf1007 | 28 | NUID n; |
anyela | 0:c8ec63cf1007 | 29 | uint16_t EPR_ADDR; |
anyela | 0:c8ec63cf1007 | 30 | }; |
anyela | 0:c8ec63cf1007 | 31 | |
anyela | 0:c8ec63cf1007 | 32 | #endif |