Subversion Repositories DashDisplay

Rev

Rev 56 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 56 Rev 77
Line 1... Line 1...
1
/**
1
/**
2
  ******************************************************************************
2
  ******************************************************************************
3
  * @file    stm32l1xx_ll_exti.c
3
  * @file    stm32l1xx_ll_exti.c
4
  * @author  MCD Application Team
4
  * @author  MCD Application Team
5
  * @brief   EXTI LL module driver.
5
  * @brief   EXTI LL module driver.
6
  ******************************************************************************
6
  ******************************************************************************
7
  * @attention
7
  * @attention
8
  *
8
  *
9
  * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
9
  * Copyright (c) 2017 STMicroelectronics.
10
  * All rights reserved.</center></h2>
10
  * All rights reserved.
11
  *
11
  *
12
  * This software component is licensed by ST under BSD 3-Clause license,
12
  * This software is licensed under terms that can be found in the LICENSE file
13
  * the "License"; You may not use this file except in compliance with the
13
  * in the root directory of this software component.
14
  * License. You may obtain a copy of the License at:
14
  * If no LICENSE file comes with this software, it is provided AS-IS.
15
  *                        opensource.org/licenses/BSD-3-Clause
15
  *
16
  *
16
  ******************************************************************************
17
  ******************************************************************************
17
  */
18
  */
18
#if defined(USE_FULL_LL_DRIVER)
19
#if defined(USE_FULL_LL_DRIVER)
19
 
20
 
20
/* Includes ------------------------------------------------------------------*/
21
/* Includes ------------------------------------------------------------------*/
21
#include "stm32l1xx_ll_exti.h"
22
#include "stm32l1xx_ll_exti.h"
22
#ifdef  USE_FULL_ASSERT
23
#ifdef  USE_FULL_ASSERT
23
#include "stm32_assert.h"
24
#include "stm32_assert.h"
24
#else
25
#else
25
#define assert_param(expr) ((void)0U)
26
#define assert_param(expr) ((void)0U)
26
#endif
27
#endif
27
 
28
 
28
/** @addtogroup STM32L1xx_LL_Driver
29
/** @addtogroup STM32L1xx_LL_Driver
29
  * @{
30
  * @{
30
  */
31
  */
31
 
32
 
32
#if defined (EXTI)
33
#if defined (EXTI)
33
 
34
 
34
/** @defgroup EXTI_LL EXTI
35
/** @defgroup EXTI_LL EXTI
35
  * @{
36
  * @{
36
  */
37
  */
37
 
38
 
38
/* Private types -------------------------------------------------------------*/
39
/* Private types -------------------------------------------------------------*/
39
/* Private variables ---------------------------------------------------------*/
40
/* Private variables ---------------------------------------------------------*/
40
/* Private constants ---------------------------------------------------------*/
41
/* Private constants ---------------------------------------------------------*/
41
/* Private macros ------------------------------------------------------------*/
42
/* Private macros ------------------------------------------------------------*/
42
/** @addtogroup EXTI_LL_Private_Macros
43
/** @addtogroup EXTI_LL_Private_Macros
43
  * @{
44
  * @{
44
  */
45
  */
45
 
46
 
46
#define IS_LL_EXTI_LINE_0_31(__VALUE__)              (((__VALUE__) & ~LL_EXTI_LINE_ALL_0_31) == 0x00000000U)
47
#define IS_LL_EXTI_LINE_0_31(__VALUE__)              (((__VALUE__) & ~LL_EXTI_LINE_ALL_0_31) == 0x00000000U)
47
 
48
 
48
#define IS_LL_EXTI_MODE(__VALUE__)                   (((__VALUE__) == LL_EXTI_MODE_IT)            \
49
#define IS_LL_EXTI_MODE(__VALUE__)                   (((__VALUE__) == LL_EXTI_MODE_IT)            \
49
                                                   || ((__VALUE__) == LL_EXTI_MODE_EVENT)         \
50
                                                   || ((__VALUE__) == LL_EXTI_MODE_EVENT)         \
50
                                                   || ((__VALUE__) == LL_EXTI_MODE_IT_EVENT))
51
                                                   || ((__VALUE__) == LL_EXTI_MODE_IT_EVENT))
51
 
52
 
52
 
53
 
53
#define IS_LL_EXTI_TRIGGER(__VALUE__)                (((__VALUE__) == LL_EXTI_TRIGGER_NONE)       \
54
#define IS_LL_EXTI_TRIGGER(__VALUE__)                (((__VALUE__) == LL_EXTI_TRIGGER_NONE)       \
54
                                                   || ((__VALUE__) == LL_EXTI_TRIGGER_RISING)     \
55
                                                   || ((__VALUE__) == LL_EXTI_TRIGGER_RISING)     \
55
                                                   || ((__VALUE__) == LL_EXTI_TRIGGER_FALLING)    \
56
                                                   || ((__VALUE__) == LL_EXTI_TRIGGER_FALLING)    \
56
                                                   || ((__VALUE__) == LL_EXTI_TRIGGER_RISING_FALLING))
57
                                                   || ((__VALUE__) == LL_EXTI_TRIGGER_RISING_FALLING))
57
 
58
 
58
/**
59
/**
59
  * @}
60
  * @}
60
  */
61
  */
61
 
62
 
62
/* Private function prototypes -----------------------------------------------*/
63
/* Private function prototypes -----------------------------------------------*/
63
 
64
 
64
/* Exported functions --------------------------------------------------------*/
65
/* Exported functions --------------------------------------------------------*/
65
/** @addtogroup EXTI_LL_Exported_Functions
66
/** @addtogroup EXTI_LL_Exported_Functions
66
  * @{
67
  * @{
67
  */
68
  */
68
 
69
 
69
/** @addtogroup EXTI_LL_EF_Init
70
/** @addtogroup EXTI_LL_EF_Init
70
  * @{
71
  * @{
71
  */
72
  */
72
 
73
 
73
/**
74
/**
74
  * @brief  De-initialize the EXTI registers to their default reset values.
75
  * @brief  De-initialize the EXTI registers to their default reset values.
75
  * @retval An ErrorStatus enumeration value:
76
  * @retval An ErrorStatus enumeration value:
76
  *          - SUCCESS: EXTI registers are de-initialized
77
  *          - SUCCESS: EXTI registers are de-initialized
77
  *          - ERROR: not applicable
78
  *          - ERROR: not applicable
78
  */
79
  */
79
uint32_t LL_EXTI_DeInit(void)
80
uint32_t LL_EXTI_DeInit(void)
80
{
81
{
81
  /* Interrupt mask register set to default reset values */
82
  /* Interrupt mask register set to default reset values */
82
  LL_EXTI_WriteReg(IMR,   0x00000000U);
83
  LL_EXTI_WriteReg(IMR,   0x00000000U);
83
  /* Event mask register set to default reset values */
84
  /* Event mask register set to default reset values */
84
  LL_EXTI_WriteReg(EMR,   0x00000000U);
85
  LL_EXTI_WriteReg(EMR,   0x00000000U);
85
  /* Rising Trigger selection register set to default reset values */
86
  /* Rising Trigger selection register set to default reset values */
86
  LL_EXTI_WriteReg(RTSR,  0x00000000U);
87
  LL_EXTI_WriteReg(RTSR,  0x00000000U);
87
  /* Falling Trigger selection register set to default reset values */
88
  /* Falling Trigger selection register set to default reset values */
88
  LL_EXTI_WriteReg(FTSR,  0x00000000U);
89
  LL_EXTI_WriteReg(FTSR,  0x00000000U);
89
  /* Software interrupt event register set to default reset values */
90
  /* Software interrupt event register set to default reset values */
90
  LL_EXTI_WriteReg(SWIER, 0x00000000U);
91
  LL_EXTI_WriteReg(SWIER, 0x00000000U);
91
  /* Pending register clear */
92
  /* Pending register clear */
92
  LL_EXTI_WriteReg(PR,    0x00FFFFFFU);
93
  LL_EXTI_WriteReg(PR,    0x00FFFFFFU);
93
 
94
 
94
  return SUCCESS;
95
  return SUCCESS;
95
}
96
}
96
 
97
 
97
/**
98
/**
98
  * @brief  Initialize the EXTI registers according to the specified parameters in EXTI_InitStruct.
99
  * @brief  Initialize the EXTI registers according to the specified parameters in EXTI_InitStruct.
99
  * @param  EXTI_InitStruct pointer to a @ref LL_EXTI_InitTypeDef structure.
100
  * @param  EXTI_InitStruct pointer to a @ref LL_EXTI_InitTypeDef structure.
100
  * @retval An ErrorStatus enumeration value:
101
  * @retval An ErrorStatus enumeration value:
101
  *          - SUCCESS: EXTI registers are initialized
102
  *          - SUCCESS: EXTI registers are initialized
102
  *          - ERROR: not applicable
103
  *          - ERROR: not applicable
103
  */
104
  */
104
uint32_t LL_EXTI_Init(LL_EXTI_InitTypeDef *EXTI_InitStruct)
105
uint32_t LL_EXTI_Init(LL_EXTI_InitTypeDef *EXTI_InitStruct)
105
{
106
{
106
  ErrorStatus status = SUCCESS;
107
  ErrorStatus status = SUCCESS;
107
  /* Check the parameters */
108
  /* Check the parameters */
108
  assert_param(IS_LL_EXTI_LINE_0_31(EXTI_InitStruct->Line_0_31));
109
  assert_param(IS_LL_EXTI_LINE_0_31(EXTI_InitStruct->Line_0_31));
109
  assert_param(IS_FUNCTIONAL_STATE(EXTI_InitStruct->LineCommand));
110
  assert_param(IS_FUNCTIONAL_STATE(EXTI_InitStruct->LineCommand));
110
  assert_param(IS_LL_EXTI_MODE(EXTI_InitStruct->Mode));
111
  assert_param(IS_LL_EXTI_MODE(EXTI_InitStruct->Mode));
111
 
112
 
112
  /* ENABLE LineCommand */
113
  /* ENABLE LineCommand */
113
  if (EXTI_InitStruct->LineCommand != DISABLE)
114
  if (EXTI_InitStruct->LineCommand != DISABLE)
114
  {
115
  {
115
    assert_param(IS_LL_EXTI_TRIGGER(EXTI_InitStruct->Trigger));
116
    assert_param(IS_LL_EXTI_TRIGGER(EXTI_InitStruct->Trigger));
116
 
117
 
117
    /* Configure EXTI Lines in range from 0 to 31 */
118
    /* Configure EXTI Lines in range from 0 to 31 */
118
    if (EXTI_InitStruct->Line_0_31 != LL_EXTI_LINE_NONE)
119
    if (EXTI_InitStruct->Line_0_31 != LL_EXTI_LINE_NONE)
119
    {
120
    {
120
      switch (EXTI_InitStruct->Mode)
121
      switch (EXTI_InitStruct->Mode)
121
      {
122
      {
122
        case LL_EXTI_MODE_IT:
123
        case LL_EXTI_MODE_IT:
123
          /* First Disable Event on provided Lines */
124
          /* First Disable Event on provided Lines */
124
          LL_EXTI_DisableEvent_0_31(EXTI_InitStruct->Line_0_31);
125
          LL_EXTI_DisableEvent_0_31(EXTI_InitStruct->Line_0_31);
125
          /* Then Enable IT on provided Lines */
126
          /* Then Enable IT on provided Lines */
126
          LL_EXTI_EnableIT_0_31(EXTI_InitStruct->Line_0_31);
127
          LL_EXTI_EnableIT_0_31(EXTI_InitStruct->Line_0_31);
127
          break;
128
          break;
128
        case LL_EXTI_MODE_EVENT:
129
        case LL_EXTI_MODE_EVENT:
129
          /* First Disable IT on provided Lines */
130
          /* First Disable IT on provided Lines */
130
          LL_EXTI_DisableIT_0_31(EXTI_InitStruct->Line_0_31);
131
          LL_EXTI_DisableIT_0_31(EXTI_InitStruct->Line_0_31);
131
          /* Then Enable Event on provided Lines */
132
          /* Then Enable Event on provided Lines */
132
          LL_EXTI_EnableEvent_0_31(EXTI_InitStruct->Line_0_31);
133
          LL_EXTI_EnableEvent_0_31(EXTI_InitStruct->Line_0_31);
133
          break;
134
          break;
134
        case LL_EXTI_MODE_IT_EVENT:
135
        case LL_EXTI_MODE_IT_EVENT:
135
          /* Directly Enable IT & Event on provided Lines */
136
          /* Directly Enable IT & Event on provided Lines */
136
          LL_EXTI_EnableIT_0_31(EXTI_InitStruct->Line_0_31);
137
          LL_EXTI_EnableIT_0_31(EXTI_InitStruct->Line_0_31);
137
          LL_EXTI_EnableEvent_0_31(EXTI_InitStruct->Line_0_31);
138
          LL_EXTI_EnableEvent_0_31(EXTI_InitStruct->Line_0_31);
138
          break;
139
          break;
139
        default:
140
        default:
140
          status = ERROR;
141
          status = ERROR;
141
          break;
142
          break;
142
      }
143
      }
143
      if (EXTI_InitStruct->Trigger != LL_EXTI_TRIGGER_NONE)
144
      if (EXTI_InitStruct->Trigger != LL_EXTI_TRIGGER_NONE)
144
      {
145
      {
145
        switch (EXTI_InitStruct->Trigger)
146
        switch (EXTI_InitStruct->Trigger)
146
        {
147
        {
147
          case LL_EXTI_TRIGGER_RISING:
148
          case LL_EXTI_TRIGGER_RISING:
148
            /* First Disable Falling Trigger on provided Lines */
149
            /* First Disable Falling Trigger on provided Lines */
149
            LL_EXTI_DisableFallingTrig_0_31(EXTI_InitStruct->Line_0_31);
150
            LL_EXTI_DisableFallingTrig_0_31(EXTI_InitStruct->Line_0_31);
150
            /* Then Enable Rising Trigger on provided Lines */
151
            /* Then Enable Rising Trigger on provided Lines */
151
            LL_EXTI_EnableRisingTrig_0_31(EXTI_InitStruct->Line_0_31);
152
            LL_EXTI_EnableRisingTrig_0_31(EXTI_InitStruct->Line_0_31);
152
            break;
153
            break;
153
          case LL_EXTI_TRIGGER_FALLING:
154
          case LL_EXTI_TRIGGER_FALLING:
154
            /* First Disable Rising Trigger on provided Lines */
155
            /* First Disable Rising Trigger on provided Lines */
155
            LL_EXTI_DisableRisingTrig_0_31(EXTI_InitStruct->Line_0_31);
156
            LL_EXTI_DisableRisingTrig_0_31(EXTI_InitStruct->Line_0_31);
156
            /* Then Enable Falling Trigger on provided Lines */
157
            /* Then Enable Falling Trigger on provided Lines */
157
            LL_EXTI_EnableFallingTrig_0_31(EXTI_InitStruct->Line_0_31);
158
            LL_EXTI_EnableFallingTrig_0_31(EXTI_InitStruct->Line_0_31);
158
            break;
159
            break;
159
          case LL_EXTI_TRIGGER_RISING_FALLING:
160
          case LL_EXTI_TRIGGER_RISING_FALLING:
160
            LL_EXTI_EnableRisingTrig_0_31(EXTI_InitStruct->Line_0_31);
161
            LL_EXTI_EnableRisingTrig_0_31(EXTI_InitStruct->Line_0_31);
161
            LL_EXTI_EnableFallingTrig_0_31(EXTI_InitStruct->Line_0_31);
162
            LL_EXTI_EnableFallingTrig_0_31(EXTI_InitStruct->Line_0_31);
162
            break;
163
            break;
163
          default:
164
          default:
164
            status = ERROR;
165
            status = ERROR;
165
            break;
166
            break;
166
        }
167
        }
167
      }
168
      }
168
    }
169
    }
169
  }
170
  }
170
  /* DISABLE LineCommand */
171
  /* DISABLE LineCommand */
171
  else
172
  else
172
  {
173
  {
173
    /* De-configure EXTI Lines in range from 0 to 31 */
174
    /* De-configure EXTI Lines in range from 0 to 31 */
174
    LL_EXTI_DisableIT_0_31(EXTI_InitStruct->Line_0_31);
175
    LL_EXTI_DisableIT_0_31(EXTI_InitStruct->Line_0_31);
175
    LL_EXTI_DisableEvent_0_31(EXTI_InitStruct->Line_0_31);
176
    LL_EXTI_DisableEvent_0_31(EXTI_InitStruct->Line_0_31);
176
  }
177
  }
177
  return status;
178
  return status;
178
}
179
}
179
 
180
 
180
/**
181
/**
181
  * @brief  Set each @ref LL_EXTI_InitTypeDef field to default value.
182
  * @brief  Set each @ref LL_EXTI_InitTypeDef field to default value.
182
  * @param  EXTI_InitStruct Pointer to a @ref LL_EXTI_InitTypeDef structure.
183
  * @param  EXTI_InitStruct Pointer to a @ref LL_EXTI_InitTypeDef structure.
183
  * @retval None
184
  * @retval None
184
  */
185
  */
185
void LL_EXTI_StructInit(LL_EXTI_InitTypeDef *EXTI_InitStruct)
186
void LL_EXTI_StructInit(LL_EXTI_InitTypeDef *EXTI_InitStruct)
186
{
187
{
187
  EXTI_InitStruct->Line_0_31      = LL_EXTI_LINE_NONE;
188
  EXTI_InitStruct->Line_0_31      = LL_EXTI_LINE_NONE;
188
  EXTI_InitStruct->LineCommand    = DISABLE;
189
  EXTI_InitStruct->LineCommand    = DISABLE;
189
  EXTI_InitStruct->Mode           = LL_EXTI_MODE_IT;
190
  EXTI_InitStruct->Mode           = LL_EXTI_MODE_IT;
190
  EXTI_InitStruct->Trigger        = LL_EXTI_TRIGGER_FALLING;
191
  EXTI_InitStruct->Trigger        = LL_EXTI_TRIGGER_FALLING;
191
}
192
}
192
 
193
 
193
/**
194
/**
194
  * @}
195
  * @}
195
  */
196
  */
196
 
197
 
197
/**
198
/**
198
  * @}
199
  * @}
199
  */
200
  */
200
 
201
 
201
/**
202
/**
202
  * @}
203
  * @}
203
  */
204
  */
204
 
205
 
205
#endif /* defined (EXTI) */
206
#endif /* defined (EXTI) */
206
 
207
 
207
/**
208
/**
208
  * @}
209
  * @}
209
  */
210
  */
210
 
211
 
211
#endif /* USE_FULL_LL_DRIVER */
212
#endif /* USE_FULL_LL_DRIVER */
212
 
213
 
213
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
214
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
-