1 /******************************************************************************
2 *  Filename:       rf_patch_cpe_genfsk.h
3 *  Revised:        2015-09-11 13:15:59 +0100 (fr, 11 Sep 2015)
4 *  Revision:
5 *
6 *  Description:    Patch for CC13XX Generic FSK
7 *
8 *  Copyright (c) 2015, Texas Instruments Incorporated
9 *  All rights reserved.
10 *
11 *  Redistribution and use in source and binary forms, with or without
12 *  modification, are permitted provided that the following conditions are met:
13 *
14 *  1) Redistributions of source code must retain the above copyright notice,
15 *     this list of conditions and the following disclaimer.
16 *
17 *  2) Redistributions in binary form must reproduce the above copyright notice,
18 *     this list of conditions and the following disclaimer in the documentation
19 *     and/or other materials provided with the distribution.
20 *
21 *  3) Neither the name of the ORGANIZATION nor the names of its contributors may
22 *     be used to endorse or promote products derived from this software without
23 *     specific prior written permission.
24 *
25 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 *  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
29 *  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 *  POSSIBILITY OF SUCH DAMAGE.
36 *
37 ******************************************************************************/
38 
39 #ifndef _RF_PATCH_CPE_GENFSK_H
40 #define _RF_PATCH_CPE_GENFSK_H
41 
42 #include <stdint.h>
43 #include <string.h>
44 
45 #ifndef CPE_PATCH_TYPE
46 #define CPE_PATCH_TYPE static const uint32_t
47 #endif
48 
49 #ifndef SYS_PATCH_TYPE
50 #define SYS_PATCH_TYPE static const uint32_t
51 #endif
52 
53 #ifndef PATCH_FUN_SPEC
54 #define PATCH_FUN_SPEC static inline
55 #endif
56 
57 
58 CPE_PATCH_TYPE patchImageGenfsk[] = {
59    0x21000479,
60    0x210004dd,
61    0x210004fd,
62    0x21000527,
63    0x2100055d,
64    0x21000465,
65    0x4710b5f8,
66    0x460eb5f8,
67    0x25012100,
68    0x473004ad,
69    0x4904b570,
70    0xb5704708,
71    0x47084903,
72    0x4903b5f8,
73    0x00004708,
74    0x00004bc9,
75    0x00004a69,
76    0x00004ce5,
77    0x21004a02,
78    0xb4f06011,
79    0x47084901,
80    0x40044014,
81    0x000068cf,
82    0x4603b570,
83    0x29014615,
84    0x2900d006,
85    0x4a11d006,
86    0xf7ff4628,
87    0xbd70ffd3,
88    0xe000480f,
89    0x2405480f,
90    0xd8034283,
91    0x1e640840,
92    0xdcf92c00,
93    0x200140e3,
94    0x18180340,
95    0x29010b82,
96    0x4906d007,
97    0x31802300,
98    0xf7ff4628,
99    0xb2e0ffbd,
100    0x4902bd70,
101    0x316c4b04,
102    0x0000e7f6,
103    0x00005c83,
104    0x2386bca0,
105    0x230d8300,
106    0x21000660,
107    0x481ab510,
108    0x56412100,
109    0xd1021c49,
110    0x7ac94918,
111    0x49177001,
112    0x31604817,
113    0xf7ff82c8,
114    0xbd10ffa8,
115    0x4815b510,
116    0xf7ff7ac4,
117    0x07a0ffa5,
118    0x490fd00c,
119    0x56082000,
120    0xd0071c42,
121    0x0212220f,
122    0x4a0c4310,
123    0x82d03260,
124    0x700820ff,
125    0xb510bd10,
126    0x21004807,
127    0x1c495641,
128    0x4906d102,
129    0x70017ac9,
130    0x48074904,
131    0x82c83160,
132    0xff80f7ff,
133    0x0000bd10,
134    0x21000690,
135    0x40086200,
136    0x00000f07,
137    0x21000260,
138    0x00000808,
139    0x4e1ab5f8,
140    0x6b714605,
141    0x09cc4819,
142    0x2d0001e4,
143    0x4918d011,
144    0x29027809,
145    0x7b00d00f,
146    0xb6724304,
147    0x4f152001,
148    0x47b80240,
149    0x38204811,
150    0x09c18800,
151    0xd00407c9,
152    0x7ac0e016,
153    0x7b40e7f0,
154    0x490fe7ee,
155    0x61cc6374,
156    0x07c00a40,
157    0x2001d00c,
158    0x6b310380,
159    0xd0012d00,
160    0xe0004301,
161    0x46084381,
162    0x49076331,
163    0x63483940,
164    0x47b82000,
165    0xbdf8b662,
166    0x21000280,
167    0x21000088,
168    0x2100029b,
169    0x00003f7b,
170    0x40044040,
171    0x4d17b538,
172    0x28007f28,
173    0x4816d127,
174    0x09c08800,
175    0xd12207c0,
176    0x69604c14,
177    0xd11e2800,
178    0xf0004668,
179    0x4668f82b,
180    0x28017800,
181    0x4668d117,
182    0x28107840,
183    0x2008d213,
184    0x6a686160,
185    0x01400940,
186    0x4a0b6020,
187    0x62d12100,
188    0x21024a0a,
189    0x21016011,
190    0x60204308,
191    0x43082103,
192    0x60206268,
193    0x4806bd38,
194    0xbd384780,
195    0x21000280,
196    0x21000068,
197    0x40044000,
198    0x40041100,
199    0xe000e280,
200    0x00003bc3,
201    0x4801b403,
202    0xbd019001,
203    0x00006fa5,
204    0x00000000,
205    0x00030001,
206    0x001f000a,
207    0x00eb0059,
208    0x04ea0239,
209    0x129709f9,
210    0x32a11feb,
211    0x660a4a78,
212    0x9e8c82fa,
213    0xc917b663,
214    0xdeedd664,
215    0xe5e0e3c1,
216    0x000000ff,
217 };
218 #define _NWORD_PATCHIMAGE 158
219 
220 #define _NWORD_PATCHSYS 0
221 
222 #define IRQ_PATCH_0 0x210005dd
223 
224 
225 #define _SYS_PATCH_FIXED_ADDR 0x20000000
226 
enterCpePatchGenfsk(void)227 PATCH_FUN_SPEC void enterCpePatchGenfsk(void)
228 {
229    uint32_t *pPatchVec = (uint32_t *) 0x2100041C;
230 
231 #if (_NWORD_PATCHIMAGE > 0)
232    memcpy(pPatchVec, patchImageGenfsk, sizeof(patchImageGenfsk));
233 #endif
234 }
235 
enterSysPatchGenfsk(void)236 PATCH_FUN_SPEC void enterSysPatchGenfsk(void)
237 {
238 }
239 
configurePatchGenfsk(void)240 PATCH_FUN_SPEC void configurePatchGenfsk(void)
241 {
242    uint8_t *pPatchTab = (uint8_t *) 0x21000340;
243    uint32_t *pIrqPatch = (uint32_t *) 0x210003BC;
244 
245 
246    pPatchTab[80] = 0;
247    pPatchTab[53] = 1;
248    pPatchTab[57] = 2;
249    pPatchTab[55] = 3;
250    pPatchTab[110] = 4;
251    pPatchTab[107] = 5;
252 
253    pIrqPatch[1] = IRQ_PATCH_0;
254 }
255 
rf_patch_cpe_genfsk(void)256 PATCH_FUN_SPEC void rf_patch_cpe_genfsk(void)
257 {
258    enterSysPatchGenfsk();
259    enterCpePatchGenfsk();
260    configurePatchGenfsk();
261 }
262 
refreshPatchGenfsk(void)263 PATCH_FUN_SPEC void refreshPatchGenfsk(void)
264 {
265    enterCpePatchGenfsk();
266    configurePatchGenfsk();
267 }
268 
269 #undef IRQ_PATCH_0
270 
271 #endif
272