00001 //****************************************************************************** 00002 //THIS PROGRAM IS PROVIDED "AS IS". TI MAKES NO WARRANTIES OR 00003 //REPRESENTATIONS, EITHER EXPRESS, IMPLIED OR STATUTORY, 00004 //INCLUDING ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS 00005 //FOR A PARTICULAR PURPOSE, LACK OF VIRUSES, ACCURACY OR 00006 //COMPLETENESS OF RESPONSES, RESULTS AND LACK OF NEGLIGENCE. 00007 //TI DISCLAIMS ANY WARRANTY OF TITLE, QUIET ENJOYMENT, QUIET 00008 //POSSESSION, AND NON-INFRINGEMENT OF ANY THIRD PARTY 00009 //INTELLECTUAL PROPERTY RIGHTS WITH REGARD TO THE PROGRAM OR 00010 //YOUR USE OF THE PROGRAM. 00011 // 00012 //IN NO EVENT SHALL TI BE LIABLE FOR ANY SPECIAL, INCIDENTAL, 00013 //CONSEQUENTIAL OR INDIRECT DAMAGES, HOWEVER CAUSED, ON ANY 00014 //THEORY OF LIABILITY AND WHETHER OR NOT TI HAS BEEN ADVISED 00015 //OF THE POSSIBILITY OF SUCH DAMAGES, ARISING IN ANY WAY OUT 00016 //OF THIS AGREEMENT, THE PROGRAM, OR YOUR USE OF THE PROGRAM. 00017 //EXCLUDED DAMAGES INCLUDE, BUT ARE NOT LIMITED TO, COST OF 00018 //REMOVAL OR REINSTALLATION, COMPUTER TIME, LABOR COSTS, LOSS 00019 //OF GOODWILL, LOSS OF PROFITS, LOSS OF SAVINGS, OR LOSS OF 00020 //USE OR INTERRUPTION OF BUSINESS. IN NO EVENT WILL TI'S 00021 //AGGREGATE LIABILITY UNDER THIS AGREEMENT OR ARISING OUT OF 00022 //YOUR USE OF THE PROGRAM EXCEED FIVE HUNDRED DOLLARS 00023 //(U.S.$500). 00024 // 00025 //Unless otherwise stated, the Program written and copyrighted 00026 //by Texas Instruments is distributed as "freeware". You may, 00027 //only under TI's copyright in the Program, use and modify the 00028 //Program without any charge or restriction. You may 00029 //distribute to third parties, provided that you transfer a 00030 //copy of this license to the third party and the third party 00031 //agrees to these terms by its first use of the Program. You 00032 //must reproduce the copyright notice and any other legend of 00033 //ownership on each copy or partial copy, of the Program. 00034 // 00035 //You acknowledge and agree that the Program contains 00036 //copyrighted material, trade secrets and other TI proprietary 00037 //information and is protected by copyright laws, 00038 //international copyright treaties, and trade secret laws, as 00039 //well as other intellectual property laws. To protect TI's 00040 //rights in the Program, you agree not to decompile, reverse 00041 //engineer, disassemble or otherwise translate any object code 00042 //versions of the Program to a human-readable form. You agree 00043 //that in no event will you alter, remove or destroy any 00044 //copyright notice included in the Program. TI reserves all 00045 //rights not specifically granted under this license. Except 00046 //as specifically provided herein, nothing in this agreement 00047 //shall be construed as conferring by implication, estoppel, 00048 //or otherwise, upon you, any license or other right under any 00049 //TI patents, copyrights or trade secrets. 00050 // 00051 //You may not use the Program in non-TI devices. 00063 // (c)2009 by Texas Instruments Incorporated, All Rights Reserved. 00064 /*----------------------------------------------------------------------------+ 00065 | | 00066 | Texas Instruments | 00067 | | 00068 | MSP430 USB-Example (CDC/HID Driver) | 00069 | | 00070 +-----------------------------------------------------------------------------+ 00071 | Source: usb_eventHandling.c, v1.18 2009/06/11 | 00072 | Author: RSTO | 00073 | | 00074 | Description: | 00075 | Event-handling placeholder functions. | 00076 | All functios are called in interrupt context. | 00077 | | 00078 | WHO WHEN WHAT | 00079 | --- ---------- ------------------------------------------------ | 00080 | RSTO 2008/09/03 born | 00081 | RSTO 2008/12/23 enhancements of CDC API | 00082 | RSTO 2009/11/06 added USB_handleEnumCompleteEvent() | 00083 +----------------------------------------------------------------------------*/ 00084 00085 #include "MSP430.h" 00086 #include "..\Common\types.h" // Basic Type declarations 00087 #include "..\USB_Common\defMSP430USB.h" 00088 #include "descriptors.h" 00089 #include "usb.h" // USB-specific Data Structures 00090 00091 // These variables are only example, they are not needed for stack 00092 extern volatile BYTE bDataReceived_event; // data received event 00093 extern volatile BYTE bDataReceiveCompleted_event; // data receive completed event 00094 extern volatile BYTE bDataSendCompleted_event; // data send completed event 00095 00096 /* 00097 If this function gets executed, it's a sign that the output of the USB PLL has failed. 00098 returns TRUE to keep CPU awake 00099 */ 00100 BYTE USB_handleClockEvent() 00101 { 00102 //TO DO: You can place your code here 00103 00104 return TRUE; //return FALSE to go asleep after interrupt (in the case the CPU slept before interrupt) 00105 } 00106 00107 /* 00108 If this function gets executed, it indicates that a valid voltage has just been applied to the VBUS pin. 00109 returns TRUE to keep CPU awake 00110 */ 00111 BYTE USB_handleVbusOnEvent() 00112 { 00113 //TO DO: You can place your code here 00114 00115 //We switch on USB and connect to the BUS 00116 if (USB_enable() == kUSB_succeed) 00117 { 00118 USB_reset(); 00119 USB_connect(); // generate rising edge on DP -> the host enumerates our device as full speed device 00120 } 00121 return TRUE; //return FALSE to go asleep after interrupt (in the case the CPU slept before interrupt) 00122 } 00123 00124 /* 00125 If this function gets executed, it indicates that a valid voltage has just been removed from the VBUS pin. 00126 returns TRUE to keep CPU awake 00127 */ 00128 BYTE USB_handleVbusOffEvent() 00129 { 00130 //TO DO: You can place your code here 00131 00132 return TRUE; //return FALSE to go asleep after interrupt (in the case the CPU slept before interrupt) 00133 } 00134 00135 /* 00136 If this function gets executed, it indicates that the USB host has issued a USB reset event to the device. 00137 returns TRUE to keep CPU awake 00138 */ 00139 BYTE USB_handleResetEvent() 00140 { 00141 //TO DO: You can place your code here 00142 00143 return TRUE; //return FALSE to go asleep after interrupt (in the case the CPU slept before interrupt) 00144 } 00145 00146 /* 00147 If this function gets executed, it indicates that the USB host has chosen to suspend this device after a period of active operation. 00148 returns TRUE to keep CPU awake 00149 */ 00150 BYTE USB_handleSuspendEvent() 00151 { 00152 //TO DO: You can place your code here 00153 00154 return TRUE; //return FALSE to go asleep after interrupt (in the case the CPU slept before interrupt) 00155 } 00156 00157 /* 00158 If this function gets executed, it indicates that the USB host has chosen to resume this device after a period of suspended operation. 00159 returns TRUE to keep CPU awake 00160 */ 00161 BYTE USB_handleResumeEvent() 00162 { 00163 //TO DO: You can place your code here 00164 00165 return TRUE; //return TRUE to wake up after interrupt 00166 } 00167 00168 /* 00169 If this function gets executed, it indicates that the USB host has enumerated this device : 00170 after host assigned the address to the device. 00171 returns TRUE to keep CPU awake 00172 */ 00173 BYTE USB_handleEnumCompleteEvent() 00174 { 00175 //TO DO: You can place your code here 00176 00177 return TRUE; //return TRUE to wake up after interrupt 00178 } 00179 00180 00181 #ifdef _CDC_ 00182 00183 /* 00184 This event indicates that data has been received for interface intfNum, but no data receive operation is underway. 00185 returns TRUE to keep CPU awake 00186 */ 00187 BYTE USBCDC_handleDataReceived(BYTE intfNum) 00188 { 00189 //TO DO: You can place your code here 00190 00191 bDataReceived_event = TRUE; // data received event 00192 00193 return TRUE; //return TURE to wake up after data was received 00194 } 00195 00196 /* 00197 This event indicates that a send operation on interface intfNum has just been completed. 00198 returns TRUE to keep CPU awake 00199 */ 00200 BYTE USBCDC_handleSendCompleted(BYTE intfNum) 00201 { 00202 //TO DO: You can place your code here 00203 00204 bDataSendCompleted_event = TRUE; 00205 00206 return TRUE; //return FALSE to go asleep after interrupt (in the case the CPU slept before interrupt) 00207 } 00208 00209 /* 00210 This event indicates that a receive operation on interface intfNum has just been completed. 00211 */ 00212 BYTE USBCDC_handleReceiveCompleted(BYTE intfNum) 00213 { 00214 //TO DO: You can place your code here 00215 00216 bDataReceiveCompleted_event = TRUE; // data received event 00217 00218 return TRUE; //return FALSE to go asleep after interrupt (in the case the CPU slept before interrupt) 00219 } 00220 00221 #endif // _CDC_ 00222 00223 00224 00225 /*----------------------------------------------------------------------------+ 00226 | End of source file | 00227 +----------------------------------------------------------------------------*/ 00228 /*------------------------ Nothing Below This Line --------------------------*/
1.7.1