Contiki-NG
tsch-slot-operation.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015, SICS Swedish ICT.
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  * \addtogroup tsch
35  * @{
36  * \file
37  * TSCH runtime operation within timeslots
38 */
39 
40 #ifndef __TSCH_SLOT_OPERATION_H__
41 #define __TSCH_SLOT_OPERATION_H__
42 
43 /********** Includes **********/
44 
45 #include "contiki.h"
46 #include "lib/ringbufindex.h"
47 
48 /***** External Variables *****/
49 
50 /* A ringbuf storing outgoing packets after they were dequeued.
51  * Will be processed layer by tsch_tx_process_pending */
52 extern struct ringbufindex dequeued_ringbuf;
53 extern struct tsch_packet *dequeued_array[TSCH_DEQUEUED_ARRAY_SIZE];
54 /* A ringbuf storing incoming packets.
55  * Will be processed layer by tsch_rx_process_pending */
56 extern struct ringbufindex input_ringbuf;
57 extern struct input_packet input_array[TSCH_MAX_INCOMING_PACKETS];
58 /* Last clock_time_t where synchronization happened */
59 extern clock_time_t tsch_last_sync_time;
60 /* Counts the length of the current burst */
61 extern int tsch_current_burst_count;
62 
63 /********** Functions *********/
64 
65 /**
66  * Checks if the TSCH lock is set. Accesses to global structures outside of
67  * interrupts must be done through the lock, unless the sturcutre has
68  * atomic read/write
69  *
70  * \return 1 if the lock is taken, 0 otherwise
71  */
72 int tsch_is_locked(void);
73 /**
74  * Takes the TSCH lock. When the lock is taken, slot operation will be skipped
75  * until release.
76  *
77  * \return 1 if the lock was successfully taken, 0 otherwise
78  */
79 int tsch_get_lock(void);
80 /**
81  * Releases the TSCH lock.
82  */
83 void tsch_release_lock(void);
84 /**
85  * Set global time before starting slot operation, with a rtimer time and an ASN
86  *
87  * \param next_slot_start the time to the start of the next slot, in rtimer ticks
88  * \param next_slot_asn the ASN of the next slot
89  */
90 void tsch_slot_operation_sync(rtimer_clock_t next_slot_start,
91  struct tsch_asn_t *next_slot_asn);
92 /**
93  * Start actual slot operation
94  */
95 void tsch_slot_operation_start(void);
96 
97 #endif /* __TSCH_SLOT_OPERATION_H__ */
98 /** @} */
TSCH packet information.
Definition: tsch-types.h:97
Header file for the ringbufindex library
int tsch_get_lock(void)
Takes the TSCH lock.
void tsch_release_lock(void)
Releases the TSCH lock.
int tsch_is_locked(void)
Checks if the TSCH lock is set.
void tsch_slot_operation_sync(rtimer_clock_t next_slot_start, struct tsch_asn_t *next_slot_asn)
Set global time before starting slot operation, with a rtimer time and an ASN.
Stores data about an incoming packet.
Definition: tsch-types.h:152
void tsch_slot_operation_start(void)
Start actual slot operation.
The ASN is an absolute slot number over 5 bytes.
Definition: tsch-asn.h:48