usbcdc.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. File: usbcdc.h
  3. Copyright (c) 2010,2013 Kustaa Nyholm / SpareTimeLabs
  4. This library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. This library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with this library; if not, write to the Free Software
  14. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  15. Version 1.1 Compatible with SDCC 3.x
  16. Respond to GET_LINE_CODING to work with overzealous
  17. Windows software (like Hyperterminal)
  18. */
  19. #ifndef USBCDC_H
  20. #define USBCDC_H
  21. extern unsigned char usbcdc_device_state;
  22. #define USBCDC_BUFFER_LEN 64 //32
  23. #define USBCDC_SELF_POWERED 1
  24. #define USBCDC_MAXPOWER 100
  25. // initialize usbcdc module
  26. void usbcdc_init(void);
  27. // waitiuntil the device is configure (if you care)
  28. void cdc_wait_config();
  29. // handle usb control messages, poll atleast every 1ms or call from IRQ
  30. void usbcdc_handler(void);
  31. void usbcdc_putchar(char c) __wparam;
  32. void usbcdc_flush();
  33. char usbcdc_getchar() ;
  34. //#pragma udata usbram5 setup_packet control_transfer_buffer cdc_rx_buffer cdc_tx_buffer cdcint_buffer
  35. #pragma udata usb_data cdc_tx_buffer cdcint_buffer
  36. #pragma udata usb_data2 setup_packet control_transfer_buffer cdc_rx_buffer
  37. extern volatile unsigned char cdc_tx_buffer[];
  38. char usbcdc_wr_busy();
  39. void usbcdc_write(unsigned char len) __wparam;
  40. extern volatile unsigned char cdc_rx_buffer[];
  41. unsigned char usbcdc_rd_ready();
  42. void usbcdc_read();
  43. #define usbcdc_rd_len() (ep2_o.CNT)
  44. #endif