HC32F460怎么用外部时钟触发DMA, 或者定时器,要硬件触发
HC32F460怎么用外部时钟触发DMA, 或者定时器,要硬件触发,不要中断那种。 省的CPU 费劲。 外部时钟源,采用SI5351 产生 10~50MHZ的 时钟信号。 核心是通过外设触发连接矩阵配置触发路径。 外部 GPIO 脉冲触发 DMA 传输 ADC 数据 //Dma Configstatic void App_DmaCfg(void)
{
/* DMA1 FCG enable */
FCG_Fcg0PeriphClockCmd(FCG0_PERIPH_DMA1, ENABLE);
/* DMA2 FCG enable */
FCG_Fcg0PeriphClockCmd(FCG0_PERIPH_DMA2, ENABLE);
/* AOS FCG enable */
FCG_Fcg0PeriphClockCmd(FCG0_PERIPH_AOS, ENABLE);
stc_dma_init_t stcDmaInit;
stc_dma_repeat_init_t stcDmaRepeatInit;
/* DMA1_CH1 Config */
AOS_SetTriggerEventSrc(AOS_DMA1_1, EVT_SRC_TMRA_1_UDF);
/* Base Config */
(void)DMA_StructInit(&stcDmaInit);
stcDmaInit.u32IntEn = DMA_INT_DISABLE;
stcDmaInit.u32BlockSize = 1024UL;
stcDmaInit.u32TransCount = 1UL;//单个传输
stcDmaInit.u32DataWidth = DMA_DATAWIDTH_16BIT;
stcDmaInit.u32DestAddr = (uint32_t)adata;// 数组1k
stcDmaInit.u32SrcAddr =(uint32_t)(&CM_GPIO->PIDRA);// porta 输入地址
stcDmaInit.u32SrcAddrInc = DMA_SRC_ADDR_FIX;
stcDmaInit.u32DestAddrInc = DMA_DEST_ADDR_INC;
(void)DMA_Init(CM_DMA1, DMA_CH1, &stcDmaInit);
(void)DMA_RepeatStructInit(&stcDmaRepeatInit); // 重复次数结构
stcDmaRepeatInit.u32Mode = DMA_RPT_SRC; // 源地址不变
stcDmaRepeatInit.u32SrcCount = 1024; //1024次
(void)DMA_RepeatInit(CM_DMA1, DMA_CH1, &stcDmaRepeatInit);
/* DMA channel enable */
(void)DMA_ChCmd(CM_DMA1, DMA_CH1, ENABLE);
/* DMA2_CH0 Config */
AOS_SetTriggerEventSrc(AOS_DMA2_0, EVT_SRC_TMR6_1_GCMP_B);
/* Base Config */
(void)DMA_StructInit(&stcDmaInit);
stcDmaInit.u32IntEn = DMA_INT_DISABLE;
stcDmaInit.u32BlockSize = 1024UL;
stcDmaInit.u32TransCount = 1UL;//单个传输
stcDmaInit.u32DataWidth = DMA_DATAWIDTH_16BIT;
stcDmaInit.u32DestAddr = (uint32_t)bdata;
stcDmaInit.u32SrcAddr = (uint32_t)(&CM_GPIO->PIDRA)+0x10UL*3 ;// portD 输入地址; GPIO_REG_OFFSET(0x10UL)
stcDmaInit.u32SrcAddrInc = DMA_SRC_ADDR_FIX;
stcDmaInit.u32DestAddrInc = DMA_DEST_ADDR_INC;
(void)DMA_Init(CM_DMA2, DMA_CH0, &stcDmaInit);
(void)DMA_RepeatStructInit(&stcDmaRepeatInit);
stcDmaRepeatInit.u32Mode = DMA_RPT_SRC; //
stcDmaRepeatInit.u32SrcCount = 1024; //1024次
(void)DMA_RepeatInit(CM_DMA2, DMA_CH0, &stcDmaRepeatInit);
/* DMA channel enable */
(void)DMA_ChCmd(CM_DMA2, DMA_CH0, ENABLE);
/* DMA module enable */
DMA_Cmd(CM_DMA1, ENABLE);
/* DMA module enable */
DMA_Cmd(CM_DMA2, ENABLE);
} //Timer6 Config
static void App_Timer6Cfg(void)
{
stc_tmr6_init_t stcTmr6Init;
/* Enable TMR6_1 peripheral clock */
FCG_Fcg2PeriphClockCmd(FCG2_PERIPH_TMR6_1, ENABLE);
/************************* Configure TMR6_1 counter *************************/
TMR6_Stop(CM_TMR6_1);
(void)TMR6_StructInit(&stcTmr6Init);
/* Config hardware count */
stcTmr6Init.u8CountSrc = TMR6_CNT_SRC_HW;
stcTmr6Init.u32PeriodValue = 0xFFFFU;
(void)TMR6_Init(CM_TMR6_1, &stcTmr6Init);
/************************* Configure TMR6_1_A GCM ***************************/
TMR6_SetCompareValue(CM_TMR6_1, TMR6_CMP_REG_C, 0x0U); /* Set General Compare RegisterC Value */
TMR6_SetCompareValue(CM_TMR6_1, TMR6_CMP_REG_E, 0x0U); /* Set General Compare RegisterE Value */
/* CAP pin function set */
TMR6_SetFunc(CM_TMR6_1, TMR6_CH_A, TMR6_PIN_CAPT_INPUT);
/* Config hardware capture */
TMR6_HWCaptureCondCmd(CM_TMR6_1, TMR6_CH_A, TMR6_CAPT_COND_TRIGB_FALLING, ENABLE);
/* Start timer6_1 */
TMR6_Start(CM_TMR6_1);
/* Enable TMR6_2 peripheral clock */
FCG_Fcg2PeriphClockCmd(FCG2_PERIPH_TMR6_2, ENABLE);
/************************* Configure TMR6_2 counter *************************/
TMR6_Stop(CM_TMR6_2);
(void)TMR6_StructInit(&stcTmr6Init);
/* Config software count */
stcTmr6Init.sw_count.u32ClockDiv = TMR6_CLK_DIV1;
stcTmr6Init.sw_count.u32CountMode = TMR6_MD_SAWTOOTH;
stcTmr6Init.sw_count.u32CountDir = TMR6_CNT_UP;
stcTmr6Init.u32PeriodValue = 0xFFFFU;
(void)TMR6_Init(CM_TMR6_2, &stcTmr6Init);
/************************* Configure TMR6_2_B GCM ***************************/
TMR6_SetCompareValue(CM_TMR6_2, TMR6_CMP_REG_D, 0x0U); /* Set General Compare RegisterD Value */
TMR6_SetCompareValue(CM_TMR6_2, TMR6_CMP_REG_F, 0x0U); /* Set General Compare RegisterF Value */
/* CAP pin function set */
TMR6_SetFunc(CM_TMR6_2, TMR6_CH_B, TMR6_PIN_CAPT_INPUT);
/* Config hardware capture */
TMR6_HWCaptureCondCmd(CM_TMR6_2, TMR6_CH_B, TMR6_CAPT_COND_PWMB_RISING, ENABLE);
/* Start timer6_2 */
TMR6_Start(CM_TMR6_2);
}
//TimerA Config
static void App_TimerACfg(void)
{
stc_tmra_init_t stcTmraInit;
/* Enable TMRA_1 peripheral clock */
FCG_Fcg2PeriphClockCmd(FCG2_PERIPH_TMRA_1, ENABLE);
/************************* Configure TMRA_1 counter *************************/
(void)TMRA_StructInit(&stcTmraInit);
/* Config hardware count */
stcTmraInit.u8CountSrc = TMRA_CNT_SRC_HW;
stcTmraInit.u32PeriodValue = 0x0U;
(void)TMRA_Init(CM_TMRA_1, &stcTmraInit);
/************************* Configure TMRA_1_1 CMP ***************************/
/* CAP pin function set */
TMRA_SetFunc(CM_TMRA_1, TMRA_CH1, TMRA_FUNC_CAPT);
/* Config hardware capture */
TMRA_HWCaptureCondCmd(CM_TMRA_1, TMRA_CH1, TMRA_CAPT_COND_PWM_RISING, ENABLE);
/* Config hardware start */
TMRA_HWStartCondCmd(CM_TMRA_1, TMRA_START_COND_TRIG_FALLING, ENABLE);
/* Start timerA */
TMRA_Start(CM_TMRA_1);
/* Enable TMRA_4 peripheral clock */
FCG_Fcg2PeriphClockCmd(FCG2_PERIPH_TMRA_4, ENABLE);
/************************* Configure TMRA_4 counter *************************/
(void)TMRA_StructInit(&stcTmraInit);
/* Config software count */
stcTmraInit.sw_count.u8ClockDiv = TMRA_CLK_DIV1;
stcTmraInit.sw_count.u8CountMode = TMRA_MD_SAWTOOTH;
stcTmraInit.sw_count.u8CountDir = TMRA_DIR_UP;
stcTmraInit.u32PeriodValue = 0x0U;
(void)TMRA_Init(CM_TMRA_4, &stcTmraInit);
/************************* Configure TMRA_4_1 CMP ***************************/
/* CAP pin function set */
TMRA_SetFunc(CM_TMRA_4, TMRA_CH1, TMRA_FUNC_CAPT);
/* Config hardware capture */
TMRA_HWCaptureCondCmd(CM_TMRA_4, TMRA_CH1, TMRA_CAPT_COND_PWM_RISING, ENABLE);
/* Config hardware start */
TMRA_HWStartCondCmd(CM_TMRA_4, TMRA_START_COND_TRIG_FALLING, ENABLE);
/* Start timerA */
TMRA_Start(CM_TMRA_4);
/* Enable TMRA_5 peripheral clock */
FCG_Fcg2PeriphClockCmd(FCG2_PERIPH_TMRA_5, ENABLE);
/************************* Configure TMRA_5 counter *************************/
(void)TMRA_StructInit(&stcTmraInit);
/* Config hardware count */
stcTmraInit.u8CountSrc = TMRA_CNT_SRC_HW;
stcTmraInit.u32PeriodValue = 0x0U;
(void)TMRA_Init(CM_TMRA_5, &stcTmraInit);
/************************* Configure TMRA_5_1 CMP ***************************/
/* CAP pin function set */
TMRA_SetFunc(CM_TMRA_5, TMRA_CH1, TMRA_FUNC_CAPT);
/* Config hardware capture */
TMRA_HWCaptureCondCmd(CM_TMRA_5, TMRA_CH1, TMRA_CAPT_COND_PWM_RISING, ENABLE);
/* Config hardware start */
TMRA_HWStartCondCmd(CM_TMRA_5, TMRA_START_COND_TRIG_FALLING, ENABLE);
/* Start timerA */
TMRA_Start(CM_TMRA_5);
}
//Port Config
static void App_PortCfg(void)
{
/* GPIO initialize */
stc_gpio_init_t stcGpioInit;
/* PC13 set to GPIO-Output */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinDir = PIN_DIR_OUT;
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
(void)GPIO_Init(GPIO_PORT_C, GPIO_PIN_13, &stcGpioInit);
/* PC15 set to GPIO-Output */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinDir = PIN_DIR_OUT;
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
(void)GPIO_Init(GPIO_PORT_C, GPIO_PIN_15, &stcGpioInit);
/* PH0 set to XTAL-EXT/XTAL-OUT */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinAttr = PIN_ATTR_ANALOG;
(void)GPIO_Init(GPIO_PORT_H, GPIO_PIN_00, &stcGpioInit);
/* PH1 set to XTAL-IN */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinAttr = PIN_ATTR_ANALOG;
(void)GPIO_Init(GPIO_PORT_H, GPIO_PIN_01, &stcGpioInit);
/* PC0 set to GPIO-Output */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinDir = PIN_DIR_OUT;
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
(void)GPIO_Init(GPIO_PORT_C, GPIO_PIN_00, &stcGpioInit);
/* PC1 set to GPIO-Output */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinDir = PIN_DIR_OUT;
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
(void)GPIO_Init(GPIO_PORT_C, GPIO_PIN_01, &stcGpioInit);
/* PC2 set to GPIO-Output */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinDir = PIN_DIR_OUT;
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
(void)GPIO_Init(GPIO_PORT_C, GPIO_PIN_02, &stcGpioInit);
/* PC3 set to GPIO-Output */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinDir = PIN_DIR_OUT;
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
(void)GPIO_Init(GPIO_PORT_C, GPIO_PIN_03, &stcGpioInit);
/* PA0 set to GPIO-Input */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
stcGpioInit.u16PullUp = PIN_PU_OFF;
stcGpioInit.u16PinDrv=PIN_HIGH_DRV;//50mhz~100mhz
(void)GPIO_Init(GPIO_PORT_A, GPIO_PIN_00, &stcGpioInit);
/* PA1 set to GPIO-Input */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
stcGpioInit.u16PullUp = PIN_PU_OFF;
stcGpioInit.u16PinDrv=PIN_HIGH_DRV;
(void)GPIO_Init(GPIO_PORT_A, GPIO_PIN_01, &stcGpioInit);
/* PA2 set to GPIO-Input */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
stcGpioInit.u16PullUp = PIN_PU_OFF;
stcGpioInit.u16PinDrv=PIN_HIGH_DRV;
(void)GPIO_Init(GPIO_PORT_A, GPIO_PIN_02, &stcGpioInit);
/* PA3 set to GPIO-Input */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
stcGpioInit.u16PullUp = PIN_PU_OFF;
stcGpioInit.u16PinDrv=PIN_HIGH_DRV;
(void)GPIO_Init(GPIO_PORT_A, GPIO_PIN_03, &stcGpioInit);
/* PA4 set to GPIO-Input */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
stcGpioInit.u16PullUp = PIN_PU_OFF;
stcGpioInit.u16PinDrv=PIN_HIGH_DRV;
(void)GPIO_Init(GPIO_PORT_A, GPIO_PIN_04, &stcGpioInit);
/* PA5 set to GPIO-Input */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
stcGpioInit.u16PullUp = PIN_PU_OFF;
stcGpioInit.u16PinDrv=PIN_HIGH_DRV;
(void)GPIO_Init(GPIO_PORT_A, GPIO_PIN_05, &stcGpioInit);
/* PA6 set to GPIO-Input */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
stcGpioInit.u16PullUp = PIN_PU_OFF;
stcGpioInit.u16PinDrv=PIN_HIGH_DRV;
(void)GPIO_Init(GPIO_PORT_A, GPIO_PIN_06, &stcGpioInit);
/* PA7 set to GPIO-Input */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
stcGpioInit.u16PullUp = PIN_PU_OFF;
stcGpioInit.u16PinDrv=PIN_HIGH_DRV;
(void)GPIO_Init(GPIO_PORT_A, GPIO_PIN_07, &stcGpioInit);
/* PC4 set to GPIO-Output */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinDir = PIN_DIR_OUT;
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
(void)GPIO_Init(GPIO_PORT_C, GPIO_PIN_04, &stcGpioInit);
/* PC5 set to GPIO-Output */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinDir = PIN_DIR_OUT;
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
(void)GPIO_Init(GPIO_PORT_C, GPIO_PIN_05, &stcGpioInit);
/* PD8 set to GPIO-Input */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
stcGpioInit.u16PullUp = PIN_PU_OFF;
stcGpioInit.u16PinDrv= PIN_HIGH_DRV;// 设置为高驱动模式50MHZ~100MHz
(void)GPIO_Init(GPIO_PORT_D, GPIO_PIN_08, &stcGpioInit);
/* PD9 set to GPIO-Input */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
stcGpioInit.u16PullUp = PIN_PU_OFF;
stcGpioInit.u16PinDrv= PIN_HIGH_DRV;// 设置为高驱动模式50MHZ~100MHz
(void)GPIO_Init(GPIO_PORT_D, GPIO_PIN_09, &stcGpioInit);
/* PC6 set to GPIO-Output */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinDir = PIN_DIR_OUT;
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
(void)GPIO_Init(GPIO_PORT_C, GPIO_PIN_06, &stcGpioInit);
/* PC7 set to GPIO-Output */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinDir = PIN_DIR_OUT;
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
(void)GPIO_Init(GPIO_PORT_C, GPIO_PIN_07, &stcGpioInit);
/* PC8 set to GPIO-Output */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinDir = PIN_DIR_OUT;
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
(void)GPIO_Init(GPIO_PORT_C, GPIO_PIN_08, &stcGpioInit);
/* PC9 set to GPIO-Output */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinDir = PIN_DIR_OUT;
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
(void)GPIO_Init(GPIO_PORT_C, GPIO_PIN_09, &stcGpioInit);
/* PA8 set to GPIO-Input */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
stcGpioInit.u16PullUp = PIN_PU_OFF;
stcGpioInit.u16PinDrv=PIN_HIGH_DRV;
(void)GPIO_Init(GPIO_PORT_A, GPIO_PIN_08, &stcGpioInit);
/* PA9 set to GPIO-Input */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
stcGpioInit.u16PullUp = PIN_PU_OFF;
stcGpioInit.u16PinDrv= PIN_HIGH_DRV;// 设置为高驱动模式50MHZ~100MHz
(void)GPIO_Init(GPIO_PORT_A, GPIO_PIN_09, &stcGpioInit);
/* PC10 set to GPIO-Output */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinDir = PIN_DIR_OUT;
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
(void)GPIO_Init(GPIO_PORT_C, GPIO_PIN_10, &stcGpioInit);
/* PC11 set to GPIO-Output */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinDir = PIN_DIR_OUT;
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
(void)GPIO_Init(GPIO_PORT_C, GPIO_PIN_11, &stcGpioInit);
/* PC12 set to GPIO-Output */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinDir = PIN_DIR_OUT;
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
(void)GPIO_Init(GPIO_PORT_C, GPIO_PIN_12, &stcGpioInit);
/* PD0 set to GPIO-Input */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
stcGpioInit.u16PullUp = PIN_PU_OFF;
stcGpioInit.u16PinDrv= PIN_HIGH_DRV;// 设置为高驱动模式50MHZ~100MHz
(void)GPIO_Init(GPIO_PORT_D, GPIO_PIN_00, &stcGpioInit);
/* PD1 set to GPIO-Input */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
stcGpioInit.u16PullUp = PIN_PU_OFF;
stcGpioInit.u16PinDrv= PIN_HIGH_DRV;// 设置为高驱动模式50MHZ~100MHz
(void)GPIO_Init(GPIO_PORT_D, GPIO_PIN_01, &stcGpioInit);
/* PD2 set to GPIO-Input */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
stcGpioInit.u16PullUp = PIN_PU_OFF;
stcGpioInit.u16PinDrv= PIN_HIGH_DRV;// 设置为高驱动模式50MHZ~100MHz
(void)GPIO_Init(GPIO_PORT_D, GPIO_PIN_02, &stcGpioInit);
/* PD3 set to GPIO-Input */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
stcGpioInit.u16PullUp = PIN_PU_OFF;
stcGpioInit.u16PinDrv= PIN_HIGH_DRV;// 设置为高驱动模式50MHZ~100MHz
(void)GPIO_Init(GPIO_PORT_D, GPIO_PIN_03, &stcGpioInit);
/* PD4 set to GPIO-Input */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
stcGpioInit.u16PullUp = PIN_PU_OFF;
stcGpioInit.u16PinDrv= PIN_HIGH_DRV;// 设置为高驱动模式50MHZ~100MHz
(void)GPIO_Init(GPIO_PORT_D, GPIO_PIN_04, &stcGpioInit);
/* PD5 set to GPIO-Input */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
stcGpioInit.u16PullUp = PIN_PU_OFF;
stcGpioInit.u16PinDrv= PIN_HIGH_DRV;// 设置为高驱动模式50MHZ~100MHz
(void)GPIO_Init(GPIO_PORT_D, GPIO_PIN_05, &stcGpioInit);
/* PD6 set to GPIO-Input */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
stcGpioInit.u16PullUp = PIN_PU_OFF;
stcGpioInit.u16PinDrv= PIN_HIGH_DRV;// 设置为高驱动模式50MHZ~100MHz
(void)GPIO_Init(GPIO_PORT_D, GPIO_PIN_06, &stcGpioInit);
/* PD7 set to GPIO-Input */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
stcGpioInit.u16PullUp = PIN_PU_OFF;
stcGpioInit.u16PinDrv= PIN_HIGH_DRV;// 设置为高驱动模式50MHZ~100MHz
(void)GPIO_Init(GPIO_PORT_D, GPIO_PIN_07, &stcGpioInit);
/* PC14 set to GPIO-Output */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinDir = PIN_DIR_OUT;
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
(void)GPIO_Init(GPIO_PORT_C, GPIO_PIN_14, &stcGpioInit);
/* PE7 set to GPIO-Output */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinDir = PIN_DIR_OUT;
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
(void)GPIO_Init(GPIO_PORT_E, GPIO_PIN_07, &stcGpioInit);
/* PE8 set to GPIO-Output */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinDir = PIN_DIR_OUT;
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
(void)GPIO_Init(GPIO_PORT_E, GPIO_PIN_08, &stcGpioInit);
/* PE9 set to GPIO-Output */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinDir = PIN_DIR_OUT;
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
(void)GPIO_Init(GPIO_PORT_E, GPIO_PIN_09, &stcGpioInit);
/* PE11 set to GPIO-Input */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
(void)GPIO_Init(GPIO_PORT_E, GPIO_PIN_11, &stcGpioInit);
/* PE10 set to GPIO-Output */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinDir = PIN_DIR_OUT;
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
(void)GPIO_Init(GPIO_PORT_E, GPIO_PIN_10, &stcGpioInit);
/* PE12 set to GPIO-Output */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinDir = PIN_DIR_OUT;
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
(void)GPIO_Init(GPIO_PORT_E, GPIO_PIN_12, &stcGpioInit);
/* PE13 set to GPIO-Output */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinDir = PIN_DIR_OUT;
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
(void)GPIO_Init(GPIO_PORT_E, GPIO_PIN_13, &stcGpioInit);
/* PE6 set to GPIO-Output */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinDir = PIN_DIR_OUT;
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
(void)GPIO_Init(GPIO_PORT_E, GPIO_PIN_06, &stcGpioInit);
/* PE3 set to GPIO-Output */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinDir = PIN_DIR_OUT;
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
(void)GPIO_Init(GPIO_PORT_E, GPIO_PIN_03, &stcGpioInit);
/* PE2 set to GPIO-Output */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinDir = PIN_DIR_OUT;
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
(void)GPIO_Init(GPIO_PORT_E, GPIO_PIN_02, &stcGpioInit);
/* PD14 set to GPIO-Input */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
(void)GPIO_Init(GPIO_PORT_D, GPIO_PIN_14, &stcGpioInit);
/* PD15 set to GPIO-Input */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
(void)GPIO_Init(GPIO_PORT_D, GPIO_PIN_15, &stcGpioInit);
/* PB11/MD set to GPIO-Input */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
(void)GPIO_Init(GPIO_PORT_B, GPIO_PIN_11, &stcGpioInit);
/* PB15 set to GPIO-Output */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinDir = PIN_DIR_OUT;
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
(void)GPIO_Init(GPIO_PORT_B, GPIO_PIN_15, &stcGpioInit);
/* PB14 set to GPIO-Output */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinDir = PIN_DIR_OUT;
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
(void)GPIO_Init(GPIO_PORT_B, GPIO_PIN_14, &stcGpioInit);
/* PB13 set to GPIO-Output */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinDir = PIN_DIR_OUT;
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
(void)GPIO_Init(GPIO_PORT_B, GPIO_PIN_13, &stcGpioInit);
/* PB10 set to GPIO-Output */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinDir = PIN_DIR_OUT;
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
(void)GPIO_Init(GPIO_PORT_B, GPIO_PIN_10, &stcGpioInit);
/* PE14 set to EIRQ14 */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16ExtInt = PIN_EXTINT_ON;
(void)GPIO_Init(GPIO_PORT_E, GPIO_PIN_14, &stcGpioInit);
/* PA15 set to EIRQ15 */
GPIO_SetDebugPort(GPIO_PIN_TDI, DISABLE);
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16ExtInt = PIN_EXTINT_ON;
(void)GPIO_Init(GPIO_PORT_A, GPIO_PIN_15, &stcGpioInit);
/* PB1 set to GPIO-Input */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
stcGpioInit.u16PullUp=PIN_PU_ON;
(void)GPIO_Init(GPIO_PORT_B, GPIO_PIN_01, &stcGpioInit);
/* PB2 set to GPIO-Input */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
stcGpioInit.u16PullUp=PIN_PU_ON;
stcGpioInit.u16PullUp=PIN_PU_ON;
(void)GPIO_Init(GPIO_PORT_B, GPIO_PIN_02, &stcGpioInit);
/* PB0 set to GPIO-Input */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
stcGpioInit.u16PullUp=PIN_PU_ON;
(void)GPIO_Init(GPIO_PORT_B, GPIO_PIN_00, &stcGpioInit);
/* PD12 set to GPIO-Output */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinDir = PIN_DIR_OUT;
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
(void)GPIO_Init(GPIO_PORT_D, GPIO_PIN_12, &stcGpioInit);
/* PD13 set to GPIO-Output */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinDir = PIN_DIR_OUT;
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
(void)GPIO_Init(GPIO_PORT_D, GPIO_PIN_13, &stcGpioInit);
/* PB3 set to GPIO-Input */
GPIO_SetDebugPort(GPIO_PIN_TDO, DISABLE);
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
stcGpioInit.u16PullUp=PIN_PU_ON;
(void)GPIO_Init(GPIO_PORT_B, GPIO_PIN_03, &stcGpioInit);
/* PB4 set to GPIO-Input */
GPIO_SetDebugPort(GPIO_PIN_TRST, DISABLE);
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
stcGpioInit.u16PullUp=PIN_PU_ON;
(void)GPIO_Init(GPIO_PORT_B, GPIO_PIN_04, &stcGpioInit);
/* PB5 set to GPIO-Input */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
stcGpioInit.u16PullUp=PIN_PU_ON;
(void)GPIO_Init(GPIO_PORT_B, GPIO_PIN_05, &stcGpioInit);
/* PB6 set to GPIO-Input */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
stcGpioInit.u16PullUp=PIN_PU_ON;
(void)GPIO_Init(GPIO_PORT_B, GPIO_PIN_06, &stcGpioInit);
/* PB8 set to GPIO-Input */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
stcGpioInit.u16PullUp=PIN_PU_ON;
(void)GPIO_Init(GPIO_PORT_B, GPIO_PIN_08, &stcGpioInit);
/* PB9 set to GPIO-Input */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
stcGpioInit.u16PullUp=PIN_PU_ON;
(void)GPIO_Init(GPIO_PORT_B, GPIO_PIN_09, &stcGpioInit);
/* PB7 set to GPIO-Input */
(void)GPIO_StructInit(&stcGpioInit);
stcGpioInit.u16PinAttr = PIN_ATTR_DIGITAL;
stcGpioInit.u16PullUp=PIN_PU_ON;
(void)GPIO_Init(GPIO_PORT_B, GPIO_PIN_07, &stcGpioInit);
GPIO_SetFunc(GPIO_PORT_E,GPIO_PIN_04,GPIO_FUNC_40);//SPI3-MOSI
GPIO_SetFunc(GPIO_PORT_E,GPIO_PIN_05,GPIO_FUNC_41);//SPI3-MISO
GPIO_SetFunc(GPIO_PORT_H,GPIO_PIN_02,GPIO_FUNC_15);//EVENTOUT
GPIO_SetFunc(GPIO_PORT_E,GPIO_PIN_15,GPIO_FUNC_5);//TIMA-5-TRIG
GPIO_SetFunc(GPIO_PORT_B,GPIO_PIN_12,GPIO_FUNC_3);//TIM6-TRIGB
GPIO_SetFunc(GPIO_PORT_D,GPIO_PIN_10,GPIO_FUNC_48);//I2C3-SDA
GPIO_SetFunc(GPIO_PORT_D,GPIO_PIN_11,GPIO_FUNC_49);//I2C3-SCL
GPIO_SetFunc(GPIO_PORT_A,GPIO_PIN_10,GPIO_FUNC_49);//I2C1-SCL
GPIO_SetFunc(GPIO_PORT_A,GPIO_PIN_11,GPIO_FUNC_48);//I2C1-SDA
GPIO_SetFunc(GPIO_PORT_A,GPIO_PIN_12,GPIO_FUNC_4);//TIMA-1-TRIG
GPIO_SetFunc(GPIO_PORT_E,GPIO_PIN_00,GPIO_FUNC_42);//SPI3-SS0
GPIO_SetFunc(GPIO_PORT_E,GPIO_PIN_01,GPIO_FUNC_43);//SPI3-SCK
}
GPIO A, 数据输入真实地址是多少? (0x40053800UL) ??还是多少? GPIO A->PIDRA 真实值是0x40053800UL?
GPIO C->PIDRA 又是多少? 不像STM32等, 都标明了具体的, 代码里都是穿透。
页:
[1]