Does the XDK hardware have a unique ID?
응답
15. 8. 4 오전 10:51
For identification purposes, I wonder - does the XDK hardware have a unique ID? If so, how can it be accessed? If not, how can I access the name of the XDK?
0 (0 투표)
Does the XDK hardware have a unique ID?
응답
15. 8. 4 오후 1:42 as a reply to Christian Renz.
If you hover with your mouse over the little "XDK Devices" field in the Workbench while your XDK is plugged in, you'll get a popup with the CoreID, USB SerialNumber and the USB Location.

You should be able to get the SerialNumber through the following set of methods:

/***************************************************************************//**
 * @brief
 *   Return a pointer to the device descriptor.
 *
 * @param[in] buf
 *   A data buffer containing enumeration data retrieved with
 *   @ref USBH_QueryDeviceB().
 *
 * @return
 *   A pointer to @ref USB_DeviceDescriptor_TypeDef. NULL if no
 *   descriptor found.
 ******************************************************************************/
USB_DeviceDescriptor_TypeDef *USBH_QGetDeviceDescriptor( const uint8_t *buf )
{
  USB_DeviceDescriptor_TypeDef *dev = &((USBH_Device_TypeDef*)buf)->devDesc;

  if ( buf == NULL )
  {
    DEBUG_USB_API_PUTS( "\nUSBH_QGetDeviceDescriptor(), buf NULL pointer" );
    EFM_ASSERT( false );
    return NULL;
  }

  if ( ( dev->bLength         == USB_DEVICE_DESCSIZE   ) &&
       ( dev->bDescriptorType == USB_DEVICE_DESCRIPTOR )    )
  {
    return dev;
  }
  return NULL;
}

The USB_DeviceDescriptor_TypeDef is defined as:

typedef struct
{
  uint8_t  bLength;                             /**< Size of this descriptor in bytes                  */
  uint8_t  bDescriptorType;                     /**< Constant DEVICE Descriptor Type                   */
  uint16_t bcdUSB;                              /**< USB Specification Release Number in Binary-Coded
                                                     Decimal                                           */
  uint8_t  bDeviceClass;                        /**< Class code (assigned by the USB-IF)               */
  uint8_t  bDeviceSubClass;                     /**< Subclass code (assigned by the USB-IF)            */
  uint8_t  bDeviceProtocol;                     /**< Protocol code (assigned by the USB-IF)            */
  uint8_t  bMaxPacketSize0;                     /**< Maximum packet size for endpoint zero             */
  uint16_t idVendor;                            /**< Vendor ID (assigned by the USB-IF)                */
  uint16_t idProduct;                           /**< Product ID (assigned by the manufacturer)         */
  uint16_t bcdDevice;                           /**< Device release number in binary-coded decimal     */
  uint8_t  iManufacturer;                       /**< Index of string descriptor describing manufacturer*/
  uint8_t  iProduct;                            /**< Index of string descriptor describing product     */
  uint8_t  iSerialNumber;                       /**< Index of string descriptor describing the device
                                                     serialnumber                                      */
  uint8_t  bNumConfigurations;                  /**< Number of possible configurations                 */
} __attribute__ ((packed)) USB_DeviceDescriptor_TypeDef;

So device->iSerialNumber should give you that number.

Let me know how it goes.

- Florian

0 (0 투표)
RE: Does the XDK hardware have a unique ID?
응답
17. 2. 16 오전 2:23 as a reply to Florian Harr.

Hi,

What do I need to #include to get this to work?
I am trying to extract the device's CoreID.

 

Thanks.

0 (0 투표)
RE: Does the XDK hardware have a unique ID?
응답
17. 2. 16 오후 7:00 as a reply to Lee Weiyang.

Hello Lee,

Florian's mentioned function should be the correct way to extract the CoreID which is the same as the unique usb ID.
To access this ID you have to include em_usb.h.
Additionally make sure that USB_HOST is defined in USB_ph.h instead of USB_DEVICE.

Please tell me if this is helpful and do not hesitate to ask if you have further questions.

Kind regards,
Franjo

0 (0 투표)
RE: Does the XDK hardware have a unique ID?
응답
17. 2. 17 오전 4:11 as a reply to Franjo Stjepandic.

Hi Fanjo,

Thank you for your reply. I eneded up using this code that I found on the forums:

   unsigned int * serialStackAddress0 = 0xFE081F0;
    unsigned int * serialStackAddress1 = 0xFE081F4;

    unsigned int serialUnique0 = *serialStackAddress0;
    unsigned int serialUnique1 = *serialStackAddress1;

  printf("0x%08x%08x\n",serialUnique1,serialUnique0);

0 (0 투표)
RE: Does the XDK hardware have a unique ID?
응답
17. 2. 17 오후 9:10 as a reply to Lee Weiyang.

Hello Lee,

I am glad to help.
The code that you found reads the same core ID and is therefore also suitable for your purpose.

Please do not hesitate to ask if you have further questions.

Kind regards,
Franjo

 

0 (0 투표)