Esempio n. 1
0
void Flanger(q31_t* pData, void *opaque){
    struct Flanger_t *tmp = (struct Flanger_t*)opaque;
    q31_t bData[256];
    q31_t fData[256];
    int32_t relativeBlock = 0;

    arm_copy_q31(pData, fData, SAMPLE_NUM);
    arm_scale_q31(pData, (q31_t)(0.5 * Q_1), Q_MULT_SHIFT, pData, SAMPLE_NUM);

    relativeBlock = (tmp->blockPtr - (uint32_t)(tmp->lfo.next(&(tmp->lfo))));

    if(relativeBlock < 0)
        relativeBlock += 400;

    BSP_SDRAM_ReadData(tmp->baseAddress + relativeBlock * 4 * SAMPLE_NUM, (uint32_t*)bData, SAMPLE_NUM);

    arm_scale_q31(bData, (q31_t)(0.5 * Q_1), Q_MULT_SHIFT, bData, SAMPLE_NUM);
    arm_add_q31(pData, bData, pData, SAMPLE_NUM);

    arm_scale_q31(bData, tmp->cache, Q_MULT_SHIFT, bData, SAMPLE_NUM);
    arm_add_q31(fData, bData, fData, SAMPLE_NUM);

    BSP_SDRAM_WriteData(tmp->baseAddress + tmp->blockPtr * SAMPLE_NUM * 4, (uint32_t*)fData, SAMPLE_NUM);

    tmp->blockPtr++;
    if(tmp->blockPtr >= 400)
        tmp->blockPtr = 0;

    return;
}
Esempio n. 2
0
/**
  * @brief  SDRAM Demo
  * @param  None
  * @retval None
  */
void SDRAM_demo (void)
{

  SDRAM_SetHint();

  /* SDRAM device configuration */
  if(BSP_SDRAM_Init() != SDRAM_OK)
  {
    BSP_LCD_DisplayStringAt(20, 115, (uint8_t *)"SDRAM Initialization : FAILED.", LEFT_MODE);
    BSP_LCD_DisplayStringAt(20, 130, (uint8_t *)"SDRAM Test Aborted.", LEFT_MODE);
  }
  else
  {
    BSP_LCD_DisplayStringAt(20, 100, (uint8_t *)"SDRAM Initialization : OK.", LEFT_MODE);
  }
  /* Fill the buffer to write */
  Fill_Buffer(sdram_aTxBuffer, SDRAM_BUFFER_SIZE, 0xA244250F);

  /* Write data to the SDRAM memory */
  if(BSP_SDRAM_WriteData(SDRAM_WRITE_READ_ADDR + WRITE_READ_ADDR_OFFSET, sdram_aTxBuffer, SDRAM_BUFFER_SIZE) != SDRAM_OK)
  {
    BSP_LCD_DisplayStringAt(20, 115, (uint8_t *)"SDRAM WRITE : FAILED.", LEFT_MODE);
    BSP_LCD_DisplayStringAt(20, 130, (uint8_t *)"SDRAM Test Aborted.", LEFT_MODE);
  }
  else
  {
    BSP_LCD_DisplayStringAt(20, 115, (uint8_t *)"SDRAM WRITE : OK.", LEFT_MODE);
  }

  /* Read back data from the SDRAM memory */
  if(BSP_SDRAM_ReadData(SDRAM_WRITE_READ_ADDR + WRITE_READ_ADDR_OFFSET, sdram_aRxBuffer, SDRAM_BUFFER_SIZE) != SDRAM_OK)
  {
    BSP_LCD_DisplayStringAt(20, 130, (uint8_t *)"SDRAM READ : FAILED.", LEFT_MODE);
    BSP_LCD_DisplayStringAt(20, 145, (uint8_t *)"SDRAM Test Aborted.", LEFT_MODE);
  }
  else
  {
    BSP_LCD_DisplayStringAt(20, 130, (uint8_t *)"SDRAM READ : OK.", LEFT_MODE);
  }

  if(Buffercmp(sdram_aTxBuffer, sdram_aRxBuffer, SDRAM_BUFFER_SIZE) > 0)
  {
    BSP_LCD_DisplayStringAt(20, 145, (uint8_t *)"SDRAM COMPARE : FAILED.", LEFT_MODE);
    BSP_LCD_DisplayStringAt(20, 160, (uint8_t *)"SDRAM Test Aborted.", LEFT_MODE);
  }
  else
  {
    BSP_LCD_DisplayStringAt(20, 145, (uint8_t *)"SDRAM Test : OK.", LEFT_MODE);
  }

  while (1)
  {
    if(CheckForUserInput() > 0)
    {
      BSP_SDRAM_DeInit();
      return;
    }
  }
}
Esempio n. 3
0
void Delay(q31_t* pData, void *opaque){
    struct Delay_t *tmp = (struct Delay_t*)opaque;
    q31_t bData[256];

    int32_t relativeBlock = (tmp->blockPtr - (uint32_t)(tmp->delayTime.value / (BLOCK_PERIOD)));
    if(relativeBlock < 0)
        relativeBlock += 400;

    BSP_SDRAM_ReadData(tmp->baseAddress + relativeBlock * SAMPLE_NUM * 4, (uint32_t*)bData, SAMPLE_NUM);

    arm_scale_q31(bData, tmp->cache, Q_MULT_SHIFT,  bData, SAMPLE_NUM);
    arm_add_q31(pData, bData, pData, SAMPLE_NUM);

    BSP_SDRAM_WriteData(tmp->baseAddress + tmp->blockPtr * SAMPLE_NUM * 4, (uint32_t*)pData, SAMPLE_NUM);

    tmp->blockPtr++;
    if(tmp->blockPtr >= 400)
        tmp->blockPtr = 0;

    return;
}
Esempio n. 4
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{    
  /* STM32F4xx HAL library initialization:
       - Configure the Flash prefetch, instruction and Data caches
       - Configure the Systick to generate an interrupt each 1 msec
       - Set NVIC Group Priority to 4
       - Global MSP (MCU Support Package) initialization
     */
  HAL_Init();
  
  /* Configure the system clock to 180 MHz */
  SystemClock_Config();
  
  /* Configure LED1, LED2, LED3 and LED4 */
  BSP_LED_Init(LED1);
  BSP_LED_Init(LED2); 
  BSP_LED_Init(LED3);
  BSP_LED_Init(LED4);
  
  /* WAKEUP button (EXTI_Line0) will be used to wakeup the system from STOP mode */
  BSP_PB_Init(BUTTON_WAKEUP, BUTTON_MODE_EXTI);
  
  /* Configure Key Button */
  BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_GPIO);
  
  /*##-1- Configure the SDRAM device #########################################*/
  /* SDRAM device configuration */ 
  BSP_SDRAM_Init();  
    
  /*##-2- SDRAM memory write access ##########################################*/  
  /* Fill the buffer to write */
  Fill_Buffer(aTxBuffer, BUFFER_SIZE, 0xA244250F);
  
  /* Write data to the SDRAM memory */
  BSP_SDRAM_WriteData(SDRAM_DEVICE_ADDR + WRITE_READ_ADDR, aTxBuffer, BUFFER_SIZE);
  
  /* Wait for TAMPER/KEY to be pushed to enter stop mode */
  while(BSP_PB_GetState(BUTTON_TAMPER) != RESET)
  {
  }  

  /*##-3- Issue self-refresh command to SDRAM device #########################*/ 
  SDRAMCommandStructure.CommandMode            = FMC_SDRAM_CMD_SELFREFRESH_MODE;
  SDRAMCommandStructure.CommandTarget          = FMC_SDRAM_CMD_TARGET_BANK1;
  SDRAMCommandStructure.AutoRefreshNumber      = 1;
  SDRAMCommandStructure.ModeRegisterDefinition = 0;
  
  if(BSP_SDRAM_Sendcmd(&SDRAMCommandStructure) != HAL_OK) 
  {
    /* Command send Error */
    Error_Handler(); 
  }
   
  /*##-4- Enter CPU power stop mode ##########################################*/   
  /* Put LED4 on to indicate entering to STOP mode */
  BSP_LED_On(LED4);  
                        
  /* Request to enter STOP mode */
  HAL_PWR_EnterSTOPMode(PWR_MAINREGULATOR_ON, PWR_STOPENTRY_WFI);
  
  /*##-5- Wakeup CPU from  power stop mode ###################################*/  
  /* Configure the system clock after wakeup from STOP: enable HSE, PLL and select 
       PLL as system clock source (HSE and PLL are disabled in STOP mode) */
  SystemClock_Config();
  
  /*##-6- SDRAM memory read back access ######################################*/
  SDRAMCommandStructure.CommandMode = FMC_SDRAM_CMD_NORMAL_MODE;
  
  if(BSP_SDRAM_Sendcmd(&SDRAMCommandStructure) != HAL_OK) 
  {
    /* Command send Error */
    Error_Handler(); 
  }

  /* Read back data from the SDRAM memory */
  BSP_SDRAM_ReadData(SDRAM_DEVICE_ADDR + WRITE_READ_ADDR, aRxBuffer, BUFFER_SIZE); 

  /*##-7- Checking data integrity ############################################*/    
  uwWriteReadStatus = Buffercmp(aTxBuffer, aRxBuffer, BUFFER_SIZE);

  if (uwWriteReadStatus != PASSED)
  {
    /* KO */
    /* Turn on LED2 */
    BSP_LED_On(LED2);     
  }
  else
  { 
    /* OK */
    /* Turn on LED1 */
    BSP_LED_On(LED1);
  }

  /* Infinite loop */  
  while (1)
  {
  }
}
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /* STM32F4xx HAL library initialization:
       - Configure the Flash prefetch, instruction and Data caches
       - Systick timer is configured by default as source of time base, but user 
         can eventually implement his proper time base source (a general purpose 
         timer for example or other time source), keeping in mind that Time base 
         duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and 
         handled in milliseconds basis.
       - Set NVIC Group Priority to 4
       - Low Level Initialization: global MSP (MCU Support Package) initialization
     */
  HAL_Init();

  /* Configure the system clock to 180 MHz */
  SystemClock_Config();
  
  /* Configure LED1 and LED3 */
  BSP_LED_Init(LED1);
  BSP_LED_Init(LED3);

  /* Configure Key Button */
  BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_GPIO);

  /*##-1- Configure the SDRAM device #########################################*/
  /* SDRAM device configuration */
  BSP_SDRAM_Init();

  /*##-2- SDRAM memory read/write access #####################################*/
 /* Fill the buffer to write */
  Fill_Buffer(aTxBuffer, BUFFER_SIZE, 0xA244250F);

	/* Write data to the SDRAM memory */
  BSP_SDRAM_WriteData(SDRAM_DEVICE_ADDR + WRITE_READ_ADDR, aTxBuffer, BUFFER_SIZE);

  /* Wait for TAMPER/KEY to be pressed to enter stop mode */
  while(BSP_PB_GetState(BUTTON_TAMPER) != GPIO_PIN_SET){}
  /* Wait for TAMPER/KEY to be released */
  while(BSP_PB_GetState(BUTTON_TAMPER) != GPIO_PIN_RESET){}

  /*##-3- Issue self-refresh command to SDRAM device #########################*/
  SDRAMCommandStructure.CommandMode            = FMC_SDRAM_CMD_SELFREFRESH_MODE;
  SDRAMCommandStructure.CommandTarget          = FMC_SDRAM_CMD_TARGET_BANK1;
  SDRAMCommandStructure.AutoRefreshNumber      = 1;
  SDRAMCommandStructure.ModeRegisterDefinition = 0;

  if(BSP_SDRAM_Sendcmd(&SDRAMCommandStructure) != HAL_OK)
  {
    /* Command send Error */
    Error_Handler();
  }

  /*##-4- Enter CPU power stop mode ##########################################*/
  /* Put LED1 and LED3 on to indicate entering to STOP mode */
  BSP_LED_On(LED1);
  BSP_LED_On(LED3);

  /* WAKEUP button (EXTI15_10) will be used to wakeup the system from STOP mode */
  BSP_PB_Init(BUTTON_TAMPER, BUTTON_MODE_EXTI);

  /* Request to enter STOP mode */
  HAL_PWR_EnterSTOPMode(PWR_MAINREGULATOR_ON, PWR_STOPENTRY_WFI);

  /*##-5- Wakeup CPU from  power stop mode ###################################*/
  /* Configure the system clock after wakeup from STOP: enable HSE, PLL and select
       PLL as system clock source (HSE and PLL are disabled in STOP mode) */
  SystemClock_Config();

  /* Put LED1 and LED3 off to indicate exiting from STOP mode */
  BSP_LED_Off(LED1);
  BSP_LED_Off(LED3);

  /*##-6- SDRAM memory read back access ######################################*/
  SDRAMCommandStructure.CommandMode = FMC_SDRAM_CMD_NORMAL_MODE;

  if(BSP_SDRAM_Sendcmd(&SDRAMCommandStructure) != HAL_OK)
  {
    /* Command send Error */
    Error_Handler();
  }

  /* Read back data from the SDRAM memory */
  BSP_SDRAM_ReadData(SDRAM_DEVICE_ADDR + WRITE_READ_ADDR, aRxBuffer, BUFFER_SIZE);

  /*##-7- Checking data integrity ############################################*/
  uwWriteReadStatus = Buffercmp(aTxBuffer, aRxBuffer, BUFFER_SIZE);

  if (uwWriteReadStatus != PASSED)
  {
    /* KO */
    /* Turn on LED3 */
    BSP_LED_On(LED3);
  }
  else
  {
    /* OK */
    /* Turn on LED1 */
    BSP_LED_On(LED1);
  }

  /* Infinite loop */
  while (1)
  {
  }
}