Zigbee协议的API接口函数手册剖析.docx
《Zigbee协议的API接口函数手册剖析.docx》由会员分享,可在线阅读,更多相关《Zigbee协议的API接口函数手册剖析.docx(56页珍藏版)》请在冰点文库上搜索。
Zigbee协议的API接口函数手册剖析
JennicTECHNOLOGYFORACHANGINGWORLD
IntegratedPeripheralsAPIReferenceManual
JN-RM-2001Revision2.318-Jun-2007
Jennic
ImportantNotice
Jennicreservestherighttomakecorrections,modifications,enhancements,improvementsandotherchangestoitsproductsandservicesatanytime,andtodiscontinueanyproductorservicewithoutnotice.Customersshouldobtainthelatestrelevantinformationbeforeplacingorders,andshouldverifythatsuchinformationiscurrentandcomplete.AllproductsaresoldsubjecttoJennic’stermsandconditionsofsale,suppliedatthetimeoforderacknowledgment.Informationrelatingtodeviceapplications,andthelike,isintendedassuggestiononlyandmaybesupersededbyupdates.Itisthecustomer’sresponsibilitytoensurethattheirapplicationmeetstheirownspecifications.Jennicmakesnorepresentationandgivesnowarrantyrelatingtoadvice,supportorcustomerproductdesign.
Jennicassumesnoresponsibilityorliabilityfortheuseofanyofitsproducts,conveysnolicenseortitleunderanypatent,copyrightormaskworkrightstotheseproducts,andmakesnorepresentationsorwarrantiesthattheseproductsarefreefrompatent,copyrightormaskworkinfringement,unlessotherwisespecified.
Jennicproductsarenotintendedforuseinlifesupportsystems/appliancesoranysystemswhereproductmalfunctioncanreasonablybeexpectedtoresultinpersonalinjury,death,severepropertydamageorenvironmentaldamage.JenniccustomersusingorsellingJennicproductsforuseinsuchapplicationsdosoattheirownriskandagreetofullyindemnifyJennicforanydamagesresultingfromsuchuse.
Alltrademarksarethepropertyoftheirrespectiveowners.
2©Jennic2007JN-RM-2001(v2.318-Jun-2007
Jennic
Contents
ImportantNotice2Contents3AboutthisManual7Organisation7Conventions7Definitions,AcronymsandAbbreviations8
1Introduction91.1Scope91.2Intended
readership92APIDescription102.1General102.1.1u32AHI_Init102.2Interrupt
Handling102.3System
Control132.3.1u8AHI_PowerStatus132.3.2vAHI_MemoryHold142.3.3vAHI_CpuDoze142.3.4vAHI_PowerDown142.3.5vAHI_Sleep(JN513xOnly152.3.6vAHI_ProtocolPower152.3.7vAppApiSetBoostMode(JN513xOnly162.3.8vAHI_HighPowerModuleEnable(JN513xOnly162.3.9vAHI_ExternalClockEnable(JN513xOnly162.3.10vAHI_AntennaDiversityOutputEnable(JN513xOnly172.3.11vAHI_SysCtrlRegisterCallback172.3.12vAHI_SwReset172.4Wake
Timers182.4.1vAHI_WakeTimerEnable182.4.2vAHI_WakeTimerStart182.4.3vAHI_WakeTimerStop182.4.4u8AHI_WakeTimerStatus192.4.5u32AHI_WakeTimerCalibrate192.4.6u8AHI_WakeTimerFiredStatus192.5Analogue
Peripherals202.5.1vAHI_ApConfigure202.5.2bAHI_APRegulatorEnabled212.5.3vAHI_APRegisterCallback212.6ADC222.6.1vAHI_AdcEnable222.6.2vAHI_AdcStartSample222.6.3bAHI_AdcPoll232.6.4u16AHI_AdcRead232.6.5vAHI_AdcDisable232.7DACs242.7.1vAHI_DacEnable242.7.2bAHI_DacPoll24
JN-RM-2001(v2.318-Jun-2007©Jennic20073
Jennic
2.7.3vAHI_DacOutput252.7.4vAHI_DacDisable252.8Comparators262.8.1vAHI_CompEnable262.8.2vAHI_ComparatorEnable(JN513xOnly272.8.3vAHI_CompDisable272.8.4vAHI_CompIntEnable282.8.5vAHI_CompWakeEnable282.8.6u8AHI_CompStatus282.8.7u8AHI_CompWakeStatus282.9DIO292.9.1vAHI_DioSetDirection292.9.2vAHI_DioSetOutput302.9.3u32AHI_DioReadInput302.9.4u8AHI_DioSetByte302.9.5u8AHI_DioReadByte312.9.6vAHI_DioSetPullup312.9.7vAHI_DioInterruptEdge312.9.8vAHI_DioInterruptEnable322.9.9u32AHI_DioInterruptStatus322.10UARTs332.10.1vAHI_UartEnable332.10.2vAHI_UartDisable342.10.3vAHI_UartSetClockDivisor342.10.4vAHI_UartSetBaudDivisor342.10.5vAHI_UartSetControl352.10.6vAHI_UartSetInterrupt362.10.7vAHI_UartSetRTSCTS(JN513xOnly362.10.8vAHI_UartReset372.10.9u8AHI_UartReadLineStatus372.10.10u8AHI_UartReadModemStatus382.10.11u8AHI_UartReadInterruptStatus382.10.12vAHI_UartWriteData382.10.13u8AHI_UartReadData392.10.14vAHI_Uart0RegisterCallback392.10.15vAHI_Uart1RegisterCallback392.11Timers402.11.1vAHI_TimerEnable402.11.2vAHI_TimerClockSelect412.11.3vAHI_TimerStartSingleShot412.11.4vAHI_TimerStartRepeat422.11.5vAHI_TimerStartDeltaSigma422.11.6vAHI_TimerStartCapture432.11.7vAHI_TimerReadCapture432.11.8vAHI_TimerStop432.11.9vAHI_TimerDisable442.11.10vAHI_TimerDIOControl
(JN513x
Only442.11.11u8AHI_TimerFired442.11.12vAHI_Timer0RegisterCallback452.11.13vAHI_Timer1RegisterCallback452.12TickTimer46
4©Jennic2007JN-RM-2001(v2.318-Jun-2007
Jennic2.12.1vAHI_TickTimerInit462.12.2vAHI_TickTimerWrite462.12.3vAHI_TickTimerIntPendClr462.12.4bAHI_TickTimerIntStatus462.12.5vAHI_TickTimerConfigure472.12.6vAHI_TickTimerIntEnable472.12.7u32AHI_TickTimerRead472.12.8vAHI_TickTimerInterval472.13SerialPeripheralInterface482.13.1vAHI_SpiConfigure482.13.2vAHI_SpiReadConfiguration492.13.3vAHI_SpiRestoreConfiguration492.13.4vAHI_SpiSelect492.13.5vAHI_SpiStop502.13.6vAHI_SpiStartTransfer32502.13.7u32AHI_SpiReadTransfer32502.13.8vAHI_SpiStartTransfer16502.13.9u16AHI_SpiReadTransfer16512.13.10vAHI_SpiStartTransfer8512.13.11u8AHI_SpiReadTransfer8512.13.12bAHI_SpiPollBusy512.13.13vAHI_SpiWaitBusy522.13.14vAHI_SpiRegisterCallback522.14SerialInterface(2Wire532.14.1vAHI_SiConfigure532.14.2vAHI_SiSetCmdReg542.14.3vAHI_SiWriteData8542.14.4vAHI_SiWriteSlaveAddr552.14.5u8AHI_SiReadData8552.14.6bAHI_SiPollBusy552.14.7bAHI_SiPollTransferInProgress552.14.8bAHI_SiPollRxNack562.14.9bAHI_SiPollArbitrationLost562.14.10vAHI_SiRegisterCallback562.15IntelligentPeripheralMode572.15.1vAHI_IpEnable572.15.2bAHI_IpSendData572.15.3bAHI_IpReadData582.15.4bAHI_IpTxDone582.15.5bAHI_IpRxDataAvailable582.15.6vAHI_IpRegisterCallback582.16Flash592.16.1bAHI_FlashInit(JN513xOnly592.16.2bAHI_FlashErase592.16.3bAHI_FlashEraseSector(JN513xOnly602.16.4bAHI_FlashProgram602.16.5bAHI_FullFlashProgram(JN513xOnly612.16.6bAHI_FlashRead612.16.7bAHI_FullFlashRead(JN513xOnly62References63JN-RM-2001(v2.318-Jun-2007©Jennic20075
Jennic
6©Jennic2007JN-RM-2001(v2.318-Jun-2007
Jennic
AboutthisManual
ThismanualdescribesthesoftwareApplicationProgrammingInterface(APItotheperipheraldevicesontheJN5121andJN513xsingle-chipIEEE802.15.4compliantwirelessmicrocontrollers.ThisisknownastheIntegratedPeripheralsAPI.ItdetailsthecallsthatmaybemadethroughtheAPIinordertosetup,controlandrespondtoeventsgeneratedbytheperipheralblocks,suchasUARTs,general-purposeIOlinesandtimersamongothers.Settingupandusingpowersavingmodesarealsocovered.
ThesoftwareinvokedbythisAPIispresentintheon-chipROM.ThisAPIdoesnotincludesupportfortheIEEE802.15.4MAChardwarebuiltintothedevice;thishardwareiscontrolledusingtheMACsoftwarestackthatisbuiltintotheon-chipROM.Readersarerecommendedtoreferto[1]forfurtherinformationontheuseofthisfeature.
Note1:
ThismanualwaspreviouslyknownastheHardwarePeripheralLibraryReferenceManual.
Note2:
ThismanualcoversboththeJN5121andJN513xversionsoftheIntegratedPeripheralsAPI.SomeoftheAPIfunctionsdescribedinthismanualarefortheJN513xonly-theseareclearlymarked.
Organisation
Thisdocumentconsistsoftwochapters.
•Chapter1givesabriefoverviewofthescopeofthemanual
•Chapter2describesindetailthecallsavailabletocontroleachfeatureofthedevice
Conventions
CodefragmentsorfunctionprototypesarerepresentedbyCouriertypeface.Whenreferringtoconstantsorfunctionsdefinedinthecodetheyareemboldened,likeso.
JN-RM-2001(v2.318-Jun-2007©Jennic20077
Jennic
Definitions,AcronymsandAbbreviations
ACLAccessControlList
ADCAnaloguetoDigitalConverterAESAdvancedEncryptionStandardAHIApplicationHardwareInterfaceAPIApplicationProgrammingInterfaceCPUCentralProcessorUnitCTSClear-To-SendDACDigitaltoAnalogueConverterDIODigitalInputOutput
FIFOFirst-In,First-OutqueueMACMediumAccessControlPANPersonalAreaNetworkPIBPANInformationBasePWMPulseWidthModulationRAMRandomAccessMemoryRTSReady-To-Send
SPISerialPeripheralInterface
UART
UniversalAsynchronousReceiverTransmitter
8©Jennic2007JN-RM-2001(v2.318-Jun-2007
Jennic1Introduction
1.1Scope
ThisdocumentdescribestheApplicationProgrammingInterface(APIfortheJN5121/JN513xhardwareperipherals–theIntegratedPeripheralsAPI.Itsfunctionalityisasfollows:
•SystemController
•Waketimers
•Analoguetodigitalconverter(ADC
•Digitaltoanalogueconverters(DACs
•Comparators
•DigitalInput/Output(DIO
•Universalasynchronousreceiver-transmitters(serialports(UARTs
•Timers
•SerialPeripheralInterface(SPI
•SerialInterface(2Wire
•TickTimer
•ExternalFLASHmemory
Note1:
ThisAPIwaspreviouslyknownastheHardwarePeripheralLibraryortheHardwareAPI.
Note2:
ThismanualcoversboththeJN5121andJN513xversionsoftheIntegratedPeripheralsAPI.SomeoftheAPIfunctionsdescribedinthismanualarefortheJN513xonly-theseareclearlymarked.
ThisAPI(sometimesreferredtointhisdocumentastheAHIprovidesathinlayerabovetheregistersusedtocontroltheJN5121/JN513xperipherals,byencapsulatingseveralregisteraccessesintoonefunctioncallandhencemakingiteasiertousetheperipheralswithouthavingtoacquiredetailedknowledgeoftheiroperation.
ThisdocumentdoesnotdescribetheBasebandController,ModemorRadio,asthesearedrivenbythe802.15.4StackAPI,whichisalwaysprovidedwiththeJN5121andJN513xdevices.The802.15.4StackAPIisdescribedin