AM263x Digital Power SDK  09.01.00
rampgen.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2024 Texas Instruments Incorporated
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the
14  * distribution.
15  *
16  * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 //#############################################################################
33 //
34 // FILE: rampgen.h
35 //
36 // TITLE: Ramp Generator Module
37 //
38 //#############################################################################
39 
40 
41 #ifndef RAMPGEN_H
42 #define RAMPGEN_H
43 
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47 
58 //
59 // Included Files
60 //
61 #include <stdint.h>
62 #include <math.h>
63 
64 
65 //#############################################################################
66 //
67 // Macro Definitions
68 //
69 //#############################################################################
70 #ifndef IEEE754_TYPES
71 #define IEEE754_TYPES
72 
73 typedef float float32_t;
74 typedef double float64_t;
75 
76 #endif // IEEE754_TYPES
77 
78 //
79 // Typedefs
80 //
81 
87 typedef volatile struct {
88  float32_t freq; // Input: Ramp frequency (pu)
89  float32_t stepAngleMax;// Parameter: Maximum step angle (pu)
90  float32_t out; // Output: Ramp signal (pu)
91 } RAMPGEN;
92 
93 
94 
95 
99 static inline void RAMPGEN_reset(RAMPGEN *v)
100 {
101  v->out=0;
102 }
103 
109 static inline void RAMPGEN_config(RAMPGEN *v,
110  float32_t isrFrequency,
111  float32_t rampFrequency)
112 {
113  v->freq=rampFrequency;
114  v->stepAngleMax=((float32_t)1.0)/isrFrequency;
115 }
116 
120 static inline void RAMPGEN_run(RAMPGEN *v)
121 {
122  //
123  // Compute the angle rate
124  //
125  v->out += (v->stepAngleMax*v->freq);
126 
127  //
128  // Saturate the angle rate within (0,1)
129  //
130  if (v->out>(1.0f))
131  {
132  v->out -= (1.0f);
133  }
134 }
135 
136 // Close the Doxygen group.
139 #ifdef __cplusplus
140 }
141 #endif // extern "C"
142 
143 
144 #endif // end of _RAMPGEN_H_ definition
145 
146 //
147 // End of File
148 //
149 
RAMPGEN::freq
float32_t freq
Definition: rampgen.h:88
float32_t
float float32_t
Definition: rampgen.h:73
RAMPGEN_reset
static void RAMPGEN_reset(RAMPGEN *v)
resets RAMPGEN internal storage data and outputs
Definition: rampgen.h:99
RAMPGEN_run
static void RAMPGEN_run(RAMPGEN *v)
Run RAMPGEN module.
Definition: rampgen.h:120
RAMPGEN_config
static void RAMPGEN_config(RAMPGEN *v, float32_t isrFrequency, float32_t rampFrequency)
configures RAMPGEN module
Definition: rampgen.h:109
RAMPGEN::out
float32_t out
Definition: rampgen.h:90
float64_t
double float64_t
Definition: rampgen.h:74
RAMPGEN
Defines the Ramp Signal Generator (RAMPGEN) structure.
Definition: rampgen.h:87
float32_t
float float32_t
Defines single,double precision data type. Note: Assumes ABI to be TI_EABI, does not support legacy T...
Definition: dcl_common.h:54
RAMPGEN::stepAngleMax
float32_t stepAngleMax
Definition: rampgen.h:89