Zigbee协议的API接口函数手册
- 格式:pdf
- 大小:418.01 KB
- 文档页数:65
IO操作函数函数原型:IORD(BASE, REGNUM)输入参数:BASE为寄存器的基地址,REGNUM为寄存器的偏移量函数说明:从基地址为BASE的设备中读取寄存器中偏移量为REGNUM的单元里面的值。
寄存器的值在地址总线的范围之内。
返回值:-函数原型:IOWR(BASE, REGNUM, DATA)输入参数:BASE为寄存器的基地址,REGNUM为寄存器的偏移量,DATA为要写入的数据函数说明:往偏移量为REGNUM寄存器中写入数据。
寄存器的值在地址总线的范围之内。
返回值:-函数原型:IORD_32DIRECT(BASE, OFFSET)输入参数:BASE为寄存器的基地址,OFFSET为寄存器的的偏移量函数说明:从地址位置为BASE+OFFSET的寄存器中直接读取32Bit的数据返回值:-函数原型:IORD_16DIRECT(BASE, OFFSET)输入参数:BASE为寄存器的基地址,OFFSET为寄存器的的偏移量函数说明:从地址位置为BASE+OFFSET的寄存器中直接读取16Bit的数据返回值:-函数原型:IORD_8DIRECT(BASE, OFFSET)输入参数:BASE为寄存器的基地址,OFFSET为寄存器的的偏移量函数说明:从地址位置为BASE+OFFSET的寄存器中直接读取8Bit的数据返回值:-函数原型:IOWR_32DIRECT(BASE, OFFSET, DATA)输入参数:BASE为寄存器的基地址,REGNUM为寄存器的偏移量,DATA为要写入的数据函数说明:往地址位置为BASE+OFFSET的寄存器中直接写入32Bit的数据返回值:-函数原型:IOWR_16DIRECT(BASE, OFFSET, DATA)输入参数:BASE为寄存器的基地址,REGNUM为寄存器的偏移量,DATA为要写入的数据函数说明:往地址位置为BASE+OFFSET的寄存器中直接写入16Bit的数据返回值:-函数原型:IOWR_8DIRECT(BASE, OFFSET, DATA)输入参数:BASE为寄存器的基地址,REGNUM为寄存器的偏移量,DATA为要写入的数据函数说明:往地址位置为BASE+OFFSET的寄存器中直接写入8Bit的数据返回值:-Dma:函数原型:int alt_dma_rxchan_close (alt_dma_rxchan rxchan)输入参数:rxchan为接收信道函数说明:函数 alt_dma_rxchan_close ()通知系统:应用程序已经完成DMA 接收信道rxchan,目前执行是成功的返回值:成功返回为0,反之为-1函数原型:alt_dma_rxchan_depth(alt_dma_rxchan dma)输入参数:dma函数说明:函数alt_dma_rxchan_depth ()返回传送到特别DMA的最大数量(深度)的接收请求返回值: DMA的最大数量函数原型:int alt_dma_rxchan_ioctl (alt_dma_rxchan dma, int req, void* arg)输入参数:dma直接存储器名, req为请求操作的列举, arg由请求决定函数说明:通过DMA接收信道执行设备的具体I/O操作返回值:成功返回请求具体值,反之返回为负数请求类型请求类型请求类型说明ALT_DMA_SET_MODE_8 传输以8Bit为单位的数据,arg值忽略ALT_DMA_SET_MODE_16 传输以16Bit为单位的数据,arg值忽略ALT_DMA_SET_MODE_32 传输以32Bit为单位的数据,arg值忽略ALT_DMA_SET_MODE_64 传输以64Bit为单位的数据,arg值忽略ALT_DMA_SET_MODE_128 传输以128Bit为单位的数据,arg值忽略ALT_DMA_TX_ONLY_ON (1) 软件控制下只能发送ALT_DMA_TX_ONLY_OFF (1) 自定义模式,软件控制下可以接收,发送ALT_DMA_RX_ONLY_ON (1) 软件控制下只能接收ALT_DMA_RX_ONLY_OFF (1) 自定义模式,软件控制下可以接收,发送函数原型:alt_dma_rxchan alt_dma_rxchan_open (const char* name)输入参数:name为常数字符指针,如/dev/dma_0函数说明:为DMA接收信道获得一个alt_dma_rxchan描述符返回值:成功返回非0,反之返回为0函数原型:int alt_dma_rxchan_prepare (alt_dma_rxchan dma, void* data, alt_u32 length, alt_rxchan_done * done, void* handle)输入参数:dma使用的信道;data接收数据位置的指针;length最大的接收数据长度;done一旦数据被接收,调用返回函数;handle,非透明值传到done 函数说明:发送一个接收请求到DMA接收信道,返回值:成功返回0,反之返回为负数函数原型:int alt_dma_rxchan_reg (alt_dma_rxchan_dev * dev)输入参数:dev接收信道设备名函数说明:给系统寄存DMA接收信道返回值:成功返回0,反之返回为负数函数原型:int alt_dma_txchan_close (alt_dma_txchan txchan)输入参数:txchan发送信道名函数说明:通知系统:应用程序已经完成DMA发送信道txchan返回值:成功返回0,反之返回为负数函数原型:int alt_dma_txchan_ioctl (alt_dma_txchan dma, int req, void* arg)输入参数:dma直接存储器名;req为请求操作的列举;arg请求的额外参数,由请求决定函数说明:通过DMA发送信道执行设备的具体I/O操作返回值:成功返回请求具体值,反之返回为负数函数原型:alt_dma_txchan alt_dma_txchan_open (const char* name)输入参数:name为常数字符指针,如/dev/dma_0函数说明:为DMA发送信道获得一个alt_dma_rxchan描述符返回值:成功返回非0,反之返回为0函数原型:int alt_dma_txchan_reg (alt_dma_txchan_dev* dev)输入参数:dev接收信道设备名函数说明:给系统寄存DMA发送信道返回值:成功返回0,反之返回为负数函数原型:int alt_dma_txchan_send (alt_dma_txchan dma, const void* from, alt_u32 length, alt_txchan_done* done, void* handle)输入参数:dma使用的信道;data接收数据位置的指针;length最大的接收数据长度;done一旦数据被接收,调用返回函数;handle,非透明值传到done函数说明:发送一个发送请求到DMA发送信道,返回值:发送成功返回0,反之返回为负数函数原型:nt alt_dma_txchan_space (alt_dma_txchan dma)输入参数:dma 直接存储器名函数说明:返回被传送到具体DMA发送信道的发送请求数目返回值:返回发送请求数目Flash函数原型:int alt_erase_flash_block(alt_flash_fd* fd, int offset, int length)输入参数:fd为具体的flash设备;offset擦除的flash模块的偏移量;length 擦除的flash模块的长度函数说明:擦除单独的一个flash模块返回值:发送成功返回0,反之返回为负数函数原型:void alt_flash_close_dev(alt_flash_fd * fd)输入参数:fd为具体的flash设备函数说明:关闭flash设备返回值:-函数原型:alt_flash_fd * alt_flash_open_dev(const char* name)输入参数:函数说明:打开flash设备。
#1楼主:【原创】ZigBee学习之13——ZStack API解读文章发表于:2010-02-06 15:48Z-Stack API[Z-Stack API _F8W-2006-0021_.pdf]这个文档是一个关键了,Z-Stack的应用程序接口。
我们在程序中基本上应该调用的是这些API吧。
ZDO层API实现了所有ZDP(ZigBee Device Profile)定义的命令和回应所需要的函数。
ZDP描述了ZDO 如何实现普通ZigBee设备的特性,它定义了设备描述和簇,ZDP为ZDO和应用提供一下功能:·设备网络建立·设备和服务发现·节点设备邦定和解邦定服务·网络管理服务设备发现是ZigBee设备发现其他ZigBee设备的过程。
比如将已知的IEEE地址作为数据载荷广播到网络的NWK地址请求,相关设备必须回应并告知其网络地址。
服务发现提供了PAN中一个设备发现其他设备提供的服务的能力。
它利用多种描述符去指定设备的能力。
当用户需要邦定控制器与被控设备(比如开关和灯)时,将用到邦定和解邦定服务。
特别是终端设备邦定支持利用用户的输入来定义控制/被控设备对的简单邦定方法。
邦定和解邦服务可以创建和删除邦定表入口。
网络管理服务主要提供给用户和调试工具网络管理的能力,它能够从设备重新获得管理信息,包括网络发现结果,路由表的内容,邻居节点链路质量,邦定表内容。
也可以通过解关联将设备从PAN中脱离来控制网络关联。
ZDO设备网络建立在ZigBee网络中默认ZDApp_Init()[in ZDApp.c]开始器件的启动,但是应用能覆盖整个默认行为,为了使应用接管网络的启动,必须在编译选项中包含HOLD_AUTO_START,推荐同时包含NV_RESTORE(储存ZigBee网络状态到NV)编译选项,包含这个两个编译选项后就需要调用ZDOInitDevice() 来启动网络中的设备。
ZigBee学习之16——ZStack API解读4应用支持子层(APS)应用支持子层提供如下管理功能:∙邦定表管理∙组表管理∙快速地址查找除了管理功能外,APS还提供数据服务,只是应用不能访问数据服务。
应用需要通过AF数据接口AF_DataRequest()来发送数据。
如果要使用邦定表函数需要包含BindingTable.h头文件。
邦定表管理请注意,绑定服务只能在“互补”设备之间建立。
那就是,只有分别在两个节点的简单描述结构体(simple descriptor structure)中,同时注册了相同的命令标识符(command_id)并且方向相反(一个属于输出指令“output”,另一个属于输入指令“input”),才能成功建立绑定。
APS邦定表是在静态RAM中定义的一张表,定义在nwk_globals.c中。
表的大小可以通过f8wCo nfig.cfg中的[NWK_MAX_BINDING_ENTRIES和MAX_BINDING_CLUSTER_IDS]莱配置。
只有定义了R EFLECTOR或者COORDINATOR_BINDING才能包含此表,用REFLECTOR编译选项来支持APS层的源邦定。
邦定表结构– BindingEntry_ttypedef struct{uint16 srcIdx; // Address Manager indexuint8 srcEP;uint8 dstGroupMode; // Destination address type; 0 - Normal address index, 1 -// Group addressuint16 dstIdx; // This field is used in both modes (group and non-group) to// save NV and RAM space// dstGroupMode = 0 - Address Manager index// dstGroupMode = 1 - Group Addressuint8 dstEP;uint8 numClusterIds;uint16 clusterIdList[MAX_BINDING_CLUSTER_IDS];// Don't use MAX_BINDING_CLUSTERS_ID when// using the clusterIdList field. Use// gMAX_BINDING_CLUSTER_IDS} BindingEntry_t;srcIdx –源地址(绑定记录的源地址)的地址管理器索引,地址管理器保存着源地址的IEEE地址和短地址。
zigbee,协议栈,按键事件篇一:从Zigbee协议栈底层添加自己的按键配置本实验是基于ZStack-CC2530-2.5.1a版本的协议栈来进行实验的,整个实验需要改动hal_board_cfg.h、hal_board_cfg.h、hal_key.c、hal_key.h和自己定义的Coordinator.c这5个文件。
注意:添加自己的按键时尽量不要修改协议栈里面的按键程序,自己另行添加即可。
1、hal_key.h在/* Switches (keys) */下面添加自己的按键定义#define HAL_KEY_SW_8 0x80图1:----------------------------------------------------------------------------------------2、hal_board_cfg.h(转载于: 小龙文档网:zigbee,协议栈,按键事件) 在/* S6 */#define PUSH1_BV BV(1)#define PUSH1_SBIT P0_1#if defined (HAL_BOARD_CC2530EB_REV17)#define PUSH1_POLARITY ACTIVE_LOW#elif defined (HAL_BOARD_CC2530EB_REV13)#define PUSH1_POLARITY ACTIVE_LOW#else#error Unknown Board Indentifier#endif下面模仿/* S6 */下的程序定义自己的按键值:/* S8 */#define PUSH8_BVBV(4)//修改#define PUSH8_SBIT P0_4//修改#if defined (HAL_BOARD_CC2530EB_REV17)#define PUSH8_POLARITY ACTIVE_HIGH#elif defined (HAL_BOARD_CC2530EB_REV13)#define PUSH8_POLARITY ACTIVE_LOW#else#error Unknown Board Indentifier#endif图2:------------------------------------------------------------------------------------------------------------- 在/* ----------- Push Buttons ---------- */#define HAL_PUSH_BUTTON1() (PUSH1_POLARITY (PUSH1_SBIT)) #define HAL_PUSH_BUTTON2() (PUSH2_POLARITY (PUSH2_SBIT)) #define HAL_PUSH_BUTTON3() (0)#define HAL_PUSH_BUTTON4() (0)#define HAL_PUSH_BUTTON5() (0)#define HAL_PUSH_BUTTON6() (0)下定义自己的按键函数#define HAL_PUSH_BUTTON8() (PUSH8_POLARITY (PUSH8_SBIT)) 图3:---------------------------------------------------------------------------------------------------------------- hal_key.c在/* SW_6 is at P0.1 */#define HAL_KEY_SW_6_PORTP0#define HAL_KEY_SW_6_BIT BV(1)#define HAL_KEY_SW_6_SEL P0SEL#define HAL_KEY_SW_6_DIR P0DIR/* edge interrupt */#define HAL_KEY_SW_6_EDGEBIT BV(0)#define HAL_KEY_SW_6_EDGEHAL_KEY_FALLING_EDGE/* SW_6 interrupts */#define HAL_KEY_SW_6_IENIEN1 /* CPU interrupt mask register */#define HAL_KEY_SW_6_IENBITBV(5) /* Mask bit for all of Port_0 */#define HAL_KEY_SW_6_ICTL P0IEN /* Port Interrupt Control register */ #define HAL_KEY_SW_6_ICTLBIT BV(1) /* P0IEN - P0.1 enable/disable bit */ #define HAL_KEY_SW_6_PXIFG P0IFG /* Interrupt flag at source */下模仿/* SW_6 is at P0.1 */建立自己的按键函数#define HAL_KEY_SW_8_PORTP0#define HAL_KEY_SW_8_BIT BV(4) //修改#define HAL_KEY_SW_8_SEL P0SEL#define HAL_KEY_SW_8_DIR P0DIR/* edge interrupt */#define HAL_KEY_SW_8_EDGEBIT BV(0)#define HAL_KEY_SW_8_EDGE HAL_KEY_FALLING_EDGE/* SW_8 interrupts */#define HAL_KEY_SW_8_IENIEN1 /* CPU interruptmask register */#define HAL_KEY_SW_8_IENBITBV(5) /* Mask bit for all of Port_0 */#define HAL_KEY_SW_8_ICTL P0IEN /* Port Interrupt Control register */ #define HAL_KEY_SW_8_ICTLBIT BV(4)//修改#define HAL_KEY_SW_8_PXIFG P0IFG /* Interrupt flag at source */图4:------------------------------------------------------------------------------------------------------------- 注意:将void HalKeyPoll (void)中的// if ((HAL_KEY_JOY_MOVE_PORT & HAL_KEY_JOY_MOVE_BIT)) /* Key is active HIGH */ // {// keys = halGetJoyKeyInput();// }/* If interrupts are not enabled, previous key status and current key status* are compared to find out if a key has changed status.*/// if (!Hal_KeyIntEnable)// {// if (keys == halKeySavedKeys)// {/* Exit - since no keys have changed *///return;// }/* Store the current keys for comparation next time */// halKeySavedKeys = keys;// }// else// {/* Key interrupt handled here */// }图5:全部注释掉,因为它会对我们设定的按键产生干扰,具体情况我也不知道... 然后再在内模仿:if (HAL_PUSH_BUTTON1()){keys |= HAL_KEY_SW_6;}篇二:ZigBee系统事件ZIGBEE事件ZIGBEE事件有两类,系统定义事件和用户定义事件。
网络层(NWK)网络层为高层提供下面函数功能:∙网络管理∙地址管理∙网络变量和效能函数除了管理功能外,NWK还提供数据服务,只是应用不能访问数据服务。
应用需要通过AF数据接口AF_DataRequest()来发送数据。
网络管理ZStatus_t NLME_NetworkDiscoveryRequest( uint32 ScanChannels,byte ScanDuration );用来请求网络层发现邻居路由器。
在加入操作执行网络扫描前应该调用此函数。
扫描确认(结果)将以回调函数ZDO_NetworkDiscoveryConfirmCB()返回。
推荐用户使用ZDO_StartDevice()来代替此函数。
(除非你清楚的知道网络加入过程)ScanChannels -执行发现的通道,2.4GHz条件下只能使用通道11-26(0x07FFF800)ScanDuration -新网络启动前,每个通道被其他网络扫描的时间BEACON_ORDER_15_MSEC 0 15.36 millisecondsBEACON_ORDER_30_MSEC 1 30.72 millisecondsBEACON_ORDER_60_MSEC 2 61.44 millisecondsBEACON_ORDER_120_MSEC 3 122.88 millisecondsBEACON_ORDER_240_MSEC 4 245.76 millisecondsBEACON_ORDER_480_MSEC 5 491.52 millisecondsBEACON_ORDER_1_SECOND 6 983.04 millisecondsBEACON_ORDER_2_SECONDS 7 1966.08 millisecondsBEACON_ORDER_4_SECONDS 8 3932.16 millisecondsBEACON_ORDER_7_5_SECONDS 9 7864.32 milliseconds BEACON_ORDER_15_SECONDS 10 15728.64 milliseconds BEACON_ORDER_31_SECONDS 11 31457.28 milliseconds BEACON_ORDER_1_MINUTE 12 62914.58 millisecondsBEACON_ORDER_2_MINUTES 13 125829.12 milliseconds BEACON_ORDER_4_MINUTES 14 251658.24 milliseconds BEACON_ORDER_NO_BEACONS 15 No Beacons transmitted 返回值:ZStatus_t -ZComDef.h中定义的状态值ZStatus_t NLME_NwkDiscReq2( NLME_ScanFields_t* fields );用来请求网络层发现邻居路由器。
ZigBee 学习之1515——————ZStackZStack API 解读3应用框架(AF)应用框架层是应用道APS 层的OTA 数据接口。
此层也接收数据消息的终端多路复用器。
AF 为应用提供以下功能:•终端(Endpoint)管理•发送和接收数据哈哈,这里的函数应该就是我们经常要用到的函数了。
终端管理每个设备都是Zigbee 中的节点,每个节点有长地址和短地址,短地址被其他设备用来发送数据。
每个节点又241个终端(0保留,1-240可分配给应用)。
每个终端可以独立设置地址;当设备发送数据时必须指定目标设备的短地址和接收终端。
一个应用必须注册一个或多个终端用来接收或者发送数据。
简单描述符-SimpleDescriptionFormat_t每个终端都必须有一个Zigbee 简单描述。
这些描述对Zigbee 网络刻画了这个终端,其他设备可以询问这个终端以知道这个设备的类型。
typedef struct{byte EndPoint;uint16AppProfId;uint16AppDeviceId;byte AppDevVer:4;byte Reserved:4;//AF_V1_SUPPORT uses for AppFlags:4.byte AppNumInClusters;cId_t *pAppInClusterList;byte AppNumOutClusters;cId_t *pAppOutClusterList;}SimpleDescriptionFormat_t;EndPoint –终端号:1-240这是节点的子地址,用来接收数据AppProfId –定义了这个终端上支持的Profile ID(剖面ID),ID 最好遵循由ZigBee 联盟的分配。
AppDeviceId –终端支持的设备ID,ID 最好遵循ZigBee 联盟的分配。
AppDevVer –此终端上设备执行的设备描述的版本:0x00为Version 1.0.Reserved –保留AppNumInClusters –终端支持的输入簇数目pAppInClusterList –指向输入Cluster ID 列表的指针AppNumOutClusters –终端支持的输出簇数目pAppOutClusterList –指向输出Cluster ID 列表的指针终端描述符-endPointDesc_t节点中的每一个终端都必须有一个终端描述符typedef struct{byte endPoint;byte *task_id;//Pointer to location of the Application task ID.SimpleDescriptionFormat_t*simpleDesc;afNetworkLatencyReq_t latencyReq;}endPointDesc_t;task_id-任务ID指针,当接收到消息时,此任务ID将指示消息传递目的。
Zigbee协议栈的使用流程1. 什么是Zigbee协议栈Zigbee协议栈是一种基于IEEE 802.15.4标准的低功耗、自组织的无线通信协议。
它被广泛应用于物联网设备、智能家居、工业自动化等领域。
Zigbee协议栈提供了一套完整的网络协议和通信机制,方便开发者在无线传感器网络中进行通信和数据交换。
2. Zigbee协议栈的使用流程Zigbee协议栈的使用流程可以分为以下几个步骤:步骤一:选择Zigbee协议栈在开始使用Zigbee协议栈之前,首先需要选择合适的Zigbee协议栈。
目前市面上有许多不同的Zigbee协议栈提供商,可以根据自己的需求选择适合的协议栈。
步骤二:准备开发环境在开始使用Zigbee协议栈之前,需要准备好相应的开发环境。
这包括硬件设备、开发工具以及相应的驱动程序。
一般来说,开发者需要购买Zigbee芯片和开发板,并安装相应的开发工具和驱动程序。
步骤三:编写应用程序一旦准备好开发环境,就可以开始编写Zigbee应用程序了。
首先,需要了解Zigbee协议栈的API和接口,理解Zigbee网络的特点和通信机制。
然后,根据具体需求,设计和实现相应的功能模块,例如网络配置、数据传输和安全性等。
步骤四:测试和调试编写完应用程序后,需要进行测试和调试,以确保程序的正确性和稳定性。
可以通过模拟器或者实际的Zigbee设备进行测试。
测试过程中需要注意检查网络连接、数据传输和异常情况处理等方面的功能。
步骤五:部署和运行在完成测试和调试后,就可以将应用程序部署到真实的Zigbee设备上了。
根据具体的部署场景,可能需要进行设备安装、网络配置和数据监控等工作。
一旦部署完成,就可以正式运行Zigbee协议栈,并进行数据交换和通信了。
3. 使用Zigbee协议栈的注意事项在使用Zigbee协议栈的过程中,需要注意以下几个方面:•理解Zigbee网络的拓扑结构和层次关系,合理设计网络拓扑和路由规划。
•注意设备之间的信号强度和信号干扰的问题,确保通信质量和稳定性。
从零开始学习Zstack之1magicchip 发表于2008-9-3 10:37:00首先介绍下本人技术背景:我是一名正宗的销售人员,虽然之前搞过几天技术,但是早就忘到老远了。
不过还是有点单片机和C 语言的基础,而且对ZigBee已经有初步了解。
怎么也弄过几天,加上本人天资聪颖,几天顶一般人几年,所以…………….,一句话:本人技术背景很复杂!再来说下写这些的目的:1、作为一名销售员,而且是针对技术性的产品的销售,我接触的99.99999……%都是技术人员,即使偶尔解除采购的,也是技术人员选好型让他购买的。
所以不怎么懂技术的我,在销售中真是困难重重,为了更好的支撑我的销售,所以决定学习下技术。
2、边学习边做笔记是我一向的坏习惯,但是以前用的都是圆珠笔,现在不是都提倡无纸办公的嘛,所以本人已经N久没有买过本子了,笔就只有办公室里有(因为平时销售也得做记录的)。
加上我遇到很多初学的客户拿到系统之后也是一头雾水,所以一开始学这个我就打算做好详细的记录,以便与前辈们交流共享。
3、那就是网上很流传某某笔记的嘛,呵呵!我也想出过小名!4、就是在家闲着也是闲着,不如做点稍稍有意义的事5、本人最近弄了个网站,还请同行多多关照。
上面的内容太空洞,想到网站上搜索点文章放上去吧,又觉得有悖初衷,不如自己写点东西放上去,反正是我的网站我做主嘛,即使错了也不至于向别的论坛上遭到群愤,我的地方哪个敢??哈哈!!6、………………………….废话是不是太多了!没办法,搞销售的就这样,交际第一条就是废话嘛!Zstack情况:本人采用的是TI的Zstack1.4.3协议,据说这个需要IAR7.30B及以上版本,而目前市面上又没有破解,所以用的人很少,这也是我的机会!呵呵!(傻笑有点多,关键是WORD里没有表情符号,不能正常表达我此时的心情!)正式开始:开始之前在说一句:从TI网站上下载的Zstack的方法就不介绍了。
否则就是从-1开始了而不是从0开始了-----------------我是这么觉得的!第一步:安装Zstack从TI官方网站上下载的Zstack为:swrc072c.zip,我想这个压缩包大家都认识。
ZigBee模块产品数据手册广州星博信息技术有限公司Guangzhou Great Symbol Information Technology Co.,Ltd一、概述ZigBeee模块分为基本型和增强,增强型/基本型模块开放了许多外设端口,两个模块的引脚完全兼容,可以通过SDK对模块进行配置后,使用其相应的外设端口,实现数据的采集、外部设备的控制等,其上面有一个天线接口,用于外接天线。
增强型模块和基本型模块开放的外设端口有:基本型模组(1)1个串行通信接口(UART)(2)4个模拟量输入通道(ADC)(3)14个含复用的通用数字输入输出口(GPIO),不复用ADC/UART时最大为8个(复用:不使用UART/ADC功能时,所有IO可配置成GPIO)●增强型模组(1)42个含复用的通用数字输入输出口(GPIO),不复用ADC /DAC/ UART/ SPI/I2C/ CAN功能引脚时最大为9个(2)3个串行外设接口(SPI),其中1个复用ADC(3)2个内部集成总线接口(I2C),其中1个复用UART(4)1个工业现场总线接口(CAN)(5)4个串行通信接口(UART),其中1个复用I2C(6)12个模拟量输入通道(ADC),其中2个复用DAC,3个复用SPI(7)2个模拟量输出通道(DAC)(8)8个16位同步定时器二、产品特性●基本型模组◆尺寸:PCB贴片封装38.6*23.2*3mm◆重量:约3g◆电源:2V-3.6V 典型值:3.3V◆模块总功耗:A无线模块不工作时平均功耗12-13.5mWB无线模块工作时平均功耗97-121mWC无线模块工作时峰值功耗105-138mW◆天线功率:4dBm◆接收灵敏度:-97dBm◆电流:工作电流小于45mA ,待机电流小于1mA◆工作频率: 2.4G ISM频段◆环境温度:-20~75℃◆无线传输距离:200-250m(外接5dB鞭状天线),300-400m(外接9dB鞭状天线) 注:无线传输的距离测试时环境为:内部增益设定为4dB,空旷的环境下测出的直线距离,中间没有障碍物。
ZigBee学习之14——ZStack API解读2ZDO邦定API绑定机制允许一个应用服务在不知道目标地址的情况下向对方(的应用服务)发送数据包。
发送时使用的目标地址将由应用支持子层从绑定表中自动获得,从而能使消息顺利被目标节点的一个或多个应用服务,乃至分组接收。
由于所有邦定信息都在Zigbee协调器中,所以只有协调器才能接收邦定请求。
ZDO Binding API ZDP Binding Service CommandZDP_EndDeviceBindReq() End_Device_Bind_reqZDP_EndDeviceBindRsp() End_Device_Bind_rspZDP_BindReq() Bind_reqZDP_BindRsp() Bind_rspZDP_UnbindReq() Unbind_reqZDP_UnbindRsp() Unbind_rspafStatus_t ZDP_EndDeviceBindReq( zAddrType_t *dstAddr,uint16 LocalCoordinator, byte epIntf,uint16 ProfileID,byte NumInClusters, byte *InClusterList,byte NumOutClusters, byte *OutClusterList,byte SecuritySuite );构建并发送节点设备邦定请求(Hand Bingding)。
LocalCoordinator - 设备父协调器的16位网络地址NumInClusters - 输入簇中的cluster ID数目InClusterList - 输入cluster IDs的数组afStatus_t ZDP_EndDeviceBindRsp( byte TranSeq, zAddrType_t *dstAddr,byte Status, byte SecurityEnable );Status - SUCCESS 0NOT_SUPPORTED 1TIMEOUT 2NO_MATCH 3afStatus_t ZDP_BindReq( zAddrType_t *dstAddr, byte *SourceAddr,byte SrcEPIntf, byte ClusterID, byte *DestinationAddr, byte DstEPI ntf,byte SecuritySuite );请求协调器利用cluster ID邦定应用ClusterID –要邦定的cluster IDDestinationAddr –接收消息的设备的64位地址afStatus_t ZDP_BindRsp( byte TranSeq, zAddrType_t *dstAddr,byte Status, byte Securi tyEnable );Status - SUCCESS 0NOT_SUPPORTED 1TABLE_FULL 2afStatus_t ZDP_UnbindReq( zAddrType_t *dstAddr,byte *SourceAddr, byte SrcEPIntf,byte ClusterID,byte *DestinationAddr, byte DstEPIntf,byte SecuritySuite );请求Zigbee协调器移除邦定。
JennicTECHNOLOGY FOR A CHANGING WORLDIntegrated Peripherals APIReference ManualJN-RM-2001Revision 2.318-Jun-2007JennicImportant NoticeJennic reserves the right to make corrections, modifications, enhancements, improvements and other changes to its products and services at any time, and to discontinue any product or service without notice. Customers should obtain the latest relevant information before placing orders, and should verify that such information is current and complete. All products are sold subject to Jennic’s terms and conditions of sale, supplied at the time of order acknowledgment. Information relating to device applications, and the like, is intended as suggestion only and may be superseded by updates. It is the customer’s responsibility to ensure that their application meets their own specifications. Jennic makes no representation and gives no warranty relating to advice, support or customer product design.Jennic assumes no responsibility or liability for the use of any of its products, conveys no license or title under any patent, copyright or mask work rights to these products, and makes no representations or warranties that these products are free from patent, copyright or mask work infringement, unless otherwise specified.Jennic products are not intended for use in life support systems/appliances or any systems where product malfunction can reasonably be expected to result in personal injury, death, severe property damage or environmental damage. Jennic customers using or selling Jennic products for use in such applications do so at their own risk and agree to fully indemnify Jennic for any damages resulting from such use.All trademarks are the property of their respective owners.2 © Jennic 2007 JN-RM-2001 (v2.3) 18-Jun-2007JennicContentsImportant Notice 2 Contents 3 About this Manual 7 Organisation 7 Conventions 7 Definitions, Acronyms and Abbreviations 81 Introduction 9 1.1 Scope 9readership 91.2 Intended2 API Description 10 2.1 General 10 2.1.1 u32AHI_Init 10Handling 10 2.2 InterruptControl 13 2.3 System2.3.1 u8AHI_PowerStatus 13 2.3.2 vAHI_MemoryHold 14 2.3.3 vAHI_CpuDoze 14 2.3.4 vAHI_PowerDown 14 2.3.5 vAHI_Sleep (JN513x Only) 15 2.3.6 vAHI_ProtocolPower 15 2.3.7 vAppApiSetBoostMode (JN513x Only) 16 2.3.8 vAHI_HighPowerModuleEnable (JN513x Only) 16 2.3.9 vAHI_ExternalClockEnable (JN513x Only) 16 2.3.10 vAHI_AntennaDiversityOutputEnable (JN513x Only) 17 2.3.11 vAHI_SysCtrlRegisterCallback 17 2.3.12 vAHI_SwReset 17Timers 18 2.4 Wake2.4.1 vAHI_WakeTimerEnable 18 2.4.2 vAHI_WakeTimerStart 18 2.4.3 vAHI_WakeTimerStop 18 2.4.4 u8AHI_WakeTimerStatus 19 2.4.5 u32AHI_WakeTimerCalibrate 19 2.4.6 u8AHI_WakeTimerFiredStatus 19Peripherals 20 2.5 Analogue2.5.1 vAHI_ApConfigure 20 2.5.2 bAHI_APRegulatorEnabled 21 2.5.3 vAHI_APRegisterCallback 21 2.6 ADC 22 2.6.1 vAHI_AdcEnable 22 2.6.2 vAHI_AdcStartSample 22 2.6.3 bAHI_AdcPoll 23 2.6.4 u16AHI_AdcRead 23 2.6.5 vAHI_AdcDisable 23 2.7 DACs 24 2.7.1 vAHI_DacEnable 24 2.7.2 bAHI_DacPoll 24JN-RM-2001 (v2.3) 18-Jun-2007 © Jennic 2007 3Jennic2.7.3 vAHI_DacOutput 25 2.7.4 vAHI_DacDisable 25 2.8 Comparators 26 2.8.1 vAHI_CompEnable 26 2.8.2 vAHI_ComparatorEnable (JN513x Only) 27 2.8.3 vAHI_CompDisable 27 2.8.4 vAHI_CompIntEnable 28 2.8.5 vAHI_CompWakeEnable 28 2.8.6 u8AHI_CompStatus 28 2.8.7 u8AHI_CompWakeStatus 28 2.9 DIO 29 2.9.1 vAHI_DioSetDirection 29 2.9.2 vAHI_DioSetOutput 30 2.9.3 u32AHI_DioReadInput 30 2.9.4 u8AHI_DioSetByte 30 2.9.5 u8AHI_DioReadByte 31 2.9.6 vAHI_DioSetPullup 31 2.9.7 vAHI_DioInterruptEdge 31 2.9.8 vAHI_DioInterruptEnable 32 2.9.9 u32AHI_DioInterruptStatus 32 2.10 UARTs 33 2.10.1 vAHI_UartEnable 33 2.10.2 vAHI_UartDisable 34 2.10.3 vAHI_UartSetClockDivisor 34 2.10.4 vAHI_UartSetBaudDivisor 34 2.10.5 vAHI_UartSetControl 35 2.10.6 vAHI_UartSetInterrupt 36 2.10.7 vAHI_UartSetRTSCTS (JN513x Only) 36 2.10.8 vAHI_UartReset 37 2.10.9 u8AHI_UartReadLineStatus 37 2.10.10 u8AHI_UartReadModemStatus 38 2.10.11 u8AHI_UartReadInterruptStatus 38 2.10.12 vAHI_UartWriteData 38 2.10.13 u8AHI_UartReadData 39 2.10.14 vAHI_Uart0RegisterCallback 39 2.10.15 vAHI_Uart1RegisterCallback 39 2.11 Timers 40 2.11.1 vAHI_TimerEnable 40 2.11.2 vAHI_TimerClockSelect 41 2.11.3 vAHI_TimerStartSingleShot 41 2.11.4 vAHI_TimerStartRepeat 42 2.11.5 vAHI_TimerStartDeltaSigma 42 2.11.6 vAHI_TimerStartCapture 43 2.11.7 vAHI_TimerReadCapture 43 2.11.8 vAHI_TimerStop 43 2.11.9 vAHI_TimerDisable 44Only) 44(JN513x2.11.10 vAHI_TimerDIOControl2.11.11 u8AHI_TimerFired 44 2.11.12 vAHI_Timer0RegisterCallback 45 2.11.13 vAHI_Timer1RegisterCallback 45 2.12 Tick Timer 464 © Jennic 2007 JN-RM-2001 (v2.3) 18-Jun-2007Jennic 2.12.1 vAHI_TickTimerInit 46 2.12.2 vAHI_TickTimerWrite 46 2.12.3 vAHI_TickTimerIntPendClr 46 2.12.4 bAHI_TickTimerIntStatus 46 2.12.5 vAHI_TickTimerConfigure 47 2.12.6 vAHI_TickTimerIntEnable 47 2.12.7 u32AHI_TickTimerRead 47 2.12.8 vAHI_TickTimerInterval 47 2.13 Serial Peripheral Interface 48 2.13.1 vAHI_SpiConfigure 48 2.13.2 vAHI_SpiReadConfiguration 49 2.13.3 vAHI_SpiRestoreConfiguration 49 2.13.4 vAHI_SpiSelect 49 2.13.5 vAHI_SpiStop 50 2.13.6 vAHI_SpiStartTransfer32 50 2.13.7 u32AHI_SpiReadTransfer32 50 2.13.8 vAHI_SpiStartTransfer16 50 2.13.9 u16AHI_SpiReadTransfer16 51 2.13.10 vAHI_SpiStartTransfer8 51 2.13.11 u8AHI_SpiReadTransfer8 51 2.13.12 bAHI_SpiPollBusy 51 2.13.13 vAHI_SpiWaitBusy 52 2.13.14 vAHI_SpiRegisterCallback 52 2.14 Serial Interface (2 Wire) 53 2.14.1 vAHI_SiConfigure 53 2.14.2 vAHI_SiSetCmdReg 54 2.14.3 vAHI_SiWriteData8 54 2.14.4 vAHI_SiWriteSlaveAddr 55 2.14.5 u8AHI_SiReadData8 55 2.14.6 bAHI_SiPollBusy 55 2.14.7 bAHI_SiPollTransferInProgress 55 2.14.8 bAHI_SiPollRxNack 56 2.14.9 bAHI_SiPollArbitrationLost 56 2.14.10 vAHI_SiRegisterCallback 56 2.15 Intelligent Peripheral Mode 57 2.15.1 vAHI_IpEnable 57 2.15.2 bAHI_IpSendData 57 2.15.3 bAHI_IpReadData 58 2.15.4 bAHI_IpTxDone 58 2.15.5 bAHI_IpRxDataAvailable 58 2.15.6 vAHI_IpRegisterCallback 58 2.16 Flash 59 2.16.1 bAHI_FlashInit (JN513x Only) 59 2.16.2 bAHI_FlashErase 59 2.16.3 bAHI_FlashEraseSector (JN513x Only) 60 2.16.4 bAHI_FlashProgram 60 2.16.5 bAHI_FullFlashProgram (JN513x Only) 61 2.16.6 bAHI_FlashRead 61 2.16.7 bAHI_FullFlashRead (JN513x Only) 62 References 63 JN-RM-2001 (v2.3) 18-Jun-2007 © Jennic 2007 5Jennic6 © Jennic 2007 JN-RM-2001 (v2.3) 18-Jun-2007JennicAbout this ManualThis manual describes the software Application Programming Interface (API) to the peripheral devices on the JN5121 and JN513x single-chip IEEE 802.15.4 compliant wireless microcontrollers. This is known as the Integrated Peripherals API. It details the calls that may be made through the API in order to set up, control and respond to events generated by the peripheral blocks, such as UARTs, general-purpose IO lines and timers among others. Setting up and using power saving modes are also covered.The software invoked by this API is present in the on-chip ROM. This API does not include support for the IEEE 802.15.4 MAC hardware built into the device; this hardware is controlled using the MAC software stack that is built into the on-chip ROM. Readers are recommended to refer to [1] for further information on the use of this feature.Note 1: This manual was previously known as the Hardware Peripheral Library Reference Manual.Note 2: This manual covers both the JN5121 and JN513x versions of the Integrated Peripherals API. Some of the API functions described in this manual are for the JN513x only - these are clearly marked.OrganisationThis document consists of two chapters.• Chapter 1 gives a brief overview of the scope of the manual• Chapter 2 describes in detail the calls available to control each feature of the deviceConventionsCode fragments or function prototypes are represented by Courier typeface. When referringto constants or functions defined in the code they are emboldened, like so.JN-RM-2001 (v2.3) 18-Jun-2007 © Jennic 2007 7JennicDefinitions, Acronyms and AbbreviationsACL Access Control ListADC Analogue to Digital Converter AES Advanced Encryption Standard AHI Application Hardware Interface API Application Programming Interface CPU Central Processor Unit CTS Clear-To-Send DAC Digital to Analogue Converter DIO Digital Input OutputFIFO First-In, First-Out queue MAC Medium Access Control PAN Personal Area Network PIB PAN Information Base PWM Pulse Width Modulation RAM Random Access Memory RTS Ready-To-SendSPI Serial Peripheral InterfaceUARTUniversal Asynchronous Receiver Transmitter8 © Jennic 2007 JN-RM-2001 (v2.3) 18-Jun-2007Jennic 1 Introduction1.1 ScopeThis document describes the Application Programming Interface (API) for the JN5121/JN513x hardware peripherals – the Integrated Peripherals API. Its functionality is as follows: • System Controller• Wake timers• Analogue to digital converter (ADC)• Digital to analogue converters (DACs)• Comparators• Digital Input/Output (DIO)• Universal asynchronous receiver-transmitters (serial ports) (UARTs)• Timers• Serial Peripheral Interface (SPI)• Serial Interface (2 Wire)• Tick Timer• External FLASH memoryNote 1: This API was previously known as the Hardware Peripheral Library or the Hardware API.Note 2: This manual covers both the JN5121 and JN513x versions of the Integrated Peripherals API. Some of the API functions described in this manual are for the JN513x only - these are clearly marked.This API (sometimes referred to in this document as the AHI) provides a thin layer above the registers used to control the JN5121/JN513x peripherals, by encapsulating several register accesses into one function call and hence making it easier to use the peripherals without having to acquire detailed knowledge of their operation.This document does not describe the Baseband Controller, Modem or Radio, as these are driven by the 802.15.4 Stack API, which is always provided with the JN5121 and JN513x devices. The 802.15.4 Stack API is described in [1].This document does not describe the API for features found on evaluation kit boards such as sensors or display panels, although the buttons and LEDs on the evaluation kit boards are connected to the GPIO pins on the JN5121/JN513x chip. The API for evaluation kit board features is described in [2].1.2 Intended readershipIt is assumed that the reader has a reasonable knowledge of ‘C’ programming.JN-RM-2001 (v2.3) 18-Jun-2007 © Jennic 2007 9Jennic2 API DescriptionThe API is described in terms of the functions it provides, and these are grouped by peripheral.The functions are defined in AppHardwareApi.h.Note: There are small differences in the Integrated Peripherals API for the JN5121 and JN513x chips. Some API functions are for the JN513x only - these are clearly marked in the section headings.2.1 General2.1.1 u32AHI_InitDeclaration PUBLIC uint32 u32AHI_Init(void);Inputs NoneOutputs 0 if initialisation failed, otherwise a 32-bit version number (most significant 16 bits are main revision, least significant 16 bits are minor revision)Description Used to initialise the AHI. This should be called after every reset or wake-up and before any other AHI calls are made. Note that the application API should havebeen initialised before this function is called, and the call to initialise theapplication API includes a parameter to register a function to call whenever aninterrupt from the peripherals occurs, see following section for details.2.2 Interrupt HandlingInterrupts from peripheral devices are handled by a set of device-specific callbacks. These canbe set within the Integrated Peripherals API by using the appropriate callback registrationroutines. For example the user can write their own UART interrupt handler and then register this routine using the vAHI_Uart0RegisterCallback function. All device-specific callback functions registered must have the following prototype:PRIVATE void vHwDeviceIntCallback(uint32 u32DeviceId, uint32 u32ItemBitmap)The device ID, u32DeviceId, is an enumerated value indicating the peripheral that generatedthe interrupt, as follows:Enumeration Interrupt Source Callback registration functionE_AHI_DEVICE_TICK_TIMER Tick Timer vAHI_TickTimerInitcontroller vAHI_SysCtrlRegisterCallback E_AHI_DEVICE_SYSCTRL SystemE_AHI_DEVICE_AES Encryption engine See JN-RM-2013-AES-Coprocessor-APIE_AHI_DEVICE_UART0 UART 0 vAHI_Uart0RegisterCallbackE_AHI_DEVICE_UART1 UART 1 vAHI_Uart1RegisterCallbackE_AHI_DEVICE_TIMER0 Timer 0 vAHI_Timer0RegisterCallbackE_AHI_DEVICE_TIMER1 Timer 1 vAHI_Timer1RegisterCallbackmaster vAHI_SpiRegisterCallback E_AHI_DEVICE_SPIM SPI10 © Jennic 2007 JN-RM-2001 (v2.3) 18-Jun-2007E_AHI_DEVICE_SI Serial Interface (2 wire) vAHI_SiRegisterCallbackvAHI_IpRegisterCallbackperipheralE_AHI_DEVICE_INTPER Intelligentperipherals vAHI_APRegisterCallbackE_AHI_DEVICE_ANALOGUE AnalogueThe item u32ItemBitmap is an enumerated value indicating the individual interrupt sourcewithin the peripheral, as described in the tables below.Before calling the callback function, the library clears the source of the interrupt, so there is no danger of the same interrupt causing the processor to enter a state of permanently trying to handle the same interrupt due to a malformed callback function. This also means that it is possible to have a NULL callback function.The UARTs are the exception to this rule; when generating a ‘receive data available’ or ‘timeout indication’ interrupt, the UARTs will only clear the interrupt when the data is read from the UART receive buffer. It is therefore vital that if UART interrupts are to be enabled, the callback function handles the ‘receive data available’ and ‘timeout indication’ interrupts by reading the data from the UART before returning.Note that if the Application Queue API is being used, the issue with UART interrupts is handled by the API, so the application does not have to cope with it. See [3] for more information about the Application Queue API.The enumerated values are defined as follows:TickTimerMask (Bit) Description0 Single source for Tick Timer interrupt, therefore returns 1 every time System ControllerMask (Bit) DescriptionE_AHI_SYSCTRL_COMP_MASK (29) Comparator eventsWake Timer eventsE_AHI_SYSCTRL_WK1_MASK (27)E_AHI_SYSCTRL_WK0_MASK (26)Digital IO eventsE_AHI_DIO20_INT (20)E_AHI_DIO19_INT (19)E_AHI_DIO18_INT (18)..E_AHI_DIO0_INT (0)UART (Identical for both UARTs)Enumerated Value DescriptionE_AHI_UART_TIMEOUT_MASK (6) Timeout indicationE_AHI_UART_RXLINE_MASK (3) Receive line statusE_AHI_UART_RXDATA_MASK (2) Receive data availableE_AHI_UART_TX_MASK (1) Transmit FIFO emptyE_AHI_UART_MODEM_MASK (0) Modem statusTimers (Identical for both timers)Mask (Bit) DescriptionE_AHI_TIMER_RISE_MASK (1) Interrupt status, generated on timer rising edge, end of low period - will benon-zero if interrupt for timer output going high has been setE_AHI_TIMER_PERIOD_MASK (0) Interrupt status, generated on timer falling edge, end of period - will benon-zero if interrupt for timer period complete has been setSerial Interface (2-wire)Mask (Bit) DescriptionE_AHI_SI_RXACK_MASK (7) Asserted if no acknowledge is received from the addressed slaveE_AHI_SI_BUSY_MASK (6) Asserted if a START signal is detectedCleared if a STOP signal is detectedE_AHI_SI_AL_MASK (5) Asserted to indicate loss of arbitrationE_AHI_SI_ACK_CTRL_MASK (2) Acknowledge control:0 indicates sent ACK1 indicates sent NACKE_AHI_SI_TIP_MASK (1) Asserted to indicate transfer in progressE_AHI_SI_INT_STATUS_MASK (0) Interrupt status; interrupt indicates loss of arbitration or that byte transferhas completedSPI MasterMask (Bit) DescriptionE_AHI_SPIM_TX_MASK (1) Asserted to indicate transfer has completedIntelligent PeripheralMask (Bit) DescriptionE_AHI_IP_INT_STATUS_MASK (6) Asserted to indicate transaction has completed, i.e slave select goes highand TXGO or RXGO has gone lowE_AHI_IP_TXGO_MASK (1) Asserted when TX data is copied to the internal buffer and cleared when ithas been sent out.E_AHI_IP_RXGO_MASK (0) Asserted when device is ready to receive state and cleared when data RXis complete.Analogue PeripheralsMask (Bit) DescriptionE_AHI_AP_INT_STATUS_MASK (0) Asserted to indicate capture complete or new sample ready2.3 System ControlThe system controller provides control for the CPU and memory power and sleep operation. There are two significant blocks in the system controller. The 32kHz domain runs from a simple oscillator and is designed for very low power sleep states. Whilst sleeping, the CPU does not run and relies on an interrupt to wake it up. The interrupt can be generated externally or from within the 32kHz domain. Later sections describe the ways in which interrupts can be generated within the chip, using the wake timers to generate events within the 32kHz domain or the DIO pins for external stimuli.The 16MHz domain is used to run the CPU and several peripherals (security engine, ADC,timing accuracy.device powers up. The RAM is powered by its own regulator, separate from the regulator for the CPU. This allows the RAM to remain powered when the CPU is asleep and powered down. This is useful for short sleep periods, when the time taken to re-load the RAM from flash is significant when compared to the sleep time. Alternatively, for longer sleep periods, the memory power may be removed as well, reducing the sleep current consumption.In addition, there are two other power domains, one for analogue peripherals and the other (the protocol domain) for the modem, encryption coprocessor, radio and baseband controller. The analogue power domain is switched on if the analogue peripherals are in use.As well as the normal sleep mode, it is possible to enter a deep sleep. In this state both the16MHz and 32kHz clock domains are turned off and the device can only be woken by the device reset line being pulled low.A final low power mode is doze mode, in which the CPU remains powered but the 16MHz clock to it is stopped. This uses more power than sleep mode but requires less time to restart. The CPU is brought out of doze mode by an interrupt (note that a tick timer interrupt cannot be used to bring the CPU out of doze mode).2.3.1 u8AHI_PowerStatusDeclaration PUBLIC uint8 u8AHI_PowerStatus(void);Inputs NoneOutputs uint8 containing power domain control settingsbit 0: 1 if chip has completed a sleep-wake up cyclebit 1: If 1 after wake up, memory contents were retained during sleepbit 2: 1 if analogue power domain is switched onbit 3: 1 if protocol power domain is switched onDescription Returns the power domain settings for the JN5121/JN513x, as described above.2.3.2 vAHI_MemoryHoldDeclaration PUBLIC void vAHI_MemoryHold(bool_t bHoldDuringSleep);Inputs bool_tbHoldDuringSleep TRUE to power memory during sleepFALSE to remove power from memory during sleepOutputs NoneDescription Determines whether the memory will remain powered during the next sleep period.2.3.3 vAHI_CpuDozeDeclaration PUBLIC void vAHI_CpuDoze(void);Inputs NoneOutputs NoneDescription Causes the CPU to stop operating until an interrupt occurs. The CPU clock will be disabled during sleep to minimise power consumption, although other modules willstill be operational. The function returns when the CPU re-starts.2.3.4 vAHI_PowerDownDeclaration PUBLIC void vAHI_PowerDown(bool_t bDeepNotNormalSleep);Inputs bool_tbDeepNotNormalSleep TRUE for the sleep to be deep sleep (device only awakes through a reset)FALSE for normal sleep (device wakes after interrupt or reset)Outputs NoneDescription Sends the device to sleep. In normal sleep mode, all parts of the device are inactive or powered down apart from the 32 kHz oscillator and those parts of thesystem controller used for wake up. In deep sleep, even these are powereddown. This function does not return. When the device restarts, it will beginprocessing at the reset vector.2.3.5 vAHI_Sleep (JN513x Only)Declaration PUBLIC void vAHI_Sleep(teAHI_SleepMode sSleepMode);Inputs teAHI_SleepModesSleepMode One of:E_AHI_SLEEP_OSCON_RAMON 32 kHz oscillator on and RAM onE_AHI_SLEEP_OSCON_RAMOFF 32 kHz oscillator on and RAM offE_AHI_SLEEP_OSCOFF_RAMON 32 kHz oscillator off and RAM onE_AHI_SLEEP_OSCOFF_RAMOFF 32 kHz oscillator off and RAM offE_AHI_SLEEP_DEEPDeep sleep (all components off)Outputs NoneDescription Sends the JN513x chip to sleep, allowing the 32 kHz oscillator and the RAM to be individually left on or switched off, as required. When in normal sleep mode, thedevice wakes after an interrupt or a reset. When in deep sleep mode, the devicewakes only after a reset. When the JN513x restarts, it will begin processing at thecold start or warm start entry point. This function does not return.2.3.6 vAHI_ProtocolPowerDeclaration PUBLIC void vAHI_ProtocolPower(bool_t bOnNotOff);Inputs bool_t bOnNotOff TRUE to turn the protocol power domain on.FALSE to turn the protocol power domain off. Outputs NoneDescription Controls the regulator that supplies the protocol domain (the radio, modem baseband and encryption coprocessor). If you intend to turn the protocol power offand then back on again without performing a reset, you must store the currentMAC settings before turning the protocol power off. You can save the MACsettings using the function vAppApiSaveMacSettings(). Turning the protocol powerback on can then be achieved simply by restoring the MAC settings using thefunction vAppApiRestoreMacSettings(). These functions are described in [1].While the protocol is powered down, you must not make any calls into the stack asthis may result in the stack trying to access the hardware (which is turned off) andtherefore a crash.2.3.7 vAppApiSetBoostMode (JN513x Only)Declaration PUBLIC void vAppApiSetBoostMode(bool_t bOnNotOff);Inputs bool_t bOnNotOff TRUE to enable boost mode.FALSE to disable boost mode (default setting). Outputs NoneDescription Enables or disables boost mode on a JN513x device – this increases the transmission power by approximately 3 dB (beware that this results in increasedcurrent consumption). A new setting only takes effect when the device isinitialised, so this function call must be followed by a call to either u32AppApiInit()or u32AppQApiInit(). The setting is maintained throughout sleep mode if memoryis held up, but is lost if memory is turned off.2.3.8 vAHI_HighPowerModuleEnable (JN513x Only)Declaration PUBLIC void vAHI_HighPowerModuleEnable(bool_t bRFTXEn,bool_t bRFRXEn);bool_t bRFTXEn TRUE to enable high power module transmitter InputsFALSE to disable high power module transmitter bool_t bRFRXEn TRUE to enable high power module receiverFALSE to disable high power module receiver Outputs NoneDescription Allows the transmitter and receiver sections of a High-Power Module (HPM) to be individually enabled or disabled. Must be called before using radio on an HPM.2.3.9 vAHI_ExternalClockEnable (JN513x Only)Declaration PUBLIC void vAHI_HighPowerModuleEnable(bool_t bExClockEn);Inputs bool_t bExClockEn TRUE to enable external clock inputFALSE to disable external clock inputOutputs NoneDescription Enables the use of an external source for the 32 kHz clock.2.3.10 vAHI_AntennaDiversityOutputEnable (JN513x Only)Declaration PUBLIC void vAHI_AntennaDiversityOutputEnable(bool_t bOddRetryOutEn,bool_t bEvenRetryOutEn);bool_t bOddRetryOutEn TRUE to enable output on DIO12FALSE to disable output on DIO12Inputsbool_t bEvenRetryOutEn TRUE to enable output on DIO13FALSE to disable output on DIO13Outputs NoneDescription Supports the provision of an alternative antenna in case of a transmission failure.DIO12 and DIO13 are each associated with an antenna, and are used to indicatewhether a transmission retry on the corresponding antenna is required. When bothDIOs are enabled for this feature, DIO13 goes high for the first transmission. If noacknowledgement is received, the need for a first retry of the transmission isindicated by DIO12 going high (DIO13 goes low). If required, a second retry isindicated by DIO13 going high (DIO12 goes low). Subsequently, all odd numberedretries are requested using DIO12 and all even numbered retries are requestedusing DIO13. The application must choose the antenna for each retry accordingly.2.3.11 vAHI_SysCtrlRegisterCallbackDeclaration PUBLIC void vAHI_SysCtrlRegisterCallback(PR_HWINT_APPCALLBACK prSysCtrlCallback);Inputs PR_HWINT_APPCALLBACKprSysCtrlCallback Pointer to function that is to be called when a system control interrupt occurs.Outputs NoneDescription Registers an application callback that will be called when the system control interrupt (caused by wake timer, comparator and DIO events) is triggered.2.3.12 vAHI_SwResetDeclaration PUBLIC void vAHI_SwReset (void);Inputs NoneOutputs NoneDescription Generates an internal reset when called, which completely re-starts the system.2.4 Wake TimersThe wake timers are normally used to time sleep periods and can be programmed to generate interrupts when the timeout period has completed. However, they can also be used whilst the CPU is running. There is another set of timers with more functionality that can operate only whilst the CPU is running; see Section 2.11.The wake timers run at a nominal 32kHz but to minimise complexity and hence power consumption, they may run at up to 30% fast or slow depending on temperature, supply voltage and manufacturing tolerance. A self-calibration facility is provided to time the 32kHz clock against the 16MHz clock if accurate timing is required.2.4.1 vAHI_WakeTimerEnableDeclaration PUBLIC void vAHI_WakeTimerEnable(uint8 u8Timer,bool_t bIntEnable);uint8 u8Timer Timer identity:E_AHI_WAKE_TIMER_0 orE_AHI_WAKE_TIMER_1Inputsbool_t bIntEnable TRUE to enable interrupt when timer fires FALSE to disable interruptOutputs NoneDescription Prepares a wake timer for use, enabling the associated interrupt if desired.2.4.2 vAHI_WakeTimerStartDeclaration PUBLIC void vAHI_WakeTimerStart(uint8 u8Timer, uint32 u32Count);uint8 u8Timer Timer identity:E_AHI_WAKE_TIMER_0 orE_AHI_WAKE_TIMER_1Inputsuint32 u32Count Count time in 32kHz periods, i.e. 32 is 1 millisecond Outputs NoneDescription Starts a wake timer to time for the specified interval.2.4.3 vAHI_WakeTimerStopDeclaration PUBLIC void vAHI_WakeTimerStop(uint8 u8Timer);Inputs uint8 u8Timer Timer identity:E_AHI_WAKE_TIMER_0 orE_AHI_WAKE_TIMER_1Outputs NoneDescription Stops a wake timer. No interrupt will be generated.2.4.4 u8AHI_WakeTimerStatusDeclaration PUBLIC uint8 u8AHI_WakeTimerStatus(void);Inputs NoneOutputs uint8 Bitmap:Returned value logical ANDed with E_AHI_WAKE_TIMER_MASK_0 will benon-zero if wake timer 0 is runningReturned value logical ANDed with E_AHI_WAKE_TIMER_MASK_1 will benon-zero if wake timer 1 is runningDescription Returns a bitmap where the relevant bits are set to show which timers are active.It is possible to have more than one timer active at once. Note that a timer remainsactive after the timed interval has completed.2.4.5 u32AHI_WakeTimerCalibrateDeclaration PUBLIC uint32 u32AHI_WakeTimerCalibrate(void);Inputs NoneOutputs uint32 Returned value shows the calibration offset from the ideal, measuredagainst the 16MHz clock. The ideal result would be 10000 decimal. Alower value means that the 32kHz clock is running fast and a highervalue means it is running slow.Description Performs a calibration of the 32kHz clock against the more accurate 16MHz clock.The returned value can be used to adjust the time interval values used to programthe wake timers.Note that the 32kHz clock has a tolerance of +/-30%.2.4.6 u8AHI_WakeTimerFiredStatusDeclaration PUBLIC uint8 u8AHI_WakeTimerFiredStatus(void);Inputs NoneOutputs uint8 Bitmap:Returned value logical ANDed with E_AHI_WAKE_TIMER_MASK_0 will benon-zero if wake timer 0 has firedReturned value logical ANDed with E_AHI_WAKE_TIMER_MASK_1 will benon-zero if wake timer 1 has firedDescription Returns a bitmap where the relevant bits are set to show which timers have fired.Any fired timer status is cleared as a result of this call.。