/**
******************************************************************************
* @file GPIO_Toggle\main.c
* @author MCD Application Team
* @version V2.0.1
* @date 18-November-2011
* @brief This file contains the main function for GPIO Toggle example.
******************************************************************************
* @attention
*
* 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 2011 STMicroelectronics</center></h2>
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "stm8s.h"
#include "tm1628.h"
/**
* @addtogroup GPIO_Toggle
* @{
*/
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Evalboard I/Os configuration */
#define LED_GPIO_PORT (GPIOB)
#define LED_GPIO_PINS (GPIO_PIN_5)
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
void Delay (uint16_t nCount);
/* Private functions ---------------------------------------------------------*/
/* Public functions ----------------------------------------------------------*/
/**
* @brief Main program.
* @param None
* @retval None
*/
#define PA3 GPIO_ReadInputPin(GPIOA, (GPIO_Pin_TypeDef)GPIO_PIN_3)
#define PB4_H GPIO_WriteHigh(GPIOC, (GPIO_Pin_TypeDef)GPIO_PIN_7)
#define PB4_L GPIO_WriteLow(GPIOC, (GPIO_Pin_TypeDef)GPIO_PIN_7)
#define PB5_H GPIO_WriteHigh(GPIOC, (GPIO_Pin_TypeDef)GPIO_PIN_6)
#define PB5_L GPIO_WriteLow(GPIOC, (GPIO_Pin_TypeDef)GPIO_PIN_6)
#define PA1_H GPIO_WriteHigh(GPIOC, (GPIO_Pin_TypeDef)GPIO_PIN_5)
#define PA1_L GPIO_WriteLow(GPIOC, (GPIO_Pin_TypeDef)GPIO_PIN_5)
#define PA2_H GPIO_WriteHigh(GPIOC, (GPIO_Pin_TypeDef)GPIO_PIN_4)
#define PA2_L GPIO_WriteLow(GPIOC, (GPIO_Pin_TypeDef)GPIO_PIN_4)
uint8_t g_flag = 0;
/*
按键切换输出:
1)111111 红灯亮
2)222222 绿灯亮
3)333333
4)444444
5)555555
6)8.8.8.8.8.8
*/
//共阴的数码管表格0-f
uchar TAB_duan[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
uchar BUFF_1[14]={0xFF,0xFF,0x00,0x00,0xFF,0xFF,0x00,0x00,0xFF,0xFF,0x00,0x00,0xFF,0xFF};
uchar BUFF_2[14]={0x00,0x00,0xFF,0xFF,0x00,0x00,0xFF,0xFF,0x00,0x00,0xFF,0xFF,0x00,0x00};
uchar BUFF_3[14]={0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA};
uchar BUFF_4[14]={0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55};
void main(void)
{
GPIO_Init(GPIOA, (GPIO_Pin_TypeDef)GPIO_PIN_3,GPIO_MODE_IN_FL_NO_IT);
TM1628_init();
Delay(0XFFFF);
while (1)
{
#if 1
if(PA3)
{
while(PA3);
g_flag++;
}
if(g_flag==1)
{
TM1628_display(BUFF_1);
}
else if(g_flag==2)
{
TM1628_display(BUFF_2); }
else if(g_flag==3)
{
TM1628_display(BUFF_3); }
else if(g_flag==4)
{
TM1628_display(BUFF_4); }
else
{
}
if(g_flag>=4)
{
g_flag=0;
}
#endif
}
}
/**
* @brief Delay
* @param nCount
* @retval None
*/
void Delay(uint16_t nCount)
{
/* Decrement nCount value */
while (nCount != 0)
{
nCount--;
}
}
#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* @param file: pointer to the source file name
* @param line: assert_param error line source number
* @retval None
*/
void assert_failed(uint8_t* file, uint32_t line)
{
/* 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) */
/* Infinite loop */
while (1)
{
}
}
#endif
/**
* @}
*/
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/