STM32 External Interrupts

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

asfarley
Posts: 8
Joined: Thu Dec 13, 2012 7:19 pm

Re: STM32 External Interrupts

Post by asfarley »

Also, when I comment out the alternate function configuration line, this line:
NVICEnableVector(EXTI15_10_IRQn,1);

gives an error: no definition for NVICEnableVector.
asfarley
Posts: 8
Joined: Thu Dec 13, 2012 7:19 pm

Re: STM32 External Interrupts

Post by asfarley »

Also, this line:
NVICEnableVector(EXTI15_10_IRQn,1);

now gives me an error: no definition for NVICEnableVector().

(sorry for the double post)

Code: Select all

/*
    ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010,
                 2011,2012 Giovanni Di Sirio.

    This file is part of ChibiOS/RT.

    ChibiOS/RT is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.

    ChibiOS/RT is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

                                      ---

    A special exception to the GPL can be applied should you wish to distribute
    a combined work that includes ChibiOS/RT, without being obliged to provide
    the source code for any proprietary components. See the file exception.txt
    for full details of how and when the exception can be applied.
*/

#include "ch.h"
#include "hal.h"
#include "stm32f4xx.h"


#define ABS_SENSOR_EXTI_LINE ((uint32_t)0x02000) /*!< External interrupt line 10, see STM32F4 reference manual p. 208  */

void extLinIntInit(void) {
EXTI->IMR = EXTI_IMR_MR10;
EXTI->EMR = EXTI_EMR_MR10;
EXTI->RTSR = EXTI_RTSR_TR10; // interrupt on rising
EXTI->FTSR = EXTI_FTSR_TR10; // and descending
//AFIO->EXTICR[3] |= (1<<9); // Assign AFIO to line EXTI10 -> PC10
//SYSCFG_EXTICR3 = (1<<9);
NVICEnableVector(EXTI15_10_IRQn,1);
}


CH_IRQ_HANDLER(EXTI15_10_IRQHandler) {
  CH_IRQ_PROLOGUE();
 
if (EXTI->PR == ABS_SENSOR_EXTI_LINE) // check activation of PC10
{
palClearPad(GPIOC, GPIOC_SPARE);
EXTI->PR = ABS_SENSOR_EXTI_LINE; // reset interrupt
}

  CH_IRQ_EPILOGUE();
}

/*
 * This is a periodic thread that does absolutely nothing except flashing
 * a LED.
 */
static WORKING_AREA(waThread1, 128);
static msg_t Thread1(void *arg) {

  (void)arg;
  chRegSetThreadName("blinker");
  while (TRUE) {
    palSetPad(GPIOC, GPIOC_SPARE);       /* Orange.  */
    chThdSleepMilliseconds(5000);
    palClearPad(GPIOC, GPIOC_SPARE);     /* Orange.  */
    chThdSleepMilliseconds(5000);
  }
}

/*
 * Application entry point.
 */
int main(void) {

  /*
   * System initializations.
   * - HAL initialization, this also initializes the configured device drivers
   *   and performs the board-specific initializations.
   * - Kernel initialization, the main() function becomes a thread and the
   *   RTOS is active.
   */
  halInit();
  chSysInit();
 

  /*
   * Creates the example thread.
   */
  extLinIntInit();
  palSetPadMode(GPIOC, GPIOC_SPARE, PAL_MODE_OUTPUT_PUSHPULL);
  palSetPad(GPIOC, GPIOC_SPARE); 
 
  //chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);

  /*
   * Normal main() thread activity, in this demo it does nothing except
   * sleeping in a loop and check the button state, when the button is
   * pressed the test procedure is launched with output on the serial
   * driver 2.
   */
  while (TRUE) {
    chThdSleepMilliseconds(500);
  }
}
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: STM32 External Interrupts

Post by Giovanni »

Is there any specific reason to not use the EXT driver?

Giovanni
asfarley
Posts: 8
Joined: Thu Dec 13, 2012 7:19 pm

Re: STM32 External Interrupts

Post by asfarley »

No, I didn't know there was such a thing. I'll look into that, thanks.
Post Reply