iLLD_TC27xD  1.0
Ifx_GlobalResources.c
Go to the documentation of this file.
1 /**
2  * \file Ifx_GlobalResources.h
3  * \brief Handling of global resources
4  *
5  * \version iLLD_1_0_0_11_0
6  * \copyright Copyright (c) 2013 Infineon Technologies AG. All rights reserved.
7  *
8  *
9  * IMPORTANT NOTICE
10  *
11  *
12  * Infineon Technologies AG (Infineon) is supplying this file for use
13  * exclusively with Infineon's microcontroller products. This file can be freely
14  * distributed within development tools that are supporting such microcontroller
15  * products.
16  *
17  * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
18  * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
19  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
20  * INFINEON SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
21  * OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
22  *
23  */
24 
25 #include "Ifx_GlobalResources.h"
26 /** \brief Global resource object */
27 typedef struct
28 {
29  const Ifx_GlobalResources_Item *table; /**< \brief Pointer to the global resource table */
30  sint32 size; /**< \brief Size of the global resource table */
32 
33 #if IFX_CFG_GLOBAL_RESOURCES_ENABLED
34 
35 Ifx_GlobalResources ifx_GlobalResource;
36 #endif
37 
39 {
40  void *result;
41 
42 #if IFX_CFG_GLOBAL_RESOURCES_ENABLED
43 
44  if (id < ifx_GlobalResource.size)
45  {
46  result = ifx_GlobalResource.table[id].resource;
47  }
48  else
49  {
50  result = NULL_PTR;
51  }
52 
53 #else
54  result = NULL_PTR;
55 
56 #endif
57 
58  return result;
59 }
60 
61 
63 {
64  sint32 id = -1;
65 
66 #if IFX_CFG_GLOBAL_RESOURCES_ENABLED
67  int i;
68 
69  for (i = 0; i < ifx_GlobalResource.size; i++)
70  {
71  if (resource == ifx_GlobalResource.table[i].resource)
72  {
73  id = i;
74  }
75  else
76  {}
77  }
78 
79 #else
80 #endif
81 
82  return id;
83 }
84 
85 
87 {
88  const Ifx_GlobalResources_Item *result;
89 
90 #if IFX_CFG_GLOBAL_RESOURCES_ENABLED
91 
92  if (id < ifx_GlobalResource.size)
93  {
94  result = &ifx_GlobalResource.table[id];
95  }
96  else
97  {
98  result = NULL_PTR;
99  }
100 
101 #else
102  result = NULL_PTR;
103 
104 #endif
105 
106  return result;
107 }
108 
109 
111 {
112  pchar name;
113 
114 #if IFX_CFG_GLOBAL_RESOURCES_ENABLED
115 
116  if (id < ifx_GlobalResource.size)
117  {
118  name = ifx_GlobalResource.table[id].name;
119  }
120  else
121  {
122  name = "unknown";
123  }
124 
125 #else
126  name = "unknown";
127 
128 #endif
129 
130  return name;
131 }
132 
133 
135 {
136  boolean result;
137 
138 #if IFX_CFG_GLOBAL_RESOURCES_ENABLED
139  ifx_GlobalResource.table = table;
140  ifx_GlobalResource.size = size;
141  result = TRUE;
142 #else
143  result = FALSE;
144 
145 #endif
146 
147  return result;
148 }