1 |
/******************************************************************** |
1 |
/******************************************************************** |
2 |
FileName: HardwareProfile - UBW.h |
2 |
FileName: HardwareProfile - UBW.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 Companys customer, for use solely and |
13 |
supplied to you, the Companys 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 |
01/15/2009 UBW support |
39 |
01/15/2009 UBW support |
40 |
********************************************************************/ |
40 |
********************************************************************/ |
41 |
|
41 |
|
42 |
#ifndef HARDWARE_PROFILE_UBW_H |
42 |
#ifndef HARDWARE_PROFILE_UBW_H |
43 |
#define HARDWARE_PROFILE_UBW_H |
43 |
#define HARDWARE_PROFILE_UBW_H |
44 |
|
44 |
|
45 |
/*******************************************************************/ |
45 |
/*******************************************************************/ |
46 |
/******** USB stack hardware selection options *********************/ |
46 |
/******** USB stack hardware selection options *********************/ |
47 |
/*******************************************************************/ |
47 |
/*******************************************************************/ |
48 |
//This section is the set of definitions required by the MCHPFSUSB |
48 |
//This section is the set of definitions required by the MCHPFSUSB |
49 |
// framework. These definitions tell the firmware what mode it is |
49 |
// framework. These definitions tell the firmware what mode it is |
50 |
// running in, and where it can find the results to some information |
50 |
// running in, and where it can find the results to some information |
51 |
// that the stack needs. |
51 |
// that the stack needs. |
52 |
//These definitions are required by every application developed with |
52 |
//These definitions are required by every application developed with |
53 |
// this revision of the MCHPFSUSB framework. Please review each |
53 |
// this revision of the MCHPFSUSB framework. Please review each |
54 |
// option carefully and determine which options are desired/required |
54 |
// option carefully and determine which options are desired/required |
55 |
// for your application. |
55 |
// for your application. |
56 |
|
56 |
|
57 |
//The PICDEM FS USB Demo Board platform supports the USE_SELF_POWER_SENSE_IO |
57 |
//The PICDEM FS USB Demo Board platform supports the USE_SELF_POWER_SENSE_IO |
58 |
//and USE_USB_BUS_SENSE_IO features. Uncomment the below line(s) if |
58 |
//and USE_USB_BUS_SENSE_IO features. Uncomment the below line(s) if |
59 |
//it is desireable to use one or both of the features. |
59 |
//it is desireable to use one or both of the features. |
60 |
//#define USE_SELF_POWER_SENSE_IO |
60 |
//#define USE_SELF_POWER_SENSE_IO |
61 |
#define tris_self_power TRISAbits.TRISA2 // Input |
61 |
#define tris_self_power TRISAbits.TRISA2 // Input |
62 |
#if defined(USE_SELF_POWER_SENSE_IO) |
62 |
#if defined(USE_SELF_POWER_SENSE_IO) |
63 |
#define self_power PORTAbits.RA2 |
63 |
#define self_power PORTAbits.RA2 |
64 |
#else |
64 |
#else |
65 |
#define self_power 1 |
65 |
#define self_power 1 |
66 |
#endif |
66 |
#endif |
67 |
|
67 |
|
68 |
//#define USE_USB_BUS_SENSE_IO |
68 |
//#define USE_USB_BUS_SENSE_IO |
69 |
#define tris_usb_bus_sense TRISAbits.TRISA1 // Input |
69 |
#define tris_usb_bus_sense TRISAbits.TRISA1 // Input |
70 |
#if defined(USE_USB_BUS_SENSE_IO) |
70 |
#if defined(USE_USB_BUS_SENSE_IO) |
71 |
#define USB_BUS_SENSE PORTAbits.RA1 |
71 |
#define USB_BUS_SENSE PORTAbits.RA1 |
72 |
#else |
72 |
#else |
73 |
#define USB_BUS_SENSE 1 |
73 |
#define USB_BUS_SENSE 1 |
74 |
#endif |
74 |
#endif |
75 |
|
75 |
|
76 |
//Uncomment the following line to make the output HEX of this |
76 |
//Uncomment the following line to make the output HEX of this |
77 |
// project work with the MCHPUSB Bootloader |
77 |
// project work with the MCHPUSB Bootloader |
78 |
#define PROGRAMMABLE_WITH_USB_MCHPUSB_BOOTLOADER |
78 |
#define PROGRAMMABLE_WITH_USB_MCHPUSB_BOOTLOADER |
79 |
|
79 |
|
80 |
//Uncomment the following line to make the output HEX of this |
80 |
//Uncomment the following line to make the output HEX of this |
81 |
// project work with the HID Bootloader |
81 |
// project work with the HID Bootloader |
82 |
//#define PROGRAMMABLE_WITH_USB_HID_BOOTLOADER |
82 |
//#define PROGRAMMABLE_WITH_USB_HID_BOOTLOADER |
83 |
|
83 |
|
84 |
/*******************************************************************/ |
84 |
/*******************************************************************/ |
85 |
/******** MDD File System selection options ************************/ |
85 |
/******** MDD File System selection options ************************/ |
86 |
/*******************************************************************/ |
86 |
/*******************************************************************/ |
87 |
#define USE_PIC18 |
87 |
#define USE_PIC18 |
88 |
|
88 |
|
89 |
#define ERASE_BLOCK_SIZE 64 |
89 |
#define ERASE_BLOCK_SIZE 64 |
90 |
#define WRITE_BLOCK_SIZE 32 |
90 |
#define WRITE_BLOCK_SIZE 32 |
91 |
|
91 |
|
92 |
/*******************************************************************/ |
92 |
/*******************************************************************/ |
93 |
/*******************************************************************/ |
93 |
/*******************************************************************/ |
94 |
/*******************************************************************/ |
94 |
/*******************************************************************/ |
95 |
/******** Application specific definitions *************************/ |
95 |
/******** Application specific definitions *************************/ |
96 |
/*******************************************************************/ |
96 |
/*******************************************************************/ |
97 |
/*******************************************************************/ |
97 |
/*******************************************************************/ |
98 |
/*******************************************************************/ |
98 |
/*******************************************************************/ |
99 |
|
99 |
|
100 |
/** Board definition ***********************************************/ |
100 |
/** Board definition ***********************************************/ |
101 |
//These defintions will tell the main() function which board is |
101 |
//These defintions will tell the main() function which board is |
102 |
// currently selected. This will allow the application to add |
102 |
// currently selected. This will allow the application to add |
103 |
// the correct configuration bits as wells use the correct |
103 |
// the correct configuration bits as wells use the correct |
104 |
// initialization functions for the board. These defitions are only |
104 |
// initialization functions for the board. These defitions are only |
105 |
// required in the stack provided demos. They are not required in |
105 |
// required in the stack provided demos. They are not required in |
106 |
// final application design. |
106 |
// final application design. |
107 |
#define DEMO_BOARD UBW |
107 |
#define DEMO_BOARD UBW |
108 |
#define UBW |
108 |
#define UBW |
109 |
#define CLOCK_FREQ 48000000 |
109 |
#define CLOCK_FREQ 48000000 |
110 |
|
110 |
|
111 |
// Special UBW emu board by YAS |
111 |
// Special UBW emu board by YAS |
112 |
// #define YAS |
112 |
// #define YAS |
113 |
|
113 |
|
114 |
/** LED ************************************************************/ |
114 |
/** LED ************************************************************/ |
115 |
|
115 |
|
116 |
/* On UBW, LED1 = RC0, LED2 = RC1, SW = RC2 */ |
116 |
/* On UBW, LED1 = RC0, LED2 = RC1, SW = RC2 */ |
117 |
|
117 |
|
118 |
#define mInitAllLEDs() LATC &= 0xFC; TRISC &= 0xFC; |
118 |
#define mInitAllLEDs() LATC &= 0xFC; TRISC &= 0xFC; |
119 |
|
119 |
|
120 |
#define mLED_1 LATCbits.LATC0 |
120 |
#define mLED_1 LATCbits.LATC0 |
121 |
#define mLED_2 LATCbits.LATC1 |
121 |
#define mLED_2 LATCbits.LATC1 |
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 |
|
125 |
|
126 |
#define mLED_1_Off() mLED_1 = 0; |
126 |
#define mLED_1_Off() mLED_1 = 0; |
127 |
#define mLED_2_Off() mLED_2 = 0; |
127 |
#define mLED_2_Off() mLED_2 = 0; |
128 |
|
128 |
|
129 |
#define mLED_1_Toggle() mLED_1 = !mLED_1; |
129 |
#define mLED_1_Toggle() mLED_1 = !mLED_1; |
130 |
#define mLED_2_Toggle() mLED_2 = !mLED_2; |
130 |
#define mLED_2_Toggle() mLED_2 = !mLED_2; |
131 |
|
131 |
|
132 |
#if defined(YAS) |
132 |
#if defined(YAS) |
133 |
#define RXTX LATBbits.LATB5 |
133 |
#define RXTX LATBbits.LATB5 |
134 |
#else |
134 |
#else |
135 |
#define RXTX LATAbits.LATA2 |
135 |
#define RXTX LATAbits.LATA2 |
136 |
#endif |
136 |
#endif |
137 |
|
137 |
|
138 |
#define BPF_S0 LATAbits.LATA0 |
138 |
#define BPF_S0 LATAbits.LATA0 |
139 |
#define BPF_S1 LATAbits.LATA1 |
139 |
#define BPF_S1 LATAbits.LATA1 |
140 |
|
140 |
|
141 |
#if defined(YAS) |
141 |
#if defined(YAS) |
142 |
#define BPF_S2 LATAbits.LATA2 |
142 |
#define BPF_S2 LATAbits.LATA2 |
143 |
#endif |
143 |
#endif |
144 |
|
144 |
|
145 |
#define BPF_S0_STATE PORTAbits.RA0 |
145 |
#define BPF_S0_STATE PORTAbits.RA0 |
146 |
#define BPF_S1_STATE PORTAbits.RA1 |
146 |
#define BPF_S1_STATE PORTAbits.RA1 |
147 |
|
147 |
|
148 |
#if defined(YAS) |
148 |
#if defined(YAS) |
149 |
#define BPF_S2_STATE PORTAbits.RA2 |
149 |
#define BPF_S2_STATE PORTAbits.RA2 |
150 |
#endif |
150 |
#endif |
151 |
|
151 |
|
152 |
#define PADDLE_DIT PORTBbits.RB6 |
152 |
#define PADDLE_DIT PORTBbits.RB6 |
153 |
#define PADDLE_DAH PORTBbits.RB7 |
153 |
#define PADDLE_DAH PORTBbits.RB7 |
154 |
|
154 |
|
155 |
#define LPF_0 LATAbits.LATA3 |
155 |
#define LPF_0 LATAbits.LATA3 |
156 |
#define LPF_1 LATAbits.LATA4 |
156 |
#define LPF_1 LATAbits.LATA4 |
157 |
#define LPF_2 LATAbits.LATA5 |
157 |
#define LPF_2 LATAbits.LATA5 |
158 |
|
158 |
|
159 |
#if defined(YAS) |
159 |
#if defined(YAS) |
160 |
#else |
160 |
#else |
161 |
#define LPF_3 LATBbits.LATB2 |
161 |
#define LPF_3 LATBbits.LATB2 |
162 |
#define LPF_4 LATBbits.LATB3 |
162 |
#define LPF_4 LATBbits.LATB3 |
163 |
#define LPF_5 LATBbits.LATB4 |
163 |
#define LPF_5 LATBbits.LATB4 |
164 |
#define LPF_6 LATBbits.LATB5 |
164 |
#define LPF_6 LATBbits.LATB5 |
165 |
#endif |
165 |
#endif |
166 |
|
166 |
|
167 |
|
167 |
|
168 |
/** S W I T C H *****************************************************/ |
168 |
/** S W I T C H *****************************************************/ |
169 |
#define mInitSwitch() TRISCbits.TRISC2 = 1; |
169 |
#define mInitSwitch() TRISCbits.TRISC2 = 1; |
170 |
#define UserSW PORTCbits.RC2 |
170 |
#define UserSW PORTCbits.RC2 |
171 |
|
171 |
|
172 |
#define mLED_Both_Off() {mLED_1_Off(); mLED_2_Off();} |
172 |
#define mLED_Both_Off() {mLED_1_Off(); mLED_2_Off();} |
173 |
#define mLED_Both_On() {mLED_1_On(); mLED_2_On();} |
173 |
#define mLED_Both_On() {mLED_1_On(); mLED_2_On();} |
174 |
#define mLED_Only_1_On() {mLED_1_On(); mLED_2_Off();} |
174 |
#define mLED_Only_1_On() {mLED_1_On(); mLED_2_Off();} |
175 |
#define mLED_Only_2_On() {mLED_1_Off(); mLED_2_On();} |
175 |
#define mLED_Only_2_On() {mLED_1_Off(); mLED_2_On();} |
176 |
|
176 |
|
177 |
|
177 |
|
178 |
|
178 |
|
179 |
|
179 |
|
180 |
|
180 |
|
181 |
|
181 |
|
182 |
#endif //HARDWARE_PROFILE_UBW_H |
182 |
#endif //HARDWARE_PROFILE_UBW_H |