]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_R5_UltraScale_MPSoC/RTOSDemo_R5_bsp/psu_cortexr5_0/libsrc/standalone_v6_1/src/putnum.c
xTaskGenericNotify() now sets xYieldPending to pdTRUE even when the 'higher priority...
[freertos] / FreeRTOS / Demo / CORTEX_R5_UltraScale_MPSoC / RTOSDemo_R5_bsp / psu_cortexr5_0 / libsrc / standalone_v6_1 / src / putnum.c
1 /* putnum.c -- put a hex number on the output device.
2  *
3  * Copyright (c) 1995 Cygnus Support
4  *
5  * The authors hereby grant permission to use, copy, modify, distribute,
6  * and license this software and its documentation for any purpose, provided
7  * that existing copyright notices are retained in all copies and that this
8  * notice is included verbatim in any distributions. No written agreement,
9  * license, or royalty fee is required for any of the authorized uses.
10  * Modifications to this software may be copyrighted by their authors
11  * and need not follow the licensing terms described here, provided that
12  * the new terms are clearly indicated on the first page of each file where
13  * they apply.
14  */
15
16 /*
17  * putnum -- print a 32 bit number in hex
18  */
19
20 /***************************** Include Files *********************************/
21 #include "xil_types.h"
22
23 /************************** Function Prototypes ******************************/
24 extern void print (const char8 *ptr);
25 void putnum(u32 num);
26
27 void putnum(u32 num)
28 {
29   char8  buf[9];
30   s32  cnt;
31   s32 i;
32   char8  *ptr;
33   u32  digit;
34   for(i = 0; i<9; i++) {
35         buf[i] = '0';
36   }
37
38   ptr = buf;
39   for (cnt = 7 ; cnt >= 0 ; cnt--) {
40     digit = (num >> (cnt * 4U)) & 0x0000000fU;
41
42     if ((digit <= 9U) && (ptr != NULL)) {
43                 digit += (u32)'0';
44                 *ptr = ((char8) digit);
45                 ptr += 1;
46         } else if (ptr != NULL) {
47                 digit += ((u32)'a' - (u32)10);
48                 *ptr = ((char8)digit);
49                 ptr += 1;
50         } else {
51                 /*Made for MisraC Compliance*/;
52         }
53   }
54
55   if(ptr != NULL) {
56           *ptr = (char8) 0;
57   }
58   print (buf);
59 }