Digital Power Starter Kit 3 Firmware
dsPIC33C Buck Converter Voltage Mode Control Example
p33c_gpio.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 
32 /* Revision history:
33  * 12/10/20 1.0 initial release
34  *************************************************************************************************/
35 
36 // This is a guard condition so that contents of this file are not included
37 // more than once.
38 #ifndef P33C_GPIO_SFR_ABSTRACTION_H
39 #define P33C_GPIO_SFR_ABSTRACTION_H
40 
41 // Include standard header files
42 #include <xc.h> // include processor files - each processor file is guarded.
43 #include <stdint.h> // include standard integer data types
44 #include <stdbool.h> // include standard boolean data types
45 #include <stddef.h> // include standard definition data types
46 
47 // GENERIC GPIO INSTANCE SPECIAL FUNCTION REGISTER SET
48 // DO NOT REORDER ELEMENTS AS THEY MAP ONTO DEVICE REGISTER MEMORY !!!
49 #ifndef P33C_GPIO_INSTANCE_s
50 
52  union {
53  volatile struct tagLATABITS bits; // Register bit-field
54  volatile uint16_t value; // 16-bit wide register value
55  }ANSELx; // ANSELx: ANALOG SELECT FOR PORTx REGISTER
56  union {
57  volatile struct tagLATABITS bits; // Register bit-field
58  volatile uint16_t value; // 16-bit wide register value
59  }TRISx; // TRISx: OUTPUT ENABLE FOR PORTx REGISTER
60  union {
61  volatile struct tagLATABITS bits; // Register bit-field
62  volatile uint16_t value; // 16-bit wide register value
63  }PORTx; // PORTx: INPUT DATA FOR PORTx REGISTER
64  union {
65  volatile struct tagLATABITS bits; // Register bit-field
66  volatile uint16_t value; // 16-bit wide register value
67  }LATx; // LATx: OUTPUT DATA FOR PORTx REGISTER
68  union {
69  volatile struct tagLATABITS bits; // Register bit-field
70  volatile uint16_t value; // 16-bit wide register value
71  }ODCx; // ODCx: OPEN-DRAIN ENABLE FOR PORTx REGISTER
72  union {
73  volatile struct tagLATABITS bits; // Register bit-field
74  volatile uint16_t value; // 16-bit wide register value
75  }CNPUx; // CNPUx: CHANGE NOTIFICATION PULL-UP ENABLE FOR PORTx REGISTER
76  union {
77  volatile struct tagLATABITS bits; // Register bit-field
78  volatile uint16_t value; // 16-bit wide register value
79  }CNPDx; // CNPDx: CHANGE NOTIFICATION PULL-DOWN ENABLE FOR PORTx REGISTER
80  union {
81  volatile struct tagLATABITS bits; // Register bit-field
82  volatile uint16_t value; // 16-bit wide register value
83  }CNCONx; // CNCONx: CHANGE NOTIFICATION CONTROL FOR PORTx REGISTER
84  union {
85  volatile struct tagLATABITS bits; // Register bit-field
86  volatile uint16_t value; // 16-bit wide register value
87  }CNEN0x; // CNEN0x: CHANGE NOTIFICATION INTERRUPT ENABLE FOR PORTx REGISTER
88  union {
89  volatile struct tagLATABITS bits; // Register bit-field
90  volatile uint16_t value; // 16-bit wide register value
91  }CNSTATx; // CNSTATx: CHANGE NOTIFICATION STATUS FOR PORTx REGISTER
92  union {
93  volatile struct tagLATABITS bits; // Register bit-field
94  volatile uint16_t value; // 16-bit wide register value
95  }CNEN1x; // CNEN1x: CHANGE NOTIFICATION EDGE SELECT FOR PORTx REGISTER
96  union {
97  volatile struct tagLATABITS bits; // Register bit-field
98  volatile uint16_t value; // 16-bit wide register value
99  }CNFx; // CNFx: CHANGE NOTIFICATION INTERRUPT FLAG FOR PORTx REGISTER
100  } __attribute__((packed)); // GPIO REGISTER SET
102 
103  #define P33C_GPIO_SFR_OFFSET ((volatile uint16_t)&ANSELB - (volatile uint16_t)&ANSELA)
104 
105 #endif
106 
107 /* ********************************************************************************************* *
108  * API FUNCTION PROTOTYPES
109  * ********************************************************************************************* */
110 
111 extern volatile struct P33C_GPIO_INSTANCE_s* p33c_GpioInstance_GetHandle(
112  volatile uint16_t gpio_Instance
113  );
114 
115 extern volatile uint16_t p33c_GpioInstance_Dispose(
116  volatile uint16_t gpioInstance
117  );
118 
120  volatile uint16_t gpioInstance
121  );
122 
123 extern volatile uint16_t p33c_GpioInstance_ConfigWrite(
124  volatile uint16_t gpioInstance,
125  volatile struct P33C_GPIO_INSTANCE_s gpioConfig
126  );
127 
128 /* ********************************************************************************************* *
129  * GPIO INSTANCE CONFIGURATION TEMPLATES
130  * ********************************************************************************************* */
131 extern volatile struct P33C_GPIO_INSTANCE_s gpioConfigClear;
132 
133 #endif /* P33C_GPIO_SFR_ABSTRACTION_H */
134 
P33C_GPIO_INSTANCE_s::bits
volatile struct tagLATABITS bits
Definition: p33c_gpio.h:53
P33C_GPIO_INSTANCE_s::CNPDx
union P33C_GPIO_INSTANCE_s::@6 CNPDx
P33C_GPIO_INSTANCE_s::CNFx
union P33C_GPIO_INSTANCE_s::@11 CNFx
P33C_GPIO_INSTANCE_s::ANSELx
union P33C_GPIO_INSTANCE_s::@0 ANSELx
P33C_GPIO_INSTANCE_s::LATx
union P33C_GPIO_INSTANCE_s::@3 LATx
p33c_GpioInstance_Dispose
volatile uint16_t p33c_GpioInstance_Dispose(volatile uint16_t gpioInstance)
Resets all GPIO Instance registers to their RESET default values.
Definition: p33c_gpio.c:77
P33C_GPIO_INSTANCE_s::CNSTATx
union P33C_GPIO_INSTANCE_s::@9 CNSTATx
P33C_GPIO_INSTANCE_s::value
volatile uint16_t value
Definition: p33c_gpio.h:54
p33c_GpioInstance_ConfigWrite
volatile uint16_t p33c_GpioInstance_ConfigWrite(volatile uint16_t gpioInstance, volatile struct P33C_GPIO_INSTANCE_s gpioConfig)
Writes a user-defined configuration to the GPIO instance registers.
Definition: p33c_gpio.c:133
p33c_GpioInstance_GetHandle
volatile struct P33C_GPIO_INSTANCE_s * p33c_GpioInstance_GetHandle(volatile uint16_t gpio_Instance)
Gets pointer to GPIO Instance SFR set.
Definition: p33c_gpio.c:45
gpioConfigClear
volatile struct P33C_GPIO_INSTANCE_s gpioConfigClear
Default RESET configuration of one GPIO instance SFRs.
Definition: p33c_gpio.c:169
P33C_GPIO_INSTANCE_s::TRISx
union P33C_GPIO_INSTANCE_s::@1 TRISx
P33C_GPIO_INSTANCE_s
Definition: p33c_gpio.h:51
P33C_GPIO_INSTANCE_s::CNCONx
union P33C_GPIO_INSTANCE_s::@7 CNCONx
P33C_GPIO_INSTANCE_s::CNPUx
union P33C_GPIO_INSTANCE_s::@5 CNPUx
P33C_GPIO_INSTANCE_s::PORTx
union P33C_GPIO_INSTANCE_s::@2 PORTx
P33C_GPIO_INSTANCE_s::CNEN1x
union P33C_GPIO_INSTANCE_s::@10 CNEN1x
P33C_GPIO_INSTANCE_s::CNEN0x
union P33C_GPIO_INSTANCE_s::@8 CNEN0x
P33C_GPIO_INSTANCE_s::ODCx
union P33C_GPIO_INSTANCE_s::@4 ODCx
p33c_GpioInstance_ConfigRead
volatile struct P33C_GPIO_INSTANCE_s p33c_GpioInstance_ConfigRead(volatile uint16_t gpioInstance)
Read the current configuration from the GPIO instance registers
Definition: p33c_gpio.c:102