Contiki-NG
CC1350_LAUNCHXL_433.c
1 /*
2  * Copyright (c) 2017-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_433.c ============================
35  * This file is responsible for setting up the board specific items for the
36  * CC1350_LAUNCHXL_433 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_433.h"
50 
51 /*
52  * =============================== ADCBuf ===============================
53  */
54 #include <ti/drivers/ADCBuf.h>
55 #include <ti/drivers/adcbuf/ADCBufCC26XX.h>
56 
57 ADCBufCC26XX_Object adcBufCC26XXobjects[CC1350_LAUNCHXL_433_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_433_ADCBUF0CHANNELCOUNT] = {
67  {CC1350_LAUNCHXL_433_DIO23_ANALOG, ADC_COMPB_IN_AUXIO7},
68  {CC1350_LAUNCHXL_433_DIO24_ANALOG, ADC_COMPB_IN_AUXIO6},
69  {CC1350_LAUNCHXL_433_DIO25_ANALOG, ADC_COMPB_IN_AUXIO5},
70  {CC1350_LAUNCHXL_433_DIO26_ANALOG, ADC_COMPB_IN_AUXIO4},
71  {CC1350_LAUNCHXL_433_DIO27_ANALOG, ADC_COMPB_IN_AUXIO3},
72  {CC1350_LAUNCHXL_433_DIO28_ANALOG, ADC_COMPB_IN_AUXIO2},
73  {CC1350_LAUNCHXL_433_DIO29_ANALOG, ADC_COMPB_IN_AUXIO1},
74  {CC1350_LAUNCHXL_433_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_433_ADCBUFCOUNT] = {
81  {
82  .intPriority = ~0,
83  .swiPriority = 0,
84  .adcChannelLut = ADCBufCC26XX_adcChannelLut,
85  .gpTimerUnit = CC1350_LAUNCHXL_433_GPTIMER0A,
86  .gptDMAChannelMask = 1 << UDMA_CHAN_TIMER0_A,
87  }
88 };
89 
90 const ADCBuf_Config ADCBuf_config[CC1350_LAUNCHXL_433_ADCBUFCOUNT] = {
91  {
92  &ADCBufCC26XX_fxnTable,
93  &adcBufCC26XXobjects[CC1350_LAUNCHXL_433_ADCBUF0],
94  &adcBufCC26XXHWAttrs[CC1350_LAUNCHXL_433_ADCBUF0]
95  },
96 };
97 
98 const uint_least8_t ADCBuf_count = CC1350_LAUNCHXL_433_ADCBUFCOUNT;
99 
100 /*
101  * =============================== ADC ===============================
102  */
103 #include <ti/drivers/ADC.h>
104 #include <ti/drivers/adc/ADCCC26XX.h>
105 
106 ADCCC26XX_Object adcCC26xxObjects[CC1350_LAUNCHXL_433_ADCCOUNT];
107 
108 const ADCCC26XX_HWAttrs adcCC26xxHWAttrs[CC1350_LAUNCHXL_433_ADCCOUNT] = {
109  {
110  .adcDIO = CC1350_LAUNCHXL_433_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 = CC1350_LAUNCHXL_433_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 = CC1350_LAUNCHXL_433_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 = CC1350_LAUNCHXL_433_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 = CC1350_LAUNCHXL_433_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 = CC1350_LAUNCHXL_433_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 = CC1350_LAUNCHXL_433_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 = CC1350_LAUNCHXL_433_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[CC1350_LAUNCHXL_433_ADCCOUNT] = {
211  {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC1350_LAUNCHXL_433_ADC0], &adcCC26xxHWAttrs[CC1350_LAUNCHXL_433_ADC0]},
212  {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC1350_LAUNCHXL_433_ADC1], &adcCC26xxHWAttrs[CC1350_LAUNCHXL_433_ADC1]},
213  {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC1350_LAUNCHXL_433_ADC2], &adcCC26xxHWAttrs[CC1350_LAUNCHXL_433_ADC2]},
214  {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC1350_LAUNCHXL_433_ADC3], &adcCC26xxHWAttrs[CC1350_LAUNCHXL_433_ADC3]},
215  {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC1350_LAUNCHXL_433_ADC4], &adcCC26xxHWAttrs[CC1350_LAUNCHXL_433_ADC4]},
216  {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC1350_LAUNCHXL_433_ADC5], &adcCC26xxHWAttrs[CC1350_LAUNCHXL_433_ADC5]},
217  {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC1350_LAUNCHXL_433_ADC6], &adcCC26xxHWAttrs[CC1350_LAUNCHXL_433_ADC6]},
218  {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC1350_LAUNCHXL_433_ADC7], &adcCC26xxHWAttrs[CC1350_LAUNCHXL_433_ADC7]},
219  {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC1350_LAUNCHXL_433_ADCDCOUPL], &adcCC26xxHWAttrs[CC1350_LAUNCHXL_433_ADCDCOUPL]},
220  {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC1350_LAUNCHXL_433_ADCVSS], &adcCC26xxHWAttrs[CC1350_LAUNCHXL_433_ADCVSS]},
221  {&ADCCC26XX_fxnTable, &adcCC26xxObjects[CC1350_LAUNCHXL_433_ADCVDDS], &adcCC26xxHWAttrs[CC1350_LAUNCHXL_433_ADCVDDS]},
222 };
223 
224 const uint_least8_t ADC_count = CC1350_LAUNCHXL_433_ADCCOUNT;
225 
226 /*
227  * =============================== Crypto ===============================
228  */
229 #include <ti/drivers/crypto/CryptoCC26XX.h>
230 
231 CryptoCC26XX_Object cryptoCC26XXObjects[CC1350_LAUNCHXL_433_CRYPTOCOUNT];
232 
233 const CryptoCC26XX_HWAttrs cryptoCC26XXHWAttrs[CC1350_LAUNCHXL_433_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[CC1350_LAUNCHXL_433_CRYPTOCOUNT] = {
243  {
244  .object = &cryptoCC26XXObjects[CC1350_LAUNCHXL_433_CRYPTO0],
245  .hwAttrs = &cryptoCC26XXHWAttrs[CC1350_LAUNCHXL_433_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 CC1350_LAUNCHXL_433.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, /* CC1350_LAUNCHXL_433_SPI_MASTER_READY */
269  GPIOCC26XX_DIO_21 | GPIO_DO_NOT_CONFIG, /* CC1350_LAUNCHXL_433_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 CC1350_LAUNCHXL_433.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, /* CC1350_LAUNCHXL_433_SPI_MASTER_READY */
293  NULL, /* CC1350_LAUNCHXL_433_SPI_SLAVE_READY */
294 };
295 
296 const GPIOCC26XX_Config GPIOCC26XX_config = {
297  .pinConfigs = (GPIO_PinConfig *)gpioPinConfigs,
298  .callbacks = (GPIO_CallbackFxn *)gpioCallbackFunctions,
299  .numberOfPinConfigs = sizeof(gpioPinConfigs)/sizeof(GPIO_PinConfig),
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[CC1350_LAUNCHXL_433_GPTIMERCOUNT];
311 
312 const GPTimerCC26XX_HWAttrs gptimerCC26xxHWAttrs[CC1350_LAUNCHXL_433_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[CC1350_LAUNCHXL_433_GPTIMERPARTSCOUNT] = {
324  { &gptimerCC26XXObjects[CC1350_LAUNCHXL_433_GPTIMER0], &gptimerCC26xxHWAttrs[CC1350_LAUNCHXL_433_GPTIMER0A], GPT_A },
325  { &gptimerCC26XXObjects[CC1350_LAUNCHXL_433_GPTIMER0], &gptimerCC26xxHWAttrs[CC1350_LAUNCHXL_433_GPTIMER0B], GPT_B },
326  { &gptimerCC26XXObjects[CC1350_LAUNCHXL_433_GPTIMER1], &gptimerCC26xxHWAttrs[CC1350_LAUNCHXL_433_GPTIMER1A], GPT_A },
327  { &gptimerCC26XXObjects[CC1350_LAUNCHXL_433_GPTIMER1], &gptimerCC26xxHWAttrs[CC1350_LAUNCHXL_433_GPTIMER1B], GPT_B },
328  { &gptimerCC26XXObjects[CC1350_LAUNCHXL_433_GPTIMER2], &gptimerCC26xxHWAttrs[CC1350_LAUNCHXL_433_GPTIMER2A], GPT_A },
329  { &gptimerCC26XXObjects[CC1350_LAUNCHXL_433_GPTIMER2], &gptimerCC26xxHWAttrs[CC1350_LAUNCHXL_433_GPTIMER2B], GPT_B },
330  { &gptimerCC26XXObjects[CC1350_LAUNCHXL_433_GPTIMER3], &gptimerCC26xxHWAttrs[CC1350_LAUNCHXL_433_GPTIMER3A], GPT_A },
331  { &gptimerCC26XXObjects[CC1350_LAUNCHXL_433_GPTIMER3], &gptimerCC26xxHWAttrs[CC1350_LAUNCHXL_433_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[CC1350_LAUNCHXL_433_I2CCOUNT];
343 
344 const I2CCC26XX_HWAttrsV1 i2cCC26xxHWAttrs[CC1350_LAUNCHXL_433_I2CCOUNT] = {
345  {
346  .baseAddr = I2C0_BASE,
347  .powerMngrId = PowerCC26XX_PERIPH_I2C0,
348  .intNum = INT_I2C_IRQ,
349  .intPriority = ~0,
350  .swiPriority = 0,
351  .sdaPin = CC1350_LAUNCHXL_433_I2C0_SDA0,
352  .sclPin = CC1350_LAUNCHXL_433_I2C0_SCL0,
353  }
354 };
355 
356 const I2C_Config I2C_config[CC1350_LAUNCHXL_433_I2CCOUNT] = {
357  {
358  .fxnTablePtr = &I2CCC26XX_fxnTable,
359  .object = &i2cCC26xxObjects[CC1350_LAUNCHXL_433_I2C0],
360  .hwAttrs = &i2cCC26xxHWAttrs[CC1350_LAUNCHXL_433_I2C0]
361  },
362 };
363 
364 const uint_least8_t I2C_count = CC1350_LAUNCHXL_433_I2CCOUNT;
365 
366 #endif /* TI_I2C_CONF_ENABLE */
367 
368 /*
369  * =============================== NVS ===============================
370  */
371 #include <ti/drivers/NVS.h>
372 #include <ti/drivers/nvs/NVSSPI25X.h>
373 #include <ti/drivers/nvs/NVSCC26XX.h>
374 
375 #define NVS_REGIONS_BASE 0x1A000
376 #define SECTORSIZE 0x1000
377 #define REGIONSIZE (SECTORSIZE * 4)
378 
379 #if TI_NVS_CONF_ENABLE
380 
381 #if TI_NVS_CONF_NVS_INTERNAL_ENABLE
382 
383 /*
384  * Reserve flash sectors for NVS driver use by placing an uninitialized byte
385  * array at the desired flash address.
386  */
387 #if defined(__TI_COMPILER_VERSION__)
388 
389 /*
390  * Place uninitialized array at NVS_REGIONS_BASE
391  */
392 #pragma LOCATION(flashBuf, NVS_REGIONS_BASE);
393 #pragma NOINIT(flashBuf);
394 static char flashBuf[REGIONSIZE];
395 
396 #elif defined(__IAR_SYSTEMS_ICC__)
397 
398 /*
399  * Place uninitialized array at NVS_REGIONS_BASE
400  */
401 static __no_init char flashBuf[REGIONSIZE] @ NVS_REGIONS_BASE;
402 
403 #elif defined(__GNUC__)
404 
405 /*
406  * Place the flash buffers in the .nvs section created in the gcc linker file.
407  * The .nvs section enforces alignment on a sector boundary but may
408  * be placed anywhere in flash memory. If desired the .nvs section can be set
409  * to a fixed address by changing the following in the gcc linker file:
410  *
411  * .nvs (FIXED_FLASH_ADDR) (NOLOAD) : AT (FIXED_FLASH_ADDR) {
412  * *(.nvs)
413  * } > REGION_TEXT
414  */
415 __attribute__ ((section (".nvs")))
416 static char flashBuf[REGIONSIZE];
417 
418 #endif
419 
420 /* Allocate objects for NVS Internal Regions */
421 NVSCC26XX_Object nvsCC26xxObjects[1];
422 
423 /* Hardware attributes for NVS Internal Regions */
424 const NVSCC26XX_HWAttrs nvsCC26xxHWAttrs[1] = {
425  {
426  .regionBase = (void *)flashBuf,
427  .regionSize = REGIONSIZE,
428  },
429 };
430 
431 #endif /* TI_NVS_CONF_NVS_INTERNAL_ENABLE */
432 
433 #if TI_NVS_CONF_NVS_EXTERNAL_ENABLE
434 
435 #define SPISECTORSIZE 0x1000
436 #define SPIREGIONSIZE (SPISECTORSIZE * 32)
437 #define VERIFYBUFSIZE 64
438 
439 static uint8_t verifyBuf[VERIFYBUFSIZE];
440 
441 /* Allocate objects for NVS External Regions */
442 NVSSPI25X_Object nvsSPI25XObjects[1];
443 
444 /* Hardware attributes for NVS External Regions */
445 const NVSSPI25X_HWAttrs nvsSPI25XHWAttrs[1] = {
446  {
447  .regionBaseOffset = 0,
448  .regionSize = SPIREGIONSIZE,
449  .sectorSize = SPISECTORSIZE,
450  .verifyBuf = verifyBuf,
451  .verifyBufSize = VERIFYBUFSIZE,
452  .spiHandle = NULL,
453  .spiIndex = 0,
454  .spiBitRate = 4000000,
455  .spiCsnGpioIndex = CC1350_LAUNCHXL_433_GPIO_SPI_FLASH_CS,
456  },
457 };
458 
459 #endif /* TI_NVS_CONF_NVS_EXTERNAL_ENABLE */
460 
461 /* NVS Region index 0 and 1 refer to NVS and NVS SPI respectively */
462 const NVS_Config NVS_config[CC1350_LAUNCHXL_433_NVSCOUNT] = {
463 #if TI_NVS_CONF_NVS_INTERNAL_ENABLE
464  {
465  .fxnTablePtr = &NVSCC26XX_fxnTable,
466  .object = &nvsCC26xxObjects[0],
467  .hwAttrs = &nvsCC26xxHWAttrs[0],
468  },
469 #endif
470 #if TI_NVS_CONF_NVS_EXTERNAL_ENABLE
471  {
472  .fxnTablePtr = &NVSSPI25X_fxnTable,
473  .object = &nvsSPI25XObjects[0],
474  .hwAttrs = &nvsSPI25XHWAttrs[0],
475  },
476 #endif
477 };
478 
479 const uint_least8_t NVS_count = CC1350_LAUNCHXL_433_NVSCOUNT;
480 
481 #endif /* TI_NVS_CONF_ENABLE */
482 
483 /*
484  * =============================== PIN ===============================
485  */
486 #include <ti/drivers/PIN.h>
487 #include <ti/drivers/pin/PINCC26XX.h>
488 
489 const PIN_Config BoardGpioInitTable[] = {
490 
491  CC1350_LAUNCHXL_433_PIN_RLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* LED initially off */
492  CC1350_LAUNCHXL_433_PIN_GLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* LED initially off */
493  CC1350_LAUNCHXL_433_PIN_BTN1 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Button is active low */
494  CC1350_LAUNCHXL_433_PIN_BTN2 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS, /* Button is active low */
495  CC1350_LAUNCHXL_433_SPI_FLASH_CS | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MIN, /* External flash chip select */
496  CC1350_LAUNCHXL_433_UART_RX | PIN_INPUT_EN | PIN_PULLUP, /* UART RX via debugger back channel */
497  CC1350_LAUNCHXL_433_UART_TX | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL, /* UART TX via debugger back channel */
498  CC1350_LAUNCHXL_433_DIO1_RF_SUB1GHZ | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* RF SW Switch defaults to 2.4 GHz path*/
499  CC1350_LAUNCHXL_433_DIO30_RF_POWER | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* External RF Switch is powered off by default */
500  CC1350_LAUNCHXL_433_SPI0_MOSI | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI master out - slave in */
501  CC1350_LAUNCHXL_433_SPI0_MISO | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI master in - slave out */
502  CC1350_LAUNCHXL_433_SPI0_CLK | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI clock */
503  PIN_TERMINATE
504 };
505 
506 const PINCC26XX_HWAttrs PINCC26XX_hwAttrs = {
507  .intPriority = ~0,
508  .swiPriority = 0
509 };
510 
511 /*
512  * =============================== Power ===============================
513  */
514 #include <ti/drivers/Power.h>
515 #include <ti/drivers/power/PowerCC26XX.h>
516 
517 const PowerCC26XX_Config PowerCC26XX_config = {
518  .policyInitFxn = NULL,
519  .policyFxn = &PowerCC26XX_standbyPolicy,
520  .calibrateFxn = &PowerCC26XX_calibrate,
521  .enablePolicy = true,
522  .calibrateRCOSC_LF = true,
523  .calibrateRCOSC_HF = true,
524 };
525 
526 /*
527  * =============================== PWM ===============================
528  * Remove unused entries to reduce flash usage both in Board.c and Board.h
529  */
530 #include <ti/drivers/PWM.h>
531 #include <ti/drivers/pwm/PWMTimerCC26XX.h>
532 
533 PWMTimerCC26XX_Object pwmtimerCC26xxObjects[CC1350_LAUNCHXL_433_PWMCOUNT];
534 
535 const PWMTimerCC26XX_HwAttrs pwmtimerCC26xxHWAttrs[CC1350_LAUNCHXL_433_PWMCOUNT] = {
536  { .pwmPin = CC1350_LAUNCHXL_433_PWMPIN0, .gpTimerUnit = CC1350_LAUNCHXL_433_GPTIMER0A },
537  { .pwmPin = CC1350_LAUNCHXL_433_PWMPIN1, .gpTimerUnit = CC1350_LAUNCHXL_433_GPTIMER0B },
538  { .pwmPin = CC1350_LAUNCHXL_433_PWMPIN2, .gpTimerUnit = CC1350_LAUNCHXL_433_GPTIMER1A },
539  { .pwmPin = CC1350_LAUNCHXL_433_PWMPIN3, .gpTimerUnit = CC1350_LAUNCHXL_433_GPTIMER1B },
540  { .pwmPin = CC1350_LAUNCHXL_433_PWMPIN4, .gpTimerUnit = CC1350_LAUNCHXL_433_GPTIMER2A },
541  { .pwmPin = CC1350_LAUNCHXL_433_PWMPIN5, .gpTimerUnit = CC1350_LAUNCHXL_433_GPTIMER2B },
542  { .pwmPin = CC1350_LAUNCHXL_433_PWMPIN6, .gpTimerUnit = CC1350_LAUNCHXL_433_GPTIMER3A },
543  { .pwmPin = CC1350_LAUNCHXL_433_PWMPIN7, .gpTimerUnit = CC1350_LAUNCHXL_433_GPTIMER3B },
544 };
545 
546 const PWM_Config PWM_config[CC1350_LAUNCHXL_433_PWMCOUNT] = {
547  { &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[CC1350_LAUNCHXL_433_PWM0], &pwmtimerCC26xxHWAttrs[CC1350_LAUNCHXL_433_PWM0] },
548  { &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[CC1350_LAUNCHXL_433_PWM1], &pwmtimerCC26xxHWAttrs[CC1350_LAUNCHXL_433_PWM1] },
549  { &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[CC1350_LAUNCHXL_433_PWM2], &pwmtimerCC26xxHWAttrs[CC1350_LAUNCHXL_433_PWM2] },
550  { &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[CC1350_LAUNCHXL_433_PWM3], &pwmtimerCC26xxHWAttrs[CC1350_LAUNCHXL_433_PWM3] },
551  { &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[CC1350_LAUNCHXL_433_PWM4], &pwmtimerCC26xxHWAttrs[CC1350_LAUNCHXL_433_PWM4] },
552  { &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[CC1350_LAUNCHXL_433_PWM5], &pwmtimerCC26xxHWAttrs[CC1350_LAUNCHXL_433_PWM5] },
553  { &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[CC1350_LAUNCHXL_433_PWM6], &pwmtimerCC26xxHWAttrs[CC1350_LAUNCHXL_433_PWM6] },
554  { &PWMTimerCC26XX_fxnTable, &pwmtimerCC26xxObjects[CC1350_LAUNCHXL_433_PWM7], &pwmtimerCC26xxHWAttrs[CC1350_LAUNCHXL_433_PWM7] },
555 };
556 
557 const uint_least8_t PWM_count = CC1350_LAUNCHXL_433_PWMCOUNT;
558 
559 /*
560  * =============================== RF Driver ===============================
561  */
562 #include <ti/drivers/rf/RF.h>
563 
564 /*
565  * Board-specific callback function to set the correct antenna path.
566  *
567  * This function is called by the RF driver on global driver events.
568  * It contains a default implementation to set the correct antenna path.
569  * This function is defined in the file CC1350_LAUNCHXL_433_fxns.c
570  */
571 extern void rfDriverCallback(RF_Handle client, RF_GlobalEvent events, void *arg);
572 
573 const RFCC26XX_HWAttrsV2 RFCC26XX_hwAttrs = {
574  .hwiPriority = ~0, /* Lowest HWI priority */
575  .swiPriority = 0, /* Lowest SWI priority */
576  .xoscHfAlwaysNeeded = true, /* Keep XOSC dependency while in stanby */
577 
578  /* Register the board specific callback */
579  .globalCallback = &rfDriverCallback,
580  /* Subscribe the callback to both events */
581  .globalEventMask = RF_GlobalEventRadioSetup | RF_GlobalEventRadioPowerDown
582 };
583 
584 /*
585  * =============================== SD ===============================
586  */
587 #include <ti/drivers/SD.h>
588 #include <ti/drivers/sd/SDSPI.h>
589 
590 #if TI_SD_CONF_ENABLE
591 
592 #if !(TI_SPI_CONF_SPI0_ENABLE)
593 #error "SD driver requires SPI0 enabled"
594 #endif
595 
596 SDSPI_Object sdspiObjects[CC1350_LAUNCHXL_433_SDCOUNT];
597 
598 const SDSPI_HWAttrs sdspiHWAttrs[CC1350_LAUNCHXL_433_SDCOUNT] = {
599  {
600  .spiIndex = CC1350_LAUNCHXL_433_SPI0,
601  .spiCsGpioIndex = CC1350_LAUNCHXL_433_SDSPI_CS
602  }
603 };
604 
605 const SD_Config SD_config[CC1350_LAUNCHXL_433_SDCOUNT] = {
606  {
607  .fxnTablePtr = &SDSPI_fxnTable,
608  .object = &sdspiObjects[CC1350_LAUNCHXL_433_SDSPI0],
609  .hwAttrs = &sdspiHWAttrs[CC1350_LAUNCHXL_433_SDSPI0]
610  },
611 };
612 
613 const uint_least8_t SD_count = CC1350_LAUNCHXL_433_SDCOUNT;
614 
615 #endif /* TI_SD_CONF_ENABLE */
616 
617 /*
618  * =============================== SPI DMA ===============================
619  */
620 #include <ti/drivers/SPI.h>
621 #include <ti/drivers/spi/SPICC26XXDMA.h>
622 
623 #if TI_SPI_CONF_ENABLE
624 
625 SPICC26XXDMA_Object spiCC26XXDMAObjects[CC1350_LAUNCHXL_433_SPICOUNT];
626 
627 /*
628  * NOTE: The SPI instances below can be used by the SD driver to communicate
629  * with a SD card via SPI. The 'defaultTxBufValue' fields below are set to 0xFF
630  * to satisfy the SDSPI driver requirement.
631  */
632 const SPICC26XXDMA_HWAttrsV1 spiCC26XXDMAHWAttrs[CC1350_LAUNCHXL_433_SPICOUNT] = {
633 #if TI_SPI_CONF_SPI0_ENABLE
634  {
635  .baseAddr = SSI0_BASE,
636  .intNum = INT_SSI0_COMB,
637  .intPriority = ~0,
638  .swiPriority = 0,
639  .powerMngrId = PowerCC26XX_PERIPH_SSI0,
640  .defaultTxBufValue = 0xFF,
641  .rxChannelBitMask = 1<<UDMA_CHAN_SSI0_RX,
642  .txChannelBitMask = 1<<UDMA_CHAN_SSI0_TX,
643  .mosiPin = CC1350_LAUNCHXL_433_SPI0_MOSI,
644  .misoPin = CC1350_LAUNCHXL_433_SPI0_MISO,
645  .clkPin = CC1350_LAUNCHXL_433_SPI0_CLK,
646  .csnPin = CC1350_LAUNCHXL_433_SPI0_CSN,
647  .minDmaTransferSize = 10
648  },
649 #endif
650 #if TI_SPI_CONF_SPI1_ENABLE
651  {
652  .baseAddr = SSI1_BASE,
653  .intNum = INT_SSI1_COMB,
654  .intPriority = ~0,
655  .swiPriority = 0,
656  .powerMngrId = PowerCC26XX_PERIPH_SSI1,
657  .defaultTxBufValue = 0xFF,
658  .rxChannelBitMask = 1<<UDMA_CHAN_SSI1_RX,
659  .txChannelBitMask = 1<<UDMA_CHAN_SSI1_TX,
660  .mosiPin = CC1350_LAUNCHXL_433_SPI1_MOSI,
661  .misoPin = CC1350_LAUNCHXL_433_SPI1_MISO,
662  .clkPin = CC1350_LAUNCHXL_433_SPI1_CLK,
663  .csnPin = CC1350_LAUNCHXL_433_SPI1_CSN,
664  .minDmaTransferSize = 10
665  },
666 #endif
667 };
668 
669 const SPI_Config SPI_config[CC1350_LAUNCHXL_433_SPICOUNT] = {
670 #if TI_SPI_CONF_SPI0_ENABLE
671  {
672  .fxnTablePtr = &SPICC26XXDMA_fxnTable,
673  .object = &spiCC26XXDMAObjects[CC1350_LAUNCHXL_433_SPI0],
674  .hwAttrs = &spiCC26XXDMAHWAttrs[CC1350_LAUNCHXL_433_SPI0]
675  },
676 #endif
677 #if TI_SPI_CONF_SPI1_ENABLE
678  {
679  .fxnTablePtr = &SPICC26XXDMA_fxnTable,
680  .object = &spiCC26XXDMAObjects[CC1350_LAUNCHXL_433_SPI1],
681  .hwAttrs = &spiCC26XXDMAHWAttrs[CC1350_LAUNCHXL_433_SPI1]
682  },
683 #endif
684 };
685 
686 const uint_least8_t SPI_count = CC1350_LAUNCHXL_433_SPICOUNT;
687 
688 #endif /* TI_SPI_CONF_ENABLE */
689 
690 
691 /*
692  * =============================== TRNG ===============================
693  */
694 #include <ti/drivers/TRNG.h>
695 #include <ti/drivers/trng/TRNGCC26X0.h>
696 
697 TRNGCC26X0_Object trngCC26X0Object[CC1350_LAUNCHXL_433_TRNGCOUNT];
698 
699 const TRNGCC26X0_HWAttrs trngCC26X0HWAttrs[CC1350_LAUNCHXL_433_TRNGCOUNT] = {
700  {
701  .swiPriority = 0,
702  .intPriority = ~0,
703  }
704 };
705 
706 const TRNG_Config TRNG_config[] = {
707  { &trngCC26X0Object[0], &trngCC26X0HWAttrs[0] },
708 };
709 
710 const uint8_t TRNG_count = CC1350_LAUNCHXL_433_TRNGCOUNT;
711 
712 
713 /*
714  * =============================== UART ===============================
715  */
716 #include <ti/drivers/UART.h>
717 #include <ti/drivers/uart/UARTCC26XX.h>
718 
719 #if TI_UART_CONF_ENABLE
720 
721 UARTCC26XX_Object uartCC26XXObjects[CC1350_LAUNCHXL_433_UARTCOUNT];
722 
723 uint8_t uartCC26XXRingBuffer[CC1350_LAUNCHXL_433_UARTCOUNT][32];
724 
725 const UARTCC26XX_HWAttrsV2 uartCC26XXHWAttrs[CC1350_LAUNCHXL_433_UARTCOUNT] = {
726 #if TI_UART_CONF_UART0_ENABLE
727  {
728  .baseAddr = UART0_BASE,
729  .powerMngrId = PowerCC26XX_PERIPH_UART0,
730  .intNum = INT_UART0_COMB,
731  .intPriority = ~0,
732  .swiPriority = 0,
733  .txPin = CC1350_LAUNCHXL_433_UART_TX,
734  .rxPin = CC1350_LAUNCHXL_433_UART_RX,
735  .ctsPin = PIN_UNASSIGNED,
736  .rtsPin = PIN_UNASSIGNED,
737  .ringBufPtr = uartCC26XXRingBuffer[CC1350_LAUNCHXL_433_UART0],
738  .ringBufSize = sizeof(uartCC26XXRingBuffer[CC1350_LAUNCHXL_433_UART0]),
739  .txIntFifoThr = UARTCC26XX_FIFO_THRESHOLD_1_8,
740  .rxIntFifoThr = UARTCC26XX_FIFO_THRESHOLD_4_8,
741  .errorFxn = NULL
742  },
743 #endif
744 };
745 
746 const UART_Config UART_config[CC1350_LAUNCHXL_433_UARTCOUNT] = {
747 #if TI_UART_CONF_UART0_ENABLE
748  {
749  .fxnTablePtr = &UARTCC26XX_fxnTable,
750  .object = &uartCC26XXObjects[CC1350_LAUNCHXL_433_UART0],
751  .hwAttrs = &uartCC26XXHWAttrs[CC1350_LAUNCHXL_433_UART0]
752  },
753 #endif
754 };
755 
756 const uint_least8_t UART_count = CC1350_LAUNCHXL_433_UARTCOUNT;
757 
758 #endif /* TI_UART_CONF_ENABLE */
759 
760 /*
761  * =============================== UDMA ===============================
762  */
763 #include <ti/drivers/dma/UDMACC26XX.h>
764 
765 UDMACC26XX_Object udmaObjects[CC1350_LAUNCHXL_433_UDMACOUNT];
766 
767 const UDMACC26XX_HWAttrs udmaHWAttrs[CC1350_LAUNCHXL_433_UDMACOUNT] = {
768  {
769  .baseAddr = UDMA0_BASE,
770  .powerMngrId = PowerCC26XX_PERIPH_UDMA,
771  .intNum = INT_DMA_ERR,
772  .intPriority = ~0
773  }
774 };
775 
776 const UDMACC26XX_Config UDMACC26XX_config[CC1350_LAUNCHXL_433_UDMACOUNT] = {
777  {
778  .object = &udmaObjects[CC1350_LAUNCHXL_433_UDMA0],
779  .hwAttrs = &udmaHWAttrs[CC1350_LAUNCHXL_433_UDMA0]
780  },
781 };
782 
783 /*
784  * =============================== Watchdog ===============================
785  */
786 #include <ti/drivers/Watchdog.h>
787 #include <ti/drivers/watchdog/WatchdogCC26XX.h>
788 
789 WatchdogCC26XX_Object watchdogCC26XXObjects[CC1350_LAUNCHXL_433_WATCHDOGCOUNT];
790 
791 const WatchdogCC26XX_HWAttrs watchdogCC26XXHWAttrs[CC1350_LAUNCHXL_433_WATCHDOGCOUNT] = {
792  {
793  .baseAddr = WDT_BASE,
794  .reloadValue = 1000 /* Reload value in milliseconds */
795  },
796 };
797 
798 const Watchdog_Config Watchdog_config[CC1350_LAUNCHXL_433_WATCHDOGCOUNT] = {
799  {
800  .fxnTablePtr = &WatchdogCC26XX_fxnTable,
801  .object = &watchdogCC26XXObjects[CC1350_LAUNCHXL_433_WATCHDOG0],
802  .hwAttrs = &watchdogCC26XXHWAttrs[CC1350_LAUNCHXL_433_WATCHDOG0]
803  },
804 };
805 
806 const uint_least8_t Watchdog_count = CC1350_LAUNCHXL_433_WATCHDOGCOUNT;
807 
808 /*
809  * Board-specific initialization function to disable external flash.
810  * This function is defined in the file CC1350_LAUNCHXL_433_fxns.c
811  */
812 extern void Board_initHook(void);
813 
814 /*
815  * ======== CC1350_LAUNCHXL_433_initGeneral ========
816  */
818 {
819  Power_init();
820 
821  if (PIN_init(BoardGpioInitTable) != PIN_SUCCESS) {
822  /* Error with PIN_init */
823  while (1);
824  }
825 
826  /* Perform board-specific initialization */
827  Board_initHook();
828 }
============================================================================
#define SSI1_BASE
Base address for SSI1.
Definition: ssi.h:59
#define SSI0_BASE
Base address for SSI0.
Definition: ssi.h:58
void CC1350_LAUNCHXL_433_initGeneral(void)
Initialize the general board specific settings.