00001 /** 00002 * \addtogroup dev 00003 * @{ 00004 */ 00005 00006 /** 00007 * \defgroup radio Radio API 00008 * 00009 * The radio API module defines a set of functions that a radio device 00010 * driver must implement. 00011 * 00012 * @{ 00013 */ 00014 00015 /* 00016 * Copyright (c) 2005, Swedish Institute of Computer Science. 00017 * All rights reserved. 00018 * 00019 * Redistribution and use in source and binary forms, with or without 00020 * modification, are permitted provided that the following conditions 00021 * are met: 00022 * 1. Redistributions of source code must retain the above copyright 00023 * notice, this list of conditions and the following disclaimer. 00024 * 2. Redistributions in binary form must reproduce the above copyright 00025 * notice, this list of conditions and the following disclaimer in the 00026 * documentation and/or other materials provided with the distribution. 00027 * 3. Neither the name of the Institute nor the names of its contributors 00028 * may be used to endorse or promote products derived from this software 00029 * without specific prior written permission. 00030 * 00031 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 00032 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00033 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00034 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 00035 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00036 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 00037 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00038 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00039 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 00040 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00041 * SUCH DAMAGE. 00042 * 00043 * This file is part of the Contiki operating system. 00044 * 00045 * $Id: radio.h,v 1.8 2010/03/30 23:00:22 adamdunkels Exp $ 00046 */ 00047 00048 /** 00049 * \file 00050 * Header file for the radio API 00051 * \author 00052 * Adam Dunkels <adam@sics.se> 00053 */ 00054 00055 #ifndef __RADIO_H__ 00056 #define __RADIO_H__ 00057 00058 /** 00059 * The structure of a device driver for a radio in Contiki. 00060 */ 00061 struct radio_driver { 00062 00063 int (* init)(void); 00064 00065 /** Prepare the radio with a packet to be sent. */ 00066 int (* prepare)(const void *payload, unsigned short payload_len); 00067 00068 /** Send the packet that has previously been prepared. */ 00069 int (* transmit)(unsigned short transmit_len); 00070 00071 /** Prepare & transmit a packet. */ 00072 int (* send)(const void *payload, unsigned short payload_len); 00073 00074 /** Read a received packet into a buffer. */ 00075 int (* read)(void *buf, unsigned short buf_len); 00076 00077 /** Perform a Clear-Channel Assessment (CCA) to find out if there is 00078 a packet in the air or not. */ 00079 int (* channel_clear)(void); 00080 00081 /** Check if the radio driver is currently receiving a packet */ 00082 int (* receiving_packet)(void); 00083 00084 /** Check if the radio driver has just received a packet */ 00085 int (* pending_packet)(void); 00086 00087 /** Turn the radio on. */ 00088 int (* on)(void); 00089 00090 /** Turn the radio off. */ 00091 int (* off)(void); 00092 }; 00093 00094 /* Generic radio return values. */ 00095 enum { 00096 RADIO_TX_OK, 00097 RADIO_TX_ERR, 00098 RADIO_TX_COLLISION, 00099 RADIO_TX_NOACK, 00100 }; 00101 00102 #endif /* __RADIO_H__ */ 00103 00104 00105 /** @} */ 00106 /** @} */