A Atmel RF2xx Radio Library for Mbed
Dependents: xBedRadio MxSniffer
MxRadio_trx_rf230.cpp
00001 /* Copyright (c) 2007 Axel Wachtler 00002 All rights reserved. 00003 00004 Redistribution and use in source and binary forms, with or without 00005 modification, are permitted provided that the following conditions 00006 are met: 00007 00008 * Redistributions of source code must retain the above copyright 00009 notice, this list of conditions and the following disclaimer. 00010 * Redistributions in binary form must reproduce the above copyright 00011 notice, this list of conditions and the following disclaimer in the 00012 documentation and/or other materials provided with the distribution. 00013 * Neither the name of the authors nor the names of its contributors 00014 may be used to endorse or promote products derived from this software 00015 without specific prior written permission. 00016 00017 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00018 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00019 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00020 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00021 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00022 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00023 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00024 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00025 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00026 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00027 POSSIBILITY OF SUCH DAMAGE. */ 00028 00029 /* 00030 * =========================================================================== 00031 * This file contains refactored code from hif_rf230.c, 00032 * which is part of Atmels software package "IEEE 802.15.4 MAC for AVR Z-Link" 00033 * =========================================================================== 00034 */ 00035 /* 00036 * Copyright (c) 2006, Atmel Corporation All rights reserved. 00037 * 00038 * Redistribution and use in source and binary forms, with or without 00039 * modification, are permitted provided that the following conditions are met: 00040 * 00041 * 1. Redistributions of source code must retain the above copyright notice, 00042 * this list of conditions and the following disclaimer. 00043 * 00044 * 2. Redistributions in binary form must reproduce the above copyright notice, 00045 * this list of conditions and the following disclaimer in the documentation 00046 * and/or other materials provided with the distribution. 00047 * 00048 * 3. The name of ATMEL may not be used to endorse or promote products derived 00049 * from this software without specific prior written permission. 00050 * 00051 * THIS SOFTWARE IS PROVIDED BY ATMEL ``AS IS'' AND ANY EXPRESS OR IMPLIED 00052 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00053 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY AND 00054 * SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, 00055 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00056 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00057 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00058 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00059 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 00060 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00061 */ 00062 00063 /* $Id$ */ 00064 /** 00065 * @file 00066 * @brief Implementation of the host interface for the AT86RF230 00067 * 00068 * Hardware interface implementation for radio-dependant functions of 00069 * the AT86RF230 radio chip. 00070 * 00071 */ 00072 00073 /* === Includes ============================================================ */ 00074 #include <MxRadio.h> 00075 00076 00077 /* === external functions =================================================== */ 00078 void cMxRadio::trx_io_init (int spirate) 00079 { 00080 m_cs = 1; 00081 m_spi.format(8, 0); 00082 m_spi.frequency(spirate); 00083 irq_pin.rise(this,&cMxRadio::rf_irq_callback); 00084 00085 /* set the SLPTR and RESET 00086 TRX_RESET_INIT(); 00087 TRX_SLPTR_INIT(); 00088 SPI_INIT(spirate); 00089 TRX_IRQ_INIT(); 00090 EI_TRX_IRQ(); 00091 */ 00092 } 00093 00094 void cMxRadio::trx_reg_write(uint8_t addr, trx_regval_t val) 00095 { 00096 00097 addr = TRX_CMD_RW | (TRX_CMD_RADDR_MASK & addr); 00098 00099 m_cs = 0;//SPI_SELN_LOW(); 00100 m_spi.write(addr);//SPI_DATA_REG = addr; 00101 //SPI_WAITFOR(); 00102 m_spi.write(val);//SPI_DATA_REG = val; 00103 //SPI_WAITFOR(); 00104 m_cs = 1;//SPI_SELN_HIGH(); 00105 } 00106 00107 trx_regval_t cMxRadio::trx_reg_read(uint8_t addr) 00108 { 00109 00110 uint8_t val; 00111 00112 addr=TRX_CMD_RR | (TRX_CMD_RADDR_MASK & addr); 00113 00114 // Select transceiver 00115 m_cs = 0;//SPI_SELN_LOW(); 00116 00117 m_spi.write(addr);//SPI_DATA_REG = addr; 00118 //SPI_WAITFOR(); 00119 val=m_spi.write(addr);//SPI_DATA_REG = addr; /* dummy out */ 00120 //SPI_WAITFOR(); 00121 //val = SPI_DATA_REG; 00122 00123 m_cs=1;//SPI_SELN_HIGH(); 00124 00125 return (trx_regval_t)val; 00126 } 00127 00128 00129 /* EOF */
Generated on Thu Jul 14 2022 01:09:40 by
1.7.2