Contiki 2.5
Main Page
Related Pages
Modules
Data Structures
Files
Examples
File List
Globals
cpu
avr
radio
ieee-manager
ieee-15-4-manager.c
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2008, Swedish Institute of Computer Science.
3
* All rights reserved.
4
*
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions
7
* are met:
8
* 1. Redistributions of source code must retain the above copyright
9
* notice, this list of conditions and the following disclaimer.
10
* 2. Redistributions in binary form must reproduce the above copyright
11
* notice, this list of conditions and the following disclaimer in the
12
* documentation and/or other materials provided with the distribution.
13
* 3. Neither the name of the Institute nor the names of its contributors
14
* may be used to endorse or promote products derived from this software
15
* without specific prior written permission.
16
*
17
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
18
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
21
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27
* SUCH DAMAGE.
28
*
29
* This file is part of the Contiki operating system.
30
*
31
* $Id: ieee-15-4-manager.c,v 1.2 2008/10/14 18:38:09 c_oflynn Exp $
32
*/
33
34
/**
35
*
36
* \addtogroup rf230mac
37
* \{
38
*/
39
40
/**
41
* \file
42
* \brief Interfaces the 802.15.4 MAC to upper network layers.
43
*
44
* \author
45
* Mike Vidales <mavida404@gmail.com>
46
*/
47
48
#include "
zmac.h
"
49
#include "radio.h"
50
#include "
ieee-15-4-manager.h
"
51
52
/*---------------------------------------------------------------------------*/
53
static
int
54
wake(
void
)
55
{
56
/* Wake the radio. */
57
return
radio_leave_sleep_mode
();
58
}
59
/*---------------------------------------------------------------------------*/
60
static
int
61
sleep(
void
)
62
{
63
/* Sleep the radio. */
64
return
radio_enter_sleep_mode
();
65
}
66
/*---------------------------------------------------------------------------*/
67
static
void
68
set_channel(
int
channel)
69
{
70
/* Set the channel. */
71
phyCurrentChannel
= channel;
72
radio_set_operating_channel
(
phyCurrentChannel
);
73
}
74
/*---------------------------------------------------------------------------*/
75
static
int
76
get_channel(
void
)
77
{
78
/* Reads the current channel. */
79
phyCurrentChannel
=
radio_get_operating_channel
();
80
return
phyCurrentChannel
;
81
}
82
/*---------------------------------------------------------------------------*/
83
static
void
84
set_dst_panid(
int
panid)
85
{
86
macDstPANId
= panid;
87
}
88
/*---------------------------------------------------------------------------*/
89
static
int
90
get_dst_panid(
void
)
91
{
92
return
macDstPANId
;
93
}
94
/*---------------------------------------------------------------------------*/
95
static
void
96
set_src_panid(
int
panid)
97
{
98
/* Writes the PAN_ID to the radio. */
99
macSrcPANId
= panid;
100
radio_set_pan_id
(
macSrcPANId
);
101
}
102
/*---------------------------------------------------------------------------*/
103
static
int
104
get_src_panid(
void
)
105
{
106
/* Gets the PAN_ID from the radio. */
107
macSrcPANId
=
radio_get_pan_id
();
108
return
macSrcPANId
;
109
}
110
/*---------------------------------------------------------------------------*/
111
static
void
112
set_auto_mode(
bool
mode)
113
{
114
autoModes = mode;
115
}
116
/*---------------------------------------------------------------------------*/
117
static
bool
118
get_auto_mode(
void
)
119
{
120
return
autoModes;
121
}
122
/*---------------------------------------------------------------------------*/
123
static
void
124
set_long_addr(uint64_t address)
125
{
126
/* Set the Long address in the radio. */
127
macLongAddr
= address;
128
radio_set_extended_address
((uint8_t *)&
macLongAddr
);
129
}
130
/*---------------------------------------------------------------------------*/
131
static
uint64_t
132
get_long_addr(
void
)
133
{
134
/* Get the Long address from the radio. */
135
radio_get_extended_address
((uint8_t *)&
macLongAddr
);
136
return
macLongAddr
;
137
}
138
/*---------------------------------------------------------------------------*/
139
static
void
140
set_short_addr(
int
address)
141
{
142
/* Set the Short address in the radio. */
143
macShortAddress
= address;
144
radio_set_short_address
(
macShortAddress
);
145
}
146
/*---------------------------------------------------------------------------*/
147
static
int
148
get_short_addr(
void
)
149
{
150
/* Get the Short address from the radio. */
151
macShortAddress
=
radio_get_short_address
();
152
return
macShortAddress
;
153
}
154
/*---------------------------------------------------------------------------*/
155
static
void
156
set_iamcoord_bit(
bool
iamcoord)
157
{
158
/** Set the iAmCoord bit. */
159
iAmCoord = iamcoord;
160
radio_set_device_role
(iAmCoord);
161
}
162
/*---------------------------------------------------------------------------*/
163
static
bool
164
get_iamcoord_bit(
void
)
165
{
166
/** Get the iAmCoord bit. */
167
iAmCoord =
radio_get_device_role
();
168
return
iAmCoord;
169
}
170
/*---------------------------------------------------------------------------*/
171
static
void
172
set_coord_long_addr(uint64_t address)
173
{
174
macCoordExtendedAddress
= address;
175
}
176
/*---------------------------------------------------------------------------*/
177
static
uint64_t
178
get_coord_long_addr(
void
)
179
{
180
return
macCoordExtendedAddress
;
181
}
182
/*---------------------------------------------------------------------------*/
183
static
void
184
set_coord_short_addr(
int
address)
185
{
186
macCoordShortAddress
= address;
187
}
188
/*---------------------------------------------------------------------------*/
189
static
int
190
get_coord_short_addr(
void
)
191
{
192
return
macCoordShortAddress
;
193
}
194
/*---------------------------------------------------------------------------*/
195
static
void
196
set_dest_long_addr(uint64_t address)
197
{
198
macDestAddress
= address;
199
}
200
/*---------------------------------------------------------------------------*/
201
static
uint64_t
202
get_dest_long_addr(
void
)
203
{
204
return
macDestAddress
;
205
}
206
/*---------------------------------------------------------------------------*/
207
/** \brief initializes the 802.15.4 manager layer.
208
* \param pieee_15_4_manager Pointer to \ref ieee_15_4_manager
209
*/
210
void
ieee_15_4_init
(
ieee_15_4_manager_t
*pieee_15_4_manager)
211
{
212
/* Initialize the IEEE 15.4 manager. */
213
pieee_15_4_manager->
wake
= wake;
214
pieee_15_4_manager->
sleep
= sleep;
215
pieee_15_4_manager->
set_channel
= set_channel;
216
pieee_15_4_manager->
get_channel
= get_channel;
217
pieee_15_4_manager->
set_dst_panid
= set_dst_panid;
218
pieee_15_4_manager->
get_dst_panid
= get_dst_panid;
219
pieee_15_4_manager->
set_src_panid
= set_src_panid;
220
pieee_15_4_manager->
get_src_panid
= get_src_panid;
221
pieee_15_4_manager->
set_auto_mode
= set_auto_mode;
222
pieee_15_4_manager->
get_auto_mode
= get_auto_mode;
223
pieee_15_4_manager->
set_long_addr
= set_long_addr;
224
pieee_15_4_manager->
get_long_addr
= get_long_addr;
225
pieee_15_4_manager->
set_short_addr
= set_short_addr;
226
pieee_15_4_manager->
get_short_addr
= get_short_addr;
227
pieee_15_4_manager->
set_iamcoord_bit
= set_iamcoord_bit;
228
pieee_15_4_manager->
get_iamcoord_bit
= get_iamcoord_bit;
229
pieee_15_4_manager->
set_coord_long_addr
= set_coord_long_addr;
230
pieee_15_4_manager->
get_coord_long_addr
= get_coord_long_addr;
231
pieee_15_4_manager->
set_coord_short_addr
= set_coord_short_addr;
232
pieee_15_4_manager->
get_coord_short_addr
= get_coord_short_addr;
233
pieee_15_4_manager->
set_dest_long_addr
= set_dest_long_addr;
234
pieee_15_4_manager->
get_dest_long_addr
= get_dest_long_addr;
235
}
236
237
/** \} */
Generated on Fri Aug 30 2013 12:34:08 for Contiki 2.5 by
1.8.3.1