Contiki-NG
CC1350_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  * ============================ CC1350_LAUNCHXL.c ============================
35  * This file is responsible for setting up the board specific items for the
36  * CC1350_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 "CC1350_LAUNCHXL.h"
50 
51 /*
52  * =============================== ADCBuf ===============================
53  */
54 #include <ti/drivers/ADCBuf.h>
55 #include <ti/drivers/adcbuf/ADCBufCC26XX.h>
56 
57 static ADCBufCC26XX_Object adcBufCC26XXobjects[CC1350_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[CC1350_LAUNCHXL_ADCBUF0CHANNELCOUNT] = {
67  {CC1350_LAUNCHXL_DIO23_ANALOG, ADC_COMPB_IN_AUXIO7},
68  {CC1350_LAUNCHXL_DIO24_ANALOG, ADC_COMPB_IN_AUXIO6},
69  {CC1350_LAUNCHXL_DIO25_ANALOG, ADC_COMPB_IN_AUXIO5},
70  {CC1350_LAUNCHXL_DIO26_ANALOG, ADC_COMPB_IN_AUXIO4},
71  {CC1350_LAUNCHXL_DIO27_ANALOG, ADC_COMPB_IN_AUXIO3},
72  {CC1350_LAUNCHXL_DIO28_ANALOG, ADC_COMPB_IN_AUXIO2},
73  {CC1350_LAUNCHXL_DIO29_ANALOG, ADC_COMPB_IN_AUXIO1},
74  {CC1350_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[CC1350_LAUNCHXL_ADCBUFCOUNT] = {
81  {
82  .intPriority = ~0,
83  .swiPriority = 0,
84  .adcChannelLut = ADCBufCC26XX_adcChannelLut,
85  .gpTimerUnit = CC1350_LAUNCHXL_GPTIMER0A,
86  .gptDMAChannelMask = 1 << UDMA_CHAN_TIMER0_A,
87  }
88 };
89 
90 const ADCBuf_Config ADCBuf_config[CC1350_LAUNCHXL_ADCBUFCOUNT] = {
91  {
92  &ADCBufCC26XX_fxnTable,
93  &adcBufCC26XXobjects[CC1350_LAUNCHXL_ADCBUF0],
94  //NULL,
95  &adcBufCC26XXHWAttrs[CC1350_LAUNCHXL_ADCBUF0]
96  },
97 };
98 
99 const uint_least8_t ADCBuf_count = CC1350_LAUNCHXL_ADCBUFCOUNT;
100 
101 /*
102  * =============================== ADC ===============================
103  */
104 #include <ti/drivers/ADC.h>
105 #include <ti/drivers/adc/ADCCC26XX.h>
106 
107 static ADCCC26XX_Object adcCC26xxObjects[CC1350_LAUNCHXL_ADCCOUNT];
108 
109 const ADCCC26XX_HWAttrs adcCC26xxHWAttrs[CC1350_LAUNCHXL_ADCCOUNT] = {
110  {
111  .adcDIO = CC1350_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 = CC1350_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 = CC1350_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 = CC1350_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 = CC1350_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 = CC1350_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 = CC1350_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 = CC1350_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[CC1350_LAUNCHXL_ADCCOUNT] = {
212  {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC1350_LAUNCHXL_ADC0], &adcCC26xxHWAttrs[CC1350_LAUNCHXL_ADC0]},
213  {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC1350_LAUNCHXL_ADC1], &adcCC26xxHWAttrs[CC1350_LAUNCHXL_ADC1]},
214  {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC1350_LAUNCHXL_ADC2], &adcCC26xxHWAttrs[CC1350_LAUNCHXL_ADC2]},
215  {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC1350_LAUNCHXL_ADC3], &adcCC26xxHWAttrs[CC1350_LAUNCHXL_ADC3]},
216  {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC1350_LAUNCHXL_ADC4], &adcCC26xxHWAttrs[CC1350_LAUNCHXL_ADC4]},
217  {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC1350_LAUNCHXL_ADC5], &adcCC26xxHWAttrs[CC1350_LAUNCHXL_ADC5]},
218  {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC1350_LAUNCHXL_ADC6], &adcCC26xxHWAttrs[CC1350_LAUNCHXL_ADC6]},
219  {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC1350_LAUNCHXL_ADC7], &adcCC26xxHWAttrs[CC1350_LAUNCHXL_ADC7]},
220  {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC1350_LAUNCHXL_ADCDCOUPL], &adcCC26xxHWAttrs[CC1350_LAUNCHXL_ADCDCOUPL]},
221  {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC1350_LAUNCHXL_ADCVSS], &adcCC26xxHWAttrs[CC1350_LAUNCHXL_ADCVSS]},
222  {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC1350_LAUNCHXL_ADCVDDS], &adcCC26xxHWAttrs[CC1350_LAUNCHXL_ADCVDDS]},
223 };
224 
225 const uint_least8_t ADC_count = CC1350_LAUNCHXL_ADCCOUNT;
226 
227 /*
228  * =============================== Crypto ===============================
229  */
230 #include <ti/drivers/crypto/CryptoCC26XX.h>
231 
232 CryptoCC26XX_Object cryptoCC26XXObjects[CC1350_LAUNCHXL_CRYPTOCOUNT];
233 
234 const CryptoCC26XX_HWAttrs cryptoCC26XXHWAttrs[CC1350_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[CC1350_LAUNCHXL_CRYPTOCOUNT] = {
244  {
245  .object = &cryptoCC26XXObjects[CC1350_LAUNCHXL_CRYPTO0],
246  .hwAttrs = &cryptoCC26XXHWAttrs[CC1350_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 CC1350_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, /* CC1350_LAUNCHXL_SPI_MASTER_READY */
270  GPIOCC26XX_DIO_21 | GPIO_DO_NOT_CONFIG, /* CC1350_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 CC1350_LAUNCHXL.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, /* CC1350_LAUNCHXL_SPI_MASTER_READY */
294  NULL, /* CC1350_LAUNCHXL_SPI_SLAVE_READY */
295 };
296 
297 const GPIOCC26XX_Config GPIOCC26XX_config = {
298  .pinConfigs = (GPIO_PinConfig *)gpioPinConfigs,
299  .callbacks = (GPIO_CallbackFxn *)gpioCallbackFunctions,
300  .numberOfPinConfigs = sizeof(gpioPinConfigs)/sizeof(GPIO_PinConfig),
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[CC1350_LAUNCHXL_GPTIMERCOUNT];
312 
313 const GPTimerCC26XX_HWAttrs gptimerCC26xxHWAttrs[CC1350_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[CC1350_LAUNCHXL_GPTIMERPARTSCOUNT] = {
325  { &gptimerCC26XXObjects[CC1350_LAUNCHXL_GPTIMER0], &gptimerCC26xxHWAttrs[CC1350_LAUNCHXL_GPTIMER0A], GPT_A },
326  { &gptimerCC26XXObjects[CC1350_LAUNCHXL_GPTIMER0], &gptimerCC26xxHWAttrs[CC1350_LAUNCHXL_GPTIMER0B], GPT_B },
327  { &gptimerCC26XXObjects[CC1350_LAUNCHXL_GPTIMER1], &gptimerCC26xxHWAttrs[CC1350_LAUNCHXL_GPTIMER1A], GPT_A },
328  { &gptimerCC26XXObjects[CC1350_LAUNCHXL_GPTIMER1], &gptimerCC26xxHWAttrs[CC1350_LAUNCHXL_GPTIMER1B], GPT_B },
329  { &gptimerCC26XXObjects[CC1350_LAUNCHXL_GPTIMER2], &gptimerCC26xxHWAttrs[CC1350_LAUNCHXL_GPTIMER2A], GPT_A },
330  { &gptimerCC26XXObjects[CC1350_LAUNCHXL_GPTIMER2], &gptimerCC26xxHWAttrs[CC1350_LAUNCHXL_GPTIMER2B], GPT_B },
331  { &gptimerCC26XXObjects[CC1350_LAUNCHXL_GPTIMER3], &gptimerCC26xxHWAttrs[CC1350_LAUNCHXL_GPTIMER3A], GPT_A },
332  { &gptimerCC26XXObjects[CC1350_LAUNCHXL_GPTIMER3], &gptimerCC26xxHWAttrs[CC1350_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[CC1350_LAUNCHXL_I2CCOUNT];
344 
345 const I2CCC26XX_HWAttrsV1 i2cCC26xxHWAttrs[CC1350_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 = CC1350_LAUNCHXL_I2C0_SDA0,
354  .sclPin = CC1350_LAUNCHXL_I2C0_SCL0,
355  },
356 #endif
357 };
358 
359 const I2C_Config I2C_config[CC1350_LAUNCHXL_I2CCOUNT] = {
360 #if TI_I2C_CONF_I2C0_ENABLE
361  {
362  .fxnTablePtr = &I2CCC26XX_fxnTable,
363  .object = &i2cCC26xxObjects[CC1350_LAUNCHXL_I2C0],
364  .hwAttrs = &i2cCC26xxHWAttrs[CC1350_LAUNCHXL_I2C0]
365  },
366 #endif
367 };
368 
369 const uint_least8_t I2C_count = CC1350_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 = CC1350_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[CC1350_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 = CC1350_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  CC1350_LAUNCHXL_PIN_RLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* LED initially off */
497  CC1350_LAUNCHXL_PIN_GLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* LED initially off */
498  CC1350_LAUNCHXL_PIN_BTN1 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Button is active low */
499  CC1350_LAUNCHXL_PIN_BTN2 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Button is active low */
500  CC1350_LAUNCHXL_SPI_FLASH_CS | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MIN, /* External flash chip select */
501  CC1350_LAUNCHXL_UART_RX | PIN_INPUT_EN | PIN_PULLDOWN, /* UART RX via debugger back channel */
502  CC1350_LAUNCHXL_UART_TX | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL, /* UART TX via debugger back channel */
503  CC1350_LAUNCHXL_DIO1_RF_SUB1GHZ | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* RF SW Switch defaults to 2.4 GHz path*/
504  CC1350_LAUNCHXL_DIO30_RF_POWER | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* External RF Switch is powered off by default */
505  CC1350_LAUNCHXL_SPI0_MOSI | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI master out - slave in */
506  CC1350_LAUNCHXL_SPI0_MISO | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI master in - slave out */
507  CC1350_LAUNCHXL_SPI0_CLK | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI clock */
508  PIN_TERMINATE
509 };
510 
511 const PINCC26XX_HWAttrs PINCC26XX_hwAttrs = {
512  .intPriority = ~0,
513  .swiPriority = 0
514 };
515 
516 /*
517  * =============================== Power ===============================
518  */
519 #include <ti/drivers/Power.h>
520 #include <ti/drivers/power/PowerCC26XX.h>
521 
522 const PowerCC26XX_Config PowerCC26XX_config = {
523  .policyInitFxn = NULL,
524  .policyFxn = &PowerCC26XX_standbyPolicy,
525  .calibrateFxn = &PowerCC26XX_calibrate,
526  .enablePolicy = true,
527  .calibrateRCOSC_LF = true,
528  .calibrateRCOSC_HF = true,
529 };
530 
531 /*
532  * =============================== PWM ===============================
533  * Remove unused entries to reduce flash usage both in Board.c and Board.h
534  */
535 #include <ti/drivers/PWM.h>
536 #include <ti/drivers/pwm/PWMTimerCC26XX.h>
537 
538 PWMTimerCC26XX_Object pwmtimerCC26xxObjects[CC1350_LAUNCHXL_PWMCOUNT];
539 
540 const PWMTimerCC26XX_HwAttrs pwmtimerCC26xxHWAttrs[CC1350_LAUNCHXL_PWMCOUNT] = {
541  { .pwmPin = CC1350_LAUNCHXL_PWMPIN0, .gpTimerUnit = CC1350_LAUNCHXL_GPTIMER0A },
542  { .pwmPin = CC1350_LAUNCHXL_PWMPIN1, .gpTimerUnit = CC1350_LAUNCHXL_GPTIMER0B },
543  { .pwmPin = CC1350_LAUNCHXL_PWMPIN2, .gpTimerUnit = CC1350_LAUNCHXL_GPTIMER1A },
544  { .pwmPin = CC1350_LAUNCHXL_PWMPIN3, .gpTimerUnit = CC1350_LAUNCHXL_GPTIMER1B },
545  { .pwmPin = CC1350_LAUNCHXL_PWMPIN4, .gpTimerUnit = CC1350_LAUNCHXL_GPTIMER2A },
546  { .pwmPin = CC1350_LAUNCHXL_PWMPIN5, .gpTimerUnit = CC1350_LAUNCHXL_GPTIMER2B },
547  { .pwmPin = CC1350_LAUNCHXL_PWMPIN6, .gpTimerUnit = CC1350_LAUNCHXL_GPTIMER3A },
548  { .pwmPin = CC1350_LAUNCHXL_PWMPIN7, .gpTimerUnit = CC1350_LAUNCHXL_GPTIMER3B },
549 };
550 
551 const PWM_Config PWM_config[CC1350_LAUNCHXL_PWMCOUNT] = {
552  { &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[CC1350_LAUNCHXL_PWM0], &pwmtimerCC26xxHWAttrs[CC1350_LAUNCHXL_PWM0] },
553  { &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[CC1350_LAUNCHXL_PWM1], &pwmtimerCC26xxHWAttrs[CC1350_LAUNCHXL_PWM1] },
554  { &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[CC1350_LAUNCHXL_PWM2], &pwmtimerCC26xxHWAttrs[CC1350_LAUNCHXL_PWM2] },
555  { &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[CC1350_LAUNCHXL_PWM3], &pwmtimerCC26xxHWAttrs[CC1350_LAUNCHXL_PWM3] },
556  { &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[CC1350_LAUNCHXL_PWM4], &pwmtimerCC26xxHWAttrs[CC1350_LAUNCHXL_PWM4] },
557  { &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[CC1350_LAUNCHXL_PWM5], &pwmtimerCC26xxHWAttrs[CC1350_LAUNCHXL_PWM5] },
558  { &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[CC1350_LAUNCHXL_PWM6], &pwmtimerCC26xxHWAttrs[CC1350_LAUNCHXL_PWM6] },
559  { &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[CC1350_LAUNCHXL_PWM7], &pwmtimerCC26xxHWAttrs[CC1350_LAUNCHXL_PWM7] },
560 };
561 
562 const uint_least8_t PWM_count = CC1350_LAUNCHXL_PWMCOUNT;
563 
564 /*
565  * =============================== RF Driver ===============================
566  */
567 #include <ti/drivers/rf/RF.h>
568 
569 /*
570  * Board-specific callback function to set the correct antenna path.
571  *
572  * This function is called by the RF driver on global driver events.
573  * It contains a default implementation to set the correct antenna path.
574  * This function is defined in the file CC1350_LAUNCHXL_fxns.c
575  */
576 extern void rfDriverCallback(RF_Handle client, RF_GlobalEvent events, void *arg);
577 
578 const RFCC26XX_HWAttrsV2 RFCC26XX_hwAttrs = {
579  .hwiPriority = ~0, /* Lowest HWI priority */
580  .swiPriority = 0, /* Lowest SWI priority */
581  .xoscHfAlwaysNeeded = true, /* Keep XOSC dependency while in stanby */
582 
583  /* Register the board specific callback */
584  .globalCallback = &rfDriverCallback,
585  /* Subscribe the callback to both events */
586  .globalEventMask = RF_GlobalEventRadioSetup | RF_GlobalEventRadioPowerDown
587 };
588 
589 /*
590  * =============================== SD ===============================
591  */
592 #include <ti/drivers/SD.h>
593 #include <ti/drivers/sd/SDSPI.h>
594 
595 #if TI_SD_CONF_ENABLE
596 
597 #if !(TI_SPI_CONF_SPI0_ENABLE)
598 #error "SD driver requires SPI0 enabled"
599 #endif
600 
601 SDSPI_Object sdspiObjects[CC1350_LAUNCHXL_SDCOUNT];
602 
603 const SDSPI_HWAttrs sdspiHWAttrs[CC1350_LAUNCHXL_SDCOUNT] = {
604  {
605  .spiIndex = CC1350_LAUNCHXL_SPI0,
606  .spiCsGpioIndex = CC1350_LAUNCHXL_SDSPI_CS
607  }
608 };
609 
610 const SD_Config SD_config[CC1350_LAUNCHXL_SDCOUNT] = {
611  {
612  .fxnTablePtr = &SDSPI_fxnTable,
613  .object = &sdspiObjects[CC1350_LAUNCHXL_SDSPI0],
614  .hwAttrs = &sdspiHWAttrs[CC1350_LAUNCHXL_SDSPI0]
615  },
616 };
617 
618 const uint_least8_t SD_count = CC1350_LAUNCHXL_SDCOUNT;
619 
620 #endif /* TI_SD_CONF_ENABLE */
621 
622 /*
623  * =============================== SPI DMA ===============================
624  */
625 #include <ti/drivers/SPI.h>
626 #include <ti/drivers/spi/SPICC26XXDMA.h>
627 
628 #if TI_SPI_CONF_ENABLE
629 
630 SPICC26XXDMA_Object spiCC26XXDMAObjects[CC1350_LAUNCHXL_SPICOUNT];
631 
632 /*
633  * NOTE: The SPI instances below can be used by the SD driver to communicate
634  * with a SD card via SPI. The 'defaultTxBufValue' fields below are set to 0xFF
635  * to satisfy the SDSPI driver requirement.
636  */
637 const SPICC26XXDMA_HWAttrsV1 spiCC26XXDMAHWAttrs[CC1350_LAUNCHXL_SPICOUNT] = {
638 #if TI_SPI_CONF_SPI0_ENABLE
639  {
640  .baseAddr = SSI0_BASE,
641  .intNum = INT_SSI0_COMB,
642  .intPriority = ~0,
643  .swiPriority = 0,
644  .powerMngrId = PowerCC26XX_PERIPH_SSI0,
645  .defaultTxBufValue = 0xFF,
646  .rxChannelBitMask = 1<<UDMA_CHAN_SSI0_RX,
647  .txChannelBitMask = 1<<UDMA_CHAN_SSI0_TX,
648  .mosiPin = CC1350_LAUNCHXL_SPI0_MOSI,
649  .misoPin = CC1350_LAUNCHXL_SPI0_MISO,
650  .clkPin = CC1350_LAUNCHXL_SPI0_CLK,
651  .csnPin = CC1350_LAUNCHXL_SPI0_CSN,
652  .minDmaTransferSize = 10
653  },
654 #endif
655 #if TI_SPI_CONF_SPI1_ENABLE
656  {
657  .baseAddr = SSI1_BASE,
658  .intNum = INT_SSI1_COMB,
659  .intPriority = ~0,
660  .swiPriority = 0,
661  .powerMngrId = PowerCC26XX_PERIPH_SSI1,
662  .defaultTxBufValue = 0xFF,
663  .rxChannelBitMask = 1<<UDMA_CHAN_SSI1_RX,
664  .txChannelBitMask = 1<<UDMA_CHAN_SSI1_TX,
665  .mosiPin = CC1350_LAUNCHXL_SPI1_MOSI,
666  .misoPin = CC1350_LAUNCHXL_SPI1_MISO,
667  .clkPin = CC1350_LAUNCHXL_SPI1_CLK,
668  .csnPin = CC1350_LAUNCHXL_SPI1_CSN,
669  .minDmaTransferSize = 10
670  },
671 #endif
672 };
673 
674 const SPI_Config SPI_config[CC1350_LAUNCHXL_SPICOUNT] = {
675 #if TI_SPI_CONF_SPI0_ENABLE
676  {
677  .fxnTablePtr = &SPICC26XXDMA_fxnTable,
678  .object = &spiCC26XXDMAObjects[CC1350_LAUNCHXL_SPI0],
679  .hwAttrs = &spiCC26XXDMAHWAttrs[CC1350_LAUNCHXL_SPI0]
680  },
681 #endif
682 #if TI_SPI_CONF_SPI1_ENABLE
683  {
684  .fxnTablePtr = &SPICC26XXDMA_fxnTable,
685  .object = &spiCC26XXDMAObjects[CC1350_LAUNCHXL_SPI1],
686  .hwAttrs = &spiCC26XXDMAHWAttrs[CC1350_LAUNCHXL_SPI1]
687  },
688 #endif
689 };
690 
691 const uint_least8_t SPI_count = CC1350_LAUNCHXL_SPICOUNT;
692 
693 #endif /* TI_SPI_CONF_ENABLE */
694 
695 
696 /*
697  * =============================== TRNG ===============================
698  */
699 #include <ti/drivers/TRNG.h>
700 #include <ti/drivers/trng/TRNGCC26X0.h>
701 
702 TRNGCC26X0_Object trngCC26X0Object[CC1350_LAUNCHXL_TRNGCOUNT];
703 
704 const TRNGCC26X0_HWAttrs trngCC26X0HWAttrs[CC1350_LAUNCHXL_TRNGCOUNT] = {
705  {
706  .swiPriority = 0,
707  .intPriority = ~0,
708  }
709 };
710 
711 const TRNG_Config TRNG_config[] = {
712  { &trngCC26X0Object[0], &trngCC26X0HWAttrs[0] },
713 };
714 
715 const uint8_t TRNG_count = CC1350_LAUNCHXL_TRNGCOUNT;
716 
717 
718 /*
719  * =============================== UART ===============================
720  */
721 #include <ti/drivers/UART.h>
722 #include <ti/drivers/uart/UARTCC26XX.h>
723 
724 #if TI_UART_CONF_ENABLE
725 
726 UARTCC26XX_Object uartCC26XXObjects[CC1350_LAUNCHXL_UARTCOUNT];
727 
728 uint8_t uartCC26XXRingBuffer[CC1350_LAUNCHXL_UARTCOUNT][32];
729 
730 const UARTCC26XX_HWAttrsV2 uartCC26XXHWAttrs[CC1350_LAUNCHXL_UARTCOUNT] = {
731 #if TI_UART_CONF_UART0_ENABLE
732  {
733  .baseAddr = UART0_BASE,
734  .powerMngrId = PowerCC26XX_PERIPH_UART0,
735  .intNum = INT_UART0_COMB,
736  .intPriority = ~0,
737  .swiPriority = 0,
738  .txPin = CC1350_LAUNCHXL_UART_TX,
739  .rxPin = CC1350_LAUNCHXL_UART_RX,
740  .ctsPin = PIN_UNASSIGNED,
741  .rtsPin = PIN_UNASSIGNED,
742  .ringBufPtr = uartCC26XXRingBuffer[CC1350_LAUNCHXL_UART0],
743  .ringBufSize = sizeof(uartCC26XXRingBuffer[CC1350_LAUNCHXL_UART0]),
744  .txIntFifoThr = UARTCC26XX_FIFO_THRESHOLD_1_8,
745  .rxIntFifoThr = UARTCC26XX_FIFO_THRESHOLD_4_8,
746  .errorFxn = NULL
747  },
748 #endif
749 };
750 
751 const UART_Config UART_config[CC1350_LAUNCHXL_UARTCOUNT] = {
752 #if TI_UART_CONF_UART0_ENABLE
753  {
754  .fxnTablePtr = &UARTCC26XX_fxnTable,
755  .object = &uartCC26XXObjects[CC1350_LAUNCHXL_UART0],
756  .hwAttrs = &uartCC26XXHWAttrs[CC1350_LAUNCHXL_UART0]
757  },
758 #endif
759 };
760 
761 const uint_least8_t UART_count = CC1350_LAUNCHXL_UARTCOUNT;
762 
763 #endif /* TI_UART_CONF_ENABLE */
764 
765 /*
766  * =============================== UDMA ===============================
767  */
768 #include <ti/drivers/dma/UDMACC26XX.h>
769 
770 UDMACC26XX_Object udmaObjects[CC1350_LAUNCHXL_UDMACOUNT];
771 
772 const UDMACC26XX_HWAttrs udmaHWAttrs[CC1350_LAUNCHXL_UDMACOUNT] = {
773  {
774  .baseAddr = UDMA0_BASE,
775  .powerMngrId = PowerCC26XX_PERIPH_UDMA,
776  .intNum = INT_DMA_ERR,
777  .intPriority = ~0
778  }
779 };
780 
781 const UDMACC26XX_Config UDMACC26XX_config[CC1350_LAUNCHXL_UDMACOUNT] = {
782  {
783  .object = &udmaObjects[CC1350_LAUNCHXL_UDMA0],
784  .hwAttrs = &udmaHWAttrs[CC1350_LAUNCHXL_UDMA0]
785  },
786 };
787 
788 /*
789  * =============================== Watchdog ===============================
790  */
791 #include <ti/drivers/Watchdog.h>
792 #include <ti/drivers/watchdog/WatchdogCC26XX.h>
793 
794 WatchdogCC26XX_Object watchdogCC26XXObjects[CC1350_LAUNCHXL_WATCHDOGCOUNT];
795 
796 const WatchdogCC26XX_HWAttrs watchdogCC26XXHWAttrs[CC1350_LAUNCHXL_WATCHDOGCOUNT] = {
797  {
798  .baseAddr = WDT_BASE,
799  .reloadValue = 1000 /* Reload value in milliseconds */
800  },
801 };
802 
803 const Watchdog_Config Watchdog_config[CC1350_LAUNCHXL_WATCHDOGCOUNT] = {
804  {
805  .fxnTablePtr = &WatchdogCC26XX_fxnTable,
806  .object = &watchdogCC26XXObjects[CC1350_LAUNCHXL_WATCHDOG0],
807  .hwAttrs = &watchdogCC26XXHWAttrs[CC1350_LAUNCHXL_WATCHDOG0]
808  },
809 };
810 
811 const uint_least8_t Watchdog_count = CC1350_LAUNCHXL_WATCHDOGCOUNT;
812 
813 /*
814  * Board-specific initialization function to disable external flash.
815  * This function is defined in the file CC1350_LAUNCHXL_fxns.c
816  */
817 extern void Board_initHook(void);
818 
819 /*
820  * ======== CC1350_LAUNCHXL_initGeneral ========
821  */
823 {
824  Power_init();
825 
826  if (PIN_init(BoardGpioInitTable) != PIN_SUCCESS) {
827  /* Error with PIN_init */
828  while (1);
829  }
830 
831  /* Perform board-specific initialization */
832  Board_initHook();
833 }
void CC1350_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
============================================================================