Contiki-NG
CC2650_LAUNCHXL.c
1 /*
2  * Copyright (c) 2016-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  * ====================== CC2650_LAUNCHXL.c ===================================
35  * This file is responsible for setting up the board specific items for the
36  * CC2650_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 "CC2650_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[CC2650_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[CC2650_LAUNCHXL_ADCBUF0CHANNELCOUNT] = {
67  {CC2650_LAUNCHXL_DIO23_ANALOG, ADC_COMPB_IN_AUXIO7},
68  {CC2650_LAUNCHXL_DIO24_ANALOG, ADC_COMPB_IN_AUXIO6},
69  {CC2650_LAUNCHXL_DIO25_ANALOG, ADC_COMPB_IN_AUXIO5},
70  {CC2650_LAUNCHXL_DIO26_ANALOG, ADC_COMPB_IN_AUXIO4},
71  {CC2650_LAUNCHXL_DIO27_ANALOG, ADC_COMPB_IN_AUXIO3},
72  {CC2650_LAUNCHXL_DIO28_ANALOG, ADC_COMPB_IN_AUXIO2},
73  {CC2650_LAUNCHXL_DIO29_ANALOG, ADC_COMPB_IN_AUXIO1},
74  {CC2650_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[CC2650_LAUNCHXL_ADCBUFCOUNT] = {
81  {
82  .intPriority = ~0,
83  .swiPriority = 0,
84  .adcChannelLut = ADCBufCC26XX_adcChannelLut,
85  .gpTimerUnit = CC2650_LAUNCHXL_GPTIMER0A,
86  .gptDMAChannelMask = 1 << UDMA_CHAN_TIMER0_A,
87  }
88 };
89 
90 const ADCBuf_Config ADCBuf_config[CC2650_LAUNCHXL_ADCBUFCOUNT] = {
91  {
92  &ADCBufCC26XX_fxnTable,
93  &adcBufCC26xxObjects[CC2650_LAUNCHXL_ADCBUF0],
94  &adcBufCC26xxHWAttrs[CC2650_LAUNCHXL_ADCBUF0]
95  },
96 };
97 
98 const uint_least8_t ADCBuf_count = CC2650_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[CC2650_LAUNCHXL_ADCCOUNT];
107 
108 const ADCCC26XX_HWAttrs adcCC26xxHWAttrs[CC2650_LAUNCHXL_ADCCOUNT] = {
109  {
110  .adcDIO = CC2650_LAUNCHXL_DIO23_ANALOG,
111  .adcCompBInput = ADC_COMPB_IN_AUXIO7,
112  .refSource = ADCCC26XX_FIXED_REFERENCE,
113  .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
114  .inputScalingEnabled = true,
115  .triggerSource = ADCCC26XX_TRIGGER_MANUAL,
116  .returnAdjustedVal = false
117  },
118  {
119  .adcDIO = CC2650_LAUNCHXL_DIO24_ANALOG,
120  .adcCompBInput = ADC_COMPB_IN_AUXIO6,
121  .refSource = ADCCC26XX_FIXED_REFERENCE,
122  .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
123  .inputScalingEnabled = true,
124  .triggerSource = ADCCC26XX_TRIGGER_MANUAL,
125  .returnAdjustedVal = false
126  },
127  {
128  .adcDIO = CC2650_LAUNCHXL_DIO25_ANALOG,
129  .adcCompBInput = ADC_COMPB_IN_AUXIO5,
130  .refSource = ADCCC26XX_FIXED_REFERENCE,
131  .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
132  .inputScalingEnabled = true,
133  .triggerSource = ADCCC26XX_TRIGGER_MANUAL,
134  .returnAdjustedVal = false
135  },
136  {
137  .adcDIO = CC2650_LAUNCHXL_DIO26_ANALOG,
138  .adcCompBInput = ADC_COMPB_IN_AUXIO4,
139  .refSource = ADCCC26XX_FIXED_REFERENCE,
140  .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
141  .inputScalingEnabled = true,
142  .triggerSource = ADCCC26XX_TRIGGER_MANUAL,
143  .returnAdjustedVal = false
144  },
145  {
146  .adcDIO = CC2650_LAUNCHXL_DIO27_ANALOG,
147  .adcCompBInput = ADC_COMPB_IN_AUXIO3,
148  .refSource = ADCCC26XX_FIXED_REFERENCE,
149  .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
150  .inputScalingEnabled = true,
151  .triggerSource = ADCCC26XX_TRIGGER_MANUAL,
152  .returnAdjustedVal = false
153  },
154  {
155  .adcDIO = CC2650_LAUNCHXL_DIO28_ANALOG,
156  .adcCompBInput = ADC_COMPB_IN_AUXIO2,
157  .refSource = ADCCC26XX_FIXED_REFERENCE,
158  .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
159  .inputScalingEnabled = true,
160  .triggerSource = ADCCC26XX_TRIGGER_MANUAL,
161  .returnAdjustedVal = false
162  },
163  {
164  .adcDIO = CC2650_LAUNCHXL_DIO29_ANALOG,
165  .adcCompBInput = ADC_COMPB_IN_AUXIO1,
166  .refSource = ADCCC26XX_FIXED_REFERENCE,
167  .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
168  .inputScalingEnabled = true,
169  .triggerSource = ADCCC26XX_TRIGGER_MANUAL,
170  .returnAdjustedVal = false
171  },
172  {
173  .adcDIO = CC2650_LAUNCHXL_DIO30_ANALOG,
174  .adcCompBInput = ADC_COMPB_IN_AUXIO0,
175  .refSource = ADCCC26XX_FIXED_REFERENCE,
176  .samplingDuration = ADCCC26XX_SAMPLING_DURATION_10P9_MS,
177  .inputScalingEnabled = true,
178  .triggerSource = ADCCC26XX_TRIGGER_MANUAL,
179  .returnAdjustedVal = false
180  },
181  {
182  .adcDIO = PIN_UNASSIGNED,
183  .adcCompBInput = ADC_COMPB_IN_DCOUPL,
184  .refSource = ADCCC26XX_FIXED_REFERENCE,
185  .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
186  .inputScalingEnabled = true,
187  .triggerSource = ADCCC26XX_TRIGGER_MANUAL,
188  .returnAdjustedVal = false
189  },
190  {
191  .adcDIO = PIN_UNASSIGNED,
192  .adcCompBInput = ADC_COMPB_IN_VSS,
193  .refSource = ADCCC26XX_FIXED_REFERENCE,
194  .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
195  .inputScalingEnabled = true,
196  .triggerSource = ADCCC26XX_TRIGGER_MANUAL,
197  .returnAdjustedVal = false
198  },
199  {
200  .adcDIO = PIN_UNASSIGNED,
201  .adcCompBInput = ADC_COMPB_IN_VDDS,
202  .refSource = ADCCC26XX_FIXED_REFERENCE,
203  .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
204  .inputScalingEnabled = true,
205  .triggerSource = ADCCC26XX_TRIGGER_MANUAL,
206  .returnAdjustedVal = false
207  }
208 };
209 
210 const ADC_Config ADC_config[CC2650_LAUNCHXL_ADCCOUNT] = {
211  {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC2650_LAUNCHXL_ADC0], &adcCC26xxHWAttrs[CC2650_LAUNCHXL_ADC0]},
212  {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC2650_LAUNCHXL_ADC1], &adcCC26xxHWAttrs[CC2650_LAUNCHXL_ADC1]},
213  {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC2650_LAUNCHXL_ADC2], &adcCC26xxHWAttrs[CC2650_LAUNCHXL_ADC2]},
214  {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC2650_LAUNCHXL_ADC3], &adcCC26xxHWAttrs[CC2650_LAUNCHXL_ADC3]},
215  {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC2650_LAUNCHXL_ADC4], &adcCC26xxHWAttrs[CC2650_LAUNCHXL_ADC4]},
216  {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC2650_LAUNCHXL_ADC5], &adcCC26xxHWAttrs[CC2650_LAUNCHXL_ADC5]},
217  {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC2650_LAUNCHXL_ADC6], &adcCC26xxHWAttrs[CC2650_LAUNCHXL_ADC6]},
218  {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC2650_LAUNCHXL_ADC7], &adcCC26xxHWAttrs[CC2650_LAUNCHXL_ADC7]},
219  {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC2650_LAUNCHXL_ADCDCOUPL], &adcCC26xxHWAttrs[CC2650_LAUNCHXL_ADCDCOUPL]},
220  {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC2650_LAUNCHXL_ADCVSS], &adcCC26xxHWAttrs[CC2650_LAUNCHXL_ADCVSS]},
221  {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC2650_LAUNCHXL_ADCVDDS], &adcCC26xxHWAttrs[CC2650_LAUNCHXL_ADCVDDS]},
222 };
223 
224 const uint_least8_t ADC_count = CC2650_LAUNCHXL_ADCCOUNT;
225 
226 /*
227  * =============================== Crypto ===============================
228  */
229 #include <ti/drivers/crypto/CryptoCC26XX.h>
230 
231 CryptoCC26XX_Object cryptoCC26XXObjects[CC2650_LAUNCHXL_CRYPTOCOUNT];
232 
233 const CryptoCC26XX_HWAttrs cryptoCC26XXHWAttrs[CC2650_LAUNCHXL_CRYPTOCOUNT] = {
234  {
235  .baseAddr = CRYPTO_BASE,
236  .powerMngrId = PowerCC26XX_PERIPH_CRYPTO,
237  .intNum = INT_CRYPTO_RESULT_AVAIL_IRQ,
238  .intPriority = ~0,
239  }
240 };
241 
242 const CryptoCC26XX_Config CryptoCC26XX_config[CC2650_LAUNCHXL_CRYPTOCOUNT] = {
243  {
244  .object = &cryptoCC26XXObjects[CC2650_LAUNCHXL_CRYPTO0],
245  .hwAttrs = &cryptoCC26XXHWAttrs[CC2650_LAUNCHXL_CRYPTO0]
246  },
247 };
248 
249 /*
250  * =============================== GPIO ===============================
251  */
252 #include <ti/drivers/GPIO.h>
253 #include <ti/drivers/gpio/GPIOCC26XX.h>
254 
255 /*
256  * Array of Pin configurations
257  * NOTE: The order of the pin configurations must coincide with what was
258  * defined in CC2650_LAUNCHXL.h
259  * NOTE: Pins not used for interrupts should be placed at the end of the
260  * array. Callback entries can be omitted from callbacks array to
261  * reduce memory usage.
262  */
263 GPIO_PinConfig gpioPinConfigs[] = {
264  /* Input pins */
265  GPIOCC26XX_DIO_13 | GPIO_DO_NOT_CONFIG, /* Button 0 */
266  GPIOCC26XX_DIO_14 | GPIO_DO_NOT_CONFIG, /* Button 1 */
267 
268  GPIOCC26XX_DIO_15 | GPIO_DO_NOT_CONFIG, /* CC2650_LAUNCHXL_SPI_MASTER_READY */
269  GPIOCC26XX_DIO_21 | GPIO_DO_NOT_CONFIG, /* CC2650_LAUNCHXL_SPI_SLAVE_READY */
270 
271  /* Output pins */
272  GPIOCC26XX_DIO_07 | GPIO_DO_NOT_CONFIG, /* Green LED */
273  GPIOCC26XX_DIO_06 | GPIO_DO_NOT_CONFIG, /* Red LED */
274 
275  /* SPI Flash CSN */
276  GPIOCC26XX_DIO_20 | GPIO_DO_NOT_CONFIG,
277 
278  /* SD CS */
279  GPIOCC26XX_DIO_21 | GPIO_DO_NOT_CONFIG,
280 };
281 
282 /*
283  * Array of callback function pointers
284  * NOTE: The order of the pin configurations must coincide with what was
285  * defined in CC2650_LAUNCH.h
286  * NOTE: Pins not used for interrupts can be omitted from callbacks array to
287  * reduce memory usage (if placed at end of gpioPinConfigs array).
288  */
289 GPIO_CallbackFxn gpioCallbackFunctions[] = {
290  NULL, /* Button 0 */
291  NULL, /* Button 1 */
292  NULL, /* CC2650_LAUNCHXL_SPI_MASTER_READY */
293  NULL, /* CC2650_LAUNCHXL_SPI_SLAVE_READY */
294 };
295 
296 const GPIOCC26XX_Config GPIOCC26XX_config = {
297  .pinConfigs = (GPIO_PinConfig *)gpioPinConfigs,
298  .callbacks = (GPIO_CallbackFxn *)gpioCallbackFunctions,
299  .numberOfPinConfigs = CC2650_LAUNCHXL_GPIOCOUNT,
300  .numberOfCallbacks = sizeof(gpioCallbackFunctions)/sizeof(GPIO_CallbackFxn),
301  .intPriority = (~0)
302 };
303 
304 /*
305  * =============================== GPTimer ===============================
306  * Remove unused entries to reduce flash usage both in Board.c and Board.h
307  */
308 #include <ti/drivers/timer/GPTimerCC26XX.h>
309 
310 GPTimerCC26XX_Object gptimerCC26XXObjects[CC2650_LAUNCHXL_GPTIMERCOUNT];
311 
312 const GPTimerCC26XX_HWAttrs gptimerCC26xxHWAttrs[CC2650_LAUNCHXL_GPTIMERPARTSCOUNT] = {
313  { .baseAddr = GPT0_BASE, .intNum = INT_GPT0A, .intPriority = (~0), .powerMngrId = PowerCC26XX_PERIPH_GPT0, .pinMux = GPT_PIN_0A, },
314  { .baseAddr = GPT0_BASE, .intNum = INT_GPT0B, .intPriority = (~0), .powerMngrId = PowerCC26XX_PERIPH_GPT0, .pinMux = GPT_PIN_0B, },
315  { .baseAddr = GPT1_BASE, .intNum = INT_GPT1A, .intPriority = (~0), .powerMngrId = PowerCC26XX_PERIPH_GPT1, .pinMux = GPT_PIN_1A, },
316  { .baseAddr = GPT1_BASE, .intNum = INT_GPT1B, .intPriority = (~0), .powerMngrId = PowerCC26XX_PERIPH_GPT1, .pinMux = GPT_PIN_1B, },
317  { .baseAddr = GPT2_BASE, .intNum = INT_GPT2A, .intPriority = (~0), .powerMngrId = PowerCC26XX_PERIPH_GPT2, .pinMux = GPT_PIN_2A, },
318  { .baseAddr = GPT2_BASE, .intNum = INT_GPT2B, .intPriority = (~0), .powerMngrId = PowerCC26XX_PERIPH_GPT2, .pinMux = GPT_PIN_2B, },
319  { .baseAddr = GPT3_BASE, .intNum = INT_GPT3A, .intPriority = (~0), .powerMngrId = PowerCC26XX_PERIPH_GPT3, .pinMux = GPT_PIN_3A, },
320  { .baseAddr = GPT3_BASE, .intNum = INT_GPT3B, .intPriority = (~0), .powerMngrId = PowerCC26XX_PERIPH_GPT3, .pinMux = GPT_PIN_3B, },
321 };
322 
323 const GPTimerCC26XX_Config GPTimerCC26XX_config[CC2650_LAUNCHXL_GPTIMERPARTSCOUNT] = {
324  { &gptimerCC26XXObjects[CC2650_LAUNCHXL_GPTIMER0], &gptimerCC26xxHWAttrs[CC2650_LAUNCHXL_GPTIMER0A], GPT_A },
325  { &gptimerCC26XXObjects[CC2650_LAUNCHXL_GPTIMER0], &gptimerCC26xxHWAttrs[CC2650_LAUNCHXL_GPTIMER0B], GPT_B },
326  { &gptimerCC26XXObjects[CC2650_LAUNCHXL_GPTIMER1], &gptimerCC26xxHWAttrs[CC2650_LAUNCHXL_GPTIMER1A], GPT_A },
327  { &gptimerCC26XXObjects[CC2650_LAUNCHXL_GPTIMER1], &gptimerCC26xxHWAttrs[CC2650_LAUNCHXL_GPTIMER1B], GPT_B },
328  { &gptimerCC26XXObjects[CC2650_LAUNCHXL_GPTIMER2], &gptimerCC26xxHWAttrs[CC2650_LAUNCHXL_GPTIMER2A], GPT_A },
329  { &gptimerCC26XXObjects[CC2650_LAUNCHXL_GPTIMER2], &gptimerCC26xxHWAttrs[CC2650_LAUNCHXL_GPTIMER2B], GPT_B },
330  { &gptimerCC26XXObjects[CC2650_LAUNCHXL_GPTIMER3], &gptimerCC26xxHWAttrs[CC2650_LAUNCHXL_GPTIMER3A], GPT_A },
331  { &gptimerCC26XXObjects[CC2650_LAUNCHXL_GPTIMER3], &gptimerCC26xxHWAttrs[CC2650_LAUNCHXL_GPTIMER3B], GPT_B },
332 };
333 
334 /*
335  * =============================== I2C ===============================
336 */
337 #include <ti/drivers/I2C.h>
338 #include <ti/drivers/i2c/I2CCC26XX.h>
339 
340 #if TI_I2C_CONF_ENABLE
341 
342 I2CCC26XX_Object i2cCC26xxObjects[CC2650_LAUNCHXL_I2CCOUNT];
343 
344 const I2CCC26XX_HWAttrsV1 i2cCC26xxHWAttrs[CC2650_LAUNCHXL_I2CCOUNT] = {
345 #if TI_I2C_CONF_I2C0_ENABLE
346  {
347  .baseAddr = I2C0_BASE,
348  .powerMngrId = PowerCC26XX_PERIPH_I2C0,
349  .intNum = INT_I2C_IRQ,
350  .intPriority = ~0,
351  .swiPriority = 0,
352  .sdaPin = CC2650_LAUNCHXL_I2C0_SDA0,
353  .sclPin = CC2650_LAUNCHXL_I2C0_SCL0,
354  },
355 #endif
356 };
357 
358 const I2C_Config I2C_config[CC2650_LAUNCHXL_I2CCOUNT] = {
359 #if TI_I2C_CONF_I2C0_ENABLE
360  {
361  .fxnTablePtr = &I2CCC26XX_fxnTable,
362  .object = &i2cCC26xxObjects[CC2650_LAUNCHXL_I2C0],
363  .hwAttrs = &i2cCC26xxHWAttrs[CC2650_LAUNCHXL_I2C0]
364  },
365 #endif
366 };
367 
368 const uint_least8_t I2C_count = CC2650_LAUNCHXL_I2CCOUNT;
369 
370 #endif /* TI_I2C_CONF_ENABLE */
371 
372 /*
373  * =============================== NVS ===============================
374  */
375 #include <ti/drivers/NVS.h>
376 #include <ti/drivers/nvs/NVSSPI25X.h>
377 #include <ti/drivers/nvs/NVSCC26XX.h>
378 
379 #define NVS_REGIONS_BASE 0x1A000
380 #define SECTORSIZE 0x1000
381 #define REGIONSIZE (SECTORSIZE * 4)
382 
383 #if TI_NVS_CONF_ENABLE
384 
385 #if TI_NVS_CONF_NVS_INTERNAL_ENABLE
386 
387 /*
388  * Reserve flash sectors for NVS driver use by placing an uninitialized byte
389  * array at the desired flash address.
390  */
391 #if defined(__TI_COMPILER_VERSION__)
392 
393 /*
394  * Place uninitialized array at NVS_REGIONS_BASE
395  */
396 #pragma LOCATION(flashBuf, NVS_REGIONS_BASE);
397 #pragma NOINIT(flashBuf);
398 static char flashBuf[REGIONSIZE];
399 
400 #elif defined(__IAR_SYSTEMS_ICC__)
401 
402 /*
403  * Place uninitialized array at NVS_REGIONS_BASE
404  */
405 static __no_init char flashBuf[REGIONSIZE] @ NVS_REGIONS_BASE;
406 
407 #elif defined(__GNUC__)
408 
409 /*
410  * Place the flash buffers in the .nvs section created in the gcc linker file.
411  * The .nvs section enforces alignment on a sector boundary but may
412  * be placed anywhere in flash memory. If desired the .nvs section can be set
413  * to a fixed address by changing the following in the gcc linker file:
414  *
415  * .nvs (FIXED_FLASH_ADDR) (NOLOAD) : AT (FIXED_FLASH_ADDR) {
416  * *(.nvs)
417  * } > REGION_TEXT
418  */
419 __attribute__ ((section (".nvs")))
420 static char flashBuf[REGIONSIZE];
421 
422 #endif
423 
424 /* Allocate objects for NVS Internal Regions */
425 NVSCC26XX_Object nvsCC26xxObjects[1];
426 
427 /* Hardware attributes for NVS Internal Regions */
428 const NVSCC26XX_HWAttrs nvsCC26xxHWAttrs[1] = {
429  {
430  .regionBase = (void *)flashBuf,
431  .regionSize = REGIONSIZE,
432  },
433 };
434 
435 #endif /* TI_NVS_CONF_NVS_INTERNAL_ENABLE */
436 
437 #if TI_NVS_CONF_NVS_EXTERNAL_ENABLE
438 
439 #define SPISECTORSIZE 0x1000
440 #define SPIREGIONSIZE (SPISECTORSIZE * 32)
441 #define VERIFYBUFSIZE 64
442 
443 static uint8_t verifyBuf[VERIFYBUFSIZE];
444 
445 /* Allocate objects for NVS External Regions */
446 NVSSPI25X_Object nvsSPI25XObjects[1];
447 
448 /* Hardware attributes for NVS External Regions */
449 const NVSSPI25X_HWAttrs nvsSPI25XHWAttrs[1] = {
450  {
451  .regionBaseOffset = 0,
452  .regionSize = SPIREGIONSIZE,
453  .sectorSize = SPISECTORSIZE,
454  .verifyBuf = verifyBuf,
455  .verifyBufSize = VERIFYBUFSIZE,
456  .spiHandle = NULL,
457  .spiIndex = 0,
458  .spiBitRate = 4000000,
459  .spiCsnGpioIndex = CC2650_LAUNCHXL_GPIO_SPI_FLASH_CS,
460  },
461 };
462 
463 #endif /* Board_EXCLUDE_NVS_EXTERNAL_FLASH */
464 
465 /* NVS Region index 0 and 1 refer to NVS and NVS SPI respectively */
466 const NVS_Config NVS_config[CC2650_LAUNCHXL_NVSCOUNT] = {
467 #if TI_NVS_CONF_NVS_INTERNAL_ENABLE
468  {
469  .fxnTablePtr = &NVSCC26XX_fxnTable,
470  .object = &nvsCC26xxObjects[0],
471  .hwAttrs = &nvsCC26xxHWAttrs[0],
472  },
473 #endif
474 #if TI_NVS_CONF_NVS_EXTERNAL_ENABLE
475  {
476  .fxnTablePtr = &NVSSPI25X_fxnTable,
477  .object = &nvsSPI25XObjects[0],
478  .hwAttrs = &nvsSPI25XHWAttrs[0],
479  },
480 #endif
481 };
482 
483 const uint_least8_t NVS_count = CC2650_LAUNCHXL_NVSCOUNT;
484 
485 #endif /* TI_NVS_CONF_ENABLE */
486 
487 /*
488  * =============================== PIN ===============================
489  */
490 #include <ti/drivers/PIN.h>
491 #include <ti/drivers/pin/PINCC26XX.h>
492 
493 const PIN_Config BoardGpioInitTable[] = {
494 
495  CC2650_LAUNCHXL_PIN_RLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* LED initially off */
496  CC2650_LAUNCHXL_PIN_GLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* LED initially off */
497  CC2650_LAUNCHXL_PIN_BTN1 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Button is active low */
498  CC2650_LAUNCHXL_PIN_BTN2 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Button is active low */
499  CC2650_LAUNCHXL_SPI_FLASH_CS | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MIN, /* External flash chip select */
500  CC2650_LAUNCHXL_UART_RX | PIN_INPUT_EN | PIN_PULLDOWN, /* UART RX via debugger back channel */
501  CC2650_LAUNCHXL_UART_TX | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL, /* UART TX via debugger back channel */
502  CC2650_LAUNCHXL_SPI0_MOSI | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI master out - slave in */
503  CC2650_LAUNCHXL_SPI0_MISO | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI master in - slave out */
504  CC2650_LAUNCHXL_SPI0_CLK | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI clock */
505 
506  PIN_TERMINATE
507 };
508 
509 const PINCC26XX_HWAttrs PINCC26XX_hwAttrs = {
510  .intPriority = ~0,
511  .swiPriority = 0
512 };
513 
514 /*
515  * =============================== Power ===============================
516  */
517 #include <ti/drivers/Power.h>
518 #include <ti/drivers/power/PowerCC26XX.h>
519 
520 const PowerCC26XX_Config PowerCC26XX_config = {
521  .policyInitFxn = NULL,
522  .policyFxn = &PowerCC26XX_standbyPolicy,
523  .calibrateFxn = &PowerCC26XX_calibrate,
524  .enablePolicy = true,
525  .calibrateRCOSC_LF = true,
526  .calibrateRCOSC_HF = true,
527 };
528 
529 /*
530  * =============================== PWM ===============================
531  * Remove unused entries to reduce flash usage both in Board.c and Board.h
532  */
533 #include <ti/drivers/PWM.h>
534 #include <ti/drivers/pwm/PWMTimerCC26XX.h>
535 
536 PWMTimerCC26XX_Object pwmtimerCC26xxObjects[CC2650_LAUNCHXL_PWMCOUNT];
537 
538 const PWMTimerCC26XX_HwAttrs pwmtimerCC26xxHWAttrs[CC2650_LAUNCHXL_PWMCOUNT] = {
539  { .pwmPin = CC2650_LAUNCHXL_PWMPIN0, .gpTimerUnit = CC2650_LAUNCHXL_GPTIMER0A },
540  { .pwmPin = CC2650_LAUNCHXL_PWMPIN1, .gpTimerUnit = CC2650_LAUNCHXL_GPTIMER0B },
541  { .pwmPin = CC2650_LAUNCHXL_PWMPIN2, .gpTimerUnit = CC2650_LAUNCHXL_GPTIMER1A },
542  { .pwmPin = CC2650_LAUNCHXL_PWMPIN3, .gpTimerUnit = CC2650_LAUNCHXL_GPTIMER1B },
543  { .pwmPin = CC2650_LAUNCHXL_PWMPIN4, .gpTimerUnit = CC2650_LAUNCHXL_GPTIMER2A },
544  { .pwmPin = CC2650_LAUNCHXL_PWMPIN5, .gpTimerUnit = CC2650_LAUNCHXL_GPTIMER2B },
545  { .pwmPin = CC2650_LAUNCHXL_PWMPIN6, .gpTimerUnit = CC2650_LAUNCHXL_GPTIMER3A },
546  { .pwmPin = CC2650_LAUNCHXL_PWMPIN7, .gpTimerUnit = CC2650_LAUNCHXL_GPTIMER3B },
547 };
548 
549 const PWM_Config PWM_config[CC2650_LAUNCHXL_PWMCOUNT] = {
550  { &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[CC2650_LAUNCHXL_PWM0], &pwmtimerCC26xxHWAttrs[CC2650_LAUNCHXL_PWM0] },
551  { &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[CC2650_LAUNCHXL_PWM1], &pwmtimerCC26xxHWAttrs[CC2650_LAUNCHXL_PWM1] },
552  { &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[CC2650_LAUNCHXL_PWM2], &pwmtimerCC26xxHWAttrs[CC2650_LAUNCHXL_PWM2] },
553  { &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[CC2650_LAUNCHXL_PWM3], &pwmtimerCC26xxHWAttrs[CC2650_LAUNCHXL_PWM3] },
554  { &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[CC2650_LAUNCHXL_PWM4], &pwmtimerCC26xxHWAttrs[CC2650_LAUNCHXL_PWM4] },
555  { &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[CC2650_LAUNCHXL_PWM5], &pwmtimerCC26xxHWAttrs[CC2650_LAUNCHXL_PWM5] },
556  { &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[CC2650_LAUNCHXL_PWM6], &pwmtimerCC26xxHWAttrs[CC2650_LAUNCHXL_PWM6] },
557  { &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[CC2650_LAUNCHXL_PWM7], &pwmtimerCC26xxHWAttrs[CC2650_LAUNCHXL_PWM7] },
558 };
559 
560 const uint_least8_t PWM_count = CC2650_LAUNCHXL_PWMCOUNT;
561 
562 /*
563  * =============================== RF Driver ===============================
564  */
565 #include <ti/drivers/rf/RF.h>
566 
567 const RFCC26XX_HWAttrsV2 RFCC26XX_hwAttrs = {
568  .hwiPriority = ~0, /* Lowest HWI priority */
569  .swiPriority = 0, /* Lowest SWI priority */
570  .xoscHfAlwaysNeeded = true, /* Keep XOSC dependency while in stanby */
571  .globalCallback = NULL, /* No board specific callback */
572  .globalEventMask = 0 /* No events subscribed to */
573 };
574 
575 /*
576  * =============================== SD ===============================
577  */
578 #include <ti/drivers/SD.h>
579 #include <ti/drivers/sd/SDSPI.h>
580 
581 #if TI_SD_CONF_ENABLE
582 
583 #if !(TI_SPI_CONF_SPI0_ENABLE)
584 #error "SD driver requires SPI0 enabled"
585 #endif
586 
587 SDSPI_Object sdspiObjects[CC2650_LAUNCHXL_SDCOUNT];
588 
589 const SDSPI_HWAttrs sdspiHWAttrs[CC2650_LAUNCHXL_SDCOUNT] = {
590  {
591  .spiIndex = CC2650_LAUNCHXL_SPI0,
592  .spiCsGpioIndex = CC2650_LAUNCHXL_SDSPI_CS
593  }
594 };
595 
596 const SD_Config SD_config[CC2650_LAUNCHXL_SDCOUNT] = {
597  {
598  .fxnTablePtr = &SDSPI_fxnTable,
599  .object = &sdspiObjects[CC2650_LAUNCHXL_SDSPI0],
600  .hwAttrs = &sdspiHWAttrs[CC2650_LAUNCHXL_SDSPI0]
601  },
602 };
603 
604 const uint_least8_t SD_count = CC2650_LAUNCHXL_SDCOUNT;
605 
606 #endif /* TI_SD_CONF_ENABLE */
607 
608 /*
609  * =============================== SPI DMA ===============================
610  */
611 #include <ti/drivers/SPI.h>
612 #include <ti/drivers/spi/SPICC26XXDMA.h>
613 
614 #if TI_SPI_CONF_ENABLE
615 
616 SPICC26XXDMA_Object spiCC26XXDMAObjects[CC2650_LAUNCHXL_SPICOUNT];
617 
618 /*
619  * NOTE: The SPI instances below can be used by the SD driver to communicate
620  * with a SD card via SPI. The 'defaultTxBufValue' fields below are set to 0xFF
621  * to satisfy the SDSPI driver requirement.
622  */
623 const SPICC26XXDMA_HWAttrsV1 spiCC26XXDMAHWAttrs[CC2650_LAUNCHXL_SPICOUNT] = {
624 #if TI_SPI_CONF_SPI0_ENABLE
625  {
626  .baseAddr = SSI0_BASE,
627  .intNum = INT_SSI0_COMB,
628  .intPriority = ~0,
629  .swiPriority = 0,
630  .powerMngrId = PowerCC26XX_PERIPH_SSI0,
631  .defaultTxBufValue = 0xFF,
632  .rxChannelBitMask = 1<<UDMA_CHAN_SSI0_RX,
633  .txChannelBitMask = 1<<UDMA_CHAN_SSI0_TX,
634  .mosiPin = CC2650_LAUNCHXL_SPI0_MOSI,
635  .misoPin = CC2650_LAUNCHXL_SPI0_MISO,
636  .clkPin = CC2650_LAUNCHXL_SPI0_CLK,
637  .csnPin = CC2650_LAUNCHXL_SPI0_CSN,
638  .minDmaTransferSize = 10
639  },
640 #endif
641 #if TI_SPI_CONF_SPI1_ENABLE
642  {
643  .baseAddr = SSI1_BASE,
644  .intNum = INT_SSI1_COMB,
645  .intPriority = ~0,
646  .swiPriority = 0,
647  .powerMngrId = PowerCC26XX_PERIPH_SSI1,
648  .defaultTxBufValue = 0xFF,
649  .rxChannelBitMask = 1<<UDMA_CHAN_SSI1_RX,
650  .txChannelBitMask = 1<<UDMA_CHAN_SSI1_TX,
651  .mosiPin = CC2650_LAUNCHXL_SPI1_MOSI,
652  .misoPin = CC2650_LAUNCHXL_SPI1_MISO,
653  .clkPin = CC2650_LAUNCHXL_SPI1_CLK,
654  .csnPin = CC2650_LAUNCHXL_SPI1_CSN,
655  .minDmaTransferSize = 10
656  },
657 #endif
658 };
659 
660 const SPI_Config SPI_config[CC2650_LAUNCHXL_SPICOUNT] = {
661 #if TI_SPI_CONF_SPI0_ENABLE
662  {
663  .fxnTablePtr = &SPICC26XXDMA_fxnTable,
664  .object = &spiCC26XXDMAObjects[CC2650_LAUNCHXL_SPI0],
665  .hwAttrs = &spiCC26XXDMAHWAttrs[CC2650_LAUNCHXL_SPI0]
666  },
667 #endif
668 #if TI_SPI_CONF_SPI1_ENABLE
669  {
670  .fxnTablePtr = &SPICC26XXDMA_fxnTable,
671  .object = &spiCC26XXDMAObjects[CC2650_LAUNCHXL_SPI1],
672  .hwAttrs = &spiCC26XXDMAHWAttrs[CC2650_LAUNCHXL_SPI1]
673  },
674 #endif
675 };
676 
677 const uint_least8_t SPI_count = CC2650_LAUNCHXL_SPICOUNT;
678 
679 #endif /* TI_SPI_CONF_ENABLE */
680 
681 
682 /*
683  * =============================== TRNG ===============================
684  */
685 #include <ti/drivers/TRNG.h>
686 #include <ti/drivers/trng/TRNGCC26X0.h>
687 
688 TRNGCC26X0_Object trngCC26X0Object[CC2650_LAUNCHXL_TRNGCOUNT];
689 
690 const TRNGCC26X0_HWAttrs trngCC26X0HWAttrs[CC2650_LAUNCHXL_TRNGCOUNT] = {
691  {
692  .swiPriority = 0,
693  .intPriority = ~0,
694  }
695 };
696 
697 const TRNG_Config TRNG_config[] = {
698  { &trngCC26X0Object[0], &trngCC26X0HWAttrs[0] },
699 };
700 
701 const uint8_t TRNG_count = CC2650_LAUNCHXL_TRNGCOUNT;
702 
703 
704 /*
705  * =============================== UART ===============================
706  */
707 #include <ti/drivers/UART.h>
708 #include <ti/drivers/uart/UARTCC26XX.h>
709 
710 #if TI_UART_CONF_ENABLE
711 
712 UARTCC26XX_Object uartCC26XXObjects[CC2650_LAUNCHXL_UARTCOUNT];
713 
714 uint8_t uartCC26XXRingBuffer[CC2650_LAUNCHXL_UARTCOUNT][32];
715 
716 const UARTCC26XX_HWAttrsV2 uartCC26XXHWAttrs[CC2650_LAUNCHXL_UARTCOUNT] = {
717 #if TI_UART_CONF_UART0_ENABLE
718  {
719  .baseAddr = UART0_BASE,
720  .powerMngrId = PowerCC26XX_PERIPH_UART0,
721  .intNum = INT_UART0_COMB,
722  .intPriority = ~0,
723  .swiPriority = 0,
724  .txPin = CC2650_LAUNCHXL_UART_TX,
725  .rxPin = CC2650_LAUNCHXL_UART_RX,
726  .ctsPin = PIN_UNASSIGNED,
727  .rtsPin = PIN_UNASSIGNED,
728  .ringBufPtr = uartCC26XXRingBuffer[CC2650_LAUNCHXL_UART0],
729  .ringBufSize = sizeof(uartCC26XXRingBuffer[CC2650_LAUNCHXL_UART0]),
730  .txIntFifoThr = UARTCC26XX_FIFO_THRESHOLD_1_8,
731  .rxIntFifoThr = UARTCC26XX_FIFO_THRESHOLD_4_8,
732  .errorFxn = NULL
733  },
734 #endif
735 };
736 
737 const UART_Config UART_config[CC2650_LAUNCHXL_UARTCOUNT] = {
738 #if TI_UART_CONF_UART0_ENABLE
739  {
740  .fxnTablePtr = &UARTCC26XX_fxnTable,
741  .object = &uartCC26XXObjects[CC2650_LAUNCHXL_UART0],
742  .hwAttrs = &uartCC26XXHWAttrs[CC2650_LAUNCHXL_UART0]
743  },
744 #endif
745 };
746 
747 const uint_least8_t UART_count = CC2650_LAUNCHXL_UARTCOUNT;
748 
749 #endif /* TI_UART_CONF_ENABLE */
750 
751 /*
752  * =============================== UDMA ===============================
753  */
754 #include <ti/drivers/dma/UDMACC26XX.h>
755 
756 UDMACC26XX_Object udmaObjects[CC2650_LAUNCHXL_UDMACOUNT];
757 
758 const UDMACC26XX_HWAttrs udmaHWAttrs[CC2650_LAUNCHXL_UDMACOUNT] = {
759  {
760  .baseAddr = UDMA0_BASE,
761  .powerMngrId = PowerCC26XX_PERIPH_UDMA,
762  .intNum = INT_DMA_ERR,
763  .intPriority = ~0
764  }
765 };
766 
767 const UDMACC26XX_Config UDMACC26XX_config[CC2650_LAUNCHXL_UDMACOUNT] = {
768  {
769  .object = &udmaObjects[CC2650_LAUNCHXL_UDMA0],
770  .hwAttrs = &udmaHWAttrs[CC2650_LAUNCHXL_UDMA0]
771  },
772 };
773 
774 
775 
776 /*
777  * =============================== Watchdog ===============================
778  */
779 #include <ti/drivers/Watchdog.h>
780 #include <ti/drivers/watchdog/WatchdogCC26XX.h>
781 
782 WatchdogCC26XX_Object watchdogCC26XXObjects[CC2650_LAUNCHXL_WATCHDOGCOUNT];
783 
784 const WatchdogCC26XX_HWAttrs watchdogCC26XXHWAttrs[CC2650_LAUNCHXL_WATCHDOGCOUNT] = {
785  {
786  .baseAddr = WDT_BASE,
787  .reloadValue = 1000 /* Reload value in milliseconds */
788  },
789 };
790 
791 const Watchdog_Config Watchdog_config[CC2650_LAUNCHXL_WATCHDOGCOUNT] = {
792  {
793  .fxnTablePtr = &WatchdogCC26XX_fxnTable,
794  .object = &watchdogCC26XXObjects[CC2650_LAUNCHXL_WATCHDOG0],
795  .hwAttrs = &watchdogCC26XXHWAttrs[CC2650_LAUNCHXL_WATCHDOG0]
796  },
797 };
798 
799 const uint_least8_t Watchdog_count = CC2650_LAUNCHXL_WATCHDOGCOUNT;
800 
801 /*
802  * Board-specific initialization function to disable external flash.
803  * This function is defined in the file CC2650_LAUNCHXL_fxns.c
804  */
805 extern void Board_initHook(void);
806 
807 /*
808  * ======== CC2650_LAUNCHXL_initGeneral ========
809  */
811 {
812  Power_init();
813 
814  if (PIN_init(BoardGpioInitTable) != PIN_SUCCESS) {
815  /* Error with PIN_init */
816  while (1);
817  }
818 
819  /* Perform board-specific initialization */
820  Board_initHook();
821 }
#define SSI1_BASE
Base address for SSI1.
Definition: ssi.h:59
============================================================================
#define SSI0_BASE
Base address for SSI0.
Definition: ssi.h:58
void CC2650_LAUNCHXL_initGeneral(void)
Initialize the general board specific settings.