Subversion Repositories DashDisplay

Rev

Rev 50 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 50 Rev 61
Line 131... Line 131...
131
/* Private typedef -----------------------------------------------------------*/
131
/* Private typedef -----------------------------------------------------------*/
132
/* Private define ------------------------------------------------------------*/
132
/* Private define ------------------------------------------------------------*/
133
/** @addtogroup GPIO_Private_Constants
133
/** @addtogroup GPIO_Private_Constants
134
  * @{
134
  * @{
135
  */
135
  */
136
#define GPIO_MODE             (0x00000003U)
-
 
137
#define EXTI_MODE             (0x10000000U)
-
 
138
#define GPIO_MODE_IT          (0x00010000U)
-
 
139
#define GPIO_MODE_EVT         (0x00020000U)
-
 
140
#define RISING_EDGE           (0x00100000U)
-
 
141
#define FALLING_EDGE          (0x00200000U)
-
 
142
#define GPIO_OUTPUT_TYPE      (0x00000010U)
-
 
143
 
-
 
144
#define GPIO_NUMBER           (16U)
136
#define GPIO_NUMBER           (16U)
145
 
137
 
146
/**
138
/**
147
  * @}
139
  * @}
148
  */
140
  */
Line 183... Line 175...
183
 
175
 
184
  /* Check the parameters */
176
  /* Check the parameters */
185
  assert_param(IS_GPIO_ALL_INSTANCE(GPIOx));
177
  assert_param(IS_GPIO_ALL_INSTANCE(GPIOx));
186
  assert_param(IS_GPIO_PIN(GPIO_Init->Pin));
178
  assert_param(IS_GPIO_PIN(GPIO_Init->Pin));
187
  assert_param(IS_GPIO_MODE(GPIO_Init->Mode));
179
  assert_param(IS_GPIO_MODE(GPIO_Init->Mode));
188
  assert_param(IS_GPIO_PULL(GPIO_Init->Pull));
-
 
189
 
180
 
190
  /* Configure the port pins */
181
  /* Configure the port pins */
191
  while (((GPIO_Init->Pin) >> position) != 0)
182
  while (((GPIO_Init->Pin) >> position) != 0)
192
  {
183
  {
193
    /* Get current io position */
184
    /* Get current io position */
Line 195... Line 186...
195
 
186
 
196
    if (iocurrent)
187
    if (iocurrent)
197
    {
188
    {
198
      /*--------------------- GPIO Mode Configuration ------------------------*/
189
      /*--------------------- GPIO Mode Configuration ------------------------*/
199
      /* In case of Output or Alternate function mode selection */
190
      /* In case of Output or Alternate function mode selection */
200
      if ((GPIO_Init->Mode == GPIO_MODE_OUTPUT_PP) || (GPIO_Init->Mode == GPIO_MODE_AF_PP) ||
191
      if (((GPIO_Init->Mode & GPIO_MODE) == MODE_OUTPUT) ||
201
          (GPIO_Init->Mode == GPIO_MODE_OUTPUT_OD) || (GPIO_Init->Mode == GPIO_MODE_AF_OD))
192
          ((GPIO_Init->Mode & GPIO_MODE) == MODE_AF))
202
      {
193
      {
203
        /* Check the Speed parameter */
194
        /* Check the Speed parameter */
204
        assert_param(IS_GPIO_SPEED(GPIO_Init->Speed));
195
        assert_param(IS_GPIO_SPEED(GPIO_Init->Speed));
205
        /* Configure the IO Speed */
196
        /* Configure the IO Speed */
206
        temp = GPIOx->OSPEEDR;
197
        temp = GPIOx->OSPEEDR;
Line 209... Line 200...
209
        GPIOx->OSPEEDR = temp;
200
        GPIOx->OSPEEDR = temp;
210
 
201
 
211
        /* Configure the IO Output Type */
202
        /* Configure the IO Output Type */
212
        temp = GPIOx->OTYPER;
203
        temp = GPIOx->OTYPER;
213
        CLEAR_BIT(temp, GPIO_OTYPER_OT_0 << position) ;
204
        CLEAR_BIT(temp, GPIO_OTYPER_OT_0 << position) ;
214
        SET_BIT(temp, ((GPIO_Init->Mode & GPIO_OUTPUT_TYPE) >> 4) << position);
205
        SET_BIT(temp, ((GPIO_Init->Mode & OUTPUT_TYPE) >> OUTPUT_TYPE_Pos) << position);
215
        GPIOx->OTYPER = temp;
206
        GPIOx->OTYPER = temp;
216
      }
207
      }
217
 
208
 
-
 
209
      if ((GPIO_Init->Mode & GPIO_MODE) != MODE_ANALOG)
-
 
210
      {
-
 
211
        /* Check the Pull parameter */
-
 
212
        assert_param(IS_GPIO_PULL(GPIO_Init->Pull));
-
 
213
 
218
      /* Activate the Pull-up or Pull down resistor for the current IO */
214
        /* Activate the Pull-up or Pull down resistor for the current IO */
219
      temp = GPIOx->PUPDR;
215
        temp = GPIOx->PUPDR;
220
      CLEAR_BIT(temp, GPIO_PUPDR_PUPDR0 << (position * 2));
216
        CLEAR_BIT(temp, GPIO_PUPDR_PUPDR0 << (position * 2));
221
      SET_BIT(temp, (GPIO_Init->Pull) << (position * 2));
217
        SET_BIT(temp, (GPIO_Init->Pull) << (position * 2));
222
      GPIOx->PUPDR = temp;
218
        GPIOx->PUPDR = temp;
-
 
219
      }
223
 
220
 
224
      /* In case of Alternate function mode selection */
221
      /* In case of Alternate function mode selection */
225
      if ((GPIO_Init->Mode == GPIO_MODE_AF_PP) || (GPIO_Init->Mode == GPIO_MODE_AF_OD))
222
      if ((GPIO_Init->Mode & GPIO_MODE) == MODE_AF)
226
      {
223
      {
227
        /* Check the Alternate function parameters */
224
        /* Check the Alternate function parameters */
228
        assert_param(IS_GPIO_AF_INSTANCE(GPIOx));
225
        assert_param(IS_GPIO_AF_INSTANCE(GPIOx));
229
        assert_param(IS_GPIO_AF(GPIO_Init->Alternate));
226
        assert_param(IS_GPIO_AF(GPIO_Init->Alternate));
230
 
227
 
Line 242... Line 239...
242
      SET_BIT(temp, (GPIO_Init->Mode & GPIO_MODE) << (position * 2));
239
      SET_BIT(temp, (GPIO_Init->Mode & GPIO_MODE) << (position * 2));
243
      GPIOx->MODER = temp;
240
      GPIOx->MODER = temp;
244
 
241
 
245
      /*--------------------- EXTI Mode Configuration ------------------------*/
242
      /*--------------------- EXTI Mode Configuration ------------------------*/
246
      /* Configure the External Interrupt or event for the current IO */
243
      /* Configure the External Interrupt or event for the current IO */
247
      if ((GPIO_Init->Mode & EXTI_MODE) == EXTI_MODE)
244
      if ((GPIO_Init->Mode & EXTI_MODE) != 0x00U)
248
      {
245
      {
249
        /* Enable SYSCFG Clock */
246
        /* Enable SYSCFG Clock */
250
        __HAL_RCC_SYSCFG_CLK_ENABLE();
247
        __HAL_RCC_SYSCFG_CLK_ENABLE();
251
 
248
 
252
        temp = SYSCFG->EXTICR[position >> 2];
249
        temp = SYSCFG->EXTICR[position >> 2];
Line 255... Line 252...
255
        SYSCFG->EXTICR[position >> 2] = temp;
252
        SYSCFG->EXTICR[position >> 2] = temp;
256
 
253
 
257
        /* Clear EXTI line configuration */
254
        /* Clear EXTI line configuration */
258
        temp = EXTI->IMR;
255
        temp = EXTI->IMR;
259
        CLEAR_BIT(temp, (uint32_t)iocurrent);
256
        CLEAR_BIT(temp, (uint32_t)iocurrent);
260
        if ((GPIO_Init->Mode & GPIO_MODE_IT) == GPIO_MODE_IT)
257
        if ((GPIO_Init->Mode & EXTI_IT) != 0x00U)
261
        {
258
        {
262
          SET_BIT(temp, iocurrent);
259
          SET_BIT(temp, iocurrent);
263
        }
260
        }
264
        EXTI->IMR = temp;
261
        EXTI->IMR = temp;
265
 
262
 
266
        temp = EXTI->EMR;
263
        temp = EXTI->EMR;
267
        CLEAR_BIT(temp, (uint32_t)iocurrent);
264
        CLEAR_BIT(temp, (uint32_t)iocurrent);
268
        if ((GPIO_Init->Mode & GPIO_MODE_EVT) == GPIO_MODE_EVT)
265
        if ((GPIO_Init->Mode & EXTI_EVT) != 0x00U)
269
        {
266
        {
270
          SET_BIT(temp, iocurrent);
267
          SET_BIT(temp, iocurrent);
271
        }
268
        }
272
        EXTI->EMR = temp;
269
        EXTI->EMR = temp;
273
 
270
 
274
        /* Clear Rising Falling edge configuration */
271
        /* Clear Rising Falling edge configuration */
275
        temp = EXTI->RTSR;
272
        temp = EXTI->RTSR;
276
        CLEAR_BIT(temp, (uint32_t)iocurrent);
273
        CLEAR_BIT(temp, (uint32_t)iocurrent);
277
        if ((GPIO_Init->Mode & RISING_EDGE) == RISING_EDGE)
274
        if ((GPIO_Init->Mode & TRIGGER_RISING) != 0x00U)
278
        {
275
        {
279
          SET_BIT(temp, iocurrent);
276
          SET_BIT(temp, iocurrent);
280
        }
277
        }
281
        EXTI->RTSR = temp;
278
        EXTI->RTSR = temp;
282
 
279
 
283
        temp = EXTI->FTSR;
280
        temp = EXTI->FTSR;
284
        CLEAR_BIT(temp, (uint32_t)iocurrent);
281
        CLEAR_BIT(temp, (uint32_t)iocurrent);
285
        if ((GPIO_Init->Mode & FALLING_EDGE) == FALLING_EDGE)
282
        if ((GPIO_Init->Mode & TRIGGER_FALLING) != 0x00U)
286
        {
283
        {
287
          SET_BIT(temp, iocurrent);
284
          SET_BIT(temp, iocurrent);
288
        }
285
        }
289
        EXTI->FTSR = temp;
286
        EXTI->FTSR = temp;
290
      }
287
      }