mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2025-02-21 00:27:19 +08:00
Convert Libraries format
This commit is contained in:
parent
74fc3f23db
commit
c178d61947
@ -4,7 +4,7 @@
|
|||||||
; <h> Stack Configuration
|
; <h> Stack Configuration
|
||||||
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
|
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
|
||||||
; </h>
|
; </h>
|
||||||
;//============== 版本 EK V1.0 20190801 ==============//
|
;//============== 版本 EK V1.0 20190801 ==============//
|
||||||
|
|
||||||
Stack_Size EQU 0x00002000
|
Stack_Size EQU 0x00002000
|
||||||
|
|
||||||
@ -153,7 +153,7 @@ __Vectors_Size EQU __Vectors_End - __Vectors
|
|||||||
Reset_Handler PROC
|
Reset_Handler PROC
|
||||||
EXPORT Reset_Handler [WEAK]
|
EXPORT Reset_Handler [WEAK]
|
||||||
IMPORT __main
|
IMPORT __main
|
||||||
LDR R0, =0xE000ED88 ; 使能浮点运算 CP10,CP11
|
LDR R0, =0xE000ED88 ; 使能浮点运算 CP10,CP11
|
||||||
LDR R1,[R0]
|
LDR R1,[R0]
|
||||||
ORR R1,R1,#(0xF << 20)
|
ORR R1,R1,#(0xF << 20)
|
||||||
STR R1,[R0]
|
STR R1,[R0]
|
||||||
|
@ -5,7 +5,7 @@ void RemapVtorTable(void)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
RCC->AHB1ENR |= 1<<13;//bkp clk,enable sram
|
RCC->AHB1ENR |= 1<<13;//bkp clk,enable sram
|
||||||
//关ROM区中断
|
//关ROM区中断
|
||||||
for(i = 0;i<90;i++)
|
for(i = 0;i<90;i++)
|
||||||
{
|
{
|
||||||
NVIC_DisableIRQ((IRQn_Type)i);
|
NVIC_DisableIRQ((IRQn_Type)i);
|
||||||
@ -32,84 +32,84 @@ void AI_Responder_disable(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//外部中断配置函数
|
//外部中断配置函数
|
||||||
//只针对GPIOA~E
|
//只针对GPIOA~E
|
||||||
//参数:
|
//参数:
|
||||||
//GPIOx:0~4,代表GPIOA~E
|
//GPIOx:0~4,代表GPIOA~E
|
||||||
//BITx:需要使能的位,例如PB12,就填 12;
|
//BITx:需要使能的位,例如PB12,就填 12;
|
||||||
//TRIM:触发模式,1,下降沿;2,上升沿;3,任意电平触发
|
//TRIM:触发模式,1,下降沿;2,上升沿;3,任意电平触发
|
||||||
//该函数一次只能配置1个IO口,多个IO口,需多次调用
|
//该函数一次只能配置1个IO口,多个IO口,需多次调用
|
||||||
//该函数会自动开启对应中断,以及屏蔽线
|
//该函数会自动开启对应中断,以及屏蔽线
|
||||||
void Ex_NVIC_Config(u8 GPIOx,u8 BITx,u8 TRIM)
|
void Ex_NVIC_Config(u8 GPIOx,u8 BITx,u8 TRIM)
|
||||||
{
|
{
|
||||||
u8 EXTOFFSET=(BITx%4)*4;
|
u8 EXTOFFSET=(BITx%4)*4;
|
||||||
RCC->APB2ENR|=1<<14; //使能SYSCFG时钟
|
RCC->APB2ENR|=1<<14; //使能SYSCFG时钟
|
||||||
SYSCFG->EXTICR[BITx/4]&=~(0x000F<<EXTOFFSET);//清除原来设置!!!
|
SYSCFG->EXTICR[BITx/4]&=~(0x000F<<EXTOFFSET);//清除原来设置!!!
|
||||||
SYSCFG->EXTICR[BITx/4]|=GPIOx<<EXTOFFSET; //EXTI.BITx映射到GPIOx.BITx
|
SYSCFG->EXTICR[BITx/4]|=GPIOx<<EXTOFFSET; //EXTI.BITx映射到GPIOx.BITx
|
||||||
//自动设置
|
//自动设置
|
||||||
EXTI->IMR|=1<<BITx; //开启line BITx上的中断(如果要禁止中断,则反操作即可)
|
EXTI->IMR|=1<<BITx; //开启line BITx上的中断(如果要禁止中断,则反操作即可)
|
||||||
if(TRIM&0x01)EXTI->FTSR|=1<<BITx; //line BITx事件下降沿触发
|
if(TRIM&0x01)EXTI->FTSR|=1<<BITx; //line BITx事件下降沿触发
|
||||||
if(TRIM&0x02)EXTI->RTSR|=1<<BITx; //line BITx事件上升沿触发
|
if(TRIM&0x02)EXTI->RTSR|=1<<BITx; //line BITx事件上升沿触发
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//THUMB指令不支持汇编内联
|
//THUMB指令不支持汇编内联
|
||||||
//采用如下方法实现执行汇编指令WFI
|
//采用如下方法实现执行汇编指令WFI
|
||||||
void WFI_SET(void)
|
void WFI_SET(void)
|
||||||
{
|
{
|
||||||
__ASM volatile("wfi");
|
__ASM volatile("wfi");
|
||||||
}
|
}
|
||||||
//关闭所有中断(但是不包括fault和NMI中断)
|
//关闭所有中断(但是不包括fault和NMI中断)
|
||||||
void INTX_DISABLE(void)
|
void INTX_DISABLE(void)
|
||||||
{
|
{
|
||||||
__ASM volatile("cpsid i");
|
__ASM volatile("cpsid i");
|
||||||
}
|
}
|
||||||
//开启所有中断
|
//开启所有中断
|
||||||
void INTX_ENABLE(void)
|
void INTX_ENABLE(void)
|
||||||
{
|
{
|
||||||
__ASM volatile("cpsie i");
|
__ASM volatile("cpsie i");
|
||||||
}
|
}
|
||||||
//设置栈顶地址 __set_MSP(0x70002000);
|
//设置栈顶地址 __set_MSP(0x70002000);
|
||||||
|
|
||||||
//进入待机模式
|
//进入待机模式
|
||||||
void Sys_Standby(void)
|
void Sys_Standby(void)
|
||||||
{
|
{
|
||||||
SCB->SCR|=1<<2; //使能SLEEPDEEP位 (SYS->CTRL)
|
SCB->SCR|=1<<2; //使能SLEEPDEEP位 (SYS->CTRL)
|
||||||
RCC->APB1ENR|=1<<28;//使能电源时钟
|
RCC->APB1ENR|=1<<28;//使能电源时钟
|
||||||
PWR->CSR|=1<<8; //设置WKUP用于唤醒
|
PWR->CSR|=1<<8; //设置WKUP用于唤醒
|
||||||
PWR->CR|=1<<2; //清除Wake-up 标志
|
PWR->CR|=1<<2; //清除Wake-up 标志
|
||||||
PWR->CR|=1<<1; //PDDS置位
|
PWR->CR|=1<<1; //PDDS置位
|
||||||
WFI_SET(); //执行WFI指令,进入待机模式
|
WFI_SET(); //执行WFI指令,进入待机模式
|
||||||
}
|
}
|
||||||
//系统软复位
|
//系统软复位
|
||||||
void Sys_Soft_Reset(void)
|
void Sys_Soft_Reset(void)
|
||||||
{
|
{
|
||||||
SCB->AIRCR =0X05FA0000|(u32)0x04;
|
SCB->AIRCR =0X05FA0000|(u32)0x04;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TK499_NVIC_Init(2,2,TK80_IRQn,2);
|
// TK499_NVIC_Init(2,2,TK80_IRQn,2);
|
||||||
//设置NVIC
|
//设置NVIC
|
||||||
//NVIC_PreemptionPriority:抢占优先级
|
//NVIC_PreemptionPriority:抢占优先级
|
||||||
//NVIC_SubPriority :响应优先级
|
//NVIC_SubPriority :响应优先级
|
||||||
//NVIC_Channel :中断编号
|
//NVIC_Channel :中断编号
|
||||||
//NVIC_Group :中断分组 0~4
|
//NVIC_Group :中断分组 0~4
|
||||||
//注意优先级不能超过设定的组的范围!否则会有意想不到的错误
|
//注意优先级不能超过设定的组的范围!否则会有意想不到的错误
|
||||||
//组划分:
|
//组划分:
|
||||||
//组0:0位抢占优先级,4位响应优先级
|
//组0:0位抢占优先级,4位响应优先级
|
||||||
//组1:1位抢占优先级,3位响应优先级
|
//组1:1位抢占优先级,3位响应优先级
|
||||||
//组2:2位抢占优先级,2位响应优先级
|
//组2:2位抢占优先级,2位响应优先级
|
||||||
//组3:3位抢占优先级,1位响应优先级
|
//组3:3位抢占优先级,1位响应优先级
|
||||||
//组4:4位抢占优先级,0位响应优先级
|
//组4:4位抢占优先级,0位响应优先级
|
||||||
//NVIC_SubPriority和NVIC_PreemptionPriority的原则是,数值越小,越优先
|
//NVIC_SubPriority和NVIC_PreemptionPriority的原则是,数值越小,越优先
|
||||||
void TK499_NVIC_Init(u8 NVIC_PreemptionPriority,u8 NVIC_SubPriority,u8 NVIC_Channel,u8 NVIC_Group)
|
void TK499_NVIC_Init(u8 NVIC_PreemptionPriority,u8 NVIC_SubPriority,u8 NVIC_Channel,u8 NVIC_Group)
|
||||||
{
|
{
|
||||||
u32 temp;
|
u32 temp;
|
||||||
NVIC_SetPriorityGrouping(NVIC_Group);//设置分组
|
NVIC_SetPriorityGrouping(NVIC_Group);//设置分组
|
||||||
temp=NVIC_PreemptionPriority<<(4-NVIC_Group);
|
temp=NVIC_PreemptionPriority<<(4-NVIC_Group);
|
||||||
temp|=NVIC_SubPriority&(0x0f>>NVIC_Group);
|
temp|=NVIC_SubPriority&(0x0f>>NVIC_Group);
|
||||||
temp&=0xf; //取低四位
|
temp&=0xf; //取低四位
|
||||||
NVIC->ISER[NVIC_Channel/32]|=1<<NVIC_Channel%32;//使能中断位(要清除的话,设置ICER对应位为1即可)
|
NVIC->ISER[NVIC_Channel/32]|=1<<NVIC_Channel%32;//使能中断位(要清除的话,设置ICER对应位为1即可)
|
||||||
NVIC->IP[NVIC_Channel]|=temp<<4; //设置响应优先级和抢断优先级
|
NVIC->IP[NVIC_Channel]|=temp<<4; //设置响应优先级和抢断优先级
|
||||||
}
|
}
|
||||||
|
|
||||||
void TK80_IRQHandler(void)
|
void TK80_IRQHandler(void)
|
||||||
@ -133,9 +133,9 @@ void TK80_IRQHandler(void)
|
|||||||
TK80->SR |= 0;
|
TK80->SR |= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//备用函数
|
//备用函数
|
||||||
//#define T_SRAM_FUN1 0x20000400
|
//#define T_SRAM_FUN1 0x20000400
|
||||||
//copyAtoB((u32)LCD_PutPixel&0xFFFFFFFE,T_SRAM_FUN1,800);//加载函数到SRAM
|
//copyAtoB((u32)LCD_PutPixel&0xFFFFFFFE,T_SRAM_FUN1,800);//加载函数到SRAM
|
||||||
//void copyAtoB(u32 srcAdd,u32 dstAdd,u16 len)
|
//void copyAtoB(u32 srcAdd,u32 dstAdd,u16 len)
|
||||||
//{
|
//{
|
||||||
// len = (len + 3)/4;
|
// len = (len + 3)/4;
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
#define __SYS_H
|
#define __SYS_H
|
||||||
#include "tk499.h"
|
#include "tk499.h"
|
||||||
#include "HAL_conf.h"
|
#include "HAL_conf.h"
|
||||||
//位带操作,实现51类似的GPIO控制功能
|
//位带操作,实现51类似的GPIO控制功能
|
||||||
//具体实现思想,参考<<CM3权威指南>>第五章(87页~92页).M4同M3类似,只是寄存器地址变了.
|
//具体实现思想,参考<<CM3权威指南>>第五章(87页~92页).M4同M3类似,只是寄存器地址变了.
|
||||||
//IO口操作宏定义
|
//IO口操作宏定义
|
||||||
//#define BITBAND(addr, bitnum) ((addr & 0xF0000000)+0x2000000+((addr &0xFFFFF)<<5)+(bitnum<<2))
|
//#define BITBAND(addr, bitnum) ((addr & 0xF0000000)+0x2000000+((addr &0xFFFFF)<<5)+(bitnum<<2))
|
||||||
//#define MEM_ADDR(addr) *((volatile unsigned long *)(addr))
|
//#define MEM_ADDR(addr) *((volatile unsigned long *)(addr))
|
||||||
//#define BIT_ADDR(addr, bitnum) MEM_ADDR(BITBAND(addr, bitnum))
|
//#define BIT_ADDR(addr, bitnum) MEM_ADDR(BITBAND(addr, bitnum))
|
||||||
@ -13,16 +13,16 @@ void RemapVtorTable(void);
|
|||||||
void AI_Responder_enable(void);
|
void AI_Responder_enable(void);
|
||||||
void AI_Responder_disable(void);
|
void AI_Responder_disable(void);
|
||||||
|
|
||||||
void Sys_Soft_Reset(void); //系统软复位
|
void Sys_Soft_Reset(void); //系统软复位
|
||||||
void Sys_Standby(void); //待机模式
|
void Sys_Standby(void); //待机模式
|
||||||
|
|
||||||
void TK499_NVIC_Init(u8 NVIC_PreemptionPriority,u8 NVIC_SubPriority,u8 NVIC_Channel,u8 NVIC_Group);
|
void TK499_NVIC_Init(u8 NVIC_PreemptionPriority,u8 NVIC_SubPriority,u8 NVIC_Channel,u8 NVIC_Group);
|
||||||
void Ex_NVIC_Config(u8 GPIOx,u8 BITx,u8 TRIM); //外部中断配置函数(只对GPIOA~I)
|
void Ex_NVIC_Config(u8 GPIOx,u8 BITx,u8 TRIM); //外部中断配置函数(只对GPIOA~I)
|
||||||
|
|
||||||
//以下为汇编函数
|
//以下为汇编函数
|
||||||
void WFI_SET(void); //执行WFI指令
|
void WFI_SET(void); //执行WFI指令
|
||||||
void INTX_DISABLE(void);//关闭所有中断
|
void INTX_DISABLE(void);//关闭所有中断
|
||||||
void INTX_ENABLE(void); //开启所有中断
|
void INTX_ENABLE(void); //开启所有中断
|
||||||
|
|
||||||
void TIM3_Config(u16 arr,u16 psc);
|
void TIM3_Config(u16 arr,u16 psc);
|
||||||
#endif
|
#endif
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//============== 版本 EK V1.0 20190818 ==============//
|
//============== <EFBFBD>汾 EK V1.0 20190818 ==============//
|
||||||
|
|
||||||
|
|
||||||
#define T_SRAM_BASE 0X20000000
|
#define T_SRAM_BASE 0X20000000
|
||||||
|
@ -304,8 +304,8 @@ typedef struct
|
|||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define ADC_FLAG_AWD ((uint8_t)0x02) //ADWIF ±È½Ï±ê־λ
|
#define ADC_FLAG_AWD ((uint8_t)0x02) //ADWIF 比较标志位
|
||||||
#define ADC_FLAG_EOC ((uint8_t)0x01) //ADIF ת»»½áÊø±ê־λ
|
#define ADC_FLAG_EOC ((uint8_t)0x01) //ADIF 转换结束标志位
|
||||||
#define IS_ADC_CLEAR_FLAG(FLAG) ((((FLAG) & (uint8_t)0xF0) == 0x00) && ((FLAG) != 0x00))
|
#define IS_ADC_CLEAR_FLAG(FLAG) ((((FLAG) & (uint8_t)0xF0) == 0x00) && ((FLAG) != 0x00))
|
||||||
#define IS_ADC_GET_FLAG(FLAG) (((FLAG) == ADC_FLAG_AWD) || ((FLAG) == ADC_FLAG_EOC))
|
#define IS_ADC_GET_FLAG(FLAG) (((FLAG) == ADC_FLAG_AWD) || ((FLAG) == ADC_FLAG_EOC))
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#ifndef __HAL_CONF_H__
|
#ifndef __HAL_CONF_H__
|
||||||
#define __HAL_CONF_H__
|
#define __HAL_CONF_H__
|
||||||
|
|
||||||
/*此处可添加或删除外设*/
|
/*此处可添加或删除外设*/
|
||||||
#include "HAL_device.h"
|
#include "HAL_device.h"
|
||||||
#include "HAL_adc.h"
|
#include "HAL_adc.h"
|
||||||
#include "HAL_dma.h"
|
#include "HAL_dma.h"
|
||||||
|
@ -65,14 +65,14 @@ typedef enum
|
|||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
GPIO_Mode_AIN = 0x0, //模拟输入
|
GPIO_Mode_AIN = 0x0, //模拟输入
|
||||||
GPIO_Mode_IN_FLOATING = 0x04, //浮空输入
|
GPIO_Mode_IN_FLOATING = 0x04, //浮空输入
|
||||||
GPIO_Mode_IPD = 0x28, //下拉输入
|
GPIO_Mode_IPD = 0x28, //下拉输入
|
||||||
GPIO_Mode_IPU = 0x48, //上拉输入
|
GPIO_Mode_IPU = 0x48, //上拉输入
|
||||||
GPIO_Mode_Out_OD = 0x14,//通用开漏输出
|
GPIO_Mode_Out_OD = 0x14,//通用开漏输出
|
||||||
GPIO_Mode_Out_PP = 0x10,//通用推免输出
|
GPIO_Mode_Out_PP = 0x10,//通用推免输出
|
||||||
GPIO_Mode_AF_OD = 0x1C, // 复用开漏输出
|
GPIO_Mode_AF_OD = 0x1C, // 复用开漏输出
|
||||||
GPIO_Mode_AF_PP = 0x18 //复用推免输出
|
GPIO_Mode_AF_PP = 0x18 //复用推免输出
|
||||||
}GPIOMode_TypeDef;
|
}GPIOMode_TypeDef;
|
||||||
|
|
||||||
#define IS_GPIO_MODE(MODE) (((MODE) == GPIO_Mode_AIN) || ((MODE) == GPIO_Mode_IN_FLOATING) || \
|
#define IS_GPIO_MODE(MODE) (((MODE) == GPIO_Mode_AIN) || ((MODE) == GPIO_Mode_IN_FLOATING) || \
|
||||||
|
@ -1223,13 +1223,13 @@ void CAN_AutoCfg_BaudParam(CAN_Peli_InitTypeDef *CAN_Peli_InitStruct, unsigned
|
|||||||
{
|
{
|
||||||
unsigned int i, value = baud, record = 1;
|
unsigned int i, value = baud, record = 1;
|
||||||
unsigned int remain = 0, sumPrescaler = 0;
|
unsigned int remain = 0, sumPrescaler = 0;
|
||||||
while(( baud == 0 ) || ( SrcClk == 0 )); //防止波特率及时钟为0
|
while(( baud == 0 ) || ( SrcClk == 0 )); //防止波特率及时钟为0
|
||||||
sumPrescaler = SrcClk / baud; //总分频
|
sumPrescaler = SrcClk / baud; //总分频
|
||||||
sumPrescaler = sumPrescaler / 2; //
|
sumPrescaler = sumPrescaler / 2; //
|
||||||
for( i = 25; i > 3; i -- )
|
for( i = 25; i > 3; i -- )
|
||||||
{
|
{
|
||||||
remain = sumPrescaler - ((sumPrescaler / i) * i);
|
remain = sumPrescaler - ((sumPrescaler / i) * i);
|
||||||
if( remain == 0 ) //整除
|
if( remain == 0 ) //整除
|
||||||
{
|
{
|
||||||
record = i;
|
record = i;
|
||||||
break;
|
break;
|
||||||
|
@ -480,7 +480,7 @@ ITStatus DMA_GetITStatus(uint32_t DMA_IT)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Clears the DMAy Channelx’s interrupt pending bits.
|
* @brief Clears the DMAy Channelx’s interrupt pending bits.
|
||||||
* @param DMA_IT: specifies the DMA interrupt pending bit to clear.
|
* @param DMA_IT: specifies the DMA interrupt pending bit to clear.
|
||||||
* This parameter can be any combination (for the same DMA) of
|
* This parameter can be any combination (for the same DMA) of
|
||||||
* the following values:
|
* the following values:
|
||||||
|
@ -202,7 +202,7 @@ FlagStatus EXTI_GetFlagStatus(uint32_t EXTI_Line)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Clears the EXTI’s line pending flags.
|
* @brief Clears the EXTI’s line pending flags.
|
||||||
* @param EXTI_Line: specifies the EXTI lines flags to clear.
|
* @param EXTI_Line: specifies the EXTI lines flags to clear.
|
||||||
* This parameter can be any combination of EXTI_Linex where
|
* This parameter can be any combination of EXTI_Linex where
|
||||||
* x can be (0..18).
|
* x can be (0..18).
|
||||||
@ -243,7 +243,7 @@ ITStatus EXTI_GetITStatus(uint32_t EXTI_Line)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Clears the EXTI’s line pending bits.
|
* @brief Clears the EXTI’s line pending bits.
|
||||||
* @param EXTI_Line: specifies the EXTI lines to clear.
|
* @param EXTI_Line: specifies the EXTI lines to clear.
|
||||||
* This parameter can be any combination of EXTI_Linex where
|
* This parameter can be any combination of EXTI_Linex where
|
||||||
* x can be (0..18).
|
* x can be (0..18).
|
||||||
|
@ -221,7 +221,7 @@ void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct)
|
|||||||
GPIOx->CRH = tmpreg;
|
GPIOx->CRH = tmpreg;
|
||||||
}
|
}
|
||||||
/*---------------------------- GPIOE_CRH_EXT Configuration ------------------------*/
|
/*---------------------------- GPIOE_CRH_EXT Configuration ------------------------*/
|
||||||
if(GPIO_InitStruct->GPIO_Pin>>16) //说明是GPIOE的16~23位
|
if(GPIO_InitStruct->GPIO_Pin>>16) //说明是GPIOE的16~23位
|
||||||
{
|
{
|
||||||
GPIO_InitStruct->GPIO_Pin = GPIO_InitStruct->GPIO_Pin>>16;
|
GPIO_InitStruct->GPIO_Pin = GPIO_InitStruct->GPIO_Pin>>16;
|
||||||
tmpreg = GPIOE->CRH_EXT;
|
tmpreg = GPIOE->CRH_EXT;
|
||||||
@ -493,39 +493,39 @@ void GPIO_PinAFConfig(GPIO_TypeDef* GPIOx, uint32_t GPIO_Pin, uint8_t GPIO_AF)
|
|||||||
assert_param(IS_GPIO_PIN_SOURCE(GPIO_PinSource));
|
assert_param(IS_GPIO_PIN_SOURCE(GPIO_PinSource));
|
||||||
assert_param(IS_GPIO_AF(GPIO_AF));
|
assert_param(IS_GPIO_AF(GPIO_AF));
|
||||||
|
|
||||||
if(GPIO_Pin>>16) //说明是GPIOE的16~23位
|
if(GPIO_Pin>>16) //说明是GPIOE的16~23位
|
||||||
{
|
{
|
||||||
temp = GPIO_Pin>>16;
|
temp = GPIO_Pin>>16;
|
||||||
for(i=0;i<8;i++)
|
for(i=0;i<8;i++)
|
||||||
{
|
{
|
||||||
if(temp&0x01)
|
if(temp&0x01)
|
||||||
{
|
{
|
||||||
GPIOE->AFRH_EXT &= ~((uint32_t)0xF << ((uint32_t)(i<<2))); //AF配置占半字节,要x4,即<<2
|
GPIOE->AFRH_EXT &= ~((uint32_t)0xF << ((uint32_t)(i<<2))); //AF配置占半字节,要x4,即<<2
|
||||||
GPIOE->AFRH_EXT |= ((uint32_t)GPIO_AF << ((uint32_t)(i<<2)));
|
GPIOE->AFRH_EXT |= ((uint32_t)GPIO_AF << ((uint32_t)(i<<2)));
|
||||||
}
|
}
|
||||||
temp = temp>>1;
|
temp = temp>>1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(GPIO_Pin&0XFF00) //说明是GPIOE的8~15位
|
if(GPIO_Pin&0XFF00) //说明是GPIOE的8~15位
|
||||||
{
|
{
|
||||||
temp = GPIO_Pin>>8;
|
temp = GPIO_Pin>>8;
|
||||||
for(i=0;i<8;i++)
|
for(i=0;i<8;i++)
|
||||||
{
|
{
|
||||||
if(temp&0x01)
|
if(temp&0x01)
|
||||||
{
|
{
|
||||||
GPIOx->AFRH &= ~((uint32_t)0xF << ((uint32_t)(i<<2))); //AF配置占半字节,要x4,即<<2
|
GPIOx->AFRH &= ~((uint32_t)0xF << ((uint32_t)(i<<2))); //AF配置占半字节,要x4,即<<2
|
||||||
GPIOx->AFRH |= ((uint32_t)GPIO_AF << ((uint32_t)(i<<2)));
|
GPIOx->AFRH |= ((uint32_t)GPIO_AF << ((uint32_t)(i<<2)));
|
||||||
}
|
}
|
||||||
temp = temp>>1;
|
temp = temp>>1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(GPIO_Pin&0XFF) //说明是GPIOE的0~7位
|
if(GPIO_Pin&0XFF) //说明是GPIOE的0~7位
|
||||||
{
|
{
|
||||||
for(i=0;i<8;i++)
|
for(i=0;i<8;i++)
|
||||||
{
|
{
|
||||||
if(temp&0x01)
|
if(temp&0x01)
|
||||||
{
|
{
|
||||||
GPIOx->AFRL &= ~((uint32_t)0xF << ((uint32_t)(i<<2))); //AF配置占半字节,要x4,即<<2
|
GPIOx->AFRL &= ~((uint32_t)0xF << ((uint32_t)(i<<2))); //AF配置占半字节,要x4,即<<2
|
||||||
GPIOx->AFRL |= ((uint32_t)GPIO_AF << ((uint32_t)(i<<2)));
|
GPIOx->AFRL |= ((uint32_t)GPIO_AF << ((uint32_t)(i<<2)));
|
||||||
}
|
}
|
||||||
temp = temp>>1;
|
temp = temp>>1;
|
||||||
|
@ -68,7 +68,7 @@
|
|||||||
#define IC_TAR_ENDUAL_Set ((uint16_t)0x1000)
|
#define IC_TAR_ENDUAL_Set ((uint16_t)0x1000)
|
||||||
#define IC_TAR_ENDUAL_Reset ((uint16_t)0xEFFF)
|
#define IC_TAR_ENDUAL_Reset ((uint16_t)0xEFFF)
|
||||||
|
|
||||||
/* I2C SPECIAL、GC_OR_START bits mask */
|
/* I2C SPECIAL、GC_OR_START bits mask */
|
||||||
#define IC_TAR_GC_Set ((uint16_t)0x0800)
|
#define IC_TAR_GC_Set ((uint16_t)0x0800)
|
||||||
#define IC_TAR_GC_Reset ((uint16_t)0xF7FF)
|
#define IC_TAR_GC_Reset ((uint16_t)0xF7FF)
|
||||||
|
|
||||||
@ -78,7 +78,7 @@
|
|||||||
//static
|
//static
|
||||||
uint8_t I2C_CMD_DIR = 0;
|
uint8_t I2C_CMD_DIR = 0;
|
||||||
|
|
||||||
/*新增加的用户变量,外部调用时需要更新该变量值*/
|
/*新增加的用户变量,外部调用时需要更新该变量值*/
|
||||||
uint16_t I2C_DMA_DIR = 0;
|
uint16_t I2C_DMA_DIR = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -176,7 +176,7 @@ void SystemClk_HSEInit(uint32_t PLL_DN)
|
|||||||
{
|
{
|
||||||
RCC_DeInit();
|
RCC_DeInit();
|
||||||
//HSE on
|
//HSE on
|
||||||
//CR寄存器BIT16位(HSEON位)置1,作用是连接外部时钟HSE作为系统时钟
|
//CR寄存器BIT16位(HSEON位)置1,作用是连接外部时钟HSE作为系统时钟
|
||||||
RCC_HSEConfig(RCC_HSE_ON);
|
RCC_HSEConfig(RCC_HSE_ON);
|
||||||
|
|
||||||
while(1)
|
while(1)
|
||||||
@ -189,7 +189,7 @@ void SystemClk_HSEInit(uint32_t PLL_DN)
|
|||||||
RCC_PLLCmd(DISABLE);
|
RCC_PLLCmd(DISABLE);
|
||||||
RCC_PLLConfig(RCC_PLLSource_HSE_Div1,PLL_DN);
|
RCC_PLLConfig(RCC_PLLSource_HSE_Div1,PLL_DN);
|
||||||
RCC_PLLCmd(ENABLE);
|
RCC_PLLCmd(ENABLE);
|
||||||
RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);//选择外部时钟作为系统时钟
|
RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);//选择外部时钟作为系统时钟
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @brief Resets the RCC clock configuration to the default reset state.
|
* @brief Resets the RCC clock configuration to the default reset state.
|
||||||
@ -833,7 +833,7 @@ void RCC_LSICmd(FunctionalState NewState)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Configures the RTC clock (RTCCLK).
|
* @brief Configures the RTC clock (RTCCLK).
|
||||||
* Once the RTC clock is selected it can抰 be changed unless the
|
* Once the RTC clock is selected it can抰 be changed unless the
|
||||||
* Backup domain is reset.
|
* Backup domain is reset.
|
||||||
* @param RCC_RTCCLKSource: specifies the RTC clock source.
|
* @param RCC_RTCCLKSource: specifies the RTC clock source.
|
||||||
* This parameter can be one of the following values:
|
* This parameter can be one of the following values:
|
||||||
@ -1269,7 +1269,7 @@ ITStatus RCC_GetITStatus(uint8_t RCC_IT)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Clears the RCC抯 interrupt pending bits.
|
* @brief Clears the RCC抯 interrupt pending bits.
|
||||||
* @param RCC_IT: specifies the interrupt pending bit to clear.
|
* @param RCC_IT: specifies the interrupt pending bit to clear.
|
||||||
* This parameter can be any combination of the following values:
|
* This parameter can be any combination of the following values:
|
||||||
* @arg RCC_IT_LSIRDY: LSI ready interrupt
|
* @arg RCC_IT_LSIRDY: LSI ready interrupt
|
||||||
|
@ -247,7 +247,7 @@ void UART_ITConfig(UART_TypeDef* UARTx, uint16_t UART_IT, FunctionalState NewSta
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Enables or disables the UART’s DMA interface.
|
* @brief Enables or disables the UART’s DMA interface.
|
||||||
* @param UARTx: Select the UART or the UART peripheral.
|
* @param UARTx: Select the UART or the UART peripheral.
|
||||||
* This parameter can be one of the following values:
|
* This parameter can be one of the following values:
|
||||||
* UART1, UART2, UART3 .
|
* UART1, UART2, UART3 .
|
||||||
@ -398,7 +398,7 @@ ITStatus UART_GetITStatus(UART_TypeDef* UARTx, uint16_t UART_IT)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Clears the UARTx’s interrupt pending bits.
|
* @brief Clears the UARTx’s interrupt pending bits.
|
||||||
* @param UARTx: Select the UART or the UART peripheral.
|
* @param UARTx: Select the UART or the UART peripheral.
|
||||||
* This parameter can be one of the following values:
|
* This parameter can be one of the following values:
|
||||||
* UART1, UART2, UART3, UART4 or UART5.
|
* UART1, UART2, UART3, UART4 or UART5.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user