Esempio n. 1
0
static int
do_rssi(void)
{
    static int sample;
    int channel;

    NETSTACK_MAC.off(0);

    RADIO_ON();
    for(channel = 11; channel <= 26; ++channel) {
        RADIO_SET_CHANNEL(channel);
        rssi_samples[sample].channel[channel - 11] = RADIO_RSSI() + 53;
    }

    NETSTACK_MAC.on();

    sample = (sample + 1) % NUM_SAMPLES;

    {
        int channel, tot;
        tot = 0;
        for(channel = 0; channel < 16; ++channel) {
            int max = -256;
            int i;
            for(i = 0; i < NUM_SAMPLES; ++i) {
                max = MAX(max, rssi_samples[i].channel[channel]);
            }
            tot += max / 20;
        }
        return tot;
    }
}
Esempio n. 2
0
/** Use this to verify that the SPI port is configured correctly and writing bytes
Use a logic analyzer or scope and view the bytes being written.
The ZNP won't do anything but you'll be able to determine whether the SPI port is working.
Configure logic analyzer to trigger on a 1->0 transition on CS.
Verify that you're seeing the bytes written out the SPI port.
 */
int main( void )
{
    halInit();                          //Initialize hardware    
    halSpiInitZnp();
    halInit();
    printf("Test ZNP Reset\r\n");
    RADIO_OFF();
    delayMs(1);
    RADIO_ON();
#define TEST_SRDY_INTERVAL_MS 1  //check SRDY every 100 mSec
#define TEST_SRDY_TIMEOUT_MS  1000
    unsigned int elapsedTime = 0;       //now, poll for SRDY going low...
    do
    {
        delayMs(TEST_SRDY_INTERVAL_MS);
        elapsedTime += TEST_SRDY_INTERVAL_MS;
    }
    while ((elapsedTime < TEST_SRDY_TIMEOUT_MS) && (SRDY_IS_HIGH()));
    if (SRDY_IS_LOW())
    {
        printf("Test PASSED - SRDY went low after approximately %umS\r\n", elapsedTime);
    }
    else
    {
        printf("ERROR - SRDY never went low\r\n");
    }


    printf("SPI Write Test\r\n");
#define TEST_DATA {0x05, 0x04, 0x03, 0x02, 0x01, 0x00}
#define TEST_DATA_LENGTH 6
    unsigned char test[] = TEST_DATA;
    spiWrite(test, TEST_DATA_LENGTH);
    printf("Done!\r\n");
}
Esempio n. 3
0
/** This utility will toggle the reset line of the ZNP and determine whether the ZNP firmware is loaded.
When using SPI, toggling the reset line should cause SRDY to go high after approx. 400mSec to indicate a SYS_RESET_IND message.
This utility doesn't read the SPI bytes, just checks the SRDY line. 
Verify that the pin connected to the hardware reset of the ZNP is pulled down for 1mSec.
Configure logic analyzer to trigger on a 1->0 transition on ZNP reset line*/
int main( void )
{
    halInit();
    printf("Test ZNP Reset\r\n");
    RADIO_OFF();
    delayMs(1);
    RADIO_ON();

#define TEST_SRDY_INTERVAL_MS 1  //check SRDY every 100 mSec
#define TEST_SRDY_TIMEOUT_MS  1000
    unsigned int elapsedTime = 0;       //now, poll for SRDY going low...
    do
    {
        delayMs(TEST_SRDY_INTERVAL_MS);
        elapsedTime += TEST_SRDY_INTERVAL_MS;
    }
    while ((elapsedTime < TEST_SRDY_TIMEOUT_MS) && (SRDY_IS_HIGH()));
    if (SRDY_IS_LOW())
    {
        printf("Test PASSED - SRDY went low after approximately %umS\r\n", elapsedTime);
    }
    else
    {
        printf("ERROR - SRDY never went low\r\n");
    }
}
Esempio n. 4
0
/** Resets the ZNP using hardware and retrieves the SYS_RESET_IND message. 
This method is used to restart the ZNP's internal state machine and apply changes to startup options, zigbee device type, etc.
@post znpResult contains the error code, or ZNP_SUCCESS if success.
@return a pointer to the beginning of the version structure, or a pointer to indeterminate data if error.
@see Interface Specification for order of fields
*/
unsigned char* znpReset()
{
    RADIO_OFF();
    DEBUG_OFF();
    delayMs(1);
    RADIO_ON(); 
    DEBUG_ON();
    znpResult = spiPoll();              //Note: this will be different if UART
    return (znpBuf+SRSP_PAYLOAD_START);  //the beginning of the reset indication string
}
Esempio n. 5
0
/** Reset the ZNP, poll for the SYS_RESET_IND message and display the contents.
 * Similar to the method znpReset() in znp_interface.c */
int main( void )
{
    halInit();                          //Initialize hardware
    halSpiInitZnp();
    printf("Resetting ZNP\r\n");
    RADIO_OFF();
    delayMs(1);
    RADIO_ON();
    spiPoll();
    for (int i=0; i< (znpBuf[0] + 3); i++)
        printf("%02X ", znpBuf[i]);
    printf("\r\n");
}
Esempio n. 6
0
/** Reset the ZNP and then get the MAC. */
int main( void )
{
    halInit();                          //Initialize hardware
    halSpiInitZnp();
    printf("Resetting ZNP to get MAC address\r\n");
    RADIO_OFF();
    delayMs(1);
    RADIO_ON();
    spiPoll();
    for (int i=0; i< (znpBuf[0] + 3); i++)
        printf("%02X ", znpBuf[i]);
    printf("\r\n");
    
    znpBuf[0] = 1;      //ZB_GET_DEVICE_INFO_PAYLOAD_LEN;
    znpBuf[1] = 0x26;   //MSB(ZB_GET_DEVICE_INFO);
    znpBuf[2] = 0x06;   //LSB(ZB_GET_DEVICE_INFO);
    znpBuf[3] = 1;      //DIP_MAC_ADDRESS;
    sendSreq();
    printf("MAC Address, LSB first:");
    for (int i=4; i< (znpBuf[0] + 3); i++)
        printf("%02X ", znpBuf[i]);
    printf("\r\n");
}