cc1200: added nullrdc timing parameters to rf configuration file

This commit is contained in:
Ulf Knoblich 2015-06-18 20:02:44 +02:00
parent 584b6ae4ca
commit 557091b710
3 changed files with 114 additions and 27 deletions

View File

@ -1,3 +1,37 @@
/*
* Copyright (c) 2015, Weptech elektronik GmbH Germany
* http://www.weptech.de
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This file is part of the Contiki operating system.
*/
#include "cc1200-rf-cfg.h"
#include "cc1200-const.h"
@ -6,9 +40,9 @@
*
* 802.15.4g
* =========
* Table 86f: Frequency band identifier 4 (863-870 MHz)
* Table 86g: Modulation scheme identifier 0 (Filtered FSK)
* Table 86h: Mode #1 (50kbps)
* Table 68f: Frequency band identifier 4 (863-870 MHz)
* Table 68g: Modulation scheme identifier 0 (Filtered FSK)
* Table 68h: Mode #1 (50kbps)
*/
/* Base frequency in kHz */
@ -23,7 +57,36 @@
#define RF_CFG_MAX_TXPOWER CC1200_CONST_TX_POWER_MAX
/* The carrier sense level used for CCA in dBm */
#define RF_CFG_CCA_THRESHOLD (-91)
/*
* ACK_WAIT_TIME is the time between sending a packet and detecting
* an arbitrary incoming packet (hopefully an ACK).
* An incoming packet is detected using either
* - receiving_packet()
* - pending_packet()
* - channel_clear()
* Let's assume we use receiving_packet() as the latest (reliable)
* indication for an incoming packet. It returns 1 as soon as the sync word
* is detected. We can then estimate this time (assuming an 802.15.4-2011 frame)
* by:
* - 1ms RX/TX turnarround (also FIFO read-out -> depends on packet length!)
* + length of preamble (4 bytes)
* + length of sync word (2 bytes)
* -> let's use 2.5 ms for 50kbps
*/
#define NULLRDC_CONF_ACK_WAIT_TIME RTIMER_SECOND/400
/*
* NULLRDC_AFTER_ACK_DETECTED_WAIT_TIME is the time after an incoming
* paket is detected (using the means described above) and the ACK is
* available for read-out by the MAC layer (pending_packet(), read()).
* If we assume that channel_clear() indicated the incoming packet, the maximum
* time it takes for the ACK to be available calulates as following:
* - length of preamble (4 bytes)
* + length of ACK (3 bytes)
* + length of CRC (2 bytes)
* - 1ms safety margin
* -> let's use 2.5 ms for 50kbps
*/
#define NULLRDC_CONF_AFTER_ACK_DETECTED_WAIT_TIME RTIMER_SECOND/400
/*---------------------------------------------------------------------------*/
static const char rf_cfg_descriptor[] = "802.15.4g 863-870MHz MR-FSK mode #1";
/*---------------------------------------------------------------------------*/

View File

@ -215,22 +215,5 @@
#define CC1200_SNIFFER 0
#endif
/*---------------------------------------------------------------------------*/
/*
* Wether to use USB for SNIFF mode or not
*/
#ifdef CC1200_CONF_SNIFFER_USB
#define CC1200_SNIFFER_USB CC1200_CONF_SNIFFER_USB
#else
#define CC1200_SNIFFER_USB 0
#endif
/*---------------------------------------------------------------------------*/
/*
* Which UART to use for the Sniffer unless USB is used
*/
#ifdef CC1200_CONF_SNIFFER_UART
#define CC1200_SNIFFER_UART CC1200_CONF_SNIFFER_UART
#else
#define CC1200_SNIFFER_UART 0
#endif
#endif /* CC1200_H_ */

View File

@ -535,9 +535,11 @@ calculate_freq(uint8_t channel);
/* Update rf channel if possible, else postpone it (-> pollhandler). */
static int
set_channel(uint8_t channel);
#if !CC1200_SNIFFER
/* Check broadcast address. */
static int
is_broadcast_addr(uint8_t mode, uint8_t *addr);
#endif /* CC1200_SNIFFER */
/* Validate address and send ACK if requested. */
static int
addr_check_auto_ack(uint8_t *frame, uint16_t frame_len);
@ -1480,6 +1482,34 @@ configure(void)
single_write(CC1200_FREQ0, ((uint8_t *)&freq)[0]);
single_write(CC1200_FREQ1, ((uint8_t *)&freq)[1]);
single_write(CC1200_FREQ2, ((uint8_t *)&freq)[2]);
printf("RF: Freq0 0x%02x\n", ((uint8_t *)&freq)[0]);
printf("RF: Freq1 0x%02x\n", ((uint8_t *)&freq)[1]);
printf("RF: Freq2 0x%02x\n", ((uint8_t *)&freq)[2]);
#if (RF_TESTMODE == 1)
single_write(CC1200_SYNC_CFG1, 0xE8);
single_write(CC1200_PREAMBLE_CFG1, 0x00);
single_write(CC1200_MDMCFG1, 0x46);
single_write(CC1200_PKT_CFG0, 0x40);
single_write(CC1200_FS_DIG1, 0x07);
single_write(CC1200_FS_DIG0, 0xAA);
single_write(CC1200_FS_DVC1, 0xFF);
single_write(CC1200_FS_DVC0, 0x17);
#endif
#if (RF_TESTMODE == 2)
single_write(CC1200_SYNC_CFG1, 0xE8);
single_write(CC1200_PREAMBLE_CFG1, 0x00);
single_write(CC1200_MDMCFG1, 0x06);
single_write(CC1200_PA_CFG1, 0x3F);
single_write(CC1200_MDMCFG2, 0x03);
single_write(CC1200_FS_DIG1, 0x07);
single_write(CC1200_FS_DIG0, 0xAA);
single_write(CC1200_FS_DVC0, 0x17);
single_write(CC1200_SERIAL_STATUS, 0x08);
#endif
strobe(CC1200_STX);
while(1) {
@ -2066,6 +2096,7 @@ set_channel(uint8_t channel)
}
/*---------------------------------------------------------------------------*/
/* Check broadcast address. */
#if !CC1200_SNIFFER
static int
is_broadcast_addr(uint8_t mode, uint8_t *addr)
{
@ -2081,6 +2112,7 @@ is_broadcast_addr(uint8_t mode, uint8_t *addr)
return 1;
}
#endif /* CC12100_SNIFFER */
/*---------------------------------------------------------------------------*/
/* Validate address and send ACK if requested. */
#if CC1200_SNIFFER
@ -2103,7 +2135,7 @@ addr_check_auto_ack(uint8_t *frame, uint16_t frame_len)
}
}
#else /* #if CC1200_SNIFFER */
#else /* CC1200_SNIFFER */
static int
addr_check_auto_ack(uint8_t *frame, uint16_t frame_len)
{
@ -2172,7 +2204,7 @@ addr_check_auto_ack(uint8_t *frame, uint16_t frame_len)
return INVALID_FRAME;
}
#endif /* #if CC1200_SNIFFER */
#endif /* CC1200_SNIFFER */
/*---------------------------------------------------------------------------*/
/*
* The CC1200 interrupt handler: called by the hardware interrupt
@ -2288,10 +2320,19 @@ cc1200_rx_interrupt(void)
PHR_LEN);
#endif
if((payload_len < ACK_LEN) ||
payload_len > CC1200_MAX_PAYLOAD_LEN) {
/* Invalid payload length. Discard packet */
WARNING("RF: Invalid payload length!\n");
if(payload_len < ACK_LEN) {
/* Packet to short. Discard it */
WARNING("RF: Packet too short!\n");
RIMESTATS_ADD(tooshort);
rx_rx();
RELEASE_SPI();
return 0;
}
if(payload_len > CC1200_MAX_PAYLOAD_LEN) {
/* Packet to long. Discard it */
WARNING("RF: Packet to long!\n");
RIMESTATS_ADD(toolong);
rx_rx();
RELEASE_SPI();
return 0;