Contiki 3.x
sicslowmac.h
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  */
32 
33 /**
34  * \file
35  * Example glue code between the existing MAC code and the
36  * Contiki mac interface
37  * \author
38  * Adam Dunkels <adam@sics.se>
39  * Eric Gnoske <egnoske@gmail.com>
40  * Blake Leverett <bleverett@gmail.com>
41  */
42 
43 /**
44  \addtogroup rf230mac
45 */
46 
47 #ifndef SICSLOWMAC_H_
48 #define SICSLOWMAC_H_
49 
50 #include <stdbool.h>
51 #include <stdint.h>
52 #include "contiki.h"
53 #include "dev/radio.h"
54 #include "frame.h"
55 
56 /* Macros & Defines */
57 
58 typedef enum {
59  MAC_EVENT_RX=0x10,
60  MAC_EVENT_ACK,
61  MAC_EVENT_NACK,
62  MAC_EVENT_SCAN,
63  MAC_EVENT_BEACON_REQ,
64  MAC_EVENT_DROPPED,
65  MAC_EVENT_TX
66  /* MAC_EVENT_TIMER */
67 } event_t;
68 
69 typedef struct {
70  event_t event; /**< Event type, see event_t for details. */
71  uint8_t *data; /**< Associated data that goes with the event. Depends on event type. */
72 } event_object_t;
73 
74 extern const struct mac_driver sicslowmac_driver;
75 
76 /* Prototypes */
77 PROCESS_NAME(mac_process);
78 
79 uint8_t mac_event_pending(void);
80 void mac_put_event(event_object_t *object);
81 event_object_t *mac_get_event(void);
82 void mac_task(process_event_t ev, process_data_t data);
83 uint8_t nwk_dataIndication(void);
84 const struct mac_driver *sicslowmac_init(const struct radio_driver *r);
85 /* void sicslowmac_input_packet(const struct radio_driver *d); */
86 int sicslowmac_dataRequest(void);
87 void sicslowmac_dataIndication(void);
88 void sicslowmac_resetRequest (bool setDefaultPIB);
89 int sicsloread(void);
90 void byte_reverse(uint8_t * bytes, uint8_t num);
91 struct mac_driver * sicslowmac_get_driver(void);
92 parsed_frame_t * sicslowmac_get_frame(void);
93 
94 #endif /* SICSLOWMAC_H_ */
void sicslowmac_resetRequest(bool setDefaultPIB)
This is the implementation of the 15.4 MAC Reset Request primitive.
Definition: sicslowmac.c:559
int sicslowmac_dataRequest(void)
This is the implementation of the 15.4 MAC Data Request primitive.
Definition: sicslowmac.c:396
Header file for the radio API
#define PROCESS_NAME(name)
Declare the name of a process.
Definition: process.h:286
uint8_t mac_event_pending(void)
Checks for any pending events in the queue.
Definition: sicslowmac.c:122
The structure of a device driver for a radio in Contiki.
Definition: radio.h:225
event_object_t * mac_get_event(void)
Pulls an event from the event queue.
Definition: sicslowmac.c:162
void mac_task(process_event_t ev, process_data_t data)
This is the main loop task for the MAC.
Definition: sicslowmac.c:193
void mac_put_event(event_object_t *object)
Puts an event into the queue of events.
Definition: sicslowmac.c:133
The structure of a MAC protocol driver in Contiki.
Definition: mac.h:54
802.15.4 frame creation and parsing functions