1 /*
2  * arch.h
3  *
4  * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
5  *
6  *
7  *  Redistribution and use in source and binary forms, with or without
8  *  modification, are permitted provided that the following conditions
9  *  are met:
10  *
11  *    Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  *
14  *    Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the
17  *    distribution.
18  *
19  *    Neither the name of Texas Instruments Incorporated nor the names of
20  *    its contributors may be used to endorse or promote products derived
21  *    from this software without specific prior written permission.
22  *
23  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26  *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27  *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28  *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29  *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30  *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31  *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32  *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33  *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34  */
35 
36 //! \ingroup MODULHIL
37 //! \file arch.h
38 //! \brief
39 //!
40 #include "msp430.h"
41 #define uController_uif
42 
43 #ifndef _UIFV1_ARCH_H_
44 #define _UIFV1_ARCH_H_
45 
46 enum {JTAG = 0, SPYBIWIRE = 1, SPYBIWIREJTAG = 2, JTAGUNDEF = 4, SPYBIWIRE_SUBMCU = 5, SPYBIWIRE_MSP_FET=6, JTAG_432 = 7, SWD_432 = 8};
47 
48 
49 typedef enum {
50     NO_SUPPLY = 0x04,
51     ET_OFF = 0x05,
52     ET_ON = 0x06,
53     LDO_OFF = 0x07,
54     ALL_OFF = 0x8,
55     LDO_ON = 0x09
56 } vccSupply_t;
57 
58 #define RSTHIGH 0
59 #define RSTLOW  1
60 
61 #define Invalid_Manufactor_IdCode 0x000000FEul
62 #define Mask_Manufactor_IdCode 0x000000FEul
63 
64 #define  ExtLimit        1700            // a level higher than this means external voltage available
65 
66 #define  R27            250.0f           // 250kOhm
67 #define  R28            250.0f           // 250kOhm
68 #define  R29            500.0f           // 500kOhm
69 #define  R30            500.0f           // 500kOhm
70 #define  R31            250.0f           // 250kOhm
71 #define  R32            150.0f           // 150kOhm
72 #define  A_VREFPLUS     2.5f         // conversion reference voltage Vref+=2.5V,
73 
74 #define DCDC_STATUS     (P3IN & (BIT0+BIT1)) // Status bits from the DCDC Sub MCU
75 
76 // Calculate ExtVcc based on Vref+=2.5V, R27=250kOhm, R28=250kOhm
77 // Calculate Vcc    based on Vref+=2.5V, R29=500kOhm, R30=500kOhm
78 
79 #define  A_VBUS          0 /* ADC12 Input Channel Select Bit 0 */
80 #define  A_VCCOUT        1 /* ADC12 Input Channel Select Bit 1 */
81 #define  A_VCCTARGET     2 /* ADC12 Input Channel Select Bit 2 */
82 
83 static const float ADC_CONV_RANGE = 4096;
84 static const unsigned short ADC_AVERAGE = 1000;
85 
86 struct jtag
87 {
88   unsigned char  TCK;
89   unsigned char  TMS;
90   unsigned char  TDI;
91   unsigned char  TDO;
92   unsigned char* In;
93   unsigned char* Out;
94   unsigned char RST;
95   unsigned char TST;
96   unsigned char* DIRECTION;
97 };
98 
99 static const struct jtag _Jtag_SubMcu =
100 {
101   0,  // TCK, P4.4 (out) (high)
102   0,  // TMS, P4.5 (out) (high)
103   0,  // TDI, P4.6 (out) (high)
104   0,  // TDO, P4.7 (in)
105   (unsigned char*)&P6IN,  // JTAG input Register
106   (unsigned char*)&P6OUT, // JTAG output Register
107   (unsigned char)BIT6,   // BIT6.6 RST
108   (unsigned char)BIT7,   // BIT6.7 TST
109   (unsigned char*)&P6DIR // JTAG direction Register
110 };
111 
112 //CONST_AT( struct jtag _Jtag, HAL_ADDR_CONST_JTAG) = {
113 static const struct jtag _Jtag_Target =
114 {
115   (unsigned char)BIT4,  // TCK, P4.4 (out) (high)
116   (unsigned char)BIT5,  // TMS, P4.5 (out) (high)
117   (unsigned char)BIT6,  // TDI, P4.6 (out) (high)
118   (unsigned char)BIT7,  // TDO, P4.7 (in)
119   (unsigned char*)&P4IN,
120   (unsigned char*)&P4OUT,
121   (unsigned char)BIT2, //RST
122   (unsigned char)BIT3, //TST
123   (unsigned char*)&P4DIR
124 };
125 
126 #define VALID_DATA   0x1A
127 #define SYNC_ONGOING 0x2A
128 #define INVALID_DATA 0x3A
129 #define JTAG_LOCKED  0x4A
130 #define SYNC_BROKEN  0x5A
131 
132 #define BP_HIT_MASK_J              0x0400000000000000ull
133 #define LPMX5_MASK_J               0x4000000000000000ull
134 #define LPM4_1MASK_J               0x8000000000000000ull
135 #define LPM4_2MASK_J               0x8300000000000000ull
136 #define EIGHT_JSTATE_BITS          0x100000000000000ull
137 
138 #define JSTATE_FLOW_CONTROL_BITS   0xC7
139 
140 #define JSTATE_BP_HIT              0x4
141 #define JSTATE_SYNC_ONGOING        0x83
142 #define JSTATE_LOCKED_STATE        0x40
143 #define JSTATE_INVALID_STATE       0x81
144 #define JSTATE_LPM_ONE_TWO         0x82
145 #define JSTATE_LPM_THREE_FOUR      0x80
146 #define JSTATE_VALID_CAPTURE       0x03
147 #define JSTATE_LPM_X_FIVE          0xC0
148 
149 
150 #define JSTATE_SYNC_BROKEN_MASK         0xC3
151 #define JSTATE_SYNC_BROKEN_PGACT        0x02
152 #define JSTATE_SYNC_BROKEN_MCLK         0x01
153 #define JSTATE_SYNC_BROKEN_MCLK_PGACT   0x00
154 
155 
156 #define FET_TRUE                   0x1
157 #define FET_FALSE                  0x0
158 
159 #define L092_MODE 0xA55AA55A
160 #define C092_MODE 0x5AA55AA5
161 
162 #endif
163 
164 
165