Vous êtes sur la page 1sur 2

1 /***************************************************************************

2 * FACIT *
3 * Sistemas Embarcados *
4 ****************************************************************************
5 * VERSÃO:1.0 *
6 * DATA: 28/12/2017 *
7 ***************************************************************************/
8
9 /***************************************************************************
10 * DESCRIÇÃO GERAL DO FIRMWARE *
11 ***************************************************************************/
12 /*
13
14
15 */
16
17 /*==========================================================================
18 1. ARQUIVOS DE DEFINIÇÕES (INCLUDES)
19 ==========================================================================*/
20
21 #include "io430.h"
22
23 /*==========================================================================
24 2. DECLARAÇÕES
25 ==========================================================================*/
26
27 unsigned int temp;
28 int inc = 1;
29 unsigned char statusLed[] = {0x08, 0x09, 0x49, 0x48};
30
31 /*==========================================================================
32 3. PROTOTIPAGEM DE FUNÇÕES
33 ==========================================================================*/
34
35 void aguardaPulso();
36 void gpioStatus();
37
38 /*==========================================================================
39 5. FUNÇÃO PRINCIPAL
40 ==========================================================================*/
41
42 int main( void ){
43 //Configurações
44 WDTCTL = WDTPW + WDTHOLD;// Desativa o watchdog timer
45 P1DIR = 0xF7; // P1.3 como entrada e P1.0 e P1.6 como saída
46 P1REN = 0x08; // Ativa o pull up interno em todos os pinos que
47 // estão sendo usado como entrada (o pull up é
48 // ativado com o valor "1")
49 P1OUT = 0x08;
50
51 while (1){
52 aguardaPulso(); gpioStatus();
53 aguardaPulso(); gpioStatus();
54 aguardaPulso(); gpioStatus();
55 aguardaPulso(); gpioStatus();
56 }
57 }
58
59 /*==========================================================================
60 6. FUNÇÃO DO USUÁRIO
61 ==========================================================================*/
62
63 // Rotina para aguardar o pressionamento e a liberação de S2
64 void aguardaPulso(){
65 while(P1IN & 0x08); // P1.3 = "1" indica SOLTO
66 __delay_cycles(200000); // aguarda o término de possível ruído de
67 // chaveamento (antiBounce)
68 while(!(P1IN & 0x08)); // P1.3 = "0" indica PRESSIONADO
69 }
70
71 void gpioStatus(){
72 P1OUT = statusLed[inc];
73 inc++;
74 if(inc>3){
75 inc = 0;
76 }
77 }
78
79 /*==========================================================================
80 FIM DO ARQUIVO
81 ==========================================================================*/
82

Vous aimerez peut-être aussi