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

STM8S/A

STM8S_StdPeriph_Examples/ITC/ITC_SoftwarePriority/main.c
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    ITC_SoftwarePriority\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 ITC software 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 "stm8s_eval.h"
00031 
00032 /**
00033   * @addtogroup ITC_SoftwarePriority
00034   * @{
00035   */
00036 
00037 /* Private typedef -----------------------------------------------------------*/
00038 /* Private define ------------------------------------------------------------*/
00039 /* Private function prototypes -----------------------------------------------*/
00040 void GPIO_Config(void);
00041 void ITC_Config(void);
00042 void Delay (uint16_t nCount);
00043 /* Private functions ---------------------------------------------------------*/
00044 /* Public functions ----------------------------------------------------------*/
00045 
00046 /**
00047   * @brief Example main entry point.
00048   * @param  None
00049   * @retval None
00050   */
00051 void main(void)
00052 {
00053   
00054     /* GPIO Configuration  -----------------------------------------*/
00055     GPIO_Config();  
00056     
00057     /* ITC Configuration  -----------------------------------------*/
00058     ITC_Config();  
00059 
00060   while (1)
00061   {}
00062 }
00063 
00064 /**
00065   * @brief  Configure GPIO for buttons and LEDs available on the evaluation board
00066   * @param  None
00067   * @retval None
00068   */
00069 void GPIO_Config(void)
00070 {
00071   
00072   /* Configure GPIO to drive LEDs on Eval board */
00073   STM_EVAL_LEDInit(LED1);
00074   STM_EVAL_LEDInit(LED2);
00075   
00076   /* LED1 & LED2 are on oer default */
00077   STM_EVAL_LEDOn(LED1);
00078   STM_EVAL_LEDOn(LED2);
00079   
00080   /* Configure GPIO used to drive the joystick Down and the Key button */
00081     STM_EVAL_PBInit(BUTTON_KEY, BUTTON_MODE_EXTI);
00082     STM_EVAL_PBInit(BUTTON_DOWN, BUTTON_MODE_EXTI);
00083 }
00084 
00085 /**
00086   * @brief  Change the software priority between Key button and joystick Down
00087   * @param  None
00088   * @retval None
00089   */
00090 void ITC_Config(void)
00091 {
00092   /*
00093     Change the software priority between button and joystick:
00094     - By hardware the PORTB (joystick) has a higher priority than PORTC (button)
00095     - We configure the PORTC (button) to have a higher sw priority than PORTB (joystick)
00096   */
00097   ITC_SetSoftwarePriority(ITC_IRQ_PORTB, ITC_PRIORITYLEVEL_1); /* joystick Down*/
00098   ITC_SetSoftwarePriority(ITC_IRQ_PORTC, ITC_PRIORITYLEVEL_2); /* button = higher sw priority */
00099   
00100   enableInterrupts();
00101 }
00102 
00103 
00104 /**
00105   * @brief Delay.
00106   * @param nCount
00107   * @retval None
00108    */
00109 void Delay(uint16_t nCount)
00110 {
00111     /* Decrement nCount value */
00112     while (nCount != 0)
00113     {
00114         nCount--;
00115     }
00116 }
00117 
00118 #ifdef USE_FULL_ASSERT
00119 
00120 /**
00121   * @brief  Reports the name of the source file and the source line number
00122   *   where the assert_param error has occurred.
00123   * @param file: pointer to the source file name
00124   * @param line: assert_param error line source number
00125   * @retval None
00126   */
00127 void assert_failed(uint8_t* file, uint32_t line)
00128 { 
00129   /* User can add his own implementation to report the file name and line number,
00130      ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
00131 
00132   /* Infinite loop */
00133   while (1)
00134   {
00135   }
00136 }
00137 #endif
00138 
00139 /**
00140   * @}
00141   */
00142 
00143 
00144 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
STM8 Standard Peripherals Library: Footer

 

 

 

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