para el ventilador

Dependencies:   QEI FastPWM

buttons.cpp

Committer:
miguelangel_2511
Date:
2020-04-16
Revision:
1:aa5df1878126
Parent:
0:9d0b9785d3d6
Child:
3:45299e7882b9

File content as of revision 1:aa5df1878126:


#include "mbed.h"
#include "buttons.h"


/* Object definition */
BusIn  buttons (ENTER_SW_PIN, LIMIT_SW_01_PIN, GAS_INPUT_SW_PIN);

/* Global variable definition */
volatile uint8_t button_state = 0; // debounced button state (bit == 1: button pressed)
volatile uint8_t button_press = 0; // button press detect



void Buttons_Initialize(void){
    // Enable the pull-up resistors for the buttons and the switch    
    //buttons.mode(PullUp);
}



/****************************************************************
   getButtonPress: check if a button has been pressed. 
   Each pressed key is reported only once
*****************************************************************/

uint8_t Get_Button_Press(uint8_t button_mask){
  __disable_irq();                                 // disable interrupts
  button_mask &= button_press;                     // read button(s)
  button_press ^= button_mask;                     // clear button(s)
  __enable_irq();                                   // enable interrupts     
  return button_mask;
}