Contiki 2.5
radio.h
Go to the documentation of this file.
1 /**
2  * \addtogroup dev
3  * @{
4  */
5 
6 /**
7  * \defgroup radio Radio API
8  *
9  * The radio API module defines a set of functions that a radio device
10  * driver must implement.
11  *
12  * @{
13  */
14 
15 /*
16  * Copyright (c) 2005, Swedish Institute of Computer Science.
17  * All rights reserved.
18  *
19  * Redistribution and use in source and binary forms, with or without
20  * modification, are permitted provided that the following conditions
21  * are met:
22  * 1. Redistributions of source code must retain the above copyright
23  * notice, this list of conditions and the following disclaimer.
24  * 2. Redistributions in binary form must reproduce the above copyright
25  * notice, this list of conditions and the following disclaimer in the
26  * documentation and/or other materials provided with the distribution.
27  * 3. Neither the name of the Institute nor the names of its contributors
28  * may be used to endorse or promote products derived from this software
29  * without specific prior written permission.
30  *
31  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
32  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
33  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
34  * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
35  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
39  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
40  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
41  * SUCH DAMAGE.
42  *
43  * This file is part of the Contiki operating system.
44  *
45  * $Id: radio.h,v 1.8 2010/03/30 23:00:22 adamdunkels Exp $
46  */
47 
48 /**
49  * \file
50  * Header file for the radio API
51  * \author
52  * Adam Dunkels <adam@sics.se>
53  */
54 
55 #ifndef __RADIO_H__
56 #define __RADIO_H__
57 
58 /**
59  * The structure of a device driver for a radio in Contiki.
60  */
61 struct radio_driver {
62 
63  int (* init)(void);
64 
65  /** Prepare the radio with a packet to be sent. */
66  int (* prepare)(const void *payload, unsigned short payload_len);
67 
68  /** Send the packet that has previously been prepared. */
69  int (* transmit)(unsigned short transmit_len);
70 
71  /** Prepare & transmit a packet. */
72  int (* send)(const void *payload, unsigned short payload_len);
73 
74  /** Read a received packet into a buffer. */
75  int (* read)(void *buf, unsigned short buf_len);
76 
77  /** Perform a Clear-Channel Assessment (CCA) to find out if there is
78  a packet in the air or not. */
79  int (* channel_clear)(void);
80 
81  /** Check if the radio driver is currently receiving a packet */
82  int (* receiving_packet)(void);
83 
84  /** Check if the radio driver has just received a packet */
85  int (* pending_packet)(void);
86 
87  /** Turn the radio on. */
88  int (* on)(void);
89 
90  /** Turn the radio off. */
91  int (* off)(void);
92 };
93 
94 /* Generic radio return values. */
95 enum {
96  RADIO_TX_OK,
97  RADIO_TX_ERR,
98  RADIO_TX_COLLISION,
99  RADIO_TX_NOACK,
100 };
101 
102 #endif /* __RADIO_H__ */
103 
104 
105 /** @} */
106 /** @} */