Change script for apply upstream code
[platform/upstream/connectedhomeip.git] / third_party / openthread / repo / examples / platforms / efr32mg12 / platform-efr32.h
1 /*
2  *  Copyright (c) 2020, The OpenThread Authors.
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 are met:
7  *  1. Redistributions of source code must retain the above copyright
8  *     notice, this list of conditions and the following disclaimer.
9  *  2. Redistributions in binary form must reproduce the above copyright
10  *     notice, this list of conditions and the following disclaimer in the
11  *     documentation and/or other materials provided with the distribution.
12  *  3. Neither the name of the copyright holder nor the
13  *     names of its contributors may be used to endorse or promote products
14  *     derived from this software without specific prior written permission.
15  *
16  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17  *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  *  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20  *  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23  *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24  *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26  *  POSSIBILITY OF SUCH DAMAGE.
27  */
28
29 /**
30  * @file
31  *   This file includes the platform-specific initializers.
32  *
33  */
34
35 #ifndef PLATFORM_EFR32_H_
36 #define PLATFORM_EFR32_H_
37
38 #include <openthread/instance.h>
39
40 #include "em_device.h"
41 #include "em_system.h"
42
43 #include "core_cm4.h"
44 #include "rail.h"
45
46 // Global OpenThread instance structure
47 extern otInstance *sInstance;
48
49 // Global reference to rail handle
50 extern RAIL_Handle_t gRailHandle;
51
52 /**
53  * This function initializes the alarm service used by OpenThread.
54  *
55  */
56 void efr32AlarmInit(void);
57
58 /**
59  * This function performs alarm driver processing.
60  *
61  * @param[in]  aInstance  The OpenThread instance structure.
62  *
63  */
64 void efr32AlarmProcess(otInstance *aInstance);
65
66 /**
67  * This function initializes the radio service used by OpenThead.
68  *
69  */
70 void efr32RadioInit(void);
71
72 /**
73  * This function deinitializes the radio service used by OpenThead.
74  *
75  */
76 void efr32RadioDeinit(void);
77
78 /**
79  * This function performs radio driver processing.
80  *
81  * @param[in]  aInstance  The OpenThread instance structure.
82  *
83  */
84 void efr32RadioProcess(otInstance *aInstance);
85
86 /**
87  * This function performs UART driver processing.
88  *
89  */
90 void efr32UartProcess(void);
91
92 /**
93  * Initialization of Misc module.
94  *
95  */
96 void efr32MiscInit(void);
97
98 /**
99  * Initialization of ADC module for random number generator.
100  *
101  */
102 void efr32RandomInit(void);
103
104 /**
105  * Initialization of Logger driver.
106  *
107  */
108 void efr32LogInit(void);
109
110 /**
111  * Deinitialization of Logger driver.
112  *
113  */
114 void efr32LogDeinit(void);
115
116 /**
117  * Registers the sleep callback handler.  The callback is used to check that
118  * the application has no work pending and that it is safe to put the EFR32
119  * into a low energy sleep mode.
120  *
121  * The callback should return true if it is ok to enter sleep mode. Note
122  * that the callback itself is run with interrupts disabled and so should
123  * be kept as short as possible.  Anny interrupt including those from timers
124  * will wake the EFR32 out of sleep mode.
125  *
126  * @param[in]  aCallback  Callback function.
127  *
128  */
129 void efr32SetSleepCallback(bool (*aCallback)(void));
130
131 /**
132  * Put the EFR32 into a low power mode.  Before sleeping it will call a callback
133  * in the application registered with efr32SetSleepCallback to ensure that there
134  * is no outstanding work in the application to do.
135  */
136 void efr32Sleep(void);
137
138 #endif // PLATFORM_EFR32_H_