📄 main.c
字号:
/**
******************************************************************************
* @file ITC_SoftwarePriority\main.c
* @brief This file contains the main function for the ITC software priority example.
* @author STMicroelectronics - MCD Application Team
* @version V1.0.1
* @date 09/22/2008
******************************************************************************
*
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
* TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*
* <h2><center>© COPYRIGHT 2008 STMicroelectronics</center></h2>
* @image html logo.bmp
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "stm8s_lib.h"
#include "main.h"
/**
* @addtogroup ITC_SoftwarePriority
* @{
*/
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
void Delay (u16 nCount);
/* Private functions ---------------------------------------------------------*/
void Delay(u16 nCount)
{
/* Decrement nCount value */
while (nCount != 0)
{
nCount--;
}
}
/* Private function prototypes -----------------------------------------------*/
/* Public functions ----------------------------------------------------------*/
/**
* @brief Example main entry point.
* @par Parameters:
* None
* @retval void None
* @par Required preconditions:
* None
* @par Library functions called:
* - GPIO_Init()
* - EXTI_SetExtIntSensitivity()
* - ITC_SetSoftwarePriority()
* - enableInterrupts()
* - GPIO_WriteHigh()
*/
void main(void)
{
/* Initialize I/Os in Output Mode for LEDs */
GPIO_Init(LEDS_PORT, LED1_PIN | LED2_PIN, GPIO_MODE_OUT_PP_LOW_FAST);
/* Initialize I/O in Input Mode with Interrupt for button and joystick */
/* Button */
GPIO_Init(BUTTON_PORT, BUTTON_PIN, GPIO_MODE_IN_FL_IT);
/* Joystick */
GPIO_Init(JOYSTICK_PORT, JOYSTICK_DOWN_PIN, GPIO_MODE_IN_FL_IT);
/* Initialize the Interrupt sensitivity for button and joystick */
EXTI_SetExtIntSensitivity(EXTI_PORT_GPIOB, EXTI_SENSITIVITY_FALL_LOW);
EXTI_SetExtIntSensitivity(EXTI_PORT_GPIOC, EXTI_SENSITIVITY_FALL_LOW);
/*
Change the software priority between button and joystick:
- By hardware the PORTB (joystick) has a higher priority than PORTC (button)
- We configure the PORTC (button) to have a higher sw priority than PORTB (joystick)
*/
ITC_SetSoftwarePriority(ITC_IRQ_PORTB, ITC_PRIORITYLEVEL_1); /* joystick */
ITC_SetSoftwarePriority(ITC_IRQ_PORTC, ITC_PRIORITYLEVEL_2); /* button = higher sw priority */
enableInterrupts();
while (1)
{
/* LEDs are ON together */
GPIO_WriteHigh(LEDS_PORT, (LED1_PIN | LED2_PIN));
}
}
/**
* @brief Reports the name of the source file and the source line number where
* the assert error has occurred.
* User can add his own implementation to report the file name and line number.
* ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line)
* @retval void None
* @par Required preconditions:
* None
* @par Called functions:
* None
*/
#ifdef FULL_ASSERT
void assert_failed(u8 *file, u16 line)
#else
void assert_failed(void)
#endif
{
/* Add your own code to manage an assert error */
/* Infinite loop */
while (1)
{
}
}
/**
* @}
*/
/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -