1 /*
2  *  Copyright (c) 2016, 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_CC2538_H_
36 #define PLATFORM_CC2538_H_
37 
38 #include <openthread-core-config.h>
39 #include <stdint.h>
40 #include <openthread/config.h>
41 #include <openthread/instance.h>
42 
43 #include "cc2538-reg.h"
44 
45 // Global OpenThread instance structure
46 extern otInstance *sInstance;
47 
48 /**
49  * Initialize the debug uart
50  */
51 void cc2538DebugUartInit(void);
52 
53 /**
54  * This function initializes the alarm service used by OpenThread.
55  *
56  */
57 void cc2538AlarmInit(void);
58 
59 /**
60  * This function performs alarm driver processing.
61  *
62  * @param[in]  aInstance  The OpenThread instance structure.
63  *
64  */
65 void cc2538AlarmProcess(otInstance *aInstance);
66 
67 /**
68  * This function initializes the radio service used by OpenThread.
69  *
70  */
71 void cc2538RadioInit(void);
72 
73 /**
74  * This function performs radio driver processing.
75  *
76  * @param[in]  aInstance  The OpenThread instance structure.
77  *
78  */
79 void cc2538RadioProcess(otInstance *aInstance);
80 
81 /**
82  * This function initializes the random number service used by OpenThread.
83  *
84  */
85 void cc2538RandomInit(void);
86 
87 /**
88  * This function performs UART driver processing.
89  *
90  */
91 void cc2538UartProcess(void);
92 
93 #if OPENTHREAD_CONFIG_CC2538_WITH_CC2592 && OPENTHREAD_CONFIG_CC2592_USE_HGM
94 /**
95  * Change the state of the CC2592 HGM pin.
96  *
97  * @param	aState	Whether or not to enable HGM
98  */
99 void cc2538RadioSetHgm(bool aState);
100 
101 /**
102  * Retrieve the state of the CC2592 HGM pin.
103  */
104 bool cc2538RadioGetHgm(void);
105 #endif // OPENTHREAD_CONFIG_CC2538_WITH_CC2592 && OPENTHREAD_CONFIG_CC2592_USE_HGM
106 
107 typedef enum
108 {
109     OT_CC2538_TIMER_ENERGY_SCAN, ///< Internal timer for energy scan
110     OT_CC2538_TIMERS_COUNT,      ///< Number of internal timers
111 } otCC2538Timer;
112 
113 /**
114  * This function sets the internal timer.
115  *
116  * @param[in]   aTimer  The timer identifier.
117  * @param[in]   aDelay  The delay to trigger the timer, and must be no more than `INT32_MAX`.
118  *
119  */
120 void cc2538SetTimer(otCC2538Timer aTimer, uint32_t aDelay);
121 
122 #endif // PLATFORM_CC2538_H_
123