drv_infra.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /* Copyright (C) 2018 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_INFRA_H_
  13. #define _DRV_INFRA_H_
  14. #include <stdint.h>
  15. #include <stdbool.h>
  16. #include <stddef.h>
  17. #include "drv_uart.h"
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. typedef struct infraDeviceUart infraDeviceUart_t;
  22. /* infrared read callback definition,passed in by the caller
  23. * pbuf:read data address
  24. * len: read data length
  25. */
  26. typedef void (*drvInfraRcvCallback_t)(uint8_t *pbuf, int len);
  27. /* open the infrared device,return false if opening fails,return true if opening success
  28. */
  29. bool drvInfraOpen(void);
  30. /* close the infrared device
  31. */
  32. void drvInfraClose(void);
  33. /* get the current state of the infrared device
  34. * opened return true
  35. * closed return false
  36. */
  37. bool drvInfraState(void);
  38. /* use infrared device to send data,the length cannot exceed 4K
  39. * return the length of the sent data
  40. * return -1 if sending error
  41. */
  42. int drvInfraSend(void *data, uint32_t length);
  43. /* set read callback for infrared device
  44. * if the infrared device obtains data,it returns the data upward through this callback
  45. * there is no limit to multiple configuration callbacks,and the new configuration callbacks,
  46. and the new configuration will overwrite the old configuration
  47. * if cb is NULL,it will clear the read callback of the infrared device
  48. * return true if the setting is successful
  49. */
  50. bool drvInfraSetRcvCallback(drvInfraRcvCallback_t cb);
  51. /* start carrier
  52. */
  53. void drvBuzzStart(void);
  54. /* stop carrier
  55. */
  56. void drvBuzzStop(void);
  57. #ifdef __cplusplus
  58. }
  59. #endif
  60. #endif