/* Programme pour une carte NUCLEO-32 L031K6 
 * modification de la led interne par lecture d'une interruption externe
 */

#define BP_Pin PA0
#define LED_PIN PB3

void incrementCount() {
  //digitalWrite(LED_PIN,!digitalRead(LED_PIN));
  GPIOB->ODR ^= (1 << 3);  // XOR operation to invert the state of PB3
}

void setup() {

  // Configure PA0 as input with pull-up
  GPIOA->MODER &= ~GPIO_MODER_MODE0_Msk;   // Clear mode bits for PA0
  GPIOA->PUPDR |= GPIO_PUPDR_PUPD0_0;      // Set pull-up configuration for PA0
  // Configure PB3 as output
  GPIOB->MODER &= ~GPIO_MODER_MODE3_Msk;  // Clear mode bits for PB3
  GPIOB->MODER |= GPIO_MODER_MODE3_0;     // Set mode bits to 01 for output

  attachInterrupt(digitalPinToInterrupt(BP_Pin), incrementCount, RISING);
}

void loop() 
{}
Loading
st-nucleo-l031k6