HardwareProfile - PICDEM FSUSB.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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. Software License Agreement:
  9. The software supplied herewith by Microchip Technology Incorporated
  10. (the “Company”) for its PIC® Microcontroller is intended and
  11. supplied to you, the Company’s customer, for use solely and
  12. exclusively on Microchip PIC Microcontroller products. The
  13. software is owned by the Company and/or its supplier, and is
  14. protected under applicable copyright laws. All rights are reserved.
  15. Any use in violation of the foregoing restrictions may subject the
  16. user to criminal sanctions under applicable laws, as well as to
  17. civil liability for the breach of the terms and conditions of this
  18. license.
  19. THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES,
  20. WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
  21. TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
  22. PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
  23. IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
  24. CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
  25. ********************************************************************
  26. File Description:
  27. Change History:
  28. Rev Date Description
  29. 1.0 11/19/2004 Initial release
  30. 2.1 02/26/2007 Updated for simplicity and to use common
  31. coding style
  32. 2.3 09/15/2008 Broke out each hardware platform into its own
  33. "HardwareProfile - xxx.h" file
  34. ********************************************************************/
  35. #ifndef HARDWARE_PROFILE_PICDEM_FSUSB_H
  36. #define HARDWARE_PROFILE_PICDEM_FSUSB_H
  37. /*******************************************************************/
  38. /******** USB stack hardware selection options *********************/
  39. /*******************************************************************/
  40. //This section is the set of definitions required by the MCHPFSUSB
  41. // framework. These definitions tell the firmware what mode it is
  42. // running in, and where it can find the results to some information
  43. // that the stack needs.
  44. //These definitions are required by every application developed with
  45. // this revision of the MCHPFSUSB framework. Please review each
  46. // option carefully and determine which options are desired/required
  47. // for your application.
  48. //The PICDEM FS USB Demo Board platform supports the USE_SELF_POWER_SENSE_IO
  49. //and USE_USB_BUS_SENSE_IO features. Uncomment the below line(s) if
  50. //it is desireable to use one or both of the features.
  51. #define USE_SELF_POWER_SENSE_IO
  52. #define tris_self_power TRISAbits.TRISA2 // Input
  53. #if defined(USE_SELF_POWER_SENSE_IO)
  54. #define self_power PORTAbits.RA2
  55. #else
  56. #define self_power 1
  57. #endif
  58. #define USE_USB_BUS_SENSE_IO
  59. #define tris_usb_bus_sense TRISAbits.TRISA1 // Input
  60. #if defined(USE_USB_BUS_SENSE_IO)
  61. #define USB_BUS_SENSE PORTAbits.RA1
  62. #else
  63. #define USB_BUS_SENSE 1
  64. #endif
  65. //Uncomment the following line to make the output HEX of this
  66. // project work with the MCHPUSB Bootloader
  67. #define PROGRAMMABLE_WITH_USB_MCHPUSB_BOOTLOADER
  68. //Uncomment the following line to make the output HEX of this
  69. // project work with the HID Bootloader
  70. //#define PROGRAMMABLE_WITH_USB_HID_BOOTLOADER
  71. /*******************************************************************/
  72. /******** MDD File System selection options ************************/
  73. /*******************************************************************/
  74. #define USE_PIC18
  75. #define ERASE_BLOCK_SIZE 64
  76. #define WRITE_BLOCK_SIZE 32
  77. /*******************************************************************/
  78. /*******************************************************************/
  79. /*******************************************************************/
  80. /******** Application specific definitions *************************/
  81. /*******************************************************************/
  82. /*******************************************************************/
  83. /*******************************************************************/
  84. /** Board definition ***********************************************/
  85. //These defintions will tell the main() function which board is
  86. // currently selected. This will allow the application to add
  87. // the correct configuration bits as wells use the correct
  88. // initialization functions for the board. These defitions are only
  89. // required in the stack provided demos. They are not required in
  90. // final application design.
  91. #define DEMO_BOARD PICDEM_FS_USB
  92. #define PICDEM_FS_USB
  93. #define CLOCK_FREQ 48000000
  94. /** LED ************************************************************/
  95. #define mInitAllLEDs() LATD &= 0xF0; TRISD &= 0xF0;
  96. #define mLED_1 LATDbits.LATD0
  97. #define mLED_2 LATDbits.LATD1
  98. #define mLED_3 LATDbits.LATD2
  99. #define mLED_4 LATDbits.LATD3
  100. #define mGetLED_1() mLED_1
  101. #define mGetLED_2() mLED_2
  102. #define mGetLED_3() mLED_3
  103. #define mGetLED_4() mLED_4
  104. #define mLED_1_On() mLED_1 = 1;
  105. #define mLED_2_On() mLED_2 = 1;
  106. #define mLED_3_On() mLED_3 = 1;
  107. #define mLED_4_On() mLED_4 = 1;
  108. #define mLED_1_Off() mLED_1 = 0;
  109. #define mLED_2_Off() mLED_2 = 0;
  110. #define mLED_3_Off() mLED_3 = 0;
  111. #define mLED_4_Off() mLED_4 = 0;
  112. #define mLED_1_Toggle() mLED_1 = !mLED_1;
  113. #define mLED_2_Toggle() mLED_2 = !mLED_2;
  114. #define mLED_3_Toggle() mLED_3 = !mLED_3;
  115. #define mLED_4_Toggle() mLED_4 = !mLED_4;
  116. /** SWITCH *********************************************************/
  117. #define mInitAllSwitches() TRISBbits.TRISB4=1;TRISBbits.TRISB5=1;
  118. #define mInitSwitch2() TRISBbits.TRISB4=1;
  119. #define mInitSwitch3() TRISBbits.TRISB5=1;
  120. #define sw2 PORTBbits.RB4
  121. #define sw3 PORTBbits.RB5
  122. /** POT ************************************************************/
  123. #define mInitPOT() {TRISAbits.TRISA0=1;ADCON0=0x01;ADCON2=0x3C;ADCON2bits.ADFM = 1;}
  124. /** SPI : Chip Select Lines ****************************************/
  125. #define tris_cs_temp_sensor TRISBbits.TRISB2 // Output
  126. #define cs_temp_sensor LATBbits.LATB2
  127. /** USB external transceiver interface (optional) ******************/
  128. #define tris_usb_vpo TRISBbits.TRISB3 // Output
  129. #define tris_usb_vmo TRISBbits.TRISB2 // Output
  130. #define tris_usb_rcv TRISAbits.TRISA4 // Input
  131. #define tris_usb_vp TRISCbits.TRISC5 // Input
  132. #define tris_usb_vm TRISCbits.TRISC4 // Input
  133. #define tris_usb_oe TRISCbits.TRISC1 // Output
  134. #define tris_usb_suspnd TRISAbits.TRISA3 // Output
  135. /** TRIS ***********************************************************/
  136. #define INPUT_PIN 1
  137. #define OUTPUT_PIN 0
  138. #endif //HARDWARE_PROFILE_PICDEM_FSUSB_H