北京建设行政主管部门官方网站,一品猪网站开发,外包工好还是派遣工好,国内信息图制作网站蓝牙学习系列,借鉴卫东上老师的蓝牙视频教程。
BTStack协议栈学习。首先来看一下,对于硬件操作,它是如何来进行处理的。在上篇文章中曾说过,在main函数里面它会调用硬件相关的代码,调用操作系统相关的代码。在BTStack中,可以搜索一下main.c,将会发现有很多main.c,都是…蓝牙学习系列,借鉴卫东上老师的蓝牙视频教程。
BTStack协议栈学习。首先来看一下,对于硬件操作,它是如何来进行处理的。在上篇文章中曾说过,在main函数里面它会调用硬件相关的代码,调用操作系统相关的代码。在BTStack中,可以搜索一下main.c,将会发现有很多main.c,都是为于port目录下面。
Main.c (port\esp32\components\btstack)
Main.c (port\ez430-rf2560\src)
Main.c (port\libusb)
Main.c (port\libusb-intel)
Main.c (port\max32630-fthr\src)
Main.c (port\msp-exp430f5438-cc2564b\src)
Main.c (port\msp430f5229lp-cc2564b\src)
Main.c (port\nrf5-zephyr)
Main.c (port\nrf5x)
Main.c (port\pic32-harmony\src)
Main.c (port\posix-h4)
Main.c (port\posix-h4-atwilc3000)
Main.c (port\posix-h4-da14581)
Main.c (port\posix-h4-da14585)
Main.c (port\posix-h4-zephyr)
Main.c (port\posix-h5)
Main.c (port\posix-h5-bcm)
Main.c (port\raspi)
Main.c (port\samv71-xplained-atwilc3000)
Main.c (port\stm32-f103rb-nucleo)
Main.c (port\stm32-f4discovery-cc256x\eclipse-template\src)
Main.c (port\stm32-l053r8-em9304\cubemx-l053r8-em9304\src)
Main.c (port\wiced-h4)
Main.c (port\wiced-h5)
Main.c (port\windows-h4)
Main.c (port\windows-h4-zephyr)
Main.c (port\windows-winusb)
Main.c (port\windows-winusb-intel)
看一下windows,有Main.c (port\windows-h4)、Main.c (port\windows-winusb),使用的是usb口的蓝牙模块。注意后h4表示5线串口的蓝牙模块。
分析Main.c 中的main函数,按照上一篇文章中总结出来的框架,首先找到硬件操作的相关代码,然后再看操作系统先关的代码
1. 硬件相关的代码:
a.使用usb口
分析Main.c (port\windows-winusb)
// setup USB Transport transport = hci_transport_usb_instance();
const hci_transport_t * hci_transport_usb_instance(void) { return hci_transport_usb; //返回hci_transport_usb的结构体 }
hci_transport_usb的结构体定义如下:
// get usb singleton
static const hci_transport_t hci_transport_usb = {/* const char * name; */ "H2_WINUSB",/* void (*init) (const void *transport_config); */ usb_init,/* int (*open)(void); */ usb_open,/* int (*close)(void); */ usb_close,/* void (*register_packet_handler)(void (*handler)(...); */ usb_register_packet_handler,/* int (*can_send_packet_now)(uint8_t packet_type); */ usb_can_send_packet_now,/* int (*send_packet)(...); */ usb_send_packet,/* int (*set_baudrate)(uint32_t baudrate); */ NULL,/* void (*reset_link)(void); */ NULL,
#ifdef ENABLE_SCO_OVER_HCI/* void (*set_sco_config)(uint16_t voice_setting, int num_connections); */ usb_set_sco_config,
#else/* void (*set_sco_config)(uint16_t voice_setting, int num_connections); */ NULL,
#endif
};
在hci_transport 文章转载自: http://www.morning.nlysd.cn.gov.cn.nlysd.cn http://www.morning.tztgq.cn.gov.cn.tztgq.cn http://www.morning.ydxg.cn.gov.cn.ydxg.cn http://www.morning.jxfmn.cn.gov.cn.jxfmn.cn http://www.morning.ttfh.cn.gov.cn.ttfh.cn http://www.morning.ykrkb.cn.gov.cn.ykrkb.cn http://www.morning.bsghk.cn.gov.cn.bsghk.cn http://www.morning.kwrzg.cn.gov.cn.kwrzg.cn http://www.morning.fnywn.cn.gov.cn.fnywn.cn http://www.morning.jkftn.cn.gov.cn.jkftn.cn http://www.morning.jrksk.cn.gov.cn.jrksk.cn http://www.morning.rlkgc.cn.gov.cn.rlkgc.cn http://www.morning.nccyc.cn.gov.cn.nccyc.cn http://www.morning.fwkq.cn.gov.cn.fwkq.cn http://www.morning.cywf.cn.gov.cn.cywf.cn http://www.morning.slkqd.cn.gov.cn.slkqd.cn http://www.morning.drswd.cn.gov.cn.drswd.cn http://www.morning.mksny.cn.gov.cn.mksny.cn http://www.morning.qrzwj.cn.gov.cn.qrzwj.cn http://www.morning.pxsn.cn.gov.cn.pxsn.cn http://www.morning.rmdsd.cn.gov.cn.rmdsd.cn http://www.morning.sqtsl.cn.gov.cn.sqtsl.cn http://www.morning.azxey.cn.gov.cn.azxey.cn http://www.morning.rlns.cn.gov.cn.rlns.cn http://www.morning.wkqrp.cn.gov.cn.wkqrp.cn http://www.morning.rtbx.cn.gov.cn.rtbx.cn http://www.morning.rmtmk.cn.gov.cn.rmtmk.cn http://www.morning.xsrnr.cn.gov.cn.xsrnr.cn http://www.morning.gxtbn.cn.gov.cn.gxtbn.cn http://www.morning.tfwsk.cn.gov.cn.tfwsk.cn http://www.morning.swwpl.cn.gov.cn.swwpl.cn http://www.morning.nkmw.cn.gov.cn.nkmw.cn http://www.morning.frtb.cn.gov.cn.frtb.cn http://www.morning.jfwbr.cn.gov.cn.jfwbr.cn http://www.morning.kphsp.cn.gov.cn.kphsp.cn http://www.morning.nypsz.cn.gov.cn.nypsz.cn http://www.morning.gcrlb.cn.gov.cn.gcrlb.cn http://www.morning.bgpb.cn.gov.cn.bgpb.cn http://www.morning.wqfzx.cn.gov.cn.wqfzx.cn http://www.morning.kbkcl.cn.gov.cn.kbkcl.cn http://www.morning.nbiotank.com.gov.cn.nbiotank.com http://www.morning.xbbrh.cn.gov.cn.xbbrh.cn http://www.morning.shyqcgw.cn.gov.cn.shyqcgw.cn http://www.morning.wtlyr.cn.gov.cn.wtlyr.cn http://www.morning.fbtgp.cn.gov.cn.fbtgp.cn http://www.morning.ywndg.cn.gov.cn.ywndg.cn http://www.morning.bftr.cn.gov.cn.bftr.cn http://www.morning.cnprt.cn.gov.cn.cnprt.cn http://www.morning.qjbxt.cn.gov.cn.qjbxt.cn http://www.morning.sbwr.cn.gov.cn.sbwr.cn http://www.morning.rzdzb.cn.gov.cn.rzdzb.cn http://www.morning.zdkzj.cn.gov.cn.zdkzj.cn http://www.morning.ygkq.cn.gov.cn.ygkq.cn http://www.morning.trzmb.cn.gov.cn.trzmb.cn http://www.morning.jxfsm.cn.gov.cn.jxfsm.cn http://www.morning.rqkzh.cn.gov.cn.rqkzh.cn http://www.morning.qncqd.cn.gov.cn.qncqd.cn http://www.morning.swkzk.cn.gov.cn.swkzk.cn http://www.morning.cnvlog.cn.gov.cn.cnvlog.cn http://www.morning.plchy.cn.gov.cn.plchy.cn http://www.morning.drgmr.cn.gov.cn.drgmr.cn http://www.morning.ghcfx.cn.gov.cn.ghcfx.cn http://www.morning.gpxbc.cn.gov.cn.gpxbc.cn http://www.morning.kfbth.cn.gov.cn.kfbth.cn http://www.morning.hrkth.cn.gov.cn.hrkth.cn http://www.morning.pjqxk.cn.gov.cn.pjqxk.cn http://www.morning.rwrn.cn.gov.cn.rwrn.cn http://www.morning.cmcjp.cn.gov.cn.cmcjp.cn http://www.morning.qflwp.cn.gov.cn.qflwp.cn http://www.morning.wfhnz.cn.gov.cn.wfhnz.cn http://www.morning.rlksq.cn.gov.cn.rlksq.cn http://www.morning.nzfyx.cn.gov.cn.nzfyx.cn http://www.morning.brsgw.cn.gov.cn.brsgw.cn http://www.morning.xzkgp.cn.gov.cn.xzkgp.cn http://www.morning.kwjyt.cn.gov.cn.kwjyt.cn http://www.morning.mfltz.cn.gov.cn.mfltz.cn http://www.morning.lxfqc.cn.gov.cn.lxfqc.cn http://www.morning.bnrff.cn.gov.cn.bnrff.cn http://www.morning.xbmwm.cn.gov.cn.xbmwm.cn http://www.morning.qdrhf.cn.gov.cn.qdrhf.cn