drv_ccid.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /* Copyright (C) 2020 RDA Technologies Limited and/or its affiliates("RDA").
  2. * All rights reserved.
  3. *
  4. * This software is supplied "AS IS" without any warranties.
  5. * RDA assumes no responsibility or liability for the use of the software,
  6. * conveys no license or title under any patent, copyright, or mask work
  7. * right to the product. RDA reserves the right to make changes in the
  8. * software without notification. RDA also make no representation or
  9. * warranty that such application will be suitable for the specified use
  10. * without further testing or modification.
  11. */
  12. #ifndef _DRV_CCID_H_
  13. #define _DRV_CCID_H_
  14. #include "osi_compiler.h"
  15. OSI_EXTERN_C_BEGIN
  16. #include "usb/ccid_message.h"
  17. #include <stddef.h>
  18. #include <stdint.h>
  19. /**
  20. * \brief ccid driver
  21. */
  22. typedef struct drv_ccid drvCCID_t;
  23. /**
  24. * \brief function type callback on ccid device line state change
  25. */
  26. typedef void (*ccidLineCallback_t)(void *priv, bool online);
  27. /**
  28. * \brief open the ccid device
  29. *
  30. * \param name the CCID device name
  31. * \return
  32. * - NULL fail
  33. * - other point of the instance
  34. */
  35. drvCCID_t *drvCCIDOpen(uint32_t name);
  36. /**
  37. * \brief set CCID line change callback
  38. * \note the callback will be called in interrupt
  39. *
  40. * \param ccid the CCID device
  41. * \param cb callback on line state change
  42. * \param ctx caller context
  43. */
  44. void drvCCIDSetLineChangeCallback(drvCCID_t *ccid, ccidLineCallback_t cb, void *ctx);
  45. /**
  46. * \brief get CCID device online or not (connect to a host and enable the config)
  47. *
  48. * \param ccid the CCID device
  49. * \return
  50. * - true if online else false
  51. */
  52. bool drvCCIDOnline(drvCCID_t *ccid);
  53. /**
  54. * \brief read CCID slot state, each bit indicated a slot
  55. *
  56. * \param ccid the CCID device
  57. * \param slotmap the slotmap must non-null
  58. * \return
  59. * - 0 succeed
  60. * - (negative integer) negative error number
  61. */
  62. int drvCCIDSlotCheck(drvCCID_t *ccid, uint8_t *slotmap);
  63. /**
  64. * \brief slot state change
  65. *
  66. * \param ccid the ccid device
  67. * \param index slot index
  68. * \param insert insert or remove
  69. * \return
  70. * - 0 succeed
  71. * - (negative integer) negative error number
  72. */
  73. int drvCCIDSlotChange(drvCCID_t *ccid, uint8_t index, bool insert);
  74. /**
  75. * \brief read CCID device
  76. * \note this api is synchronous, if no data coming, the call will block
  77. *
  78. * \param ccid the CCID device
  79. * \param buf buf to store read data
  80. * \param size buffer size, must greater than struct ccid_bulk_out_header
  81. * \return
  82. * - (negative integer) negative error number
  83. * - other actual read size
  84. */
  85. int drvCCIDRead(drvCCID_t *ccid, struct ccid_bulk_out_header *buf, unsigned size);
  86. /**
  87. * \brief write CCID device
  88. *
  89. * \param ccid the CCID device
  90. * \param data data buffer
  91. * \param size data size
  92. * \return
  93. * - (negative integer) negative error number
  94. * - other actual write size
  95. */
  96. int drvCCIDWrite(drvCCID_t *ccid, const struct ccid_bulk_in_header *data, unsigned size);
  97. /**
  98. * \brief close CCID device
  99. *
  100. * \param ccid the CCID device
  101. */
  102. void drvCCIDClose(drvCCID_t *ccid);
  103. OSI_EXTERN_C_END
  104. #endif