| 1 | /* USER CODE BEGIN Header */
|
|---|
| 2 | /**
|
|---|
| 3 | ******************************************************************************
|
|---|
| 4 | * @file : App/usbd_desc.c
|
|---|
| 5 | * @version : v1.0_Cube
|
|---|
| 6 | * @brief : This file implements the USB device descriptors.
|
|---|
| 7 | ******************************************************************************
|
|---|
| 8 | * @attention
|
|---|
| 9 | *
|
|---|
| 10 | * <h2><center>© Copyright (c) 2021 STMicroelectronics.
|
|---|
| 11 | * All rights reserved.</center></h2>
|
|---|
| 12 | *
|
|---|
| 13 | * This software component is licensed by ST under Ultimate Liberty license
|
|---|
| 14 | * SLA0044, the "License"; You may not use this file except in compliance with
|
|---|
| 15 | * the License. You may obtain a copy of the License at:
|
|---|
| 16 | * www.st.com/SLA0044
|
|---|
| 17 | *
|
|---|
| 18 | ******************************************************************************
|
|---|
| 19 | */
|
|---|
| 20 | /* USER CODE END Header */
|
|---|
| 21 |
|
|---|
| 22 | /* Includes ------------------------------------------------------------------*/
|
|---|
| 23 | #include "usbd_core.h"
|
|---|
| 24 | #include "usbd_desc.h"
|
|---|
| 25 | #include "usbd_conf.h"
|
|---|
| 26 |
|
|---|
| 27 | /* USER CODE BEGIN INCLUDE */
|
|---|
| 28 |
|
|---|
| 29 | /* USER CODE END INCLUDE */
|
|---|
| 30 |
|
|---|
| 31 | /* Private typedef -----------------------------------------------------------*/
|
|---|
| 32 | /* Private define ------------------------------------------------------------*/
|
|---|
| 33 | /* Private macro -------------------------------------------------------------*/
|
|---|
| 34 |
|
|---|
| 35 | /* USER CODE BEGIN PV */
|
|---|
| 36 | /* Private variables ---------------------------------------------------------*/
|
|---|
| 37 |
|
|---|
| 38 | /* USER CODE END PV */
|
|---|
| 39 |
|
|---|
| 40 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
|
|---|
| 41 | * @{
|
|---|
| 42 | */
|
|---|
| 43 |
|
|---|
| 44 | /** @addtogroup USBD_DESC
|
|---|
| 45 | * @{
|
|---|
| 46 | */
|
|---|
| 47 |
|
|---|
| 48 | /** @defgroup USBD_DESC_Private_TypesDefinitions USBD_DESC_Private_TypesDefinitions
|
|---|
| 49 | * @brief Private types.
|
|---|
| 50 | * @{
|
|---|
| 51 | */
|
|---|
| 52 |
|
|---|
| 53 | /* USER CODE BEGIN PRIVATE_TYPES */
|
|---|
| 54 |
|
|---|
| 55 | /* USER CODE END PRIVATE_TYPES */
|
|---|
| 56 |
|
|---|
| 57 | /**
|
|---|
| 58 | * @}
|
|---|
| 59 | */
|
|---|
| 60 |
|
|---|
| 61 | /** @defgroup USBD_DESC_Private_Defines USBD_DESC_Private_Defines
|
|---|
| 62 | * @brief Private defines.
|
|---|
| 63 | * @{
|
|---|
| 64 | */
|
|---|
| 65 |
|
|---|
| 66 | #define USBD_VID 1155
|
|---|
| 67 | #define USBD_LANGID_STRING 1033
|
|---|
| 68 | #define USBD_MANUFACTURER_STRING "STMicroelectronics"
|
|---|
| 69 | #define USBD_PID_FS 22336
|
|---|
| 70 | #define USBD_PRODUCT_STRING_FS "STM32 Virtual ComPort"
|
|---|
| 71 | #define USBD_CONFIGURATION_STRING_FS "CDC Config"
|
|---|
| 72 | #define USBD_INTERFACE_STRING_FS "CDC Interface"
|
|---|
| 73 |
|
|---|
| 74 | #define USB_SIZ_BOS_DESC 0x0C
|
|---|
| 75 |
|
|---|
| 76 | /* USER CODE BEGIN PRIVATE_DEFINES */
|
|---|
| 77 |
|
|---|
| 78 | /* USER CODE END PRIVATE_DEFINES */
|
|---|
| 79 |
|
|---|
| 80 | /**
|
|---|
| 81 | * @}
|
|---|
| 82 | */
|
|---|
| 83 |
|
|---|
| 84 | /* USER CODE BEGIN 0 */
|
|---|
| 85 |
|
|---|
| 86 | /* USER CODE END 0 */
|
|---|
| 87 |
|
|---|
| 88 | /** @defgroup USBD_DESC_Private_Macros USBD_DESC_Private_Macros
|
|---|
| 89 | * @brief Private macros.
|
|---|
| 90 | * @{
|
|---|
| 91 | */
|
|---|
| 92 |
|
|---|
| 93 | /* USER CODE BEGIN PRIVATE_MACRO */
|
|---|
| 94 |
|
|---|
| 95 | /* USER CODE END PRIVATE_MACRO */
|
|---|
| 96 |
|
|---|
| 97 | /**
|
|---|
| 98 | * @}
|
|---|
| 99 | */
|
|---|
| 100 |
|
|---|
| 101 | /** @defgroup USBD_DESC_Private_FunctionPrototypes USBD_DESC_Private_FunctionPrototypes
|
|---|
| 102 | * @brief Private functions declaration.
|
|---|
| 103 | * @{
|
|---|
| 104 | */
|
|---|
| 105 |
|
|---|
| 106 | static void Get_SerialNum(void);
|
|---|
| 107 | static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len);
|
|---|
| 108 |
|
|---|
| 109 | /**
|
|---|
| 110 | * @}
|
|---|
| 111 | */
|
|---|
| 112 |
|
|---|
| 113 | /** @defgroup USBD_DESC_Private_FunctionPrototypes USBD_DESC_Private_FunctionPrototypes
|
|---|
| 114 | * @brief Private functions declaration for FS.
|
|---|
| 115 | * @{
|
|---|
| 116 | */
|
|---|
| 117 |
|
|---|
| 118 | uint8_t * USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
|
|---|
| 119 | uint8_t * USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
|
|---|
| 120 | uint8_t * USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
|
|---|
| 121 | uint8_t * USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
|
|---|
| 122 | uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
|
|---|
| 123 | uint8_t * USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
|
|---|
| 124 | uint8_t * USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
|
|---|
| 125 | #if (USBD_LPM_ENABLED == 1)
|
|---|
| 126 | uint8_t * USBD_FS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
|
|---|
| 127 | #endif /* (USBD_LPM_ENABLED == 1) */
|
|---|
| 128 |
|
|---|
| 129 | /**
|
|---|
| 130 | * @}
|
|---|
| 131 | */
|
|---|
| 132 |
|
|---|
| 133 | /** @defgroup USBD_DESC_Private_Variables USBD_DESC_Private_Variables
|
|---|
| 134 | * @brief Private variables.
|
|---|
| 135 | * @{
|
|---|
| 136 | */
|
|---|
| 137 |
|
|---|
| 138 | USBD_DescriptorsTypeDef FS_Desc =
|
|---|
| 139 | {
|
|---|
| 140 | USBD_FS_DeviceDescriptor
|
|---|
| 141 | , USBD_FS_LangIDStrDescriptor
|
|---|
| 142 | , USBD_FS_ManufacturerStrDescriptor
|
|---|
| 143 | , USBD_FS_ProductStrDescriptor
|
|---|
| 144 | , USBD_FS_SerialStrDescriptor
|
|---|
| 145 | , USBD_FS_ConfigStrDescriptor
|
|---|
| 146 | , USBD_FS_InterfaceStrDescriptor
|
|---|
| 147 | #if (USBD_LPM_ENABLED == 1)
|
|---|
| 148 | , USBD_FS_USR_BOSDescriptor
|
|---|
| 149 | #endif /* (USBD_LPM_ENABLED == 1) */
|
|---|
| 150 | };
|
|---|
| 151 |
|
|---|
| 152 | #if defined ( __ICCARM__ ) /* IAR Compiler */
|
|---|
| 153 | #pragma data_alignment=4
|
|---|
| 154 | #endif /* defined ( __ICCARM__ ) */
|
|---|
| 155 | /** USB standard device descriptor. */
|
|---|
| 156 | __ALIGN_BEGIN uint8_t USBD_FS_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END =
|
|---|
| 157 | {
|
|---|
| 158 | 0x12, /*bLength */
|
|---|
| 159 | USB_DESC_TYPE_DEVICE, /*bDescriptorType*/
|
|---|
| 160 | #if (USBD_LPM_ENABLED == 1)
|
|---|
| 161 | 0x01, /*bcdUSB */ /* changed to USB version 2.01
|
|---|
| 162 | in order to support LPM L1 suspend
|
|---|
| 163 | resume test of USBCV3.0*/
|
|---|
| 164 | #else
|
|---|
| 165 | 0x00, /*bcdUSB */
|
|---|
| 166 | #endif /* (USBD_LPM_ENABLED == 1) */
|
|---|
| 167 | 0x02,
|
|---|
| 168 | 0x02, /*bDeviceClass*/
|
|---|
| 169 | 0x02, /*bDeviceSubClass*/
|
|---|
| 170 | 0x00, /*bDeviceProtocol*/
|
|---|
| 171 | USB_MAX_EP0_SIZE, /*bMaxPacketSize*/
|
|---|
| 172 | LOBYTE(USBD_VID), /*idVendor*/
|
|---|
| 173 | HIBYTE(USBD_VID), /*idVendor*/
|
|---|
| 174 | LOBYTE(USBD_PID_FS), /*idProduct*/
|
|---|
| 175 | HIBYTE(USBD_PID_FS), /*idProduct*/
|
|---|
| 176 | 0x00, /*bcdDevice rel. 2.00*/
|
|---|
| 177 | 0x02,
|
|---|
| 178 | USBD_IDX_MFC_STR, /*Index of manufacturer string*/
|
|---|
| 179 | USBD_IDX_PRODUCT_STR, /*Index of product string*/
|
|---|
| 180 | USBD_IDX_SERIAL_STR, /*Index of serial number string*/
|
|---|
| 181 | USBD_MAX_NUM_CONFIGURATION /*bNumConfigurations*/
|
|---|
| 182 | };
|
|---|
| 183 |
|
|---|
| 184 | /* USB_DeviceDescriptor */
|
|---|
| 185 | /** BOS descriptor. */
|
|---|
| 186 | #if (USBD_LPM_ENABLED == 1)
|
|---|
| 187 | #if defined ( __ICCARM__ ) /* IAR Compiler */
|
|---|
| 188 | #pragma data_alignment=4
|
|---|
| 189 | #endif /* defined ( __ICCARM__ ) */
|
|---|
| 190 | __ALIGN_BEGIN uint8_t USBD_FS_BOSDesc[USB_SIZ_BOS_DESC] __ALIGN_END =
|
|---|
| 191 | {
|
|---|
| 192 | 0x5,
|
|---|
| 193 | USB_DESC_TYPE_BOS,
|
|---|
| 194 | 0xC,
|
|---|
| 195 | 0x0,
|
|---|
| 196 | 0x1, /* 1 device capability*/
|
|---|
| 197 | /* device capability*/
|
|---|
| 198 | 0x7,
|
|---|
| 199 | USB_DEVICE_CAPABITY_TYPE,
|
|---|
| 200 | 0x2,
|
|---|
| 201 | 0x2, /* LPM capability bit set*/
|
|---|
| 202 | 0x0,
|
|---|
| 203 | 0x0,
|
|---|
| 204 | 0x0
|
|---|
| 205 | };
|
|---|
| 206 | #endif /* (USBD_LPM_ENABLED == 1) */
|
|---|
| 207 |
|
|---|
| 208 | /**
|
|---|
| 209 | * @}
|
|---|
| 210 | */
|
|---|
| 211 |
|
|---|
| 212 | /** @defgroup USBD_DESC_Private_Variables USBD_DESC_Private_Variables
|
|---|
| 213 | * @brief Private variables.
|
|---|
| 214 | * @{
|
|---|
| 215 | */
|
|---|
| 216 |
|
|---|
| 217 | #if defined ( __ICCARM__ ) /* IAR Compiler */
|
|---|
| 218 | #pragma data_alignment=4
|
|---|
| 219 | #endif /* defined ( __ICCARM__ ) */
|
|---|
| 220 |
|
|---|
| 221 | /** USB lang indentifier descriptor. */
|
|---|
| 222 | __ALIGN_BEGIN uint8_t USBD_LangIDDesc[USB_LEN_LANGID_STR_DESC] __ALIGN_END =
|
|---|
| 223 | {
|
|---|
| 224 | USB_LEN_LANGID_STR_DESC,
|
|---|
| 225 | USB_DESC_TYPE_STRING,
|
|---|
| 226 | LOBYTE(USBD_LANGID_STRING),
|
|---|
| 227 | HIBYTE(USBD_LANGID_STRING)
|
|---|
| 228 | };
|
|---|
| 229 |
|
|---|
| 230 | #if defined ( __ICCARM__ ) /* IAR Compiler */
|
|---|
| 231 | #pragma data_alignment=4
|
|---|
| 232 | #endif /* defined ( __ICCARM__ ) */
|
|---|
| 233 | /* Internal string descriptor. */
|
|---|
| 234 | __ALIGN_BEGIN uint8_t USBD_StrDesc[USBD_MAX_STR_DESC_SIZ] __ALIGN_END;
|
|---|
| 235 |
|
|---|
| 236 | #if defined ( __ICCARM__ ) /*!< IAR Compiler */
|
|---|
| 237 | #pragma data_alignment=4
|
|---|
| 238 | #endif
|
|---|
| 239 | __ALIGN_BEGIN uint8_t USBD_StringSerial[USB_SIZ_STRING_SERIAL] __ALIGN_END = {
|
|---|
| 240 | USB_SIZ_STRING_SERIAL,
|
|---|
| 241 | USB_DESC_TYPE_STRING,
|
|---|
| 242 | };
|
|---|
| 243 |
|
|---|
| 244 | /**
|
|---|
| 245 | * @}
|
|---|
| 246 | */
|
|---|
| 247 |
|
|---|
| 248 | /** @defgroup USBD_DESC_Private_Functions USBD_DESC_Private_Functions
|
|---|
| 249 | * @brief Private functions.
|
|---|
| 250 | * @{
|
|---|
| 251 | */
|
|---|
| 252 |
|
|---|
| 253 | /**
|
|---|
| 254 | * @brief Return the device descriptor
|
|---|
| 255 | * @param speed : Current device speed
|
|---|
| 256 | * @param length : Pointer to data length variable
|
|---|
| 257 | * @retval Pointer to descriptor buffer
|
|---|
| 258 | */
|
|---|
| 259 | uint8_t * USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
|
|---|
| 260 | {
|
|---|
| 261 | UNUSED(speed);
|
|---|
| 262 | *length = sizeof(USBD_FS_DeviceDesc);
|
|---|
| 263 | return USBD_FS_DeviceDesc;
|
|---|
| 264 | }
|
|---|
| 265 |
|
|---|
| 266 | /**
|
|---|
| 267 | * @brief Return the LangID string descriptor
|
|---|
| 268 | * @param speed : Current device speed
|
|---|
| 269 | * @param length : Pointer to data length variable
|
|---|
| 270 | * @retval Pointer to descriptor buffer
|
|---|
| 271 | */
|
|---|
| 272 | uint8_t * USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
|
|---|
| 273 | {
|
|---|
| 274 | UNUSED(speed);
|
|---|
| 275 | *length = sizeof(USBD_LangIDDesc);
|
|---|
| 276 | return USBD_LangIDDesc;
|
|---|
| 277 | }
|
|---|
| 278 |
|
|---|
| 279 | /**
|
|---|
| 280 | * @brief Return the product string descriptor
|
|---|
| 281 | * @param speed : Current device speed
|
|---|
| 282 | * @param length : Pointer to data length variable
|
|---|
| 283 | * @retval Pointer to descriptor buffer
|
|---|
| 284 | */
|
|---|
| 285 | uint8_t * USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
|
|---|
| 286 | {
|
|---|
| 287 | if(speed == 0)
|
|---|
| 288 | {
|
|---|
| 289 | USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_FS, USBD_StrDesc, length);
|
|---|
| 290 | }
|
|---|
| 291 | else
|
|---|
| 292 | {
|
|---|
| 293 | USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_FS, USBD_StrDesc, length);
|
|---|
| 294 | }
|
|---|
| 295 | return USBD_StrDesc;
|
|---|
| 296 | }
|
|---|
| 297 |
|
|---|
| 298 | /**
|
|---|
| 299 | * @brief Return the manufacturer string descriptor
|
|---|
| 300 | * @param speed : Current device speed
|
|---|
| 301 | * @param length : Pointer to data length variable
|
|---|
| 302 | * @retval Pointer to descriptor buffer
|
|---|
| 303 | */
|
|---|
| 304 | uint8_t * USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
|
|---|
| 305 | {
|
|---|
| 306 | UNUSED(speed);
|
|---|
| 307 | USBD_GetString((uint8_t *)USBD_MANUFACTURER_STRING, USBD_StrDesc, length);
|
|---|
| 308 | return USBD_StrDesc;
|
|---|
| 309 | }
|
|---|
| 310 |
|
|---|
| 311 | /**
|
|---|
| 312 | * @brief Return the serial number string descriptor
|
|---|
| 313 | * @param speed : Current device speed
|
|---|
| 314 | * @param length : Pointer to data length variable
|
|---|
| 315 | * @retval Pointer to descriptor buffer
|
|---|
| 316 | */
|
|---|
| 317 | uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
|
|---|
| 318 | {
|
|---|
| 319 | UNUSED(speed);
|
|---|
| 320 | *length = USB_SIZ_STRING_SERIAL;
|
|---|
| 321 |
|
|---|
| 322 | /* Update the serial number string descriptor with the data from the unique
|
|---|
| 323 | * ID */
|
|---|
| 324 | Get_SerialNum();
|
|---|
| 325 | /* USER CODE BEGIN USBD_FS_SerialStrDescriptor */
|
|---|
| 326 |
|
|---|
| 327 | /* USER CODE END USBD_FS_SerialStrDescriptor */
|
|---|
| 328 | return (uint8_t *) USBD_StringSerial;
|
|---|
| 329 | }
|
|---|
| 330 |
|
|---|
| 331 | /**
|
|---|
| 332 | * @brief Return the configuration string descriptor
|
|---|
| 333 | * @param speed : Current device speed
|
|---|
| 334 | * @param length : Pointer to data length variable
|
|---|
| 335 | * @retval Pointer to descriptor buffer
|
|---|
| 336 | */
|
|---|
| 337 | uint8_t * USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
|
|---|
| 338 | {
|
|---|
| 339 | if(speed == USBD_SPEED_HIGH)
|
|---|
| 340 | {
|
|---|
| 341 | USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_FS, USBD_StrDesc, length);
|
|---|
| 342 | }
|
|---|
| 343 | else
|
|---|
| 344 | {
|
|---|
| 345 | USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_FS, USBD_StrDesc, length);
|
|---|
| 346 | }
|
|---|
| 347 | return USBD_StrDesc;
|
|---|
| 348 | }
|
|---|
| 349 |
|
|---|
| 350 | /**
|
|---|
| 351 | * @brief Return the interface string descriptor
|
|---|
| 352 | * @param speed : Current device speed
|
|---|
| 353 | * @param length : Pointer to data length variable
|
|---|
| 354 | * @retval Pointer to descriptor buffer
|
|---|
| 355 | */
|
|---|
| 356 | uint8_t * USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
|
|---|
| 357 | {
|
|---|
| 358 | if(speed == 0)
|
|---|
| 359 | {
|
|---|
| 360 | USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_FS, USBD_StrDesc, length);
|
|---|
| 361 | }
|
|---|
| 362 | else
|
|---|
| 363 | {
|
|---|
| 364 | USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_FS, USBD_StrDesc, length);
|
|---|
| 365 | }
|
|---|
| 366 | return USBD_StrDesc;
|
|---|
| 367 | }
|
|---|
| 368 |
|
|---|
| 369 | #if (USBD_LPM_ENABLED == 1)
|
|---|
| 370 | /**
|
|---|
| 371 | * @brief Return the BOS descriptor
|
|---|
| 372 | * @param speed : Current device speed
|
|---|
| 373 | * @param length : Pointer to data length variable
|
|---|
| 374 | * @retval Pointer to descriptor buffer
|
|---|
| 375 | */
|
|---|
| 376 | uint8_t * USBD_FS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
|
|---|
| 377 | {
|
|---|
| 378 | UNUSED(speed);
|
|---|
| 379 | *length = sizeof(USBD_FS_BOSDesc);
|
|---|
| 380 | return (uint8_t*)USBD_FS_BOSDesc;
|
|---|
| 381 | }
|
|---|
| 382 | #endif /* (USBD_LPM_ENABLED == 1) */
|
|---|
| 383 |
|
|---|
| 384 | /**
|
|---|
| 385 | * @brief Create the serial number string descriptor
|
|---|
| 386 | * @param None
|
|---|
| 387 | * @retval None
|
|---|
| 388 | */
|
|---|
| 389 | static void Get_SerialNum(void)
|
|---|
| 390 | {
|
|---|
| 391 | uint32_t deviceserial0, deviceserial1, deviceserial2;
|
|---|
| 392 |
|
|---|
| 393 | deviceserial0 = *(uint32_t *) DEVICE_ID1;
|
|---|
| 394 | deviceserial1 = *(uint32_t *) DEVICE_ID2;
|
|---|
| 395 | deviceserial2 = *(uint32_t *) DEVICE_ID3;
|
|---|
| 396 |
|
|---|
| 397 | deviceserial0 += deviceserial2;
|
|---|
| 398 |
|
|---|
| 399 | if (deviceserial0 != 0)
|
|---|
| 400 | {
|
|---|
| 401 | IntToUnicode(deviceserial0, &USBD_StringSerial[2], 8);
|
|---|
| 402 | IntToUnicode(deviceserial1, &USBD_StringSerial[18], 4);
|
|---|
| 403 | }
|
|---|
| 404 | }
|
|---|
| 405 |
|
|---|
| 406 | /**
|
|---|
| 407 | * @brief Convert Hex 32Bits value into char
|
|---|
| 408 | * @param value: value to convert
|
|---|
| 409 | * @param pbuf: pointer to the buffer
|
|---|
| 410 | * @param len: buffer length
|
|---|
| 411 | * @retval None
|
|---|
| 412 | */
|
|---|
| 413 | static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len)
|
|---|
| 414 | {
|
|---|
| 415 | uint8_t idx = 0;
|
|---|
| 416 |
|
|---|
| 417 | for (idx = 0; idx < len; idx++)
|
|---|
| 418 | {
|
|---|
| 419 | if (((value >> 28)) < 0xA)
|
|---|
| 420 | {
|
|---|
| 421 | pbuf[2 * idx] = (value >> 28) + '0';
|
|---|
| 422 | }
|
|---|
| 423 | else
|
|---|
| 424 | {
|
|---|
| 425 | pbuf[2 * idx] = (value >> 28) + 'A' - 10;
|
|---|
| 426 | }
|
|---|
| 427 |
|
|---|
| 428 | value = value << 4;
|
|---|
| 429 |
|
|---|
| 430 | pbuf[2 * idx + 1] = 0;
|
|---|
| 431 | }
|
|---|
| 432 | }
|
|---|
| 433 | /**
|
|---|
| 434 | * @}
|
|---|
| 435 | */
|
|---|
| 436 |
|
|---|
| 437 | /**
|
|---|
| 438 | * @}
|
|---|
| 439 | */
|
|---|
| 440 |
|
|---|
| 441 | /**
|
|---|
| 442 | * @}
|
|---|
| 443 | */
|
|---|
| 444 |
|
|---|
| 445 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|---|