usbd_mtp.c 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /**
  2. * @file usbd_mtp.h
  3. * @brief
  4. *
  5. * Copyright (c) 2022 sakumisu
  6. *
  7. * Licensed to the Apache Software Foundation (ASF) under one or more
  8. * contributor license agreements. See the NOTICE file distributed with
  9. * this work for additional information regarding copyright ownership. The
  10. * ASF licenses this file to you under the Apache License, Version 2.0 (the
  11. * "License"); you may not use this file except in compliance with the
  12. * License. You may obtain a copy of the License at
  13. *
  14. * http://www.apache.org/licenses/LICENSE-2.0
  15. *
  16. * Unless required by applicable law or agreed to in writing, software
  17. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  18. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  19. * License for the specific language governing permissions and limitations
  20. * under the License.
  21. *
  22. */
  23. #include "usbd_core.h"
  24. #include "usbd_mtp.h"
  25. /* Device data structure */
  26. struct mtp_cfg_priv {
  27. USB_MEM_ALIGN32 uint8_t device_status;
  28. } usbd_mtp_cfg;
  29. /* max USB packet size */
  30. #ifndef CONFIG_USB_HS
  31. #define MTP_BULK_EP_MPS 64
  32. #else
  33. #define MTP_BULK_EP_MPS 512
  34. #endif
  35. #define MSD_OUT_EP_IDX 0
  36. #define MSD_IN_EP_IDX 1
  37. /* Describe EndPoints configuration */
  38. static usbd_endpoint_t mtp_ep_data[2];
  39. /**
  40. * @brief Handler called for Class requests not handled by the USB stack.
  41. *
  42. * @param setup Information about the request to execute.
  43. * @param len Size of the buffer.
  44. * @param data Buffer containing the request result.
  45. *
  46. * @return 0 on success, negative errno code on fail.
  47. */
  48. static int mtp_class_request_handler(struct usb_setup_packet *setup, uint8_t **data, uint32_t *len)
  49. {
  50. USB_LOG_DBG("MTP Class request: "
  51. "bRequest 0x%02x\r\n",
  52. setup->bRequest);
  53. switch (setup->bRequest) {
  54. case MTP_REQUEST_CANCEL:
  55. break;
  56. case MTP_REQUEST_GET_EXT_EVENT_DATA:
  57. break;
  58. case MTP_REQUEST_RESET:
  59. break;
  60. case MTP_REQUEST_GET_DEVICE_STATUS:
  61. break;
  62. default:
  63. USB_LOG_WRN("Unhandled MTP Class bRequest 0x%02x\r\n", setup->bRequest);
  64. return -1;
  65. }
  66. return 0;
  67. }
  68. static void usbd_mtp_bulk_out(uint8_t ep)
  69. {
  70. }
  71. static void usbd_mtp_bulk_in(uint8_t ep)
  72. {
  73. }
  74. static void mtp_notify_handler(uint8_t event, void *arg)
  75. {
  76. switch (event) {
  77. case USBD_EVENT_RESET:
  78. break;
  79. default:
  80. break;
  81. }
  82. }