ald_gpio.c 17.6 KB
Newer Older
W
wangyq2018 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
/**
  *********************************************************************************
  *
  * @file    ald_gpio.c
  * @brief   GPIO module driver.
  *          This file provides firmware functions to manage the following
  *          functionalities of the General Purpose Input/Output (GPIO) peripheral:
  *           + Initialization functions
  *           + IO operation functions
  *           + Control functions
  *
  * @version V1.0
  * @date    07 Nov 2017
  * @author  AE Team
  * @note
  *
  * Copyright (C) Shanghai Eastsoft Microelectronics Co. Ltd. All rights reserved.
  *
  *********************************************************************************
  * @verbatim
  ==============================================================================
                    ##### GPIO Peripheral features #####
  ==============================================================================
  [..]
  Subject to the specific hardware characteristics of each I/O port listed in the datasheet, each
  port bit of the General Purpose IO (GPIO) Ports, can be individually configured by software
  in several modes:
  (+) Input mode
  (+) Analog mode
  (+) Output mode
  (+) External interrupt/event lines

  [..]
  During and just after reset, the external interrupt lines are not active and
  the I/O ports are configured Analog mode.

  [..]
  All GPIO pins have weak internal pull-up and pull-down resistors, which can be
  activated or not.

  [..]
  In Output mode, each IO can be configured on open-drain or push-pull
  type and the Output driver can be selected depending on ODRV register.

  [..]
  In Input mode, each IO can select filter function.

  [..]
  Each IO can select TTL or SMIT type.

  [..]
  Each IO have up to eight functions, user can configure the functions depend
  on the user's environment.

  [..]
  Each IO can be locked. Once locked, uesr can only change the output data.
  Only when the CPU reset to unlock the GPIO port.

  [..]
  All ports have external interrupt/event capability. To use external interrupt
  lines, the port must be configured in input mode. All available GPIO pins are
  connected to the 16 external interrupt/event lines from EXTI0 to EXTI15.

  [..]
  Each input line can be independently configured to select the type (event or interrupt) and
  the corresponding trigger event (rising or falling). Each line can also masked
  independently. A pending register maintains the status line of the interrupt requests.

  ==============================================================================
                        ##### How to use this driver #####
  ==============================================================================
  [..]
   (#) Enable the GPIO clock.

W
wangyq2018 已提交
75
   (#) Configure the GPIO pin(s) using ald_gpio_init().
W
wangyq2018 已提交
76 77 78 79 80 81 82 83 84 85 86 87 88 89
       (++) Configure the IO mode using "mode" member from gpio_init_t structure
       (++) Activate Pull-up, Pull-down resistor using "pupd" member from gpio_init_t
            structure.
       (++) In Output mode, configured on open-drain or push-pull using "odos"
            member from gpio_init_t structure.
       (++) In Output mode, configured output driver using "odrv" member
            from gpio_init_t structure.
       (++) In Input mode, configured filter function using "flt" member
            from gpio_init_t structure.
       (++) Configured type using "type" member from gpio_init_t structure.
       (++) Configured functions using "func" member from gpio_init_t structure.
       (++) Analog mode is required when a pin is to be used as ADC channel
            or DAC output.

W
wangyq2018 已提交
90
   (#) Configure the GPIO pin(s) using ald_gpio_init_default().
W
wangyq2018 已提交
91 92 93 94 95 96 97 98 99 100
       (++) Configure GPIO pin using default param:
            init.mode = GPIO_MODE_OUTPUT;
            init.odos = GPIO_PUSH_PULL;
            init.pupd = GPIO_PUSH_UP;
            init.odrv = GPIO_OUT_DRIVE_NORMAL;
            init.flt  = GPIO_FILTER_DISABLE;
            init.type = GPIO_TYPE_TTL;
            init.func = GPIO_FUNC_1;

   (#) In case of external interrupt/event mode selection, user need invoke
W
wangyq2018 已提交
101 102
       ald_gpio_exti_init() to configure some param. And then invoke
       ald_gpio_exti_interrupt_config() to enable/disable external interrupt/event.
W
wangyq2018 已提交
103 104 105 106 107 108 109 110

   (#) In case of external interrupt/event mode selection, configure NVIC IRQ priority
       mapped to the EXTI line using NVIC_SetPriority() and enable it using
       NVIC_EnableIRQ().

   (#) To get the level of a pin configured in input mode use GPIO_read_pin().

   (#) To set/reset the level of a pin configured in output mode use
W
wangyq2018 已提交
111
       ald_gpio_write_pin()/ald_gpio_toggle_pin().
W
wangyq2018 已提交
112

W
wangyq2018 已提交
113
   (#) To lock pin configuration until next reset use ald_gpio_lock_pin().
W
wangyq2018 已提交
114 115

   (#) Configure external interrupt mode and enable/disable using
W
wangyq2018 已提交
116
       ald_gpio_exti_interrupt_config().
W
wangyq2018 已提交
117

W
wangyq2018 已提交
118
   (#) Get external interrupt flag status using ald_gpio_exti_get_flag_status().
W
wangyq2018 已提交
119 120

   (#) Clear pending external interrupt flag status using
W
wangyq2018 已提交
121
       ald_gpio_exti_clear_flag_status().
W
wangyq2018 已提交
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168

    @endverbatim
  */

#include "ald_conf.h"
#include "ald_gpio.h"


/** @addtogroup ES32FXXX_ALD
  * @{
  */

/** @defgroup GPIO GPIO
  * @brief GPIO module driver
  * @{
  */

#ifdef ALD_GPIO

/** @defgroup GPIO_Public_Functions GPIO Public Functions
  * @{
  */

/** @defgroup GPIO_Public_Functions_Group1 Initialization functions
  * @brief    Initialization and Configuration functions
  *
    @verbatim
 ===============================================================================
              ##### Initialization functions #####
 ===============================================================================
  [..]
    This section provides functions allowing to initialize the GPIOs or external
    interrupt to be ready for use.

    @endverbatim
  * @{
  */

/**
  * @brief  Initialize the GPIOx peripheral according to the specified
  *         parameters in the gpio_init_t.
  * @param  GPIOx: Where x can be (A--H) to select the GPIO peripheral.
  * @param  pin: The pin which need to initialize.
  * @param  init: Pointer to a gpio_init_t structure that can contains
  *         the configuration information for the specified parameters.
  * @retval None
  */
W
wangyq2018 已提交
169
void ald_gpio_init(GPIO_TypeDef *GPIOx, uint16_t pin, gpio_init_t *init)
W
wangyq2018 已提交
170
{
W
wangyq2018 已提交
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241
    uint32_t i, pos, mask, tmp;

    assert_param(IS_GPIO_PORT(GPIOx));
    assert_param(IS_GPIO_PIN(pin));
    assert_param(IS_GPIO_MODE(init->mode));
    assert_param(IS_GPIO_ODOS(init->odos));
    assert_param(IS_GPIO_PUPD(init->pupd));
    assert_param(IS_GPIO_ODRV(init->odrv));
    assert_param(IS_GPIO_FLT(init->flt));
    assert_param(IS_GPIO_TYPE(init->type));
    assert_param(IS_GPIO_FUNC(init->func));

    for (i = 0; i < 16; ++i)
    {
        if (((pin >> i) & 0x1) == 0)
            continue;

        /* Get position and 2-bits mask */
        pos  = i << 1;
        mask = 0x3 << pos;

        /* Set PIN mode */
        tmp  = READ_REG(GPIOx->MODE);
        tmp &= ~mask;
        tmp |= (init->mode << pos);
        WRITE_REG(GPIOx->MODE, tmp);

        /* Set PIN open-drain or push-pull */
        tmp  = READ_REG(GPIOx->ODOS);
        tmp &= ~mask;
        tmp |= (init->odos << pos);
        WRITE_REG(GPIOx->ODOS, tmp);

        /* Set PIN push-up or/and push-down */
        tmp  = READ_REG(GPIOx->PUPD);
        tmp &= ~mask;
        tmp |= (init->pupd << pos);
        WRITE_REG(GPIOx->PUPD, tmp);

        /* Set PIN output driver */
        tmp  = READ_REG(GPIOx->ODRV);
        tmp &= ~mask;
        tmp |= (init->odrv << pos);
        WRITE_REG(GPIOx->ODRV, tmp);

        /* Get position and 1-bit mask */
        pos  = i;
        mask = 0x1 << pos;

        /* Set PIN filter enable or disable */
        tmp  = READ_REG(GPIOx->FLT);
        tmp &= ~mask;
        tmp |= (init->flt << pos);
        WRITE_REG(GPIOx->FLT, tmp);

        /* Set PIN type ttl or smit */
        tmp  = READ_REG(GPIOx->TYPE);
        tmp &= ~mask;
        tmp |= (init->type << pos);
        WRITE_REG(GPIOx->TYPE, tmp);

        /* Configure PIN function */
        pos  = i < 8 ? (i << 2) : ((i - 8) << 2);
        mask = 0xF << pos;
        tmp  = i < 8 ? READ_REG(GPIOx->FUNC0) : READ_REG(GPIOx->FUNC1);
        tmp &= ~mask;
        tmp |= (init->func << pos);
        i < 8 ? WRITE_REG(GPIOx->FUNC0, tmp) : WRITE_REG(GPIOx->FUNC1, tmp);
    }

    return;
W
wangyq2018 已提交
242 243 244 245 246 247 248 249
}

/**
  * @brief  Initialize the GPIOx peripheral using the default parameters.
  * @param  GPIOx: Where x can be (A--H) to select the GPIO peripheral.
  * @param  pin: The pin which need to initialize.
  * @retval None
  */
W
wangyq2018 已提交
250
void ald_gpio_init_default(GPIO_TypeDef *GPIOx, uint16_t pin)
W
wangyq2018 已提交
251
{
W
wangyq2018 已提交
252 253 254 255 256 257 258 259 260 261 262 263 264
    gpio_init_t init;

    /* Fill GPIO_init_t structure with default parameter */
    init.mode = GPIO_MODE_OUTPUT;
    init.odos = GPIO_PUSH_PULL;
    init.pupd = GPIO_PUSH_UP;
    init.odrv = GPIO_OUT_DRIVE_NORMAL;
    init.flt  = GPIO_FILTER_DISABLE;
    init.type = GPIO_TYPE_CMOS;
    init.func = GPIO_FUNC_1;

    ald_gpio_init(GPIOx, pin, &init);
    return;
W
wangyq2018 已提交
265 266 267 268 269 270 271
}

/**
  * @brief  Sets GPIO function to default(func0).
  * @param  GPIOx: Where x can be (A--H) to select the GPIO peripheral.
  * @retval None
  */
W
wangyq2018 已提交
272
void ald_gpio_func_default(GPIO_TypeDef *GPIOx)
W
wangyq2018 已提交
273
{
W
wangyq2018 已提交
274 275
    WRITE_REG(GPIOx->FUNC0, 0x00);
    WRITE_REG(GPIOx->FUNC1, 0x00);
W
wangyq2018 已提交
276

W
wangyq2018 已提交
277
    return;
W
wangyq2018 已提交
278 279 280 281 282 283 284 285 286 287 288
}

/**
  * @brief  Initialize the external interrupt according to the specified
  *         parameters in the exti_init_t.
  * @param  GPIOx: Where x can be (A--H) to select the GPIO peripheral.
  * @param  pin: The pin which need to initialize.
  * @param  init: Pointer to a exti_init_t structure that can contains
  *         the configuration information for the specified parameters.
  * @retval None
  */
W
wangyq2018 已提交
289
void ald_gpio_exti_init(GPIO_TypeDef *GPIOx, uint16_t pin, exti_init_t *init)
W
wangyq2018 已提交
290
{
W
wangyq2018 已提交
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351
    uint8_t i;
    uint8_t port;

    assert_param(IS_GPIO_PORT(GPIOx));
    assert_param(IS_GPIO_PIN(pin));
    assert_param(IS_FUNC_STATE(init->filter));
    assert_param(IS_EXTI_FLTCKS_TYPE(init->cks));

    /* Get GPIO port */
    if (GPIOx == GPIOA)
        port = 0x0;
    else if (GPIOx == GPIOB)
        port = 0x1;
    else if (GPIOx == GPIOC)
        port = 2;
    else if (GPIOx == GPIOD)
        port = 3;
    else if (GPIOx == GPIOE)
        port = 4;
    else if (GPIOx == GPIOF)
        port = 5;
    else if (GPIOx == GPIOG)
        port = 6;
    else if (GPIOx == GPIOH)
        port = 7;
    else
        port = 0;

    /* Get Pin index */
    for (i = 0; i < 16; ++i)
    {
        if (((pin >> i) & 0x1) == 0x1)
            break;
    }

    /* Select external interrupt line */
    if (i <= 7)
    {
        EXTI->EXTIPSR0 &= ~(0x7 << (i * 4));
        EXTI->EXTIPSR0 |= (port << (i * 4));
    }
    else
    {
        i -= 8;
        EXTI->EXTIPSR1 &= ~(0x7 << (i * 4));
        EXTI->EXTIPSR1 |= (port << (i * 4));
    }

    /* Configure filter parameter */
    if (init->filter == ENABLE)
    {
        SET_BIT(EXTI->EXTIFLTCR, pin);
        MODIFY_REG(EXTI->EXTIFLTCR, GPIO_EXTIFLTCR_FLTCKS_MSK, init->cks << GPIO_EXTIFLTCR_FLTCKS_POSS);
        MODIFY_REG(EXTI->EXTIFLTCR, GPIO_EXTIFLTCR_FLTSEL_MSK, init->filter_time << GPIO_EXTIFLTCR_FLTSEL_POSS);
    }
    else
    {
        CLEAR_BIT(EXTI->EXTIFLTCR, pin);
    }

    return;
W
wangyq2018 已提交
352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378
}
/**
  * @}
  */

/** @defgroup GPIO_Public_Functions_Group2 IO operation functions
  * @brief   GPIO Read and Write
  *
    @verbatim
 ===============================================================================
                       ##### IO operation functions #####
 ===============================================================================
  [..]
    This subsection provides a set of functions allowing to manage the GPIOs.

    @endverbatim
  * @{
  */

/**
  * @brief  Read the specified input port pin.
  * @param  GPIOx: Where x can be (A--H) to select the GPIO peripheral.
  * @param  pin: Specifies the pin to read.
  * @retval The input pin value
  *         - BIT_SET
  *         - BIT_RESET
  */
W
wangyq2018 已提交
379
uint8_t ald_gpio_read_pin(GPIO_TypeDef *GPIOx, uint16_t pin)
W
wangyq2018 已提交
380
{
W
wangyq2018 已提交
381 382
    assert_param(IS_GPIO_PORT(GPIOx));
    assert_param(IS_GPIO_PIN(pin));
W
wangyq2018 已提交
383

W
wangyq2018 已提交
384 385
    if (READ_BIT(GPIOx->DIN, pin))
        return BIT_SET;
W
wangyq2018 已提交
386

W
wangyq2018 已提交
387 388
    else
        return BIT_RESET;
W
wangyq2018 已提交
389 390 391 392 393 394 395 396 397
}

/**
  * @brief  Set or clear the select Pin data.
  * @param  GPIOx: Where x can be (A--H) to select the GPIO peripheral.
  * @param  pin: The specified pin to be written.
  * @param  val: The specifies value to be written.
  * @retval None
  */
W
wangyq2018 已提交
398
void ald_gpio_write_pin(GPIO_TypeDef *GPIOx, uint16_t pin, uint8_t val)
W
wangyq2018 已提交
399
{
W
wangyq2018 已提交
400 401
    assert_param(IS_GPIO_PORT(GPIOx));
    assert_param(IS_GPIO_PIN(pin));
W
wangyq2018 已提交
402

W
wangyq2018 已提交
403 404 405 406
    if ((val & (0x01)) == 0x00)
        CLEAR_BIT(GPIOx->DOUT, pin);
    else
        SET_BIT(GPIOx->DOUT, pin);
W
wangyq2018 已提交
407

W
wangyq2018 已提交
408
    return;
W
wangyq2018 已提交
409 410 411 412 413 414 415 416
}

/**
  * @brief  Turn over the select data.
  * @param  GPIOx: Where x can be (A--H) to select the GPIO peripheral.
  * @param  pin: Specifies the pin to turn over.
  * @retval None
  */
W
wangyq2018 已提交
417
void ald_gpio_toggle_pin(GPIO_TypeDef *GPIOx, uint16_t pin)
W
wangyq2018 已提交
418
{
W
wangyq2018 已提交
419 420
    assert_param(IS_GPIO_PORT(GPIOx));
    assert_param(IS_GPIO_PIN(pin));
W
wangyq2018 已提交
421

W
wangyq2018 已提交
422 423
    WRITE_REG(GPIOx->BIR, pin);
    return;
W
wangyq2018 已提交
424 425 426 427 428 429 430 431
}

/**
  * @brief  Turn over the direction.
  * @param  GPIOx: Where x can be (A--H) to select the GPIO peripheral.
  * @param  pin: Specifies the pin to turn over.
  * @retval None
  */
W
wangyq2018 已提交
432
void ald_gpio_toggle_dir(GPIO_TypeDef *GPIOx, uint16_t pin)
W
wangyq2018 已提交
433
{
W
wangyq2018 已提交
434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469
    uint32_t i, pos, mask, tmp, value;

    assert_param(IS_GPIO_PORT(GPIOx));
    assert_param(IS_GPIO_PIN(pin));

    for (i = 0; i < 16; ++i)
    {
        if (((pin >> i) & 0x1) == 0)
            continue;

        /* Get position and 2-bits mask */
        pos  = i << 1;
        mask = 0x3 << pos;

        /* Get the new direction */
        tmp = READ_REG(GPIOx->MODE);
        value = (tmp >> pos) & 0x3;

        if ((value == 2) || (value == 3))
            value = 1;
        else if (value == 1)
        {
            value = 2;
        }
        else
        {
            continue; /* do nothing */
        }

        /* Set PIN mode */
        tmp &= ~mask;
        tmp |= (value << pos);
        WRITE_REG(GPIOx->MODE, tmp);
    }

    return;
W
wangyq2018 已提交
470 471 472 473 474 475 476 477 478 479
}

/**
  * @brief  Lock the GPIO prot. Once locked, can
  *         only change the output data. Only when the CPU
  *         reset to unlock the GPIO port.
  * @param  GPIOx: Where x can be (A--H) to select the GPIO peripheral.
  * @param  pin: The specified Pin to be written.
  * @retval None
  */
W
wangyq2018 已提交
480
void ald_gpio_lock_pin(GPIO_TypeDef *GPIOx, uint16_t pin)
W
wangyq2018 已提交
481
{
W
wangyq2018 已提交
482 483
    assert_param(IS_GPIO_PORT(GPIOx));
    assert_param(IS_GPIO_PIN(pin));
W
wangyq2018 已提交
484

W
wangyq2018 已提交
485 486
    MODIFY_REG(GPIOx->LOCK, GPIO_LOCK_KEY_MSK, UNLOCK_KEY << GPIO_LOCK_KEY_POSS);
    WRITE_REG(GPIOx->LOCK, pin);
W
wangyq2018 已提交
487

W
wangyq2018 已提交
488
    return;
W
wangyq2018 已提交
489 490 491 492 493 494 495
}

/**
  * @brief  Read the specified input port pin.
  * @param  GPIOx: Where x can be (A--H) to select the GPIO peripheral.
  * @retval The value;
  */
W
wangyq2018 已提交
496
uint16_t ald_gpio_read_port(GPIO_TypeDef *GPIOx)
W
wangyq2018 已提交
497
{
W
wangyq2018 已提交
498
    assert_param(IS_GPIO_PORT(GPIOx));
W
wangyq2018 已提交
499

W
wangyq2018 已提交
500
    return READ_REG(GPIOx->DIN);
W
wangyq2018 已提交
501 502 503 504 505 506 507 508
}

/**
  * @brief  Set or clear the select Pin data.
  * @param  GPIOx: Where x can be (A--H) to select the GPIO peripheral.
  * @param  val: The specifies value to be written.
  * @retval None
  */
W
wangyq2018 已提交
509
void ald_gpio_write_port(GPIO_TypeDef *GPIOx, uint16_t val)
W
wangyq2018 已提交
510
{
W
wangyq2018 已提交
511
    assert_param(IS_GPIO_PORT(GPIOx));
W
wangyq2018 已提交
512

W
wangyq2018 已提交
513 514
    WRITE_REG(GPIOx->DOUT, val);
    return;
W
wangyq2018 已提交
515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545
}


/**
  * @}
  */

/** @defgroup GPIO_Public_Functions_Group3 Control functions
  * @brief EXTI Control functions
  *
    @verbatim
 ===============================================================================
                       ##### Control functions #####
 ===============================================================================
  [..]
    This subsection provides a set of functions allowing to
    control external interrupt.

    @endverbatim
  * @{
  */

/**
  * @brief  Configure the interrupt according to the specified parameter.
  * @param  pin: The Pin which need to configure.
  * @param  style: External interrupt trigger style.
  * @param  status:
  *           @arg ENABLE
  *           @arg DISABLE
  * @retval None
  */
W
wangyq2018 已提交
546
void ald_gpio_exti_interrupt_config(uint16_t pin, exti_trigger_style_t style, type_func_t status)
W
wangyq2018 已提交
547
{
W
wangyq2018 已提交
548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598
    assert_param(IS_GPIO_PIN(pin));
    assert_param(IS_TRIGGER_STYLE(style));
    assert_param(IS_FUNC_STATE(status));

    if (status == ENABLE)
    {
        if (style == EXTI_TRIGGER_RISING_EDGE)
        {
            SET_BIT(EXTI->EXTIRER, pin);
        }
        else if (style == EXTI_TRIGGER_TRAILING_EDGE)
        {
            SET_BIT(EXTI->EXTIFER, pin);
        }
        else if (style == EXTI_TRIGGER_BOTH_EDGE)
        {
            SET_BIT(EXTI->EXTIRER, pin);
            SET_BIT(EXTI->EXTIFER, pin);
        }
        else
        {
            ; /* do nothing */
        }

        WRITE_REG(EXTI->EXTICFR, 0xffff);
        SET_BIT(EXTI->EXTIEN, pin);
    }
    else
    {
        if (style == EXTI_TRIGGER_RISING_EDGE)
        {
            CLEAR_BIT(EXTI->EXTIRER, pin);
        }
        else if (style == EXTI_TRIGGER_TRAILING_EDGE)
        {
            CLEAR_BIT(EXTI->EXTIFER, pin);
        }
        else if (style == EXTI_TRIGGER_BOTH_EDGE)
        {
            CLEAR_BIT(EXTI->EXTIRER, pin);
            CLEAR_BIT(EXTI->EXTIFER, pin);
        }
        else
        {
            ; /* do nothing */
        }

        CLEAR_BIT(EXTI->EXTIEN, pin);
    }

    return;
W
wangyq2018 已提交
599 600 601 602 603 604 605 606 607
}

/**
  * @brief  Get the Flag about external interrupt.
  * @param  pin: The pin which belong to external interrupt.
  * @retval Flag status
  *         - SET
  *         - RESET
  */
W
wangyq2018 已提交
608
flag_status_t ald_gpio_exti_get_flag_status(uint16_t pin)
W
wangyq2018 已提交
609
{
W
wangyq2018 已提交
610
    assert_param(IS_GPIO_PIN(pin));
W
wangyq2018 已提交
611

W
wangyq2018 已提交
612 613
    if (READ_BIT(EXTI->EXTIFLAG, pin))
        return SET;
W
wangyq2018 已提交
614

W
wangyq2018 已提交
615
    return RESET;
W
wangyq2018 已提交
616 617 618 619 620 621 622
}

/**
  * @brief  Clear the external interrupt flag.
  * @param  pin: The pin which belong to external interrupt.
  * @retval None
  */
W
wangyq2018 已提交
623
void ald_gpio_exti_clear_flag_status(uint16_t pin)
W
wangyq2018 已提交
624
{
W
wangyq2018 已提交
625
    assert_param(IS_GPIO_PIN(pin));
W
wangyq2018 已提交
626

W
wangyq2018 已提交
627 628
    WRITE_REG(EXTI->EXTICFR, pin);
    return;
W
wangyq2018 已提交
629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645
}
/**
  * @}
  */

/**
  * @}
  */

#endif /* ALD_GPIO */
/**
  * @}
  */

/**
  * @}
  */