This commit is contained in:
2025-05-13 04:55:13 +03:00
parent 3f693566bd
commit ceb6d0ccec
4364 changed files with 2897163 additions and 0 deletions
@@ -0,0 +1,217 @@
#include "KEY&LED.h"
#define USER_KEY_Port GPIOF
#define USER_KEY_Pin GPIO_Pin_10
#define USER_KEY_RCC_AHBPeriph RCC_AHB1Periph_GPIOF
/****************************************************************/
#define WAKEUP_KEY_Port GPIOA
#define WAKEUP_KEY_Pin GPIO_Pin_0
#define WAKEUP_KEY_RCC_AHBPeriph RCC_AHB1Periph_GPIOA
/****************************************************************/
#define JOY_A_KEY_Port GPIOE
#define JOY_A_KEY_Pin GPIO_Pin_2
#define JOY_A_KEY_RCC_AHBPeriph RCC_AHB1Periph_GPIOE
#define JOY_B_KEY_Port GPIOE
#define JOY_B_KEY_Pin GPIO_Pin_3
#define JOY_B_KEY_RCC_AHBPeriph RCC_AHB1Periph_GPIOE
#define JOY_C_KEY_Port GPIOE
#define JOY_C_KEY_Pin GPIO_Pin_4
#define JOY_C_KEY_RCC_AHBPeriph RCC_AHB1Periph_GPIOE
#define JOY_D_KEY_Port GPIOE
#define JOY_D_KEY_Pin GPIO_Pin_5
#define JOY_D_KEY_RCC_AHBPeriph RCC_AHB1Periph_GPIOE
#define JOY_CTR_KEY_Port GPIOE
#define JOY_CTR_KEY_Pin GPIO_Pin_6
#define JOY_CTR_KEY_RCC_AHBPeriph RCC_AHB1Periph_GPIOE
/****************************************************************/
#define LED1_Port GPIOH
#define LED1_Pin GPIO_Pin_2
#define LED1_RCC_AHBPeriph RCC_AHB1Periph_GPIOH
#define LED2_Port GPIOH
#define LED2_Pin GPIO_Pin_3
#define LED2_RCC_AHBPeriph RCC_AHB1Periph_GPIOH
#define LED3_Port GPIOI
#define LED3_Pin GPIO_Pin_8
#define LED3_RCC_AHBPeriph RCC_AHB1Periph_GPIOI
#define LED4_Port GPIOI
#define LED4_Pin GPIO_Pin_10
#define LED4_RCC_AHBPeriph RCC_AHB1Periph_GPIOI
static void Delay(__IO uint32_t nCount);
void JOYState_LED_GPIO_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
/* GPIOF Periph clock enable */
RCC_AHB1PeriphClockCmd(LED1_RCC_AHBPeriph | LED2_RCC_AHBPeriph | LED3_RCC_AHBPeriph | LED4_RCC_AHBPeriph, ENABLE);
/* Configure PF6 PF7 PF8 PF9 in output pushpull mode */
GPIO_InitStructure.GPIO_Pin = LED1_Pin;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(LED1_Port, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = LED2_Pin;
GPIO_Init(LED2_Port, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = LED3_Pin;
GPIO_Init(LED3_Port, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = LED4_Pin;
GPIO_Init(LED4_Port, &GPIO_InitStructure);
/*--------------------------------------------------------------------------------
Key GPIO Config
--------------------------------------------------------------------------------*/
/* Periph clock enable */
RCC_AHB1PeriphClockCmd(USER_KEY_RCC_AHBPeriph | WAKEUP_KEY_RCC_AHBPeriph | JOY_A_KEY_RCC_AHBPeriph |
JOY_B_KEY_RCC_AHBPeriph | JOY_C_KEY_RCC_AHBPeriph | JOY_D_KEY_RCC_AHBPeriph |
JOY_CTR_KEY_RCC_AHBPeriph, ENABLE);
/* Configure Input pushpull mode */
GPIO_InitStructure.GPIO_Pin = USER_KEY_Pin;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(USER_KEY_Port, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = WAKEUP_KEY_Pin;
GPIO_Init(WAKEUP_KEY_Port, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = JOY_A_KEY_Pin;
GPIO_Init(JOY_A_KEY_Port, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = JOY_B_KEY_Pin;
GPIO_Init(JOY_B_KEY_Port, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = JOY_C_KEY_Pin;
GPIO_Init(JOY_C_KEY_Port, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = JOY_D_KEY_Pin;
GPIO_Init(JOY_D_KEY_Port, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = JOY_CTR_KEY_Pin;
GPIO_Init(JOY_CTR_KEY_Port, &GPIO_InitStructure);
}
uint8_t Read_JOYState(void)
{
if(!GPIO_ReadInputDataBit(USER_KEY_Port,USER_KEY_Pin))
return 0;
else if(!GPIO_ReadInputDataBit(WAKEUP_KEY_Port,WAKEUP_KEY_Pin))
return 1;
else if(!GPIO_ReadInputDataBit(JOY_A_KEY_Port,JOY_A_KEY_Pin))
return 2;
else if(!GPIO_ReadInputDataBit(JOY_B_KEY_Port,JOY_B_KEY_Pin))
return 3;
else if(!GPIO_ReadInputDataBit(JOY_C_KEY_Port,JOY_C_KEY_Pin))
return 4;
else if(!GPIO_ReadInputDataBit(JOY_D_KEY_Port,JOY_D_KEY_Pin))
return 5;
else if(!GPIO_ReadInputDataBit(JOY_CTR_KEY_Port,JOY_CTR_KEY_Pin))
return 6;
return 6;
}
void Led_Toggle(uint8_t keyvulua)
{
switch(keyvulua)
{
case 0:
GPIO_SetBits(LED4_Port , LED4_Pin);
Delay(0x1fffff);
GPIO_ResetBits(LED4_Port , LED4_Pin);
Delay(0x1fffff);
break;
case 1:
GPIO_SetBits(LED1_Port , LED1_Pin);
Delay(0x1fffff);
GPIO_ResetBits(LED1_Port , LED1_Pin);
Delay(0x1fffff);
break;
case 2:
GPIO_SetBits(LED2_Port , LED2_Pin);
Delay(0x1fffff);
GPIO_ResetBits(LED2_Port , LED2_Pin);
Delay(0x1fffff);
break;
case 3:
GPIO_SetBits(LED3_Port , LED3_Pin);
Delay(0x1fffff);
GPIO_ResetBits(LED3_Port , LED3_Pin);
Delay(0x1fffff);
break;
case 4:
GPIO_SetBits(LED1_Port , LED1_Pin);
GPIO_SetBits(LED2_Port , LED2_Pin);
GPIO_SetBits(LED3_Port , LED3_Pin);
GPIO_SetBits(LED4_Port , LED4_Pin);
Delay(0x1fffff);
GPIO_ResetBits(LED1_Port , LED1_Pin);
GPIO_ResetBits(LED2_Port , LED2_Pin);
GPIO_ResetBits(LED3_Port , LED3_Pin);
GPIO_ResetBits(LED4_Port , LED4_Pin);
Delay(0x1fffff);
break;
case 5:
GPIO_SetBits(LED1_Port , LED1_Pin);
Delay(0x1fffff);
GPIO_ResetBits(LED1_Port , LED1_Pin);
GPIO_SetBits(LED2_Port , LED2_Pin);
Delay(0x1fffff);
GPIO_ResetBits(LED2_Port , LED2_Pin);
GPIO_SetBits(LED3_Port , LED3_Pin);
Delay(0x1fffff);
GPIO_ResetBits(LED3_Port , LED3_Pin);
GPIO_SetBits(LED4_Port , LED4_Pin);
Delay(0x1fffff);
GPIO_ResetBits(LED4_Port , LED4_Pin);
break;
case 6:
GPIO_SetBits(LED4_Port , LED4_Pin);
Delay(0x1fffff);
GPIO_ResetBits(LED4_Port , LED4_Pin);
GPIO_SetBits(LED3_Port , LED3_Pin);
Delay(0x1fffff);
GPIO_ResetBits(LED3_Port , LED3_Pin);
GPIO_SetBits(LED2_Port , LED2_Pin);
Delay(0x1fffff);
GPIO_ResetBits(LED2_Port , LED2_Pin);
GPIO_SetBits(LED1_Port , LED1_Pin);
Delay(0x1fffff);
GPIO_ResetBits(LED1_Port , LED1_Pin);
break;
case 7:
break;
}
}
/**
* @brief Delay Function.
* @param nCount:specifies the Delay time length.
* @retval None
*/
static void Delay(__IO uint32_t nCount)
{
while(nCount--)
{
}
}
@@ -0,0 +1,12 @@
#ifndef _KEY_LED_H
#define _KEY_LED_H
#include <stdio.h>
#include "stm32f4xx.h"
void JOYState_LED_GPIO_Init(void);
uint8_t Read_JOYState(void);
void Led_Toggle(uint8_t key);
#endif /*_KEY_LED_H*/
@@ -0,0 +1,43 @@
/**
******************************************************************************
* @file main.c
* @author MCD Application Team
* @version V1.0.0
* @date 18-April-2011
* @brief Main program body
******************************************************************************
* @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>&copy; COPYRIGHT 2011 STMicroelectronics</center></h2>
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "stm32f4xx.h"
#include "KEY&LED.h"
int main(void)
{
JOYState_LED_GPIO_Init();
while (1)
{
Led_Toggle(Read_JOYState());
}
}
/**
* @}
*/
/**
* @}
*/
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
@@ -0,0 +1,88 @@
/**
******************************************************************************
* @file I2C/EEPROM/stm32f4xx_conf.h
* @author MCD Application Team
* @version V1.0.0
* @date 30-September-2011
* @brief Library configuration file.
******************************************************************************
* @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>&copy; COPYRIGHT 2011 STMicroelectronics</center></h2>
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM32F4xx_CONF_H
#define __STM32F4xx_CONF_H
/* Includes ------------------------------------------------------------------*/
/* Uncomment the line below to enable peripheral header file inclusion */
#include "stm32f4xx_adc.h"
#include "stm32f4xx_can.h"
#include "stm32f4xx_crc.h"
#include "stm32f4xx_cryp.h"
#include "stm32f4xx_dac.h"
#include "stm32f4xx_dbgmcu.h"
#include "stm32f4xx_dcmi.h"
#include "stm32f4xx_dma.h"
#include "stm32f4xx_exti.h"
#include "stm32f4xx_flash.h"
#include "stm32f4xx_fsmc.h"
#include "stm32f4xx_hash.h"
#include "stm32f4xx_gpio.h"
#include "stm32f4xx_i2c.h"
#include "stm32f4xx_iwdg.h"
#include "stm32f4xx_pwr.h"
#include "stm32f4xx_rcc.h"
#include "stm32f4xx_rng.h"
#include "stm32f4xx_rtc.h"
#include "stm32f4xx_sdio.h"
#include "stm32f4xx_spi.h"
#include "stm32f4xx_syscfg.h"
#include "stm32f4xx_tim.h"
#include "stm32f4xx_usart.h"
#include "stm32f4xx_wwdg.h"
#include "misc.h" /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* If an external clock source is used, then the value of the following define
should be set to the value of the external clock source, else, if no external
clock is used, keep this define commented */
/*#define I2S_EXTERNAL_CLOCK_VAL 12288000 */ /* Value of the external clock in Hz */
/* Uncomment the line below to expanse the "assert_param" macro in the
Standard Peripheral Library drivers code */
/* #define USE_FULL_ASSERT 1 */
/* Exported macro ------------------------------------------------------------*/
#ifdef USE_FULL_ASSERT
/**
* @brief The assert_param macro is used for function's parameters check.
* @param expr: If expr is false, it calls assert_failed function
* which reports the name of the source file and the source
* line number of the call that failed.
* If expr is true, it returns no value.
* @retval None
*/
#define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__))
/* Exported functions ------------------------------------------------------- */
void assert_failed(uint8_t* file, uint32_t line);
#else
#define assert_param(expr) ((void)0)
#endif /* USE_FULL_ASSERT */
#endif /* __STM32F4xx_CONF_H */
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
@@ -0,0 +1,161 @@
/**
******************************************************************************
* @file I2C/EEPROM/stm32f4xx_it.c
* @author MCD Application Team
* @version V1.0.0
* @date 30-September-2011
* @brief Main Interrupt Service Routines.
* This file provides template for all exceptions handler and
* peripherals interrupt service routine.
******************************************************************************
* @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>&copy; COPYRIGHT 2011 STMicroelectronics</center></h2>
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "stm32f4xx_it.h"
/** @addtogroup STM32F4xx_StdPeriph_Examples
* @{
*/
/** @addtogroup I2C_EEPROM
* @{
*/
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
/******************************************************************************/
/* Cortex-M4 Processor Exceptions Handlers */
/******************************************************************************/
/**
* @brief This function handles NMI exception.
* @param None
* @retval None
*/
void NMI_Handler(void)
{
}
/**
* @brief This function handles Hard Fault exception.
* @param None
* @retval None
*/
void HardFault_Handler(void)
{
/* Go to infinite loop when Hard Fault exception occurs */
while (1)
{
}
}
/**
* @brief This function handles Memory Manage exception.
* @param None
* @retval None
*/
void MemManage_Handler(void)
{
/* Go to infinite loop when Memory Manage exception occurs */
while (1)
{
}
}
/**
* @brief This function handles Bus Fault exception.
* @param None
* @retval None
*/
void BusFault_Handler(void)
{
/* Go to infinite loop when Bus Fault exception occurs */
while (1)
{
}
}
/**
* @brief This function handles Usage Fault exception.
* @param None
* @retval None
*/
void UsageFault_Handler(void)
{
/* Go to infinite loop when Usage Fault exception occurs */
while (1)
{
}
}
/**
* @brief This function handles SVCall exception.
* @param None
* @retval None
*/
void SVC_Handler(void)
{
}
/**
* @brief This function handles Debug Monitor exception.
* @param None
* @retval None
*/
void DebugMon_Handler(void)
{
}
/**
* @brief This function handles PendSVC exception.
* @param None
* @retval None
*/
void PendSV_Handler(void)
{
}
/**
* @brief This function handles SysTick Handler.
* @param None
* @retval None
*/
void SysTick_Handler(void)
{
}
/**
* @brief This function handles PPP interrupt request.
* @param None
* @retval None
*/
/*void PPP_IRQHandler(void)
{
}*/
/**
* @}
*/
/**
* @}
*/
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
@@ -0,0 +1,54 @@
/**
******************************************************************************
* @file I2C/EEPROM/stm32f4xx_it.h
* @author MCD Application Team
* @version V1.0.0
* @date 30-September-2011
* @brief This file contains the headers of the interrupt handlers.
******************************************************************************
* @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>&copy; COPYRIGHT 2011 STMicroelectronics</center></h2>
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM32F4xx_IT_H
#define __STM32F4xx_IT_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32f4xx.h"
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
void NMI_Handler(void);
void HardFault_Handler(void);
void MemManage_Handler(void);
void BusFault_Handler(void);
void UsageFault_Handler(void);
void SVC_Handler(void);
void DebugMon_Handler(void);
void PendSV_Handler(void);
void SysTick_Handler(void);
#ifdef __cplusplus
}
#endif
#endif /* __STM32F4xx_IT_H */
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/