⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 halcc2420m.nc

📁 Develop Zigbee network real-time Os
💻 NC
📖 第 1 页 / 共 4 页
字号:
        ***********************************************/        taskPosted[TASK_SET_CHANNEL] = FALSE;        call Spi.disable();        call BusArbitration.releaseBus();    }        /**********************************************************************     * setTransmitPower     *********************************************************************/    uint8_t currentPower;        command error_t HALCC2420.setTransmitPower(uint8_t power)    {        if (power > 100)             return FAIL;        else {            currentPower = power;            if (!taskPosted[TASK_SET_POWER]) {                taskPosted[TASK_SET_POWER] = TRUE;                if (queueEmpty()) {                    post setTransmitPowerTask();                } else {                    queuePut(TASK_SET_POWER);                }                return SUCCESS;            } else {                return FAIL;            }        }    }        task void setTransmitPowerTask()    {        /***********************************************        ** Reserve SPI bus        ***********************************************/        if (call BusArbitration.getBus() != SUCCESS) {            queuePut(TASK_SET_POWER);            return;        }        /***********************************************        ** select SPI bus and module 1 (micro4)        ***********************************************/        call Spi.enable(BUS_STE | BUS_PHASE_INVERT, 1);        /* set power output */        CC2420_POWER_SET(currentPower);        /***********************************************        ** Release bus        ***********************************************/        taskPosted[TASK_SET_POWER] = FALSE;        call Spi.disable();        call BusArbitration.releaseBus();    }    /**********************************************************************     * rxEnable     *********************************************************************/    command error_t HALCC2420.rxEnable()    {        /* ignore call if radio is already on */        if (!rxEnabled)         {            if (!taskPosted[TASK_RX_ENABLE]) {                taskPosted[TASK_RX_ENABLE] = TRUE;                if (queueEmpty()) {                    post rxEnableTask();                } else {                    queuePut(TASK_RX_ENABLE);                }                return SUCCESS;            } else {                return FAIL;            }        } else            return FAIL;    }        task void rxEnableTask()    {        /***********************************************        ** Reserve SPI bus        ***********************************************/        if (call BusArbitration.getBus() != SUCCESS) {            queuePut(TASK_RX_ENABLE);            return;        }        /***********************************************        ** select SPI bus and module 1 (micro4)        ***********************************************/        call Spi.enable(BUS_STE | BUS_PHASE_INVERT, 1);        /* turn on receiver */        CC2420_RX_ENABLE();        /***********************************************        ** Release bus        ***********************************************/        taskPosted[TASK_RX_ENABLE] = FALSE;        call Spi.disable();        call BusArbitration.releaseBus();    }    /**********************************************************************     * rxDisable     *********************************************************************/    command error_t HALCC2420.rxDisable()    {        /* ignore call if radio is already off */        if (rxEnabled)         {            if (!taskPosted[TASK_RX_DISABLE]) {                taskPosted[TASK_RX_DISABLE] = TRUE;                if (queueEmpty()) {                    post rxDisableTask();                } else {                    queuePut(TASK_RX_DISABLE);                }                return SUCCESS;            } else {                return FAIL;            }        } else            return FAIL;    }    task void rxDisableTask()    {        /***********************************************        ** Reserve SPI bus        ***********************************************/        if (call BusArbitration.getBus() != SUCCESS) {            queuePut(TASK_RX_DISABLE);            return;        }        /***********************************************        ** select SPI bus and module 1 (micro4)        ***********************************************/        call Spi.enable(BUS_STE | BUS_PHASE_INVERT, 1);        /* turn off receiver */        CC2420_RX_DISABLE();        /***********************************************        ** Release bus        ***********************************************/        taskPosted[TASK_RX_DISABLE] = FALSE;        call Spi.disable();        call BusArbitration.releaseBus();    }/**************************************************************************************************** Adressing**************************************************************************************************/    /**********************************************************************     * setShortAddress     *********************************************************************/    command error_t HALCC2420.setAddress(mac_addr_t *addr)    {        shortAddress = *addr;        if (!taskPosted[TASK_SET_SHORT]) {            taskPosted[TASK_SET_SHORT] = TRUE;            if (queueEmpty()) {                post setShortAddressTask();            } else {                queuePut(TASK_SET_SHORT);            }            return SUCCESS;        } else {            return FAIL;        }    }        task void setShortAddressTask()     {        /***********************************************        ** Reserve SPI bus        ***********************************************/        if (call BusArbitration.getBus() != SUCCESS) {            queuePut(TASK_SET_SHORT);            return;        }        /***********************************************        ** select SPI bus and module 1 (micro4)        ***********************************************/        call Spi.enable(BUS_STE | BUS_PHASE_INVERT, 1);        TOSH_uwait(100);        CC2420_SET_SHORTADDR(shortAddress);                /***********************************************        ** Release bus        ***********************************************/        taskPosted[TASK_SET_SHORT] = FALSE;        call Spi.disable();        call BusArbitration.releaseBus();    }    /**********************************************************************     * getShortAddress     *********************************************************************/    command const mac_addr_t * HALCC2420.getAddress()    {        return &shortAddress;    }        task void getShortAddressTask()     {        if (call BusArbitration.getBus() != SUCCESS) return;        call Spi.enable(BUS_STE | BUS_PHASE_INVERT, 1);                call HPLCC2420RAM.read(CC_ADDR_SHORTADDR, 2, (uint8_t *) &shortAddress);        call Spi.disable();        call BusArbitration.releaseBus();    }    /**********************************************************************     * setPANAddress     *********************************************************************/    command error_t HALCC2420.setPanAddress(mac_addr_t *addr)    {        panid = *addr;        if (!taskPosted[TASK_SET_PANID]) {            taskPosted[TASK_SET_PANID] = TRUE;            if (queueEmpty()) {                post setPanAddressTask();            } else {                queuePut(TASK_SET_PANID);            }            return SUCCESS;        } else {            return FAIL;        }    }        task void setPanAddressTask()     {        /***********************************************        ** Reserve SPI bus        ***********************************************/        if (call BusArbitration.getBus() != SUCCESS) {            queuePut(TASK_SET_PANID);            return;        }        /***********************************************        ** select SPI bus and module 1 (micro4)        ***********************************************/        call Spi.enable(BUS_STE | BUS_PHASE_INVERT, 1);        TOSH_uwait(100);        CC2420_SET_PANID(panid);                /***********************************************        ** Release bus        ***********************************************/        taskPosted[TASK_SET_PANID] = FALSE;        call Spi.disable();        call BusArbitration.releaseBus();    }    /**********************************************************************     * getShortAddress     *********************************************************************/    command const mac_addr_t * HALCC2420.getPanAddress()    {        return &panid;    }        task void getPanAddressTask()     {        if (call BusArbitration.getBus() != SUCCESS) return;        call Spi.enable(BUS_STE | BUS_PHASE_INVERT, 1);                call HPLCC2420RAM.read(CC_ADDR_PANID, 2, (uint8_t *) &panid);        call Spi.disable();        call BusArbitration.releaseBus();    }    /**********************************************************************     * getExtAddress     *********************************************************************/    command const ieee_mac_addr_t * HALCC2420.getExtAddress()    {        return (const ieee_mac_addr_t *) &ieeeAddress;    }    /**********************************************************************     * Hardware Address Filtering     *********************************************************************/    command error_t HALCC2420.addressFilterEnable()    {        if (!taskPosted[TASK_ADDR_ENABLE]) {            taskPosted[TASK_ADDR_ENABLE] = TRUE;            if (queueEmpty()) {                post addressEnableTask();            } else {                queuePut(TASK_ADDR_ENABLE);            }            return SUCCESS;        } else {            return FAIL;        }    }        task void addressEnableTask()     {        /***********************************************        ** Reserve SPI bus        ***********************************************/        if (call BusArbitration.getBus() != SUCCESS) {            queuePut(TASK_ADDR_ENABLE);            return;        }        /***********************************************        ** select SPI bus and module 1 (micro4)        ***********************************************/        call Spi.enable(BUS_STE | BUS_PHASE_INVERT, 1);        mcr0Ptr->adr_decode = TRUE;        call HPLCC2420.write(CC_REG_MDMCTRL0, mcr0);         /***********************************************        ** Release bus        ***********************************************/        taskPosted[TASK_ADDR_ENABLE] = FALSE;        call Spi.disable();        call BusArbitration.releaseBus();    }    command error_t HALCC2420.addressFilterDisable()    {        if (!taskPosted[TASK_ADDR_DISABLE]) {            taskPosted[TASK_ADDR_DISABLE] = TRUE;            if (queueEmpty()) {                post addressDisableTask();            } else {                queuePut(TASK_ADDR_DISABLE);            }            return SUCCESS;        } else {            return FAIL;        }    }    task void addressDisableTask()     {        /***********************************************        ** Reserve SPI bus        ***********************************************/        if (call BusArbitration.getBus() != SUCCESS) {            queuePut(TASK_ADDR_DISABLE);            return;        }        /***********************************************        ** select SPI bus and module 1 (micro4)        ***********************************************/        call Spi.enable(BUS_STE | BUS_PHASE_INVERT, 1);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -