STM8S/A Standard Peripherals Firmware Library
|
STM8S_StdPeriph_Examples/GPIO/GPIO_Toggle/main.c
Go to the documentation of this file.
00001 /** 00002 ****************************************************************************** 00003 * @file GPIO_Toggle\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 GPIO Toggle example. 00008 ****************************************************************************** 00009 * @attention 00010 * 00011 * <h2><center>© 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 00031 /** 00032 * @addtogroup GPIO_Toggle 00033 * @{ 00034 */ 00035 00036 /* Private typedef -----------------------------------------------------------*/ 00037 /* Private define ------------------------------------------------------------*/ 00038 /* Evalboard I/Os configuration */ 00039 00040 #define LED_GPIO_PORT (GPIOH) 00041 #define LED_GPIO_PINS (GPIO_PIN_3 | GPIO_PIN_2 | GPIO_PIN_1 | GPIO_PIN_0) 00042 00043 /* Private macro -------------------------------------------------------------*/ 00044 /* Private variables ---------------------------------------------------------*/ 00045 /* Private function prototypes -----------------------------------------------*/ 00046 void Delay (uint16_t nCount); 00047 00048 /* Private functions ---------------------------------------------------------*/ 00049 /* Public functions ----------------------------------------------------------*/ 00050 00051 /** 00052 * @brief Main program. 00053 * @param None 00054 * @retval None 00055 */ 00056 void main(void) 00057 { 00058 00059 /* Initialize I/Os in Output Mode */ 00060 GPIO_Init(LED_GPIO_PORT, (GPIO_Pin_TypeDef)LED_GPIO_PINS, GPIO_MODE_OUT_PP_LOW_FAST); 00061 00062 while (1) 00063 { 00064 /* Toggles LEDs */ 00065 GPIO_WriteReverse(LED_GPIO_PORT, (GPIO_Pin_TypeDef)LED_GPIO_PINS); 00066 Delay(0xFFFF); 00067 } 00068 00069 } 00070 00071 /** 00072 * @brief Delay 00073 * @param nCount 00074 * @retval None 00075 */ 00076 void Delay(uint16_t nCount) 00077 { 00078 /* Decrement nCount value */ 00079 while (nCount != 0) 00080 { 00081 nCount--; 00082 } 00083 } 00084 00085 #ifdef USE_FULL_ASSERT 00086 00087 /** 00088 * @brief Reports the name of the source file and the source line number 00089 * where the assert_param error has occurred. 00090 * @param file: pointer to the source file name 00091 * @param line: assert_param error line source number 00092 * @retval None 00093 */ 00094 void assert_failed(uint8_t* file, uint32_t line) 00095 { 00096 /* User can add his own implementation to report the file name and line number, 00097 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ 00098 00099 /* Infinite loop */ 00100 while (1) 00101 { 00102 } 00103 } 00104 #endif 00105 00106 /** 00107 * @} 00108 */ 00109 00110 00111 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/