/* * ======== dmaErrorHwi ======== */ static void dmaErrorHwi(uintptr_t arg) { DebugP_log1("DMA error code: %d\n", MAP_DMA_getErrorStatus()); MAP_DMA_clearErrorStatus(); DebugP_log0("DMA error!!\n"); while(1); }
/* * ======== MSP_EXP432P401R_initDMA ======== */ void MSP_EXP432P401R_initDMA(void) { HwiP_Params hwiParams; HwiP_Handle dmaErrorHwiHandle; if (!dmaInitialized) { HwiP_Params_init(&hwiParams); dmaErrorHwiHandle = HwiP_create(INT_DMA_ERR, dmaErrorHwi, &hwiParams); if (dmaErrorHwiHandle == NULL) { DebugP_log0("Failed to create DMA error Hwi!!\n"); while (1); } MAP_DMA_enableModule(); MAP_DMA_setControlBase(dmaControlTable); dmaInitialized = true; } }
/* * ======== WatchdogMSP432_open ======== */ Watchdog_Handle WatchdogMSP432_open(Watchdog_Handle handle, Watchdog_Params *params) { uintptr_t key; HwiP_Params hwiParams; WatchdogMSP432_Object *object = handle->object; WatchdogMSP432_HWAttrs const *hwAttrs = handle->hwAttrs; /* If params are NULL use defaults. */ if (params == NULL) { params = (Watchdog_Params *) &Watchdog_defaultParams; } /* Ensure a callbackFxn is specified if using watchdog in interval mode */ DebugP_assert((params->resetMode == Watchdog_RESET_ON) || (params->callbackFxn != NULL)); /* Don't allow preemption */ key = HwiP_disable(); /* Check if the Watchdog is open already with the HWAttrs */ if (object->isOpen) { HwiP_restore(key); DebugP_log1("Watchdog: Handle %x already in use.", (uintptr_t) handle); return (NULL); } object->isOpen = true; HwiP_restore(key); /* * Add power management support - Disable performance transitions while * opening the driver. */ Power_setConstraint(PowerMSP432_DISALLOW_PERF_CHANGES); if (params->resetMode == Watchdog_RESET_ON || hwAttrs->clockSource == WDT_A_CLOCKSOURCE_SMCLK || hwAttrs->clockSource == WDT_A_CLOCKSOURCE_ACLK) { /* * Do not support power modes lower than LPM0 if in watchdog mode or * in interval mode and using SMCLK or ACLK as clock sources. * Additionally, LPM3.5 cannot be reached. */ Power_setConstraint(PowerMSP432_DISALLOW_DEEPSLEEP_0); Power_setConstraint(PowerMSP432_DISALLOW_SHUTDOWN_0); } else { /* * Interval mode and not using SMCLK and ACLK as clock sources. Can * be configured as a LPM3.5 wake up source, so we do not set the * SHUTDOWN_0 constraint. */ Power_setConstraint(PowerMSP432_DISALLOW_DEEPSLEEP_1); } /* SHUTDOWN_1 (LPM4.5) not supported while driver is open */ Power_setConstraint(PowerMSP432_DISALLOW_SHUTDOWN_1); /* Construct Hwi object for watchdog */ if (params->callbackFxn) { HwiP_Params_init(&hwiParams); hwiParams.arg = (uintptr_t) handle; hwiParams.priority = hwAttrs->intPriority; object->hwiHandle = HwiP_create(hwAttrs->intNum, params->callbackFxn, &hwiParams); if (!object->hwiHandle) { DebugP_log0("Watchdog: HwiP_create() failed"); Power_releaseConstraint(PowerMSP432_DISALLOW_PERF_CHANGES); WatchdogMSP432_close(handle); return (NULL); } } /* Configure and initialize WDT */ object->resetMode = params->resetMode; if (object->resetMode == Watchdog_RESET_ON) { MAP_WDT_A_initWatchdogTimer(hwAttrs->clockSource, hwAttrs->clockDivider); } else { MAP_WDT_A_initIntervalTimer(hwAttrs->clockSource, hwAttrs->clockDivider); } MAP_WDT_A_startTimer(); /* Allow performance level changes */ Power_releaseConstraint(PowerMSP432_DISALLOW_PERF_CHANGES); DebugP_log1("Watchdog: (0x%x) opened and enabled.", (uintptr_t) handle); /* Return handle of the Watchdog object */ return (handle); }