1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-28 07:51:19 +01:00

[board/chronos board/msb-430h board/msba2-common drivers/cc110x_ng sys/shell

sys/transceiver]
* renamed all occurrences of cc1100 to cc110x as in fact all driver parts should
work for cc1100 and cc110x as well

[driver/cc110x_ng]
* added some documentation
* introduced a new register function to access rxfifo (fixing the of-by-one
problem on chronos platform
This commit is contained in:
Oliver Hahm 2010-12-11 12:09:20 +01:00
parent da7077b467
commit 6be1cf2a76
27 changed files with 468 additions and 370 deletions

View File

@ -1,4 +1,4 @@
SubDir TOP board chronos drivers ;
Module board_display : display.c display1.c ;
Module board_cc1100 : cc430-cc1100.c : cc110x_cc430 ;
Module board_cc110x : cc430-cc110x.c : cc110x_cc430 ;

View File

@ -2,78 +2,79 @@
#include <cpu.h>
#include <irq.h>
#include <cc1100_ng.h>
#include <arch_cc1100.h>
#include <cc110x_ng.h>
#include <cc110x-arch.h>
#include <cc430_.h>
#include <msp430/rf1a.h>
//#include <cc430_.h>
#include <cc430x613x.h>
//#include <msp430/rf1a.h>
#define CC1100_GDO0 (RF1AIN & BIT0)
#define CC1100_GDO1 (RF1AIN & BIT1)
#define CC1100_GDO2 (RF1AIN & BIT2)
int cc1100_get_gdo0(void) {
int cc110x_get_gdo0(void) {
return CC1100_GDO0;
}
int cc1100_get_gdo1(void) {
int cc110x_get_gdo1(void) {
return CC1100_GDO1;
}
int cc1100_get_gdo2(void) {
int cc110x_get_gdo2(void) {
return CC1100_GDO2;
}
void cc1100_before_send(void)
void cc110x_before_send(void)
{
// Disable GDO2 interrupt before sending packet
cc1100_gdo2_disable();
cc110x_gdo2_disable();
}
void cc1100_after_send(void)
void cc110x_after_send(void)
{
// Enable GDO2 interrupt after sending packet
cc1100_gdo2_enable();
cc110x_gdo2_enable();
}
void cc1100_gdo0_enable(void) {
void cc110x_gdo0_enable(void) {
RF1AIFG &= ~BIT0;
RF1AIE |= BIT0;
}
void cc1100_gdo0_disable(void) {
void cc110x_gdo0_disable(void) {
RF1AIE &= ~BIT0;
RF1AIFG &= ~BIT0;
}
void cc1100_gdo2_disable(void) {
void cc110x_gdo2_disable(void) {
RF1AIFG &= ~BIT2; // Clear a pending interrupt
RF1AIE &= ~BIT2; // Disable the interrupt
}
void cc1100_gdo2_enable(void) {
void cc110x_gdo2_enable(void) {
RF1AIFG &= ~BIT2; // Clear a pending interrupt
RF1AIE |= BIT2; // Enable the interrupt
}
void cc1100_init_interrupts(void) {
void cc110x_init_interrupts(void) {
uint8_t state = disableIRQ(); /* Disable all interrupts */
cc1100_gdo2_enable();
cc1100_gdo0_disable();
cc110x_gdo2_enable();
cc110x_gdo0_disable();
restoreIRQ(state); /* Enable all interrupts */
}
interrupt (CC1101_VECTOR) __attribute__ ((naked)) cc1100_isr(void){
interrupt (CC1101_VECTOR) __attribute__ ((naked)) cc110x_isr(void){
__enter_isr();
/* Check IFG */
if (RF1AIV == RF1AIV_RFIFG2) {
while (RF1AIN & BIT2);
/* discard all further interrupts */
RF1AIV = 0;
cc1100_gdo2_irq();
cc110x_gdo2_irq();
}
if (RF1AIV == RF1AIV_RFIFG0) {
cc1100_gdo0_irq();
cc110x_gdo0_irq();
RF1AIE &= ~BIT0;
}
__exit_isr();

View File

@ -27,7 +27,7 @@
SubDir TOP board msb-430h ;
Module board_cc1100 : driver_cc1100.c : cc110x_spi ;
Module board_cc110x : driver_cc110x.c : cc110x_spi ;
SubInclude TOP board msb-430-common ;
SubInclude TOP cpu $(CPU) ;

View File

@ -23,8 +23,8 @@ Boston, MA 02111-1307, USA. */
#include <cpu.h>
#include <irq.h>
#include <cc1100_ng.h>
#include <arch_cc1100.h>
#include <cc110x_ng.h>
#include <arch_cc110x.h>
#define CC1100_GDO0 (P2IN & 0x02) // read serial I/O (GDO0)
#define CC1100_GDO1 (P3IN & 0x04) // read serial I/O (GDO1)
@ -39,61 +39,61 @@ Boston, MA 02111-1307, USA. */
volatile int abort_count;
volatile int retry_count = 0;
void cc1100_gdo0_enable(void)
void cc110x_gdo0_enable(void)
{
P2IFG &= ~0x02; /* Clear IFG for GDO0 */
P2IE |= 0x02; /* Enable interrupt for GDO0 */
}
void cc1100_gdo0_disable(void)
void cc110x_gdo0_disable(void)
{
P2IE &= ~0x02; /* Disable interrupt for GDO0 */
P2IFG &= ~0x02; /* Clear IFG for GDO0 */
}
void cc1100_gdo2_enable(void)
void cc110x_gdo2_enable(void)
{
P2IFG &= ~0x01; /* Clear IFG for GDO2 */
P2IE |= 0x01; /* Enable interrupt for GDO2 */
}
void cc1100_gdo2_disable(void)
void cc110x_gdo2_disable(void)
{
P2IE &= ~0x01; /* Disable interrupt for GDO2 */
P2IFG &= ~0x01; /* Clear IFG for GDO2 */
}
void cc1100_before_send(void)
void cc110x_before_send(void)
{
// Disable GDO2 interrupt before sending packet
cc1100_gdo2_disable();
cc110x_gdo2_disable();
}
void cc1100_after_send(void)
void cc110x_after_send(void)
{
// Enable GDO2 interrupt after sending packet
cc1100_gdo2_enable();
cc110x_gdo2_enable();
}
int cc1100_get_gdo0(void) {
int cc110x_get_gdo0(void) {
return CC1100_GDO0;
}
int cc1100_get_gdo1(void) {
int cc110x_get_gdo1(void) {
return CC1100_GDO1;
}
int cc1100_get_gdo2(void) {
int cc110x_get_gdo2(void) {
return CC1100_GDO2;
}
void cc1100_spi_cs(void)
void cc110x_spi_cs(void)
{
CC1100_CS_LOW;
}
uint8_t cc1100_txrx(uint8_t data)
uint8_t cc110x_txrx(uint8_t data)
{
/* Ensure TX Buf is empty */
long c = 0;
@ -103,20 +103,20 @@ uint8_t cc1100_txrx(uint8_t data)
while(!(IFG1 & UTXIFG0))
{
if (c++ == 1000000)
puts("cc1100_txrx alarm()");
puts("cc110x_txrx alarm()");
}
/* Wait for Byte received */
c = 0;
while(!(IFG1 & URXIFG0))
{
if (c++ == 1000000)
puts("cc1100_txrx alarm()");
puts("cc110x_txrx alarm()");
}
return RXBUF0;
}
void cc1100_spi_select(void)
void cc110x_spi_select(void)
{
// Switch to GDO mode
P3SEL &= ~0x04;
@ -147,11 +147,11 @@ void cc1100_spi_select(void)
P3SEL |= 0x04;
}
void cc1100_spi_unselect(void) {
void cc110x_spi_unselect(void) {
CC1100_CS_HIGH;
}
void cc1100_init_interrupts(void)
void cc110x_init_interrupts(void)
{
unsigned int state = disableIRQ(); /* Disable all interrupts */
P2SEL = 0x00; /* must be <> 1 to use interrupts */
@ -163,7 +163,7 @@ void cc1100_init_interrupts(void)
restoreIRQ(state); /* Enable all interrupts */
}
void cc1100_spi_init(uint8_t clockrate)
void cc110x_spi_init(uint8_t clockrate)
{
// Switch off async UART
while(!(UTCTL0 & TXEPT)); // Wait for empty UxTXBUF register
@ -197,8 +197,8 @@ void cc1100_spi_init(uint8_t clockrate)
// #include <msp430x16x.h>
// #include <signal.h>
// #include "type.h"
// #include "cc1100_defines.h"
// #include "driver_cc1100.h"
// #include "cc110x_defines.h"
// #include "driver_cc110x.h"
// #include "driver_system.h"
// #include "spi0.h"
//
@ -213,17 +213,17 @@ void cc1100_spi_init(uint8_t clockrate)
// // void spiInitTrx(void)
// //
// // DESCRIPTION:
// // This function puts the cc1100 into spi mode. You have to call this bevore every spi transaction.
// // This function puts the cc110x into spi mode. You have to call this bevore every spi transaction.
// //
// //-------------------------------------------------------------------------------------------------------
//
//
// void drivercc1100_spiwriteburstreg(uint8_t addr, unsigned char *buffer, uint8_t count)
// void drivercc110x_spiwriteburstreg(uint8_t addr, unsigned char *buffer, uint8_t count)
// {
// uint8_t i;
// long c;
// drivercc1100_spiinittrx();
// drivercc1100_trxspi(addr | CC1100_WRITE_BURST);
// drivercc110x_spiinittrx();
// drivercc110x_trxspi(addr | CC1100_WRITE_BURST);
// for (i = 0; i < count; i++)
// {
// c = 0;
@ -247,11 +247,11 @@ void cc1100_spi_init(uint8_t clockrate)
// CC1100_CS_HIGH;
// }
//
// void drivercc1100_spireadburstreg(uint8_t addr, char *buffer, uint8_t count)
// void drivercc110x_spireadburstreg(uint8_t addr, char *buffer, uint8_t count)
// {
// uint8_t i;
// drivercc1100_spiinittrx();
// drivercc1100_trxspi(addr | CC1100_READ_BURST);
// drivercc110x_spiinittrx();
// drivercc110x_trxspi(addr | CC1100_READ_BURST);
// for (i = 0; i < count; i++)
// {
// long c = 0;
@ -275,21 +275,21 @@ void cc1100_spi_init(uint8_t clockrate)
// CC1100_CS_HIGH;
// }
//
// void drivercc1100_load(callback_t cs_cb,callback_t paket_cb)
// void drivercc110x_load(callback_t cs_cb,callback_t paket_cb)
// {
// _paket_cb = paket_cb;
// _cs_cb = cs_cb;
// spi0_init(0);
// }
//
// void drivercc1100_aftersend(void)
// void drivercc110x_aftersend(void)
// {
// CLEAR(P2IFG, 0x01);
// SET(P2IE, 0x01); /* Enable interrupts on port 2 pin 0 */
// CLEAR(P4OUT, 0x08); /* Turn off Sending Led*/
// }
//
// void drivercc1100_initinterrupts(void)
// void drivercc110x_initinterrupts(void)
// {
// _DINT(); /* Disable all interrupts */
// P2SEL = 0x00; /* must be <> 1 to use interrupts */
@ -301,7 +301,7 @@ void cc1100_spi_init(uint8_t clockrate)
// _EINT(); /* Enable all interrupts */
// }
//
// void drivercc1100_beforesend(void)
// void drivercc110x_beforesend(void)
// {
// /* Turn on Led while sending paket for debug reasons */
// SET(P4OUT, 0x08);
@ -319,21 +319,21 @@ void cc1100_spi_init(uint8_t clockrate)
/*
* CC1100 receive interrupt
*/
interrupt (PORT2_VECTOR) __attribute__ ((naked)) cc1100_isr(void){
interrupt (PORT2_VECTOR) __attribute__ ((naked)) cc110x_isr(void){
__enter_isr();
puts("cc1100_isr()");
puts("cc110x_isr()");
// if (system_state.POWERDOWN) SPI_INIT; /* Initialize SPI after wakeup */
/* Check IFG */
if ((P2IFG & 0x01) != 0) {
P2IFG &= ~0x01;
cc1100_gdo2_irq();
cc110x_gdo2_irq();
}
else if ((P2IFG & 0x02) != 0) {
cc1100_gdo0_irq();
cc110x_gdo0_irq();
P2IE &= ~0x02; // Disable interrupt for GDO0
P2IFG &= ~0x02; // Clear IFG for GDO0
} else {
puts("cc1100_isr(): unexpected IFG!");
puts("cc110x_isr(): unexpected IFG!");
/* Should not occur - only Port 2 Pin 0 interrupts are enabled */
// CLEAR(P2IFG, 0xFF); /* Clear all flags */
}

View File

@ -1,6 +1,6 @@
SubDir TOP board msba2-common drivers ;
Module board_cc1100 : msba2-cc1100.c : cc110x_spi gpioint ;
Module board_cc110x : msba2-cc110x.c : cc110x_spi gpioint ;
Module board_ltc4150 : msba2-ltc4150.c : gpioint ;
Module board_uart : msba2-uart0.c : chardev_thread ringbuffer ;

View File

@ -34,7 +34,7 @@ and the mailinglist (subscription via web site)
* @author Thomas Hillebrandt <hillebra@inf.fu-berlin.de>
* @version $Revision: 1781 $
*
* @note $Id: msba2-cc1100.c 1781 2010-01-26 13:39:36Z hillebra $
* @note $Id: msba2-cc110x.c 1781 2010-01-26 13:39:36Z hillebra $
*/
#include <stdio.h>
@ -43,10 +43,10 @@ and the mailinglist (subscription via web site)
#include <cpu.h>
#include <irq.h>
// sys
#include "cc1100.h"
#include "arch_cc1100.h"
#include "cc1100_spi.h"
#include "gpioint.h"
#include <cc110x_ng.h>
#include <cc110x-arch.h>
#include <cc110x_spi.h>
#include <gpioint.h>
#define CC1100_GDO0 (FIO0PIN & BIT27) // read serial I/O (GDO0)
#define CC1100_GDO1 (FIO1PIN & BIT23) // read serial I/O (GDO1)
@ -82,19 +82,19 @@ static int test_time(int code) {
}
#endif
int cc1100_get_gdo0(void) {
int cc110x_get_gdo0(void) {
return CC1100_GDO0;
}
int cc1100_get_gdo1(void) {
int cc110x_get_gdo1(void) {
return CC1100_GDO1;
}
int cc1100_get_gdo2(void) {
int cc110x_get_gdo2(void) {
return CC1100_GDO2;
}
void cc1100_spi_init(void)
void cc110x_spi_init(void)
{
// configure chip-select
FIO1DIR |= BIT21;
@ -128,7 +128,7 @@ void cc1100_spi_init(void)
}
}
uint8_t cc1100_txrx(uint8_t c) {
uint8_t cc110x_txrx(uint8_t c) {
uint8_t result;
SSP0DR = c;
#ifdef DEBUG
@ -159,13 +159,13 @@ uint8_t cc1100_txrx(uint8_t c) {
return result;
}
void cc1100_spi_cs(void)
void cc110x_spi_cs(void)
{
FIO1CLR = BIT21;
}
void
cc1100_spi_select(void)
cc110x_spi_select(void)
{
volatile int retry_count = 0;
volatile int abort_count;
@ -199,44 +199,44 @@ cc1100_spi_select(void)
}
void
cc1100_spi_unselect(void)
cc110x_spi_unselect(void)
{
FIO1SET = BIT21;
}
void cc1100_before_send(void)
void cc110x_before_send(void)
{
// Disable GDO2 interrupt before sending packet
cc1100_gdo2_disable();
cc110x_gdo2_disable();
}
void cc1100_after_send(void)
void cc110x_after_send(void)
{
// Enable GDO2 interrupt after sending packet
cc1100_gdo2_enable();
cc110x_gdo2_enable();
}
void cc1100_gdo0_enable(void) {
gpioint_set(0, BIT27, GPIOINT_RISING_EDGE, &cc1100_gdo0_irq);
void cc110x_gdo0_enable(void) {
gpioint_set(0, BIT27, GPIOINT_RISING_EDGE, &cc110x_gdo0_irq);
}
void cc1100_gdo0_disable(void) {
void cc110x_gdo0_disable(void) {
gpioint_set(0, BIT27, GPIOINT_DISABLE, NULL);
}
void cc1100_gdo2_disable(void) {
void cc110x_gdo2_disable(void) {
gpioint_set(0, BIT28, GPIOINT_DISABLE, NULL);
}
void cc1100_gdo2_enable(void) {
gpioint_set(0, BIT28, GPIOINT_FALLING_EDGE, &cc1100_gdo2_irq);
void cc110x_gdo2_enable(void) {
gpioint_set(0, BIT28, GPIOINT_FALLING_EDGE, &cc110x_gdo2_irq);
}
void cc1100_init_interrupts(void)
void cc110x_init_interrupts(void)
{
// Enable external interrupt on low edge (for GDO2)
FIO0DIR &= ~BIT28;
cc1100_gdo2_enable();
cc110x_gdo2_enable();
// Enable external interrupt on low edge (for GDO0)
FIO0DIR &= ~BIT27;
}

View File

@ -29,6 +29,6 @@ SubDir TOP drivers cc110x_ng ;
HDRS += $(TOP)/drivers/cc110x_ng ;
Module cc110x_ng : cc1100.c cc1100-rx.c cc1100-tx.c cc1100-defaultSettings.c : hwtimer board_cc1100 ;
Module cc110x_spi : cc1100_spi.c ;
Module cc110x_cc430 : cc1100_cc430.c ;
Module cc110x_ng : cc110x.c cc110x-rx.c cc110x-tx.c cc110x-defaultSettings.c : hwtimer board_cc110x ;
Module cc110x_spi : cc110x_spi.c ;
Module cc110x_cc430 : cc110x_cc430.c ;

View File

@ -1,12 +0,0 @@
#ifndef CC110X_REG_H
#define CC110X_REG_H
#include <stdint.h>
uint8_t cc1100_writeburst_reg(uint8_t addr, char *buffer, uint8_t count);
void cc1100_readburst_reg(uint8_t addr, char *buffer, uint8_t count);
void cc1100_write_reg(uint8_t addr, uint8_t value);
uint8_t cc1100_read_reg(uint8_t addr);
uint8_t cc1100_read_status(uint8_t addr);
uint8_t cc1100_strobe(uint8_t c);
#endif

View File

@ -33,18 +33,18 @@ and the mailinglist (subscription via web site)
* @author Heiko Will <hwill@inf.fu-berlin.de>
* @version $Revision: 1775 $
*
* @note $Id: arch_cc1100.h 1775 2010-01-26 09:37:03Z hillebra $
* @note $Id: arch_cc110x.h 1775 2010-01-26 09:37:03Z hillebra $
*/
#include <stdint.h>
uint8_t cc1100_txrx(uint8_t c);
uint8_t cc110x_txrx(uint8_t c);
void cc1100_gdo0_enable(void);
void cc1100_gdo0_disable(void);
void cc1100_gdo2_enable(void);
void cc1100_gdo2_disable(void);
void cc1100_init_interrupts(void);
void cc110x_gdo0_enable(void);
void cc110x_gdo0_disable(void);
void cc110x_gdo2_enable(void);
void cc110x_gdo2_disable(void);
void cc110x_init_interrupts(void);
void cc1100_before_send(void);
void cc1100_after_send(void);
void cc110x_before_send(void);
void cc110x_after_send(void);

View File

@ -45,13 +45,13 @@ typedef struct {
uint8_t _FSCAL2;
uint8_t _FSCAL1;
uint8_t _FSCAL0;
} cc1100_reg_t;
} cc110x_reg_t;
/** CC1100 radio configuration */
typedef struct {
cc1100_reg_t reg_cfg; ///< CC1100 register configuration
cc110x_reg_t reg_cfg; ///< CC1100 register configuration
uint8_t pa_power; ///< Output power setting
} cc1100_cfg_t;
} cc110x_cfg_t;
/**
* @brief Radio Control Flags
@ -74,12 +74,12 @@ typedef struct
unsigned KT_RES_ERR : 1; ///< A hwtimer resource error has occurred (no free timers available)
unsigned TX : 1; ///< State machine TX lock, only ACKs will be received
unsigned WOR_RST : 1; ///< Reset CC1100 real time clock (WOR) on next WOR strobe
} cc1100_flags;
} cc110x_flags;
/**
* @brief Statistic interface for debugging
*/
typedef struct cc1100_statistic {
typedef struct cc110x_statistic {
uint32_t packets_in;
uint32_t packets_in_crc_fail;
uint32_t packets_in_while_tx;
@ -91,6 +91,6 @@ typedef struct cc1100_statistic {
uint32_t acks_send;
uint32_t rx_buffer_max;
uint32_t watch_dog_resets;
} cc1100_statistic_t;
} cc110x_statistic_t;
#endif

View File

@ -38,10 +38,10 @@ and the mailinglist (subscription via web site)
* @author Heiko Will <hwill@inf.fu-berlin.de>
* @version $Revision: 2058 $
*
* @note $Id: cc1100-defaultSettings.c 2058 2010-03-31 08:59:31Z hillebra $
* @note $Id: cc110x-defaultSettings.c 2058 2010-03-31 08:59:31Z hillebra $
*/
#include <cc1100-defaultSettings.h>
#include <cc110x-defaultSettings.h>
/**
* Usable, non overlapping channels and corresponding frequencies
@ -77,7 +77,7 @@ and the mailinglist (subscription via web site)
*/
// 400 kbps, MSK, X-tal: 26 MHz (Chip Revision F)
char cc1100_conf[] = {
char cc110x_conf[] = {
0x06, // IOCFG2
0x2E, // IOCFG1
0x0E, // IOCFG0

View File

@ -41,7 +41,7 @@ and the mailinglist (subscription via web site)
* @author Heiko Will <hwill@inf.fu-berlin.de>
* @version $Revision: 2139 $
*
* @note $Id: cc1100-defaultSettings.h 2139 2010-05-26 08:04:04Z hillebra $
* @note $Id: cc110x-defaultSettings.h 2139 2010-05-26 08:04:04Z hillebra $
*/
#include <stdint.h>

View File

@ -42,7 +42,7 @@ and the mailinglist (subscription via web site)
* @author Heiko Will <hwill@inf.fu-berlin.de>
* @version $Revision: 1231 $
*
* @note $Id: cc1100-internal.h 1231 2009-08-20 08:31:32Z baar $
* @note $Id: cc110x-internal.h 1231 2009-08-20 08:31:32Z baar $
*/
#define FIXED_PKTLEN (0x00) ///< Fixed length packets, length configured in PKTLEN register.

View File

@ -0,0 +1,83 @@
/**
* @file cc110x-reg.h
* @ingroup dev_cc110x_ng
* @brief Access to CC110X registers
*
* @author Freie Uniersität Berlin, Computer Systems & Telematics, µkleos
* @author Oliver Hahm <oliver.hahm@fu-berlin.de
* version $Revision$
*
*/
#ifndef CC110X_REG_H
#define CC110X_REG_H
#include <stdint.h>
/**
* @brief Write a set of bytes using burst mode (if available)
*
* @param addr Destination register
* @param buffer Data to be written
* @param count Size of data
*
* @return Written bytes
*/
uint8_t cc110x_writeburst_reg(uint8_t addr, char *buffer, uint8_t count);
/**
* @brief Read a set of bytes using burst mode (if available)
*
* @param addr Source register
* @param buffer Buffer to store read data
* @param count Size of data to be read
*/
void cc110x_readburst_reg(uint8_t addr, char *buffer, uint8_t count);
/**
* @brief Read bytes from RXFIFO
*
* @param buffer Buffer to store read data
* @param count Size of data to be read
*
* @note: Calls cc110x_readburst_reg if not dedicated fifo read command
* available
*/
void cc110x_read_fifo(char *buffer, uint8_t count);
/**
* @brief Write one byte to a register
*
* @param addr Destinatoin register
* @param value New value
*/
void cc110x_write_reg(uint8_t addr, uint8_t value);
/**
* @brief Read a byte from register
*
* @param addr Source register
*
* @return Read state and value of register
*/
uint8_t cc110x_read_reg(uint8_t addr);
/**
* @brief Read state of a register
*
* @param addr Source register
*
* @return State of register
*/
uint8_t cc110x_read_status(uint8_t addr);
/**
* @brief Sends a command strobe
*
* @param c Command code
*
* @return Command response
*/
uint8_t cc110x_strobe(uint8_t c);
#endif

View File

@ -1,9 +1,9 @@
#include <cc1100_ng.h>
#include <cc1100-internal.h>
#include <cc1100-config.h>
#include <cc1100-defaultSettings.h>
#include <cc1100_spi.h>
#include <cc1100-reg.h>
#include <cc110x_ng.h>
#include <cc110x-internal.h>
#include <cc110x-config.h>
#include <cc110x-defaultSettings.h>
#include <cc110x_spi.h>
#include <cc110x-reg.h>
#include <hwtimer.h>
#include <msg.h>
@ -15,37 +15,37 @@
static uint8_t receive_packet_variable(uint8_t *rxBuffer, uint8_t length);
static uint8_t receive_packet(uint8_t *rxBuffer, uint8_t length);
rx_buffer_t cc1100_rx_buffer[RX_BUF_SIZE]; ///< RX buffer
rx_buffer_t cc110x_rx_buffer[RX_BUF_SIZE]; ///< RX buffer
volatile uint8_t rx_buffer_next; ///< Next packet in RX queue
void cc1100_rx_handler(void) {
void cc110x_rx_handler(void) {
uint8_t res = 0;
// Possible packet received, RX -> IDLE (0.1 us)
rflags.CAA = 0;
rflags.MAN_WOR = 0;
cc1100_statistic.packets_in++;
cc110x_statistic.packets_in++;
res = receive_packet((uint8_t*)&(cc1100_rx_buffer[rx_buffer_next].packet), sizeof(cc1100_packet_t));
res = receive_packet((uint8_t*)&(cc110x_rx_buffer[rx_buffer_next].packet), sizeof(cc110x_packet_t));
if (res) {
// If we are sending a burst, don't accept packets.
// Only ACKs are processed (for stopping the burst).
// Same if state machine is in TX lock.
if (radio_state == RADIO_SEND_BURST || rflags.TX)
{
cc1100_statistic.packets_in_while_tx++;
cc110x_statistic.packets_in_while_tx++;
return;
}
cc1100_rx_buffer[rx_buffer_next].rssi = rflags._RSSI;
cc1100_rx_buffer[rx_buffer_next].lqi = rflags._LQI;
cc1100_strobe(CC1100_SFRX); // ...for flushing the RX FIFO
cc110x_rx_buffer[rx_buffer_next].rssi = rflags._RSSI;
cc110x_rx_buffer[rx_buffer_next].lqi = rflags._LQI;
cc110x_strobe(CC1100_SFRX); // ...for flushing the RX FIFO
// Valid packet. After a wake-up, the radio should be in IDLE.
// So put CC1100 to RX for WOR_TIMEOUT (have to manually put
// the radio back to sleep/WOR).
//cc1100_spi_write_reg(CC1100_MCSM0, 0x08); // Turn off FS-Autocal
cc1100_write_reg(CC1100_MCSM2, 0x07); // Configure RX_TIME (until end of packet)
cc1100_strobe(CC1100_SRX);
//cc110x_spi_write_reg(CC1100_MCSM0, 0x08); // Turn off FS-Autocal
cc110x_write_reg(CC1100_MCSM2, 0x07); // Configure RX_TIME (until end of packet)
cc110x_strobe(CC1100_SRX);
hwtimer_wait(IDLE_TO_RX_TIME);
radio_state = RADIO_RX;
@ -69,26 +69,26 @@ void cc1100_rx_handler(void) {
rflags.TOF = 0;
// CRC false or RX buffer full -> clear RX FIFO in both cases
cc1100_strobe(CC1100_SIDLE); // Switch to IDLE (should already be)...
cc1100_strobe(CC1100_SFRX); // ...for flushing the RX FIFO
cc110x_strobe(CC1100_SIDLE); // Switch to IDLE (should already be)...
cc110x_strobe(CC1100_SFRX); // ...for flushing the RX FIFO
// If packet interrupted this nodes send call,
// don't change anything after this point.
if (radio_state == RADIO_AIR_FREE_WAITING)
{
cc1100_strobe(CC1100_SRX);
cc110x_strobe(CC1100_SRX);
hwtimer_wait(IDLE_TO_RX_TIME);
return;
}
// If currently sending, exit here (don't go to RX/WOR)
if (radio_state == RADIO_SEND_BURST)
{
cc1100_statistic.packets_in_while_tx++;
cc110x_statistic.packets_in_while_tx++;
return;
}
// No valid packet, so go back to RX/WOR as soon as possible
cc1100_switch_to_rx();
cc110x_switch_to_rx();
}
}
@ -98,11 +98,11 @@ static uint8_t receive_packet_variable(uint8_t *rxBuffer, uint8_t length) {
uint8_t packetLength = 0;
/* Any bytes available in RX FIFO? */
if ((cc1100_read_status(CC1100_RXBYTES) & BYTES_IN_RXFIFO)) {
if ((cc110x_read_status(CC1100_RXBYTES) & BYTES_IN_RXFIFO)) {
//LED_GREEN_TOGGLE;
//LED_RED_TOGGLE;
// Read length byte (first byte in RX FIFO)
packetLength = cc1100_read_reg(CC1100_RXFIFO);
cc110x_read_fifo((char*) &packetLength, 1);
// Read data from RX FIFO and store in rxBuffer
if (packetLength <= length)
{
@ -110,11 +110,11 @@ static uint8_t receive_packet_variable(uint8_t *rxBuffer, uint8_t length) {
rxBuffer[0] = packetLength;
// Read the rest of the packet
// TODO: Offset + 2 here for cc430
cc1100_readburst_reg(CC1100_RXFIFO, (char*)rxBuffer+1, packetLength);
//cc110x_readburst_reg(CC1100_RXFIFO, (char*)rxBuffer+1, packetLength);
cc110x_read_fifo((char*) rxBuffer + 1, packetLength);
// Read the 2 appended status bytes (status[0] = RSSI, status[1] = LQI)
cc1100_readburst_reg(CC1100_RXFIFO, (char*)status, 2);
cc110x_readburst_reg(CC1100_RXFIFO, (char*)status, 2);
// Store RSSI value of packet
rflags._RSSI = status[I_RSSI];
@ -122,7 +122,7 @@ static uint8_t receive_packet_variable(uint8_t *rxBuffer, uint8_t length) {
// MSB of LQI is the CRC_OK bit
rflags.CRC = (status[I_LQI] & CRC_OK) >> 7;
if (!rflags.CRC) {
cc1100_statistic.packets_in_crc_fail++;
cc110x_statistic.packets_in_crc_fail++;
}
// Bit 0-6 of LQI indicates the link quality (LQI)
@ -145,7 +145,7 @@ static uint8_t receive_packet_variable(uint8_t *rxBuffer, uint8_t length) {
}
static uint8_t receive_packet(uint8_t *rxBuffer, uint8_t length) {
uint8_t pkt_len_cfg = cc1100_read_reg(CC1100_PKTCTRL0) & PKT_LENGTH_CONFIG;
uint8_t pkt_len_cfg = cc110x_read_reg(CC1100_PKTCTRL0) & PKT_LENGTH_CONFIG;
if (pkt_len_cfg == VARIABLE_PKTLEN)
{
return receive_packet_variable(rxBuffer, length);

View File

@ -1,17 +1,17 @@
#include <stdio.h>
#include <cc1100_ng.h>
#include <cc1100-defaultSettings.h>
#include <cc1100-internal.h>
#include <cc1100-arch.h>
#include <cc1100_spi.h>
#include <cc1100-reg.h>
#include <cc110x_ng.h>
#include <cc110x-defaultSettings.h>
#include <cc110x-internal.h>
#include <cc110x-arch.h>
#include <cc110x_spi.h>
#include <cc110x-reg.h>
#include <irq.h>
#include <board.h>
uint8_t cc1100_send(cc1100_packet_t *packet) {
uint8_t cc110x_send(cc110x_packet_t *packet) {
volatile uint32_t abort_count;
uint8_t size;
/* TODO: burst sending */
@ -33,23 +33,23 @@ uint8_t cc1100_send(cc1100_packet_t *packet) {
return 0;
}
packet->phy_src = cc1100_get_address();
packet->phy_src = cc110x_get_address();
// Disables RX interrupt etc.
cc1100_before_send();
cc110x_before_send();
// But CC1100 in IDLE mode to flush the FIFO
cc1100_strobe(CC1100_SIDLE);
cc110x_strobe(CC1100_SIDLE);
// Flush TX FIFO to be sure it is empty
cc1100_strobe(CC1100_SFTX);
cc110x_strobe(CC1100_SFTX);
// Write packet into TX FIFO
cc1100_writeburst_reg(CC1100_TXFIFO, (char*) packet, size);
cc110x_writeburst_reg(CC1100_TXFIFO, (char*) packet, size);
// Switch to TX mode
abort_count = 0;
unsigned int cpsr = disableIRQ();
cc1100_strobe(CC1100_STX);
cc110x_strobe(CC1100_STX);
// Wait for GDO2 to be set -> sync word transmitted
while (cc1100_get_gdo2() == 0) {
while (cc110x_get_gdo2() == 0) {
abort_count++;
if (abort_count > CC1100_SYNC_WORD_TX_TIME) {
// Abort waiting. CC1100 maybe in wrong mode
@ -60,18 +60,18 @@ uint8_t cc1100_send(cc1100_packet_t *packet) {
}
restoreIRQ(cpsr);
// Wait for GDO2 to be cleared -> end of packet
while (cc1100_get_gdo2() != 0);
while (cc110x_get_gdo2() != 0);
//LED_GREEN_TOGGLE;
// Experimental - TOF Measurement
cc1100_after_send();
cc1100_statistic.raw_packets_out++;
cc110x_after_send();
cc110x_statistic.raw_packets_out++;
// Store number of transmission retries
rflags.TX = 0;
// Go to mode after TX (CONST_RX -> RX, WOR -> WOR)
cc1100_switch_to_rx();
cc110x_switch_to_rx();
return true;
}

View File

@ -1,10 +1,10 @@
#include <cc1100_ng.h>
#include <cc1100-arch.h>
#include <cc1100-config.h>
#include <cc1100-defaultSettings.h>
#include <cc1100-internal.h>
#include <cc1100_spi.h>
#include <cc1100-reg.h>
#include <cc110x_ng.h>
#include <cc110x-arch.h>
#include <cc110x-config.h>
#include <cc110x-defaultSettings.h>
#include <cc110x-internal.h>
#include <cc110x_spi.h>
#include <cc110x-reg.h>
#include <hwtimer.h>
#include <config.h>
@ -18,9 +18,9 @@ extern uint8_t pa_table_index; ///< Current PATABLE Index
/* global variables */
cc1100_statistic_t cc1100_statistic;
cc110x_statistic_t cc110x_statistic;
volatile cc1100_flags rflags; ///< Radio control flags
volatile cc110x_flags rflags; ///< Radio control flags
volatile uint8_t radio_state = RADIO_UNKNOWN; ///< Radio state
static radio_address_t radio_address; ///< Radio address
@ -37,7 +37,7 @@ static void write_register(uint8_t r, uint8_t value);
/*---------------------------------------------------------------------------*/
// Radio Driver API
/*---------------------------------------------------------------------------*/
void cc1100_init(int tpid) {
void cc110x_init(int tpid) {
transceiver_pid = tpid;
DEBUG("Transceiver PID: %i\n", transceiver_pid);
@ -45,17 +45,17 @@ void cc1100_init(int tpid) {
#ifdef MODULE_CC110X_SPI
/* Initialize SPI */
cc1100_spi_init();
cc110x_spi_init();
#endif
/* Load driver & reset */
power_up_reset();
/* Write configuration to configuration registers */
cc1100_writeburst_reg(0x00, cc1100_conf, CC1100_CONF_SIZE);
cc110x_writeburst_reg(0x00, cc110x_conf, CC1100_CONF_SIZE);
/* Write PATABLE (power settings) */
cc1100_write_reg(CC1100_PATABLE, pa_table[pa_table_index]);
cc110x_write_reg(CC1100_PATABLE, pa_table[pa_table_index]);
/* Initialize Radio Flags */
rflags._RSSI = 0x00;
@ -70,9 +70,9 @@ void cc1100_init(int tpid) {
/* Set default channel number */
#ifdef MODULE_CONFIG
cc1100_set_config_channel(sysconfig.radio_channel);
cc110x_set_config_channel(sysconfig.radio_channel);
#else
cc1100_set_channel(CC1100_DEFAULT_CHANNR);
cc110x_set_channel(CC1100_DEFAULT_CHANNR);
#endif
DEBUG("CC1100 initialized and set to channel %i\n", radio_channel);
@ -80,31 +80,31 @@ void cc1100_init(int tpid) {
rd_set_mode(RADIO_MODE_ON);
}
void cc1100_disable_interrupts(void) {
cc1100_gdo2_disable();
cc1100_gdo0_disable();
void cc110x_disable_interrupts(void) {
cc110x_gdo2_disable();
cc110x_gdo0_disable();
}
void cc1100_gdo0_irq(void) {
void cc110x_gdo0_irq(void) {
// Air was not free -> Clear CCA flag
rflags.CAA = false;
// Disable carrier sense detection (GDO0 interrupt)
cc1100_gdo0_disable();
cc110x_gdo0_disable();
}
void cc1100_gdo2_irq(void) {
cc1100_rx_handler();
void cc110x_gdo2_irq(void) {
cc110x_rx_handler();
}
uint8_t cc1100_get_buffer_pos(void) {
uint8_t cc110x_get_buffer_pos(void) {
return (rx_buffer_next-1);
}
radio_address_t cc1100_get_address() {
radio_address_t cc110x_get_address() {
return radio_address;
}
radio_address_t cc1100_set_address(radio_address_t address) {
radio_address_t cc110x_set_address(radio_address_t address) {
if ((address < MIN_UID) || (address > MAX_UID)) {
return 0;
}
@ -119,8 +119,8 @@ radio_address_t cc1100_set_address(radio_address_t address) {
}
#ifdef MODULE_CONFIG
radio_address_t cc1100_set_config_address(radio_address_t address) {
radio_address_t a = cc1100_set_address(address);
radio_address_t cc110x_set_config_address(radio_address_t address) {
radio_address_t a = cc110x_set_address(address);
if (a) {
sysconfig.radio_address = a;
}
@ -129,7 +129,7 @@ radio_address_t cc1100_set_config_address(radio_address_t address) {
}
#endif
void cc1100_set_monitor(uint8_t mode) {
void cc110x_set_monitor(uint8_t mode) {
if (mode) {
write_register(CC1100_PKTCTRL1, (0x04));
}
@ -138,43 +138,43 @@ void cc1100_set_monitor(uint8_t mode) {
}
}
void cc1100_setup_rx_mode(void) {
void cc110x_setup_rx_mode(void) {
// Stay in RX mode until end of packet
cc1100_write_reg(CC1100_MCSM2, 0x07);
cc1100_switch_to_rx();
cc110x_write_reg(CC1100_MCSM2, 0x07);
cc110x_switch_to_rx();
}
void cc1100_switch_to_rx(void) {
void cc110x_switch_to_rx(void) {
radio_state = RADIO_RX;
cc1100_strobe(CC1100_SRX);
cc110x_strobe(CC1100_SRX);
}
void cc1100_wakeup_from_rx(void) {
void cc110x_wakeup_from_rx(void) {
if (radio_state != RADIO_RX) {
return;
}
DEBUG("CC1100 going to idle\n");
cc1100_strobe(CC1100_SIDLE);
cc110x_strobe(CC1100_SIDLE);
radio_state = RADIO_IDLE;
}
char* cc1100_get_marc_state(void) {
char* cc110x_get_marc_state(void) {
uint8_t state;
// Save old radio state
uint8_t old_state = radio_state;
// Read content of status register
state = cc1100_read_status(CC1100_MARCSTATE) & MARC_STATE;
state = cc110x_read_status(CC1100_MARCSTATE) & MARC_STATE;
// Make sure in IDLE state.
// Only goes to IDLE if state was RX/WOR
cc1100_wakeup_from_rx();
cc110x_wakeup_from_rx();
// Have to put radio back to WOR/RX if old radio state
// was WOR/RX, otherwise no action is necessary
if (old_state == RADIO_WOR || old_state == RADIO_RX) {
cc1100_switch_to_rx();
cc110x_switch_to_rx();
}
switch (state)
@ -198,7 +198,7 @@ char* cc1100_get_marc_state(void) {
}
}
char* cc1100_state_to_text(uint8_t state) {
char* cc110x_state_to_text(uint8_t state) {
switch (state)
{
case RADIO_UNKNOWN:
@ -222,22 +222,22 @@ char* cc1100_state_to_text(uint8_t state) {
}
}
void cc1100_print_config(void) {
printf("Current radio state: %s\r\n", cc1100_state_to_text(radio_state));
printf("Current MARC state: %s\r\n", cc1100_get_marc_state());
void cc110x_print_config(void) {
printf("Current radio state: %s\r\n", cc110x_state_to_text(radio_state));
printf("Current MARC state: %s\r\n", cc110x_get_marc_state());
printf("Current channel number: %u\r\n", radio_channel);
}
void cc1100_switch_to_pwd(void) {
void cc110x_switch_to_pwd(void) {
DEBUG("[cc110x_ng] switching to powerdown\n");
cc1100_wakeup_from_rx();
cc1100_strobe(CC1100_SPWD);
cc110x_wakeup_from_rx();
cc110x_strobe(CC1100_SPWD);
radio_state = RADIO_PWD;
}
/*---------------------------------------------------------------------------*/
int16_t cc1100_set_channel(uint8_t channr) {
uint8_t state = cc1100_read_status(CC1100_MARCSTATE) & MARC_STATE;
int16_t cc110x_set_channel(uint8_t channr) {
uint8_t state = cc110x_read_status(CC1100_MARCSTATE) & MARC_STATE;
if ((state != 1) && (channr > MAX_CHANNR)) {
return -1;
}
@ -247,8 +247,8 @@ int16_t cc1100_set_channel(uint8_t channr) {
}
#ifdef MODULE_CONFIG
int16_t cc1100_set_config_channel(uint8_t channr) {
int16_t c = cc1100_set_channel(channr);
int16_t cc110x_set_config_channel(uint8_t channr) {
int16_t c = cc110x_set_channel(channr);
if (c) {
sysconfig.radio_channel = c;
}
@ -257,7 +257,7 @@ int16_t cc1100_set_config_channel(uint8_t channr) {
}
#endif
int16_t cc1100_get_channel(void) {
int16_t cc110x_get_channel(void) {
return radio_channel;
}
@ -267,19 +267,19 @@ int16_t cc1100_get_channel(void) {
/*---------------------------------------------------------------------------*/
static void reset(void) {
cc1100_wakeup_from_rx();
cc110x_wakeup_from_rx();
#ifdef MODULE_CC110x_SPI
cc1100_spi_select();
cc110x_spi_select();
#endif
cc1100_strobe(CC1100_SRES);
cc110x_strobe(CC1100_SRES);
hwtimer_wait(RTIMER_TICKS(100));
}
static void power_up_reset(void) {
#ifdef MODULE_CC110x_SPI
cc1100_spi_unselect();
cc1100_spi_cs();
cc1100_spi_unselect();
cc110x_spi_unselect();
cc110x_spi_cs();
cc110x_spi_unselect();
#endif
hwtimer_wait(RESET_WAIT_TIME);
reset();
@ -291,13 +291,13 @@ static void write_register(uint8_t r, uint8_t value) {
uint8_t old_state = radio_state;
/* Wake up from WOR/RX (if in WOR/RX, else no effect) */
cc1100_wakeup_from_rx();
cc1100_write_reg(r, value);
cc110x_wakeup_from_rx();
cc110x_write_reg(r, value);
// Have to put radio back to WOR/RX if old radio state
// was WOR/RX, otherwise no action is necessary
if ((old_state == RADIO_WOR) || (old_state == RADIO_RX)) {
cc1100_switch_to_rx();
cc110x_switch_to_rx();
}
}
@ -315,12 +315,12 @@ static int rd_set_mode(int mode) {
switch (mode) {
case RADIO_MODE_ON:
DEBUG("Enabling rx mode\n");
cc1100_init_interrupts(); // Enable interrupts
cc1100_setup_rx_mode(); // Set chip to desired mode
cc110x_init_interrupts(); // Enable interrupts
cc110x_setup_rx_mode(); // Set chip to desired mode
break;
case RADIO_MODE_OFF:
cc1100_disable_interrupts(); // Disable interrupts
cc1100_switch_to_pwd(); // Set chip to power down mode
cc110x_disable_interrupts(); // Disable interrupts
cc110x_switch_to_pwd(); // Set chip to power down mode
break;
case RADIO_MODE_GET:
// do nothing, just return current mode

View File

@ -1,6 +1,6 @@
#include <irq.h>
#include <cc1100-defaultSettings.h>
#include <cc1100-reg.h>
#include <cc110x-defaultSettings.h>
#include <cc110x-reg.h>
#include <stdint.h>
#include <board.h>
#include <hwtimer.h>
@ -11,7 +11,7 @@
// @param none
// @return none
// *************************************************************************************************
uint8_t cc1100_strobe(uint8_t c) {
uint8_t cc110x_strobe(uint8_t c) {
uint8_t statusByte = 0;
uint16_t int_state, gdo_state;
@ -29,8 +29,8 @@ uint8_t cc1100_strobe(uint8_t c) {
if ((c > RF_SRES) && (c < RF_SNOP))
{
gdo_state = cc1100_read_reg(IOCFG2); // buffer IOCFG2 state
cc1100_write_reg(IOCFG2, 0x29); // c-ready to GDO2
gdo_state = cc110x_read_reg(IOCFG2); // buffer IOCFG2 state
cc110x_write_reg(IOCFG2, 0x29); // c-ready to GDO2
RF1AINSTRB = c;
if ((RF1AIN & 0x04) == 0x04 ) // chip at sleep mode
@ -42,7 +42,7 @@ uint8_t cc1100_strobe(uint8_t c) {
hwtimer_wait(RTIMER_TICKS(9800)); // Delay for ~810usec at 12MHz CPU clock
}
}
cc1100_write_reg(IOCFG2, gdo_state); // restore IOCFG2 setting
cc110x_write_reg(IOCFG2, gdo_state); // restore IOCFG2 setting
}
else // chip active mode
{
@ -57,12 +57,12 @@ uint8_t cc1100_strobe(uint8_t c) {
// *************************************************************************************************
// @fn cc1100_read_reg
// @fn cc110x_read_reg
// @brief Read byte from register.
// @param none
// @return none
// *************************************************************************************************
uint8_t cc1100_read_reg(uint8_t addr) {
uint8_t cc110x_read_reg(uint8_t addr) {
unsigned char x;
uint16_t int_state;
@ -77,12 +77,12 @@ uint8_t cc1100_read_reg(uint8_t addr) {
// *************************************************************************************************
// @fn cc1100_write_reg
// @fn cc110x_write_reg
// @brief Write byte to register.
// @param none
// @return none
// *************************************************************************************************
void cc1100_write_reg(uint8_t addr, uint8_t value) {
void cc110x_write_reg(uint8_t addr, uint8_t value) {
volatile unsigned int i;
uint16_t int_state;
@ -98,7 +98,7 @@ void cc1100_write_reg(uint8_t addr, uint8_t value) {
restoreIRQ(int_state);
}
uint8_t cc1100_read_status(uint8_t addr) {
uint8_t cc110x_read_status(uint8_t addr) {
unsigned char x;
uint16_t int_state;
@ -112,12 +112,12 @@ uint8_t cc1100_read_status(uint8_t addr) {
}
// *************************************************************************************************
// @fn cc1100_readburst_reg
// @fn cc110x_readburst_reg
// @brief Read sequence of bytes from register.
// @param none
// @return none
// *************************************************************************************************
void cc1100_readburst_reg(uint8_t addr, char *buffer, uint8_t count) {
void cc110x_readburst_reg(uint8_t addr, char *buffer, uint8_t count) {
unsigned int i;
uint16_t int_state;
@ -137,14 +137,32 @@ void cc1100_readburst_reg(uint8_t addr, char *buffer, uint8_t count) {
restoreIRQ(int_state);
}
void cc110x_read_fifo(char *buffer, uint8_t count) {
unsigned int i;
uint16_t int_state;
int_state = disableIRQ();
while (!(RF1AIFCTL1 & RFINSTRIFG)); // Wait for the Radio to be ready for next instruction
RF1AINSTR1B = (RF_RXFIFORD); // Send address + Instruction
for (i = 0; i < (count-1); i++)
{
while (!(RFDOUTIFG&RF1AIFCTL1)); // Wait for the Radio Core to update the RF1ADOUTB reg
buffer[i] = RF1ADOUT1B; // Read DOUT from Radio Core + clears RFDOUTIFG
// Also initiates auo-read for next DOUT byte
}
buffer[count-1] = RF1ADOUT0B; // Store the last DOUT from Radio Core
restoreIRQ(int_state);
}
// *************************************************************************************************
// @fn cc1100_writeburst_reg
// @fn cc110x_writeburst_reg
// @brief Write sequence of bytes to register.
// @param none
// @return none
// *************************************************************************************************
uint8_t cc1100_writeburst_reg(uint8_t addr, char *buffer, uint8_t count) {
uint8_t cc110x_writeburst_reg(uint8_t addr, char *buffer, uint8_t count) {
// Write Burst works wordwise not bytewise - bug known already
unsigned char i;
uint16_t int_state;

View File

@ -4,7 +4,7 @@
#include <radio/radio.h>
#include <radio/types.h>
#include <stdint.h>
#include <cc1100-config.h>
#include <cc110x-config.h>
#define CC1100_MAX_DATA_LENGTH (58)
@ -39,9 +39,8 @@
/** @} */
extern volatile cc1100_flags rflags; ///< Radio flags
extern char cc1100_conf[];
extern volatile cc110x_flags rflags; ///< Radio flags
extern char cc110x_conf[];
/**
* @brief CC1100 layer 0 protocol
@ -72,12 +71,12 @@ typedef struct __attribute__ ((packed)) {
uint8_t phy_src; ///< Source address (physical source)
uint8_t flags; ///< Flags
uint8_t data[CC1100_MAX_DATA_LENGTH]; ///< Data (high layer protocol)
} cc1100_packet_t;
} cc110x_packet_t;
typedef struct {
uint8_t rssi;
uint8_t lqi;
cc1100_packet_t packet;
cc110x_packet_t packet;
} rx_buffer_t;
enum radio_mode {
@ -86,51 +85,51 @@ enum radio_mode {
RADIO_MODE_ON = 1 ///< turn radio on
};
extern rx_buffer_t cc1100_rx_buffer[];
extern rx_buffer_t cc110x_rx_buffer[];
extern volatile uint8_t rx_buffer_next; ///< Next packet in RX queue
extern volatile uint8_t radio_state; ///< Radio state
extern cc1100_statistic_t cc1100_statistic;
extern cc110x_statistic_t cc110x_statistic;
int transceiver_pid; ///< the transceiver thread pid
void cc1100_init(int transceiver_pid);
void cc110x_init(int transceiver_pid);
void cc1100_rx_handler(void);
void cc110x_rx_handler(void);
uint8_t cc1100_send(cc1100_packet_t *pkt);
uint8_t cc110x_send(cc110x_packet_t *pkt);
uint8_t cc1100_get_buffer_pos(void);
uint8_t cc110x_get_buffer_pos(void);
void cc1100_setup_rx_mode(void);
void cc1100_switch_to_rx(void);
void cc1100_wakeup_from_rx(void);
void cc1100_switch_to_pwd(void);
void cc110x_setup_rx_mode(void);
void cc110x_switch_to_rx(void);
void cc110x_wakeup_from_rx(void);
void cc110x_switch_to_pwd(void);
void cc1100_disable_interrupts(void);
int16_t cc1100_set_config_channel(uint8_t channr);
int16_t cc1100_set_channel(uint8_t channr);
int16_t cc1100_get_channel(void);
void cc110x_disable_interrupts(void);
int16_t cc110x_set_config_channel(uint8_t channr);
int16_t cc110x_set_channel(uint8_t channr);
int16_t cc110x_get_channel(void);
radio_address_t cc1100_set_address(radio_address_t addr);
radio_address_t cc1100_set_config_address(radio_address_t addr);
radio_address_t cc1100_get_address(void);
void cc1100_set_monitor(uint8_t mode);
radio_address_t cc110x_set_address(radio_address_t addr);
radio_address_t cc110x_set_config_address(radio_address_t addr);
radio_address_t cc110x_get_address(void);
void cc110x_set_monitor(uint8_t mode);
void cc1100_print_config(void);
void cc110x_print_config(void);
/**
* @brief GDO0 interrupt handler.
*/
void cc1100_gdo0_irq(void);
void cc110x_gdo0_irq(void);
/**
* @brief GDO2 interrupt handler.
*
* @note Wakes up MCU on packet reception.
*/
void cc1100_gdo2_irq(void);
void cc110x_gdo2_irq(void);
#endif

View File

@ -39,16 +39,16 @@ and the mailinglist (subscription via web site)
* @author Heiko Will <hwill@inf.fu-berlin.de>
* @version $Revision: 1775 $
*
* @note $Id: cc1100_spi.c 1775 2010-01-26 09:37:03Z hillebra $
* @note $Id: cc110x_spi.c 1775 2010-01-26 09:37:03Z hillebra $
*/
#include <stdio.h>
#include <cc1100_ng.h>
#include <cc1100-arch.h>
#include <cc1100-internal.h>
#include <cc1100_spi.h>
#include <cc1100-reg.h>
#include <cc110x_ng.h>
#include <cc110x-arch.h>
#include <cc110x-internal.h>
#include <cc110x_spi.h>
#include <cc110x-reg.h>
#include <irq.h>
@ -58,70 +58,74 @@ and the mailinglist (subscription via web site)
#define NOBYTE 0xFF
uint8_t cc1100_writeburst_reg(uint8_t addr, char *src, uint8_t count) {
uint8_t cc110x_writeburst_reg(uint8_t addr, char *src, uint8_t count) {
int i = 0;
unsigned int cpsr = disableIRQ();
cc1100_spi_select();
cc1100_txrx(addr | CC1100_WRITE_BURST);
cc110x_spi_select();
cc110x_txrx(addr | CC1100_WRITE_BURST);
while (i < count) {
cc1100_txrx(src[i]);
cc110x_txrx(src[i]);
i++;
}
cc1100_spi_unselect();
cc110x_spi_unselect();
restoreIRQ(cpsr);
return count;
}
void cc1100_readburst_reg(uint8_t addr, char *buffer, uint8_t count) {
void cc110x_readburst_reg(uint8_t addr, char *buffer, uint8_t count) {
int i = 0;
unsigned int cpsr = disableIRQ();
cc1100_spi_select();
cc1100_txrx(addr | CC1100_READ_BURST);
cc110x_spi_select();
cc110x_txrx(addr | CC1100_READ_BURST);
while (i < count) {
buffer[i] = cc1100_txrx(NOBYTE);
buffer[i] = cc110x_txrx(NOBYTE);
i++;
}
cc1100_spi_unselect();
cc110x_spi_unselect();
restoreIRQ(cpsr);
}
void cc1100_write_reg(uint8_t addr, uint8_t value) {
void cc110x_read_fifo(char *buffer, uint8_t count) {
cc110x_readburst_reg(CC1100_RXFIFO, buffer,count);
}
void cc110x_write_reg(uint8_t addr, uint8_t value) {
unsigned int cpsr = disableIRQ();
cc1100_spi_select();
cc1100_txrx(addr);
cc1100_txrx(value);
cc1100_spi_unselect();
cc110x_spi_select();
cc110x_txrx(addr);
cc110x_txrx(value);
cc110x_spi_unselect();
restoreIRQ(cpsr);
}
uint8_t cc1100_read_reg(uint8_t addr) {
uint8_t cc110x_read_reg(uint8_t addr) {
uint8_t result;
unsigned int cpsr = disableIRQ();
cc1100_spi_select();
cc1100_txrx(addr | CC1100_READ_SINGLE);
result = cc1100_txrx(NOBYTE);
cc1100_spi_unselect();
cc110x_spi_select();
cc110x_txrx(addr | CC1100_READ_SINGLE);
result = cc110x_txrx(NOBYTE);
cc110x_spi_unselect();
restoreIRQ(cpsr);
return result;
}
uint8_t cc1100_read_status(uint8_t addr) {
uint8_t cc110x_read_status(uint8_t addr) {
uint8_t result;
unsigned int cpsr = disableIRQ();
cc1100_spi_select();
cc1100_txrx(addr | CC1100_READ_BURST);
result = cc1100_txrx(NOBYTE);
cc1100_spi_unselect();
cc110x_spi_select();
cc110x_txrx(addr | CC1100_READ_BURST);
result = cc110x_txrx(NOBYTE);
cc110x_spi_unselect();
restoreIRQ(cpsr);
return result;
}
uint8_t cc1100_strobe(uint8_t c) {
uint8_t cc110x_strobe(uint8_t c) {
uint8_t result;
unsigned int cpsr = disableIRQ();
cc1100_spi_select();
result = cc1100_txrx(c);
cc1100_spi_unselect();
cc110x_spi_select();
result = cc110x_txrx(c);
cc110x_spi_unselect();
restoreIRQ(cpsr);
return result;
}

View File

@ -38,20 +38,20 @@ and the mailinglist (subscription via web site)
* @author Heiko Will <hwill@inf.fu-berlin.de>
* @version $Revision: 1775 $
*
* @note $Id: cc1100_spi.h 1775 2010-01-26 09:37:03Z hillebra $
* @note $Id: cc110x_spi.h 1775 2010-01-26 09:37:03Z hillebra $
*/
#ifndef CC1100_SPI_H_
#define CC1100_SPI_H_
int cc1100_get_gdo0(void);
int cc1100_get_gdo1(void);
int cc1100_get_gdo2(void);
int cc110x_get_gdo0(void);
int cc110x_get_gdo1(void);
int cc110x_get_gdo2(void);
void cc1100_spi_init(void);
void cc1100_spi_cs(void);
void cc1100_spi_select(void);
void cc1100_spi_unselect(void);
void cc110x_spi_init(void);
void cc110x_spi_cs(void);
void cc110x_spi_select(void);
void cc110x_spi_unselect(void);
/** @} */
#endif /* CC1100_SPI_H_ */

View File

@ -6,10 +6,10 @@
#include <thread.h>
#include <board.h>
#include <hwtimer.h>
#include <swtimer.h>
#include <vtimer.h>
#include <msg.h>
#include <transceiver.h>
#include <cc1100_ng.h>
#include <cc110x_ng.h>
#define RADIO_STACK_SIZE (512)
#define SEND_SIZE CC1100_MAX_DATA_LENGTH
@ -39,6 +39,8 @@ void send(radio_address_t dst, uint8_t len, uint8_t *data) {
p.length = len;
p.dst = dst;
display_chars(LCD_SEG_L2_5_0, "CC1100", SEG_OFF);
display_chars(LCD_SEG_L2_5_0, (char*) itoa(p.dst, 6, 0), SEG_ON);
p.data = data;
msg_send(&mesg, transceiver_pid, 1);
@ -58,6 +60,9 @@ void radio(void) {
display_chars(LCD_SEG_L2_5_0, "CC1100", SEG_OFF);
display_chars(LCD_SEG_L2_5_0, (char*) p->data, SEG_ON);
send(p->src, p->length, p->data);
hwtimer_wait(50000);
send(p->src, sizeof(p->length), &(p->length));
p->processing--;
}
else if (m.type == ENOBUFFER) {
@ -86,7 +91,7 @@ int main(void) {
tcmd.data = &addr;
msg_send(&mesg, transceiver_pid, 1);
send(0, SEND_SIZE, snd_buffer);
send(12, SEND_SIZE, snd_buffer);
while (1) {
hwtimer_wait(SENDING_DELAY);

View File

@ -10,7 +10,7 @@
#include <swtimer.h>
#include <msg.h>
#include <transceiver.h>
#include <cc1100_ng.h>
#include <cc110x_ng.h>
#define SHELL_STACK_SIZE (2048)
#define RADIO_STACK_SIZE (2048)
@ -81,9 +81,9 @@ void print_buffer(char *unused) {
for (i = 0; i < TRANSCEIVER_BUFFER_SIZE; i++) {
printf("[%u] %u # %u # %u\n", i, transceiver_buffer[i].processing, transceiver_buffer[i].length, transceiver_buffer[i].data[i]);
}
extern rx_buffer_t cc1100_rx_buffer[];
extern rx_buffer_t cc110x_rx_buffer[];
for (i = 0; i < TRANSCEIVER_BUFFER_SIZE; i++) {
printf("[%u] %u # %u \n", i, cc1100_rx_buffer[i].packet.length, cc1100_rx_buffer[i].packet.data[i]);
printf("[%u] %u # %u \n", i, cc110x_rx_buffer[i].packet.length, cc110x_rx_buffer[i].packet.data[i]);
}
}

View File

@ -28,7 +28,7 @@
SubDir TOP sys shell ;
Module shell : shell.c ;
Module shell_commands : shell_commands.c id.c rtc.c sht11.c ltc4150.c cc1100.c cc1100_ng.c : shell ;
Module shell_commands : shell_commands.c id.c rtc.c sht11.c ltc4150.c cc1100.c cc110x_ng.c : shell ;
Module ps : ps.c ;

View File

@ -2,7 +2,7 @@
#include <stdlib.h>
#include <string.h>
#include <transceiver.h>
#include <cc1100_ng.h>
#include <cc110x_ng.h>
#include <msg.h>
#define TEXT_SIZE CC1100_MAX_DATA_LENGTH
@ -11,7 +11,7 @@ char text_msg[TEXT_SIZE];
msg mesg;
transceiver_command_t tcmd;
void _cc1100_ng_get_set_address_handler(char *addr) {
void _cc110x_ng_get_set_address_handler(char *addr) {
int16_t a;
tcmd.transceivers = TRANSCEIVER_CC1100;
@ -19,17 +19,17 @@ void _cc1100_ng_get_set_address_handler(char *addr) {
mesg.content.ptr = (char*) &tcmd;
a = atoi(addr+5);
if (strlen(addr) > 5) {
printf("[cc1100] Trying to set address %i\n", a);
printf("[cc110x] Trying to set address %i\n", a);
mesg.type = SET_ADDRESS;
}
else {
mesg.type = GET_ADDRESS;
}
msg_send_receive(&mesg, &mesg, transceiver_pid);
printf("[cc1100] Got address: %i\n", a);
printf("[cc110x] Got address: %i\n", a);
}
void _cc1100_ng_get_set_channel_handler(char *chan) {
void _cc110x_ng_get_set_channel_handler(char *chan) {
int16_t c;
tcmd.transceivers = TRANSCEIVER_CC1100;
@ -37,17 +37,17 @@ void _cc1100_ng_get_set_channel_handler(char *chan) {
mesg.content.ptr = (char*) &tcmd;
c = atoi(chan+5);
if (strlen(chan) > 5) {
printf("[cc1100] Trying to set channel %i\n", c);
printf("[cc110x] Trying to set channel %i\n", c);
mesg.type = SET_CHANNEL;
}
else {
mesg.type = GET_CHANNEL;
}
msg_send_receive(&mesg, &mesg, transceiver_pid);
printf("[cc1100] Got channel: %i\n", c);
printf("[cc110x] Got channel: %i\n", c);
}
void _cc1100_ng_send_handler(char *pkt) {
void _cc110x_ng_send_handler(char *pkt) {
radio_packet_t p;
uint32_t response;
uint16_t addr;
@ -69,17 +69,17 @@ void _cc1100_ng_send_handler(char *pkt) {
p.dst = addr;
mesg.type = SND_PKT;
mesg.content.ptr = (char*) &tcmd;
printf("[cc1100] Sending packet of length %u to %hu: %s\n", p.length, p.dst, (char*) p.data);
printf("[cc110x] Sending packet of length %u to %hu: %s\n", p.length, p.dst, (char*) p.data);
msg_send_receive(&mesg, &mesg, transceiver_pid);
response = mesg.content.value;
printf("[cc1100] Packet sent: %lu\n", response);
printf("[cc110x] Packet sent: %lu\n", response);
return;
}
}
puts("Usage:\ttxtsnd <ADDR> <MSG>");
}
void _cc1100_ng_monitor_handler(char *mode) {
void _cc110x_ng_monitor_handler(char *mode) {
unsigned int m;
tcmd.transceivers = TRANSCEIVER_CC1100;

View File

@ -24,16 +24,16 @@ extern void _reset_current_handler(char* unused);
#endif
#ifdef MODULE_CC110X
extern void _cc1100_get_address_handler(char *unused);
extern void _cc1100_set_address_handler(char *ptr);
extern void _cc110x_get_address_handler(char *unused);
extern void _cc110x_set_address_handler(char *ptr);
#endif
#ifdef MODULE_TRANSCEIVER
#ifdef MODULE_CC110X_NG
extern void _cc1100_ng_get_set_address_handler(char *addr);
extern void _cc1100_ng_get_set_channel_handler(char *chan);
extern void _cc1100_ng_send_handler(char *pkt);
extern void _cc1100_ng_monitor_handler(char *mode);
extern void _cc110x_ng_get_set_address_handler(char *addr);
extern void _cc110x_ng_get_set_channel_handler(char *chan);
extern void _cc110x_ng_send_handler(char *pkt);
extern void _cc110x_ng_monitor_handler(char *mode);
#endif
#endif
@ -56,15 +56,15 @@ const shell_command_t _shell_command_list[] = {
{"rstcur", "Resets coulomb counter.", _reset_current_handler},
#endif
#ifdef MODULE_CC110X
{"cc1100_get_address", "", _cc1100_get_address_handler},
{"cc1100_set_address", "", _cc1100_set_address_handler},
{"cc110x_get_address", "", _cc110x_get_address_handler},
{"cc110x_set_address", "", _cc110x_set_address_handler},
#endif
#ifdef MODULE_TRANSCEIVER
#ifdef MODULE_CC110X_NG
{"addr", "Gets or sets the address for the CC1100 transceiver", _cc1100_ng_get_set_address_handler},
{"chan", "Gets or sets the channel for the CC1100 transceiver", _cc1100_ng_get_set_channel_handler},
{"txtsnd", "Sends a text message to a given node via the CC1100 transceiver", _cc1100_ng_send_handler},
{"monitor", "Enables or disables address checking for the CC1100 transceiver", _cc1100_ng_monitor_handler},
{"addr", "Gets or sets the address for the CC1100 transceiver", _cc110x_ng_get_set_address_handler},
{"chan", "Gets or sets the channel for the CC1100 transceiver", _cc110x_ng_get_set_channel_handler},
{"txtsnd", "Sends a text message to a given node via the CC1100 transceiver", _cc110x_ng_send_handler},
{"monitor", "Enables or disables address checking for the CC1100 transceiver", _cc110x_ng_monitor_handler},
#endif
#endif
{NULL, NULL, NULL}

View File

@ -12,7 +12,7 @@
/* supported transceivers */
#ifdef MODULE_CC110X_NG
#include <cc1100_ng.h>
#include <cc110x_ng.h>
#if (CC1100_MAX_DATA_LENGTH > PAYLOAD_SIZE)
#undef PAYLOAD_SIZE
#define PAYLOAD_SIZE (CC1100_MAX_DATA_LENGTH)
@ -50,7 +50,7 @@ char transceiver_stack[TRANSCEIVER_STACK_SIZE];
/* function prototypes */
static void run(void);
static void receive_packet(uint16_t type, uint8_t pos);
static void receive_cc1100_packet(radio_packet_t *trans_p);
static void receive_cc110x_packet(radio_packet_t *trans_p);
static uint8_t send_packet(transceiver_type_t t, void *pkt);
static int16_t get_channel(transceiver_type_t t);
static int16_t set_channel(transceiver_type_t t, void *channel);
@ -84,7 +84,7 @@ int transceiver_start(void) {
}
else if (transceivers & TRANSCEIVER_CC1100) {
DEBUG("Transceiver started for CC1100\n");
cc1100_init(transceiver_pid);
cc110x_init(transceiver_pid);
}
return transceiver_pid;
}
@ -213,7 +213,7 @@ static void receive_packet(uint16_t type, uint8_t pos) {
m.type = PKT_PENDING;
if (type == RCV_PKT_CC1100) {
receive_cc1100_packet(trans_p);
receive_cc110x_packet(trans_p);
}
else {
puts("Invalid transceiver type");
@ -241,16 +241,16 @@ static void receive_packet(uint16_t type, uint8_t pos) {
*
* @param trans_p The current entry in the transceiver buffer
*/
static void receive_cc1100_packet(radio_packet_t *trans_p) {
static void receive_cc110x_packet(radio_packet_t *trans_p) {
DEBUG("Handling CC1100 packet\n");
/* disable interrupts while copying packet */
dINT();
cc1100_packet_t p = cc1100_rx_buffer[rx_buffer_pos].packet;
cc110x_packet_t p = cc110x_rx_buffer[rx_buffer_pos].packet;
trans_p->src = p.phy_src;
trans_p->dst = p.address;
trans_p->rssi = cc1100_rx_buffer[rx_buffer_pos].rssi;
trans_p->lqi = cc1100_rx_buffer[rx_buffer_pos].lqi;
trans_p->rssi = cc110x_rx_buffer[rx_buffer_pos].rssi;
trans_p->lqi = cc110x_rx_buffer[rx_buffer_pos].lqi;
trans_p->length = p.length - CC1100_HEADER_LENGTH;
memcpy((void*) &(data_buffer[transceiver_buffer_pos * PAYLOAD_SIZE]), p.data, CC1100_MAX_DATA_LENGTH);
eINT();
@ -271,16 +271,16 @@ static void receive_cc1100_packet(radio_packet_t *trans_p) {
static uint8_t send_packet(transceiver_type_t t, void *pkt) {
uint8_t res = 0;
radio_packet_t p = *((radio_packet_t*) pkt);
cc1100_packet_t cc1100_pkt;
cc110x_packet_t cc110x_pkt;
switch (t) {
case TRANSCEIVER_CC1100:
cc1100_pkt.length = p.length + CC1100_HEADER_LENGTH;
cc1100_pkt.address = p.dst;
cc1100_pkt.flags = 0;
memcpy(cc1100_pkt.data, p.data, p.length);
cc110x_pkt.length = p.length + CC1100_HEADER_LENGTH;
cc110x_pkt.address = p.dst;
cc110x_pkt.flags = 0;
memcpy(cc110x_pkt.data, p.data, p.length);
res = cc1100_send(&cc1100_pkt);
res = cc110x_send(&cc110x_pkt);
break;
default:
puts("Unknown transceiver");
@ -302,7 +302,7 @@ static int16_t set_channel(transceiver_type_t t, void *channel) {
uint8_t c = *((uint8_t*) channel);
switch (t) {
case TRANSCEIVER_CC1100:
return cc1100_set_channel(c);
return cc110x_set_channel(c);
default:
return -1;
}
@ -318,7 +318,7 @@ static int16_t set_channel(transceiver_type_t t, void *channel) {
static int16_t get_channel(transceiver_type_t t) {
switch (t) {
case TRANSCEIVER_CC1100:
return cc1100_get_channel();
return cc110x_get_channel();
default:
return -1;
}
@ -334,7 +334,7 @@ static int16_t get_channel(transceiver_type_t t) {
static int16_t get_address(transceiver_type_t t) {
switch (t) {
case TRANSCEIVER_CC1100:
return cc1100_get_address();
return cc110x_get_address();
default:
return -1;
}
@ -352,7 +352,7 @@ static int16_t set_address(transceiver_type_t t, void *address) {
radio_address_t addr = *((radio_address_t*) address);
switch (t) {
case TRANSCEIVER_CC1100:
return cc1100_set_address(addr);
return cc110x_set_address(addr);
default:
return -1;
}
@ -367,7 +367,7 @@ static int16_t set_address(transceiver_type_t t, void *address) {
static void set_monitor(transceiver_type_t t, void *mode) {
switch (t) {
case TRANSCEIVER_CC1100:
cc1100_set_monitor(*((uint8_t*) mode));
cc110x_set_monitor(*((uint8_t*) mode));
break;
default:
break;
@ -377,7 +377,7 @@ static void set_monitor(transceiver_type_t t, void *mode) {
static void powerdown(transceiver_type_t t) {
switch (t) {
case TRANSCEIVER_CC1100:
cc1100_switch_to_pwd();
cc110x_switch_to_pwd();
break;
default:
break;
@ -388,7 +388,7 @@ static void powerdown(transceiver_type_t t) {
static void switch_to_rx(transceiver_type_t t) {
switch (t) {
case TRANSCEIVER_CC1100:
cc1100_switch_to_rx();
cc110x_switch_to_rx();
break;
default:
break;