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 */
33 /*
34 * ======== MSP_EXP432E401Y.c ========
35 * This file is responsible for setting up the board specific items for the
36 * MSP_EXP432E401Y board.
37 */
38 #include <stdint.h>
39 #include <stdlib.h>
41 #ifndef __MSP432E401Y__
42 #define __MSP432E401Y__
43 #endif
45 #include <ti/devices/msp432e4/inc/msp432.h>
47 #include <ti/devices/msp432e4/driverlib/adc.h>
48 #include <ti/devices/msp432e4/driverlib/interrupt.h>
49 #include <ti/devices/msp432e4/driverlib/pwm.h>
50 #include <ti/devices/msp432e4/driverlib/sysctl.h>
51 #include <ti/devices/msp432e4/driverlib/udma.h>
53 #include <ti/drivers/Power.h>
55 #include "MSP_EXP432E401Y.h"
57 /*
58 * =============================== ADC ===============================
59 */
60 #include <ti/drivers/ADC.h>
61 #include <ti/drivers/adc/ADCMSP432E4.h>
63 /* ADC objects */
64 ADCMSP432E4_Object adcMSP432E4Objects[MSP_EXP432E401Y_ADCCOUNT];
66 /* ADC configuration structure */
67 const ADCMSP432E4_HWAttrsV1 adcMSP432E4HWAttrs[MSP_EXP432E401Y_ADCCOUNT] = {
68 {
69 .adcPin = ADCMSP432E4_PE_3_A0,
70 .refVoltage = ADCMSP432E4_VREF_INTERNAL,
71 .adcModule = ADCMSP432E4_MOD0,
72 .adcSeq = ADCMSP432E4_SEQ0
73 },
74 {
75 .adcPin = ADCMSP432E4_PE_2_A1,
76 .refVoltage = ADCMSP432E4_VREF_INTERNAL,
77 .adcModule = ADCMSP432E4_MOD1,
78 .adcSeq = ADCMSP432E4_SEQ0
79 }
80 };
82 const ADC_Config ADC_config[MSP_EXP432E401Y_ADCCOUNT] = {
83 {
84 .fxnTablePtr = &ADCMSP432E4_fxnTable,
85 .object = &adcMSP432E4Objects[MSP_EXP432E401Y_ADC0],
86 .hwAttrs = &adcMSP432E4HWAttrs[MSP_EXP432E401Y_ADC0]
87 },
88 {
89 .fxnTablePtr = &ADCMSP432E4_fxnTable,
90 .object = &adcMSP432E4Objects[MSP_EXP432E401Y_ADC1],
91 .hwAttrs = &adcMSP432E4HWAttrs[MSP_EXP432E401Y_ADC1]
92 }
93 };
95 const uint_least8_t ADC_count = MSP_EXP432E401Y_ADCCOUNT;
97 /*
98 * =============================== ADCBuf ===============================
99 */
100 #include <ti/drivers/ADCBuf.h>
101 #include <ti/drivers/adcbuf/ADCBufMSP432E4.h>
103 /* ADC objects */
104 ADCBufMSP432E4_Object adcbufMSP432E4Objects[MSP_EXP432E401Y_ADCBUFCOUNT];
106 ADCBufMSP432E4_Channels adcBuf0MSP432E4Channels[MSP_EXP432E401Y_ADCBUF0CHANNELCOUNT] = {
107 {
108 .adcPin = ADCBufMSP432E4_PE_3_A0,
109 .adcSequence = ADCBufMSP432E4_Seq_0,
110 .adcInputMode = ADCBufMSP432E4_SINGLE_ENDED,
111 .adcDifferentialPin = ADCBufMSP432E4_PIN_NONE,
112 .adcInternalSource = ADCBufMSP432E4_INTERNAL_SOURCE_MODE_OFF,
113 .refVoltage = 3300000
114 },
115 {
116 .adcPin = ADCBufMSP432E4_PE_2_A1,
117 .adcSequence = ADCBufMSP432E4_Seq_1,
118 .adcInputMode = ADCBufMSP432E4_SINGLE_ENDED,
119 .adcDifferentialPin = ADCBufMSP432E4_PIN_NONE,
120 .adcInternalSource = ADCBufMSP432E4_INTERNAL_SOURCE_MODE_OFF,
121 .refVoltage = 3300000
122 },
123 {
124 .adcPin = ADCBufMSP432E4_PIN_NONE,
125 .adcSequence = ADCBufMSP432E4_Seq_0,
126 .adcInputMode = ADCBufMSP432E4_SINGLE_ENDED,
127 .adcDifferentialPin = ADCBufMSP432E4_PIN_NONE,
128 .adcInternalSource = ADCBufMSP432E4_TEMPERATURE_MODE,
129 .refVoltage = 3300000
130 },
131 {
132 .adcPin = ADCBufMSP432E4_PE_3_A0,
133 .adcSequence = ADCBufMSP432E4_Seq_0,
134 .adcInputMode = ADCBufMSP432E4_DIFFERENTIAL,
135 .adcDifferentialPin = ADCBufMSP432E4_PE_2_A1,
136 .adcInternalSource = ADCBufMSP432E4_INTERNAL_SOURCE_MODE_OFF,
137 .refVoltage = 3300000
138 },
139 {
140 .adcPin = ADCBufMSP432E4_PE_2_A1,
141 .adcSequence = ADCBufMSP432E4_Seq_0,
142 .adcInputMode = ADCBufMSP432E4_SINGLE_ENDED,
143 .adcDifferentialPin = ADCBufMSP432E4_PIN_NONE,
144 .adcInternalSource = ADCBufMSP432E4_INTERNAL_SOURCE_MODE_OFF,
145 .refVoltage = 3300000
146 }
147 };
149 /* ADC sequencer priorities for SS0-SS3, set to 0-3 to initialize sequencer */
150 static ADCBufMSP432E4_SequencePriorities seqPriorities[ADCBufMSP432E4_SEQUENCER_COUNT] = {
151 ADCBufMSP432E4_Priority_0,
152 ADCBufMSP432E4_Seq_Disable,
153 ADCBufMSP432E4_Seq_Disable,
154 ADCBufMSP432E4_Seq_Disable
155 };
157 /* ADC sequencer tigger source for SS0-SS3*/
158 static ADCBufMSP432E4_TriggerSource triggerSource[ADCBufMSP432E4_SEQUENCER_COUNT] = {
159 ADCBufMSP432E4_TIMER_TRIGGER,
160 ADCBufMSP432E4_TIMER_TRIGGER,
161 ADCBufMSP432E4_TIMER_TRIGGER,
162 ADCBufMSP432E4_TIMER_TRIGGER
163 };
165 /* ADC configuration structure */
166 const ADCBufMSP432E4_HWAttrsV1 adcbufMSP432E4HWAttrs[MSP_EXP432E401Y_ADCBUFCOUNT] = {
167 {
168 .intPriority = ~0,
169 .adcBase = ADC0_BASE,
170 .channelSetting = adcBuf0MSP432E4Channels,
171 .sequencePriority = seqPriorities,
172 .adcTriggerSource = triggerSource,
173 .modulePhase = ADCBufMSP432E4_Phase_Delay_0,
174 .refSource = ADCBufMSP432E4_VREF_INTERNAL,
175 .useDMA = 1,
176 .adcTimerSource = TIMER1_BASE,
177 }
178 };
180 const ADCBuf_Config ADCBuf_config[MSP_EXP432E401Y_ADCBUFCOUNT] = {
181 {
182 .fxnTablePtr = &ADCBufMSP432E4_fxnTable,
183 .object = &adcbufMSP432E4Objects[MSP_EXP432E401Y_ADCBUF0],
184 .hwAttrs = &adcbufMSP432E4HWAttrs[MSP_EXP432E401Y_ADCBUF0]
185 }
186 };
188 const uint_least8_t ADCBuf_count = MSP_EXP432E401Y_ADCBUFCOUNT;
190 /*
191 * ============================= Display =============================
192 */
193 #include <ti/display/Display.h>
194 #include <ti/display/DisplayUart.h>
195 #include <ti/display/DisplaySharp.h>
196 #define MAXPRINTLEN 1024
198 #ifndef BOARD_DISPLAY_SHARP_SIZE
199 #define BOARD_DISPLAY_SHARP_SIZE 96
200 #endif
202 DisplayUart_Object displayUartObject;
203 DisplaySharp_Object displaySharpObject;
205 static char displayBuf[MAXPRINTLEN];
206 static uint_least8_t sharpDisplayBuf[BOARD_DISPLAY_SHARP_SIZE * BOARD_DISPLAY_SHARP_SIZE / 8];
209 const DisplayUart_HWAttrs displayUartHWAttrs = {
210 .uartIdx = MSP_EXP432E401Y_UART0,
211 .baudRate = 115200,
212 .mutexTimeout = (unsigned int)(-1),
213 .strBuf = displayBuf,
214 .strBufLen = MAXPRINTLEN
215 };
217 const DisplaySharp_HWAttrsV1 displaySharpHWattrs = {
218 .spiIndex = MSP_EXP432E401Y_SPI2,
219 .csPin = MSP_EXP432E401Y_LCD_CS,
220 .powerPin = MSP_EXP432E401Y_LCD_POWER,
221 .enablePin = MSP_EXP432E401Y_LCD_ENABLE,
222 .pixelWidth = BOARD_DISPLAY_SHARP_SIZE,
223 .pixelHeight = BOARD_DISPLAY_SHARP_SIZE,
224 .displayBuf = sharpDisplayBuf,
225 };
227 #ifndef BOARD_DISPLAY_USE_UART
228 #define BOARD_DISPLAY_USE_UART 1
229 #endif
230 #ifndef BOARD_DISPLAY_USE_UART_ANSI
231 #define BOARD_DISPLAY_USE_UART_ANSI 0
232 #endif
233 #ifndef BOARD_DISPLAY_USE_LCD
234 #define BOARD_DISPLAY_USE_LCD 0
235 #endif
237 /*
238 * This #if/#else is needed to workaround a problem with the
239 * IAR compiler. The IAR compiler doesn't like the empty array
240 * initialization. (IAR Error[Pe1345])
241 */
242 #if (BOARD_DISPLAY_USE_UART || BOARD_DISPLAY_USE_LCD)
243 const Display_Config Display_config[] = {
244 {
245 # if (BOARD_DISPLAY_USE_UART_ANSI)
246 .fxnTablePtr = &DisplayUartAnsi_fxnTable,
247 # else /* Default to minimal UART with no cursor placement */
248 .fxnTablePtr = &DisplayUartMin_fxnTable,
249 # endif
250 .object = &displayUartObject,
251 .hwAttrs = &displayUartHWAttrs
252 },
253 #endif
254 #if (BOARD_DISPLAY_USE_LCD)
255 {
256 .fxnTablePtr = &DisplaySharp_fxnTable,
257 .object = &displaySharpObject,
258 .hwAttrs = &displaySharpHWattrs
259 },
260 #endif
261 };
263 const uint_least8_t Display_count = sizeof(Display_config) / sizeof(Display_Config);
265 /*
266 * =============================== DMA ===============================
267 */
268 #include <ti/drivers/dma/UDMAMSP432E4.h>
270 #if defined(__TI_COMPILER_VERSION__)
271 #pragma DATA_ALIGN(dmaControlTable, 1024)
272 #elif defined(__IAR_SYSTEMS_ICC__)
273 #pragma data_alignment=1024
274 #elif defined(__GNUC__)
275 __attribute__ ((aligned (1024)))
276 #endif
277 static tDMAControlTable dmaControlTable[64];
279 /*
280 * ======== dmaErrorFxn ========
281 * This is the handler for the uDMA error interrupt.
282 */
283 static void dmaErrorFxn(uintptr_t arg)
284 {
285 int status = uDMAErrorStatusGet();
286 uDMAErrorStatusClear();
288 /* Suppress unused variable warning */
289 (void)status;
291 while (1);
292 }
294 UDMAMSP432E4_Object udmaMSP432E4Object;
296 const UDMAMSP432E4_HWAttrs udmaMSP432E4HWAttrs = {
297 .controlBaseAddr = (void *)dmaControlTable,
298 .dmaErrorFxn = (UDMAMSP432E4_ErrorFxn)dmaErrorFxn,
299 .intNum = INT_UDMAERR,
300 .intPriority = (~0)
301 };
303 const UDMAMSP432E4_Config UDMAMSP432E4_config = {
304 .object = &udmaMSP432E4Object,
305 .hwAttrs = &udmaMSP432E4HWAttrs
306 };
308 /*
309 * =============================== General ===============================
310 */
311 /*
312 * ======== MSP_EXP432E401Y_initGeneral ========
313 */
314 void MSP_EXP432E401Y_initGeneral(void)
315 {
316 Power_init();
318 /* Grant the DMA access to all FLASH memory */
319 FLASH_CTRL->PP |= FLASH_PP_DFA;
321 /* Region start address - match FLASH start address */
322 FLASH_CTRL->DMAST = 0x00000000;
324 /*
325 * Access to FLASH is granted to the DMA in 2KB regions. The value
326 * assigned to DMASZ is the amount of 2KB regions to which the DMA will
327 * have access. The value can be determined via the following:
328 * 2 * (num_regions + 1) KB
329 *
330 * To grant full access to entire 1MB of FLASH:
331 * 2 * (511 + 1) KB = 1024 KB (1 MB)
332 */
333 FLASH_CTRL->DMASZ = 511;
334 }
336 /*
337 * =============================== EMAC ===============================
338 */
339 /* minimize scope of ndk/inc/stk_main.h -- this eliminates TIPOSIX path dependencies */
340 #define NDK_NOUSERAPIS 1
341 #include <ti/drivers/emac/EMACMSP432E4.h>
343 /*
344 * Required by the Networking Stack (NDK). This array must be NULL terminated.
345 * This can be removed if NDK is not used.
346 * Double curly braces are needed to avoid GCC bug #944572
347 * https://bugs.launchpad.net/gcc-linaro/+bug/944572
348 */
349 NIMU_DEVICE_TABLE_ENTRY NIMUDeviceTable[2] = {
350 {
351 /* Default: use Ethernet driver */
352 .init = EMACMSP432E4_NIMUInit
353 },
354 {NULL}
355 };
357 /*
358 * Ethernet MAC address
359 * NOTE: By default (i.e. when each octet is 0xff), the driver reads the MAC
360 * address that's stored in flash. To override this behavior, manually
361 * set the octets of the MAC address you wish to use into the array here:
362 */
363 unsigned char macAddress[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
365 /* EMAC configuration structure */
366 const EMACMSP432E4_HWAttrs EMACMSP432E4_hwAttrs = {
367 .baseAddr = EMAC0_BASE,
368 .intNum = INT_EMAC0,
369 .intPriority = (~0),
370 .led0Pin = EMACMSP432E4_PF0_EN0LED0,
371 .led1Pin = EMACMSP432E4_PF4_EN0LED1,
372 .macAddress = macAddress
373 };
375 /*
376 * =============================== GPIO ===============================
377 */
378 #include <ti/drivers/GPIO.h>
379 #include <ti/drivers/gpio/GPIOMSP432E4.h>
381 /*
382 * Array of Pin configurations
383 * NOTE: The order of the pin configurations must coincide with what was
384 * defined in MSP_EXP432E401Y.h
385 * NOTE: Pins not used for interrupts should be placed at the end of the
386 * array. Callback entries can be omitted from callbacks array to
387 * reduce memory usage.
388 */
389 GPIO_PinConfig gpioPinConfigs[] = {
390 /* Input pins */
391 /* MSP_EXP432E401Y_USR_SW1 */
392 GPIOMSP432E4_PJ0 | GPIO_CFG_IN_PU | GPIO_CFG_IN_INT_RISING,
393 /* MSP_EXP432E401Y_USR_SW2 */
394 GPIOMSP432E4_PJ1 | GPIO_CFG_IN_PU | GPIO_CFG_IN_INT_RISING,
396 /* MSP_EXP432E401Y_SPI_MASTER_READY */
397 GPIOMSP432E4_PM3 | GPIO_DO_NOT_CONFIG,
398 /* MSP_EXP432E401Y_SPI_SLAVE_READY */
399 GPIOMSP432E4_PL0 | GPIO_DO_NOT_CONFIG,
401 /* Output pins */
402 /* MSP_EXP432E401Y_USR_D1 */
403 GPIOMSP432E4_PN1 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW,
404 /* MSP_EXP432E401Y_USR_D2 */
405 GPIOMSP432E4_PN0 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW,
407 /* MSP_EXP432E401Y_SDSPI_CS */
408 GPIOMSP432E4_PC7 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_HIGH,
410 /* Sharp Display - GPIO configurations will be done in the Display files */
411 GPIOMSP432E4_PE5 | GPIO_DO_NOT_CONFIG, /* SPI chip select */
412 GPIOMSP432E4_PC6 | GPIO_DO_NOT_CONFIG, /* LCD power control */
413 GPIOMSP432E4_PE4 | GPIO_DO_NOT_CONFIG, /*LCD enable */
414 };
416 /*
417 * Array of callback function pointers
418 * NOTE: The order of the pin configurations must coincide with what was
419 * defined in MSP_EXP432E401Y.h
420 * NOTE: Pins not used for interrupts can be omitted from callbacks array to
421 * reduce memory usage (if placed at end of gpioPinConfigs array).
422 */
423 GPIO_CallbackFxn gpioCallbackFunctions[] = {
424 NULL, /* MSP_EXP432E401Y_USR_SW1 */
425 NULL, /* MSP_EXP432E401Y_USR_SW2 */
426 NULL, /* MSP_EXP432E401Y_SPI_MASTER_READY */
427 NULL /* MSP_EXP432E401Y_SPI_SLAVE_READY */
428 };
430 /* The device-specific GPIO_config structure */
431 const GPIOMSP432E4_Config GPIOMSP432E4_config = {
432 .pinConfigs = (GPIO_PinConfig *)gpioPinConfigs,
433 .callbacks = (GPIO_CallbackFxn *)gpioCallbackFunctions,
434 .numberOfPinConfigs = sizeof(gpioPinConfigs)/sizeof(GPIO_PinConfig),
435 .numberOfCallbacks = sizeof(gpioCallbackFunctions)/sizeof(GPIO_CallbackFxn),
436 .intPriority = (~0)
437 };
439 /*
440 * =============================== I2C ===============================
441 */
442 #include <ti/drivers/I2C.h>
443 #include <ti/drivers/i2c/I2CMSP432E4.h>
445 I2CMSP432E4_Object i2cMSP432E4Objects[MSP_EXP432E401Y_I2CCOUNT];
447 const I2CMSP432E4_HWAttrs i2cMSP432E4HWAttrs[MSP_EXP432E401Y_I2CCOUNT] = {
448 {
449 .baseAddr = I2C0_BASE,
450 .intNum = INT_I2C0,
451 .intPriority = (~0),
452 .sclPin = I2CMSP432E4_PB2_I2C0SCL,
453 .sdaPin = I2CMSP432E4_PB3_I2C0SDA,
454 .masterCode = 0x08
455 },
456 {
457 .baseAddr = I2C7_BASE,
458 .intNum = INT_I2C7,
459 .intPriority = (~0),
460 .sclPin = I2CMSP432E4_PD0_I2C7SCL,
461 .sdaPin = I2CMSP432E4_PD1_I2C7SDA,
462 .masterCode = 0x09
463 }
464 };
466 const I2C_Config I2C_config[MSP_EXP432E401Y_I2CCOUNT] = {
467 {
468 .fxnTablePtr = &I2CMSP432E4_fxnTable,
469 .object = &i2cMSP432E4Objects[MSP_EXP432E401Y_I2C0],
470 .hwAttrs = &i2cMSP432E4HWAttrs[MSP_EXP432E401Y_I2C0]
471 },
472 {
473 .fxnTablePtr = &I2CMSP432E4_fxnTable,
474 .object = &i2cMSP432E4Objects[MSP_EXP432E401Y_I2C7],
475 .hwAttrs = &i2cMSP432E4HWAttrs[MSP_EXP432E401Y_I2C7]
476 },
477 };
479 const uint_least8_t I2C_count = MSP_EXP432E401Y_I2CCOUNT;
481 /*
482 * =============================== NVS ===============================
483 */
484 #include <ti/drivers/NVS.h>
485 #include <ti/drivers/nvs/NVSMSP432E4.h>
487 #define SECTORSIZE (0x4000)
488 #define NVS_REGIONS_BASE (0xE0000)
489 #define REGIONSIZE (SECTORSIZE * 8)
491 /*
492 * Reserve flash sectors for NVS driver use
493 * by placing an uninitialized byte array
494 * at the desired flash address.
495 */
496 #if defined(__TI_COMPILER_VERSION__)
498 /*
499 * Place uninitialized array at NVS_REGIONS_BASE
500 */
501 #pragma LOCATION(flashBuf, NVS_REGIONS_BASE);
502 #pragma NOINIT(flashBuf);
503 static char flashBuf[REGIONSIZE];
505 #elif defined(__IAR_SYSTEMS_ICC__)
507 /*
508 * Place uninitialized array at NVS_REGIONS_BASE
509 */
510 static __no_init char flashBuf[REGIONSIZE] @ NVS_REGIONS_BASE;
512 #elif defined(__GNUC__)
514 /*
515 * Place the flash buffers in the .nvs section created in the gcc linker file.
516 * The .nvs section enforces alignment on a sector boundary but may
517 * be placed anywhere in flash memory. If desired the .nvs section can be set
518 * to a fixed address by changing the following in the gcc linker file:
519 *
520 * .nvs (FIXED_FLASH_ADDR) (NOLOAD) : AT (FIXED_FLASH_ADDR) {
521 * *(.nvs)
522 * } > REGION_TEXT
523 */
524 __attribute__ ((section (".nvs")))
525 static char flashBuf[REGIONSIZE];
527 #endif
529 NVSMSP432E4_Object nvsMSP432E4Objects[MSP_EXP432E401Y_NVSCOUNT];
531 const NVSMSP432E4_HWAttrs nvsMSP432E4HWAttrs[MSP_EXP432E401Y_NVSCOUNT] = {
532 {
533 .regionBase = (void *) flashBuf,
534 .regionSize = REGIONSIZE,
535 },
536 };
538 const NVS_Config NVS_config[MSP_EXP432E401Y_NVSCOUNT] = {
539 {
540 .fxnTablePtr = &NVSMSP432E4_fxnTable,
541 .object = &nvsMSP432E4Objects[MSP_EXP432E401Y_NVSMSP432E40],
542 .hwAttrs = &nvsMSP432E4HWAttrs[MSP_EXP432E401Y_NVSMSP432E40],
543 },
544 };
546 const uint_least8_t NVS_count = MSP_EXP432E401Y_NVSCOUNT;
548 /*
549 * =============================== Power ===============================
550 */
551 #include <ti/drivers/power/PowerMSP432E4.h>
552 const PowerMSP432E4_Config PowerMSP432E4_config = {
553 .policyFxn = &PowerMSP432E4_sleepPolicy,
554 .enablePolicy = true
555 };
557 /*
558 * =============================== PWM ===============================
559 */
560 #include <ti/drivers/PWM.h>
561 #include <ti/drivers/pwm/PWMMSP432E4.h>
563 PWMMSP432E4_Object pwmMSP432E4Objects[MSP_EXP432E401Y_PWMCOUNT];
565 const PWMMSP432E4_HWAttrs pwmMSP432E4HWAttrs[MSP_EXP432E401Y_PWMCOUNT] = {
566 {
567 .pwmBaseAddr = PWM0_BASE,
568 .pwmOutput = PWM_OUT_0,
569 .pwmGenOpts = PWM_GEN_MODE_DOWN | PWM_GEN_MODE_DBG_RUN,
570 .pinConfig = PWMMSP432E4_PF0_M0PWM0
571 }
572 };
574 const PWM_Config PWM_config[MSP_EXP432E401Y_PWMCOUNT] = {
575 {
576 .fxnTablePtr = &PWMMSP432E4_fxnTable,
577 .object = &pwmMSP432E4Objects[MSP_EXP432E401Y_PWM0],
578 .hwAttrs = &pwmMSP432E4HWAttrs[MSP_EXP432E401Y_PWM0]
579 },
580 };
582 const uint_least8_t PWM_count = MSP_EXP432E401Y_PWMCOUNT;
584 /*
585 * =============================== SDFatFS ===============================
586 */
587 #include <ti/drivers/SD.h>
588 #include <ti/drivers/SDFatFS.h>
590 /*
591 * Note: The SDFatFS driver provides interface functions to enable FatFs
592 * but relies on the SD driver to communicate with SD cards. Opening a
593 * SDFatFs driver instance will internally try to open a SD driver instance
594 * reusing the same index number (opening SDFatFs driver at index 0 will try to
595 * open SD driver at index 0). This requires that all SDFatFs driver instances
596 * have an accompanying SD driver instance defined with the same index. It is
597 * acceptable to have more SD driver instances than SDFatFs driver instances
598 * but the opposite is not supported & the SDFatFs will fail to open.
599 */
600 SDFatFS_Object sdfatfsObjects[MSP_EXP432E401Y_SDFatFSCOUNT];
602 const SDFatFS_Config SDFatFS_config[MSP_EXP432E401Y_SDFatFSCOUNT] = {
603 {
604 .object = &sdfatfsObjects[MSP_EXP432E401Y_SDFatFS0]
605 }
606 };
608 const uint_least8_t SDFatFS_count = MSP_EXP432E401Y_SDFatFSCOUNT;
610 /*
611 * =============================== SD ===============================
612 */
613 #include <ti/drivers/SD.h>
614 #include <ti/drivers/sd/SDSPI.h>
616 SDSPI_Object sdspiObjects[MSP_EXP432E401Y_SDCOUNT];
618 const SDSPI_HWAttrs sdspiHWAttrs[MSP_EXP432E401Y_SDCOUNT] = {
619 {
620 .spiIndex = MSP_EXP432E401Y_SPI2,
621 .spiCsGpioIndex = MSP_EXP432E401Y_SDSPI_CS
622 }
623 };
625 const SD_Config SD_config[MSP_EXP432E401Y_SDCOUNT] = {
626 {
627 .fxnTablePtr = &SDSPI_fxnTable,
628 .object = &sdspiObjects[MSP_EXP432E401Y_SDSPI0],
629 .hwAttrs = &sdspiHWAttrs[MSP_EXP432E401Y_SDSPI0]
630 },
631 };
633 const uint_least8_t SD_count = MSP_EXP432E401Y_SDCOUNT;
635 /*
636 * =============================== SPI ===============================
637 */
638 #include <ti/drivers/SPI.h>
639 #include <ti/drivers/spi/SPIMSP432E4DMA.h>
641 SPIMSP432E4DMA_Object spiMSP432E4DMAObjects[MSP_EXP432E401Y_SPICOUNT];
643 /*
644 * NOTE: The SPI instances below can be used by the SD driver to communicate
645 * with a SD card via SPI. The 'defaultTxBufValue' fields below are set to
646 * (~0) to satisfy the SDSPI driver requirement.
647 */
648 const SPIMSP432E4DMA_HWAttrs spiMSP432E4DMAHWAttrs[MSP_EXP432E401Y_SPICOUNT] = {
649 {
650 .baseAddr = SSI2_BASE,
651 .intNum = INT_SSI2,
652 .intPriority = (~0),
653 .defaultTxBufValue = (~0),
654 .rxDmaChannel = UDMA_CH12_SSI2RX,
655 .txDmaChannel = UDMA_CH13_SSI2TX,
656 .minDmaTransferSize = 10,
657 .clkPinMask = SPIMSP432E4_PD3_SSI2CLK,
658 .fssPinMask = SPIMSP432E4_PD2_SSI2FSS,
659 .xdat0PinMask = SPIMSP432E4_PD1_SSI2XDAT0,
660 .xdat1PinMask = SPIMSP432E4_PD0_SSI2XDAT1
661 },
662 {
663 .baseAddr = SSI3_BASE,
664 .intNum = INT_SSI3,
665 .intPriority = (~0),
666 .defaultTxBufValue = (~0),
667 .minDmaTransferSize = 10,
668 .rxDmaChannel = UDMA_CH14_SSI3RX,
669 .txDmaChannel = UDMA_CH15_SSI3TX,
670 .clkPinMask = SPIMSP432E4_PQ0_SSI3CLK,
671 .fssPinMask = SPIMSP432E4_PQ1_SSI3FSS,
672 .xdat0PinMask = SPIMSP432E4_PQ2_SSI3XDAT0,
673 .xdat1PinMask = SPIMSP432E4_PQ3_SSI3XDAT1
674 }
675 };
677 const SPI_Config SPI_config[MSP_EXP432E401Y_SPICOUNT] = {
678 {
679 .fxnTablePtr = &SPIMSP432E4DMA_fxnTable,
680 .object = &spiMSP432E4DMAObjects[MSP_EXP432E401Y_SPI2],
681 .hwAttrs = &spiMSP432E4DMAHWAttrs[MSP_EXP432E401Y_SPI2]
682 },
683 {
684 .fxnTablePtr = &SPIMSP432E4DMA_fxnTable,
685 .object = &spiMSP432E4DMAObjects[MSP_EXP432E401Y_SPI3],
686 .hwAttrs = &spiMSP432E4DMAHWAttrs[MSP_EXP432E401Y_SPI3]
687 },
688 };
690 const uint_least8_t SPI_count = MSP_EXP432E401Y_SPICOUNT;
692 /*
693 * =============================== Timer ===============================
694 */
695 #include <ti/drivers/Timer.h>
696 #include <ti/drivers/timer/TimerMSP432E4.h>
698 TimerMSP432E4_Object timerMSP432E4Objects[MSP_EXP432E401Y_TIMERCOUNT];
700 const TimerMSP432E4_HWAttrs timerMSP432E4HWAttrs[MSP_EXP432E401Y_TIMERCOUNT] = {
701 {
702 .baseAddress = TIMER2_BASE,
703 .subTimer = TimerMSP432E4_timer32,
704 .intNum = INT_TIMER2A,
705 .intPriority = ~0
706 },
707 {
708 .baseAddress = TIMER1_BASE,
709 .subTimer = TimerMSP432E4_timer16A,
710 .intNum = INT_TIMER1A,
711 .intPriority = ~0
712 },
713 {
714 .baseAddress = TIMER1_BASE,
715 .subTimer = TimerMSP432E4_timer16B,
716 .intNum = INT_TIMER1B,
717 .intPriority = ~0
718 },
719 };
721 const Timer_Config Timer_config[MSP_EXP432E401Y_TIMERCOUNT] = {
722 {
723 .fxnTablePtr = &TimerMSP432E4_fxnTable,
724 .object = &timerMSP432E4Objects[MSP_EXP432E401Y_TIMER0],
725 .hwAttrs = &timerMSP432E4HWAttrs[MSP_EXP432E401Y_TIMER0]
726 },
727 {
728 .fxnTablePtr = &TimerMSP432E4_fxnTable,
729 .object = &timerMSP432E4Objects[MSP_EXP432E401Y_TIMER1],
730 .hwAttrs = &timerMSP432E4HWAttrs[MSP_EXP432E401Y_TIMER1]
731 },
732 {
733 .fxnTablePtr = &TimerMSP432E4_fxnTable,
734 .object = &timerMSP432E4Objects[MSP_EXP432E401Y_TIMER2],
735 .hwAttrs = &timerMSP432E4HWAttrs[MSP_EXP432E401Y_TIMER2]
736 },
737 };
739 const uint_least8_t Timer_count = MSP_EXP432E401Y_TIMERCOUNT;
741 /*
742 * =============================== UART ===============================
743 */
744 #include <ti/drivers/UART.h>
745 #include <ti/drivers/uart/UARTMSP432E4.h>
747 UARTMSP432E4_Object uartMSP432E4Objects[MSP_EXP432E401Y_UARTCOUNT];
748 unsigned char uartMSP432E4RingBuffer[MSP_EXP432E401Y_UARTCOUNT][32];
750 /* UART configuration structure */
751 const UARTMSP432E4_HWAttrs uartMSP432E4HWAttrs[MSP_EXP432E401Y_UARTCOUNT] = {
752 {
753 .baseAddr = UART0_BASE,
754 .intNum = INT_UART0,
755 .intPriority = (~0),
756 .flowControl = UARTMSP432E4_FLOWCTRL_NONE,
757 .ringBufPtr = uartMSP432E4RingBuffer[MSP_EXP432E401Y_UART0],
758 .ringBufSize = sizeof(uartMSP432E4RingBuffer[MSP_EXP432E401Y_UART0]),
759 .rxPin = UARTMSP432E4_PA0_U0RX,
760 .txPin = UARTMSP432E4_PA1_U0TX,
761 .ctsPin = UARTMSP432E4_PIN_UNASSIGNED,
762 .rtsPin = UARTMSP432E4_PIN_UNASSIGNED,
763 .errorFxn = NULL
764 }
765 };
767 const UART_Config UART_config[MSP_EXP432E401Y_UARTCOUNT] = {
768 {
769 .fxnTablePtr = &UARTMSP432E4_fxnTable,
770 .object = &uartMSP432E4Objects[MSP_EXP432E401Y_UART0],
771 .hwAttrs = &uartMSP432E4HWAttrs[MSP_EXP432E401Y_UART0]
772 }
773 };
775 const uint_least8_t UART_count = MSP_EXP432E401Y_UARTCOUNT;
777 /*
778 * =============================== Watchdog ===============================
779 */
780 #include <ti/drivers/Watchdog.h>
781 #include <ti/drivers/watchdog/WatchdogMSP432E4.h>
783 WatchdogMSP432E4_Object watchdogMSP432E4Objects[MSP_EXP432E401Y_WATCHDOGCOUNT];
785 const WatchdogMSP432E4_HWAttrs watchdogMSP432E4HWAttrs[MSP_EXP432E401Y_WATCHDOGCOUNT] = {
786 {
787 .baseAddr = WATCHDOG0_BASE,
788 .intNum = INT_WATCHDOG,
789 .intPriority = (~0),
790 .reloadValue = 80000000 /* 1 second period at default CPU clock freq */
791 },
792 };
794 const Watchdog_Config Watchdog_config[MSP_EXP432E401Y_WATCHDOGCOUNT] = {
795 {
796 .fxnTablePtr = &WatchdogMSP432E4_fxnTable,
797 .object = &watchdogMSP432E4Objects[MSP_EXP432E401Y_WATCHDOG0],
798 .hwAttrs = &watchdogMSP432E4HWAttrs[MSP_EXP432E401Y_WATCHDOG0]
799 },
800 };
802 const uint_least8_t Watchdog_count = MSP_EXP432E401Y_WATCHDOGCOUNT;