CC26xx Driver Library
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
vims.c
Go to the documentation of this file.
1 /******************************************************************************
2 * Filename: vims.c
3 * Revised: 2015-01-13 16:59:55 +0100 (ti, 13 jan 2015)
4 * Revision: 42365
5 *
6 * Description: Driver for the VIMS.
7 *
8 * Copyright (c) 2015, Texas Instruments Incorporated
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions are met:
13 *
14 * 1) Redistributions of source code must retain the above copyright notice,
15 * this list of conditions and the following disclaimer.
16 *
17 * 2) Redistributions in binary form must reproduce the above copyright notice,
18 * this list of conditions and the following disclaimer in the documentation
19 * and/or other materials provided with the distribution.
20 *
21 * 3) Neither the name of the ORGANIZATION nor the names of its contributors may
22 * be used to endorse or promote products derived from this software without
23 * specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
29 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
36 *
37 ******************************************************************************/
38 
39 #include <driverlib/vims.h>
40 
41 //*****************************************************************************
42 //
43 // Handle support for DriverLib in ROM:
44 // This section will undo prototype renaming made in the header file
45 //
46 //*****************************************************************************
47 #ifndef DRIVERLIB_GENERATE_ROM
48  #undef VIMSConfigure
49  #define VIMSConfigure NOROM_VIMSConfigure
50  #undef VIMSModeSet
51  #define VIMSModeSet NOROM_VIMSModeSet
52  #undef VIMSModeGet
53  #define VIMSModeGet NOROM_VIMSModeGet
54  #undef VIMSModeSetBlocking
55  #define VIMSModeSetBlocking NOROM_VIMSModeSetBlocking
56 #endif
57 
58 //*****************************************************************************
59 //
61 //
62 //*****************************************************************************
63 void
64 VIMSConfigure(uint32_t ui32Base, bool bRoundRobin, bool bPrefetch)
65 {
66  uint32_t ui32Reg;
67 
68  //
69  // Check the arguments.
70  //
71  ASSERT(VIMSBaseValid(ui32Base));
72 
73  ui32Reg = HWREG(ui32Base + VIMS_O_CTL);
74  ui32Reg &= ~(VIMS_CTL_PREF_EN | VIMS_CTL_ARB_CFG);
75  if(bRoundRobin)
76  {
77  ui32Reg |= VIMS_CTL_ARB_CFG;
78  }
79  if(bPrefetch)
80  {
81  ui32Reg |= VIMS_CTL_PREF_EN;
82  }
83 
84  //
85  // Set the Arbitration and prefetch mode.
86  //
87  HWREG(ui32Base + VIMS_O_CTL) = ui32Reg;
88 }
89 
90 //*****************************************************************************
91 //
93 //
94 //*****************************************************************************
95 void
96 VIMSModeSet(uint32_t ui32Base, uint32_t ui32Mode)
97 {
98  uint32_t ui32Reg;
99 
100  //
101  // Check the arguments.
102  //
103  ASSERT(VIMSBaseValid(ui32Base));
104 
105  ASSERT((ui32Mode == VIMS_MODE_INVALIDATE) ||
106  (ui32Mode == VIMS_MODE_DISABLED) ||
107  (ui32Mode == VIMS_MODE_ENABLED) ||
108  (ui32Mode == VIMS_MODE_OFF) ||
109  (ui32Mode == VIMS_MODE_SPLIT));
110 
111  //
112  // Set the mode.
113  //
114  ui32Reg = HWREG(ui32Base + VIMS_O_CTL);
115  ui32Reg &= ~VIMS_CTL_MODE_M;
116  ui32Reg |= (ui32Mode & VIMS_CTL_MODE_M);
117 
118  HWREG(ui32Base + VIMS_O_CTL) = ui32Reg;
119 }
120 
121 //*****************************************************************************
122 //
124 //
125 //*****************************************************************************
126 uint32_t
127 VIMSModeGet(uint32_t ui32Base)
128 {
129  uint32_t ui32Reg;
130 
131  //
132  // Check the arguments.
133  //
134  ASSERT(VIMSBaseValid(ui32Base));
135 
136  ui32Reg = HWREG(ui32Base + VIMS_O_STAT);
137  if(ui32Reg & VIMS_STAT_INV)
138  {
139  return (VIMS_MODE_INVALIDATE);
140  }
141  else
142  {
143  return (ui32Reg & VIMS_STAT_MODE_M);
144  }
145 }
146 
147 //*****************************************************************************
148 //
149 // Safe setting of new VIMS mode
150 // - Function is blocking
151 // - Can be called for any mode change (also if actually not changing mode)
152 // Note: The shift operators (VIMS_CTL_MODE_S and VIMS_STAT_MODE_S) is not
153 // used bacause we know that they both are = 0.
154 //
155 //*****************************************************************************
156 void
157 VIMSModeSetBlocking( uint32_t ui32Mode )
158 {
159  //
160  // Make sure that only the mode bits are set (just for sequirity)
161  //
162  ui32Mode &= VIMS_CTL_MODE_M;
163 
164  //
165  // Wait for any pending change to complete
166  //
167  while ( HWREGBITW( VIMS_BASE + VIMS_O_STAT, VIMS_STAT_MODE_CHANGING_BITN )) {
168  // Do nothing - wait for change to complete.
169  }
170 
171  //
172  // Request mode change
173  //
174  HWREG( VIMS_BASE + VIMS_O_CTL ) =
175  ( HWREG( VIMS_BASE + VIMS_O_CTL ) & ~VIMS_CTL_MODE_M ) | ui32Mode;
176 
177  //
178  // Wait for mode change to complete
179  //
180  while (( HWREG( VIMS_BASE + VIMS_O_STAT ) & VIMS_STAT_MODE_M ) != ui32Mode ) {
181  // Do nothing - wait for new mode to be entered
182  }
183 }
void VIMSModeSet(uint32_t ui32Base, uint32_t ui32Mode)
Set the operational mode of the VIMS.
Definition: vims.c:96
#define VIMS_MODE_INVALIDATE
Definition: vims.h:95
#define ASSERT(expr)
Definition: debug.h:65
#define VIMS_MODE_ENABLED
Definition: vims.h:99
uint32_t VIMSModeGet(uint32_t ui32Base)
Get the current operational mode of the VIMS.
Definition: vims.c:127
#define VIMS_MODE_SPLIT
Definition: vims.h:100
#define VIMS_MODE_DISABLED
Definition: vims.h:98
#define VIMS_MODE_OFF
Definition: vims.h:102
void VIMSModeSetBlocking(uint32_t ui32Mode)
Set the operational mode of the VIMS in a safe sequence (blocking).
Definition: vims.c:157
void VIMSConfigure(uint32_t ui32Base, bool bRoundRobin, bool bPrefetch)
Configures the VIMS.
Definition: vims.c:64