Contiki-NG
int-master.h
1 /*
2  * Copyright (c) 2017, George Oikonomou - http://www.spd.gr
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  *
9  * 1. Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  * 3. Neither the name of the copyright holder nor the names of its
15  * contributors may be used to endorse or promote products derived
16  * from this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
29  * OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31 /*---------------------------------------------------------------------------*/
32 /** \addtogroup sys
33  * @{
34  *
35  * \defgroup interrupts Master interrupt manipulation
36  * @{
37  *
38  * These functions can be used to manipulate the master interrupt in a
39  * platform-independent fashion
40  */
41 /*---------------------------------------------------------------------------*/
42 #ifndef INT_MASTER_H_
43 #define INT_MASTER_H_
44 /*---------------------------------------------------------------------------*/
45 #include "contiki.h"
46 
47 #include <stdbool.h>
48 #include <stdint.h>
49 /*---------------------------------------------------------------------------*/
50 #ifdef INT_MASTER_CONF_STATUS_DATATYPE
51 #define INT_MASTER_STATUS_DATATYPE INT_MASTER_CONF_STATUS_DATATYPE
52 #else
53 #define INT_MASTER_STATUS_DATATYPE uint32_t
54 #endif
55 
56 /**
57  * \brief Master interrupt state representation data type
58  *
59  * It is possible for the platform code to change this datatype by defining
60  * INT_MASTER_CONF_STATUS_DATATYPE
61  */
62 typedef INT_MASTER_STATUS_DATATYPE int_master_status_t;
63 /*---------------------------------------------------------------------------*/
64 /**
65  * \brief Enable the master interrupt
66  *
67  * The platform developer must provide this function
68  */
69 void int_master_enable(void);
70 
71 /**
72  * \brief Disable the master interrupt
73  * \return The status of the master interrupt before disabling it
74  *
75  * This function will return the status of the master interrupt as it was
76  * before it got disabled.
77  *
78  * The semantics of the return value are entirely platform-specific. The
79  * calling code should not try to determine whether the master interrupt was
80  * previously enabled/disabled by interpreting the return value of this
81  * function. The return value should only be used as an argument to
82  * int_master_status_set()
83  *
84  * To determine the status of the master interrupt in a platform-independent
85  * fashion you should use int_master_is_enabled().
86  *
87  * The platform developer must provide this function
88  */
90 
91 /**
92  * \brief Set the status of the master interrupt
93  * \param status The new status
94  *
95  * The semantics of \e status are platform-dependent. Normally, the argument
96  * provided to this function will be a value previously retrieved through a
97  * call to int_master_read_and_disable()
98  *
99  * The platform developer must provide this function
100  */
102 
103 /**
104  * \brief Retrieve the status of the master interrupt
105  * \retval false Interrupts are disabled
106  * \retval true Interrupts are enabled
107  *
108  * This function can be used to retrieve the status of the master interrupt
109  * in a platform-independent fashion.
110  *
111  * The platform developer must provide this function
112  */
113 bool int_master_is_enabled(void);
114 /*---------------------------------------------------------------------------*/
115 #endif /* INT_MASTER_H_ */
116 /*---------------------------------------------------------------------------*/
117 /**
118  * @}
119  * @}
120  */
bool int_master_is_enabled(void)
Retrieve the status of the master interrupt.
Definition: int-master.c:74
void int_master_enable(void)
Enable the master interrupt.
Definition: int-master.c:52
int_master_status_t int_master_read_and_disable(void)
Disable the master interrupt.
Definition: int-master.c:58
INT_MASTER_STATUS_DATATYPE int_master_status_t
Master interrupt state representation data type.
Definition: int-master.h:62
void int_master_status_set(int_master_status_t status)
Set the status of the master interrupt.
Definition: int-master.c:68