Appiko
cc1190_drv.c
1 /******************************************************************************
2  * Filename: cc1190_drv.c
3  *
4  * Description: Implementation file for controling the CC1190 device
5  *
6  * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
7  *
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  *
16  * Redistributions in binary form must reproduce the above copyright
17  * notice, this list of conditions and the following disclaimer in the
18  * documentation and/or other materials provided with the distribution.
19  *
20  * Neither the name of Texas Instruments Incorporated nor the names of
21  * its contributors may be used to endorse or promote products derived
22  * from this software without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35  *
36  *******************************************************************************/
37 #include "msp430.h"
38 #include "hal_spi_rf.h"
39 #include "cc112x_def.h"
40 
41 /******************************************************************************
42  * @fn range_extender_rxon
43  *
44  * @brief Enable the RX path of the front end module
45  *
46  *
47  * input parameters
48  *
49  * @param void
50  *
51  * output parameters
52  *
53  * @return void
54  *
55  *
56  */
57 void range_extender_rxon(void) {
58 
59  /* configure txon */
60  RF_PA_EN_PxOUT &= ~RF_PA_EN_PIN;
61  RF_LNA_EN_PxOUT |= RF_LNA_EN_PIN;
62 
63  return;
64 }
65 
66 /******************************************************************************
67  * @fn range_extender_txon
68  *
69  * @brief Enable the TX path of the front end module
70  *
71  *
72  * input parameters
73  *
74  * @param void
75  *
76  * output parameters
77  *
78  * @return void
79  *
80  *
81  */
82 void range_extender_txon(void) {
83 
84  /* configure txon */
85  RF_PA_EN_PxOUT |= RF_PA_EN_PIN;
86  RF_LNA_EN_PxOUT &= ~RF_LNA_EN_PIN;
87 
88  return;
89 }
90 
91 /******************************************************************************
92  * @fn range_extender_idle
93  *
94  * @brief Idle the front end module
95  *
96  *
97  * input parameters
98  *
99  * @param void
100  *
101  * output parameters
102  *
103  * @return void
104  *
105  *
106  */
107 void range_extender_idle(void) {
108 
109  /* configure idle */
110  RF_PA_EN_PxOUT &= ~RF_PA_EN_PIN;
111  RF_LNA_EN_PxOUT &= ~RF_LNA_EN_PIN;
112 
113  return;
114 }
115 
116 
117 /******************************************************************************
118  * @fn range_extender_init
119  *
120  * @brief Initialize the front end module
121  *
122  *
123  * input parameters
124  *
125  * @param void
126  *
127  * output parameters
128  *
129  * @return void
130  *
131  *
132  */
133 void range_extender_init(void) {
134 
135  uint8 regs_uint8;
136 
137 #ifdef USE_CC112X
138  /* lower the maximum output of the transciever to 10dBm */
139  regs_uint8 = 0x74;
140  trx8BitRegAccess(RADIO_WRITE_ACCESS , PA_CFG2, &regs_uint8, 1);
141 #endif
142 
143  /* initialize the IO */
144  RF_PA_EN_PxDIR |= RF_PA_EN_PIN;
145  RF_LNA_EN_PxDIR |= RF_LNA_EN_PIN;
146 
147  /* initialize idle */
148  range_extender_idle();
149 
150  return;
151 }