A Atmel RF2xx Radio Library for Mbed

Dependents:   xBedRadio MxSniffer

Committer:
fredqian
Date:
Thu Apr 09 16:42:51 2015 +0800
Revision:
0:5f1d66c85ae0
init commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
fredqian 0:5f1d66c85ae0 1 /* Copyright (c) 2007 Axel Wachtler
fredqian 0:5f1d66c85ae0 2 All rights reserved.
fredqian 0:5f1d66c85ae0 3
fredqian 0:5f1d66c85ae0 4 Redistribution and use in source and binary forms, with or without
fredqian 0:5f1d66c85ae0 5 modification, are permitted provided that the following conditions
fredqian 0:5f1d66c85ae0 6 are met:
fredqian 0:5f1d66c85ae0 7
fredqian 0:5f1d66c85ae0 8 * Redistributions of source code must retain the above copyright
fredqian 0:5f1d66c85ae0 9 notice, this list of conditions and the following disclaimer.
fredqian 0:5f1d66c85ae0 10 * Redistributions in binary form must reproduce the above copyright
fredqian 0:5f1d66c85ae0 11 notice, this list of conditions and the following disclaimer in the
fredqian 0:5f1d66c85ae0 12 documentation and/or other materials provided with the distribution.
fredqian 0:5f1d66c85ae0 13 * Neither the name of the authors nor the names of its contributors
fredqian 0:5f1d66c85ae0 14 may be used to endorse or promote products derived from this software
fredqian 0:5f1d66c85ae0 15 without specific prior written permission.
fredqian 0:5f1d66c85ae0 16
fredqian 0:5f1d66c85ae0 17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
fredqian 0:5f1d66c85ae0 18 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
fredqian 0:5f1d66c85ae0 19 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
fredqian 0:5f1d66c85ae0 20 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
fredqian 0:5f1d66c85ae0 21 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
fredqian 0:5f1d66c85ae0 22 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
fredqian 0:5f1d66c85ae0 23 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
fredqian 0:5f1d66c85ae0 24 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
fredqian 0:5f1d66c85ae0 25 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
fredqian 0:5f1d66c85ae0 26 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
fredqian 0:5f1d66c85ae0 27 POSSIBILITY OF SUCH DAMAGE. */
fredqian 0:5f1d66c85ae0 28
fredqian 0:5f1d66c85ae0 29 /*
fredqian 0:5f1d66c85ae0 30 * ===========================================================================
fredqian 0:5f1d66c85ae0 31 * This file is a copy of the file hif_rf230.c, which is part of
fredqian 0:5f1d66c85ae0 32 * Atmels software package "IEEE 802.15.4 MAC for AVR Z-Link"
fredqian 0:5f1d66c85ae0 33 * ===========================================================================
fredqian 0:5f1d66c85ae0 34 */
fredqian 0:5f1d66c85ae0 35 /*
fredqian 0:5f1d66c85ae0 36 * Copyright (c) 2006, Atmel Corporation All rights reserved.
fredqian 0:5f1d66c85ae0 37 *
fredqian 0:5f1d66c85ae0 38 * Redistribution and use in source and binary forms, with or without
fredqian 0:5f1d66c85ae0 39 * modification, are permitted provided that the following conditions are met:
fredqian 0:5f1d66c85ae0 40 *
fredqian 0:5f1d66c85ae0 41 * 1. Redistributions of source code must retain the above copyright notice,
fredqian 0:5f1d66c85ae0 42 * this list of conditions and the following disclaimer.
fredqian 0:5f1d66c85ae0 43 *
fredqian 0:5f1d66c85ae0 44 * 2. Redistributions in binary form must reproduce the above copyright notice,
fredqian 0:5f1d66c85ae0 45 * this list of conditions and the following disclaimer in the documentation
fredqian 0:5f1d66c85ae0 46 * and/or other materials provided with the distribution.
fredqian 0:5f1d66c85ae0 47 *
fredqian 0:5f1d66c85ae0 48 * 3. The name of ATMEL may not be used to endorse or promote products derived
fredqian 0:5f1d66c85ae0 49 * from this software without specific prior written permission.
fredqian 0:5f1d66c85ae0 50 *
fredqian 0:5f1d66c85ae0 51 * THIS SOFTWARE IS PROVIDED BY ATMEL ``AS IS'' AND ANY EXPRESS OR IMPLIED
fredqian 0:5f1d66c85ae0 52 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
fredqian 0:5f1d66c85ae0 53 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY AND
fredqian 0:5f1d66c85ae0 54 * SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT,
fredqian 0:5f1d66c85ae0 55 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
fredqian 0:5f1d66c85ae0 56 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
fredqian 0:5f1d66c85ae0 57 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
fredqian 0:5f1d66c85ae0 58 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
fredqian 0:5f1d66c85ae0 59 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
fredqian 0:5f1d66c85ae0 60 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
fredqian 0:5f1d66c85ae0 61 */
fredqian 0:5f1d66c85ae0 62
fredqian 0:5f1d66c85ae0 63
fredqian 0:5f1d66c85ae0 64 /* $Id$ */
fredqian 0:5f1d66c85ae0 65 /**
fredqian 0:5f1d66c85ae0 66 * @file
fredqian 0:5f1d66c85ae0 67 * @brief SRAM access functionds for AT86RF230.
fredqian 0:5f1d66c85ae0 68 *
fredqian 0:5f1d66c85ae0 69 * This functions are moved to this module, in order to
fredqian 0:5f1d66c85ae0 70 * make librf230 more scaleable.
fredqian 0:5f1d66c85ae0 71 *
fredqian 0:5f1d66c85ae0 72 *
fredqian 0:5f1d66c85ae0 73 */
fredqian 0:5f1d66c85ae0 74
fredqian 0:5f1d66c85ae0 75
fredqian 0:5f1d66c85ae0 76 /* === Includes ============================================================ */
fredqian 0:5f1d66c85ae0 77 #include <MxRadio.h>
fredqian 0:5f1d66c85ae0 78
fredqian 0:5f1d66c85ae0 79 void cMxRadio::trx_sram_write(trx_ramaddr_t addr, uint8_t length, uint8_t *data)
fredqian 0:5f1d66c85ae0 80 {
fredqian 0:5f1d66c85ae0 81
fredqian 0:5f1d66c85ae0 82 // Select transceiver
fredqian 0:5f1d66c85ae0 83 m_cs=0;//SPI_SELN_LOW();
fredqian 0:5f1d66c85ae0 84
fredqian 0:5f1d66c85ae0 85 m_spi.write(TRX_CMD_SW);//SPI_DATA_REG = TRX_CMD_SW;
fredqian 0:5f1d66c85ae0 86 //SPI_WAITFOR();
fredqian 0:5f1d66c85ae0 87 m_spi.write(addr);//SPI_DATA_REG = addr;
fredqian 0:5f1d66c85ae0 88 //SPI_WAITFOR();
fredqian 0:5f1d66c85ae0 89 do
fredqian 0:5f1d66c85ae0 90 {
fredqian 0:5f1d66c85ae0 91 m_spi.write(*data++);//SPI_DATA_REG = *data++;
fredqian 0:5f1d66c85ae0 92 //SPI_WAITFOR();
fredqian 0:5f1d66c85ae0 93 }
fredqian 0:5f1d66c85ae0 94 while (--length > 0);
fredqian 0:5f1d66c85ae0 95
fredqian 0:5f1d66c85ae0 96 // Deselect Slave
fredqian 0:5f1d66c85ae0 97 m_cs=1;//SPI_SELN_HIGH();
fredqian 0:5f1d66c85ae0 98 }
fredqian 0:5f1d66c85ae0 99
fredqian 0:5f1d66c85ae0 100
fredqian 0:5f1d66c85ae0 101 void cMxRadio::trx_sram_read(trx_ramaddr_t addr, uint8_t length, uint8_t *data)
fredqian 0:5f1d66c85ae0 102 {
fredqian 0:5f1d66c85ae0 103
fredqian 0:5f1d66c85ae0 104 // Select transceiver
fredqian 0:5f1d66c85ae0 105 m_cs=0;//SPI_SELN_LOW();
fredqian 0:5f1d66c85ae0 106
fredqian 0:5f1d66c85ae0 107 m_spi.write(TRX_CMD_SR);//SPI_DATA_REG = TRX_CMD_SR;
fredqian 0:5f1d66c85ae0 108 //SPI_WAITFOR();
fredqian 0:5f1d66c85ae0 109 m_spi.write(addr);//SPI_DATA_REG = addr;
fredqian 0:5f1d66c85ae0 110 //SPI_WAITFOR();
fredqian 0:5f1d66c85ae0 111 do
fredqian 0:5f1d66c85ae0 112 {
fredqian 0:5f1d66c85ae0 113 //SPI_DATA_REG = 0; /* dummy out */
fredqian 0:5f1d66c85ae0 114 //SPI_WAITFOR();
fredqian 0:5f1d66c85ae0 115 *data++ = m_spi.write(0);//SPI_DATA_REG;
fredqian 0:5f1d66c85ae0 116 }
fredqian 0:5f1d66c85ae0 117 while (--length > 0);
fredqian 0:5f1d66c85ae0 118
fredqian 0:5f1d66c85ae0 119 // Deselect Slave
fredqian 0:5f1d66c85ae0 120 m_cs=1;//SPI_SELN_HIGH();
fredqian 0:5f1d66c85ae0 121 }
fredqian 0:5f1d66c85ae0 122
fredqian 0:5f1d66c85ae0 123 /* EOF */