EPC9143 300 W 16th Brick DC/DC Module Reference Design
p33c_dsp.h
1 /*LICENSE *****************************************************************************************
2  *
3  * Software License Agreement
4  *
5  * Copyright (R) 2012 Microchip Technology Inc. All rights reserved. Microchip licenses to you the
6  * right to use, modify, copy and distribute Software only when embedded on a Microchip
7  * microcontroller or digital signal controller, which is integrated into your product or third
8  * party product (pursuant to the sublicense terms in the accompanying license agreement).
9  *
10  * You should refer to the license agreement accompanying this Software for additional information
11  * regarding your rights and obligations.
12  *
13  * SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR
14  * IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE, NON-INFRINGEMENT
15  * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR
16  * OBLIGATED UNDER CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
17  * OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES INCLUDING BUT NOT
18  * LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR CONSEQUENTIAL DAMAGES, LOST PROFITS
19  * OR LOST DATA, COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY
20  * THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
21  *
22  * ***********************************************************************************************/
23 
24 #ifndef P33C_DSP_SFR_ABSTRACTION_H
25 #define P33C_DSP_SFR_ABSTRACTION_H
26 
27 /*@@p33c_dac.h
28  * ************************************************************************************************
29  * Summary:
30  * Generic Digital Signal Processor Driver Module (header file)
31  *
32  * Description:
33  * This additional header file contains defines for all required bit-settings of all related
34  * special function registers of a peripheral module and/or instance.
35  * This file is an additional header file on top of the generic device header file.
36  *
37  * See Also:
38  * p33c_dsp.c
39  * ***********************************************************************************************/
40 
41 // CORCON: CORE CONTROL REGISTER
42 
43 #define REG_CORCON_UNUSED_MSK 0b0100000000000000
44 #define REG_CORCON_VALID_DATA_WRITE_MSK 0b1011100011110011
45 #define REG_CORCON_VALID_DATA_READ_MSK 0b1011111111111111
46 
47 #define REG_CORCON_VAR_VARIABLE 0b1000000000000000
48 #define REG_CORCON_VAR_FIXED 0b0000000000000000
49 
50 typedef enum {
51  CORCON_VAR_VARIABLE = 0b1, // Variable exception processing is enabled
52  CORCON_VAR_FIXED = 0b0 // Fixed exception processing is enabled
53 } CORCON_VAR_e; // Variable Exception Processing Latency Control bit
54 
55 #define REG_CORCON_US_MIXED 0b0010000000000000 // DSP engine multiplies are mixed sign
56 #define REG_CORCON_US_UNSIGNED 0b0001000000000000 // DSP engine multiplies are unsigned
57 #define REG_CORCON_US_SIGNED 0b0000000000000000 // DSP engine multiplies are signed
58 
59 typedef enum {
60  CORCON_US_MIXED = 0b10, // DSP engine multiplies are mixed sign
61  CORCON_US_UNSIGNED = 0b01, // DSP engine multiplies are unsigned
62  CORCON_US_SIGNED = 0b00 // DSP engine multiplies are signed
63 } CORCON_US_e; // DSP Multiply Unsigned/Signed Control bits
64 
65 #define REG_CORCON_EDT_TERMINATE 0b0000100000000000
66 #define REG_CORCON_EDT_RUN 0b0000000000000000
67 
68 typedef enum {
69  CORCON_EDT_TERMINATE = 0b1, // Terminates executing DO loop at the end of the current loop iteration
70  CORCON_EDT_RUN = 0b0 // No effect
71 } CORCON_EDT_e; // Early DO Loop Termination Control bit
72 
73 #define REG_CORCON_DL_7 0b0000011100000000 // Seven DO loops are active
74 #define REG_CORCON_DL_6 0b0000011100000000 // Six DO loops are active
75 #define REG_CORCON_DL_5 0b0000011100000000 // Five DO loops are active
76 #define REG_CORCON_DL_4 0b0000011100000000 // Four DO loops are active
77 #define REG_CORCON_DL_3 0b0000011100000000 // Three DO loops are active
78 #define REG_CORCON_DL_2 0b0000011100000000 // Two DO loops are active
79 #define REG_CORCON_DL_1 0b0000011100000000 // One DO loops are active
80 #define REG_CORCON_DL_0 0b0000011100000000 // Zero DO loops are active
81 
82 typedef enum {
83  CORCON_DL_7 = 0b111, // Seven DO loops are active
84  CORCON_DL_6 = 0b110, // Six DO loops are active
85  CORCON_DL_5 = 0b101, // Five DO loops are active
86  CORCON_DL_4 = 0b100, // Four DO loops are active
87  CORCON_DL_3 = 0b011, // Three DO loops are active
88  CORCON_DL_2 = 0b010, // Two DO loops are active
89  CORCON_DL_1 = 0b001, // One DO loops are active
90  CORCON_DL_0 = 0b000 // Zero DO loops are active
91 } CORCON_DL_STAT_e; // DO Loop Nesting Level Status bits
92 
93 #define REG_CORCON_SATA_ON 0b0000000010000000 // Accumulator A saturation is enabled
94 #define REG_CORCON_SATA_OFF 0b0000000000000000 // Accumulator A saturation is disabled
95 
96 typedef enum {
97  CORCON_SATA_ON = 0b1, // Accumulator A saturation is enabled
98  CORCON_SATA_OFF = 0b0 // Accumulator A saturation is disabled
99 } CORCON_SATA_e; // ACCA Saturation Enable bit
100 
101 #define REG_CORCON_SATB_ON 0b0000000001000000 // Accumulator B saturation is enabled
102 #define REG_CORCON_SATB_OFF 0b0000000000000000 // Accumulator B saturation is disabled
103 
104 typedef enum {
105  CORCON_SATB_ON = 0b1, // Accumulator B saturation is enabled
106  CORCON_SATB_OFF = 0b0 // Accumulator B saturation is disabled
107 } CORCON_SATB_e; // ACCB Saturation Enable bit
108 
109 #define REG_CORCON_SATDW_ON 0b0000000000100000 // Data Space write saturation is enabled
110 #define REG_CORCON_SATDW_OFF 0b0000000000000000 // Data Space write saturation is disabled
111 
112 typedef enum {
113  CORCON_SATDW_ON = 0b1, // Data Space write saturation is enabled
114  CORCON_SATDW_OFF = 0b0 // Data Space write saturation is disabled
115 } CORCON_SATDW_e; // Data Space Write from DSP Engine Saturation Enable bit
116 
117 #define REG_CORCON_ACCSAT_931 0b0000000000010000 // 9.31 saturation (super saturation)
118 #define REG_CORCON_ACCSAT_131 0b0000000000000000 // 1.31 saturation (normal saturation)
119 
120 typedef enum {
121  CORCON_ACCSAT_931 = 0b1, // 9.31 saturation (super saturation)
122  CORCON_ACCSAT_131 = 0b0 // 1.31 saturation (normal saturation)
123 } CORCON_ACCSAT_e; // Accumulator Saturation Mode Select bit
124 
125 #define REG_CORCON_IPL3_STAT_GT7 0b0000000000001000
126 #define REG_CORCON_IPL3_STAT_LT7 0b0000000000000000
127 
128 typedef enum {
129  CORCON_IPL3_STAT_GT7 = 0b1, // CPU Interrupt Priority Level is greater than 7
130  CORCON_IPL3_STAT_LT7 = 0b0 // CPU Interrupt Priority Level is 7 or less
131 } CORCON_IPL3_STAT_e; // CPU Interrupt Priority Level Status bit 3
132 
133 #define REG_CORCON_SFA_ACTIVE 0b0000000000000100 // Stack frame is active; W14 and W15 address 0x0000 to 0xFFFF, regardless of DSRPAG
134 #define REG_CORCON_SFA_INACTIVE 0b0000000000000000 // Stack frame is not active; W14 and W15 address the base Data Space
135 
136 typedef enum {
137  CORCON_SFA_ACTIVE = 0b1, // Stack frame is active; W14 and W15 address 0x0000 to 0xFFFF, regardless of DSRPAG
138  CORCON_SFA_INACTIVE = 0b0 // Stack frame is not active; W14 and W15 address the base Data Space
139 } CORCON_SFA_e; // Stack Frame Active Status bit
140 
141 #define REG_CORCON_RND_BIASED 0b0000000000000010 // Biased (conventional) rounding is enabled
142 #define REG_CORCON_RND_UNBIASED 0b0000000000000000 // Unbiased (convergent) rounding is enabled
143 
144 typedef enum {
145  CORCON_RND_BIASED = 0b1, // Biased (conventional) rounding is enabled
146  CORCON_RND_UNBIASED = 0b0 // Unbiased (convergent) rounding is enabled
147 } CORCON_RND_e; // Rounding Mode Select bit
148 
149 #define REG_CORCON_IF_INTEGER 0b0000000000000001 // Integer mode is enabled for DSP multiply
150 #define REG_CORCON_IF_FRACTIONAL 0b0000000000000000 // Fractional mode is enabled for DSP multiply
151 
152 typedef enum {
153  CORCON_IF_INTEGER = 0b1, // Integer mode is enabled for DSP multiply
154  CORCON_IF_FRACTIONAL = 0b0 // Fractional mode is enabled for DSP multiply
155 } CORCON_IF_e; // Integer or Fractional Multiplier Mode Select bit
156 
157 typedef struct DSP_CONFIG_s
158 {
159  union {
160  struct {
161  volatile CORCON_IF_e IF : 1; // Integer or Fractional Multiplier Mode Select bit
162  volatile CORCON_RND_e RND : 1; // Rounding Mode Select bit
163  volatile CORCON_SFA_e SFA : 1; // Stack Frame Active Status bit
164  volatile CORCON_IPL3_STAT_e IPL3 : 1; // CPU Interrupt Priority Level Status bit 3
165  volatile CORCON_ACCSAT_e ACCSAT : 1; // Accumulator Saturation Mode Select bit
166  volatile CORCON_SATDW_e SATDW : 1; // Data Space Write from DSP Engine Saturation Enable bit
167  volatile CORCON_SATB_e SATB : 1; // ACCB Saturation Enable bit
168  volatile CORCON_SATA_e SATA : 1; // ACCA Saturation Enable bit
169 
170  volatile CORCON_DL_STAT_e DL : 3; // DO Loop Nesting Level Status bits
171  volatile CORCON_EDT_e EDT : 1; // Early DO Loop Termination Control bit
172  volatile CORCON_US_e US : 2; // DSP Multiply Unsigned/Signed Control bits
173  volatile unsigned : 1; // reserved
174  volatile CORCON_VAR_e VAR : 1; // Variable Exception Processing Latency Control bit
175  } __attribute__((packed)) bits; // CORCON: CORE CONTROL REGISTER
176 
177  volatile uint16_t value;
178  };
179 
180 } DSP_CONFIG_t; // CORCON: CORE CONTROL REGISTER
181 
182 
183 /* PROTOTYPES */
184 extern volatile uint16_t Dsp_SetConfig(volatile struct DSP_CONFIG_s dsp_cfg);
185 extern volatile struct DSP_CONFIG_s Dsp_GetConfig(void);
186 
187 #endif /* end of P33C_DSP_SFR_ABSTRACTION_H */
188 // END OF FILE
DSP_CONFIG_s::DL
volatile CORCON_DL_STAT_e DL
Definition: p33c_dsp.h:170
DSP_CONFIG_s::SFA
volatile CORCON_SFA_e SFA
Definition: p33c_dsp.h:163
DSP_CONFIG_s
Definition: p33c_dsp.h:158
DSP_CONFIG_s::value
volatile uint16_t value
Definition: p33c_dsp.h:177
DSP_CONFIG_s::US
volatile CORCON_US_e US
Definition: p33c_dsp.h:172
DSP_CONFIG_s::IPL3
volatile CORCON_IPL3_STAT_e IPL3
Definition: p33c_dsp.h:164
DSP_CONFIG_s::SATA
volatile CORCON_SATA_e SATA
Definition: p33c_dsp.h:168
DSP_CONFIG_s::unsigned
volatile unsigned
Definition: p33c_dsp.h:173
DSP_CONFIG_s::VAR
volatile CORCON_VAR_e VAR
Definition: p33c_dsp.h:174
DSP_CONFIG_s::EDT
volatile CORCON_EDT_e EDT
Definition: p33c_dsp.h:171
Dsp_GetConfig
volatile struct DSP_CONFIG_s Dsp_GetConfig(void)
Reads the DSP engine configuration.
Definition: p33c_dsp.c:78
DSP_CONFIG_s::SATDW
volatile CORCON_SATDW_e SATDW
Definition: p33c_dsp.h:166
DSP_CONFIG_s::ACCSAT
volatile CORCON_ACCSAT_e ACCSAT
Definition: p33c_dsp.h:165
Dsp_SetConfig
volatile uint16_t Dsp_SetConfig(volatile struct DSP_CONFIG_s dsp_cfg)
Initializes the DSP engine in accordance to user settings.
Definition: p33c_dsp.c:53
DSP_CONFIG_s::RND
volatile CORCON_RND_e RND
Definition: p33c_dsp.h:162
DSP_CONFIG_s::IF
volatile CORCON_IF_e IF
Definition: p33c_dsp.h:161
DSP_CONFIG_s::SATB
volatile CORCON_SATB_e SATB
Definition: p33c_dsp.h:167