| Digital Power Starter Kit 3 Firmware dsPIC33C Boost Converter Voltage Mode Control Example |

p33c_crc.h
1 /* Microchip Technology Inc. and its subsidiaries. You may use this software
2 * and any derivatives exclusively with Microchip products.
3 *
4 * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
5 * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED
6 * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A
7 * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION
8 * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION.
9 *
10 * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
11 * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
12 * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS
13 * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE
14 * FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS
15 * IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF
16 * ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
17 *
18 * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE
19 * TERMS.
20 */
21
22 /**************************************************************************************************
23 * @file p33c_crc.h
24 * @see p33c_crc.c
25 * @brief Generic Cyclic Redundancy Check (header file)
26 * @details
27 * This additional header file contains defines for all required bit-settings of all related
28 * special function registers of a peripheral module and/or instance.
29 * This file is an additional header file on top of the generic device header file.
30 *
31 *************************************************************************************************/
32
33 // This is a guard condition so that contents of this file are not included
34 // more than once.
35 #ifndef P33C_CRC_SFR_ABSTRACTION_H
36 #define P33C_CRC_SFR_ABSTRACTION_H
37
38 // Include standard header files
39 #include <xc.h> // include processor files - each processor file is guarded.
40 #include <stdint.h> // include standard integer data types
41 #include <stdbool.h> // include standard boolean data types
42 #include <stddef.h> // include standard definition data types
43
44 #include "p33c_macros.h" // include inline assembly macro extensions header file
45
46 // GENERIC CRC MODULE SPECIAL FUNCTION REGISTER SET
47 #ifndef P33C_CRC_MODULE_s
48
49 /***********************************************************************************
50 * @ingroup lib-layer-pral-properties-public-crc
51 * @struct P33C_CRC_MODULE_s
52 * @brief Abstracted set of Special Function Registers of the Cyclic Redundancy Check module
53 * @details
54 * This structure defines an abstracted set of Special Function Registers of
55 * Cyclic Redundancy Check peripheral module base registers. Users can use this
56 * abstracted set of registers to capture register settings from or write
57 * generic register settings to these peripheral base registers.
58 *
59 **********************************************************************************/
60
61 struct P33C_CRC_MODULE_s {
62 union {
63 volatile struct tagCRCCONLBITS bits; // Register bit-field
64 volatile uint16_t value; // 16-bit wide register value
65 } CrcConl; // CRCCON1: CRC Control Register 1
66 union {
67 volatile struct tagCRCCONHBITS bits; // Register bit-field
68 volatile uint16_t value; // 16-bit wide register value
69 } CrcConh; // CRCCON2: CRC Control Register 2
70 union {
71 struct {
72 uint16_t CRCXORL : 16; // Register bit-field
73 } bits; // Register bit-field
74 uint16_t value; // 16-bit wide register value
75 } CrcXorl; // CRCXORL: CRC XOR Low Register
76 union {
77 struct {
78 uint16_t CRCXORH : 16; // Register bit-field
79 } bits; // Register bit-field
80 uint16_t value; // 16-bit wide register value
81 } CrcXorh; // CRCXORH: CRC XOR High Register
82 union {
83 struct {
84 uint16_t CRCDATL : 16; // Register bit-field
85 } bits; // Register bit-field
86 uint16_t value; // 16-bit wide register value
87 } CrcDatl; // CRCDATL: CRC Data Low Register
88 union {
89 struct {
90 uint16_t CRCDATH : 16; // Register bit-field
91 } bits; // Register bit-field
92 uint16_t value; // 16-bit wide register value
93 } CrcDath; // CRCDATH: CRC Data High Register
94 union {
95 struct {
96 uint16_t CRCWDATL : 16; // Register bit-field
97 } bits; // Register bit-field
98 uint16_t value; // 16-bit wide register value
99 } CrcWdatl; // CRCWDATL: CRC Shift Low Register
100 union {
101 struct {
102 uint16_t CRCWDATH : 16; // Register bit-field
103 } bits; // Register bit-field
104 uint16_t value; // 16-bit wide register value
105 } CrcWdath; // CRCWDATL: CRC Shift High Register
106 } __attribute__((packed));
107 typedef struct P33C_CRC_MODULE_s P33C_CRC_MODULE_t; // DMA MODULE REGISTER SET
108
109 //#define CRC16_PVIZ_POLYNOMIAL ((uint16_t)0x8005) // Standard Polynomial
110 #define CRC16_PVIZ_REV_POLYNOMIAL ((uint16_t)0xA001) // Standard Polynomial 0x8005
111 #define CRC16_PVIZ_SEED_VALUE ((uint16_t)0x0000) // non-direct of 0x0000
112
113 //#define CRC16_CCITT_POLYNOMIAL ((uint16_t)0x1021) // Standard Polynomial
114 #define CRC16_CCITT_REV_POLYNOMIAL ((uint16_t)0x8408) // Standard Polynomial
115 #define CRC16_CCITT_SEED_VALUE ((uint16_t)0x0000) // non-direct of 0x0000
116
117 enum CRC_POLYNOMIAL_e {
118 CRC8_STANDARD_POLYNOMIAL = 0xD5,
119 CRC8_AUTOSAR_POLYNOMIAL = 0x2F,
120 CRC8_BLUETOOTH_POLYNOMIAL = 0xA7,
121 CRC8_CCITT_POLYNOMIAL = 0x07,
122 CRC8_DALLAS_POLYNOMIAL = 0x31,
123 CRC8_DARC_POLYNOMIAL = 0x39,
124 CRC8_GSMB_POLYNOMIAL = 0x49,
125 CRC8_SAEJ1850_POLYNOMIAL = 0x1D,
126 CRC8_WCDMA_POLYNOMIAL = 0x9B,
127 CRC16_PVIZ_POLYNOMIAL = 0x8005,
128 CRC16_CHAKRAVARTY_POLYNOMIAL = 0x2F15,
129 CRC16_ARINC_POLYNOMIAL = 0xA02B,
130 CRC16_CCITT_POLYNOMIAL = 0x1021,
131 CRC16_CDMA_POLYNOMIAL = 0xC867,
132 CRC16_DECT_POLYNOMIAL = 0x0589,
133 CRC16_DIF_POLYNOMIAL = 0x8BB7,
134 CRC16_DNP_POLYNOMIAL = 0x3D65,
135 CRC16_IBM_POLYNOMIAL = 0x8005,
136 CRC16_OPENSAFETY_A_POLYNOMIAL = 0x5935,
137 CRC16_OPENSAFETY_B_POLYNOMIAL = 0x755B,
138 CRC16_PROFIBUS_POLYNOMIAL = 0x1DCF
139 };
140 typedef enum CRC_POLYNOMIAL_e CRC_POLYNOMIAL_t;
141
142 /*********************************************************************************
143 * @fn volatile struct P33C_CRC_MODULE_s* p33c_CrcModule_GetHandle(void)
144 * @ingroup lib-layer-pral-functions-public-crc
145 * @brief Gets pointer to CRC Module SFR set
146 * @param void
147 * @return struct P33C_CRC_MODULE_s Pointer to CRC module special function register set object
148 *
149 * @details
150 * This function returns the pointer to a CRC module register set in
151 * Special Function Register memory space. This pointer can be used to
152 * directly write to/read from the Special Function Registers of the
153 * CRC peripheral module configuration.
154 *********************************************************************************/
155 #define p33c_CrcModule_GetHandle() (struct P33C_CRC_MODULE_s*)&CRCCONL
156
157 #endif // end of P33C_CRC_MODULE_s
158
159
160 /* ********************************************************************************************* *
161 * API FUNCTION PROTOTYPES
162 * ********************************************************************************************* */
163
164 extern volatile uint16_t p33c_CrcModule_Dispose(void);
165 extern volatile struct P33C_CRC_MODULE_s p33c_CrcModule_ConfigRead(void);
166 extern volatile uint16_t p33c_CrcModule_ConfigWrite(
167 volatile struct P33C_CRC_MODULE_s crcModuleConfig);
168 extern volatile uint16_t p33c_CrcModule_Initialize(void);
169 extern volatile uint16_t p33c_CrcModule_Get_Data8_CRC16(
170 volatile uint8_t *data, volatile uint8_t start, volatile uint8_t size);
171 extern volatile uint16_t p33c_CrcModule_Polynomial_Config(volatile uint8_t lendian, volatile uint8_t data_width,
172 volatile uint8_t poly_size, volatile enum CRC_POLYNOMIAL_e poly, volatile uint16_t seed);
173
174 /* ********************************************************************************************* *
175 * DMA MODULE CONFIGURATION TEMPLATES
176 * ********************************************************************************************* */
177 extern volatile struct P33C_CRC_MODULE_s crcModuleConfigClear;
178 extern volatile struct P33C_CRC_MODULE_s crcModuleConfigPviz;
179
180 #endif /* P33C_CRC_SFR_ABSTRACTION_H */
181
182 // end of file
P33C_CRC_MODULE_s::bits
volatile struct tagCRCCONLBITS bits
Definition: p33c_crc.h:63
P33C_CRC_MODULE_s::CrcDatl
union P33C_CRC_MODULE_s::@48 CrcDatl
P33C_CRC_MODULE_s::CRCXORH
uint16_t CRCXORH
Definition: p33c_crc.h:78
P33C_CRC_MODULE_s::value
uint16_t value
Definition: p33c_crc.h:74
P33C_CRC_MODULE_s::CRCDATH
uint16_t CRCDATH
Definition: p33c_crc.h:90
P33C_CRC_MODULE_s::CrcConl
union P33C_CRC_MODULE_s::@44 CrcConl
P33C_CRC_MODULE_s::CrcWdatl
union P33C_CRC_MODULE_s::@50 CrcWdatl
P33C_CRC_MODULE_s::CRCDATL
uint16_t CRCDATL
Definition: p33c_crc.h:84
P33C_CRC_MODULE_s::CRCXORL
uint16_t CRCXORL
Definition: p33c_crc.h:72
P33C_CRC_MODULE_s::CRCWDATH
uint16_t CRCWDATH
Definition: p33c_crc.h:102
P33C_CRC_MODULE_s::CrcWdath
union P33C_CRC_MODULE_s::@51 CrcWdath
P33C_CRC_MODULE_s::CrcXorl
union P33C_CRC_MODULE_s::@46 CrcXorl
P33C_CRC_MODULE_s::CrcDath
union P33C_CRC_MODULE_s::@49 CrcDath
P33C_CRC_MODULE_s::value
volatile uint16_t value
Definition: p33c_crc.h:64
P33C_CRC_MODULE_s::CRCWDATL
uint16_t CRCWDATL
Definition: p33c_crc.h:96
P33C_CRC_MODULE_s
Definition: p33c_crc.h:61
P33C_CRC_MODULE_s::CrcXorh
union P33C_CRC_MODULE_s::@47 CrcXorh
P33C_CRC_MODULE_s::CrcConh
union P33C_CRC_MODULE_s::@45 CrcConh