ВходНаше всё Теги codebook 无线电组件 Поиск Опросы Закон Среда
27 ноября
148972
Aдикм (23.02.2009 16:59, просмотров: 7316)
:) Что бы это значило (С)  #include <msp430tc0701.h> #include "USB_CDC_API\defTC0701.h" #include "USB_CDC_API\types.h" // Basic Type declarations #include "USB_CDC_API\Proj_Settings.h" #include "USB_CDC_API\usb.h" // USB-specific functions #include "main.h" #include "USB_CDC_API\hal_UCS.h" #include "USB_CDC_API\UsbCdc.h" #include <intrinsics.h> #include <string.h> volatile BYTE S0_event = 0; // Button S1 event volatile BYTE S1_event = 0; // Button S2 event const BYTE text[] = {"CDC: Button S2 pushed !!!"}; /*----------------------------------------------------------------------------+ | Main Routine | +----------------------------------------------------------------------------*/ VOID main(VOID) { WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer //initialize device Init_StartUp(); //init USB USB_init(); //we observe USB cable plagging-in event USB_setEnabledEvents(kUSB_VbusOnEvent); //connect to USB if cable already was plagged in if (USB_connectionStatus() & kUSB_vbusPresent) { if (USB_enable(USBPLL_SETCLK_4_0) == kUSB_succeed) { USB_reset(); USB_connect(); } } while(1) { if (USB_connectionStatus() & kUSB_suspended) { //if device suspended from USB - we go sleep __bis_SR_register(LPM3_bits + GIE); // Enter LPM3 w/interrupt __no_operation(); // Required for debugger } if (USB_connectionStatus() & kUSB_Enumerated) // if enumeration completed { if (!(USB_connectionStatus() & kUSB_suspended)) // and device not suspended { BYTE dataBuffer[64]; BYTE bytes_received; if (S1_event) // board button S1 was pushed, send CDC packet { //WORD bytes_send = 0; BYTE ret; ret = USBCDC_sendData(text, sizeof(text), 1); if (ret != kUSBCDC_sendStarted) { //error sending, you can try resend here... } //USBCDC_abortSend(&bytes_send, 1); S1_event = 0; } if (S0_event) { S0_event = 0; //reset remotewakeup event } bytes_received = USBCDC_receiveData(dataBuffer, 64, 1); if (bytes_received) { BYTE ret; // toggle LED1-3 if first byte is '1' .. '7' P8OUT = (dataBuffer[0] - '0') & 0x07; //send data back to PC ret = USBCDC_sendData((BYTE*)&dataBuffer, bytes_received, 1); if (ret != kUSBCDC_sendStarted) { //error sending, you can try resend here... } } } } // if Enumeration completed } // while(1) } //main()