commit
f90032f94f
@ -1,3 +1,2 @@
|
||||
FEATURES_PROVIDED += transceiver
|
||||
FEATURES_PROVIDED += periph_rtc
|
||||
FEATURES_MCU_GROUP = arm7
|
||||
|
@ -1,12 +1,2 @@
|
||||
export INCLUDES += -I$(RIOTBOARD)/avsextrem/include
|
||||
|
||||
ifneq (,$(filter defaulttransceiver,$(USEMODULE)))
|
||||
USEMODULE += cc110x_legacy
|
||||
USEMODULE += transceiver
|
||||
endif
|
||||
|
||||
ifneq (,$(filter cc110x_legacy_csma,$(USEMODULE)))
|
||||
INCLUDES += -I$(RIOTBASE)/sys/net/include
|
||||
endif
|
||||
|
||||
export INCLUDES += -I$(RIOTCPU)/$(CPU)/include/ -I$(RIOTBOARD)/$(BOARD)/include/
|
||||
include $(RIOTBOARD)/msba2-common/Makefile.include
|
||||
|
@ -1,254 +0,0 @@
|
||||
/*
|
||||
* avsextrem-cc1100.c - CC100 Transceiver Driver for the AVSEXTREM-BOARD.
|
||||
* Copyright (C) 2013 Heiko Will <hwill@inf.fu-berlin.de>
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
* directory for more details.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @ingroup LPC2387
|
||||
* @brief CC1100 LPC2387 dependend functions
|
||||
*
|
||||
* @author Heiko Will <hwill@inf.fu-berlin.de>
|
||||
* @author Thomas Hillebrandt <hillebra@inf.fu-berlin.de>
|
||||
* @author Zakaria Kasmi <zkasmi@inf.fu-berlin.de>
|
||||
*
|
||||
* @version $Revision: 1781 $
|
||||
*
|
||||
* @note $Id: avsextrem-cc1100.c 1781 2013-08-14 13:39:36Z kasmi $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stddef.h>
|
||||
// cpu
|
||||
#include "cpu.h"
|
||||
// sys
|
||||
#include "cc110x_legacy.h"
|
||||
#include "gpioint.h"
|
||||
|
||||
#define CC1100_GDO0 (FIO2PIN & BIT6) // read serial I/O (GDO0)
|
||||
#define CC1100_GDO1 (FIO0PIN & BIT8) // read serial I/O (GDO1)
|
||||
#define CC1100_GDO2 (FIO0PIN & BIT28) // read serial I/O (GDO2)
|
||||
|
||||
#define SPI_TX_EMPTY (SSP1SR & SSPSR_TFE)
|
||||
#define SPI_BUSY (SSP1SR & SSPSR_BSY)
|
||||
#define SPI_RX_AVAIL (SSP1SR & SSPSR_RNE)
|
||||
|
||||
#define CC1100_GDO1_LOW_RETRY (100) // max. retries for GDO1 to go low
|
||||
#define CC1100_GDO1_LOW_COUNT (2700) // loop count (timeout ~ 500 us) to wait
|
||||
// for GDO1 to go low when CS low
|
||||
|
||||
//#define DEBUG
|
||||
#ifdef DEBUG
|
||||
|
||||
static unsigned long time_value;
|
||||
|
||||
static void set_time(void)
|
||||
{
|
||||
time_value = 0;
|
||||
}
|
||||
|
||||
static int test_time(int code)
|
||||
{
|
||||
time_value++;
|
||||
|
||||
if (time_value > 10000000) {
|
||||
printf("CC1100 SPI alarm: %d!\n", code);
|
||||
time_value = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
int cc110x_get_gdo0(void)
|
||||
{
|
||||
return CC1100_GDO0;
|
||||
}
|
||||
|
||||
int cc110x_get_gdo1(void)
|
||||
{
|
||||
return CC1100_GDO1;
|
||||
}
|
||||
|
||||
int cc110x_get_gdo2(void)
|
||||
{
|
||||
return CC1100_GDO2;
|
||||
}
|
||||
|
||||
void cc110x_spi_init(void)
|
||||
{
|
||||
// configure chip-select
|
||||
FIO0DIR |= BIT6;
|
||||
FIO0SET = BIT6;
|
||||
|
||||
// Power
|
||||
PCONP |= PCSSP1; // Enable power for SSP1 (default is on)
|
||||
|
||||
// PIN Setup
|
||||
PINSEL0 |= BIT15; // Set CLK function to SSP1
|
||||
PINSEL0 &= ~BIT14;
|
||||
PINSEL0 |= BIT17 ; // Set MISO function to SSP1
|
||||
PINSEL0 &= ~BIT16;
|
||||
PINSEL0 |= BIT19; // Set MOSI function to SSP1
|
||||
PINSEL0 &= ~BIT18;
|
||||
// Interface Setup
|
||||
SSP1CR0 = 7;
|
||||
|
||||
// Clock Setup
|
||||
uint32_t pclksel;
|
||||
uint32_t cpsr;
|
||||
lpc2387_pclk_scale(F_CPU / 1000, 6000, &pclksel, &cpsr);
|
||||
PCLKSEL0 &= ~(BIT21 | BIT20); // CCLK to PCLK divider
|
||||
PCLKSEL0 |= pclksel << 20;
|
||||
SSP1CPSR = cpsr;
|
||||
|
||||
// Enable
|
||||
SSP1CR1 |= BIT1; // SSP-Enable
|
||||
int dummy;
|
||||
|
||||
// Clear RxFIFO:
|
||||
while (SPI_RX_AVAIL) { // while RNE (Receive FIFO Not Empty)...
|
||||
dummy = SSP1DR; // read data
|
||||
}
|
||||
|
||||
/* to suppress unused-but-set-variable */
|
||||
(void) dummy;
|
||||
}
|
||||
|
||||
uint8_t
|
||||
cc110x_txrx(uint8_t c)
|
||||
{
|
||||
uint8_t result;
|
||||
SSP1DR = c;
|
||||
#ifdef DEBUG
|
||||
set_time();
|
||||
#endif
|
||||
|
||||
while (!SPI_TX_EMPTY) {
|
||||
#ifdef DEBUG
|
||||
test_time(0);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
set_time();
|
||||
#endif
|
||||
|
||||
while (SPI_BUSY) {
|
||||
#ifdef DEBUG
|
||||
test_time(1);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
set_time();
|
||||
#endif
|
||||
|
||||
while (!SPI_RX_AVAIL) {
|
||||
#ifdef DEBUG
|
||||
test_time(2);
|
||||
#endif
|
||||
}
|
||||
|
||||
result = (uint8_t)SSP1DR;
|
||||
return result;
|
||||
}
|
||||
|
||||
void cc110x_spi_cs(void)
|
||||
{
|
||||
FIO0CLR = BIT6;
|
||||
}
|
||||
|
||||
void
|
||||
cc110x_spi_select(void)
|
||||
{
|
||||
volatile int retry_count = 0;
|
||||
volatile int abort_count;
|
||||
// Switch to GDO mode input
|
||||
PINSEL0 &= ~(BIT17 + BIT16); // Set MISO function to GPIO
|
||||
FIO0DIR &= ~BIT8;
|
||||
cs_low:
|
||||
// CS to low
|
||||
abort_count = 0;
|
||||
FIO0CLR = BIT6;
|
||||
// Wait for SO to go low (voltage regulator
|
||||
// has stabilized and the crystal is running)
|
||||
loop:
|
||||
asm volatile("nop");
|
||||
|
||||
if (CC1100_GDO1) {
|
||||
abort_count++;
|
||||
|
||||
if (abort_count > CC1100_GDO1_LOW_COUNT) {
|
||||
retry_count++;
|
||||
|
||||
if (retry_count > CC1100_GDO1_LOW_RETRY) {
|
||||
puts("[CC1100 SPI] fatal error\n");
|
||||
goto final;
|
||||
}
|
||||
|
||||
FIO0SET = BIT6; // CS to high
|
||||
goto cs_low; // try again
|
||||
}
|
||||
|
||||
goto loop;
|
||||
}
|
||||
|
||||
final:
|
||||
// Switch to SPI mode
|
||||
PINSEL0 |= BIT17; // Set MISO function to SSP1
|
||||
PINSEL0 &= ~BIT16;
|
||||
}
|
||||
|
||||
void
|
||||
cc110x_spi_unselect(void)
|
||||
{
|
||||
FIO0SET = BIT6;
|
||||
}
|
||||
|
||||
void cc110x_gdo2_disable(void)
|
||||
{
|
||||
gpioint_set(0, BIT28, GPIOINT_DISABLE, NULL);
|
||||
}
|
||||
|
||||
void cc110x_gdo2_enable(void)
|
||||
{
|
||||
gpioint_set(0, BIT28, GPIOINT_FALLING_EDGE, &cc110x_gdo2_irq);
|
||||
}
|
||||
|
||||
void cc110x_before_send(void)
|
||||
{
|
||||
// Disable GDO2 interrupt before sending packet
|
||||
cc110x_gdo2_disable();
|
||||
}
|
||||
|
||||
void cc110x_after_send(void)
|
||||
{
|
||||
// Enable GDO2 interrupt after sending packet
|
||||
cc110x_gdo2_enable();
|
||||
}
|
||||
|
||||
void cc110x_gdo0_enable(void)
|
||||
{
|
||||
gpioint_set(2, BIT6, GPIOINT_RISING_EDGE, &cc110x_gdo0_irq);
|
||||
}
|
||||
|
||||
void cc110x_gdo0_disable(void)
|
||||
{
|
||||
gpioint_set(2, BIT6, GPIOINT_DISABLE, NULL);
|
||||
}
|
||||
|
||||
void cc110x_init_interrupts(void)
|
||||
{
|
||||
// Enable external interrupt on low edge (for GDO2)
|
||||
FIO0DIR &= ~BIT28;
|
||||
cc110x_gdo2_enable();
|
||||
// Enable external interrupt on low edge (for GDO0)
|
||||
FIO2DIR &= ~BIT6;
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
ifneq (,$(filter defaulttransceiver,$(USEMODULE)))
|
||||
USEMODULE += cc110x_legacy
|
||||
USEMODULE += transceiver
|
||||
endif
|
@ -1,3 +1,2 @@
|
||||
FEATURES_PROVIDED += transceiver
|
||||
FEATURES_PROVIDED += periph_rtc
|
||||
FEATURES_MCU_GROUP = msp430
|
||||
|
@ -1,112 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2014 INRIA
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
* directory for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup chronos
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief eZ430-chronos radio driver (board dependent part)
|
||||
*
|
||||
* @author Oliver Hahm <oliver.hahm@inria.fr>
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdint.h>
|
||||
#include <cc430f6137.h>
|
||||
|
||||
#include "cpu.h"
|
||||
#include "irq.h"
|
||||
#include "cc110x_legacy.h"
|
||||
|
||||
#define CC1100_GDO0 (RF1AIN & BIT0)
|
||||
#define CC1100_GDO1 (RF1AIN & BIT1)
|
||||
#define CC1100_GDO2 (RF1AIN & BIT2)
|
||||
|
||||
int cc110x_get_gdo0(void)
|
||||
{
|
||||
return CC1100_GDO0;
|
||||
}
|
||||
|
||||
int cc110x_get_gdo1(void)
|
||||
{
|
||||
return CC1100_GDO1;
|
||||
}
|
||||
|
||||
int cc110x_get_gdo2(void)
|
||||
{
|
||||
return CC1100_GDO2;
|
||||
}
|
||||
|
||||
void cc110x_before_send(void)
|
||||
{
|
||||
// Disable GDO2 interrupt before sending packet
|
||||
cc110x_gdo2_disable();
|
||||
}
|
||||
|
||||
void cc110x_after_send(void)
|
||||
{
|
||||
// Enable GDO2 interrupt after sending packet
|
||||
cc110x_gdo2_enable();
|
||||
}
|
||||
|
||||
void cc110x_gdo0_enable(void)
|
||||
{
|
||||
RF1AIFG &= ~BIT0;
|
||||
RF1AIE |= BIT0;
|
||||
}
|
||||
|
||||
void cc110x_gdo0_disable(void)
|
||||
{
|
||||
RF1AIE &= ~BIT0;
|
||||
RF1AIFG &= ~BIT0;
|
||||
}
|
||||
|
||||
void cc110x_gdo2_disable(void)
|
||||
{
|
||||
RF1AIFG &= ~BIT2; // Clear a pending interrupt
|
||||
RF1AIE &= ~BIT2; // Disable the interrupt
|
||||
}
|
||||
|
||||
void cc110x_gdo2_enable(void)
|
||||
{
|
||||
RF1AIFG &= ~BIT2; // Clear a pending interrupt
|
||||
RF1AIE |= BIT2; // Enable the interrupt
|
||||
}
|
||||
|
||||
void cc110x_init_interrupts(void)
|
||||
{
|
||||
uint8_t state = disableIRQ(); /* Disable all interrupts */
|
||||
cc110x_gdo2_enable();
|
||||
cc110x_gdo0_disable();
|
||||
restoreIRQ(state); /* Enable all interrupts */
|
||||
}
|
||||
|
||||
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;
|
||||
cc110x_gdo2_irq();
|
||||
}
|
||||
|
||||
if (RF1AIV == RF1AIV_RFIFG0) {
|
||||
cc110x_gdo0_irq();
|
||||
RF1AIE &= ~BIT0;
|
||||
}
|
||||
|
||||
__exit_isr();
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
ifneq (,$(filter defaulttransceiver,$(USEMODULE)))
|
||||
USEMODULE += at86rf231
|
||||
ifeq (,$(filter netdev_base,$(USEMODULE)))
|
||||
USEMODULE += transceiver
|
||||
endif
|
||||
endif
|
@ -1,8 +0,0 @@
|
||||
ifneq (,$(filter defaulttransceiver,$(USEMODULE)))
|
||||
USEMODULE += cc110x_legacy
|
||||
USEMODULE += transceiver
|
||||
endif
|
||||
|
||||
ifneq (,$(filter cc110x_legacy,$(USEMODULE)))
|
||||
USEMODULE += cc110x_spi
|
||||
endif
|
@ -1,2 +1,2 @@
|
||||
FEATURES_PROVIDED += transceiver config
|
||||
FEATURES_PROVIDED += config
|
||||
FEATURES_MCU_GROUP = msp430
|
||||
|
@ -1,347 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005, 2006, 2007, 2008 by Thomas Hillebrandt and Heiko Will
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
* directory for more details.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "board.h"
|
||||
#include "cpu.h"
|
||||
#include "irq.h"
|
||||
|
||||
#include "cc110x_legacy.h"
|
||||
|
||||
#define CC1100_GDO0 (P2IN & 0x02) // read serial I/O (GDO0)
|
||||
#define CC1100_GDO1 (P3IN & 0x04) // read serial I/O (GDO1)
|
||||
#define CC1100_GDO2 (P2IN & 0x01) // read serial I/O (GDO2)
|
||||
|
||||
#define CC1100_CS_LOW (P3OUT &= ~0x01)
|
||||
#define CC1100_CS_HIGH (P3OUT |= 0x01)
|
||||
|
||||
#define CC1100_GDO1_LOW_COUNT (2700) // loop count (timeout ~ 500 us) to wait
|
||||
#define CC1100_GDO1_LOW_RETRY (100) // max. retries for GDO1 to go low
|
||||
|
||||
volatile int abort_count;
|
||||
volatile int retry_count = 0;
|
||||
|
||||
void cc110x_gdo0_enable(void)
|
||||
{
|
||||
P2IFG &= ~0x02; /* Clear IFG for GDO0 */
|
||||
P2IE |= 0x02; /* Enable interrupt for GDO0 */
|
||||
}
|
||||
|
||||
void cc110x_gdo0_disable(void)
|
||||
{
|
||||
P2IE &= ~0x02; /* Disable interrupt for GDO0 */
|
||||
P2IFG &= ~0x02; /* Clear IFG for GDO0 */
|
||||
}
|
||||
|
||||
void cc110x_gdo2_enable(void)
|
||||
{
|
||||
P2IFG &= ~0x01; /* Clear IFG for GDO2 */
|
||||
P2IE |= 0x01; /* Enable interrupt for GDO2 */
|
||||
}
|
||||
|
||||
void cc110x_gdo2_disable(void)
|
||||
{
|
||||
P2IE &= ~0x01; /* Disable interrupt for GDO2 */
|
||||
P2IFG &= ~0x01; /* Clear IFG for GDO2 */
|
||||
}
|
||||
|
||||
void cc110x_before_send(void)
|
||||
{
|
||||
// Disable GDO2 interrupt before sending packet
|
||||
cc110x_gdo2_disable();
|
||||
}
|
||||
|
||||
void cc110x_after_send(void)
|
||||
{
|
||||
// Enable GDO2 interrupt after sending packet
|
||||
cc110x_gdo2_enable();
|
||||
}
|
||||
|
||||
|
||||
int cc110x_get_gdo0(void)
|
||||
{
|
||||
return CC1100_GDO0;
|
||||
}
|
||||
|
||||
int cc110x_get_gdo1(void)
|
||||
{
|
||||
return CC1100_GDO1;
|
||||
}
|
||||
|
||||
int cc110x_get_gdo2(void)
|
||||
{
|
||||
return CC1100_GDO2;
|
||||
}
|
||||
|
||||
void cc110x_spi_cs(void)
|
||||
{
|
||||
CC1100_CS_LOW;
|
||||
}
|
||||
|
||||
uint8_t cc110x_txrx(uint8_t data)
|
||||
{
|
||||
/* Ensure TX Buf is empty */
|
||||
long c = 0;
|
||||
IFG1 &= ~UTXIFG0;
|
||||
IFG1 &= ~URXIFG0;
|
||||
TXBUF0 = data;
|
||||
|
||||
while (!(IFG1 & UTXIFG0)) {
|
||||
if (c++ == 1000000) {
|
||||
puts("cc110x_txrx alarm()");
|
||||
}
|
||||
}
|
||||
|
||||
/* Wait for Byte received */
|
||||
c = 0;
|
||||
|
||||
while (!(IFG1 & URXIFG0)) {
|
||||
if (c++ == 1000000) {
|
||||
puts("cc110x_txrx alarm()");
|
||||
}
|
||||
}
|
||||
|
||||
return RXBUF0;
|
||||
}
|
||||
|
||||
|
||||
void cc110x_spi_select(void)
|
||||
{
|
||||
// Switch to GDO mode
|
||||
P3SEL &= ~0x04;
|
||||
P3DIR &= ~0x04;
|
||||
cs_low:
|
||||
// CS to low
|
||||
abort_count = 0;
|
||||
CC1100_CS_LOW;
|
||||
// Wait for SO to go low (voltage regulator
|
||||
// has stabilized and the crystal is running)
|
||||
loop:
|
||||
|
||||
// asm volatile ("nop");
|
||||
if (CC1100_GDO1) {
|
||||
abort_count++;
|
||||
|
||||
if (abort_count > CC1100_GDO1_LOW_COUNT) {
|
||||
retry_count++;
|
||||
|
||||
if (retry_count > CC1100_GDO1_LOW_RETRY) {
|
||||
puts("[CC1100 SPI] fatal error\n");
|
||||
goto final;
|
||||
}
|
||||
|
||||
CC1100_CS_HIGH;
|
||||
goto cs_low; // try again
|
||||
}
|
||||
|
||||
goto loop;
|
||||
}
|
||||
|
||||
final:
|
||||
/* Switch to SPI mode */
|
||||
P3SEL |= 0x04;
|
||||
}
|
||||
|
||||
void cc110x_spi_unselect(void)
|
||||
{
|
||||
CC1100_CS_HIGH;
|
||||
}
|
||||
|
||||
void cc110x_init_interrupts(void)
|
||||
{
|
||||
unsigned int state = disableIRQ(); /* Disable all interrupts */
|
||||
P2SEL = 0x00; /* must be <> 1 to use interrupts */
|
||||
P2IES |= 0x01; /* Enables external interrupt on low edge (for GDO2) */
|
||||
P2IE |= 0x01; /* Enable interrupt */
|
||||
P2IFG &= ~0x01; /* Clears the interrupt flag */
|
||||
P2IE &= ~0x02; /* Disable interrupt for GDO0 */
|
||||
P2IFG &= ~0x02; /* Clear IFG for GDO0 */
|
||||
restoreIRQ(state); /* Enable all interrupts */
|
||||
}
|
||||
|
||||
void cc110x_spi_init(void)
|
||||
{
|
||||
// Switch off async UART
|
||||
while (!(UTCTL0 & TXEPT)); // Wait for empty UxTXBUF register
|
||||
|
||||
IE1 &= ~(URXIE0 + UTXIE0); // Disable USART0 receive&transmit interrupt
|
||||
ME1 &= ~(UTXE0 + URXE0);
|
||||
P3SEL |= 0x0E; // Set pin as SPI
|
||||
|
||||
// Keep peripheral in reset state
|
||||
UCTL0 = SWRST;
|
||||
|
||||
// 8-bit SPI Master 3-pin mode, with SMCLK as clock source
|
||||
// CKPL works also, but not CKPH+CKPL or none of them!!
|
||||
UCTL0 |= CHAR + SYNC + MM;
|
||||
UTCTL0 = CKPH + SSEL1 + SSEL0 + STC;
|
||||
|
||||
// Ignore clockrate argument for now, just use clock source/2
|
||||
// SMCLK = 7,3728 MHz
|
||||
UBR00 = 0x02; // Ensure baud rate >= 2
|
||||
UBR10 = 0x00;
|
||||
UMCTL0 = 0x00; // No modulation
|
||||
URCTL0 = 0x00; // Reset Receive Control Register
|
||||
|
||||
// Enable SPI mode
|
||||
ME1 |= USPIE0;
|
||||
|
||||
// Release for operation
|
||||
UCTL0 &= ~SWRST;
|
||||
}
|
||||
|
||||
|
||||
// #include <msp430x16x.h>
|
||||
// #include <signal.h>
|
||||
// #include "type.h"
|
||||
// #include "cc110x_defines.h"
|
||||
// #include "driver_cc110x.h"
|
||||
// #include "driver_system.h"
|
||||
// #include "spi0.h"
|
||||
//
|
||||
// static callback_t _paket_cb;
|
||||
// static callback_t _cs_cb;
|
||||
//
|
||||
// //-------------------------------------------------------------------------------------------------------
|
||||
// // Public CC1100 communication functions (SPI)
|
||||
// //-------------------------------------------------------------------------------------------------------
|
||||
//
|
||||
// //-------------------------------------------------------------------------------------------------------
|
||||
// // void spiInitTrx(void)
|
||||
// //
|
||||
// // DESCRIPTION:
|
||||
// // This function puts the cc110x into spi mode. You have to call this bevore every spi transaction.
|
||||
// //
|
||||
// //-------------------------------------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
// void drivercc110x_spiwriteburstreg(uint8_t addr, unsigned char *buffer, uint8_t count)
|
||||
// {
|
||||
// uint8_t i;
|
||||
// long c;
|
||||
// drivercc110x_spiinittrx();
|
||||
// drivercc110x_trxspi(addr | CC1100_WRITE_BURST);
|
||||
// for (i = 0; i < count; i++)
|
||||
// {
|
||||
// c = 0;
|
||||
// IFG1 &= ~UTXIFG0;
|
||||
// IFG1 &= ~URXIFG0;
|
||||
// TXBUF0 = buffer[i];
|
||||
// /* Wait for TX to finish */
|
||||
// while(!(IFG1 & UTXIFG0))
|
||||
// {
|
||||
// if (c++ == 1000000)
|
||||
// alarm();
|
||||
// }
|
||||
// }
|
||||
// /* Wait for Byte received */
|
||||
// c = 0;
|
||||
// while(!(IFG1 & URXIFG0))
|
||||
// {
|
||||
// if (c++ == 1000000)
|
||||
// alarm();
|
||||
// }
|
||||
// CC1100_CS_HIGH;
|
||||
// }
|
||||
//
|
||||
// void drivercc110x_spireadburstreg(uint8_t addr, char *buffer, uint8_t count)
|
||||
// {
|
||||
// uint8_t i;
|
||||
// drivercc110x_spiinittrx();
|
||||
// drivercc110x_trxspi(addr | CC1100_READ_BURST);
|
||||
// for (i = 0; i < count; i++)
|
||||
// {
|
||||
// long c = 0;
|
||||
// IFG1 &= ~UTXIFG0;
|
||||
// IFG1 &= ~URXIFG0;
|
||||
// TXBUF0 = NOBYTE;
|
||||
// while(!(IFG1 & UTXIFG0))
|
||||
// {
|
||||
// if (c++ == 1000000)
|
||||
// alarm();
|
||||
// }
|
||||
// /* Wait for Byte received */
|
||||
// c = 0;
|
||||
// while(!(IFG1 & URXIFG0))
|
||||
// {
|
||||
// if (c++ == 1000000)
|
||||
// alarm();
|
||||
// }
|
||||
// buffer[i] = RXBUF0;
|
||||
// }
|
||||
// CC1100_CS_HIGH;
|
||||
// }
|
||||
//
|
||||
// void drivercc110x_load(callback_t cs_cb,callback_t paket_cb)
|
||||
// {
|
||||
// _paket_cb = paket_cb;
|
||||
// _cs_cb = cs_cb;
|
||||
// spi0_init(0);
|
||||
// }
|
||||
//
|
||||
// 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 drivercc110x_initinterrupts(void)
|
||||
// {
|
||||
// _DINT(); /* Disable all interrupts */
|
||||
// P2SEL = 0x00; /* must be <> 1 to use interrupts */
|
||||
// SET(P2IES, 0x01); /* Enables external interrupt on low edge (for GDO2) */
|
||||
// SET(P2IE, 0x01); /* Enable interrupt */
|
||||
// CLEAR(P2IFG, 0x01); /* Clears the interrupt flag */
|
||||
// CLEAR(P2IE, 0x02); /* Disable interrupt for GDO0 */
|
||||
// CLEAR(P2IFG, 0x02); /* Clear IFG for GDO0 */
|
||||
// _EINT(); /* Enable all interrupts */
|
||||
// }
|
||||
//
|
||||
// void drivercc110x_beforesend(void)
|
||||
// {
|
||||
// /* Turn on Led while sending paket for debug reasons */
|
||||
// SET(P4OUT, 0x08);
|
||||
// /* Disable interrupts on port 2 pin 0 */
|
||||
// CLEAR(P2IE, 0x01);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /*
|
||||
// * Private functions
|
||||
// */
|
||||
//
|
||||
//
|
||||
|
||||
/*
|
||||
* CC1100 receive interrupt
|
||||
*/
|
||||
interrupt(PORT2_VECTOR) __attribute__((naked)) cc110x_isr(void)
|
||||
{
|
||||
__enter_isr();
|
||||
// if (system_state.POWERDOWN) SPI_INIT; /* Initialize SPI after wakeup */
|
||||
/* Check IFG */
|
||||
if ((P2IFG & 0x01) != 0) {
|
||||
P2IFG &= ~0x01;
|
||||
cc110x_gdo2_irq();
|
||||
}
|
||||
else if ((P2IFG & 0x02) != 0) {
|
||||
cc110x_gdo0_irq();
|
||||
P2IE &= ~0x02; // Disable interrupt for GDO0
|
||||
P2IFG &= ~0x02; // Clear IFG for GDO0
|
||||
}
|
||||
else {
|
||||
puts("cc110x_isr(): unexpected IFG!");
|
||||
/* Should not occur - only Port 2 Pin 0 interrupts are enabled */
|
||||
// CLEAR(P2IFG, 0xFF); /* Clear all flags */
|
||||
}
|
||||
|
||||
// if (system_state.POWERDOWN != 0) END_LPM3;
|
||||
__exit_isr();
|
||||
}
|
@ -1,12 +1,3 @@
|
||||
ifneq (,$(filter cc110x_legacy_csma,$(USEMODULE)))
|
||||
USEMODULE += gpioint
|
||||
endif
|
||||
|
||||
ifneq (,$(filter cc110x_legacy,$(USEMODULE)))
|
||||
USEMODULE += cc110x_spi
|
||||
USEMODULE += gpioint
|
||||
endif
|
||||
|
||||
ifneq (,$(filter ltc4150,$(USEMODULE)))
|
||||
USEMODULE += gpioint
|
||||
endif
|
||||
|
@ -1,8 +1,3 @@
|
||||
export INCLUDES += -I$(RIOTBOARD)/msba2/include
|
||||
|
||||
ifneq (,$(filter defaulttransceiver,$(USEMODULE)))
|
||||
USEMODULE += cc110x_legacy
|
||||
USEMODULE += transceiver
|
||||
endif
|
||||
|
||||
include $(RIOTBOARD)/msba2-common/Makefile.include
|
||||
|
@ -1,249 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2008, Freie Universitaet Berlin
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
* directory for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @ingroup LPC2387
|
||||
* @brief CC1100 LPC2387 dependend functions
|
||||
*
|
||||
* @author Heiko Will <hwill@inf.fu-berlin.de>
|
||||
* @author Thomas Hillebrandt <hillebra@inf.fu-berlin.de>
|
||||
* @version $Revision: 1781 $
|
||||
*
|
||||
* @note $Id: msba2-cc110x.c 1781 2010-01-26 13:39:36Z hillebra $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stddef.h>
|
||||
/* core */
|
||||
#include "irq.h"
|
||||
/* cpu */
|
||||
#include "cpu.h"
|
||||
/* drivers */
|
||||
#include "cc110x_legacy.h"
|
||||
|
||||
#include "gpioint.h"
|
||||
|
||||
#define CC1100_GDO0 (FIO0PIN & BIT27) // read serial I/O (GDO0)
|
||||
#define CC1100_GDO1 (FIO1PIN & BIT23) // read serial I/O (GDO1)
|
||||
#define CC1100_GDO2 (FIO0PIN & BIT28) // read serial I/O (GDO2)
|
||||
|
||||
#define SPI_TX_EMPTY (SSP0SR & SSPSR_TFE)
|
||||
#define SPI_BUSY (SSP0SR & SSPSR_BSY)
|
||||
#define SPI_RX_AVAIL (SSP0SR & SSPSR_RNE)
|
||||
|
||||
#define CC1100_GDO1_LOW_RETRY (100) // max. retries for GDO1 to go low
|
||||
#define CC1100_GDO1_LOW_COUNT (2700) // loop count (timeout ~ 500 us) to wait
|
||||
// for GDO1 to go low when CS low
|
||||
|
||||
//#define DEBUG
|
||||
#ifdef DEBUG
|
||||
|
||||
static unsigned long time_value;
|
||||
|
||||
static void set_time(void)
|
||||
{
|
||||
time_value = 0;
|
||||
}
|
||||
|
||||
static int test_time(int code)
|
||||
{
|
||||
time_value++;
|
||||
|
||||
if (time_value > 10000000) {
|
||||
printf("CC1100 SPI alarm: %d!\n", code);
|
||||
time_value = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
int cc110x_get_gdo0(void)
|
||||
{
|
||||
return CC1100_GDO0;
|
||||
}
|
||||
|
||||
int cc110x_get_gdo1(void)
|
||||
{
|
||||
return CC1100_GDO1;
|
||||
}
|
||||
|
||||
int cc110x_get_gdo2(void)
|
||||
{
|
||||
return CC1100_GDO2;
|
||||
}
|
||||
|
||||
void cc110x_spi_init(void)
|
||||
{
|
||||
// configure chip-select
|
||||
FIO1DIR |= BIT21;
|
||||
FIO1SET = BIT21;
|
||||
|
||||
// Power
|
||||
PCONP |= PCSSP0; // Enable power for SSP0 (default is on)
|
||||
|
||||
// PIN Setup
|
||||
PINSEL3 |= BIT8 + BIT9; // Set CLK function to SPI
|
||||
PINSEL3 |= BIT14 + BIT15; // Set MISO function to SPI
|
||||
PINSEL3 |= BIT16 + BIT17; // Set MOSI function to SPI
|
||||
|
||||
// Interface Setup
|
||||
SSP0CR0 = 7;
|
||||
|
||||
// Clock Setup
|
||||
uint32_t pclksel;
|
||||
uint32_t cpsr;
|
||||
lpc2387_pclk_scale(F_CPU / 1000, 6000, &pclksel, &cpsr);
|
||||
PCLKSEL1 &= ~(BIT10 | BIT11); // CCLK to PCLK divider
|
||||
PCLKSEL1 |= pclksel << 10;
|
||||
SSP0CPSR = cpsr;
|
||||
|
||||
// Enable
|
||||
SSP0CR1 |= BIT1; // SSP-Enable
|
||||
int dummy;
|
||||
|
||||
// Clear RxFIFO:
|
||||
while (SPI_RX_AVAIL) { // while RNE (Receive FIFO Not Empty)...
|
||||
dummy = SSP0DR; // read data
|
||||
}
|
||||
|
||||
/* to suppress unused-but-set-variable */
|
||||
(void) dummy;
|
||||
}
|
||||
|
||||
uint8_t cc110x_txrx(uint8_t c)
|
||||
{
|
||||
uint8_t result;
|
||||
SSP0DR = c;
|
||||
#ifdef DEBUG
|
||||
set_time();
|
||||
#endif
|
||||
|
||||
while (!SPI_TX_EMPTY) {
|
||||
#ifdef DEBUG
|
||||
test_time(0);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
set_time();
|
||||
#endif
|
||||
|
||||
while (SPI_BUSY) {
|
||||
#ifdef DEBUG
|
||||
test_time(1);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
set_time();
|
||||
#endif
|
||||
|
||||
while (!SPI_RX_AVAIL) {
|
||||
#ifdef DEBUG
|
||||
test_time(2);
|
||||
#endif
|
||||
}
|
||||
|
||||
result = (uint8_t)SSP0DR;
|
||||
return result;
|
||||
}
|
||||
|
||||
void cc110x_spi_cs(void)
|
||||
{
|
||||
FIO1CLR = BIT21;
|
||||
}
|
||||
|
||||
void
|
||||
cc110x_spi_select(void)
|
||||
{
|
||||
volatile int retry_count = 0;
|
||||
volatile int abort_count;
|
||||
// Switch to GDO mode input
|
||||
PINSEL3 &= ~(BIT14 + BIT15);// Set MISO function to GPIO
|
||||
FIO1DIR &= ~BIT23;
|
||||
cs_low:
|
||||
// CS to low
|
||||
abort_count = 0;
|
||||
FIO1CLR = BIT21;
|
||||
// Wait for SO to go low (voltage regulator
|
||||
// has stabilized and the crystal is running)
|
||||
loop:
|
||||
asm volatile("nop");
|
||||
|
||||
if (CC1100_GDO1) {
|
||||
abort_count++;
|
||||
|
||||
if (abort_count > CC1100_GDO1_LOW_COUNT) {
|
||||
retry_count++;
|
||||
|
||||
if (retry_count > CC1100_GDO1_LOW_RETRY) {
|
||||
puts("[CC1100 SPI] fatal error\n");
|
||||
goto final;
|
||||
}
|
||||
|
||||
FIO1SET = BIT21; // CS to high
|
||||
goto cs_low; // try again
|
||||
}
|
||||
|
||||
goto loop;
|
||||
}
|
||||
|
||||
final:
|
||||
// Switch to SPI mode
|
||||
PINSEL3 |= (BIT14 + BIT15); // Set MISO function to SPI
|
||||
}
|
||||
|
||||
void
|
||||
cc110x_spi_unselect(void)
|
||||
{
|
||||
FIO1SET = BIT21;
|
||||
}
|
||||
|
||||
void cc110x_before_send(void)
|
||||
{
|
||||
// Disable GDO2 interrupt before sending packet
|
||||
cc110x_gdo2_disable();
|
||||
}
|
||||
|
||||
void cc110x_after_send(void)
|
||||
{
|
||||
// Enable GDO2 interrupt after sending packet
|
||||
cc110x_gdo2_enable();
|
||||
}
|
||||
|
||||
void cc110x_gdo0_enable(void)
|
||||
{
|
||||
gpioint_set(0, BIT27, GPIOINT_RISING_EDGE, &cc110x_gdo0_irq);
|
||||
}
|
||||
|
||||
void cc110x_gdo0_disable(void)
|
||||
{
|
||||
gpioint_set(0, BIT27, GPIOINT_DISABLE, NULL);
|
||||
}
|
||||
|
||||
void cc110x_gdo2_disable(void)
|
||||
{
|
||||
gpioint_set(0, BIT28, GPIOINT_DISABLE, NULL);
|
||||
}
|
||||
|
||||
void cc110x_gdo2_enable(void)
|
||||
{
|
||||
gpioint_set(0, BIT28, GPIOINT_FALLING_EDGE, &cc110x_gdo2_irq);
|
||||
}
|
||||
|
||||
void cc110x_init_interrupts(void)
|
||||
{
|
||||
// Enable external interrupt on low edge (for GDO2)
|
||||
FIO0DIR &= ~BIT28;
|
||||
cc110x_gdo2_enable();
|
||||
// Enable external interrupt on low edge (for GDO0)
|
||||
FIO0DIR &= ~BIT27;
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
# tell the Makefile.base which module to build
|
||||
MODULE = $(BOARD)_base
|
||||
INCLUDES += -I$(RIOTBASE)/drivers/cc110x
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
||||
|
@ -1,10 +1,3 @@
|
||||