Choco OS  V.0.16.9.0
Join to the chocolate world
oc_module.h
Go to the documentation of this file.
1 
28 #ifndef SYSTEM_LIBRARIES_INC_OC_MODULE_H_
29 #define SYSTEM_LIBRARIES_INC_OC_MODULE_H_
30 
31 #include <stdbool.h>
32 #include <oc_stdtypes.h>
33 #include <oc_bits.h>
34 #include <oc_errors.h>
35 
41 #define _________________________________________TYPES_SECTION______________________________________________________________________________
42 
43 #define MAX_REQUIRED_MODULES 5
44 
45 typedef enum
46 {
47  oC_Module_None = 0,
48  oC_Module_GPIO ,
49  oC_Module_CLOCK_LLD ,
50  oC_Module_MEM_LLD ,
51  oC_Module_SYS_LLD ,
52  oC_Module_GPIO_LLD ,
53  oC_Module_UART_LLD ,
54  oC_Module_LCDTFT_LLD ,
55  oC_Module_LCDTFT ,
56  oC_Module_FMC ,
57  oC_Module_FMC_LLD ,
58  oC_Module_ScreenMan ,
59  oC_Module_ETH ,
60  oC_Module_ETH_LLD ,
61  oC_Module_NetifMan ,
62  oC_Module_Udp ,
63  oC_Module_ExcHan ,
64  oC_Module_Icmp ,
65  oC_Module_Tcp ,
66  oC_Module_PortMan ,
67  oC_Module_ServiceMan ,
68  oC_Module_ProcessMan ,
69  oC_Module_ThreadMan ,
70 
71  /* This should be always at the end of the list */
72  oC_Module_NumberOfModules ,
73  oC_Module_MaxRequiredModules = MAX_REQUIRED_MODULES,
74 } oC_Module_t;
75 
76 typedef oC_ErrorCode_t (*oC_Module_TurnFunction_t)( void );
77 
78 typedef oC_Module_t oC_Module_RequiredArray_t[MAX_REQUIRED_MODULES];
79 
80 typedef struct
81 {
82  const char * Name;
83  oC_Module_t Module;
84  oC_Module_TurnFunction_t TurnOnFunction;
85  oC_Module_TurnFunction_t TurnOffFunction;
86  oC_Module_RequiredArray_t RequiredModules;
88 
89 #undef _________________________________________TYPES_SECTION______________________________________________________________________________
90 
96 #define _________________________________________VARIABLES_SECTION__________________________________________________________________________
97 
98 extern uint32_t oC_Module_EnabledFlags[ oC_Module_NumberOfModules/32 + ((oC_Module_NumberOfModules%32) ? 1 : 0)];
99 
100 #undef _________________________________________VARIABLES_SECTION__________________________________________________________________________
101 
102 
108 #define _________________________________________STATIC_INLINE_SECTION______________________________________________________________________
109 
110 //==========================================================================================================================================
120 //==========================================================================================================================================
121 static inline bool oC_Module_IsTurnedOn( oC_Module_t Module )
122 {
123  return (Module < oC_Module_NumberOfModules) && (oC_Bits_IsBitSetU32(oC_Module_EnabledFlags[Module/32],Module % 32));
124 }
125 
126 //==========================================================================================================================================
137 //==========================================================================================================================================
138 static inline bool oC_Module_TurnOnVerification( oC_ErrorCode_t * outErrorCode , oC_Module_t Module )
139 {
140  return oC_AssignErrorCodeIfFalse( outErrorCode , oC_Module_IsTurnedOn(Module) , oC_ErrorCode_ModuleNotStartedYet );
141 }
142 
143 //==========================================================================================================================================
154 //==========================================================================================================================================
155 static inline bool oC_Module_TurnOffVerification( oC_ErrorCode_t * outErrorCode , oC_Module_t Module )
156 {
157  return oC_AssignErrorCodeIfFalse( outErrorCode , !oC_Module_IsTurnedOn(Module) , oC_ErrorCode_ModuleIsTurnedOn );
158 }
159 
160 //==========================================================================================================================================
169 //==========================================================================================================================================
170 static inline void oC_Module_TurnOn( oC_Module_t Module )
171 {
172  oC_Bits_SetBitU32(&oC_Module_EnabledFlags[Module/32],Module % 32);
173 }
174 
175 //==========================================================================================================================================
184 //==========================================================================================================================================
185 static inline void oC_Module_TurnOff( oC_Module_t Module )
186 {
187  oC_Bits_ClearBitU32(&oC_Module_EnabledFlags[Module/32],Module % 32);
188 }
189 #undef _________________________________________STATIC_INLINE_SECTION______________________________________________________________________
190 
191 
192 #endif /* SYSTEM_LIBRARIES_INC_OC_MODULE_H_ */
static bool oC_Module_IsTurnedOn(oC_Module_t Module)
checks if the module is turned on
Definition: oc_module.h:121
static void oC_Module_TurnOn(oC_Module_t Module)
sets module as turned on
Definition: oc_module.h:170
The file with functions for the bits operation.
static bool oC_Bits_IsBitSetU32(uint32_t BitMask, uint8_t BitIndex)
checks if bit is set
Definition: oc_bits.h:679
static bool oC_Module_TurnOffVerification(oC_ErrorCode_t *outErrorCode, oC_Module_t Module)
verify if module is turned off
Definition: oc_module.h:155
static bool oC_Module_TurnOnVerification(oC_ErrorCode_t *outErrorCode, oC_Module_t Module)
verify if module is turned on
Definition: oc_module.h:138
static uint32_t oC_Bits_SetBitU32(uint32_t *outVariable, uint8_t BitIndex)
sets bit in the variable
Definition: oc_bits.h:743
FILE__DESCRIPTION
static void oC_Module_TurnOff(oC_Module_t Module)
sets module as turned off
Definition: oc_module.h:185
static uint32_t oC_Bits_ClearBitU32(uint32_t *outVariable, uint8_t BitIndex)
clear selected bit
Definition: oc_bits.h:814