2014-08-27 18:47:31 +02:00
|
|
|
/*
|
2013-08-16 10:20:23 +02:00
|
|
|
* Copyright 2008, Freie Universitaet Berlin (FUB). All rights reserved.
|
|
|
|
*
|
2014-07-31 19:45:27 +02:00
|
|
|
* 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.
|
2014-08-27 18:47:31 +02:00
|
|
|
*/
|
2010-09-22 15:10:42 +02:00
|
|
|
|
|
|
|
/**
|
2014-10-26 22:02:18 +01:00
|
|
|
* @ingroup dev_cc110x_legacy_csma
|
2010-09-22 15:10:42 +02:00
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* @internal
|
2014-07-31 20:49:35 +02:00
|
|
|
* @brief TI Chipcon CC1100 SPI driver
|
2010-09-22 15:10:42 +02:00
|
|
|
*
|
2014-07-31 20:49:35 +02:00
|
|
|
* @author Thomas Hillebrandt <hillebra@inf.fu-berlin.de>
|
|
|
|
* @author Heiko Will <hwill@inf.fu-berlin.de>
|
2010-09-22 15:10:42 +02:00
|
|
|
* @version $Revision: 1775 $
|
|
|
|
*
|
2014-07-31 20:49:35 +02:00
|
|
|
* @note $Id: cc1100_spi.c 1775 2010-01-26 09:37:03Z hillebra $
|
2010-09-22 15:10:42 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "irq.h"
|
|
|
|
#include "arch_cc1100.h"
|
|
|
|
#include "cc1100.h"
|
|
|
|
#include "cc1100_spi.h"
|
|
|
|
#include "cc1100-internal.h"
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
2014-07-31 20:49:35 +02:00
|
|
|
// CC1100 SPI access
|
2010-09-22 15:10:42 +02:00
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
/** @} */
|