/**
  * @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_stm32f0xx.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f0xx.c file
     */ 

  /* TIM1 Configuration */
  TIM_Config(); 
  
  /* DMA1 Configuration */
  DMA_Config();

  /* Wait until DMA2 Stream5 end of Transfer */
  while (!DMA_GetFlagStatus(DMA1_FLAG_TC5))
  {
  }

  /* Infinite loop */ 
  while(1)
  {
  }
}
Ejemplo n.º 2
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_stm32f0xx.s) before to branch to application main.
  To reconfigure the default setting of SystemInit() function, refer to
  system_stm32f0xx.c file
  */ 
  
  
  /* ADC1 configuration *******************************************************/
  /*  - Enable peripheral clocks                                              */
  /*  - Configure ADC Channel12 pin as analog input                           */
  /*  - Configure ADC1 Channel12                                              */
  ADC_Config();

  /*  DMA1_Cahnnel1  configuration */  
  DMA_Config();
    
  while (1)
  {
    /* Test DMA1 TC flag */
    while((DMA_GetFlagStatus(DMA1_FLAG_TC1)) == RESET ); 
    
    /* Clear DMA TC flag */
    DMA_ClearFlag(DMA1_FLAG_TC1);
    
    /* convert the ADC value (from 0 to 0xFFF) to a voltage value (from 0V to 3.0V)*/
    uwADC1ConvertedVoltage = uhADC1ConvertedValue *3000/0xFFF;
  }
}
Ejemplo n.º 3
0
void Peripheral_Config(void) {
	RCC_Config();
	GPIO_Config();
	USART_Config();
	TIM_Config();
	DMA_Config();
}
Ejemplo n.º 4
0
/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
void main(void)
{
  /* CLK configuration -------------------------------------------*/
  CLK_Config(); 

  /* ADC configuration -------------------------------------------*/
  ADC_Config(); 

  /* DMA configuration -------------------------------------------*/
  DMA_Config(); 

  /* TIM1 configuration -------------------------------------------*/
  TIM1_Config(); 

  /* Enable ADC1 DMA requests*/
  ADC_DMACmd(ADC1, ENABLE);

  /* Enable TIM1 DMA requests*/
  TIM1_DMACmd(TIM1_DMASource_Update, ENABLE);

  /* Start ADC1 Conversion using Software trigger*/
  ADC_SoftwareStartConv(ADC1);

  while (1)
  {}
}
Ejemplo n.º 5
0
Archivo: main.c Proyecto: shjere/common
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /* STM32L0xx HAL library initialization:
       - Configure the Flash prefetch, Flash preread and Buffer 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.
       - Low Level Initialization
     */
  HAL_Init();
  
  /* Configure LED2 */
  BSP_LED_Init(LED2);
  /* Configure the system clock to 2 Mhz */
  SystemClock_Config();

  /* Configure and enable the DMA Stream for Memory to Memory transfer */
  DMA_Config(); 
  
  /* Infinite loop */
  while (1)
  {
  }
}
Ejemplo n.º 6
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 LED3, LED4, and LED5 */
  BSP_LED_Init(LED3);
  BSP_LED_Init(LED4);
  BSP_LED_Init(LED5);

  /* Configure the system clock to 168 MHz */
  SystemClock_Config();     
  
  /* Configure and enable the DMA Stream for Memory to Memory transfer */
  DMA_Config(); 

  /* Infinite loop */
  while (1)
  {
  }
}
Ejemplo n.º 7
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_stm32l1xx_xx.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32l1xx.c file
     */     

  /* Fill Sine12bit table */
  for (Idx = 0; Idx < 32; Idx++)
  {
    DualSine12bit[Idx] = (Sine12bit[Idx] << 16) + (Sine12bit[Idx]);
  }

  /* DMA1 channel3 configuration: DualSine12bit is used as memory base address */
  DMA_Config();

  /* DAC configuration ------------------------------------------------------*/
  DAC_Config();

  /* TIM2 configuration ------------------------------------------------------*/
  TIM_Config();

  while (1)
  {
  }
}
Ejemplo n.º 8
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
       files (startup_stm32f40xx.s/startup_stm32f427x.s) before to branch to 
       application main. 
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f4xx.c file
     */     

  /* Configure LEDs to monitor program status */
  STM_EVAL_LEDInit(LED1);
  STM_EVAL_LEDInit(LED2);
  STM_EVAL_LEDInit(LED3);
  STM_EVAL_LEDInit(LED4);
  
  STM_EVAL_LEDOn(LED1); /* Turn LED1 on: start of configuration */
  
  /* Configure and enable the DMA Stream for Memory to Memory transfer */
  DMA_Config();

  STM_EVAL_LEDOn(LED2); /* Turn LED2 on: start of Transfer */
  
  /* Wait the end of transmission (the DMA Stream is disabled by Hardware at the 
     end of the transfer) .
     There is also another way to check on end of transfer by monitoring the 
     number of remaining data to be transferred. */
  /* while (DMA_GetCurrentMemoryTarget(DMA_STREAM) != 0) */   /* First method */
  while (DMA_GetCmdStatus(DMA_STREAM) != DISABLE)           /* Second method */
  {
    /*
       Since this code present a simple example of how to use DMA, it is just
       waiting on the end of transfer.
       But, while DMA Stream is transferring data, the CPU is free to perform 
       other tasks in parallel to the DMA transfer.
    */
  }
   
  /* Check if the transmitted and received data are equal */
  TransferStatus = Buffercmp(aSRC_Const_Buffer, aDST_Buffer, BUFFER_SIZE);
  /* TransferStatus = PASSED, if the transmitted and received data 
     are the same */
  /* TransferStatus = FAILED, if the transmitted and received data 
     are different */

  if (TransferStatus != FAILED)
  {
    /* Turn LED4 on: Transfer correct */
    STM_EVAL_LEDOn(LED4);
  }
  
  while (1)
  {
  }
}
Ejemplo n.º 9
0
/**
  * @brief   Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  ADC_CommonInitTypeDef ADC_CommonInitStructure;
  
  /*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       files (startup_stm32f40_41xxx.s/startup_stm32f427_437xx.s/startup_stm32f429_439xx.s)
       before to branch to application main. 
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f4xx.c file
     */

  /* Enable peripheral clocks *************************************************/
  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2, ENABLE);
  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE);
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE);
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC2, ENABLE);
    
  /* DMA2 Stream0 channel0 configuration **************************************/
  DMA_Config();
  
  /* ADCs configuration ------------------------------------------------------*/
  /* Configure ADC Channel10, 11, 12 pin as analog input */
  GPIO_Config();

  /* ADC Common Init */
  ADC_CommonInitStructure.ADC_Mode = ADC_DualMode_RegSimult;
  ADC_CommonInitStructure.ADC_Prescaler = ADC_Prescaler_Div2;
  ADC_CommonInitStructure.ADC_DMAAccessMode = ADC_DMAAccessMode_1;
  ADC_CommonInitStructure.ADC_TwoSamplingDelay = ADC_TwoSamplingDelay_5Cycles;
  ADC_CommonInit(&ADC_CommonInitStructure);

  /* ADC1 regular channels 10, 11 configuration */
  ADC1_CH10_CH11_Config();

  /* ADC2 regular channels 11, 12 configuration */
  ADC2_CH11_CH12_Config();

  /* Enable DMA request after last transfer (Multi-ADC mode)  */
  ADC_MultiModeDMARequestAfterLastTransferCmd(ENABLE);

  /* Enable ADC1 */
  ADC_Cmd(ADC1, ENABLE);

  /* Enable ADC2 */
  ADC_Cmd(ADC2, ENABLE);

  /* Start ADC1 Software Conversion */
  ADC_SoftwareStartConv(ADC1);

  while (1)
  {
  }
}
Ejemplo n.º 10
0
void Sys_Init()
{
	NVIC_Config();
	Usart1_Config();
	DMA_Config();
	SPI1_Init();
	Nrf24l01_Init(3,40);
	LED_Config();
	LED_OFF();
//	I2C_MPU_Init();
//	MPU6050_Init();
}
Ejemplo n.º 11
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /* Configure the MPU attributes as Write Through */
  MPU_Config();

  /* Enable the CPU Cache */
  CPU_CACHE_Enable();

  /* STM32F7xx HAL library initialization:
       - Configure the Flash prefetch
       - 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
     */
  HAL_Init();

  /* Configure the system clock to 216 MHz */
  SystemClock_Config();

  /* Initialize LED */
  BSP_LED_Init(LED1);

  /* Set to 1 if an transfer error is detected */
  transferErrorDetected = 0;
  transferCompleteDetected = 0;

  /* Configure and enable the DMA stream for Memory to Memory transfer */
  DMA_Config();

  /* Infinite loop */
  while (1)
  {
    if (transferErrorDetected == 1)
    {
      /* Toggle LED1 with a period of 200 ms */
      BSP_LED_Toggle(LED1);
      HAL_Delay(200);
      transferErrorDetected = 0;
    }
    if (transferCompleteDetected == 1)
    {
      /* Turn LED1 on*/
      BSP_LED_On(LED1);
      transferCompleteDetected = 0;
    } 
  }
}
Ejemplo n.º 12
0
/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
void main(void)
{

   /* CLK configuration -------------------------------------------*/
  CLK_Config(); 

  /* Init the Eval board LCD */
  STM8_EVAL_LCD_Init();

  /* Clear  LCD */
  LCD_Clear();

  /* Print the Voltage on the LCD*/
  LCD_SetCursorPos(LCD_LINE1, 0);
  LCD_Print("  POT      BNC  ");

   /* ADC configuration -------------------------------------------*/
  ADC_Config();

   /* DMA configuration -------------------------------------------*/
  DMA_Config();
    
  /* Enable ADC1 DMA requests*/
  ADC_DMACmd(ADC1, ENABLE);

  /* Start ADC1 Conversion using TIM1 TRGO*/
  ADC_ExternalTrigConfig(ADC1, ADC_ExtEventSelection_Trigger2,
                         ADC_ExtTRGSensitivity_Rising);

  /* Master Mode selection: Update event */
  TIM1_SelectOutputTrigger(TIM1_TRGOSource_Update);

  /* Enable TIM1 */
  TIM1_Cmd(ENABLE);

  /* Enable Interrupts */
  enableInterrupts();

  /* Infinite loop*/
  while (1)
  {
    if (DisplayStatus != DISABLE)
    {
      /* Display Potentiometer RV and BNC voltage values on LCD*/
      ShowVoltages(PotVoltage, BNCVoltage);
      /* Disable displaying voltages on LCD until next DMA Channel0 Transfer complete occurs */
      DisplayStatus = DISABLE;
    }
  }
}
Ejemplo n.º 13
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /* STM32F103xG HAL library initialization:
       - Configure the Flash prefetch
       - 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
     */
  HAL_Init();

  /* Configure the system clock to 72 MHz */
  SystemClock_Config();

  /* Initialize LEDs */
  BSP_LED_Init(LED1);
  BSP_LED_Init(LED2);
  BSP_LED_Init(LED3);

  /* Set to 1 if an transfer error is detected */
  transferErrorDetected = 0;
  transferCompleteDetected = 0;

  /* Configure and enable the DMA channel for Memory to Memory transfer */
  DMA_Config();

  /* Infinite loop */
  while (1)
  {
    if (transferErrorDetected == 1)
    {
      /* Turn LED2 on*/
      BSP_LED_On(LED2);
      transferErrorDetected = 0;
    }
    if (transferCompleteDetected == 1)
    {
      /* Turn LED1 on*/
      BSP_LED_On(LED1);
      transferCompleteDetected = 0;
    } 
 }
}
Ejemplo n.º 14
0
void vidInit(void)
{
	/*Populate DMA_TEST*/
	//int i=0;
	//int a=0xFF;
	
	/*for(i=0; i<100;i++){
		if(i%2 != 0)
		DMA_TEST[0][i]=a;
	}*/
	
	vidClearScreen();
	TIM8_Init();
	TIM_Configuration();
	DMA_Config();
	//TIM5_Init();
	
	
}
Ejemplo n.º 15
0
/*******************************************************************************
* Function Name: main
********************************************************************************
*
* Summary:
*  Main function performs following functions:
*   1: Enables global interrupts
*   2: Start all components on the schematic
*   3: Calls a function to configure DMA

* Parameters:
*  None.
*
* Return:
*  None.
*
*******************************************************************************/
int main()
{
    /* Start all components used on schematic */
    ADC_DelSig_IRQ_Start();
    //isr_StartEx(filterVDAC);
    ADC_DelSig_Start();
    ADC_DelSig_StartConvert();
    VDAC8_Start();
    //Opamp_Start();
    Filter_Start();

    /* User-implemented function to set-up DMA */
    DMA_Config();

    /* Enable Global Interrupts */
    CYGlobalIntEnable;

    for(;;)
    {
    }
} /* End of main */
Ejemplo n.º 16
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_stm32l1xx_xx.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32l1xx.c file
     */     

  /* Initialize Leds and Key Button mounted on STM3210X-EVAL board */       
  STM_EVAL_LEDInit(LED1);
  STM_EVAL_LEDInit(LED2);
  STM_EVAL_LEDInit(LED3);
  STM_EVAL_LEDInit(LED4);
  STM_EVAL_PBInit(BUTTON_KEY, BUTTON_MODE_EXTI); 

  /* DMA Channel 6 or 3 configuration ----------------------------------------------*/
  DMA_Config();

  /* EVAL COM1 configuration --------------------------------------------------*/
  USART_Config();  
    
  while (1)
  {
    if(LowPowerMode == 1)
    {
      /* Turn Off LED2 and LED3 */
      STM_EVAL_LEDOff(LED2);
      STM_EVAL_LEDOff(LED3);

      /* Request to enter WFI mode */
      __WFI();
      LowPowerMode = 0;
    }

    Delay(0xFFFFF);
    STM_EVAL_LEDToggle(LED1);
  }

}
Ejemplo n.º 17
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_stm32f30x.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f30x.c file
       */
  
  /* DMA1 channel1 configuration */
  DMA_Config();
  
  /* TIM3 channel3 configuration */
  TIM3_Config();
  
  /* ADC channel7 configuration */
  ADC_Config();
  
  while (1)
  {
  }
}
Ejemplo n.º 18
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /* STM32L0xx HAL library initialization:
       - Configure the Flash prefetch, Flash preread and Buffer 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.
       - Low Level Initialization
     */
  HAL_Init();
  
  /* Configure LED3 */
  BSP_LED_Init(LED3);
  /* Configure the system clock to 2 Mhz */
  SystemClock_Config();

  /* Configure and enable the DMA Stream for Memory to Memory transfer */
  DMA_Config(); 
  
  /* Suspend Tick increment to prevent wakeup by Systick interrupt.         */
  /* Otherwise the Systick interrupt will wake up the device within 1ms     */
  /* (HAL time base).                                                       */
  HAL_SuspendTick();

  /* Enter sleep mode and wait for DMA interrupt */
  HAL_PWR_EnterSLEEPMode(PWR_LOWPOWERREGULATOR_ON, PWR_SLEEPENTRY_WFI);

  /* Resume Tick interrupt if disabled prior to SLEEP mode entry */
  HAL_ResumeTick();

  /* Infinite loop */
  while (1)
  {
  }
}
Ejemplo n.º 19
0
int main(void)
{
    //uint16_t kezdet, vege;
    vSemaphoreCreateBinary(xADCSemaphore);
    RCC_Config();

    IO_Init();
    UART_Config();
    PWM_Config();
    DMA_Config();
    I2C_Config();
    NVIC_Config();
    DebugTimerInit();

    xTaskCreate(prvInitTask,(signed char*)"INIT", configMINIMAL_STACK_SIZE,NULL,TASK_INIT_PRIORITY,NULL);

    vTaskStartScheduler();
    while (1)
    {



    }
}
Ejemplo n.º 20
0
HIF_RESULT hif_dma_read_internal(HIF_HANDLE handle, HIF_TYPE type, kal_uint32 addr, kal_uint32 size, HIF_CALLBACK fCB)
{
    HIF_RESULT result = HIF_RESULT_OK;
    HIF_INTERNAL_HANDLE_T* pHandle = (HIF_INTERNAL_HANDLE_T*) handle;
    kal_uint32 retrieved_events;
    // Enable HIF interrupt.
    ENABLE_HIF_INTR(pHandle->engine_id);
    pHandle->DMA_BUSY = KAL_TRUE;
    #ifdef MTK_SLEEP_ENABLE
    L1SM_SleepDisable(hif_sleepMode_handle[pHandle->engine_id]);//unlock MD sleep mode
    #endif
    
    if (fCB == NULL)
    {
      if(!(kal_if_lisr()||kal_if_hisr()))
        {
          //Clear the evnet for pHandle->engine_id HIF for task level
          kal_set_eg_events(hif_events, ~(1 << pHandle->engine_id), KAL_AND);
        }
      else 
      ASSERT(0); //HIF DMA blocking mode is not allowed in LISR or HISR
    }
    // Setup HIF.
    //SET_HIF_BUS_WIDTH(pHandle->engine_id, pHandle->config.hif_bus_width);
    SET_HIF_READ(pHandle->engine_id);
    if(type == HIF_TYPE_A0H_DMA)
    {
      SET_HIF_A0_HIGH(pHandle->engine_id);
    }
    else if(type == HIF_TYPE_A0L_DMA)
    {	
      SET_HIF_A0_LOW(pHandle->engine_id);
    }
    SET_HIF_DAMOUNT(pHandle->engine_id, size);
/*              // Set DMA address.
    PDMA_SET_BUF_ADDR(pHandle->engine_id, addr);
    PDMA_SET_RW_DIRECTION(pHandle->engine_id, 1); // 1:read; 0: write
    PDMA_SET_BUF_LEN(pHandle->engine_id, size);
    PDMA_SET_BURST_LEN(pHandle->engine_id, 7);

    PDMA_START(pHandle->engine_id); //Start DMA
*/
    //dma config
    SLA_CustomLogging("HDM",1);//set for debug
    #if (defined(MT6752) && !defined(__ANDROID_MODEM__))
    hif_dma_menu[pHandle->engine_id].addr = addr + 0x80000000;
    #else
    hif_dma_menu[pHandle->engine_id].addr = addr;
    #endif
    hif_dma_input[pHandle->engine_id].count  = (pHandle->config.hif_bus_width == 16) ? (size >> 1) : size;
    hif_dma_input[pHandle->engine_id].type = DMA_HWRX;
    hif_dma_input[pHandle->engine_id].size = (pHandle->config.hif_bus_width == 16) ? DMA_SHORT : DMA_BYTE;
    hif_dma_input[pHandle->engine_id].callback = NULL;
    hif_dma_input[pHandle->engine_id].menu = (void*) &hif_dma_menu[pHandle->engine_id];
    DMA_Config(hif_sysdma_id[pHandle->engine_id], &hif_dma_input[pHandle->engine_id], KAL_TRUE);

    // Set fCB as HIF interrupt callback.
    hif_cb[pHandle->engine_id] = fCB;

    // Start HIF
    START_HIF(pHandle->engine_id);
    if (fCB == NULL)
    {
      if(!(kal_if_lisr()||kal_if_hisr()))
      {
        kal_retrieve_eg_events(hif_events, (1<<pHandle->engine_id), KAL_OR_CONSUME, &retrieved_events, KAL_SUSPEND);
            	      pHandle->DMA_BUSY = KAL_FALSE;
      }
      else 
        ASSERT(0); //HIF DMA blocking mode is not allowed in LISR or HISR
    }	
   return result;
}
Ejemplo n.º 21
0
/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
void main(void)
{
  uint32_t index = 0;

   /* CLK configuration -------------------------------------------*/
  CLK_Config(); 
 
  /* Set the MOSI and SCK at high level */
  GPIO_ExternalPullUpConfig(GPIOB, GPIO_Pin_6 | GPIO_Pin_5, ENABLE);

#ifdef USE_STM8L1526_EVAL
  /* Set USART CK at high level */
  GPIO_ExternalPullUpConfig(GPIOC, GPIO_Pin_4, ENABLE);
#else /* USE_STM8L1528_EVAL is defined */
  /* Set USART CK at high level */
  GPIO_ExternalPullUpConfig(GPIOH, GPIO_Pin_6, ENABLE);
#endif  /* USE_STM8L1526_EVAL */

   /* USART configuration -------------------------------------------*/
  USART_Config(); 
  
   /* SPI configuration -------------------------------------------*/
  SPI_Config(); 
  
  /*Disable USART the master*/
  USART_Cmd(EVAL_COM1, DISABLE);

   /* DMA configuration -------------------------------------------*/
  DMA_Config(); 
 
  /* Enable USART */
  USART_Cmd(EVAL_COM1, ENABLE);

  /* Insert Delay to ensure Synchro w/ SPI */
  for (index = 0; index < 0xFF; index++);

  /* Enable SPI */
  SPI_Cmd(SPI1, ENABLE);

  USART_ITConfig(EVAL_COM1, USART_IT_TC, ENABLE);

  /* Wait until Data transmitted to SPI*/
  while (UsartTransferStatus != 2);
  /* Wait the SPI DMA Rx transfer complete */
  while (DMA_GetFlagStatus((DMA_FLAG_TypeDef)SPI_DMA_FlagTCRx) == RESET);


  /* Check the correctness of written dada */
  TransferStatus1 = Buffercmp((uint8_t*)RxBuffer1, SPIBuffer_Rx, RX_BUFFER_SIZE);
  /* TransferStatus1 = PASSED, if the received data by USART and received data
    by SPI1 are the same */
  /* TransferStatus1 = FAILED, if the received data by USART and received data
     by SPI1 are different */

  if (TransferStatus1 != FAILED)
  {
    for (index = 0; index < MESSAGE2_SIZE; index++)
    {
      /* Wait while USART TC = 0 */
      while (USART_GetFlagStatus(EVAL_COM1, USART_FLAG_TC) == RESET);
      /* Send on byte from stm8l15x USART to HyperTerminal */
      USART_SendData8(EVAL_COM1, Message2[index]);
    }
  }
  else
  {
    for (index = 0; index < MESSAGE3_SIZE; index++)
    {
      /* Wait while USART TC = 0 */
      while (USART_GetFlagStatus(EVAL_COM1, USART_FLAG_TC) == RESET);
      /* Send on byte from stm8l15x USART to HyperTerminal */
      USART_SendData8(EVAL_COM1, Message3[index]);
    }
  }

  while (1)
  {}
}
Ejemplo n.º 22
0
/**************************************************************/
//程 序 名: Adc_Init()
//开 发 者: chenhonglin
//入口参数: 无
//功能说明: ADC所有外设初始化
//**************************************************************/
void  Adc_Init(void)
{
	ADC_Config();
	DMA_Config();
}