打印
[DemoCode下载]

M451的GPIO操作相关库函数

[复制链接]
4947|19
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
稳稳の幸福|  楼主 | 2015-4-3 11:47 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
<div class="blockcode"><blockquote>/**************************************************************************//**
* [url=home.php?mod=space&uid=288409]@file[/url]     gpio.c
* [url=home.php?mod=space&uid=895143]@version[/url]  V3.00
* $Revision: 4 $
* $Date: 14/10/16 5:40p $
* [url=home.php?mod=space&uid=247401]@brief[/url]    M451 series GPIO driver source file
*
* @note
* Copyright (C) 2014 Nuvoton Technology Corp. All rights reserved.
*****************************************************************************/

#include "M451Series.h"

/** @addtogroup M451_Device_Driver M451 Device Driver
  @{
*/

/** @addtogroup M451_GPIO_Driver GPIO Driver
  @{
*/

/** @addtogroup M451_GPIO_EXPORTED_FUNCTIONS GPIO Exported Functions
  @{
*/

/**
* @brief       Set GPIO operation mode
*
* @param[in]   port        GPIO port. It could be PA, PB, PC, PD, PE or PF.
* @param[in]   u32PinMask  The single or multiple pins of specified GPIO port.
*                          It could be BIT0 ~ BIT15 for PA, PB, PC and PD GPIO port.
*                          It could be BIT0 ~ BIT14 for PE GPIO port.
*                          It could be BIT0 ~ BIT7 for PF GPIO port.
* @param[in]   u32Mode     Operation mode.  It could be \n
*                          GPIO_MODE_INPUT, GPIO_MODE_OUTPUT, GPIO_MODE_OPEN_DRAIN, GPIO_MODE_QUASI.
*
* [url=home.php?mod=space&uid=266161]@return[/url]      None
*
* @details     This function is used to set specified GPIO operation mode.
*/
void GPIO_SetMode(GPIO_T *port, uint32_t u32PinMask, uint32_t u32Mode)
{
    uint32_t i;

    for(i = 0; i < GPIO_PIN_MAX; i++)
    {
        if(u32PinMask & (1 << i))
        {
            port->MODE = (port->MODE & ~(0x3 << (i << 1))) | (u32Mode << (i << 1));
        }
    }
}

/**
* @brief       Enable GPIO interrupt
*
* @param[in]   port            GPIO port. It could be PA, PB, PC, PD, PE or PF.
* @param[in]   u32Pin          The pin of specified GPIO port.
*                              It could be 0 ~ 15 for PA, PB, PC and PD GPIO port.
*                              It could be 0 ~ 14 for PE GPIO port.
*                              It could be 0 ~ 7 for PF GPIO port.
* @param[in]   u32IntAttribs   The interrupt attribute of specified GPIO pin. It could be \n
*                              GPIO_INT_RISING, GPIO_INT_FALLING, GPIO_INT_BOTH_EDGE, GPIO_INT_HIGH, GPIO_INT_LOW.
*
* @return      None
*
* @details     This function is used to enable specified GPIO pin interrupt.
*/
void GPIO_EnableInt(GPIO_T *port, uint32_t u32Pin, uint32_t u32IntAttribs)
{
    port->INTTYPE |= (((u32IntAttribs >> 24) & 0xFFUL) << u32Pin);
    port->INTEN |= ((u32IntAttribs & 0xFFFFFFUL) << u32Pin);
}


/**
* @brief       Disable GPIO interrupt
*
* @param[in]   port        GPIO port. It could be PA, PB, PC, PD, PE or PF.
* @param[in]   u32Pin      The pin of specified GPIO port.
*                          It could be 0 ~ 15 for PA, PB, PC and PD GPIO port.
*                          It could be 0 ~ 14 for PE GPIO port.
*                          It could be 0 ~ 7 for PF GPIO port.
*
* @return      None
*
* @details     This function is used to enable specified GPIO pin interrupt.
*/
void GPIO_DisableInt(GPIO_T *port, uint32_t u32Pin)
{
    port->INTTYPE &= ~(1UL << u32Pin);
    port->INTEN &= ~((0x00010001UL) << u32Pin);
}


/*@}*/ /* end of group M451_GPIO_EXPORTED_FUNCTIONS */

/*@}*/ /* end of group M451_GPIO_Driver */

/*@}*/ /* end of group M451_Device_Driver */

/*** (C) COPYRIGHT 2014 Nuvoton Technology Corp. ***/

沙发
稳稳の幸福|  楼主 | 2015-4-3 12:45 | 只看该作者
看了看这个。c里面没有操作IO的,都是中断相关的。

使用特权

评论回复
板凳
稳稳の幸福|  楼主 | 2015-4-3 12:47 | 只看该作者
没有看懂那个GPIO_DisableEINT    GPIO_DisableInt
这个是什么意思?关闭GPIO中断源吗?

使用特权

评论回复
地板
稳稳の幸福|  楼主 | 2015-4-3 12:50 | 只看该作者
/**
* @brief       Set GPIO Port OUT Data
*
* @param[in]   port        GPIO port. It could be PA, PB, PC, PD, PE or PF.
* @param[in]   u32Data     GPIO port data.
*
* @return      None
*
* @details     Set the Data into specified GPIO port.
*/
#define GPIO_SET_OUT_DATA(port, u32Data)    ((port)->DOUT = (u32Data))

使用特权

评论回复
5
稳稳の幸福|  楼主 | 2015-4-3 12:50 | 只看该作者
上面的这个设置输出数据,一共两个参量,port我知道,指的是端口。

使用特权

评论回复
6
稳稳の幸福|  楼主 | 2015-4-3 12:51 | 只看该作者
可以是PA,PB,PC等,那么GPIO port data,到底是什么呢,根据定义,好像是个32位的数据,不知道可以是什么,也没有给的例子,我一会儿去例程看看。

使用特权

评论回复
7
稳稳の幸福|  楼主 | 2015-4-4 20:43 | 只看该作者
这种库函数总是喜欢用指针概念

使用特权

评论回复
8
598330983| | 2015-4-5 10:43 | 只看该作者
楼主说的基本操作在头文件里面

使用特权

评论回复
9
mintspring| | 2015-4-5 21:02 | 只看该作者
这个好多在.h头文件就搞定了,只有复杂的才在对应.c做。

使用特权

评论回复
10
734774645| | 2017-2-19 18:06 | 只看该作者
不知道GPIO有没有时钟的配置。

使用特权

评论回复
11
734774645| | 2017-2-19 18:13 | 只看该作者
不好意思,不是通过一个IO的时钟配置,那个是STM32的,新唐的应该是直接使用的某个时钟系统的

使用特权

评论回复
12
598330983| | 2017-2-19 19:23 | 只看该作者
/**************************************************************************//**
* [url=home.php?mod=space&uid=288409]@file[/url]     main.c
* [url=home.php?mod=space&uid=895143]@version[/url]  V1.00
* $Date: 15/09/02 10:03a $
* [url=home.php?mod=space&uid=247401]@brief[/url]    Toggle PC.9 to turn on / off the board LED
*
* @note
* Copyright (C) 2013~2015 Nuvoton Technology Corp. All rights reserved.
*
******************************************************************************/
#include <stdio.h>
#include "M451Series.h"

#define HCLK_CLOCK       72000000


void SYS_Init(void)
{
    /*---------------------------------------------------------------------------------------------------------*/
    /* Init System Clock                                                                                       */
    /*---------------------------------------------------------------------------------------------------------*/
    /* Unlock protected registers */
    SYS_UnlockReg();

    /* Enable HIRC clock (Internal RC 22.1184MHz) */
    CLK_EnableXtalRC(CLK_PWRCTL_HIRCEN_Msk);

    /* Wait for HIRC clock ready */
    CLK_WaitClockReady(CLK_STATUS_HIRCSTB_Msk);

    /* Select HCLK clock source as HIRC and and HCLK clock divider as 1 */
    CLK_SetHCLK(CLK_CLKSEL0_HCLKSEL_HIRC, CLK_CLKDIV0_HCLK(1));

    /* Enable HXT clock (external XTAL 12MHz) */
    CLK_EnableXtalRC(CLK_PWRCTL_HXTEN_Msk);

    /* Wait for HXT clock ready */
    CLK_WaitClockReady(CLK_STATUS_HXTSTB_Msk);

    /* Set core clock as HCLK_CLOCK */
    CLK_SetCoreClock(HCLK_CLOCK);

    /* Update System Core Clock */
    /* User can use SystemCoreClockUpdate() to calculate SystemCoreClock. */
    SystemCoreClockUpdate();

    /*---------------------------------------------------------------------------------------------------------*/
    /* Init I/O Multi-function                                                                                 */
    /*---------------------------------------------------------------------------------------------------------*/
    /* Set GPD multi-function pins for UART0 RXD and TXD */
    SYS->GPD_MFPL &= ~(SYS_GPD_MFPL_PD6MFP_Msk | SYS_GPD_MFPL_PD1MFP_Msk);
    SYS->GPD_MFPL |= (SYS_GPD_MFPL_PD6MFP_UART0_RXD | SYS_GPD_MFPL_PD1MFP_UART0_TXD);

    /* Lock protected registers */
    SYS_LockReg();
}


/*---------------------------------------------------------------------------------------------------------*/
/* MAIN function                                                                                           */
/*---------------------------------------------------------------------------------------------------------*/
int main(void)
{
    /* Init System, IP clock and multi-function I/O
       In the end of SYS_Init() will issue SYS_LockReg()
       to lock protected register. If user want to write
       protected register, please issue SYS_UnlockReg()
       to unlock protected register if necessary */
    SYS_Init();

    /* Select SysTick clock source as HXT */
    CLK_SetSysTickClockSrc(CLK_CLKSEL0_STCLKSEL_HXT);

    /* Configure PC.9 as Output mode */
    GPIO_SetMode(PC, BIT9, GPIO_MODE_OUTPUT);

    while(1)
    {
        /* Configure PC.9 to low */
        PC9 = 0;
        /* Delay 200 ms */
        CLK_SysTickDelay(200000);

        /* Configure PC.9 to high */
        PC9 = 1;
        /* Delay 200 ms */
        CLK_SysTickDelay(200000);
    }

}

使用特权

评论回复
13
598330983| | 2017-2-19 19:23 | 只看该作者
/**************************************************************************//**
* @file     main.c
* @version  V1.00
* $Revision: 2 $
* $Date: 15/09/02 10:03a $
* @brief    Display an image on TFT LCD panel via SPI interface and control LED.
*
* @note
* Copyright (C) 2013~2015 Nuvoton Technology Corp. All rights reserved.
*
******************************************************************************/
#include <stdio.h>
#include "M451Series.h"

#define ILI9341_RESET   PB15
#define ILI9341_DC      PB11
#define ILI9341_LED     PB5

#define LED1            PC3
#define LED2            PC2
#define LED3            PB1
#define LED4            PC7

#define LED_R           PC9
#define LED_G           PC10
#define LED_B           PC11


extern uint8_t u8Image[153600];
extern uint8_t Font8x16[];

#define        White           0xFFFF
#define Black           0x0000
#define Blue            0x001F
#define Blue2           0x051F
#define Red             0xF800
#define Magenta         0xF81F
#define Green           0x07E0
#define Cyan            0x7FFF
#define Yellow          0xFFE0

uint8_t LCD_ReadReg(uint8_t u8Comm)
{
    SPI_ClearRxFIFO(SPI2);

    ILI9341_DC = 0;

    SPI_WRITE_TX(SPI2, u8Comm);
    SPI_WRITE_TX(SPI2, 0x00);

    // wait tx finish
    while(SPI_IS_BUSY(SPI2));

    SPI_READ_RX(SPI2);

    return (SPI_READ_RX(SPI2));
}

void LCD_WriteCommand(uint8_t u8Comm)
{
    ILI9341_DC = 0;

    SPI_WRITE_TX(SPI2, u8Comm);

    // wait tx finish
    while(SPI_IS_BUSY(SPI2));
}

void LCD_WriteData(uint8_t u8Data)
{
    ILI9341_DC = 1;

    SPI_WRITE_TX(SPI2, u8Data);

    // wait tx finish
    while(SPI_IS_BUSY(SPI2));
}

void ILI9341_LCD_DisplayOnScreen(void)
{
    uint32_t i,j;
    uint16_t *u16ImgPtr = (uint16_t *) &u8Image[0];

    LCD_WriteCommand(0x2c);

    ILI9341_DC = 1;

    /* Need to disable and then can change data width to 16-bit */
    SPI_DISABLE(SPI2);
    SPI_SET_DATA_WIDTH(SPI2, 16);
    SPI_ENABLE(SPI2);

    /* Load image */
    for (i=0; i<320; i++) {
        for (j=0; j<240; j++) {
            while(SPI_GET_TX_FIFO_FULL_FLAG(SPI2));
            SPI_WRITE_TX(SPI2, *(u16ImgPtr++));
        }
    }

    // wait tx finish
    while(SPI_IS_BUSY(SPI2));

    /* Change data width back to 8-bit */
    SPI_DISABLE(SPI2);
    SPI_SET_DATA_WIDTH(SPI2, 8);
    SPI_ENABLE(SPI2);

    LCD_WriteCommand(0x29);
}

void ILI9341_LCD_SetAddress(uint32_t x1,uint32_t x2,uint32_t y1,uint32_t y2)
{
    if(x1 >= 240)
        x1 = 239;
    if(x2 >= 240)
        x2 = 239;  
    if(y1 >= 320)
        y1 = 319;  
    if(y2 >= 320)
        y2 = 319;   
   
    LCD_WriteCommand(0x2a);
    LCD_WriteData(x1>>8);
    LCD_WriteData(x1);
    LCD_WriteData(x2>>8);
    LCD_WriteData(x2);

    LCD_WriteCommand(0x2b);
    LCD_WriteData(y1>>8);
    LCD_WriteData(y1);
    LCD_WriteData(y2>>8);
    LCD_WriteData(y2);
}

void ILI9341_LCD_PutChar8x16(uint16_t x, uint16_t y, uint8_t c, uint32_t fColor, uint32_t bColor)
{
        uint32_t i,j;
        for(i=0;i<16;i++){
        uint8_t m=Font8x16[c*16+i];
        ILI9341_LCD_SetAddress(x+i,x+i,y,y+7);
        LCD_WriteCommand(0x2c);        
        
                for(j=0;j<8;j++){
                        if((m&0x01)==0x01){
                LCD_WriteData(fColor>>8);
                                LCD_WriteData(fColor);
                        }
                        else{
                LCD_WriteData(bColor>>8);
                                LCD_WriteData(bColor);
                        }
                        m>>=1;
                }
        }
}

void ILI9341_LCD_PutString(uint16_t x, uint16_t y,uint8_t *s, uint32_t fColor, uint32_t bColor)
{
    uint8_t l=0;
    while(*s){
        if(*s<0x80){
            ILI9341_LCD_PutChar8x16(x,312-y-l*8,*s,fColor,bColor);
            s++;
            l++;
                }
        }       
}
void ILI9341_LCD_Init(void)
{
    /* Configure DC/RESET/LED pins */
    ILI9341_DC =0;
    ILI9341_RESET=0;
    ILI9341_LED=0;

    GPIO_SetMode(PB, BIT5, GPIO_MODE_OUTPUT);
    GPIO_SetMode(PB, BIT11, GPIO_MODE_OUTPUT);
    GPIO_SetMode(PB, BIT15, GPIO_MODE_OUTPUT);

    /* Configure LCD */
    ILI9341_DC = 1;

    ILI9341_RESET = 0;
    TIMER_Delay(TIMER0, 20000);

    ILI9341_RESET = 1;
    TIMER_Delay(TIMER0, 40000);

    LCD_WriteCommand(0xCB);
    LCD_WriteData(0x39);
    LCD_WriteData(0x2C);
    LCD_WriteData(0x00);
    LCD_WriteData(0x34);
    LCD_WriteData(0x02);

    LCD_WriteCommand(0xCF);
    LCD_WriteData(0x00);
    LCD_WriteData(0xC1);
    LCD_WriteData(0x30);

    LCD_WriteCommand(0xE8);
    LCD_WriteData(0x85);
    LCD_WriteData(0x00);
    LCD_WriteData(0x78);

    LCD_WriteCommand(0xEA);
    LCD_WriteData(0x00);
    LCD_WriteData(0x00);

    LCD_WriteCommand(0xED);
    LCD_WriteData(0x64);
    LCD_WriteData(0x03);
    LCD_WriteData(0x12);
    LCD_WriteData(0x81);

    LCD_WriteCommand(0xF7);
    LCD_WriteData(0x20);

    LCD_WriteCommand(0xC0);
    LCD_WriteData(0x23);

    LCD_WriteCommand(0xC1);
    LCD_WriteData(0x10);

    LCD_WriteCommand(0xC5);
    LCD_WriteData(0x3e);
    LCD_WriteData(0x28);

    LCD_WriteCommand(0xC7);
    LCD_WriteData(0x86);

    LCD_WriteCommand(0x36);
    LCD_WriteData(0x48);

    LCD_WriteCommand(0x3A);
    LCD_WriteData(0x55);

    LCD_WriteCommand(0xB1);
    LCD_WriteData(0x00);
    LCD_WriteData(0x18);

    LCD_WriteCommand(0xB6);
    LCD_WriteData(0x08);
    LCD_WriteData(0x82);
    LCD_WriteData(0x27);

    LCD_WriteCommand(0xF2);
    LCD_WriteData(0x00);

    LCD_WriteCommand(0x26);
    LCD_WriteData(0x01);

    LCD_WriteCommand(0xE0);
    LCD_WriteData(0x0F);
    LCD_WriteData(0x31);
    LCD_WriteData(0x2B);
    LCD_WriteData(0x0C);
    LCD_WriteData(0x0E);
    LCD_WriteData(0x08);
    LCD_WriteData(0x4E);
    LCD_WriteData(0xF1);
    LCD_WriteData(0x37);
    LCD_WriteData(0x07);
    LCD_WriteData(0x10);
    LCD_WriteData(0x03);
    LCD_WriteData(0x0E);
    LCD_WriteData(0x09);
    LCD_WriteData(0x00);

    LCD_WriteCommand(0xE1);
    LCD_WriteData(0x00);
    LCD_WriteData(0x0E);
    LCD_WriteData(0x14);
    LCD_WriteData(0x03);
    LCD_WriteData(0x11);
    LCD_WriteData(0x07);
    LCD_WriteData(0x31);
    LCD_WriteData(0xC1);
    LCD_WriteData(0x48);
    LCD_WriteData(0x08);
    LCD_WriteData(0x0F);
    LCD_WriteData(0x0C);
    LCD_WriteData(0x31);
    LCD_WriteData(0x36);
    LCD_WriteData(0x0F);

    LCD_WriteCommand(0x11);
    TIMER_Delay(TIMER0, 60000);

    LCD_WriteCommand(0x29);    //Display on

    ILI9341_LED = 1;
}

void LED_Init(void)
{
    GPIO_SetMode(PB, BIT1, GPIO_MODE_OUTPUT);
    GPIO_SetMode(PC, BIT2, GPIO_MODE_OUTPUT);
    GPIO_SetMode(PC, BIT3, GPIO_MODE_OUTPUT);
    GPIO_SetMode(PC, BIT7, GPIO_MODE_OUTPUT);
    GPIO_SetMode(PC, BIT9, GPIO_MODE_OUTPUT);
    GPIO_SetMode(PC, BIT10, GPIO_MODE_OUTPUT);
    GPIO_SetMode(PC, BIT11, GPIO_MODE_OUTPUT);   
}

void LED_Light(uint32_t u32LED)
{
    LED1 = u32LED;
    u32LED = u32LED>>1;
    LED2 = u32LED;
    u32LED = u32LED>>1;
    LED3 = u32LED;
    u32LED = u32LED>>1;
    LED4 = u32LED;
    u32LED = u32LED>>1;
    LED_R = u32LED;
    u32LED = u32LED>>1;   
    LED_G = u32LED;
    u32LED = u32LED>>1;   
    LED_B = u32LED;
    u32LED = u32LED>>1;   
}


void SYS_Init(void)
{
    /*---------------------------------------------------------------------------------------------------------*/
    /* Init System Clock                                                                                       */
    /*---------------------------------------------------------------------------------------------------------*/
    /* Unlock protected registers */
    SYS_UnlockReg();

    /* Enable External XTAL (4~24 MHz) */
    CLK_EnableXtalRC(CLK_PWRCTL_HXTEN_Msk);

    /* Waiting for 12MHz clock ready */
    CLK_WaitClockReady( CLK_STATUS_HXTSTB_Msk);

    /* Switch HCLK clock source to HXT */
    CLK_SetHCLK(CLK_CLKSEL0_HCLKSEL_HXT,CLK_CLKDIV0_HCLK(1));

    /* Set PLL to power down mode and PLL_STB bit in CLKSTATUS register will be cleared by hardware.*/
    CLK->PLLCTL |= CLK_PLLCTL_PD_Msk;

    /* Set PLL frequency */
    CLK->PLLCTL = CLK_PLLCTL_72MHz_HXT;

    /* Waiting for clock ready */
    CLK_WaitClockReady(CLK_STATUS_PLLSTB_Msk);

    /* Switch HCLK clock source to PLL */
    CLK_SetHCLK(CLK_CLKSEL0_HCLKSEL_PLL,CLK_CLKDIV0_HCLK(1));

    /* Enable IP clock */
    CLK_EnableModuleClock(UART0_MODULE);
    CLK_EnableModuleClock(TMR0_MODULE);
    CLK_EnableModuleClock(SPI2_MODULE);

    /* Select IP clock source */
    CLK_SetModuleClock(UART0_MODULE, CLK_CLKSEL1_UARTSEL_HXT, CLK_CLKDIV0_UART(1));
    CLK_SetModuleClock(TMR0_MODULE, CLK_CLKSEL1_TMR0SEL_HXT, 0);
    CLK_SetModuleClock(SPI2_MODULE, CLK_CLKSEL2_SPI2SEL_PLL, 0);

    /* Update System Core Clock */
    /* User can use SystemCoreClockUpdate() to calculate SystemCoreClock. */
    SystemCoreClockUpdate();

    /*---------------------------------------------------------------------------------------------------------*/
    /* Init I/O Multi-function                                                                                 */
    /*---------------------------------------------------------------------------------------------------------*/
    /* Set GPG multi-function pins for UART0 RXD and TXD */
    SYS->GPD_MFPL = SYS_GPD_MFPL_PD6MFP_UART0_RXD | SYS_GPD_MFPL_PD1MFP_UART0_TXD ;

    /* SPI2: GPD12=SS, GPD15=CLK, GPD14=MISO, GPD13=MOSI */
    SYS->GPD_MFPH = SYS_GPD_MFPH_PD12MFP_SPI2_SS | SYS_GPD_MFPH_PD13MFP_SPI2_MOSI | SYS_GPD_MFPH_PD14MFP_SPI2_MISO | SYS_GPD_MFPH_PD15MFP_SPI2_CLK;

    /* Lock protected registers */
    SYS_LockReg();
}



int main(void)
{
    uint32_t u32temp = 0;
    /* Init System, IP clock and multi-function I/O */
    SYS_Init();
    LED_Init();

    /* Init UART to 115200-8n1 for print message */
    UART_Open(UART0, 115200);

    /* Configure SPI3 as a master, MSB first, 8-bit transaction, SPI Mode-0 timing, clock is 4MHz */
    SPI_Open(SPI2, SPI_MASTER, SPI_MODE_0, 8, 4000000);

    /* Configure SPI1 as a low level active device. */
    SPI_EnableAutoSS(SPI2, SPI_SS, SPI_SS_ACTIVE_LOW);

    /* Start SPI */
    SPI_ENABLE(SPI2);

    /* Init LCD */
    ILI9341_LCD_Init();

    /* Setup display address */
    ILI9341_LCD_SetAddress(0, 239, 0, 319);

    /* Show the image on the screen */
    ILI9341_LCD_DisplayOnScreen();

    while(1)
    {
        CLK_SysTickDelay(200000);
        LED_Light(u32temp++);
        if(PA8 == 0)
            ILI9341_LCD_PutString(50,60,"Hello World!",Red,Yellow);
        if(PD2 == 0)
            ILI9341_LCD_PutString(50,60,"I Love You!",Red,Yellow);            
    }
}

使用特权

评论回复
14
heisexingqisi| | 2017-2-19 23:25 | 只看该作者
void GPIO_SetMode(GPIO_T *port, uint32_t u32PinMask, uint32_t u32Mode)

使用特权

评论回复
15
heisexingqisi| | 2017-2-19 23:26 | 只看该作者
PinMask 这个概念有点神秘。

使用特权

评论回复
16
gejigeji521| | 2017-2-19 23:57 | 只看该作者

中断的形式有
       GPIO_INT_RISING, GPIO_INT_FALLING, GPIO_INT_BOTH_EDGE, GPIO_INT_HIGH, GPIO_INT_LOW.

使用特权

评论回复
17
gejigeji521| | 2017-2-19 23:57 | 只看该作者
上升沿,下降沿,双边沿,低电平。。。
低电平的跟下降沿的区别应该在于只要开机是低电平就进入。

使用特权

评论回复
18
gejigeji521| | 2017-2-19 23:58 | 只看该作者
通过IO的中断还是可以做很多事情的。比如测量脉冲宽度,或者检测红外信号。

使用特权

评论回复
19
yiyigirl2014| | 2017-2-20 00:15 | 只看该作者
void GPIO_DisableInt(GPIO_T *port, uint32_t u32Pin)
{
    port->INTTYPE &= ~(1UL << u32Pin);
    port->INTEN &= ~((0x00010001UL) << u32Pin);
}
关闭这个中断,需要两个参数,对应端口和对应管脚编号。

使用特权

评论回复
20
mintspring| | 2017-2-20 00:16 | 只看该作者
PIN MASK可以通过逻辑运算组合操作。

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

185

主题

3267

帖子

8

粉丝