میخواستم بدونم تو کمپایلرccsتوابعی برای کار با usbو کارت حافظه وجود داره؟اگر وجود داره چه کتاب یا سورسی میشناسید که از روی اون بخونم؟
اطلاعیه
Collapse
No announcement yet.
توابع کار با usbو کارت حافظه درccs
Collapse
X
-
پاسخ : توابع کار با usbو کارت حافظه درccs
من تا حالا با USB کار نکردم ولی یه مقدار از بخش help رو می ذارم اینجا تا توابع آماده ی اون رو ببینید:
کد:Universal Serial Bus, or USB, is used as a method for peripheral devices to connect to and talk to a personal computer. CCS provides libraries for interfacing a PIC to PC using USB by using a PIC with an internal USB peripheral (like the PIC16C765 or the PIC18F4550 family) or by using any PIC with an external USB peripheral (the National USBN9603 family). Relevant Functions: usb_init() Initializes the USB hardware. Will then wait in an infinite loop for the USB peripheral to be connected to bus (but that doesn't mean it has been enumerated by the PC). Will enable and use the USB interrupt. usb_init_cs() The same as usb_init(), but does not wait for the device to be connected to the bus. This is useful if your device is not bus powered and can operate without a USB connection. usb_task() If you use connection sense, and the usb_init_cs() for initialization, then you must periodically call this function to keep an eye on the connection sense pin. When the PIC is connected to the BUS, this function will then perpare the USB peripheral. When the PIC is disconnected from the BUS, it will reset the USB stack and peripheral. Will enable and use the USB interrupt. Note: In your application you must define USB_CON_SENSE_PIN to the connection sense pin. usb_detach() Removes the PIC from the bus. Will be called automatically by usb_task() if connection is lost, but can be called manually by the user. usb_attach() Attaches the PIC to the bus. Will be called automatically by usb_task() if connection is made, but can be called manually by the user. usb_attached() If using connection sense pin (USB_CON_SENSE_PIN), returns TRUE if that pin is high. Else will always return TRUE. usb_enumerated() Returns TRUE if the device has been enumerated by the PC. If the device has been enumerated by the PC, that means it is in normal operation mode and you can send/receive packets. usb_put_packet (endpoint, data, len, tgl) Places the packet of data into the specified endpoint buffer. Returns TRUE if success, FALSE if the buffer is still full with the last packet. usb_puts (endpoint, data, len, timeout) Sends the following data to the specified endpoint. usb_puts() differs from usb_put_packet() in that it will send multi packet messages if the data will not fit into one packet. usb_kbhit(endpoint) Returns TRUE if the specified endpoint has data in it's receive buffer usb_get_packet (endpoint, ptr, max) Reads up to max bytes from the specified endpoint buffer and saves it to the pointer ptr. Returns the number of bytes saved to ptr. usb_gets(endpoint, ptr, max, timeout) Reads a message from the specified endpoint. The difference usb_get_packet() and usb_gets() is that usb_gets() will wait until a full message has received, which a message may contain more than one packet. Returns the number of bytes received. Relevant CDC Functions: A CDC USB device will emulate an RS-232 device, and will appear on your PC as a COM port. The follow functions provide you this virtual RS-232/serial interface Note: When using the CDC library, you can use the same functions above, but do not use the packet related function such as usb_kbhit(), usb_get_packet(), etc. usb_cdc_kbhit() The same as kbhit(), returns TRUE if there is 1 or more character in the receive buffer. usb_cdc_getc() The same as getc(), reads and returns a character from the receive buffer. If there is no data in the receive buffer it will wait indefinitely until there a character has been received. usb_cdc_putc(c) The same as putc(), sends a character. It actually puts a character into the transmit buffer, and if the transmit buffer is full will wait indefinitely until there is space for the character. usb_cdc_putc_fast(c) The same as usb_cdc_putc(), but will not wait indefinitely until there is space for the character in the transmit buffer. In that situation the character is lost. usb_cdc_putready() Returns TRUE if there is space in the transmit buffer for another character. Relevant Preporcessor: None Relevant Interrupts: #int_usb A USB event has happened, and requires application intervention. The USB library that CCS provides handles this interrupt automatically. Relevant Include files: pic_usb.h Hardware layer driver for the PIC16C765 family PICmicro controllers with an internal USB peripheral. pic_18usb.h Hardware layer driver for the PIC18F4550 family PICmicro controllers with an internal USB peripheral. usbn960x.h Hardware layer driver for the National USBN9603/USBN9604 external USB peripheral. You can use this external peripheral to add USB to any microcontroller. usb.h Common definitions and prototypes used by the USB driver usb.c The USB stack, which handles the USB interrupt and USB Setup Requests on Endpoint 0. usb_cdc.h A driver that takes the previous include files to make a CDC USB device, which emulates an RS232 legacy device and shows up as a COM port in the MS Windows device manager. Relevant getenv() Parameters: USB Returns TRUE if the PICmicro controller has an integrated internal USB peripheral. Example Code: Due to the complexity of USB example code will not fit here. But you can find the following examples installed with your CCS C Compiler: ex_usb_hid.c A simple HID device ex_usb_mouse.c A HID Mouse, when connected to your PC the mouse cursor will go in circles. ex_usb_kbmouse.c An example of how to create a USB device with multiple interfaces by creating a keyboard and mouse in one device. ex_usb_kbmouse2.c An example of how to use multiple HID report Ids to transmit more than one type of HID packet, as demonstrated by a keyboard and mouse on one device. ex_usb_scope.c A vendor-specific class using bulk transfers is demonstrated. ex_usb_serial.c The CDC virtual RS232 library is demonstrated with this RS232 < - > USB example. ex_usb_serial2.c Another CDC virtual RS232 library example, this time a port of the ex_intee.c example to use USB instead of RS232.
دوستان عزیزم تصمیم گرفتم تا یه مدت کمتر به تالار سر بزنم . اگر دیر جواب دادم ببخشید.
دیدگاه
-
پاسخ : توابع کار با usbو کارت حافظه درccs
نوشته اصلی توسط m.a.m.electro
برای کارت حافظه هم تایپ کیند MMC/SD card یه چیزایی میاره
اگه انگلیسیتون خوبه حتما یه سر به سایت CCSInfo.com بزنیددوستان عزیزم تصمیم گرفتم تا یه مدت کمتر به تالار سر بزنم . اگر دیر جواب دادم ببخشید.
دیدگاه
دیدگاه