at32f425_exint.h 7.3 KB
Newer Older
S
sheltonyu 已提交
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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 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 169 170 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
/**
  **************************************************************************
  * @file     at32f425_exint.h
  * @brief    at32f425 exint header file
  **************************************************************************
  *                       Copyright notice & Disclaimer
  *
  * The software Board Support Package (BSP) that is made available to
  * download from Artery official website is the copyrighted work of Artery.
  * Artery authorizes customers to use, copy, and distribute the BSP
  * software and its related documentation for the purpose of design and
  * development in conjunction with Artery microcontrollers. Use of the
  * software is governed by this copyright notice and the following disclaimer.
  *
  * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
  * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
  * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
  * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
  * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
  * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
  *
  **************************************************************************
  */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __AT32F425_EXINT_H
#define __AT32F425_EXINT_H

#ifdef __cplusplus
extern "C" {
#endif


/* Includes ------------------------------------------------------------------*/
#include "at32f425.h"

/** @addtogroup AT32F425_periph_driver
  * @{
  */

/** @addtogroup EXINT
  * @{
  */

/** @defgroup EXINT_lines
  * @{
  */

#define EXINT_LINE_NONE                  ((uint32_t)0x000000)
#define EXINT_LINE_0                     ((uint32_t)0x000001) /*!< external interrupt line 0 */
#define EXINT_LINE_1                     ((uint32_t)0x000002) /*!< external interrupt line 1 */
#define EXINT_LINE_2                     ((uint32_t)0x000004) /*!< external interrupt line 2 */
#define EXINT_LINE_3                     ((uint32_t)0x000008) /*!< external interrupt line 3 */
#define EXINT_LINE_4                     ((uint32_t)0x000010) /*!< external interrupt line 4 */
#define EXINT_LINE_5                     ((uint32_t)0x000020) /*!< external interrupt line 5 */
#define EXINT_LINE_6                     ((uint32_t)0x000040) /*!< external interrupt line 6 */
#define EXINT_LINE_7                     ((uint32_t)0x000080) /*!< external interrupt line 7 */
#define EXINT_LINE_8                     ((uint32_t)0x000100) /*!< external interrupt line 8 */
#define EXINT_LINE_9                     ((uint32_t)0x000200) /*!< external interrupt line 9 */
#define EXINT_LINE_10                    ((uint32_t)0x000400) /*!< external interrupt line 10 */
#define EXINT_LINE_11                    ((uint32_t)0x000800) /*!< external interrupt line 11 */
#define EXINT_LINE_12                    ((uint32_t)0x001000) /*!< external interrupt line 12 */
#define EXINT_LINE_13                    ((uint32_t)0x002000) /*!< external interrupt line 13 */
#define EXINT_LINE_14                    ((uint32_t)0x004000) /*!< external interrupt line 14 */
#define EXINT_LINE_15                    ((uint32_t)0x008000) /*!< external interrupt line 15 */
#define EXINT_LINE_16                    ((uint32_t)0x010000) /*!< external interrupt line 16 connected to the pvm output */
#define EXINT_LINE_17                    ((uint32_t)0x020000) /*!< external interrupt line 17 connected to the ertc alarm event */
#define EXINT_LINE_18                    ((uint32_t)0x040000) /*!< external interrupt line 18 connected to otg interrupt */
#define EXINT_LINE_19                    ((uint32_t)0x080000) /*!< external interrupt line 19 connected to the ertc timestamp event */
#define EXINT_LINE_20                    ((uint32_t)0x100000) /*!< external interrupt line 20 connected to the ertc wakeup timer event */


/**
  * @}
  */

/** @defgroup EXINT_exported_types
  * @{
  */

/**
  * @brief exint line mode type
  */
typedef enum
{
  EXINT_LINE_INTERRUPUT                  = 0x00, /*!< external interrupt line interrupt mode */
  EXINT_LINE_EVENT                       = 0x01  /*!< external interrupt line event mode */
} exint_line_mode_type;

/**
  * @brief exint polarity configuration type
  */
typedef enum
{
  EXINT_TRIGGER_RISING_EDGE              = 0x00, /*!< external interrupt line rising trigger mode */
  EXINT_TRIGGER_FALLING_EDGE             = 0x01, /*!< external interrupt line falling trigger mode */
  EXINT_TRIGGER_BOTH_EDGE                = 0x02  /*!< external interrupt line both rising and falling trigger mode */
} exint_polarity_config_type;

/**
  * @brief exint init type
  */
typedef struct
{
  exint_line_mode_type                   line_mode;     /*!< choose mode event or interrupt mode */
  uint32_t                               line_select;   /*!< select the exint line, availiable for single line or multiple lines */
  exint_polarity_config_type             line_polarity; /*!< select the tregger polarity, with rising edge, falling edge or both edge */
  confirm_state                          line_enable;   /*!< enable or disable exint */
} exint_init_type;

/**
  * @brief type define exint register all
  */
typedef struct
{

  /**
    * @brief exint inten register, offset:0x00
    */
  union
  {
    __IO uint32_t inten;
    struct
    {
      __IO uint32_t intenx               : 22;/* [21:0] */
      __IO uint32_t reserved1            : 10;/* [31:22] */
    } inten_bit;
  };

  /**
    * @brief exint evten register, offset:0x04
    */
  union
  {
    __IO uint32_t evten;
    struct
    {
      __IO uint32_t evtenx               : 22;/* [21:0] */
      __IO uint32_t reserved1            : 10;/* [31:22] */
    } evten_bit;
  };

  /**
    * @brief exint polcfg1 register, offset:0x08
    */
  union
  {
    __IO uint32_t polcfg1;
    struct
    {
      __IO uint32_t rpx                  : 22;/* [21:0] */
      __IO uint32_t reserved1            : 10;/* [31:22] */
    } polcfg1_bit;
  };

  /**
    * @brief exint polcfg2 register, offset:0x0C
    */
  union
  {
    __IO uint32_t polcfg2;
    struct
    {
      __IO uint32_t fpx                  : 22;/* [21:0] */
      __IO uint32_t reserved1            : 10;/* [31:22] */
    } polcfg2_bit;
  };

  /**
    * @brief exint swtrg register, offset:0x10
    */
  union
  {
    __IO uint32_t swtrg;
    struct
    {
      __IO uint32_t swtx                 : 22;/* [21:0] */
      __IO uint32_t reserved1            : 10;/* [31:22] */
    } swtrg_bit;
  };

  /**
    * @brief exint intsts register, offset:0x14
    */
  union
  {
    __IO uint32_t intsts;
    struct
    {
      __IO uint32_t linex                : 20;/* [21:0] */
      __IO uint32_t reserved1            : 12;/* [31:22] */
    } intsts_bit;
  };
} exint_type;

/**
  * @}
  */

#define EXINT                             ((exint_type *) EXINT_BASE)

/** @defgroup EXINT_exported_functions
  * @{
  */

void exint_reset(void);
void exint_default_para_init(exint_init_type *exint_struct);
void exint_init(exint_init_type *exint_struct);
void exint_flag_clear(uint32_t exint_line);
flag_status exint_flag_get(uint32_t exint_line);
void exint_software_interrupt_event_generate(uint32_t exint_line);
void exint_interrupt_enable(uint32_t exint_line, confirm_state new_state);
void exint_event_enable(uint32_t exint_line, confirm_state new_state);

/**
  * @}
  */

/**
  * @}
  */

/**
  * @}
  */

#ifdef __cplusplus
}
#endif

#endif