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