Ejemplo n.º 1
0
/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
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_stm32f072xb.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f0xx.c file
  
     PLL is set to x12 with  a PREDIV /2 so the system clock SYSCLK = 48MHz
     */

  ConfigureGPIO();
  SetClockForADC();
  CalibrateADC(); 
  ConfigureGPIOforADC();
  EnableADC();
  ConfigureADC();
  ConfigureDMA();
  ADC1->CR |= ADC_CR_ADSTART; /* start the ADC conversions */
  GPIOC->BSRR = (1<<9); /* switch on the green led */    
  __WFI(); /* No interrupt should occur, as only error could trigger an interrupt */ 
  GPIOC->BRR = (1<<9); /* switch off the green led */
  DisableADC();
  SysTick_Config(48000); /* 1ms config */
  while (1) /* Infinite loop */
  {
  }
}
Ejemplo n.º 2
0
/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
int main(void)
{
  uint32_t x;
  /*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       file (startup_stm32f072xb.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f0xx.c file
     */

  /* initialization of the tables values for DAC signal generations */
  for (x = 0; x < SIN1_ARRAY_SIZE; x++)
  {
    sin1_data[x] = (uint32_t) GenerateWave(INCREMENT1, DAC_AMPL_MAX); /* as the DAC buffer are enabled */
    sin1_data[x] += sin1_data[x] << 16;
  }
  
  ConfigureGPIO();
  ConfigureGPIOasAnalog();
  ConfigureDAC();
  ConfigureDMA();
  ConfigureTIM7();
  __WFI(); /* If an error occurs or the execution is stop by debugger, the wait mode is exited */
  SysTick_Config(48000); /* 1ms config */
  while (1) /* Infinite loop only reach in case of error */
  {    
  }
}
Ejemplo n.º 3
0
/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
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_stm32f072xb.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f0xx.c file
  
     PLL is set to x12 with  a PREDIV /2 so the system clock SYSCLK = 48MHz
     */
  ConfigureGPIO();
  ConfigureExternalIT();
  RCC->APB2ENR = RCC_APB2ENR_ADC1EN; /* Enable the peripheral clock of the ADC */
  RCC->CFGR |= RCC_CFGR_PPRE_2; /* Set peripheral prescaler to /2 so PCLK = HCLK/2 = 24MHz */
  CalibrateADC(); 
  EnableADC();
  ConfigureADC();
  ConfigureDMA();
  ADC1->CR |= ADC_CR_ADSTART; /* Start the ADC conversions */
      
  while (error < ERROR_UNEXPECTED_DMA_IT) /* loop till no unrecoverable error */
  {
    __WFI();
  }
  
  DisableADC();
  SysTick_Config(48000); /* 1ms config */
  while (1) /* Infinite loop */
  {
  }
}
Ejemplo n.º 4
0
status_t
ATAPIDevice::Configure()
{
	if (fInfoBlock.word_0.atapi.atapi_device != ATA_WORD_0_ATAPI_DEVICE) {
		TRACE_ERROR("infoblock indicates non-atapi device\n");
		return B_ERROR;
	}

	fTaskFile.packet.lun = 0;

	status_t result = ConfigureDMA();
	if (result != B_OK)
		return result;

	result = DisableCommandQueueing();
	if (result != B_OK)
		return result;

	return B_OK;
}
Ejemplo n.º 5
0
/**
  * @brief  Main function. Executes all initialization and terminate its thread.
  * @param  None
  * @retval None
  */
int main(void)
{	
  ///////////////////////////////////////////////////////////////////////////////////////////
  /* Configure the MPU attributes as Write Through */
  MPU_Config();
  /* Enable the CPU Cache */
  CPU_CACHE_Enable();
	// initialize CMSIS-RTOS
  osKernelInitialize();
	///////////////////////////////////////////////////////////////////////////////////////////
	// Hardware initialize
  if( HAL_Init() != HAL_OK)
		Error_Handler();
	if( ConfigureDMA(&g_DmaHandle, &g_AdcHandle) != HAL_OK)
		Error_Handler();
	if( ADC_INIT(&g_AdcHandle) != HAL_OK)
		Error_Handler();
	
	BSP_SDRAM_Init();
	Touch_Initialize();
	///////////////////////////////////////////////////////////////////////////////////////////
  /* Configure the System clock to have a frequency of 216 MHz */
  SystemClock_Config();
	// Thread initialization
	Init_TH_GUI();
	Init_TH_Touch();
	// RTOS Start Kernel
  osKernelStart();                      // start thread execution 
	// Get Main Thread ID
	Main_thID = osThreadGetId();
	///////////////////////////////////////////////////////////////////////////////////////////
	// Start data acquire
	HAL_ADC_Start_DMA(&g_AdcHandle, values, ADC_BUFFER_LENGTH);
	///////////////////////////////////////////////////////////////////////////////////////////
	// Terminate main thread
	osThreadTerminate(Main_thID);
	/* Infinite loop */
  while (1) {  }
}
Ejemplo n.º 6
0
/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
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_stm32f072xb.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f0xx.c file
     */
  ConfigureGPIO();
  SysTick_Config(48000);/* 1ms config */    
  ConfigureTIMxAsPWM_Input();
  ConfigureDMA();
  GPIOC->BSRR = 1<<9; /* switch on green led */
  while (error < ERROR_UNEXPECTED_DMA_IT)  
  {  
    __WFI();
  }
  GPIOC->BRR = 1<<9; /* switch off green led */  
  while (1) /* Infinite loop */
  {
  }    
}