Keyboard firmwares for Atmel AVR and Cortex-M
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

usb1_function_controlrw.c 6.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /*******************************************************************************
  2. * DISCLAIMER
  3. * This software is supplied by Renesas Electronics Corporation and is only
  4. * intended for use with Renesas products. No other uses are authorized. This
  5. * software is owned by Renesas Electronics Corporation and is protected under
  6. * all applicable laws, including copyright laws.
  7. * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
  8. * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
  9. * LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
  10. * AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
  11. * TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
  12. * ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
  13. * FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
  14. * ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
  15. * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
  16. * Renesas reserves the right, without notice, to make changes to this software
  17. * and to discontinue the availability of this software. By using this software,
  18. * you agree to the additional terms and conditions found by accessing the
  19. * following link:
  20. * http://www.renesas.com/disclaimer
  21. * Copyright (C) 2012 - 2014 Renesas Electronics Corporation. All rights reserved.
  22. *******************************************************************************/
  23. /*******************************************************************************
  24. * File Name : usb1_function_controlrw.c
  25. * $Rev: 1116 $
  26. * $Date:: 2014-07-09 16:29:19 +0900#$
  27. * Device(s) : RZ/A1H
  28. * Tool-Chain :
  29. * OS : None
  30. * H/W Platform :
  31. * Description : RZ/A1H R7S72100 USB Sample Program
  32. * Operation :
  33. * Limitations :
  34. *******************************************************************************/
  35. /*******************************************************************************
  36. Includes <System Includes> , "Project Includes"
  37. *******************************************************************************/
  38. #include "usb1_function.h"
  39. /*******************************************************************************
  40. Typedef definitions
  41. *******************************************************************************/
  42. /*******************************************************************************
  43. Macro definitions
  44. *******************************************************************************/
  45. /*******************************************************************************
  46. Imported global variables and functions (from other files)
  47. *******************************************************************************/
  48. /*******************************************************************************
  49. Exported global variables and functions (to be accessed by other files)
  50. *******************************************************************************/
  51. /*******************************************************************************
  52. Private global variables and functions
  53. *******************************************************************************/
  54. /*******************************************************************************
  55. * Function Name: usb1_api_function_CtrlReadStart
  56. * Description : Executes the USB control read transfer.
  57. * : USB host controller <- USB device
  58. * Arguments : uint16_t size ; Data Size
  59. * : uint8_t *data ; Data Address
  60. * Return Value : DEVDRV_USBF_WRITEEND ; End of data write
  61. * : DEVDRV_USBF_WRITESHRT ; End of short data write
  62. * : DEVDRV_USBF_WRITING ; Continue of data write
  63. * : DEVDRV_USBF_FIFOERROR ; FIFO access error
  64. *******************************************************************************/
  65. uint16_t usb1_api_function_CtrlReadStart (uint32_t size, uint8_t * data)
  66. {
  67. uint16_t status;
  68. uint16_t mbw;
  69. usb1_function_set_pid_nak(USB_FUNCTION_PIPE0);
  70. g_usb1_function_data_count[USB_FUNCTION_PIPE0] = size;
  71. g_usb1_function_data_pointer[USB_FUNCTION_PIPE0] = data;
  72. mbw = usb1_function_get_mbw(g_usb1_function_data_count[USB_FUNCTION_PIPE0],
  73. (uint32_t)g_usb1_function_data_pointer[USB_FUNCTION_PIPE0]);
  74. usb1_function_set_curpipe(USB_FUNCTION_PIPE0, USB_FUNCTION_CUSE, USB_FUNCTION_CFIFO_WRITE, mbw);
  75. USB201.CFIFOCTR = USB_FUNCTION_BITBCLR;
  76. status = usb1_function_write_buffer_c(USB_FUNCTION_PIPE0);
  77. /* Peripheral Control sequence */
  78. switch (status)
  79. {
  80. case DEVDRV_USBF_WRITESHRT: /* End of data write */
  81. case DEVDRV_USBF_WRITEEND: /* End of data write (not null) */
  82. case DEVDRV_USBF_WRITING: /* Continue of data write */
  83. usb1_function_enable_bemp_int(USB_FUNCTION_PIPE0); /* Enable Empty Interrupt */
  84. usb1_function_set_pid_buf(USB_FUNCTION_PIPE0); /* Set BUF */
  85. break;
  86. case DEVDRV_USBF_FIFOERROR: /* FIFO access error */
  87. break;
  88. default:
  89. break;
  90. }
  91. return status; /* End or Err or Continue */
  92. }
  93. /*******************************************************************************
  94. * Function Name: usb1_api_function_CtrlWriteStart
  95. * Description : Executes the USB control write transfer.
  96. * : USB host controller -> USB device
  97. * Arguments : uint16_t size ; Data Size
  98. * : uint8_t *data ; Data Address
  99. * Return Value : none
  100. *******************************************************************************/
  101. void usb1_api_function_CtrlWriteStart (uint32_t size, uint8_t * data)
  102. {
  103. uint16_t mbw;
  104. usb1_function_set_pid_nak(USB_FUNCTION_PIPE0);
  105. g_usb1_function_data_count[USB_FUNCTION_PIPE0] = size;
  106. g_usb1_function_data_pointer[USB_FUNCTION_PIPE0] = data;
  107. mbw = usb1_function_get_mbw(g_usb1_function_data_count[USB_FUNCTION_PIPE0],
  108. (uint32_t)g_usb1_function_data_pointer[USB_FUNCTION_PIPE0]);
  109. usb1_function_set_curpipe(USB_FUNCTION_PIPE0, USB_FUNCTION_CUSE, USB_FUNCTION_CFIFO_WRITE, mbw);
  110. USB201.CFIFOCTR = USB_FUNCTION_BITBCLR;
  111. usb1_function_enable_brdy_int(USB_FUNCTION_PIPE0);
  112. usb1_function_set_pid_buf(USB_FUNCTION_PIPE0);
  113. }
  114. /* End of File */