2010-09-22 15:10:42 +02:00
|
|
|
/******************************************************************************
|
2013-08-16 10:20:23 +02:00
|
|
|
* Copyright 2008, Freie Universitaet Berlin (FUB). All rights reserved.
|
|
|
|
*
|
|
|
|
* These sources were developed at the Freie Universitaet Berlin, Computer Systems
|
2010-09-22 15:10:42 +02:00
|
|
|
and Telematics group (http://cst.mi.fu-berlin.de).
|
2013-08-16 10:20:23 +02:00
|
|
|
* ----------------------------------------------------------------------------
|
|
|
|
* This file is part of RIOT.
|
|
|
|
*
|
2013-11-22 20:47:05 +01:00
|
|
|
* This file is subject to the terms and conditions of the GNU Lesser General
|
2013-08-16 10:20:23 +02:00
|
|
|
* Public License. See the file LICENSE in the top level directory for more
|
|
|
|
* details.
|
|
|
|
*
|
2010-09-22 15:10:42 +02:00
|
|
|
*******************************************************************************/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ingroup dev_cc110x
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* @internal
|
|
|
|
* @brief TI Chipcon CC1100 SPI driver
|
|
|
|
*
|
2013-03-08 11:30:23 +01:00
|
|
|
* @author Freie Universität Berlin, Computer Systems & Telematics
|
2010-09-22 15:10:42 +02:00
|
|
|
* @author Thomas Hillebrandt <hillebra@inf.fu-berlin.de>
|
|
|
|
* @author Heiko Will <hwill@inf.fu-berlin.de>
|
|
|
|
* @version $Revision: 1775 $
|
|
|
|
*
|
|
|
|
* @note $Id: cc1100_spi.c 1775 2010-01-26 09:37:03Z hillebra $
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "irq.h"
|
|
|
|
#include "arch_cc1100.h"
|
|
|
|
#include "cc1100.h"
|
|
|
|
#include "cc1100_spi.h"
|
|
|
|
#include "cc1100-internal.h"
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
// CC1100 SPI access
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
uint8_t
|
|
|
|
cc1100_spi_writeburst_reg(uint8_t addr, char *src, uint8_t count)
|
|
|
|
{
|
2013-06-21 22:36:48 +02:00
|
|
|
int i = 0;
|
|
|
|
unsigned int cpsr = disableIRQ();
|
|
|
|
cc110x_spi_select();
|
|
|
|
cc110x_txrx(addr | CC1100_WRITE_BURST);
|
|
|
|
|
2013-06-24 22:37:35 +02:00
|
|
|
while (i < count) {
|
2013-06-21 22:36:48 +02:00
|
|
|
cc110x_txrx(src[i]);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
cc110x_spi_unselect();
|
|
|
|
restoreIRQ(cpsr);
|
|
|
|
return count;
|
2010-09-22 15:10:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
cc1100_spi_readburst_reg(uint8_t addr, char *buffer, uint8_t count)
|
|
|
|
{
|
2013-06-21 22:36:48 +02:00
|
|
|
int i = 0;
|
|
|
|
unsigned int cpsr = disableIRQ();
|
|
|
|
cc110x_spi_select();
|
|
|
|
cc110x_txrx(addr | CC1100_READ_BURST);
|
|
|
|
|
2013-06-24 22:37:35 +02:00
|
|
|
while (i < count) {
|
2013-12-15 14:04:35 +01:00
|
|
|
buffer[i] = cc110x_txrx(CC1100_NOBYTE);
|
2013-06-21 22:36:48 +02:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
cc110x_spi_unselect();
|
|
|
|
restoreIRQ(cpsr);
|
2010-09-22 15:10:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
cc1100_spi_write_reg(uint8_t addr, uint8_t value)
|
|
|
|
{
|
2013-06-21 22:36:48 +02:00
|
|
|
unsigned int cpsr = disableIRQ();
|
|
|
|
cc110x_spi_select();
|
|
|
|
cc110x_txrx(addr);
|
|
|
|
cc110x_txrx(value);
|
|
|
|
cc110x_spi_unselect();
|
|
|
|
restoreIRQ(cpsr);
|
2010-09-22 15:10:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t cc1100_spi_read_reg(uint8_t addr)
|
|
|
|
{
|
2013-06-21 22:36:48 +02:00
|
|
|
uint8_t result;
|
|
|
|
unsigned int cpsr = disableIRQ();
|
|
|
|
cc110x_spi_select();
|
|
|
|
cc110x_txrx(addr | CC1100_READ_SINGLE);
|
2013-12-15 14:04:35 +01:00
|
|
|
result = cc110x_txrx(CC1100_NOBYTE);
|
2013-06-21 22:36:48 +02:00
|
|
|
cc110x_spi_unselect();
|
|
|
|
restoreIRQ(cpsr);
|
|
|
|
return result;
|
2010-09-22 15:10:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t cc1100_spi_read_status(uint8_t addr)
|
|
|
|
{
|
2013-06-21 22:36:48 +02:00
|
|
|
uint8_t result;
|
|
|
|
unsigned int cpsr = disableIRQ();
|
|
|
|
cc110x_spi_select();
|
|
|
|
cc110x_txrx(addr | CC1100_READ_BURST);
|
2013-12-15 14:04:35 +01:00
|
|
|
result = cc110x_txrx(CC1100_NOBYTE);
|
2013-06-21 22:36:48 +02:00
|
|
|
cc110x_spi_unselect();
|
|
|
|
restoreIRQ(cpsr);
|
|
|
|
return result;
|
2010-09-22 15:10:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t cc1100_spi_strobe(uint8_t c)
|
|
|
|
{
|
2013-06-21 22:36:48 +02:00
|
|
|
uint8_t result;
|
|
|
|
unsigned int cpsr = disableIRQ();
|
|
|
|
cc110x_spi_select();
|
|
|
|
result = cc110x_txrx(c);
|
|
|
|
cc110x_spi_unselect();
|
|
|
|
restoreIRQ(cpsr);
|
|
|
|
return result;
|
2010-09-22 15:10:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/** @} */
|