亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? demozrfdapp.c

?? zbee potocol 無線通訊測試.平臺:microchip 18f452 與 cc2420 zbee 晶片.含coord端與rfd端
?? C
?? 第 1 頁 / 共 3 頁
字號:
/*********************************************************************
 *
 *                  Demo RFD App
 *
 *********************************************************************
 * FileName:        DemoZRFDApp.c
 * Dependencies:
 * Processor:       PIC18F
 * Complier:        MCC18 v2.30 or higher
 *                  HITECH PICC-18 V8.10PL1 or higher
 * Company:         Microchip Technology, Inc.
 *
 * Software License Agreement
 *
 * The software supplied herewith by Microchip Technology Incorporated
 * (the 揅ompany? for its PICmicro?Microcontroller is intended and
 * supplied to you, the Company抯 customer, for use solely and
 * exclusively on Microchip PICmicro Microcontroller products. The
 * software is owned by the Company and/or its supplier, and is
 * protected under applicable copyright laws. All rights are reserved.
 * Any use in violation of the foregoing restrictions may subject the
 * user to criminal sanctions under applicable laws, as well as to
 * civil liability for the breach of the terms and conditions of this
 * license.
 *
 * THIS SOFTWARE IS PROVIDED IN AN 揂S IS?CONDITION. NO WARRANTIES,
 * WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
 * TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
 * PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
 * IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
 * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
 *
 * HiTech PICC18 Compiler Options excluding device selection:
 *                  -FAKELOCAL -G -Zg -E -C
 *
 * Author               Date    Comment
 *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 * Nilesh Rajbharti     7/12/04 Rel 0.9
 * Nilesh Rajbharti     11/1/04 Pre-release version
 *******************************************************************/
// Uncomment ENABLE_DEBUG line to enable debug mode for this file.
// Or you may also globally enable debug by defining this macro
// in zigbee.h file or from compiler command-line.
#ifndef ENABLE_DEBUG
//#define ENABLE_DEBUG
#endif

#if defined(WIN32)
#include <stdio.h>
#endif

#include <string.h>
#include "zigbee.h"         // Zigbee defs
#include "Tick.h"           // Tick manager
#include "zAPL.h"           // APL layer functions
#include "Debug.h"          // For debug output support
#include "zdo.h"            // Required because of custom binding
                            // Don't need to include if not using demo custom
                            // binding
#include "zAPS.h"           // For EP operations defs

#include "S2OnEndDevice.h"
#include "D1OnEndDevice.h"
#include "LedOnEndDevice.h"

#if defined(WIN32)
    #include "physim.h"     // Not distributed.
#endif


// Switches and LEDs locations.
#define S2              RB5
#define S3              RB4

#define D1              LATA0
#define D2              LATA1

// This defines how LEDs will be blinked when unexpected RESET is detected.
#define FATAL_ERROR_BLINK_PERIOD    (1*TICK_SECOND)

// Configuration fuse bits.
// If other than 18F4620 device is used, you must define config values of your
// choice or set them via MPLAB interface.
#if defined(MCHP_C18) && defined(__18F4620)
    #pragma romdata CONFIG1H = 0x300001
    const rom unsigned char config1H = 0b00000110;      // HSPLL oscillator

    #pragma romdata CONFIG2L = 0x300002
    const rom unsigned char config2L = 0b00011111;      // PWRTEN disabled, BOR enabled in hardware @ 2.0V

    #pragma romdata CONFIG2H = 0x300003
    const rom unsigned char config2H = 0b00001110;      // HW WD disabled, 1:128 prescaler

    #pragma romdata CONFIG3H = 0x300005
    const rom unsigned char config3H = 0b10000001;      // PORTB digital on RESET

    #pragma romdata CONFIG4L = 0x300006
    const rom unsigned char config4L = 0b10000001;      // DEBUG disabled,
                                                        // XINST disabled
                                                        // LVP disabled
                                                        // STVREN enabled

    #pragma romdata

#elif defined(HITECH_C18) && defined(_18F4620)
    // Set configuration fuses for HITECH compiler.
    __CONFIG(1, 0x0600);    // HSPLL oscillator
    __CONFIG(2, 0x0E1F);    // PWRTEN disabled, HW WD disabled, 1:64 prescaler, BOR enabled in hardware @ 2.0V
    __CONFIG(3, 0x8100);    // PORTB digital on RESET
    __CONFIG(4, 0x0081);    // DEBUG disabled,
                            // XINST disabled
                            // LVP disabled
                            // STVREN enabled
#endif


#define STARTUP_MSG "ZigBee Demo RFD Application v1.0 (Microchip Stack for ZigBee v1.0.0)"

#if defined(ENABLE_DEBUG)
    #define BUILD_MODE  " (Debug Build)"
#else
    #define BUILD_MODE  " (Non-debug Build)"
#endif


// This menu is displayed when in configuration mode.
// A configuration mode can be entered by powering the board with S3 pushed down.
// Once the micro is programmed with new code, this application will
// automatically enter into config mode.
ROM char * const menu =
    "\r\n"
    "\r\n****************************************************************************"
    "\r\n"STARTUP_MSG       \
    "\r\n     Built on " __DATE__ BUILD_MODE
    "\r\n****************************************************************************"

    "\r\n     1: Set node ID..."
    "\r\n     2: Join a network."
    "\r\n     3: Perform quick demo binding (Must perform #2 first)."
    "\r\n     4: Leave a previously joined network (Must perform #2 first)."
    "\r\n     5: Change to next channel."
    "\r\n     6: Transmit unmodulated signal."
    "\r\n     7: Transmit random modulated signal."
    "\r\n     0: Save changes and exit."

    "\r\n\r\nEnter a menu choice: ";

// enums to execute menu options.
typedef enum _MENU_CMD
{
    MENU_CMD_START = '0',
    MENU_CMD_QUIT = '0',
    MENU_CMD_SET_ID,
    MENU_CMD_JOIN,
    MENU_CMD_DEMO,
    MENU_CMD_LEAVE,
    MENU_CMD_NEXT_CHANNEL = 'A',
    MENU_CMD_UNMODULATED_OP,
    MENU_CMD_RANDOM_OP,
    MENU_CMD_STOP
} MENU_CMD;


// Various informational messages as part of configuration process.
ROM char * const testTxMsg             = "\r\n\r\nNow transmitting test signal..."
                                         "\r\nYou must reset the board to perform other action.";
ROM char * const continueMsg           = "\r\n\r\nPress any key to continue...";
ROM char * const currentChannelMsg     = "\r\n\r\nCurrent channel is ";
ROM char * const invalidValueMsg       = "\r\nInvalid value received.\r\n";
ROM char * const associateSuccessMsg   = "\r\nSuccessfully associated.\r\n";
ROM char * const associateFailMsg      = "\r\nFailed to associate.\r\n";
ROM char * const leaveSuccessMsg       = "\r\nSuccessfully left the network.\r\n";
ROM char * const leaveFailMsg          = "\r\nFailed to leave.\r\n";
ROM char * const idEntryMsg            = "\r\nEnter exact 4 digit long decimal board id: ";
ROM char * const exitMsg               = "\r\nNow running application...\r\n";
ROM char * const addrSavedMsg          = "\r\nNode is saved; Press any key to continue...\r\n";
ROM char * const resetMsg              = "\r\n******Unexpected reset occurred.******\r\n";
ROM char * const macAddrNotAssignedMsg = "\r\nMAC Address is not assigned, entering Configuration mode...\r\n";
ROM char * const D1BindingMsg          = "Attempting to bind D1 EP.\r\n";
ROM char * const S2BindingMsg          = "Attempting to bind S2 EP.\r\n";
ROM char * const LEDSrcBindingMsg         = "Attempting to bind LED_S EP.\r\n";
ROM char * const LEDDecBindingMsg         = "Attempting to bind LED_D EP.\r\n";
ROM char * const demoBindCompleteMsg   = "Demo binding complete.\r\n";
ROM char * const ledSrcBindCompleteMsg    = "LED source binding complete.\r\n";
ROM char * const ledDesBindCompleteMsg    = "LED destination binding complete.\r\n";
ROM char * const demoBindFailedMsg     = "\r\nBinding failed.  Not associated?\r\n";
ROM char * const joinAttemptMsg        = "Attempting to join a coordinator...\r\n";
ROM char * const tc77TestingMsg        = "Testing TC77...\r\n";
ROM char * const tc77ProblemMsg        = "Auto test of TC77 failed.\r\n";
ROM char * const tc77TestSuccessMsg    = "TC77 test successful.\r\n";
ROM char * const rejoinSuccessMsg      = "Rejoin successful.\r\n";
ROM char * const rejoinFailedMsg       = "Rejoin failed.\r\n";

// Private variables
static union
{
    struct
    {
        unsigned int bInConfigMode : 1;
        unsigned int S2Toggled : 1;
    } bits;
    BYTE Val;
} appFlags;


// Private helper functions
static void InitializeBoard(void);
static void ConfigTask(void);
static BOOL ExecuteMenuChoice(MENU_CMD choice);
static void LEDBindingTask(void);
static void BindingTask(void);
static void TestTC77(void);

typedef enum _CUSTOM_BIND_ACTION
{
    CUSTOM_BIND_SOURCE = 0,
    CUSTOM_BIND_DEST,
    CUSTOM_BIND_DEMO
} CUSTOM_BIND_ACTION;

static BYTE customEP;
static CUSTOM_BIND_ACTION customAction;

static void InitCustomBind(void);
static BOOL IsCustomBindComplete(void);
static BOOL IsLEDBindComplete(void);

#define StartCustomBind(action, ep)     \
{  smBind = SM_BIND_IDLE; customEP = ep; customAction = action; }

#define StartLEDCustomBind(action, ep)     \
{  ledBind = LED_BIND_IDLE; customEP = ep; customAction = action; }


/*
 * Custom binding information
 */
struct
{
    CUSTOM_BIND_ACTION cmd;
    LONG_ADDR nodeAddr;
    BYTE ep;
    BYTE clusterID;
} bindInfo;

typedef enum _SM_BIND
{
    SM_BIND_IDLE = 0,
    SM_BIND_SEND,
    SM_BIND_WAIT
} SM_BIND;

typedef enum _LED_BIND
{
    LED_BIND_IDLE = 0,
    LED_BIND_SEND,
    LED_BIND_WAIT
} LED_BIND;

static EP_HANDLE hCustomBind;
static SM_BIND smBind;
static LED_BIND ledBind;

// Custom binding functions.
#define CUSTOM_BINDER_EP                (0xfe)
#define CUSTOM_BINDER_CLUSTER_ID        (0xfe)

// Persistent MAC address, defined in "NVM.c" file.
extern ROM LONG_ADDR macLongAddr;


#define SaveMACLongAddr(a) \
            NVMWrite((NVM_ADDR*)&macLongAddr, (BYTE*)a, sizeof(LONG_ADDR))
static BOOL IsMACAddrAssigned(void);



void main(void)
{
    // Main state machine states.
    enum
    {
        SM_APP_INIT = 0,
        SM_APP_INIT_RUN,
        SM_APP_RUN,
        SM_APP_CONFIG_START,
        SM_APP_NORMAL_START,
        SM_APP_NORMAL_START_WAIT,
        SM_APP_NORMAL_RUN,
        SM_APP_RUN_S2_TASK,
        SM_APP_RUN_D1_TASK,
        SM_APP_RUN_BINDING_TASK,
        SM_APP_SLEEP
    } smApp;

    // Enable watchdog
    ENABLE_WDT();

    // Clear all flags in the begining.
    appFlags.Val = 0x00;

    // Initialize the board hardware.
    InitializeBoard();

    // This is to initialize tick manager required for Zigbee stack modules.
    TickInit();

    // Blink on LEDs on startup to provide visual feedback
    // LEDs are turned off before main loop is started.
    D1 = 1;
    D2 = 1;

    if ( TO == 0 )
    {
        // Clear watchdog to set TO bit.
        CLRWDT();

        // Clear flags so that we can detect it next time.
        STKPTR &= 0x3F;
        RCON |= 0x1F;

        // Display message on terminal.
        ConsolePutROMString(resetMsg);

        // Since core is going to sleep in coming lines, make sure that
        // UART finishes its transmission.
        while( !ConsoleIsPutReady() );

        // Disable all interrupts
        INTCON = 0;

        // Prepare for alternating flashing LED sequence.
        D1 = 0;
        D2 = 1;

        // On this error, blink LEDs.
        while(1)
        {
            CLRWDT();

            // This is to make sure that we don't waste battery.
            // At least one LED is always ON so saving would not be
            // that much - actual application may do something different.
            SLEEP();
            NOP();

            D1 ^= 1;
            D2 ^= 1;

        }
    }

    // Test on-board temperature sensor TC77 - This version does not use TC77.
    // This test is done here because SPI is initialized in PHY.h
    // You may change it so that SPI is initialized in main file instead of stack file.
    TestTC77();

    // This demo application uses S3 switch to enter into configuration mode.
    // Actual application may implelement any logic to select configuratoin mode
    // or may not have any - completely application dependent.
    if ( S3 == 0 )
        appFlags.bits.bInConfigMode = TRUE;


    // If MAC long address is not assigned, enter configuration by default.
    if ( !IsMACAddrAssigned() )
    {
        ConsolePutROMString(macAddrNotAssignedMsg);
        appFlags.bits.bInConfigMode = TRUE;
    }

    // This is main Zigbee stack initialization call.
    // MAC will be in disable state until enabled.
    APLInit();

    // We have to enable MAC separately. This way you can disable and enable as per your
    // requirement.
    APLEnable();

    // Start with Init state.
    smApp = SM_APP_INIT;

    // Turn off LEDs
    D1 = 0;
    D2 = 0;

    while( 1 )
    {
        // Toggle RA4 to indicate how long we execute this loop
        LATA4 ^= 1;

        // Keep watchdog happy
        CLRWDT();

        // This is the main stack task, responsible for Zigbee stack related functionality.
        // This function must be called before all Zigbee tasks.
        // Actual application task function can be called in any order.
        APLTask();

        // This demo application provides two modes of operations - config and normal.
        // In config mode, this node will attempt to associate with available coordinator.
        // In normal mode, it will simply rejoin previously associated coordinator.
        // You may change this logic as per your application requirements.
        switch(smApp)
        {
        case SM_APP_INIT:
            // Initialize all local end point tasks
            InitCustomBind();
            //S2Init();
            //D1Init();
	    LEDInit();

            // If S3 was pressed on startup, go to config mode.
            if ( appFlags.bits.bInConfigMode == TRUE )
                smApp = SM_APP_CONFIG_START;

            // Or else go in normal mode.
            else
                smApp = SM_APP_NORMAL_START;

            break;


        case SM_APP_CONFIG_START:
            // While in config mode, disable watchdog.
            // Normally, you would want to keep watchdog enabled all the time, but in this demo that would
            // amount to increased complexity and make this demo difficult to understand.
            // Actual application code may afford extra complexity.
            DISABLE_WDT();

            DEBUG_OUT("In Configuration mode...\r\n");

            // This is a blocking call. Note that watchdog is already disabled.
            ConfigTask();

            // Mark that we are no longer in config mode.
            appFlags.bits.bInConfigMode = FALSE;

            smApp = SM_APP_NORMAL_START;

            // After config mode, enable watchdog
            ENABLE_WDT();

            break;

        case SM_APP_NORMAL_START:
            // In normal mode, this node will try to rejoin previously associated network.
            // This will make sure that we join to a known network.
            // Actual logic would depend on the application requirements.
            DEBUG_OUT("Rejoining previous network...\r\n");

            APLRejoin();

            smApp = SM_APP_NORMAL_START_WAIT;
            break;

        case SM_APP_NORMAL_START_WAIT:
            // See if rejoin is complete.

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩视频一区二区| av一区二区不卡| 国产成人一级电影| 色综合久久天天综合网| 精品免费一区二区三区| 亚洲日本护士毛茸茸| 另类调教123区| 日本道色综合久久| 国产精品网站在线| 久久国内精品自在自线400部| 91老师片黄在线观看| 久久综合久久99| 日本成人在线电影网| 一本大道av伊人久久综合| 国产亚洲综合av| 国产大陆亚洲精品国产| 国产98色在线|日韩| 欧洲激情一区二区| 久久久99精品免费观看不卡| 婷婷久久综合九色综合绿巨人 | 国产日韩欧美麻豆| 偷拍自拍另类欧美| 欧美三级视频在线| 洋洋av久久久久久久一区| 成人18精品视频| 久久久久久久久免费| 久久aⅴ国产欧美74aaa| 日韩西西人体444www| 无码av免费一区二区三区试看| 日本精品视频一区二区| 亚洲视频精选在线| 欧美日韩五月天| 国产精品视频免费看| 国产成人午夜高潮毛片| 亚洲精品在线电影| 国产在线精品视频| 精品国产一区二区三区不卡| 久久精品国产免费| 久久综合色之久久综合| 国内精品第一页| 国产日韩v精品一区二区| 国产精品一区二区你懂的| 国产午夜亚洲精品午夜鲁丝片| 久久精品国产色蜜蜜麻豆| 欧美精品一区二区久久婷婷| 韩国av一区二区| 亚洲国产精品二十页| caoporn国产一区二区| 一区二区三区在线观看国产| 欧美亚洲综合网| 成人免费毛片嘿嘿连载视频| 国产精品理论在线观看| 91小视频在线| 日本亚洲天堂网| 久久综合狠狠综合| av欧美精品.com| 亚洲韩国一区二区三区| 91精品国产综合久久久久久久久久| 日本最新不卡在线| 国产女人18水真多18精品一级做| eeuss鲁片一区二区三区在线观看 eeuss鲁片一区二区三区在线看 | 91日韩一区二区三区| 亚洲精品国产a久久久久久| 欧美精品丝袜中出| 国产精品综合av一区二区国产馆| 中文字幕av在线一区二区三区| 在线亚洲欧美专区二区| 麻豆精品在线观看| 亚洲欧洲国产专区| 3d动漫精品啪啪一区二区竹菊 | 欧美一级艳片视频免费观看| 国产成人免费在线观看| 国产美女久久久久| 亚洲色图丝袜美腿| 日韩免费在线观看| 色婷婷久久综合| 国内成+人亚洲+欧美+综合在线| 亚洲色图.com| 久久久.com| 欧美高清视频在线高清观看mv色露露十八| 麻豆91在线看| 亚洲综合另类小说| 欧美国产精品v| 日韩一级大片在线观看| 91麻豆国产香蕉久久精品| 久久精品国产999大香线蕉| 中文字幕一区二区三| 精品国产伦理网| 欧美性猛交一区二区三区精品| 国产精品一二三四五| 日本vs亚洲vs韩国一区三区| 国产高清不卡二三区| 亚洲日本在线看| 日韩一区国产二区欧美三区| 不卡的av在线播放| 国产精品白丝jk黑袜喷水| 亚洲gay无套男同| 亚洲精品视频一区二区| 久久精品人人做人人爽人人| 欧美一区二区在线观看| 色天天综合久久久久综合片| 成人免费毛片aaaaa**| 久久国产精品99久久人人澡| 午夜精品久久久久久不卡8050| 亚洲欧美韩国综合色| 国产精品美女一区二区三区| 久久久久久亚洲综合影院红桃| 欧美疯狂性受xxxxx喷水图片| 91免费看片在线观看| 成人app网站| 国产精品亚洲а∨天堂免在线| 免费高清在线一区| 日本成人在线网站| 欧美探花视频资源| 国产一区二区三区综合| 蜜臀av性久久久久蜜臀aⅴ| 午夜精品久久久久久久久久| 亚洲狠狠丁香婷婷综合久久久| 综合久久久久久久| 国产精品久久久久久久久免费樱桃 | 欧美一区二区三区公司| 欧美日韩大陆一区二区| 在线不卡中文字幕播放| 在线播放中文字幕一区| 欧美高清视频一二三区 | 亚洲午夜私人影院| 夜夜亚洲天天久久| 亚洲第一搞黄网站| 日本成人在线看| 激情小说亚洲一区| 国产白丝精品91爽爽久久| 成人国产亚洲欧美成人综合网| 99久久综合色| 欧洲色大大久久| 91精品国产福利| 久久久久久97三级| 成人欧美一区二区三区| 亚洲国产中文字幕在线视频综合| 亚洲高清在线视频| 久草在线在线精品观看| 国产69精品久久99不卡| 色综合久久久久久久久久久| 在线观看av一区二区| 91精品国产欧美一区二区| 精品国产一二三| 中文字幕综合网| 日日骚欧美日韩| 国产精品123区| 欧美视频完全免费看| 精品国产一区二区三区av性色| 中国色在线观看另类| 亚洲成人久久影院| 国产精品一级片| 欧美丝袜丝交足nylons图片| 日韩一区二区三区在线| 国产精品免费视频一区| 偷拍亚洲欧洲综合| 成人精品一区二区三区四区 | yourporn久久国产精品| 6080亚洲精品一区二区| 国产三级精品在线| 视频精品一区二区| 99这里都是精品| 日韩精品一区二区三区中文不卡| 亚洲天堂成人网| 国产乱码精品一区二区三区忘忧草 | 国产乱子伦视频一区二区三区 | 午夜欧美电影在线观看| 国产精品自拍在线| 欧美肥胖老妇做爰| 自拍偷拍亚洲激情| 国产成人综合精品三级| 91精品国模一区二区三区| 亚洲日本青草视频在线怡红院| 精品亚洲成a人| 欧美乱熟臀69xxxxxx| 中文字幕电影一区| 精品写真视频在线观看| 91福利社在线观看| 国产精品国产自产拍高清av | 亚洲一区在线观看免费观看电影高清| 国产毛片一区二区| 在线播放91灌醉迷j高跟美女| 亚洲视频一二区| 成人91在线观看| 国产亚洲美州欧州综合国| 美国十次综合导航| 7777精品伊人久久久大香线蕉超级流畅| 中文字幕一区二区三区在线不卡| 国产九九视频一区二区三区| 欧美成人a∨高清免费观看| 天天操天天色综合| 欧美精品在线观看一区二区| 亚洲伊人色欲综合网| www.av亚洲| 亚洲欧美韩国综合色| 色综合久久久久久久| 一区二区三区成人在线视频 | 国产激情一区二区三区四区 | 制服丝袜亚洲色图|