STM8S/A Standard Peripherals Firmware Library: main.c Source File

STM8S/A

STM8S_StdPeriph_Examples/ADC2/ADC2_ContinuousConversion/main.c
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    ADC2_ContinuousConversion\main.c
00004   * @author  MCD Application Team
00005   * @version  V2.2.0
00006   * @date     30-September-2014
00007   * @brief   This file contains the main function for the ADC2 Continuous Conversion example.
00008   ******************************************************************************
00009   * @attention
00010   *
00011   * <h2><center>&copy; COPYRIGHT 2014 STMicroelectronics</center></h2>
00012   *
00013   * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
00014   * You may not use this file except in compliance with the License.
00015   * You may obtain a copy of the License at:
00016   *
00017   *        http://www.st.com/software_license_agreement_liberty_v2
00018   *
00019   * Unless required by applicable law or agreed to in writing, software 
00020   * distributed under the License is distributed on an "AS IS" BASIS, 
00021   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00022   * See the License for the specific language governing permissions and
00023   * limitations under the License.
00024   *
00025   ******************************************************************************
00026   */ 
00027 
00028 /* Includes ------------------------------------------------------------------*/
00029 #include "stm8s.h"
00030 #include "stm8s_eval.h"
00031 
00032 /**
00033   * @addtogroup ADC2_ContinuousConversion
00034   * @{
00035   */
00036 
00037 /* Private typedef -----------------------------------------------------------*/
00038 /* Private define ------------------------------------------------------------*/
00039 uint16_t Conversion_Value = 0;
00040 /* Private function prototypes -----------------------------------------------*/
00041 static void ADC_Config(void);
00042 static void GPIO_Config(void);
00043 /* Private functions ---------------------------------------------------------*/
00044 
00045 /**
00046   * @brief ADC2_ContinuousConversion  main entry point.
00047   * @param  None
00048   * @retval None
00049   */
00050 void main(void)
00051 {
00052   /* GPIO configuration ------------------------------------------*/
00053   GPIO_Config();
00054 
00055   /* ADC configuration -------------------------------------------*/
00056   ADC_Config();
00057      
00058   /* The LEDs state is changed in the interrupt routine */
00059   while (1);
00060 }
00061 
00062 /**
00063   * @brief  Configure ADC2 Continuous Conversion with End Of Conversion interrupt 
00064   *         enabled .
00065   * @param  None
00066   * @retval None
00067   */
00068 static void ADC_Config()
00069 {
00070   /*  Init GPIO for ADC2 */
00071   GPIO_Init(GPIOE, GPIO_PIN_6, GPIO_MODE_IN_FL_NO_IT);
00072   
00073   /* De-Init ADC peripheral*/
00074   ADC2_DeInit();
00075 
00076   /* Init ADC2 peripheral */
00077   ADC2_Init(ADC2_CONVERSIONMODE_CONTINUOUS, ADC2_CHANNEL_9, ADC2_PRESSEL_FCPU_D2, \
00078             ADC2_EXTTRIG_TIM, DISABLE, ADC2_ALIGN_RIGHT, ADC2_SCHMITTTRIG_CHANNEL9,\
00079             DISABLE);
00080 
00081   /* Enable EOC interrupt */
00082   ADC2_ITConfig(ENABLE);
00083 
00084   /* Enable general interrupts */  
00085   enableInterrupts();
00086   
00087   /*Start Conversion */
00088   ADC2_StartConversion();
00089 }
00090 
00091 /**
00092   * @brief  Configure GPIO for LEDs and buttons available on the evaluation board
00093   * @param  None
00094   * @retval None
00095   */
00096 static void GPIO_Config(void)
00097 {
00098     /* Initialize LEDs mounted on STM8-128 EVAL board */
00099     STM_EVAL_LEDInit(LED1);
00100     STM_EVAL_LEDInit(LED2);
00101     STM_EVAL_LEDInit(LED3);
00102     STM_EVAL_LEDInit(LED4);
00103 
00104 }
00105  
00106 #ifdef USE_FULL_ASSERT
00107 
00108 /**
00109   * @brief  Reports the name of the source file and the source line number
00110   *   where the assert_param error has occurred.
00111   * @param file: pointer to the source file name
00112   * @param line: assert_param error line source number
00113   * @retval None
00114   */
00115 void assert_failed(uint8_t* file, uint32_t line)
00116 { 
00117   /* User can add his own implementation to report the file name and line number,
00118      ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
00119 
00120   /* Infinite loop */
00121   while (1)
00122   {
00123   }
00124 }
00125 #endif
00126 
00127 /**
00128   * @}
00129   */
00130 
00131 
00132 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
STM8 Standard Peripherals Library: Footer

 

 

 

      For complete documentation on STM8 8-bit Microcontrollers platform visit www.st.com