void SSI3DMASlaveClass::begin() { ROM_SysCtlPeripheralClockGating(true); configureSSI3(); configureDMA(); configureCSInterrupt(); }
//----------------------------------- // Start/Stop/configure this singleton //----------------------------------- void METH(setParameter)(void * bufferTx, t_uint16 bufferSizeInSample, t_uint16 nbMspChannelEnabled, t_uint16 target) { mNbMspChannelEnabled = nbMspChannelEnabled; // MAINTAIN BOTH COUNTERS ALIGNED ! param_buffer_tx = getLogicalParameterPtr(getLogicalChannel(MSP_AB8500_TX, MSP_TX)); mTxBuffer = bufferTx; mTxBufferSize = 48 * nbMspChannelEnabled; mTxBufferArmAddr = getArmPhysicalAddr(mTxBuffer); load_prcmu_pointers(target); mTarget = target; configureMspRegs(STOPPED); resetDefaultTxBuffer(); // Configure DMA common stuff configureDMA(); mIsConfigured = 1; }
void start_DMA_MSP(t_uint16 samplerate){ if(mStartCount) { return; } mStartCount++; //resetMSP(MSP0); // reset shoud NOT be called EVER mspReg->WMRK = 0x9; // Init Rx mspReg->IMSC |= 0x2; // mask for msp overrun IT mspReg->RCF = 0x2007; // 1 elements of 32 bits, RDDLY=1 MSB first mspReg->DMACR |= 0x1; mspReg->MCR |= 0x1; mspReg->RCE0 = 0x3; mspReg->GCR |= 0x202UL; // enable fifos // Init Tx mspReg->IMSC |= 0x20UL; // mask for msp underrun IT mspReg->TCF = 0x0000007; // 1 elements of 32 bits, TDDLY=1 MSB first mspReg->DMACR |= 0x2UL; mspReg->MCR |= 0x20UL; mspReg->TCE0 = 0x3UL; //mspReg->IODLY |= 0x00020UL; // works with or without mspReg->GCR |= 0x155A50UL; // this is mandatory if (samplerate == 8000) mspReg->SRG |= 0x1F004A; // internal bitclk = 19.2MHz/75 = 256 KHz (needed 256 KHZ = 2x16x8KHz), width = 1 bclk,frame periode = 32 bclk else mspReg->SRG = 0x27001D; // SCKDIV=30, width = 1 bclk,frame periode = 40 bclk. internal bitclk = 19.2MHz/30/40 = 16 KHz // Remap Msp0 Tc interrupt // Async_IT[1] = mmdsp_IT[17] = MSP0_RX_TC // Async_IT[11] = mmdsp_IT[37] = MSP0_TX_TC ITREMAP_interf_reg28 = 37; ITREMAP_interf_reg26 = 17; ITREMAP_interf_reg17 = 26; configureDMA(); AUDIO_UNMASK_IT(30); }
int main(void) { /*!< At this stage the microcontroller clock setting is already configured, this is done through SystemInit() function which is called from startup file (startup_stm32l1xx_md.s) before to branch to application main. To reconfigure the default setting of SystemInit() function, refer to system_stm32l1xx.c file */ /* Configure Clocks for Application need */ RCC_Configuration(); /* Configure RTC Clocks */ RTC_Configuration(); /* Set internal voltage regulator to 1.8V */ PWR_VoltageScalingConfig(PWR_VoltageScaling_Range1); /* Wait Until the Voltage Regulator is ready */ while (PWR_GetFlagStatus(PWR_FLAG_VOS) != RESET) ; /* Enable debug features in low power modes (Sleep, STOP and STANDBY) */ #ifdef DEBUG_SWD_PIN DBGMCU_Config(DBGMCU_SLEEP | DBGMCU_STOP | DBGMCU_STANDBY, ENABLE); #endif /* Configure SysTick IRQ and SysTick Timer to generate interrupts */ RCC_GetClocksFreq(&RCC_Clocks); SysTick_Config(RCC_Clocks.HCLK_Frequency / 500); /* Init I/O ports */ Init_GPIOs(); /* Initializes the LCD glass */ LCD_GLASS_Configure_GPIO(); LCD_GLASS_Init(); /* Display Welcome message */ LCD_GLASS_ScrollSentence(" ** TEMPERATURE SENSOR EXAMPLE ** ",1,SCROLL_SPEED); /* Disable SysTick IRQ and SysTick Timer */ SysTick->CTRL &= ~ ( SysTick_CTRL_TICKINT_Msk | SysTick_CTRL_ENABLE_Msk ); /* Test user or factory temperature sensor calibration value */ if ( testFactoryCalibData() == SUCCESS ) getFactoryTSCalibData(&calibdata); else if ( testUserCalibData() == SUCCESS ) calibdata = *USER_CALIB_DATA; else { /* User calibration or factory calibration TS data are not available */ calibdata.TS_CAL_1 = DEFAULT_COLD_VAL; calibdata.TS_CAL_2 = DEFAULT_HOT_VAL; writeCalibData(&calibdata); calibdata = *USER_CALIB_DATA; } /* Configure Wakeup from sleep using RTC event*/ configureWakeup(); /* Configure direct memory access for ADC usage*/ configureDMA(); /* Configure ADC for temperature sensor value conversion */ configureADC_Temp(); while(1) { /* Re-enable DMA and ADC conf and start Temperature Data acquisition */ acquireTemperatureData(); /* Stay in SLEEP mode untill the data are acquired by ADC */ __WFI(); /* for DEBUG purpose uncomment the following line and comment the __WFI call to do not enter STOP mode */ // while (!flag_ADCDMA_TransferComplete); /* Disable ADC, DMA and clock*/ powerDownADC_Temper(); /* Process mesured Temperature data - calculate average temperature value in °C */ processTempData(); if (flag_UserButton == TRUE) { clearUserButtonFlag(); if (CurrentlyDisplayed == Display_TemperatureDegC) CurrentlyDisplayed = Display_ADCval; else CurrentlyDisplayed = Display_TemperatureDegC; } if (CurrentlyDisplayed == Display_TemperatureDegC) { /* print average temperature value in °C */ sprintf(strDisp, "%d °C", temperature_C ); } else { /* print result of ADC conversion */ sprintf(strDisp, "> %d", tempAVG ); } LCD_GLASS_Clear(); LCD_GLASS_DisplayString( (unsigned char *) strDisp ); /* Enable RTC Wakeup */ RTC_WakeUpCmd(ENABLE); /* Clear WakeUp flag */ PWR_ClearFlag(PWR_FLAG_WU); /* Enter in wait for interrupt stop mode*/ PWR_EnterSTOPMode(PWR_Regulator_LowPower, PWR_STOPEntry_WFI); RCC_Configuration(); // reinitialize clock /* After Wake up : Disable Wake up from RTC*/ RTC_WakeUpCmd(DISABLE); } }