1 //###########################################################################
2 //
3 // FILE:	F2837xD_PieCtrl.c
4 //
5 // TITLE:	F2837xD Device PIE Control Register Initialization Functions.
6 //
7 //###########################################################################
8 // $TI Release: F2837xD Support Library v3.05.00.00 $
9 // $Release Date: Tue Jun 26 03:15:23 CDT 2018 $
10 // $Copyright:
11 // Copyright (C) 2013-2018 Texas Instruments Incorporated - http://www.ti.com/
12 //
13 // Redistribution and use in source and binary forms, with or without
14 // modification, are permitted provided that the following conditions
15 // are met:
16 //
17 //   Redistributions of source code must retain the above copyright
18 //   notice, this list of conditions and the following disclaimer.
19 //
20 //   Redistributions in binary form must reproduce the above copyright
21 //   notice, this list of conditions and the following disclaimer in the
22 //   documentation and/or other materials provided with the
23 //   distribution.
24 //
25 //   Neither the name of Texas Instruments Incorporated nor the names of
26 //   its contributors may be used to endorse or promote products derived
27 //   from this software without specific prior written permission.
28 //
29 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 // $
41 //###########################################################################
42 
43 //
44 // Included Files
45 //
46 #include "F2837xD_device.h"     // F2837xD Headerfile Include File
47 #include "F2837xD_Examples.h"   // F2837xD Examples Include File
48 
49 //
50 // InitPieCtrl - This function initializes the PIE control registers to a
51 //               known state.
52 //
InitPieCtrl(void)53 void InitPieCtrl(void)
54 {
55     //
56     // Disable Interrupts at the CPU level:
57     //
58     DINT;
59 
60     //
61     // Disable the PIE
62     //
63     PieCtrlRegs.PIECTRL.bit.ENPIE = 0;
64 
65 	//
66     // Clear all PIEIER registers:
67     //
68 	PieCtrlRegs.PIEIER1.all = 0;
69 	PieCtrlRegs.PIEIER2.all = 0;
70 	PieCtrlRegs.PIEIER3.all = 0;
71 	PieCtrlRegs.PIEIER4.all = 0;
72 	PieCtrlRegs.PIEIER5.all = 0;
73 	PieCtrlRegs.PIEIER6.all = 0;
74 	PieCtrlRegs.PIEIER7.all = 0;
75 	PieCtrlRegs.PIEIER8.all = 0;
76 	PieCtrlRegs.PIEIER9.all = 0;
77 	PieCtrlRegs.PIEIER10.all = 0;
78 	PieCtrlRegs.PIEIER11.all = 0;
79 	PieCtrlRegs.PIEIER12.all = 0;
80 
81 	//
82     // Clear all PIEIFR registers:
83     //
84 	PieCtrlRegs.PIEIFR1.all = 0;
85 	PieCtrlRegs.PIEIFR2.all = 0;
86 	PieCtrlRegs.PIEIFR3.all = 0;
87 	PieCtrlRegs.PIEIFR4.all = 0;
88 	PieCtrlRegs.PIEIFR5.all = 0;
89 	PieCtrlRegs.PIEIFR6.all = 0;
90 	PieCtrlRegs.PIEIFR7.all = 0;
91 	PieCtrlRegs.PIEIFR8.all = 0;
92 	PieCtrlRegs.PIEIFR9.all = 0;
93 	PieCtrlRegs.PIEIFR10.all = 0;
94 	PieCtrlRegs.PIEIFR11.all = 0;
95 	PieCtrlRegs.PIEIFR12.all = 0;
96 }
97 
98 //
99 // EnableInterrupts - This function enables the PIE module and CPU __interrupts
100 //
EnableInterrupts()101 void EnableInterrupts()
102 {
103     //
104     // Enable the PIE
105     //
106     PieCtrlRegs.PIECTRL.bit.ENPIE = 1;
107 
108 	//
109     // Enables PIE to drive a pulse into the CPU
110     //
111 	PieCtrlRegs.PIEACK.all = 0xFFFF;
112 
113 	//
114     // Enable Interrupts at the CPU level
115     //
116     EINT;
117 }
118 
119 //
120 // End of file
121 //
122