找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 3248|回復(fù): 1
打印 上一主題 下一主題
收起左側(cè)

NRF51822藍(lán)牙串口源碼分享

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
NRF51822 藍(lán)牙串口


單片機(jī)源程序如下:
  1. /* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved.
  2. *
  3. * The information contained herein is property of Nordic Semiconductor ASA.
  4. * Terms and conditions of usage are described in detail in NORDIC
  5. * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
  6. *
  7. * Licensees are granted free, non-transferable use of the information. NO
  8. * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
  9. * the file.
  10. *
  11. */

  12. #include <stdint.h>
  13. #include "app_error.h"
  14. #include "ble_dtm_app.h"
  15. #include "ble_serialization.h"
  16. #include "nrf_error.h"
  17. #include "ser_config.h"
  18. #include "ser_hal_transport.h"
  19. #include "ser_sd_transport.h"


  20. static uint32_t dtm_init_rsp_dec(const uint8_t * p_buffer, uint16_t length)
  21. {
  22.     uint32_t result_code;

  23.     const uint32_t err_code = ble_dtm_init_rsp_dec(p_buffer, length, &result_code);
  24.     APP_ERROR_CHECK(err_code);

  25.     return result_code;
  26. }


  27. uint32_t ble_dtm_init(app_uart_stream_comm_params_t * p_uart_comm_params)
  28. {
  29.     if (p_uart_comm_params == NULL)
  30.     {
  31.         return NRF_ERROR_NULL;
  32.     }
  33.    
  34.     uint32_t err_code = NRF_SUCCESS;
  35.     uint32_t index = 0;
  36.    
  37.     uint8_t * p_tx_buf = NULL;
  38.     uint32_t tx_buf_len = 0;

  39.     err_code = ser_hal_transport_tx_pkt_alloc(&p_tx_buf, (uint16_t *)&tx_buf_len);
  40.     if (err_code != NRF_SUCCESS)
  41.     {
  42.         return err_code;
  43.     }

  44.     p_tx_buf[index++] = SER_PKT_TYPE_DTM_CMD;
  45.     tx_buf_len -= SER_PKT_TYPE_SIZE;

  46.     err_code = ble_dtm_init_req_enc(p_uart_comm_params, &(p_tx_buf[SER_PKT_TYPE_SIZE]), &tx_buf_len);
  47.     if (err_code == NRF_SUCCESS)
  48.     {
  49.         tx_buf_len += SER_PKT_TYPE_SIZE;

  50.         err_code = ser_sd_transport_cmd_write(p_tx_buf, tx_buf_len, dtm_init_rsp_dec);
  51.         if (err_code != NRF_SUCCESS)
  52.         {
  53.             err_code = NRF_ERROR_INTERNAL;
  54.         }
  55.     }
  56.     else
  57.     {
  58.         err_code = NRF_ERROR_INTERNAL;
  59.     }

  60.     return err_code;
  61. }
復(fù)制代碼

所有資料51hei提供下載:
BLE實(shí)驗(yàn)4:藍(lán)牙串口.zip (14.5 MB, 下載次數(shù): 34)


分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏2 分享淘帖 頂 踩
回復(fù)

使用道具 舉報(bào)

沙發(fā)
ID:68875 發(fā)表于 2018-12-15 18:39 | 只看該作者
good topic
回復(fù)

使用道具 舉報(bào)

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

手機(jī)版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表