main.c

来自「STM8示例程序」· C语言 代码 · 共 110 行

C
110
字号
/**
  ******************************************************************************
  * @file UART3_HyperTerminal_Interrupt\main.c
  * @brief This file contains the main function for UART3 using interrupts in communication 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>&copy; COPYRIGHT 2008 STMicroelectronics</center></h2>
  * @image html logo.bmp
  ******************************************************************************
  */

/* Includes ------------------------------------------------------------------*/
#include "stm8s_lib.h"

/**
  * @addtogroup UART3_HyperTerminal_Interrupt
  * @{
  */
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
/**
  * @brief Example firmware main entry point.
  * @par Parameters:
  * None
  * @retval void None
  * @par Required preconditions:
  * None
  * @par Library functions called:
  * - UART3_DeInit()
  * - UART3_Init()
	* - UART3_Cmd()
  * - UART3_ITConfig()
	* - CLK_HSIPrescalerConfig()
  */
void main(void)
{
    /* Enable general interrupts */
    enableInterrupts();

    /*High speed internal clock prescaler: 1*/
    CLK_HSIPrescalerConfig(CLK_PRESCALER_HSIDIV1);
	
    UART3_DeInit();
    /* UART3 configuration ------------------------------------------------------*/
    /* UART3 configured as follow:
      		- BaudRate = 9600 baud  
          - Word Length = 8 Bits
          - Two Stop Bit
          - Odd parity
          - Receive and transmit enabled
    */
    /* Configure the UART3 */
 		UART3_Init((u32)9600, UART3_WORDLENGTH_8D, UART3_STOPBITS_2, UART3_PARITY_ODD, UART3_MODE_TXRX_ENABLE);

    /* Enable the UART3 Transmit interrupt: this interrupt is generated when the
       UART3 transmit data register is empty */
    UART3_ITConfig(UART3_IT_TXE, ENABLE);

    /* Enable the UART3 Receive interrupt: this interrupt is generated when the
       UART3 receive data register is not empty */
    UART3_ITConfig(UART3_IT_RXNE_OR, ENABLE);

    while (1);
}

/**
  * @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 + =
减小字号Ctrl + -
显示快捷键?