如何使用 CC2540 制作一个 iBeacon

如何使用 CC2540 制作一个 iBeacon,第1张

准备工作

一台 PC

IAR Embedded Workbench 集成开发环境,可以用30天试用版本。

支持 蓝牙 4.0 的智能手机链悄梁逗一部,并安装下列应用之一

Android Google Play Store.

iPhone App Store.

CC2540 开发板

CCDebugger 下载器

创建 iBeacon 工程文档

安装 TI 官方的 CC254x 开发环境

复制 C:\Texas Instruments\BLE-CC254x-1.3.2\Projects\ble\SimpleBLEBroadcaster 文件夹

粘贴到:C:\Texas Instruments\BLE-CC254x-1.3.2\Projects\ble\iBeacon

运行棚渣渣 IAR Embedded Workbench,点击 File >Open >Workspace

修改源代码

simpleBLEBroadcaster.c

// GAP - Advertisement data (max size = 31 bytes, though this is

// best kept short to conserve power while advertisting)

static uint8 advertData[] =

{

// Flagsthis sets the device to use limited discoverable

// mode (advertises for 30 seconds at a time) instead of general

// discoverable mode (advertises indefinitely)

0x02, // length of this data

GAP_ADTYPE_FLAGS,

GAP_ADTYPE_FLAGS_BREDR_NOT_SUPPORTED,

// three-byte broadcast of the data "1 2 3"

0x04, // length of this data including the data type byte

GAP_ADTYPE_MANUFACTURER_SPECIFIC, // manufacturer specific advertisement data type

1,

2,

3

}

修改下面关键字

UID: E2C56DB5-DFFB-48D2-B060-D0F5A71096E0

Major: 1 (0x0001)

Minor: 1 (0x0001)

Measured Power: -59 (0xc5)

// GAP - Advertisement data (max size = 31 bytes, though this is

// best kept short to conserve power while advertisting)

static uint8 advertData[] =

{

// 25 byte ibeacon advertising data

// Preamble: 0x4c000215

// UUID: E2C56DB5-DFFB-48D2-B060-D0F5A71096E0

// Major: 1 (0x0001)

// Minor: 1 (0x0001)

// Measured Power: -59 (0xc5)

0x1A, // length of this data including the data type byte

GAP_ADTYPE_MANUFACTURER_SPECIFIC, // manufacturer specific advertisement data type

0x4c,

0x00,

0x02,

0x15,

0xe2,

0xc5,

0x6d,

0xb5,

0xdf,

0xfb,

0x48,

0xd2,

0xb0,

0x60,

0xd0,

0xf5,

0xa7,

0x10,

0x96,

0xe0,

0x00,

0x01,

0x00,

0x01,

0xc5

}

接下来修改广播类型,将下面代码

//uint8 advType = GAP_ADTYPE_ADV_NONCONN_IND// use non-connectable advertisements

uint8 advType = GAP_ADTYPE_ADV_DISCOVER_IND// use scannable unidirected advertisements

修改为

uint8 advType = GAP_ADTYPE_ADV_NONCONN_IND // use non-connectable advertisements

//uint8 advType = GAP_ADTYPE_ADV_DISCOVER_IND// use scannable unidirected advertisements

接下来修改 GAP

// Set the GAP Role Parameters

GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), &initial_advertising_enable )

GAPRole_SetParameter( GAPROLE_ADVERT_OFF_TIME, sizeof( uint16 ), &gapRole_AdvertOffTime )

GAPRole_SetParameter( GAPROLE_SCAN_RSP_DATA, sizeof ( scanRspData ), scanRspData )

GAPRole_SetParameter( GAPROLE_ADVERT_DATA, sizeof( advertData ), advertData )

GAPRole_SetParameter( GAPROLE_ADV_EVENT_TYPE, sizeof( uint8 ), &advType )

因为 iBeacon 必须不间断广播,并且不响应任何数据请求,所以我们要修改 GAPROLE_ADVERT_OFF_TIME 和 GAPROLE_SCAN_RSP_DATA。

// Set the GAP Role Parameters

GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), &initial_advertising_enable )

//GAPRole_SetParameter( GAPROLE_ADVERT_OFF_TIME, sizeof( uint16 ), &gapRole_AdvertOffTime )

//GAPRole_SetParameter( GAPROLE_SCAN_RSP_DATA, sizeof ( scanRspData ), scanRspData )

GAPRole_SetParameter( GAPROLE_ADVERT_DATA, sizeof( advertData ), advertData )

GAPRole_SetParameter( GAPROLE_ADV_EVENT_TYPE, sizeof( uint8 ), &advType )

保存工程后,进行编译,并通过 CCDebugger 下载程序到开发板中。

Select Project >Clean to clean the project.

Select Project >Make to make the project.

Select Project >Download and Debug to send the code to the CC2540 Key Fob

Select Debug >Go to Run the code on the CC2540 Key Fob.

BLE iBeacon

TI Displayport ESD Protection – TPD8S009

Arduino SPI 精华课程

TAGS

Arduino Arduino Due Arduino Esplora Atmega32u4 Atmel BacklightBMP085 Bootloader CC3x00 DatasheetDisplayport EasyDriver EDID eDPEsplora HDMI HMC5883L I2CJoystick LCD LED Luban LVDS MIPIMPU6050 MySQL Nginx PCB PHP pinModePWM PX4 Raspberry Pi RGB Sensor SPIStepper Motor Ubuntu Wifi 摇杆 树莓派步进电机 电源 背光 蓝牙

CATEGORIES

3D Printer

Android

Application Notes

Arduino

AVR

Backlight Driver

C

CC3x00

Datasheet

Development Environment

HDMI

Imaging &Graphics

iOS

Javascript

LCD/LCM

Material

Others

PCB Design

Power Management

Prototyping

Raspberry Pi

Rostock

Sensor

Server

Software

STM32

Super Manual

Tutorials

Work

cc2540芯片介绍 在线观看 - 酷6视频

http://v.ku6.com/show/gwXXE3siM7IXhMa2.html?loc=youce_tuijian

CC2540低功率蓝牙系统单晶片

用于感应器应用的低功率蓝牙解决方案包括CC2540 2.4 GHz系统单晶片、协定衫陵堆叠、轮廓软体及应用支援。

CC2540是一个超低消耗功率的真正系统单晶片,它整合了包含微控制器、主机端及应用程式在一个元件上。 CC2540结合一个优异的无线射频传送接收器及一个工业标准的加强型8051微控制器,它包括连接类比及数位感应器的周边,内建可程式的快闪记忆体,精确的无线射频讯号强度指示, 全速USB 2.0界面,内建AES-128加密引擎。

 丛塌禅 CC2540可让强固的主控或从属式节点以很低的成本建立起来,它具有很低的睡眠模式功率消耗及不同工作模式间短暂的转换时间,适用于需要超低消耗功率的系统。

CC2540有两个版本: CC2540F128/ F256, 各含有128KB及256 KB快闪记忆体,为40-pin

6mm x 6mm 的QFN包装。整合低功率蓝牙协定堆叠,使得CC2540F128/ F256成为市场上最具d性及成本效益的单模式低功率蓝牙解决方案。CC2540低功率蓝牙感应器解决方案主要功能

● 8051微控制器 - 128KB或256 KB内建快闪记忆体, 8KB SRAM。

● 完全整合的无线射频功能 - 低功率蓝牙 (1Mbps GFSK ) 。

● 数位周边 – 21个通用型输出入界面, 2个USART (UART或SPI),全速USB 2.0,2个16位元

及2个8位元计时器,专属的连接层计时器用于低功率蓝牙协定时脉,AES-128硬体加密/解渗尘密

功能。

● 先进的类比周边 – 8通道 8到12位元 delta-sigma 类比数位转换器,超低功率类比比较器,

内建高效能运算放大器。

● 完整解决方案–2.4 GHz系统单晶片,德州仪器协定堆叠,轮廓软体,及应用支援。

● 超低消耗功率–感应器应用可使用一个硬币型电池运作超过一年的时间。

● 领先的无线射频效能–最高达+97dB link budget,可用于大范围通讯

cc2540本身是TI的一款低功耗蓝牙芯片(蔽迅 BLE )

德州仪器(TI)于2012年强势推出CC254x系列单芯片(SOC)低功耗蓝牙收发器,经典51内核,最强优势在于丰富的外围(21个IO,UART,SPI,USB2.0,PWM,ADC,analog comparator,op-amp),超宽的工作知巧电压(2v-3.6v),极低的能耗(<0.4uA),极小的唤醒延时(4us)。

为方便低功耗蓝牙(BLE)应用技术在各个行业产品中的移植和使用,中国宏猛此TI无线领域战略合作伙伴信驰达科技特别推出了低功耗蓝牙透传模块。

搭载cc2540芯片的模块就是cc2540低功耗蓝牙模块了( BLE )


欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/yw/12443089.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-23
下一篇2023-05-23

发表评论

登录后才能评论

评论列表(0条)

    保存