init
This commit is contained in:
@@ -1,30 +1,47 @@
|
||||
#include "led.h"
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD><D6BB>ѧϰʹ<CFB0>ã<EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɣ<EFBFBD><C9A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>κ<EFBFBD><CEBA><EFBFBD>;
|
||||
//ALIENTEK STM32F429<32><39><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//LED<45><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD><EFBFBD>@ALIENTEK
|
||||
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̳:www.openedv.com
|
||||
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:2016/1/5
|
||||
//<EFBFBD>汾<EFBFBD><EFBFBD>V1.0
|
||||
//<EFBFBD><EFBFBD>Ȩ<EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ؾ<EFBFBD><EFBFBD><EFBFBD>
|
||||
//Copyright(C) <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӿƼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˾ 2014-2024
|
||||
//All rights reserved
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//<2F><>ʼ<EFBFBD><CABC>PB1Ϊ<31><CEAA><EFBFBD><EFBFBD>.<2E><>ʹ<EFBFBD><CAB9>ʱ<EFBFBD><CAB1>
|
||||
//LED IO<49><4F>ʼ<EFBFBD><CABC>
|
||||
//-----------------------------------------------------------------
|
||||
GPIO_TypeDef* GPIO_PORT[LEDn] = {LEDB_GPIO_PORT,LEDG_GPIO_PORT,LEDR_GPIO_PORT};
|
||||
const uint16_t GPIO_PIN[LEDn] = {LEDB_PIN,LEDG_PIN,LEDR_PIN};
|
||||
//-----------------------------------------------------------------
|
||||
// void LED_Init(void)
|
||||
//-----------------------------------------------------------------
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: LED GPIO<49><4F><EFBFBD><EFBFBD>
|
||||
// <EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
||||
// <20><> <EFBFBD><EFBFBD> ֵ: <EFBFBD><EFBFBD>
|
||||
// ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
|
||||
//
|
||||
//-----------------------------------------------------------------
|
||||
void LED_Init(void)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_Initure;
|
||||
__HAL_RCC_GPIOB_CLK_ENABLE(); //<2F><><EFBFBD><EFBFBD>GPIOBʱ<42><CAB1>
|
||||
|
||||
GPIO_Initure.Pin=GPIO_PIN_0|GPIO_PIN_1; //PB1,0
|
||||
GPIO_Initure.Mode=GPIO_MODE_OUTPUT_PP; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
GPIO_Initure.Pull=GPIO_PULLUP; //<2F><><EFBFBD><EFBFBD>
|
||||
GPIO_Initure.Speed=GPIO_SPEED_HIGH; //<2F><><EFBFBD><EFBFBD>
|
||||
HAL_GPIO_Init(GPIOB,&GPIO_Initure);
|
||||
|
||||
HAL_GPIO_WritePin(GPIOB,GPIO_PIN_0,GPIO_PIN_SET); //PB0<42><30>1
|
||||
HAL_GPIO_WritePin(GPIOB,GPIO_PIN_1,GPIO_PIN_SET); //PB1<42><31>1
|
||||
BSP_LED_Init(LEDB); // LED_B(<28><><EFBFBD><EFBFBD>)<29><>PB14
|
||||
BSP_LED_Init(LEDG); // LED_G(<28>̵<EFBFBD>)<29><>PF7
|
||||
BSP_LED_Init(LEDR); // LED_R(<28><><EFBFBD><EFBFBD>)<29><>PI3
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
// void BSP_LED_Init(Led_TypeDef Led)
|
||||
//-----------------------------------------------------------------
|
||||
//
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD>LED
|
||||
// <20><><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD>: Led<65><64>ָ<EFBFBD><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD>õ<EFBFBD>LED<45><44>ֵ<EFBFBD><D6B5>LEDB<44><42>LEDG<44><47>LEDR<44><52>
|
||||
// <20><> <20><> ֵ: <20><>
|
||||
// ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
|
||||
//
|
||||
//-----------------------------------------------------------------
|
||||
void BSP_LED_Init(Led_TypeDef Led)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStruct;
|
||||
LEDx_GPIO_CLK_ENABLE(Led); // <20><><EFBFBD><EFBFBD>Ledʱ<64><CAB1>
|
||||
|
||||
GPIO_InitStruct.Pin = GPIO_PIN[Led]; // <20><><EFBFBD><EFBFBD>Led
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
GPIO_InitStruct.Pull = GPIO_PULLUP; // <20><><EFBFBD><EFBFBD>
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; // <20><><EFBFBD><EFBFBD>
|
||||
HAL_GPIO_Init(GPIO_PORT[Led], &GPIO_InitStruct); // <20><>ʼ<EFBFBD><CABC>Led
|
||||
|
||||
HAL_GPIO_WritePin(GPIO_PORT[Led], GPIO_PIN[Led], GPIO_PIN_SET); // LED<45>ø<EFBFBD>
|
||||
}
|
||||
//-----------------------------------------------------------------
|
||||
// End Of File
|
||||
//-----------------------------------------------------------------
|
||||
|
||||
@@ -1,21 +1,53 @@
|
||||
#ifndef _LED_H
|
||||
#define _LED_H
|
||||
#include "sys.h"
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD><EFBFBD>ѧϰʹ<EFBFBD>ã<EFBFBD>δ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>κ<EFBFBD><EFBFBD><EFBFBD>;
|
||||
//ALIENTEK STM32F429<32><39><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//LED<45><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//<2F><><EFBFBD><EFBFBD>ԭ<EFBFBD><D4AD>@ALIENTEK
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̳:www.openedv.com
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:2016/1/1
|
||||
//<2F>汾<EFBFBD><E6B1BE>V1.0
|
||||
//<2F><>Ȩ<EFBFBD><C8A8><EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ؾ<EFBFBD><D8BE><EFBFBD>
|
||||
//Copyright(C) <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӿƼ<D3BF><C6BC><EFBFBD><EFBFBD><EFBFBD>˾ 2014-2024
|
||||
//All rights reserved
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
#include "stm32f429_winner.h"
|
||||
//-----------------------------------------------------------------
|
||||
// LED<EFBFBD><EFBFBD><EFBFBD>Ŷ<EFBFBD><EFBFBD><EFBFBD>
|
||||
//-----------------------------------------------------------------
|
||||
typedef enum
|
||||
{
|
||||
LEDB = 0,
|
||||
LEDG = 1,
|
||||
LEDR = 2
|
||||
}Led_TypeDef;
|
||||
|
||||
#define LED0 PBout(1) //LED0
|
||||
#define LED1 PBout(0) //LED1
|
||||
#define LEDn 3
|
||||
|
||||
void LED_Init(void);
|
||||
#define LEDB_PIN GPIO_PIN_14
|
||||
#define LEDB_GPIO_PORT GPIOB
|
||||
#define LEDB_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
|
||||
#define LEDB_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE()
|
||||
#define LED_B PBout(14) // LED_B(<28><><EFBFBD><EFBFBD>) PB14
|
||||
|
||||
#define LEDG_PIN GPIO_PIN_7
|
||||
#define LEDG_GPIO_PORT GPIOF
|
||||
#define LEDG_GPIO_CLK_ENABLE() __HAL_RCC_GPIOF_CLK_ENABLE()
|
||||
#define LEDG_GPIO_CLK_DISABLE() __HAL_RCC_GPIOF_CLK_DISABLE()
|
||||
#define LED_G PFout(7) // LED_G(<28>̵<EFBFBD>) PF7
|
||||
|
||||
#define LEDR_PIN GPIO_PIN_3
|
||||
#define LEDR_GPIO_PORT GPIOI
|
||||
#define LEDR_GPIO_CLK_ENABLE() __HAL_RCC_GPIOI_CLK_ENABLE()
|
||||
#define LEDR_GPIO_CLK_DISABLE() __HAL_RCC_GPIOI_CLK_DISABLE()
|
||||
#define LED_R PIout(3) // LED_R(<28><><EFBFBD><EFBFBD>) PI3
|
||||
|
||||
#define LEDx_GPIO_CLK_ENABLE(__INDEX__) do{if((__INDEX__) == 0) LEDB_GPIO_CLK_ENABLE(); else \
|
||||
if((__INDEX__) == 1) LEDG_GPIO_CLK_ENABLE(); else \
|
||||
if((__INDEX__) == 2) LEDR_GPIO_CLK_ENABLE(); \
|
||||
}while(0)
|
||||
#define LEDx_GPIO_CLK_DISABLE(__INDEX__) do{if((__INDEX__) == 0) LEDB_GPIO_CLK_DISABLE(); else \
|
||||
if((__INDEX__) == 1) LEDG_GPIO_CLK_DISABLE(); else \
|
||||
if((__INDEX__) == 2) LEDR_GPIO_CLK_DISABLE(); \
|
||||
}while(0)
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
// <20>ⲿ<EFBFBD><E2B2BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//-----------------------------------------------------------------
|
||||
extern void LED_Init(void);
|
||||
extern void BSP_LED_Init(Led_TypeDef Led);
|
||||
#endif
|
||||
//-----------------------------------------------------------------
|
||||
// End Of File
|
||||
//-----------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user