MotorWare f2806x Driver API Documentation

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

comp.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 #include "sw/drivers/comp/src/32b/f28x/f2806x/comp.h"
42
43
44 // assembly file
45 extern void usDelay(uint32_t Count);
46
47
48 // **************************************************************************
49 // the defines
50
51
52 // **************************************************************************
53 // the globals
54
55
56 // **************************************************************************
57 // the functions
58
59
60 void COMP_disable(COMP_Handle compHandle)
61 {
62 COMP_Obj *comp = (COMP_Obj *)compHandle;
63
64 ENABLE_PROTECTED_REGISTER_WRITE_MODE;
65
66 // clear the bits
67 comp->COMPCTL &= ~COMP_COMPCTL_COMPDACE_BITS;
68
69 DISABLE_PROTECTED_REGISTER_WRITE_MODE;
70
71 return;
72 } // end of COMP_disable() function
73
74
75 void COMP_disableDac(COMP_Handle compHandle)
76 {
77 COMP_Obj *comp = (COMP_Obj *)compHandle;
78
79 ENABLE_PROTECTED_REGISTER_WRITE_MODE;
80
81 // set the bits
82 comp->COMPCTL |= COMP_COMPCTL_COMPSOURCE_BITS;
83
84 DISABLE_PROTECTED_REGISTER_WRITE_MODE;
85
86 return;
87 } // end of COMP_disableDac() function
88
89
90 void COMP_enable(COMP_Handle compHandle)
91 {
92 COMP_Obj *comp = (COMP_Obj *)compHandle;
93
94 ENABLE_PROTECTED_REGISTER_WRITE_MODE;
95
96 // set the bits
97 comp->COMPCTL |= COMP_COMPCTL_COMPDACE_BITS;
98
99 DISABLE_PROTECTED_REGISTER_WRITE_MODE;
100
101 return;
102 } // end of COMP_enable() function
103
104
105 void COMP_enableDac(COMP_Handle compHandle)
106 {
107 COMP_Obj *comp = (COMP_Obj *)compHandle;
108
109 ENABLE_PROTECTED_REGISTER_WRITE_MODE;
110
111 // set the bits
112 comp->COMPCTL &= ~COMP_COMPCTL_COMPSOURCE_BITS;
113
114 DISABLE_PROTECTED_REGISTER_WRITE_MODE;
115
116 return;
117 } // end of COMP_enableDac() function
118
119
120 COMP_Handle COMP_init(void *pMemory, const size_t numBytes)
121 {
122 COMP_Handle compHandle;
123
124 if(numBytes < sizeof(COMP_Obj))
125 return((COMP_Handle)NULL);
126
127 // assign the handle
128 compHandle = (COMP_Handle)pMemory;
129
130 return(compHandle);
131 } // end of COMP_init() function
132
133
134
135
136
137
138
139 // end of file
DISABLE_PROTECTED_REGISTER_WRITE_MODE
#define DISABLE_PROTECTED_REGISTER_WRITE_MODE
Define to disable protected register writes.
Definition: cpu.h:101
COMP_disable
void COMP_disable(COMP_Handle compHandle)
Disables the comparator (COMP)
Definition: comp.c:60
COMP_disableDac
void COMP_disableDac(COMP_Handle compHandle)
Disables the DAC.
Definition: comp.c:75
COMP_COMPCTL_COMPDACE_BITS
#define COMP_COMPCTL_COMPDACE_BITS
Defines the location of the COMPDACE bits in the COMPCTL register.
Definition: comp.h:80
comp.h
Contains public interface to various functions related to the comparator (COMP) object.
COMP_enableDac
void COMP_enableDac(COMP_Handle compHandle)
Enables the DAC.
Definition: comp.c:105
ENABLE_PROTECTED_REGISTER_WRITE_MODE
#define ENABLE_PROTECTED_REGISTER_WRITE_MODE
Define to allow protected register writes.
Definition: cpu.h:93
COMP_enable
void COMP_enable(COMP_Handle compHandle)
Enables the comparator (COMP)
Definition: comp.c:90
COMP_COMPCTL_COMPSOURCE_BITS
#define COMP_COMPCTL_COMPSOURCE_BITS
Defines the location of the COMPSOURCE bits in the COMPCTL register.
Definition: comp.h:84
usDelay
void usDelay(uint32_t Count)
_COMP_Obj_
Defines the comparator (COMP) object.
Definition: comp.h:173
_COMP_Obj_::COMPCTL
volatile uint16_t COMPCTL
COMP Control Register.
Definition: comp.h:175
COMP_Handle
struct _COMP_Obj_ * COMP_Handle
Defines the comparator (COMP) handle.
Definition: comp.h:197
COMP_init
COMP_Handle COMP_init(void *pMemory, const size_t numBytes)
Initializes the comparator (COMP) object handle.
Definition: comp.c:120