MotorWare f2806x Driver API Documentation
cpu.c
Go to the documentation of this file.
1 /* --COPYRIGHT--,BSD
2  * Copyright (c) 2015, Texas Instruments Incorporated
3  * All rights reserved.
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 distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  * --/COPYRIGHT--*/
37 
38 
39 // **************************************************************************
40 // the includes
41 
43 
44 
45 // **************************************************************************
46 // the defines
47 
48 
49 // **************************************************************************
50 // the globals
51 
53 
54 
55 // **************************************************************************
56 // the functions
57 
59 {
60 
61  // clear the bits
62  IFR = 0;
63 
64  return;
65 } // end of CPU_clearIntFlags() function
66 
67 
69 {
70 
71  // set the bit
72  asm(" setc DBGM");
73 
74  return;
75 } // end of CPU_disableDebug() function
76 
77 
79 {
80 
81  // set the bit
82  asm(" setc INTM");
83 
84  return;
85 } // end of CPU_disableGlobalInts() function
86 
87 
88 void CPU_disableInt(CPU_Handle cpuHandle,const CPU_IntNumber_e intNumber)
89 {
90 
91  // clear the bit
92  IER &= (~intNumber);
93 
94  return;
95 } // end of CPU_disableInt() function
96 
97 
98 void CPU_disableInts(CPU_Handle cpuHandle)
99 {
100 
101  // clear the bits
102  IER = 0;
103 
104  return;
105 } // end of CPU_disableInts() function
106 
107 
109 {
110 
111  // clear the bits
112  asm(" EDIS");
113 
114  return;
115 } // end fo CPU_disableProtectedRegisterWrite() function
116 
117 
119 {
120 
121  // clear the bit
122  asm(" clrc DBGM");
123 
124  return;
125 } // end of CPU_enableDebugInt() function
126 
127 
129 {
130 
131  // clear the bit
132  asm(" clrc INTM");
133 
134  return;
135 } // end of CPU_enableGlobalInts() function
136 
137 
138 void CPU_enableInt(CPU_Handle cpuHandle,const CPU_IntNumber_e intNumber)
139 {
140 
141  // set the interrupt
142  IER |= intNumber;
143 
144  return;
145 } // end of CPU_enableInt() function
146 
147 
149 {
150 
151  // set the bits
152  asm(" EALLOW");
153 
154  return;
155 } // end fo CPU_enableProtectedRegisterWrite() function
156 
157 
158 CPU_Handle CPU_init(void *pMemory,const size_t numBytes)
159 {
160  CPU_Handle cpuHandle;
161 
162 
163  if(numBytes < sizeof(CPU_Obj))
164  return((CPU_Handle)NULL);
165 
166  // assign the handle
167  cpuHandle = (CPU_Handle)pMemory;
168 
169  return(cpuHandle);
170 } // end of CPU_init() function
171 
172 
173 // end of file
void CPU_clearIntFlags(CPU_Handle cpuHandle)
Clears all interrupt flags.
Definition: cpu.c:58
void CPU_enableGlobalInts(CPU_Handle cpuHandle)
Enables global interrupts.
Definition: cpu.c:128
Defines the central processing unit (CPU) object.
Definition: cpu.h:435
CPU_Handle CPU_init(void *pMemory, const size_t numBytes)
Initializes the central processing unit (CPU) object handle.
Definition: cpu.c:158
void CPU_disableProtectedRegisterWrite(CPU_Handle cpuHandle)
Disables protected register writes.
Definition: cpu.c:108
CPU_Obj cpu
Defines the CPU object.
Definition: cpu.c:52
void CPU_enableDebugInt(CPU_Handle cpuHandle)
Enables the debug interrupt.
Definition: cpu.c:118
CPU_IntNumber_e
Enumeration to define the interrupt numbers.
Definition: cpu.h:414
void CPU_disableInt(CPU_Handle cpuHandle, const CPU_IntNumber_e intNumber)
Disables a specified interrupt number.
Definition: cpu.c:88
cregister volatile unsigned int IER
External reference to the interrupt enable register (IER) register.
cregister volatile unsigned int IFR
External reference to the interrupt flag register (IFR) register.
void CPU_disableGlobalInts(CPU_Handle cpuHandle)
Disables global interrupts.
Definition: cpu.c:78
struct _CPU_Obj_ * CPU_Handle
Defines the central processing unit (CPU) handle.
Definition: cpu.h:443
Contains public interface to various functions related to the central processing unit (CPU) object...
void CPU_enableInt(CPU_Handle cpuHandle, const CPU_IntNumber_e intNumber)
Enables a specified interrupt number.
Definition: cpu.c:138
void CPU_enableProtectedRegisterWrite(CPU_Handle cpuHandle)
Enables protected register writes.
Definition: cpu.c:148
void CPU_disableInts(CPU_Handle cpuHandle)
Disables all interrupts.
Definition: cpu.c:98
void CPU_disableDebugInt(CPU_Handle cpuHandle)
Disables the debug interrupt.
Definition: cpu.c:68