MotorWare f2806x Module API Documentation
fem.c
Go to the documentation of this file.
1 
7 
8 // **************************************************************************
9 // the includes
10 
12 
13 
14 // **************************************************************************
15 // the globals
16 
17 
18 // **************************************************************************
19 // the functions
20 
21 FEM_Handle FEM_init(void *pMemory,const size_t numBytes)
22 {
23  FEM_Handle handle;
24 
25  if(numBytes < sizeof(FEM_Obj))
26  return((FEM_Handle)NULL);
27 
28  // assign the handle
29  handle = (FEM_Handle)pMemory;
30 
31  return(handle);
32 } // end of FEM_init() function
33 
34 
36  const float_t timerFreq_Hz,
37  const uint32_t timerPeriod_cnts,
38  const float_t spFreq_Hz,
39  const float_t maxFreqError_Hz)
40 {
41  uint32_t maxDeltaCnt = (uint32_t)(timerFreq_Hz/(spFreq_Hz - maxFreqError_Hz));
42  uint32_t minDeltaCnt = (uint32_t)(timerFreq_Hz/(spFreq_Hz + maxFreqError_Hz));
43 
44  FEM_setTimerPeriod(handle,timerPeriod_cnts);
45 
46  FEM_setCnt_z0(handle,0);
47  FEM_setCnt_z1(handle,0);
48  FEM_setDeltaCnt(handle,0);
49 
50  FEM_setMaxDeltaCnt(handle,maxDeltaCnt);
52  FEM_setMinDeltaCnt(handle,minDeltaCnt);
53 
54  FEM_setErrorCnt(handle,0);
55  FEM_setFlag_freqError(handle,false);
56 
57  return;
58 } // end of FEM_setParams() function
59 
60 // end of file
static void FEM_setFlag_freqError(FEM_Handle handle, const bool state)
Sets the state of the frequency error flag.
Definition: fem.h:243
static void FEM_setDeltaCnt(FEM_Handle handle, const uint32_t deltaCnt)
Sets the delta count value.
Definition: fem.h:217
static void FEM_setMinDeltaCnt(FEM_Handle handle, const uint32_t minDeltaCnt)
Sets the minimum delta count, cnts.
Definition: fem.h:282
void FEM_setParams(FEM_Handle handle, const float_t timerFreq_Hz, const uint32_t timerPeriod_cnts, const float_t spFreq_Hz, const float_t maxFreqError_Hz)
Sets the frequency of execution monitoring parameters, cnts.
Definition: fem.c:35
static void FEM_setErrorCnt(FEM_Handle handle, const uint32_t numErrors)
Sets the error count.
Definition: fem.h:230
Contains the public interface to the frequency of execution monitoring(FEM) module routines...
static void FEM_setMaxDeltaCntObserved(FEM_Handle handle, const uint32_t maxDeltaCnt)
Sets the maximum delta count observed, cnts.
Definition: fem.h:269
Defines the frequency of execution monitoring (FEM) object.
Definition: fem.h:40
static void FEM_setCnt_z0(FEM_Handle handle, const uint32_t cnt)
Sets the current count value.
Definition: fem.h:191
static void FEM_setMaxDeltaCnt(FEM_Handle handle, const uint32_t maxDeltaCnt)
Sets the maximum delta count, cnts.
Definition: fem.h:256
static void FEM_setCnt_z1(FEM_Handle handle, const uint32_t cnt)
Sets the previous count value.
Definition: fem.h:204
struct _FEM_Obj_ * FEM_Handle
Defines the FEM handle.
Definition: fem.h:60
FEM_Handle FEM_init(void *pMemory, const size_t numBytes)
Initializes the frequency of execution monitoring (FEM) object.
Definition: fem.c:21
static void FEM_setTimerPeriod(FEM_Handle handle, const uint32_t timerPeriod_cnts)
Sets the timer period, cnts.
Definition: fem.h:308
float float_t
Defines the portable data type for 32 bit, signed floating-point data.
Definition: types.h:121