AM263x Motor Control SDK  09.02.00
dcl_css.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2024 Texas Instruments Incorporated - https://www.ti.com/
3  *
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the
15  * distribution.
16  *
17  * * Neither the name of Texas Instruments Incorporated nor the names of
18  * its contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 #ifndef _DCL_CSS_H_
35 #define _DCL_CSS_H_
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
49 //--- Controller Common Support Structure ------------------------------------
50 
57 typedef struct dcl_css {
60  volatile uint32_t sts;
61  uint32_t err_line;
62  uint32_t err;
63  const char* err_func;
64 } DCL_CSS;
65 
68 #define DCL_CSS_DEFAULTS { 0.0f, DCL_DEFAULT_PERIOD_S, 0U, 0U, 0U, NULL }
69 
72 typedef struct dcl_css64 {
75  volatile uint32_t sts;
76  uint32_t err_line;
77  uint32_t err;
78  const char* err_func;
79 } DCL_CSSF64;
80 
83 #define DCL_CSSF64_DEFAULTS { 0.0L, DCL_DEFAULT_PERIODF64_S, 0U, 0U, 0U, NULL }
84 
92 #define DCL_setControllerPeriod(p,t_sec) ((p)->css->T = t_sec)
93 
94 //--- Status word ------------------------------------------------------------
95 
106 typedef enum dcl_status_bits
107 {
109  DCL_STS_PARAM_UPDATE = (1U << 0),
110  DCL_STS_CTRL_RUNNING = (1U << 1),
112 
115 #define DCL_setUpdateStatus(p) ((p)->css->sts |= DCL_STS_PARAM_UPDATE)
116 #define DCL_clearUpdateStatus(p) ((p)->css->sts &= ~DCL_STS_PARAM_UPDATE)
117 
122 #define DCL_getUpdateStatus(p) (0U != ((p)->css->sts & DCL_STS_PARAM_UPDATE))
123 
129 #define DCL_setControllerStatus(p) ((p)->css->sts |= DCL_STS_CTRL_RUNNING)
130 #define DCL_clearControllerStatus(p) ((p)->css->sts &= ~DCL_STS_CTRL_RUNNING)
131 
136 #define DCL_getControllerStatus(p) (0U != ((p)->css->sts & DCL_STS_CTRL_RUNNING))
137 
140 #ifdef __cplusplus
141 }
142 #endif // extern "C"
143 
144 #endif // _DCL_CSS_H_
DCL_STS_CTRL_RUNNING
@ DCL_STS_CTRL_RUNNING
Controller operation-in-progress flag, high if operation is in progress.
Definition: dcl_css.h:110
DCL_status_bits
DCL_status_bits
Defines the library enumerated status bits.
Definition: dcl_css.h:107
DCL_CSSF64::tpt
float64_t tpt
Test point.
Definition: dcl_css.h:73
DCL_CSS::tpt
float32_t tpt
Test point.
Definition: dcl_css.h:58
DCL_CSS::sts
volatile uint32_t sts
Status word.
Definition: dcl_css.h:60
DCL_CSS::err
uint32_t err
Error status code.
Definition: dcl_css.h:62
DCL_CSSF64::T
float64_t T
Controller period in seconds.
Definition: dcl_css.h:74
DCL_CSSF64::err_line
uint32_t err_line
Error location line (errno)
Definition: dcl_css.h:76
DCL_CSS::err_line
uint32_t err_line
Error location line (errno)
Definition: dcl_css.h:61
DCL_STS_PARAM_UPDATE
@ DCL_STS_PARAM_UPDATE
Parameter update-in-progress flag, high if ongoing parameter update.
Definition: dcl_css.h:109
DCL_CSSF64::err_func
const char * err_func
Error function name.
Definition: dcl_css.h:78
DCL_STS_NONE
@ DCL_STS_NONE
Status empty.
Definition: dcl_css.h:108
DCL_CSS::T
float32_t T
Controller period in seconds.
Definition: dcl_css.h:59
DCL_CSSF64
Defines the 64bit CSS structure.
Definition: dcl_css.h:72
DCL_CSSF64::sts
volatile uint32_t sts
Status word.
Definition: dcl_css.h:75
DCL_CSS
Defines the controller common support structure.
Definition: dcl_css.h:57
float64_t
double float64_t
Definition: dcl_common.h:59
DCL_CSSF64::err
uint32_t err
Error status code.
Definition: dcl_css.h:77
float32_t
float float32_t
Definition: dcl_common.h:58
DCL_CSS::err_func
const char * err_func
Error function name.
Definition: dcl_css.h:63