![]() ![]() We retrieve the current status of the button, and set it so that if the button is pressed, then it turns on the green LED and extinguishes the red. Here, we begin and end the critical section. PortMUX_TYPE mux = portMUX_INITIALIZER_UNLOCKED usado para desabilitar e interromper interrupções Para configurar seções críticas (interrupções de ativação e interrupções de desativação não disponíveis) used to disable and interrupt interrupts For setting up critical sections (enableinterrupts and disableinterrupts not available) Volatile uint32_t debounceTimeout = 0 //guarda o tempo de debounce Volatile bool lastState //guarda o último estado do botão quando ocorreu a interrupção Volatile int numberOfButtonInterrupts = 0 //número de vezes que a interrupção foi executada É DECLARADA VOLÁTIL PORQUE SERÁ COMPARTILHADA PELO ISR E PELO CÓDIGO PRINCIPAL ![]() #define pinGREENled 4 //pino do led VERDE ![]() #define pinREDled 2 //pino do led VERMELHO #define pinBUTTON 23 //pino de interrupção (botão) #define DEBOUNCETIME 10 //tempo máximo de debounce para o botão (ms) We point out the variables for control within the loop. Next, we’ll set the red and green LEDs.Īt this stage, we will also declare volatiles to be shared by the ISR and the primary code. ![]() First, we’ll set the interrupt pin and the maximum debounce time for the button. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |