Rev 1661 Rev 1691
1 /******************************************************************** 1 /********************************************************************
2 FileName: HardwareProfile - PICDEM FSUSB.h 2 FileName: HardwareProfile - PICDEM FSUSB.h
3 Dependencies: See INCLUDES section 3 Dependencies: See INCLUDES section
4 Processor: PIC18 USB Microcontrollers 4 Processor: PIC18 USB Microcontrollers
5 Hardware: PICDEM FSUSB 5 Hardware: PICDEM FSUSB
6 Compiler: Microchip C18 6 Compiler: Microchip C18
7 Company: Microchip Technology, Inc. 7 Company: Microchip Technology, Inc.
8   8  
9 Software License Agreement: 9 Software License Agreement:
10   10  
11 The software supplied herewith by Microchip Technology Incorporated 11 The software supplied herewith by Microchip Technology Incorporated
12 (the “Company”) for its PIC® Microcontroller is intended and 12 (the “Company”) for its PIC® Microcontroller is intended and
13 supplied to you, the Company’s customer, for use solely and 13 supplied to you, the Company’s customer, for use solely and
14 exclusively on Microchip PIC Microcontroller products. The 14 exclusively on Microchip PIC Microcontroller products. The
15 software is owned by the Company and/or its supplier, and is 15 software is owned by the Company and/or its supplier, and is
16 protected under applicable copyright laws. All rights are reserved. 16 protected under applicable copyright laws. All rights are reserved.
17 Any use in violation of the foregoing restrictions may subject the 17 Any use in violation of the foregoing restrictions may subject the
18 user to criminal sanctions under applicable laws, as well as to 18 user to criminal sanctions under applicable laws, as well as to
19 civil liability for the breach of the terms and conditions of this 19 civil liability for the breach of the terms and conditions of this
20 license. 20 license.
21   21  
22 THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES, 22 THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES,
23 WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED 23 WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
24 TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 24 TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
25 PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, 25 PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
26 IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR 26 IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
27 CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. 27 CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
28   28  
29 ******************************************************************** 29 ********************************************************************
30 File Description: 30 File Description:
31   31  
32 Change History: 32 Change History:
33 Rev Date Description 33 Rev Date Description
34 1.0 11/19/2004 Initial release 34 1.0 11/19/2004 Initial release
35 2.1 02/26/2007 Updated for simplicity and to use common 35 2.1 02/26/2007 Updated for simplicity and to use common
36 coding style 36 coding style
37 2.3 09/15/2008 Broke out each hardware platform into its own 37 2.3 09/15/2008 Broke out each hardware platform into its own
38 "HardwareProfile - xxx.h" file 38 "HardwareProfile - xxx.h" file
39 ********************************************************************/ 39 ********************************************************************/
40   40  
41 #ifndef HARDWARE_PROFILE_PICDEM_FSUSB_H 41 #ifndef HARDWARE_PROFILE_PICDEM_FSUSB_H
42 #define HARDWARE_PROFILE_PICDEM_FSUSB_H 42 #define HARDWARE_PROFILE_PICDEM_FSUSB_H
43   43  
44 /*******************************************************************/ 44 /*******************************************************************/
45 /******** USB stack hardware selection options *********************/ 45 /******** USB stack hardware selection options *********************/
46 /*******************************************************************/ 46 /*******************************************************************/
47 //This section is the set of definitions required by the MCHPFSUSB 47 //This section is the set of definitions required by the MCHPFSUSB
48 // framework. These definitions tell the firmware what mode it is 48 // framework. These definitions tell the firmware what mode it is
49 // running in, and where it can find the results to some information 49 // running in, and where it can find the results to some information
50 // that the stack needs. 50 // that the stack needs.
51 //These definitions are required by every application developed with 51 //These definitions are required by every application developed with
52 // this revision of the MCHPFSUSB framework. Please review each 52 // this revision of the MCHPFSUSB framework. Please review each
53 // option carefully and determine which options are desired/required 53 // option carefully and determine which options are desired/required
54 // for your application. 54 // for your application.
55   55  
56 //The PICDEM FS USB Demo Board platform supports the USE_SELF_POWER_SENSE_IO 56 //The PICDEM FS USB Demo Board platform supports the USE_SELF_POWER_SENSE_IO
57 //and USE_USB_BUS_SENSE_IO features. Uncomment the below line(s) if 57 //and USE_USB_BUS_SENSE_IO features. Uncomment the below line(s) if
58 //it is desireable to use one or both of the features. 58 //it is desireable to use one or both of the features.
59 //#define USE_SELF_POWER_SENSE_IO 59 //#define USE_SELF_POWER_SENSE_IO
60 #define tris_self_power TRISAbits.TRISA2 // Input 60 #define tris_self_power TRISAbits.TRISA2 // Input
61 #if defined(USE_SELF_POWER_SENSE_IO) 61 #if defined(USE_SELF_POWER_SENSE_IO)
62 #define self_power PORTAbits.RA2 62 #define self_power PORTAbits.RA2
63 #else 63 #else
64 #define self_power 1 64 #define self_power 1
65 #endif 65 #endif
66   66  
67 //#define USE_USB_BUS_SENSE_IO 67 //#define USE_USB_BUS_SENSE_IO
68 #define tris_usb_bus_sense TRISAbits.TRISA1 // Input 68 #define tris_usb_bus_sense TRISAbits.TRISA1 // Input
69 #if defined(USE_USB_BUS_SENSE_IO) 69 #if defined(USE_USB_BUS_SENSE_IO)
70 #define USB_BUS_SENSE PORTAbits.RA1 70 #define USB_BUS_SENSE PORTAbits.RA1
71 #else 71 #else
72 #define USB_BUS_SENSE 1 72 #define USB_BUS_SENSE 1
73 #endif 73 #endif
74   74  
75 //Uncomment the following line to make the output HEX of this 75 //Uncomment the following line to make the output HEX of this
76 // project work with the MCHPUSB Bootloader 76 // project work with the MCHPUSB Bootloader
77 //#define PROGRAMMABLE_WITH_USB_MCHPUSB_BOOTLOADER 77 #define PROGRAMMABLE_WITH_USB_MCHPUSB_BOOTLOADER
78 78
79 //Uncomment the following line to make the output HEX of this 79 //Uncomment the following line to make the output HEX of this
80 // project work with the HID Bootloader 80 // project work with the HID Bootloader
81 #define PROGRAMMABLE_WITH_USB_HID_BOOTLOADER 81 //#define PROGRAMMABLE_WITH_USB_HID_BOOTLOADER
82   82  
83 /*******************************************************************/ 83 /*******************************************************************/
84 /******** MDD File System selection options ************************/ 84 /******** MDD File System selection options ************************/
85 /*******************************************************************/ 85 /*******************************************************************/
86 #define USE_PIC18 86 #define USE_PIC18
87   87  
88 #define ERASE_BLOCK_SIZE 64 88 #define ERASE_BLOCK_SIZE 64
89 #define WRITE_BLOCK_SIZE 32 89 #define WRITE_BLOCK_SIZE 32
90   90  
91 /*******************************************************************/ 91 /*******************************************************************/
92 /*******************************************************************/ 92 /*******************************************************************/
93 /*******************************************************************/ 93 /*******************************************************************/
94 /******** Application specific definitions *************************/ 94 /******** Application specific definitions *************************/
95 /*******************************************************************/ 95 /*******************************************************************/
96 /*******************************************************************/ 96 /*******************************************************************/
97 /*******************************************************************/ 97 /*******************************************************************/
98   98  
99 /** Board definition ***********************************************/ 99 /** Board definition ***********************************************/
100 //These defintions will tell the main() function which board is 100 //These defintions will tell the main() function which board is
101 // currently selected. This will allow the application to add 101 // currently selected. This will allow the application to add
102 // the correct configuration bits as wells use the correct 102 // the correct configuration bits as wells use the correct
103 // initialization functions for the board. These defitions are only 103 // initialization functions for the board. These defitions are only
104 // required in the stack provided demos. They are not required in 104 // required in the stack provided demos. They are not required in
105 // final application design. 105 // final application design.
106 #define DEMO_BOARD PICDEM_FS_USB 106 #define DEMO_BOARD PICDEM_FS_USB
107 #define PICDEM_FS_USB 107 #define PICDEM_FS_USB
108 #define CLOCK_FREQ 48000000 108 #define CLOCK_FREQ 48000000
109   109  
110 /** LED ************************************************************/ 110 /** LED ************************************************************/
111 #define mInitAllLEDs() LATD &= 0xF0; TRISD &= 0xF0; 111 #define mInitAllLEDs() LATD &= 0xF0; TRISD &= 0xF0;
112 112
113 #define mLED_1 LATDbits.LATD0 113 #define mLED_1 LATDbits.LATD0
114 #define mLED_2 LATDbits.LATD1 114 #define mLED_2 LATDbits.LATD1
115 #define mLED_3 LATDbits.LATD2 115 #define mLED_3 LATDbits.LATD2
116 #define mLED_4 LATDbits.LATD3 116 #define mLED_4 LATDbits.LATD3
117 117
118 #define mGetLED_1() mLED_1 118 #define mGetLED_1() mLED_1
119 #define mGetLED_2() mLED_2 119 #define mGetLED_2() mLED_2
120 #define mGetLED_3() mLED_3 120 #define mGetLED_3() mLED_3
121 #define mGetLED_4() mLED_4 121 #define mGetLED_4() mLED_4
122   122  
123 #define mLED_1_On() mLED_1 = 1; 123 #define mLED_1_On() mLED_1 = 1;
124 #define mLED_2_On() mLED_2 = 1; 124 #define mLED_2_On() mLED_2 = 1;
125 #define mLED_3_On() mLED_3 = 1; 125 #define mLED_3_On() mLED_3 = 1;
126 #define mLED_4_On() mLED_4 = 1; 126 #define mLED_4_On() mLED_4 = 1;
127 127
128 #define mLED_1_Off() mLED_1 = 0; 128 #define mLED_1_Off() mLED_1 = 0;
129 #define mLED_2_Off() mLED_2 = 0; 129 #define mLED_2_Off() mLED_2 = 0;
130 #define mLED_3_Off() mLED_3 = 0; 130 #define mLED_3_Off() mLED_3 = 0;
131 #define mLED_4_Off() mLED_4 = 0; 131 #define mLED_4_Off() mLED_4 = 0;
132 132
133 #define mLED_1_Toggle() mLED_1 = !mLED_1; 133 #define mLED_1_Toggle() mLED_1 = !mLED_1;
134 #define mLED_2_Toggle() mLED_2 = !mLED_2; 134 #define mLED_2_Toggle() mLED_2 = !mLED_2;
135 #define mLED_3_Toggle() mLED_3 = !mLED_3; 135 #define mLED_3_Toggle() mLED_3 = !mLED_3;
136 #define mLED_4_Toggle() mLED_4 = !mLED_4; 136 #define mLED_4_Toggle() mLED_4 = !mLED_4;
137 137
138 /** SWITCH *********************************************************/ 138 /** SWITCH *********************************************************/
139 #define mInitAllSwitches() TRISBbits.TRISB4=1;TRISBbits.TRISB5=1; 139 #define mInitAllSwitches() TRISBbits.TRISB4=1;TRISBbits.TRISB5=1;
140 #define mInitSwitch2() TRISBbits.TRISB4=1; 140 #define mInitSwitch2() TRISBbits.TRISB4=1;
141 #define mInitSwitch3() TRISBbits.TRISB5=1; 141 #define mInitSwitch3() TRISBbits.TRISB5=1;
142 #define sw2 PORTBbits.RB4 142 #define sw2 PORTBbits.RB4
143 #define sw3 PORTBbits.RB5 143 #define sw3 PORTBbits.RB5
144 144
145 /** POT ************************************************************/ 145 /** POT ************************************************************/
146 #define mInitPOT() {TRISAbits.TRISA0=1;ADCON0=0x01;ADCON2=0x3C;ADCON2bits.ADFM = 1;} 146 #define mInitPOT() {TRISAbits.TRISA0=1;ADCON0=0x01;ADCON2=0x3C;ADCON2bits.ADFM = 1;}
147 147
148 /** SPI : Chip Select Lines ****************************************/ 148 /** SPI : Chip Select Lines ****************************************/
149 #define tris_cs_temp_sensor TRISBbits.TRISB2 // Output 149 #define tris_cs_temp_sensor TRISBbits.TRISB2 // Output
150 #define cs_temp_sensor LATBbits.LATB2 150 #define cs_temp_sensor LATBbits.LATB2
151 /** USB external transceiver interface (optional) ******************/ 151 /** USB external transceiver interface (optional) ******************/
152 #define tris_usb_vpo TRISBbits.TRISB3 // Output 152 #define tris_usb_vpo TRISBbits.TRISB3 // Output
153 #define tris_usb_vmo TRISBbits.TRISB2 // Output 153 #define tris_usb_vmo TRISBbits.TRISB2 // Output
154 #define tris_usb_rcv TRISAbits.TRISA4 // Input 154 #define tris_usb_rcv TRISAbits.TRISA4 // Input
155 #define tris_usb_vp TRISCbits.TRISC5 // Input 155 #define tris_usb_vp TRISCbits.TRISC5 // Input
156 #define tris_usb_vm TRISCbits.TRISC4 // Input 156 #define tris_usb_vm TRISCbits.TRISC4 // Input
157 #define tris_usb_oe TRISCbits.TRISC1 // Output 157 #define tris_usb_oe TRISCbits.TRISC1 // Output
158 158
159 #define tris_usb_suspnd TRISAbits.TRISA3 // Output 159 #define tris_usb_suspnd TRISAbits.TRISA3 // Output
160 160
161 /** TRIS ***********************************************************/ 161 /** TRIS ***********************************************************/
162 #define INPUT_PIN 1 162 #define INPUT_PIN 1
163 #define OUTPUT_PIN 0 163 #define OUTPUT_PIN 0
164   164  
165 #if defined(YAS) 165 #if defined(YAS)
166 #define RXTX LATBbits.LATB5 166 #define RXTX LATBbits.LATB5
167 #else 167 #else
168 #define RXTX LATAbits.LATA2 168 #define RXTX LATAbits.LATA2
169 #endif 169 #endif
170   170  
171 #define BPF_S0 LATAbits.LATA0 171 #define BPF_S0 LATAbits.LATA0
172 #define BPF_S1 LATAbits.LATA1 172 #define BPF_S1 LATAbits.LATA1
173   173  
174 #if defined(YAS) 174 #if defined(YAS)
175 #define BPF_S2 LATAbits.LATA2 175 #define BPF_S2 LATAbits.LATA2
176 #endif 176 #endif
177   177  
178 #define BPF_S0_STATE PORTAbits.RA0 178 #define BPF_S0_STATE PORTAbits.RA0
179 #define BPF_S1_STATE PORTAbits.RA1 179 #define BPF_S1_STATE PORTAbits.RA1
180   180  
181 #if defined(YAS) 181 #if defined(YAS)
182 #define BPF_S2_STATE PORTAbits.RA2 182 #define BPF_S2_STATE PORTAbits.RA2
183 #endif 183 #endif
184   184  
185 #define PADDLE_DIT PORTBbits.RB6 185 #define PADDLE_DIT PORTBbits.RB6
186 #define PADDLE_DAH PORTBbits.RB7 186 #define PADDLE_DAH PORTBbits.RB7
187   187  
188 #define LPF_0 LATAbits.LATA3 188 #define LPF_0 LATAbits.LATA3
189 #define LPF_1 LATAbits.LATA4 189 #define LPF_1 LATAbits.LATA4
190 #define LPF_2 LATAbits.LATA5 190 #define LPF_2 LATAbits.LATA5
191   191  
192 #if defined(YAS) 192 #if defined(YAS)
193 #else 193 #else
194 #define LPF_3 LATBbits.LATB2 194 #define LPF_3 LATBbits.LATB2
195 #define LPF_4 LATBbits.LATB3 195 #define LPF_4 LATBbits.LATB3
196 #define LPF_5 LATBbits.LATB4 196 #define LPF_5 LATBbits.LATB4
197 #define LPF_6 LATBbits.LATB5 197 #define LPF_6 LATBbits.LATB5
198 #endif 198 #endif
199   199  
200 /** S W I T C H *****************************************************/ 200 /** S W I T C H *****************************************************/
201 #define mInitSwitch() TRISCbits.TRISC2 = 1; 201 #define mInitSwitch() TRISCbits.TRISC2 = 1;
202 #define UserSW PORTCbits.RC2 202 #define UserSW PORTCbits.RC2
203   203  
204 #define mLED_Both_Off() {mLED_1_Off(); mLED_2_Off();} 204 #define mLED_Both_Off() {mLED_1_Off(); mLED_2_Off();}
205 #define mLED_Both_On() {mLED_1_On(); mLED_2_On();} 205 #define mLED_Both_On() {mLED_1_On(); mLED_2_On();}
206 #define mLED_Only_1_On() {mLED_1_On(); mLED_2_Off();} 206 #define mLED_Only_1_On() {mLED_1_On(); mLED_2_Off();}
207 #define mLED_Only_2_On() {mLED_1_Off(); mLED_2_On();} 207 #define mLED_Only_2_On() {mLED_1_Off(); mLED_2_On();}
208   208  
209   209  
210 #endif //HARDWARE_PROFILE_PICDEM_FSUSB_H 210 #endif //HARDWARE_PROFILE_PICDEM_FSUSB_H