peripheral.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /********************************** (C) COPYRIGHT *******************************
  2. * File Name : peripheral.h
  3. * Author : WCH
  4. * Version : V1.0
  5. * Date : 2018/12/11
  6. * Description :
  7. *********************************************************************************
  8. * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
  9. * Attention: This software (modified or not) and binary are used for
  10. * microcontroller manufactured by Nanjing Qinheng Microelectronics.
  11. *******************************************************************************/
  12. #ifndef PERIPHERAL_H
  13. #define PERIPHERAL_H
  14. #include <stdint.h>
  15. #include <stdbool.h>
  16. #include "define.h"
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. /*********************************************************************
  21. * INCLUDES
  22. */
  23. /*********************************************************************
  24. * CONSTANTS
  25. */
  26. // Peripheral Task Events
  27. #define SBP_START_DEVICE_EVT 0x0001
  28. #define SBP_PERIODIC_EVT 0x0002
  29. #define SBP_READ_RSSI_EVT 0x0004
  30. #define SBP_PARAM_UPDATE_EVT 0x0008
  31. #define SBP_PHY_UPDATE_EVT 0x0010
  32. /*********************************************************************
  33. * MACROS
  34. */
  35. typedef struct
  36. {
  37. uint16_t connHandle; // Connection handle of current connection
  38. uint16_t connInterval;
  39. uint16_t connSlaveLatency;
  40. uint16_t connTimeout;
  41. } peripheralConnItem_t;
  42. //for send to ble
  43. typedef enum
  44. {
  45. SEND_TO_BLE_TO_SEND = 1,
  46. SEND_TO_BLE_ALLOC_FAILED,
  47. SEND_TO_BLE_SEND_FAILED,
  48. } send_to_ble_state_t;
  49. /*********************************************************************
  50. * FUNCTIONS
  51. */
  52. /*
  53. * Task Initialization for the BLE Application
  54. */
  55. extern void Peripheral_Init(void);
  56. /*
  57. * Task Event Processor for the BLE Application
  58. */
  59. extern uint16_t Peripheral_ProcessEvent(uint8_t task_id, uint16_t events);
  60. typedef bool (*download_ble_data_func)(uint8_t *data, int len);
  61. typedef void (*ble_connect_func)(bool stat);
  62. void ble_data_send(uint8_t *data, int len);
  63. void set_download_ble_data_func(download_ble_data_func func);
  64. void set_download_ble_file_func(download_ble_data_func func);
  65. void set_ble_connect_evtfunc(ble_connect_func func);
  66. void debug_ble_tx_data(uint8_t *data, uint16_t length);
  67. /*********************************************************************
  68. *********************************************************************/
  69. #ifdef __cplusplus
  70. }
  71. #endif
  72. #endif