Contiki-NG
CC1310_LAUNCHXL.c
1 /*
2  * Copyright (c) 2015-2018, Texas Instruments Incorporated
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  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 /*
34  * ====================== CC1310_LAUNCHXL.c ===================================
35  * This file is responsible for setting up the board specific items for the
36  * CC1310_LAUNCHXL board.
37  */
38 
39 #include <stdbool.h>
40 #include <stddef.h>
41 #include <stdint.h>
42 
43 #include <ti/devices/DeviceFamily.h>
44 #include DeviceFamily_constructPath(driverlib/ioc.h)
45 #include DeviceFamily_constructPath(driverlib/udma.h)
46 #include DeviceFamily_constructPath(inc/hw_ints.h)
47 #include DeviceFamily_constructPath(inc/hw_memmap.h)
48 
49 #include "CC1310_LAUNCHXL.h"
50 
51 /*
52  * =============================== ADCBuf ===============================
53  */
54 #include <ti/drivers/ADCBuf.h>
55 #include <ti/drivers/adcbuf/ADCBufCC26XX.h>
56 
57 ADCBufCC26XX_Object adcBufCC26xxObjects[CC1310_LAUNCHXL_ADCBUFCOUNT];
58 
59 /*
60  * This table converts a virtual adc channel into a dio and internal analogue
61  * input signal. This table is necessary for the functioning of the adcBuf
62  * driver. Comment out unused entries to save flash. Dio and internal signal
63  * pairs are hardwired. Do not remap them in the table. You may reorder entire
64  * entries. The mapping of dio and internal signals is package dependent.
65  */
66 const ADCBufCC26XX_AdcChannelLutEntry ADCBufCC26XX_adcChannelLut[CC1310_LAUNCHXL_ADCBUF0CHANNELCOUNT] = {
67  {CC1310_LAUNCHXL_DIO23_ANALOG, ADC_COMPB_IN_AUXIO7},
68  {CC1310_LAUNCHXL_DIO24_ANALOG, ADC_COMPB_IN_AUXIO6},
69  {CC1310_LAUNCHXL_DIO25_ANALOG, ADC_COMPB_IN_AUXIO5},
70  {CC1310_LAUNCHXL_DIO26_ANALOG, ADC_COMPB_IN_AUXIO4},
71  {CC1310_LAUNCHXL_DIO27_ANALOG, ADC_COMPB_IN_AUXIO3},
72  {CC1310_LAUNCHXL_DIO28_ANALOG, ADC_COMPB_IN_AUXIO2},
73  {CC1310_LAUNCHXL_DIO29_ANALOG, ADC_COMPB_IN_AUXIO1},
74  {CC1310_LAUNCHXL_DIO30_ANALOG, ADC_COMPB_IN_AUXIO0},
75  {PIN_UNASSIGNED, ADC_COMPB_IN_VDDS},
76  {PIN_UNASSIGNED, ADC_COMPB_IN_DCOUPL},
77  {PIN_UNASSIGNED, ADC_COMPB_IN_VSS},
78 };
79 
80 const ADCBufCC26XX_HWAttrs adcBufCC26xxHWAttrs[CC1310_LAUNCHXL_ADCBUFCOUNT] = {
81  {
82  .intPriority = ~0,
83  .swiPriority = 0,
84  .adcChannelLut = ADCBufCC26XX_adcChannelLut,
85  .gpTimerUnit = CC1310_LAUNCHXL_GPTIMER0A,
86  .gptDMAChannelMask = 1 << UDMA_CHAN_TIMER0_A,
87  }
88 };
89 
90 const ADCBuf_Config ADCBuf_config[CC1310_LAUNCHXL_ADCBUFCOUNT] = {
91  {
92  &ADCBufCC26XX_fxnTable,
93  &adcBufCC26xxObjects[CC1310_LAUNCHXL_ADCBUF0],
94  &adcBufCC26xxHWAttrs[CC1310_LAUNCHXL_ADCBUF0]
95  },
96 };
97 
98 const uint_least8_t ADCBuf_count = CC1310_LAUNCHXL_ADCBUFCOUNT;
99 
100 /*
101  * =============================== ADC ===============================
102  */
103 #include <ti/drivers/ADC.h>
104 #include <ti/drivers/adc/ADCCC26XX.h>
105 
106 ADCCC26XX_Object adcCC26xxObjects[CC1310_LAUNCHXL_ADCCOUNT];
107 
108 
109 const ADCCC26XX_HWAttrs adcCC26xxHWAttrs[CC1310_LAUNCHXL_ADCCOUNT] = {
110  {
111  .adcDIO = CC1310_LAUNCHXL_DIO23_ANALOG,
112  .adcCompBInput = ADC_COMPB_IN_AUXIO7,
113  .refSource = ADCCC26XX_FIXED_REFERENCE,
114  .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
115  .inputScalingEnabled = true,
116  .triggerSource = ADCCC26XX_TRIGGER_MANUAL,
117  .returnAdjustedVal = false
118  },
119  {
120  .adcDIO = CC1310_LAUNCHXL_DIO24_ANALOG,
121  .adcCompBInput = ADC_COMPB_IN_AUXIO6,
122  .refSource = ADCCC26XX_FIXED_REFERENCE,
123  .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
124  .inputScalingEnabled = true,
125  .triggerSource = ADCCC26XX_TRIGGER_MANUAL,
126  .returnAdjustedVal = false
127  },
128  {
129  .adcDIO = CC1310_LAUNCHXL_DIO25_ANALOG,
130  .adcCompBInput = ADC_COMPB_IN_AUXIO5,
131  .refSource = ADCCC26XX_FIXED_REFERENCE,
132  .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
133  .inputScalingEnabled = true,
134  .triggerSource = ADCCC26XX_TRIGGER_MANUAL,
135  .returnAdjustedVal = false
136  },
137  {
138  .adcDIO = CC1310_LAUNCHXL_DIO26_ANALOG,
139  .adcCompBInput = ADC_COMPB_IN_AUXIO4,
140  .refSource = ADCCC26XX_FIXED_REFERENCE,
141  .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
142  .inputScalingEnabled = true,
143  .triggerSource = ADCCC26XX_TRIGGER_MANUAL,
144  .returnAdjustedVal = false
145  },
146  {
147  .adcDIO = CC1310_LAUNCHXL_DIO27_ANALOG,
148  .adcCompBInput = ADC_COMPB_IN_AUXIO3,
149  .refSource = ADCCC26XX_FIXED_REFERENCE,
150  .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
151  .inputScalingEnabled = true,
152  .triggerSource = ADCCC26XX_TRIGGER_MANUAL,
153  .returnAdjustedVal = false
154  },
155  {
156  .adcDIO = CC1310_LAUNCHXL_DIO28_ANALOG,
157  .adcCompBInput = ADC_COMPB_IN_AUXIO2,
158  .refSource = ADCCC26XX_FIXED_REFERENCE,
159  .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
160  .inputScalingEnabled = true,
161  .triggerSource = ADCCC26XX_TRIGGER_MANUAL,
162  .returnAdjustedVal = false
163  },
164  {
165  .adcDIO = CC1310_LAUNCHXL_DIO29_ANALOG,
166  .adcCompBInput = ADC_COMPB_IN_AUXIO1,
167  .refSource = ADCCC26XX_FIXED_REFERENCE,
168  .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
169  .inputScalingEnabled = true,
170  .triggerSource = ADCCC26XX_TRIGGER_MANUAL,
171  .returnAdjustedVal = false
172  },
173  {
174  .adcDIO = CC1310_LAUNCHXL_DIO30_ANALOG,
175  .adcCompBInput = ADC_COMPB_IN_AUXIO0,
176  .refSource = ADCCC26XX_FIXED_REFERENCE,
177  .samplingDuration = ADCCC26XX_SAMPLING_DURATION_10P9_MS,
178  .inputScalingEnabled = true,
179  .triggerSource = ADCCC26XX_TRIGGER_MANUAL,
180  .returnAdjustedVal = false
181  },
182  {
183  .adcDIO = PIN_UNASSIGNED,
184  .adcCompBInput = ADC_COMPB_IN_DCOUPL,
185  .refSource = ADCCC26XX_FIXED_REFERENCE,
186  .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
187  .inputScalingEnabled = true,
188  .triggerSource = ADCCC26XX_TRIGGER_MANUAL,
189  .returnAdjustedVal = false
190  },
191  {
192  .adcDIO = PIN_UNASSIGNED,
193  .adcCompBInput = ADC_COMPB_IN_VSS,
194  .refSource = ADCCC26XX_FIXED_REFERENCE,
195  .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
196  .inputScalingEnabled = true,
197  .triggerSource = ADCCC26XX_TRIGGER_MANUAL,
198  .returnAdjustedVal = false
199  },
200  {
201  .adcDIO = PIN_UNASSIGNED,
202  .adcCompBInput = ADC_COMPB_IN_VDDS,
203  .refSource = ADCCC26XX_FIXED_REFERENCE,
204  .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
205  .inputScalingEnabled = true,
206  .triggerSource = ADCCC26XX_TRIGGER_MANUAL,
207  .returnAdjustedVal = false
208  }
209 };
210 
211 const ADC_Config ADC_config[CC1310_LAUNCHXL_ADCCOUNT] = {
212  {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC1310_LAUNCHXL_ADC0], &adcCC26xxHWAttrs[CC1310_LAUNCHXL_ADC0]},
213  {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC1310_LAUNCHXL_ADC1], &adcCC26xxHWAttrs[CC1310_LAUNCHXL_ADC1]},
214  {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC1310_LAUNCHXL_ADC2], &adcCC26xxHWAttrs[CC1310_LAUNCHXL_ADC2]},
215  {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC1310_LAUNCHXL_ADC3], &adcCC26xxHWAttrs[CC1310_LAUNCHXL_ADC3]},
216  {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC1310_LAUNCHXL_ADC4], &adcCC26xxHWAttrs[CC1310_LAUNCHXL_ADC4]},
217  {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC1310_LAUNCHXL_ADC5], &adcCC26xxHWAttrs[CC1310_LAUNCHXL_ADC5]},
218  {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC1310_LAUNCHXL_ADC6], &adcCC26xxHWAttrs[CC1310_LAUNCHXL_ADC6]},
219  {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC1310_LAUNCHXL_ADC7], &adcCC26xxHWAttrs[CC1310_LAUNCHXL_ADC7]},
220  {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC1310_LAUNCHXL_ADCDCOUPL], &adcCC26xxHWAttrs[CC1310_LAUNCHXL_ADCDCOUPL]},
221  {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC1310_LAUNCHXL_ADCVSS], &adcCC26xxHWAttrs[CC1310_LAUNCHXL_ADCVSS]},
222  {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC1310_LAUNCHXL_ADCVDDS], &adcCC26xxHWAttrs[CC1310_LAUNCHXL_ADCVDDS]},
223 };
224 
225 const uint_least8_t ADC_count = CC1310_LAUNCHXL_ADCCOUNT;
226 
227 /*
228  * =============================== Crypto ===============================
229  */
230 #include <ti/drivers/crypto/CryptoCC26XX.h>
231 
232 CryptoCC26XX_Object cryptoCC26XXObjects[CC1310_LAUNCHXL_CRYPTOCOUNT];
233 
234 const CryptoCC26XX_HWAttrs cryptoCC26XXHWAttrs[CC1310_LAUNCHXL_CRYPTOCOUNT] = {
235  {
236  .baseAddr = CRYPTO_BASE,
237  .powerMngrId = PowerCC26XX_PERIPH_CRYPTO,
238  .intNum = INT_CRYPTO_RESULT_AVAIL_IRQ,
239  .intPriority = ~0,
240  }
241 };
242 
243 const CryptoCC26XX_Config CryptoCC26XX_config[CC1310_LAUNCHXL_CRYPTOCOUNT] = {
244  {
245  .object = &cryptoCC26XXObjects[CC1310_LAUNCHXL_CRYPTO0],
246  .hwAttrs = &cryptoCC26XXHWAttrs[CC1310_LAUNCHXL_CRYPTO0]
247  }
248 };
249 
250 /*
251  * =============================== GPIO ===============================
252  */
253 #include <ti/drivers/GPIO.h>
254 #include <ti/drivers/gpio/GPIOCC26XX.h>
255 
256 /*
257  * Array of Pin configurations
258  * NOTE: The order of the pin configurations must coincide with what was
259  * defined in CC1310_LAUNCHXL.h
260  * NOTE: Pins not used for interrupts should be placed at the end of the
261  * array. Callback entries can be omitted from callbacks array to
262  * reduce memory usage.
263  */
264 GPIO_PinConfig gpioPinConfigs[] = {
265  /* Input pins */
266  GPIOCC26XX_DIO_13 | GPIO_DO_NOT_CONFIG, /* Button 0 */
267  GPIOCC26XX_DIO_14 | GPIO_DO_NOT_CONFIG, /* Button 1 */
268 
269  GPIOCC26XX_DIO_15 | GPIO_DO_NOT_CONFIG, /* CC1310_LAUNCHXL_SPI_MASTER_READY */
270  GPIOCC26XX_DIO_21 | GPIO_DO_NOT_CONFIG, /* CC1310_LAUNCHXL_SPI_SLAVE_READY */
271 
272  /* Output pins */
273  GPIOCC26XX_DIO_07 | GPIO_DO_NOT_CONFIG, /* Green LED */
274  GPIOCC26XX_DIO_06 | GPIO_DO_NOT_CONFIG, /* Red LED */
275 
276  /* SPI Flash CSN */
277  GPIOCC26XX_DIO_20 | GPIO_DO_NOT_CONFIG,
278 
279  /* SD CS */
280  GPIOCC26XX_DIO_21 | GPIO_DO_NOT_CONFIG,
281 };
282 
283 /*
284  * Array of callback function pointers
285  * NOTE: The order of the pin configurations must coincide with what was
286  * defined in CC1310_LAUNCH.h
287  * NOTE: Pins not used for interrupts can be omitted from callbacks array to
288  * reduce memory usage (if placed at end of gpioPinConfigs array).
289  */
290 GPIO_CallbackFxn gpioCallbackFunctions[] = {
291  NULL, /* Button 0 */
292  NULL, /* Button 1 */
293  NULL, /* CC1310_LAUNCHXL_SPI_MASTER_READY */
294  NULL, /* CC1310_LAUNCHXL_SPI_SLAVE_READY */
295 };
296 
297 const GPIOCC26XX_Config GPIOCC26XX_config = {
298  .pinConfigs = (GPIO_PinConfig *)gpioPinConfigs,
299  .callbacks = (GPIO_CallbackFxn *)gpioCallbackFunctions,
300  .numberOfPinConfigs = CC1310_LAUNCHXL_GPIOCOUNT,
301  .numberOfCallbacks = sizeof(gpioCallbackFunctions)/sizeof(GPIO_CallbackFxn),
302  .intPriority = (~0)
303 };
304 
305 /*
306  * =============================== GPTimer ===============================
307  * Remove unused entries to reduce flash usage both in Board.c and Board.h
308  */
309 #include <ti/drivers/timer/GPTimerCC26XX.h>
310 
311 GPTimerCC26XX_Object gptimerCC26XXObjects[CC1310_LAUNCHXL_GPTIMERCOUNT];
312 
313 const GPTimerCC26XX_HWAttrs gptimerCC26xxHWAttrs[CC1310_LAUNCHXL_GPTIMERPARTSCOUNT] = {
314  { .baseAddr = GPT0_BASE, .intNum = INT_GPT0A, .intPriority = (~0), .powerMngrId = PowerCC26XX_PERIPH_GPT0, .pinMux = GPT_PIN_0A, },
315  { .baseAddr = GPT0_BASE, .intNum = INT_GPT0B, .intPriority = (~0), .powerMngrId = PowerCC26XX_PERIPH_GPT0, .pinMux = GPT_PIN_0B, },
316  { .baseAddr = GPT1_BASE, .intNum = INT_GPT1A, .intPriority = (~0), .powerMngrId = PowerCC26XX_PERIPH_GPT1, .pinMux = GPT_PIN_1A, },
317  { .baseAddr = GPT1_BASE, .intNum = INT_GPT1B, .intPriority = (~0), .powerMngrId = PowerCC26XX_PERIPH_GPT1, .pinMux = GPT_PIN_1B, },
318  { .baseAddr = GPT2_BASE, .intNum = INT_GPT2A, .intPriority = (~0), .powerMngrId = PowerCC26XX_PERIPH_GPT2, .pinMux = GPT_PIN_2A, },
319  { .baseAddr = GPT2_BASE, .intNum = INT_GPT2B, .intPriority = (~0), .powerMngrId = PowerCC26XX_PERIPH_GPT2, .pinMux = GPT_PIN_2B, },
320  { .baseAddr = GPT3_BASE, .intNum = INT_GPT3A, .intPriority = (~0), .powerMngrId = PowerCC26XX_PERIPH_GPT3, .pinMux = GPT_PIN_3A, },
321  { .baseAddr = GPT3_BASE, .intNum = INT_GPT3B, .intPriority = (~0), .powerMngrId = PowerCC26XX_PERIPH_GPT3, .pinMux = GPT_PIN_3B, },
322 };
323 
324 const GPTimerCC26XX_Config GPTimerCC26XX_config[CC1310_LAUNCHXL_GPTIMERPARTSCOUNT] = {
325  { &gptimerCC26XXObjects[CC1310_LAUNCHXL_GPTIMER0], &gptimerCC26xxHWAttrs[CC1310_LAUNCHXL_GPTIMER0A], GPT_A },
326  { &gptimerCC26XXObjects[CC1310_LAUNCHXL_GPTIMER0], &gptimerCC26xxHWAttrs[CC1310_LAUNCHXL_GPTIMER0B], GPT_B },
327  { &gptimerCC26XXObjects[CC1310_LAUNCHXL_GPTIMER1], &gptimerCC26xxHWAttrs[CC1310_LAUNCHXL_GPTIMER1A], GPT_A },
328  { &gptimerCC26XXObjects[CC1310_LAUNCHXL_GPTIMER1], &gptimerCC26xxHWAttrs[CC1310_LAUNCHXL_GPTIMER1B], GPT_B },
329  { &gptimerCC26XXObjects[CC1310_LAUNCHXL_GPTIMER2], &gptimerCC26xxHWAttrs[CC1310_LAUNCHXL_GPTIMER2A], GPT_A },
330  { &gptimerCC26XXObjects[CC1310_LAUNCHXL_GPTIMER2], &gptimerCC26xxHWAttrs[CC1310_LAUNCHXL_GPTIMER2B], GPT_B },
331  { &gptimerCC26XXObjects[CC1310_LAUNCHXL_GPTIMER3], &gptimerCC26xxHWAttrs[CC1310_LAUNCHXL_GPTIMER3A], GPT_A },
332  { &gptimerCC26XXObjects[CC1310_LAUNCHXL_GPTIMER3], &gptimerCC26xxHWAttrs[CC1310_LAUNCHXL_GPTIMER3B], GPT_B },
333 };
334 
335 /*
336  * =============================== I2C ===============================
337 */
338 #include <ti/drivers/I2C.h>
339 #include <ti/drivers/i2c/I2CCC26XX.h>
340 
341 #if TI_I2C_CONF_ENABLE
342 
343 I2CCC26XX_Object i2cCC26xxObjects[CC1310_LAUNCHXL_I2CCOUNT];
344 
345 const I2CCC26XX_HWAttrsV1 i2cCC26xxHWAttrs[CC1310_LAUNCHXL_I2CCOUNT] = {
346 #if TI_I2C_CONF_I2C0_ENABLE
347  {
348  .baseAddr = I2C0_BASE,
349  .powerMngrId = PowerCC26XX_PERIPH_I2C0,
350  .intNum = INT_I2C_IRQ,
351  .intPriority = ~0,
352  .swiPriority = 0,
353  .sdaPin = CC1310_LAUNCHXL_I2C0_SDA0,
354  .sclPin = CC1310_LAUNCHXL_I2C0_SCL0,
355  },
356 #endif
357 };
358 
359 const I2C_Config I2C_config[CC1310_LAUNCHXL_I2CCOUNT] = {
360 #if TI_I2C_CONF_I2C0_ENABLE
361  {
362  .fxnTablePtr = &I2CCC26XX_fxnTable,
363  .object = &i2cCC26xxObjects[CC1310_LAUNCHXL_I2C0],
364  .hwAttrs = &i2cCC26xxHWAttrs[CC1310_LAUNCHXL_I2C0]
365  },
366 #endif
367 };
368 
369 const uint_least8_t I2C_count = CC1310_LAUNCHXL_I2CCOUNT;
370 
371 #endif /* TI_I2C_CONF_ENABLE */
372 
373 /*
374  * =============================== NVS ===============================
375  */
376 #include <ti/drivers/NVS.h>
377 #include <ti/drivers/nvs/NVSSPI25X.h>
378 #include <ti/drivers/nvs/NVSCC26XX.h>
379 
380 #define NVS_REGIONS_BASE 0x1A000
381 #define SECTORSIZE 0x1000
382 #define REGIONSIZE (SECTORSIZE * 4)
383 
384 #if TI_NVS_CONF_ENABLE
385 
386 #if TI_NVS_CONF_NVS_INTERNAL_ENABLE
387 
388 /*
389  * Reserve flash sectors for NVS driver use by placing an uninitialized byte
390  * array at the desired flash address.
391  */
392 #if defined(__TI_COMPILER_VERSION__)
393 
394 /*
395  * Place uninitialized array at NVS_REGIONS_BASE
396  */
397 #pragma LOCATION(flashBuf, NVS_REGIONS_BASE);
398 #pragma NOINIT(flashBuf);
399 static char flashBuf[REGIONSIZE];
400 
401 #elif defined(__IAR_SYSTEMS_ICC__)
402 
403 /*
404  * Place uninitialized array at NVS_REGIONS_BASE
405  */
406 static __no_init char flashBuf[REGIONSIZE] @ NVS_REGIONS_BASE;
407 
408 #elif defined(__GNUC__)
409 
410 /*
411  * Place the flash buffers in the .nvs section created in the gcc linker file.
412  * The .nvs section enforces alignment on a sector boundary but may
413  * be placed anywhere in flash memory. If desired the .nvs section can be set
414  * to a fixed address by changing the following in the gcc linker file:
415  *
416  * .nvs (FIXED_FLASH_ADDR) (NOLOAD) : AT (FIXED_FLASH_ADDR) {
417  * *(.nvs)
418  * } > REGION_TEXT
419  */
420 __attribute__ ((section (".nvs")))
421 static char flashBuf[REGIONSIZE];
422 
423 #endif
424 
425 /* Allocate objects for NVS Internal Regions */
426 NVSCC26XX_Object nvsCC26xxObjects[1];
427 
428 /* Hardware attributes for NVS Internal Regions */
429 const NVSCC26XX_HWAttrs nvsCC26xxHWAttrs[1] = {
430  {
431  .regionBase = (void *)flashBuf,
432  .regionSize = REGIONSIZE,
433  },
434 };
435 
436 #endif /* TI_NVS_CONF_NVS_INTERNAL_ENABLE */
437 
438 #if TI_NVS_CONF_NVS_EXTERNAL_ENABLE
439 
440 #define SPISECTORSIZE 0x1000
441 #define SPIREGIONSIZE (SPISECTORSIZE * 32)
442 #define VERIFYBUFSIZE 64
443 
444 static uint8_t verifyBuf[VERIFYBUFSIZE];
445 
446 /* Allocate objects for NVS External Regions */
447 NVSSPI25X_Object nvsSPI25XObjects[1];
448 
449 /* Hardware attributes for NVS External Regions */
450 const NVSSPI25X_HWAttrs nvsSPI25XHWAttrs[1] = {
451  {
452  .regionBaseOffset = 0,
453  .regionSize = SPIREGIONSIZE,
454  .sectorSize = SPISECTORSIZE,
455  .verifyBuf = verifyBuf,
456  .verifyBufSize = VERIFYBUFSIZE,
457  .spiHandle = NULL,
458  .spiIndex = 0,
459  .spiBitRate = 4000000,
460  .spiCsnGpioIndex = CC1310_LAUNCHXL_GPIO_SPI_FLASH_CS,
461  },
462 };
463 
464 #endif /* TI_NVS_CONF_NVS_EXTERNAL_ENABLE */
465 
466 /* NVS Region index 0 and 1 refer to NVS and NVS SPI respectively */
467 const NVS_Config NVS_config[CC1310_LAUNCHXL_NVSCOUNT] = {
468 #if TI_NVS_CONF_NVS_INTERNAL_ENABLE
469  {
470  .fxnTablePtr = &NVSCC26XX_fxnTable,
471  .object = &nvsCC26xxObjects[0],
472  .hwAttrs = &nvsCC26xxHWAttrs[0],
473  },
474 #endif
475 #if TI_NVS_CONF_NVS_EXTERNAL_ENABLE
476  {
477  .fxnTablePtr = &NVSSPI25X_fxnTable,
478  .object = &nvsSPI25XObjects[0],
479  .hwAttrs = &nvsSPI25XHWAttrs[0],
480  },
481 #endif
482 };
483 
484 const uint_least8_t NVS_count = CC1310_LAUNCHXL_NVSCOUNT;
485 
486 #endif /* TI_NVS_CONF_ENABLE */
487 
488 /*
489  * =============================== PIN ===============================
490  */
491 #include <ti/drivers/PIN.h>
492 #include <ti/drivers/pin/PINCC26XX.h>
493 
494 const PIN_Config BoardGpioInitTable[] = {
495 
496  CC1310_LAUNCHXL_PIN_RLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* LED initially off */
497  CC1310_LAUNCHXL_PIN_GLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* LED initially off */
498  CC1310_LAUNCHXL_PIN_BTN1 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Button is active low */
499  CC1310_LAUNCHXL_PIN_BTN2 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Button is active low */
500  CC1310_LAUNCHXL_SPI_FLASH_CS | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MIN, /* External flash chip select */
501  CC1310_LAUNCHXL_UART_RX | PIN_INPUT_EN | PIN_PULLDOWN, /* UART RX via debugger back channel */
502  CC1310_LAUNCHXL_UART_TX | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL, /* UART TX via debugger back channel */
503  CC1310_LAUNCHXL_SPI0_MOSI | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI master out - slave in */
504  CC1310_LAUNCHXL_SPI0_MISO | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI master in - slave out */
505  CC1310_LAUNCHXL_SPI0_CLK | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI clock */
506 
507  PIN_TERMINATE
508 };
509 
510 const PINCC26XX_HWAttrs PINCC26XX_hwAttrs = {
511  .intPriority = ~0,
512  .swiPriority = 0
513 };
514 
515 /*
516  * =============================== Power ===============================
517  */
518 #include <ti/drivers/Power.h>
519 #include <ti/drivers/power/PowerCC26XX.h>
520 
521 const PowerCC26XX_Config PowerCC26XX_config = {
522  .policyInitFxn = NULL,
523  .policyFxn = &PowerCC26XX_standbyPolicy,
524  .calibrateFxn = &PowerCC26XX_calibrate,
525  .enablePolicy = true,
526  .calibrateRCOSC_LF = true,
527  .calibrateRCOSC_HF = true,
528 };
529 
530 /*
531  * =============================== PWM ===============================
532  * Remove unused entries to reduce flash usage both in Board.c and Board.h
533  */
534 #include <ti/drivers/PWM.h>
535 #include <ti/drivers/pwm/PWMTimerCC26XX.h>
536 
537 PWMTimerCC26XX_Object pwmtimerCC26xxObjects[CC1310_LAUNCHXL_PWMCOUNT];
538 
539 const PWMTimerCC26XX_HwAttrs pwmtimerCC26xxHWAttrs[CC1310_LAUNCHXL_PWMCOUNT] = {
540  { .pwmPin = CC1310_LAUNCHXL_PWMPIN0, .gpTimerUnit = CC1310_LAUNCHXL_GPTIMER0A },
541  { .pwmPin = CC1310_LAUNCHXL_PWMPIN1, .gpTimerUnit = CC1310_LAUNCHXL_GPTIMER0B },
542  { .pwmPin = CC1310_LAUNCHXL_PWMPIN2, .gpTimerUnit = CC1310_LAUNCHXL_GPTIMER1A },
543  { .pwmPin = CC1310_LAUNCHXL_PWMPIN3, .gpTimerUnit = CC1310_LAUNCHXL_GPTIMER1B },
544  { .pwmPin = CC1310_LAUNCHXL_PWMPIN4, .gpTimerUnit = CC1310_LAUNCHXL_GPTIMER2A },
545  { .pwmPin = CC1310_LAUNCHXL_PWMPIN5, .gpTimerUnit = CC1310_LAUNCHXL_GPTIMER2B },
546  { .pwmPin = CC1310_LAUNCHXL_PWMPIN6, .gpTimerUnit = CC1310_LAUNCHXL_GPTIMER3A },
547  { .pwmPin = CC1310_LAUNCHXL_PWMPIN7, .gpTimerUnit = CC1310_LAUNCHXL_GPTIMER3B },
548 };
549 
550 const PWM_Config PWM_config[CC1310_LAUNCHXL_PWMCOUNT] = {
551  { &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[CC1310_LAUNCHXL_PWM0], &pwmtimerCC26xxHWAttrs[CC1310_LAUNCHXL_PWM0] },
552  { &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[CC1310_LAUNCHXL_PWM1], &pwmtimerCC26xxHWAttrs[CC1310_LAUNCHXL_PWM1] },
553  { &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[CC1310_LAUNCHXL_PWM2], &pwmtimerCC26xxHWAttrs[CC1310_LAUNCHXL_PWM2] },
554  { &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[CC1310_LAUNCHXL_PWM3], &pwmtimerCC26xxHWAttrs[CC1310_LAUNCHXL_PWM3] },
555  { &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[CC1310_LAUNCHXL_PWM4], &pwmtimerCC26xxHWAttrs[CC1310_LAUNCHXL_PWM4] },
556  { &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[CC1310_LAUNCHXL_PWM5], &pwmtimerCC26xxHWAttrs[CC1310_LAUNCHXL_PWM5] },
557  { &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[CC1310_LAUNCHXL_PWM6], &pwmtimerCC26xxHWAttrs[CC1310_LAUNCHXL_PWM6] },
558  { &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[CC1310_LAUNCHXL_PWM7], &pwmtimerCC26xxHWAttrs[CC1310_LAUNCHXL_PWM7] },
559 };
560 
561 const uint_least8_t PWM_count = CC1310_LAUNCHXL_PWMCOUNT;
562 
563 /*
564  * =============================== RF Driver ===============================
565  */
566 #include <ti/drivers/rf/RF.h>
567 
568 const RFCC26XX_HWAttrsV2 RFCC26XX_hwAttrs = {
569  .hwiPriority = ~0, /* Lowest HWI priority */
570  .swiPriority = 0, /* Lowest SWI priority */
571  .xoscHfAlwaysNeeded = true, /* Keep XOSC dependency while in stanby */
572  .globalCallback = NULL, /* No board specific callback */
573  .globalEventMask = 0 /* No events subscribed to */
574 };
575 
576 /*
577  * =============================== SD ===============================
578  */
579 #include <ti/drivers/SD.h>
580 #include <ti/drivers/sd/SDSPI.h>
581 
582 #if TI_SD_CONF_ENABLE
583 
584 #if !(TI_SPI_CONF_SPI0_ENABLE)
585 #error "SD driver requires SPI0 enabled"
586 #endif
587 
588 SDSPI_Object sdspiObjects[CC1310_LAUNCHXL_SDCOUNT];
589 
590 const SDSPI_HWAttrs sdspiHWAttrs[CC1310_LAUNCHXL_SDCOUNT] = {
591  {
592  .spiIndex = CC1310_LAUNCHXL_SPI0,
593  .spiCsGpioIndex = CC1310_LAUNCHXL_SDSPI_CS
594  }
595 };
596 
597 const SD_Config SD_config[CC1310_LAUNCHXL_SDCOUNT] = {
598  {
599  .fxnTablePtr = &SDSPI_fxnTable,
600  .object = &sdspiObjects[CC1310_LAUNCHXL_SDSPI0],
601  .hwAttrs = &sdspiHWAttrs[CC1310_LAUNCHXL_SDSPI0]
602  },
603 };
604 
605 const uint_least8_t SD_count = CC1310_LAUNCHXL_SDCOUNT;
606 
607 #endif /* TI_SD_CONF_ENABLE */
608 
609 /*
610  * =============================== SPI DMA ===============================
611  */
612 #include <ti/drivers/SPI.h>
613 #include <ti/drivers/spi/SPICC26XXDMA.h>
614 
615 #if TI_SPI_CONF_ENABLE
616 
617 SPICC26XXDMA_Object spiCC26XXDMAObjects[CC1310_LAUNCHXL_SPICOUNT];
618 
619 /*
620  * NOTE: The SPI instances below can be used by the SD driver to communicate
621  * with a SD card via SPI. The 'defaultTxBufValue' fields below are set to 0xFF
622  * to satisfy the SDSPI driver requirement.
623  */
624 const SPICC26XXDMA_HWAttrsV1 spiCC26XXDMAHWAttrs[CC1310_LAUNCHXL_SPICOUNT] = {
625 #if TI_SPI_CONF_SPI0_ENABLE
626  {
627  .baseAddr = SSI0_BASE,
628  .intNum = INT_SSI0_COMB,
629  .intPriority = ~0,
630  .swiPriority = 0,
631  .powerMngrId = PowerCC26XX_PERIPH_SSI0,
632  .defaultTxBufValue = 0xFF,
633  .rxChannelBitMask = 1<<UDMA_CHAN_SSI0_RX,
634  .txChannelBitMask = 1<<UDMA_CHAN_SSI0_TX,
635  .mosiPin = CC1310_LAUNCHXL_SPI0_MOSI,
636  .misoPin = CC1310_LAUNCHXL_SPI0_MISO,
637  .clkPin = CC1310_LAUNCHXL_SPI0_CLK,
638  .csnPin = CC1310_LAUNCHXL_SPI0_CSN,
639  .minDmaTransferSize = 10
640  },
641 #endif
642 #if TI_SPI_CONF_SPI1_ENABLE
643  {
644  .baseAddr = SSI1_BASE,
645  .intNum = INT_SSI1_COMB,
646  .intPriority = ~0,
647  .swiPriority = 0,
648  .powerMngrId = PowerCC26XX_PERIPH_SSI1,
649  .defaultTxBufValue = 0xFF,
650  .rxChannelBitMask = 1<<UDMA_CHAN_SSI1_RX,
651  .txChannelBitMask = 1<<UDMA_CHAN_SSI1_TX,
652  .mosiPin = CC1310_LAUNCHXL_SPI1_MOSI,
653  .misoPin = CC1310_LAUNCHXL_SPI1_MISO,
654  .clkPin = CC1310_LAUNCHXL_SPI1_CLK,
655  .csnPin = CC1310_LAUNCHXL_SPI1_CSN,
656  .minDmaTransferSize = 10
657  },
658 #endif
659 };
660 
661 const SPI_Config SPI_config[CC1310_LAUNCHXL_SPICOUNT] = {
662 #if TI_SPI_CONF_SPI0_ENABLE
663  {
664  .fxnTablePtr = &SPICC26XXDMA_fxnTable,
665  .object = &spiCC26XXDMAObjects[CC1310_LAUNCHXL_SPI0],
666  .hwAttrs = &spiCC26XXDMAHWAttrs[CC1310_LAUNCHXL_SPI0]
667  },
668 #endif
669 #if TI_SPI_CONF_SPI1_ENABLE
670  {
671  .fxnTablePtr = &SPICC26XXDMA_fxnTable,
672  .object = &spiCC26XXDMAObjects[CC1310_LAUNCHXL_SPI1],
673  .hwAttrs = &spiCC26XXDMAHWAttrs[CC1310_LAUNCHXL_SPI1]
674  },
675 #endif
676 };
677 
678 const uint_least8_t SPI_count = CC1310_LAUNCHXL_SPICOUNT;
679 
680 #endif /* TI_SPI_CONF_ENABLE */
681 
682 
683 /*
684  * =============================== TRNG ===============================
685  */
686 #include <ti/drivers/TRNG.h>
687 #include <ti/drivers/trng/TRNGCC26X0.h>
688 
689 TRNGCC26X0_Object trngCC26X0Object[CC1310_LAUNCHXL_TRNGCOUNT];
690 
691 const TRNGCC26X0_HWAttrs trngCC26X0HWAttrs[CC1310_LAUNCHXL_TRNGCOUNT] = {
692  {
693  .swiPriority = 0,
694  .intPriority = ~0,
695  }
696 };
697 
698 const TRNG_Config TRNG_config[] = {
699  { &trngCC26X0Object[0], &trngCC26X0HWAttrs[0] },
700 };
701 
702 const uint8_t TRNG_count = CC1310_LAUNCHXL_TRNGCOUNT;
703 
704 
705 /*
706  * =============================== UART ===============================
707  */
708 #include <ti/drivers/UART.h>
709 #include <ti/drivers/uart/UARTCC26XX.h>
710 
711 #if TI_UART_CONF_ENABLE
712 
713 UARTCC26XX_Object uartCC26XXObjects[CC1310_LAUNCHXL_UARTCOUNT];
714 
715 uint8_t uartCC26XXRingBuffer[CC1310_LAUNCHXL_UARTCOUNT][32];
716 
717 const UARTCC26XX_HWAttrsV2 uartCC26XXHWAttrs[CC1310_LAUNCHXL_UARTCOUNT] = {
718 #if TI_UART_CONF_UART0_ENABLE
719  {
720  .baseAddr = UART0_BASE,
721  .powerMngrId = PowerCC26XX_PERIPH_UART0,
722  .intNum = INT_UART0_COMB,
723  .intPriority = ~0,
724  .swiPriority = 0,
725  .txPin = CC1310_LAUNCHXL_UART_TX,
726  .rxPin = CC1310_LAUNCHXL_UART_RX,
727  .ctsPin = PIN_UNASSIGNED,
728  .rtsPin = PIN_UNASSIGNED,
729  .ringBufPtr = uartCC26XXRingBuffer[CC1310_LAUNCHXL_UART0],
730  .ringBufSize = sizeof(uartCC26XXRingBuffer[CC1310_LAUNCHXL_UART0]),
731  .txIntFifoThr = UARTCC26XX_FIFO_THRESHOLD_1_8,
732  .rxIntFifoThr = UARTCC26XX_FIFO_THRESHOLD_4_8,
733  .errorFxn = NULL
734  },
735 #endif
736 };
737 
738 const UART_Config UART_config[CC1310_LAUNCHXL_UARTCOUNT] = {
739 #if TI_UART_CONF_UART0_ENABLE
740  {
741  .fxnTablePtr = &UARTCC26XX_fxnTable,
742  .object = &uartCC26XXObjects[CC1310_LAUNCHXL_UART0],
743  .hwAttrs = &uartCC26XXHWAttrs[CC1310_LAUNCHXL_UART0]
744  },
745 #endif
746 };
747 
748 const uint_least8_t UART_count = CC1310_LAUNCHXL_UARTCOUNT;
749 
750 #endif /* TI_UART_CONF_ENABLE */
751 
752 /*
753  * =============================== UDMA ===============================
754  */
755 #include <ti/drivers/dma/UDMACC26XX.h>
756 
757 UDMACC26XX_Object udmaObjects[CC1310_LAUNCHXL_UDMACOUNT];
758 
759 const UDMACC26XX_HWAttrs udmaHWAttrs[CC1310_LAUNCHXL_UDMACOUNT] = {
760  {
761  .baseAddr = UDMA0_BASE,
762  .powerMngrId = PowerCC26XX_PERIPH_UDMA,
763  .intNum = INT_DMA_ERR,
764  .intPriority = ~0
765  }
766 };
767 
768 const UDMACC26XX_Config UDMACC26XX_config[CC1310_LAUNCHXL_UDMACOUNT] = {
769  {
770  .object = &udmaObjects[CC1310_LAUNCHXL_UDMA0],
771  .hwAttrs = &udmaHWAttrs[CC1310_LAUNCHXL_UDMA0]
772  },
773 };
774 
775 /*
776  * =============================== Watchdog ===============================
777  */
778 #include <ti/drivers/Watchdog.h>
779 #include <ti/drivers/watchdog/WatchdogCC26XX.h>
780 
781 WatchdogCC26XX_Object watchdogCC26XXObjects[CC1310_LAUNCHXL_WATCHDOGCOUNT];
782 
783 const WatchdogCC26XX_HWAttrs watchdogCC26XXHWAttrs[CC1310_LAUNCHXL_WATCHDOGCOUNT] = {
784  {
785  .baseAddr = WDT_BASE,
786  .reloadValue = 1000 /* Reload value in milliseconds */
787  },
788 };
789 
790 const Watchdog_Config Watchdog_config[CC1310_LAUNCHXL_WATCHDOGCOUNT] = {
791  {
792  .fxnTablePtr = &WatchdogCC26XX_fxnTable,
793  .object = &watchdogCC26XXObjects[CC1310_LAUNCHXL_WATCHDOG0],
794  .hwAttrs = &watchdogCC26XXHWAttrs[CC1310_LAUNCHXL_WATCHDOG0]
795  },
796 };
797 
798 const uint_least8_t Watchdog_count = CC1310_LAUNCHXL_WATCHDOGCOUNT;
799 
800 /*
801  * Board-specific initialization function to disable external flash.
802  * This function is defined in the file CC1310_LAUNCHXL_fxns.c
803  */
804 extern void Board_initHook(void);
805 
806 /*
807  * ======== CC1310_LAUNCHXL_initGeneral ========
808  */
810 {
811  Power_init();
812 
813  if (PIN_init(BoardGpioInitTable) != PIN_SUCCESS) {
814  /* Error with PIN_init */
815  while (1);
816  }
817 
818  /* Perform board-specific initialization */
819  Board_initHook();
820 }
void CC1310_LAUNCHXL_initGeneral(void)
Initialize the general board specific settings.
#define SSI1_BASE
Base address for SSI1.
Definition: ssi.h:59
#define SSI0_BASE
Base address for SSI0.
Definition: ssi.h:58
============================================================================