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

STM8S/A

STM8S_StdPeriph_Examples/EXTI/EXTI_InterruptPriority/main.c
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    EXTI_InterruptPriority\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 EXTI Interrupt Priority 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 "main.h"
00031 
00032 /**
00033   * @addtogroup EXTI_InterruptPriority
00034   * @{
00035   */
00036 
00037 /* Private typedef -----------------------------------------------------------*/
00038 /* Private define ------------------------------------------------------------*/
00039 /* Public functions ----------------------------------------------------------*/
00040 /* Private function prototypes -----------------------------------------------*/
00041 static void GPIO_Config(void);
00042 /* Private functions ---------------------------------------------------------*/
00043 
00044 /**
00045   * @brief  Main program.
00046   * @param  None
00047   * @retval None
00048   */
00049 void main(void)
00050 {
00051 
00052   /* GPIO Configuration  -----------------------------------------*/
00053   GPIO_Config();  
00054   
00055   /* Initialize the Interrupt sensitivity */
00056   EXTI_SetExtIntSensitivity(EXTI_PORT_GPIOB, EXTI_SENSITIVITY_FALL_ONLY);
00057   EXTI_SetTLISensitivity(EXTI_TLISENSITIVITY_FALL_ONLY);
00058   
00059   enableInterrupts();
00060 
00061   while (1)
00062   {
00063     /* The LED toggles in the interrupt routines */
00064   }
00065 
00066 }
00067 
00068 /**
00069   * @brief  Configure GPIO for buttons and Leds available on the evaluation board
00070   * @param  None
00071   * @retval None
00072   */
00073 static void GPIO_Config(void)
00074 {
00075   /* Initialize I/Os in Output Mode for LEDs */
00076   GPIO_Init(LEDS_PORT, (GPIO_Pin_TypeDef)(LED1_PIN | LED2_PIN | LED3_PIN | LED4_PIN),
00077             GPIO_MODE_OUT_PP_HIGH_FAST);
00078 
00079   /* Initialize I/O in Input Mode with Interrupt for Joystick */
00080   GPIO_Init(JOYSTICK_PORT, (GPIO_Pin_TypeDef)(JOYSTICK_LEFT_PIN|JOYSTICK_RIGHT_PIN|JOYSTICK_UP_PIN|JOYSTICK_DOWN_PIN),
00081             GPIO_MODE_IN_FL_IT);
00082   
00083   GPIO_Init(JOYSTICK_SEL_PORT, JOYSTICK_SEL_PIN, GPIO_MODE_IN_FL_IT);
00084 }
00085 
00086 #ifdef USE_FULL_ASSERT
00087 
00088 /**
00089   * @brief  Reports the name of the source file and the source line number
00090   *   where the assert_param error has occurred.
00091   * @param file: pointer to the source file name
00092   * @param line: assert_param error line source number
00093   * @retval None
00094   */
00095 void assert_failed(uint8_t* file, uint32_t line)
00096 { 
00097   /* User can add his own implementation to report the file name and line number,
00098      ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
00099 
00100   /* Infinite loop */
00101   while (1)
00102   {
00103   }
00104 }
00105 #endif
00106 
00107 /**
00108   * @}
00109   */
00110 
00111 
00112 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
STM8 Standard Peripherals Library: Footer

 

 

 

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