You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
2.7 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
  1. #pragma once
  2. #include <stdint.h>
  3. #include <string.h>
  4. #include "app_scheduler.h"
  5. #include "app_timer.h"
  6. #include "app_uart.h"
  7. #include "app_util_platform.h"
  8. #include "ble_advdata.h"
  9. #include "ble_advertising.h"
  10. #include "ble_conn_params.h"
  11. #include "ble_hci.h"
  12. #include "ble_nus.h"
  13. #include "bsp_btn_ble.h"
  14. #include "diskio_blkdev.h"
  15. #include "ff.h"
  16. #include "nordic_common.h"
  17. #include "nrf.h"
  18. #include "nrf_ble_gatt.h"
  19. #include "nrf_ble_qwr.h"
  20. #include "nrf_block_dev_sdc.h"
  21. #include "nrf_delay.h"
  22. #include "nrf_drv_pwm.h"
  23. #include "nrf_drv_saadc.h"
  24. #include "nrf_drv_spi.h"
  25. #include "nrf_drv_twi.h"
  26. #include "nrf_drv_wdt.h"
  27. #include "nrf_gpio.h"
  28. #include "nrf_log.h"
  29. #include "nrf_log_ctrl.h"
  30. #include "nrf_log_default_backends.h"
  31. #include "nrf_pwr_mgmt.h"
  32. #include "nrf_sdh.h"
  33. #include "nrf_sdh_ble.h"
  34. #include "nrf_sdh_soc.h"
  35. //
  36. #define APP_BLE_CONN_CFG_TAG 1 /**< A tag identifying the SoftDevice BLE configuration. */
  37. // #define ZNORDIC_SCHED_INIT(EVENT_SIZE, QUEUE_SIZE) APP_SCHED_INIT(EVENT_SIZE, QUEUE_SIZE)
  38. /*******************************************************************************
  39. * UTILS *
  40. *******************************************************************************/
  41. void znordic_init();
  42. int32_t znordic_get_event_max_size();
  43. void znordic_loop();
  44. void znrf_gpio_cfg_output(uint32_t pin_number, nrf_gpio_pin_pull_t pull);
  45. int16_t znrf_adc_channel_read_val(uint16_t channel);
  46. /*******************************************************************************
  47. * LOG *
  48. *******************************************************************************/
  49. #define ZLOGI(...) NRF_LOG_INFO(__VA_ARGS__)
  50. #define ZLOGE(...) NRF_LOG_ERROR(__VA_ARGS__)
  51. #define ZLOGW(...) NRF_LOG_WARNING(__VA_ARGS__)
  52. #define ZLOGD(...) NRF_LOG_DEBUG(__VA_ARGS__)
  53. #define ZARRAY_SIZE(array) (sizeof(array) / sizeof(array[0]))
  54. #define ZPIN(port, num) NRF_GPIO_PIN_MAP(port, num)
  55. #define ZERROR_CHECK(err_code) \
  56. do { \
  57. const uint32_t LOCAL_ERR_CODE = (err_code); \
  58. if (LOCAL_ERR_CODE != NRF_SUCCESS) { \
  59. ZLOGI("%s:%d ZERROR_CHECK(%s) fail:%d", __FILE__, __LINE__, #err_code, LOCAL_ERR_CODE); \
  60. APP_ERROR_CHECK(LOCAL_ERR_CODE); \
  61. } \
  62. } while (0)