Contiki-NG
Toggle main menu visibility
Loading...
Searching...
No Matches
oscillators.c
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2015, Texas Instruments Incorporated - http://www.ti.com/
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 copyright holder nor the names of its
14
* contributors may be used to endorse or promote products derived
15
* from this software without specific prior written permission.
16
*
17
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
20
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28
* OF THE POSSIBILITY OF SUCH DAMAGE.
29
*/
30
/*---------------------------------------------------------------------------*/
31
/**
32
* \addtogroup cc26xx-oscillators
33
* @{
34
*
35
* \file
36
* Implementation of CC26xxware oscillator control wrappers.
37
*/
38
/*---------------------------------------------------------------------------*/
39
#include "
ti-lib.h
"
40
#include "
aux-ctrl.h
"
41
42
#include <stdint.h>
43
/*---------------------------------------------------------------------------*/
44
void
45
oscillators_select_lf_xosc
(
void
)
46
{
47
/* Request AUX access, with OSCCTRL and SMPH clocks */
48
aux_consumer_module_t
osc = {
49
.clocks = AUX_WUC_OSCCTRL_CLOCK | AUX_WUC_SMPH_CLOCK
50
};
51
aux_ctrl_register_consumer
(&osc);
52
53
/* Switch LF clock source to the LF XOSC if required */
54
if
(ti_lib_osc_clock_source_get(OSC_SRC_CLK_LF) != OSC_XOSC_LF) {
55
ti_lib_osc_clock_source_set(OSC_SRC_CLK_LF, OSC_XOSC_LF);
56
57
/* Wait for LF clock source to become XOSC_LF */
58
while
(ti_lib_osc_clock_source_get(OSC_SRC_CLK_LF) != OSC_XOSC_LF);
59
60
/* Disable the LF clock qualifiers */
61
ti_lib_ddi_16_bit_field_write(AUX_DDI0_OSC_BASE, DDI_0_OSC_O_CTL0,
62
DDI_0_OSC_CTL0_BYPASS_XOSC_LF_CLK_QUAL_M |
63
DDI_0_OSC_CTL0_BYPASS_RCOSC_LF_CLK_QUAL_M,
64
DDI_0_OSC_CTL0_BYPASS_RCOSC_LF_CLK_QUAL_S,
65
0x3);
66
}
67
68
/* Release the OSC AUX consumer */
69
aux_ctrl_unregister_consumer
(&osc);
70
}
71
/*---------------------------------------------------------------------------*/
72
void
73
oscillators_select_lf_rcosc
(
void
)
74
{
75
/* Request AUX access, with OSCCTRL and SMPH clocks */
76
aux_consumer_module_t
osc = {
77
.clocks = AUX_WUC_OSCCTRL_CLOCK | AUX_WUC_SMPH_CLOCK
78
};
79
aux_ctrl_register_consumer
(&osc);
80
81
/* Switch LF clock source to the LF XOSC if required */
82
if
(ti_lib_osc_clock_source_get(OSC_SRC_CLK_LF) != OSC_RCOSC_LF) {
83
ti_lib_osc_clock_source_set(OSC_SRC_CLK_LF, OSC_RCOSC_LF);
84
85
/* Wait for LF clock source to become XOSC_LF */
86
while
(ti_lib_osc_clock_source_get(OSC_SRC_CLK_LF) != OSC_RCOSC_LF);
87
}
88
89
/* Release the OSC AUX consumer */
90
aux_ctrl_unregister_consumer
(&osc);
91
}
92
/*---------------------------------------------------------------------------*/
93
void
94
oscillators_request_hf_xosc
(
void
)
95
{
96
/* Request AUX access, with OSCCTRL and SMPH clocks */
97
aux_consumer_module_t
osc = {
98
.clocks = AUX_WUC_OSCCTRL_CLOCK | AUX_WUC_SMPH_CLOCK
99
};
100
aux_ctrl_register_consumer
(&osc);
101
102
if
(ti_lib_osc_clock_source_get(OSC_SRC_CLK_HF) != OSC_XOSC_HF) {
103
/*
104
* Request to switch to the crystal to enable radio operation. It takes a
105
* while for the XTAL to be ready so instead of performing the actual
106
* switch, we return and we do other stuff while the XOSC is getting ready.
107
*/
108
ti_lib_osc_clock_source_set(OSC_SRC_CLK_MF | OSC_SRC_CLK_HF, OSC_XOSC_HF);
109
}
110
111
/* Release the OSC AUX consumer */
112
aux_ctrl_unregister_consumer
(&osc);
113
}
114
/*---------------------------------------------------------------------------*/
115
void
116
oscillators_switch_to_hf_xosc
(
void
)
117
{
118
/* Request AUX access, with OSCCTRL and SMPH clocks */
119
aux_consumer_module_t
osc = {
120
.clocks = AUX_WUC_OSCCTRL_CLOCK | AUX_WUC_SMPH_CLOCK
121
};
122
aux_ctrl_register_consumer
(&osc);
123
124
if
(ti_lib_osc_clock_source_get(OSC_SRC_CLK_HF) != OSC_XOSC_HF) {
125
/* Switch the HF clock source (cc26xxware executes this from ROM) */
126
ti_lib_osc_hf_source_switch();
127
}
128
129
/* Release the OSC AUX consumer */
130
aux_ctrl_unregister_consumer
(&osc);
131
}
132
/*---------------------------------------------------------------------------*/
133
void
134
oscillators_switch_to_hf_rc
(
void
)
135
{
136
/* Request AUX access, with OSCCTRL and SMPH clocks */
137
aux_consumer_module_t
osc = {
138
.clocks = AUX_WUC_OSCCTRL_CLOCK | AUX_WUC_SMPH_CLOCK
139
};
140
aux_ctrl_register_consumer
(&osc);
141
142
/* Set all clock sources to the HF RC Osc */
143
ti_lib_osc_clock_source_set(OSC_SRC_CLK_MF | OSC_SRC_CLK_HF, OSC_RCOSC_HF);
144
145
/* Check to not enable HF RC oscillator if already enabled */
146
if
(ti_lib_osc_clock_source_get(OSC_SRC_CLK_HF) != OSC_RCOSC_HF) {
147
/* Switch the HF clock source (cc26xxware executes this from ROM) */
148
ti_lib_osc_hf_source_switch();
149
}
150
151
/* Release the OSC AUX consumer */
152
aux_ctrl_unregister_consumer
(&osc);
153
}
154
/*---------------------------------------------------------------------------*/
155
/** @} */
aux-ctrl.h
Header file for the management of the CC13xx/CC26xx AUX domain.
aux_consumer_module_t
struct aux_consumer_module aux_consumer_module_t
The data structure to be used for modules that require access to AUX.
aux_ctrl_unregister_consumer
void aux_ctrl_unregister_consumer(aux_consumer_module_t *consumer)
Deregister a module that no longer requires access to the AUX power domain.
Definition
aux-ctrl.c:61
aux_ctrl_register_consumer
void aux_ctrl_register_consumer(aux_consumer_module_t *consumer)
Register a module that no longer requires access to the AUX power domain.
Definition
aux-ctrl.c:44
oscillators_switch_to_hf_xosc
void oscillators_switch_to_hf_xosc(void)
Performs the switch to the XOSC.
Definition
oscillators.c:116
oscillators_request_hf_xosc
void oscillators_request_hf_xosc(void)
Requests the HF XOSC as the source for the HF clock, but does not perform the actual switch.
Definition
oscillators.c:94
oscillators_select_lf_rcosc
void oscillators_select_lf_rcosc(void)
Set the LF clock source to be the LF RCOSC.
Definition
oscillators.c:73
oscillators_switch_to_hf_rc
void oscillators_switch_to_hf_rc(void)
Switches MF and HF clock source to be the HF RC OSC.
Definition
oscillators.c:134
oscillators_select_lf_xosc
void oscillators_select_lf_xosc(void)
Set the LF clock source to be the LF XOSC.
Definition
oscillators.c:45
ti-lib.h
Header file with macros which rename TI CC26xxware functions.
arch
cpu
cc26x0-cc13x0
dev
oscillators.c
Generated on
for Contiki-NG by
1.17.0