nfc_tlv_block.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* Copyright (c) 2015 Nordic Semiconductor. All Rights Reserved.
  2. *
  3. * The information contained herein is property of Nordic Semiconductor ASA.
  4. * Terms and conditions of usage are described in detail in NORDIC
  5. * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
  6. *
  7. * Licensees are granted free, non-transferable use of the information. NO
  8. * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
  9. * the file.
  10. *
  11. */
  12. #ifndef NFC_TLV_BLOCK_H__
  13. #define NFC_TLV_BLOCK_H__
  14. #include <stdint.h>
  15. /**@file
  16. *
  17. * @defgroup nfc_type_2_tag_tlv_block Type 2 Tag TLV blocks
  18. * @{
  19. * @ingroup nfc_type_2_tag_parser
  20. *
  21. * @brief Descriptor for a Type 2 Tag TLV block.
  22. *
  23. */
  24. /**
  25. * @brief Tag field values.
  26. *
  27. * Possible values for the tag field in a TLV block.
  28. */
  29. typedef enum
  30. {
  31. TLV_NULL = 0x00, ///< Might be used for padding of memory areas.
  32. TLV_LOCK_CONTROL = 0x01, ///< Defines details of the lock bits.
  33. TLV_MEMORY_CONTROL = 0x02, ///< Identifies reserved memory areas.
  34. TLV_NDEF_MESSAGE = 0x03, ///< Contains an NDEF message.
  35. TLV_PROPRIETARY = 0xFD, ///< Tag proprietary information.
  36. TLV_TERMINATOR = 0xFE ///< Last TLV block in the data area.
  37. } tlv_block_types_t;
  38. /**
  39. * @brief TLV block descriptor.
  40. */
  41. typedef struct
  42. {
  43. uint8_t tag; ///< Type of the TLV block.
  44. uint16_t length; ///< Length of the value field.
  45. uint8_t * p_value; ///< Pointer to the value field (NULL if no value field is present in the block).
  46. } tlv_block_t;
  47. #define TLV_T_LENGTH 1 ///< Length of a tag field.
  48. #define TLV_L_SHORT_LENGTH 1 ///< Length of a short length field.
  49. #define TLV_L_LONG_LENGTH 3 ///< Length of an extended length field.
  50. #define TLV_L_FORMAT_FLAG 0xFF ///< Value indicating the use of an extended length field.
  51. #define TLV_NULL_TERMINATOR_LEN 0 ///< Predefined length of the NULL and TERMINATOR TLV blocks.
  52. #define TLV_LOCK_MEMORY_CTRL_LEN 3 ///< Predefined length of the LOCK CONTROL and MEMORY CONTROL blocks.
  53. /**
  54. * @}
  55. */
  56. #endif /* NFC_TLV_BLOCK_H__ */