datalog.h
Go to the documentation of this file.
1 //#############################################################################
2 // $TI Release: MotorControl SDK v3.00.01.00 $
3 // $Release Date: Tue May 26 19:13:58 CDT 2020 $
4 // $Copyright:
5 // Copyright (C) 2017-2019 Texas Instruments Incorporated - http://www.ti.com/
6 //
7 // Redistribution and use in source and binary forms, with or without
8 // modification, are permitted provided that the following conditions
9 // are met:
10 //
11 // Redistributions of source code must retain the above copyright
12 // notice, this list of conditions and the following disclaimer.
13 //
14 // Redistributions in binary form must reproduce the above copyright
15 // notice, this list of conditions and the following disclaimer in the
16 // documentation and/or other materials provided with the
17 // distribution.
18 //
19 // Neither the name of Texas Instruments Incorporated nor the names of
20 // its contributors may be used to endorse or promote products derived
21 // from this software without specific prior written permission.
22 //
23 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 // $
35 //#############################################################################
36 
37 #ifndef DATALOG_H
38 #define DATALOG_H
39 
44 
45 // **************************************************************************
46 // the includes
47 
49 
55 
56 #ifdef __cplusplus
57 extern "C" {
58 #endif
59 
60 // **************************************************************************
61 // the defines
62 #define DATA_LOG_BUFF_NUM 4
63 
64 #define DATA_LOG_BUFF_SIZE 400 //20*20
65 
66 #define DLOG_BURST_SIZE 20 // write 820 to the register for
67  // a burst size of 20
68 
69 #define DLOG_TRANSFER_SIZE 42 // [(MEM_BUFFER_SIZE/(BURST)]
70 
73 #define DATALOG_DEFAULTS { \
74  {NULL, \
75  NULL, \
76  NULL, \
77  NULL}, \
78  true, \
79  false, \
80  0, \
81  DATA_LOG_BUFF_SIZE \
82  }
83 
84 // **************************************************************************
85 // the typedefs
86 
89 typedef struct _DATALOG_OBJ_
90 {
92 
95  uint16_t cntr;
96  uint16_t size;
97 } DATALOG_Obj;
98 
101 typedef struct _DATALOG_Obj_ *DATALOG_Handle;
102 
103 // **************************************************************************
104 // the globals
109 
112 extern DATALOG_Obj datalog;
114 
115 // **************************************************************************
116 // the globals
117 
118 // **************************************************************************
119 // the function prototypes
120 
123 extern DATALOG_Handle DATALOG_init(void *pMemory, const size_t numBytes);
124 
127 static inline void DATALOG_update(DATALOG_Handle handle)
128 {
129  DATALOG_Obj *obj = (DATALOG_Obj *)handle;
130 
131  if(obj->flag_enableLogData == true)
132  {
133  if(obj->cntr >= obj->size)
134  {
135  obj->cntr = 0;
136 
137  if(obj->flag_enableLogOneShot == true)
138  {
139  obj->flag_enableLogData = false;
140  obj->flag_enableLogOneShot = false;
141  }
142  }
143 
144  datalogBuff1[obj->cntr] = (*obj->iptr[0]);
145  datalogBuff2[obj->cntr] = (*obj->iptr[1]);
146  datalogBuff3[obj->cntr] = (*obj->iptr[2]);
147  datalogBuff4[obj->cntr] = (*obj->iptr[3]);
148 
149  obj->cntr++;
150  }
151  else if(obj->flag_enableLogOneShot == true)
152  {
153  obj->flag_enableLogData = true;
154  obj->cntr = 0;
155  }
156 }
157 
160 static inline void DATALOG_updateWithDMA(DATALOG_Handle handle)
161 {
162  DATALOG_Obj *obj = (DATALOG_Obj *)handle;
163 
164  uint16_t number = obj->size - 1;
165 
166  datalogBuff1[number] = (*obj->iptr[0]);
167  datalogBuff2[number] = (*obj->iptr[1]);
168  datalogBuff3[number] = (*obj->iptr[2]);
169  datalogBuff4[number] = (*obj->iptr[3]);
170 }
171 
172 #ifdef __cplusplus
173 }
174 #endif // extern "C"
175 
177 #endif // end of DATALOG_H definition
178 
datalog
DATALOG_Obj datalog
Defines the DATALOG object.
DATALOG_Obj
struct _DATALOG_OBJ_ DATALOG_Obj
Defines the data logging (DATALOG) object.
DATALOG_init
DATALOG_Handle DATALOG_init(void *pMemory, const size_t numBytes)
Initializes the data logger.
float32_t
float float32_t
Definition: sfra_f32.h:42
_DATALOG_OBJ_::iptr
float32_t * iptr[4]
Input: First input pointer.
Definition: datalog.h:91
DATA_LOG_BUFF_NUM
#define DATA_LOG_BUFF_NUM
Definition: datalog.h:62
DATALOG_Handle
struct _DATALOG_Obj_ * DATALOG_Handle
Defines the DATALOG handle.
Definition: datalog.h:101
_DATALOG_OBJ_::size
uint16_t size
Parameter: Maximum data buffer.
Definition: datalog.h:96
datalogBuff2
float32_t datalogBuff2[400+2]
math.h
DATA_LOG_BUFF_SIZE
#define DATA_LOG_BUFF_SIZE
Definition: datalog.h:64
_DATALOG_OBJ_
Defines the data logging (DATALOG) object.
Definition: datalog.h:89
_DATALOG_OBJ_::flag_enableLogOneShot
bool flag_enableLogOneShot
Parameter: Maximum data buffer.
Definition: datalog.h:94
datalogBuff1
float32_t datalogBuff1[400+2]
_DATALOG_OBJ_::cntr
uint16_t cntr
Variable: Data log counter.
Definition: datalog.h:95
_DATALOG_OBJ_::flag_enableLogData
bool flag_enableLogData
Parameter: Maximum data buffer.
Definition: datalog.h:93
datalogHandle
DATALOG_Handle datalogHandle
datalogBuff3
float32_t datalogBuff3[400+2]
datalogBuff4
float32_t datalogBuff4[400+2]
DATALOG_updateWithDMA
static void DATALOG_updateWithDMA(DATALOG_Handle handle)
Updates the data logger.
Definition: datalog.h:160
DATALOG_update
static void DATALOG_update(DATALOG_Handle handle)
Updates the data logger.
Definition: datalog.h:127

Copyright 2023, Texas Instruments Incorporated