; /*********************************************************************************************************** ; * Tastiera.asm ; ***********************************************************************************************************/ ; /* Created on: 24 luglio 2017 ; * Author: Maria Angela Cianci ; */ ;*************************************************************************************************************** ; La macro tastiera gestisce la pressione dei tasti e la funzione del tasto premuto, purchè il dat gli arrivi ; all'interno del registro R4 in posizione LSB. Questa sarà poi la funzione che vado a chiamare per il ; controllo della tastiera (tasto premuto o no, per quanto tempo, ecc...). ;*************************************************************************************************************** ;*************************************************************************************************************** ; La direttiva cdecl mi permettere di includere i vari header file di cui ho bisogno per il funzionamento ; del programma. ;*************************************************************************************************************** .cdecls C,LIST, "msp430g2744.h" .cdecls C,LIST, "Definizioni_Tastiera.h" .align 2 .bss TASTO,1 .bss OLD_TASTO,1 .bss PRENDITASTO,1 .bss FLAG_VARI,2,2 .bss TIMER_BLINK,1 .bss TIMER_TASTOSOLO,1 .text .global TASTO .global OLD_TASTO .global tastiera_standard tastiera_standard: .asmfunc push.w R5 mov.b P2IN, R5 inv.b R5 and.b #00111111b, R5 cmp.b OLD_TASTO, R5 jeq tasto_premuto ritasto: mov.b R5, OLD_TASTO clr.b TASTO bic.w #(FLAG_TASTOCONTINUO+FLAG_TASTOSOLO+FLAG_TASTOPREMUTO),FLAG_VARI mov.b #CAMPIONI_TASTI, PRENDITASTO clr.b TIMER_TASTOSOLO br #tastiera_exit tasto_premuto: bit.w #(FLAG_TASTOCONTINUO+FLAG_TASTOSOLO+FLAG_TASTOPREMUTO),FLAG_VARI jne PRESO dec.b PRENDITASTO jn PRESO mov.b R5, OLD_TASTO br #tastiera_exit PRESO: mov.b #CAMPIONI_TASTI, PRENDITASTO mov.b OLD_TASTO, TASTO tst.b TASTO jeq ritasto bit.b #TIMER_BLINK800,TIMER_TASTOSOLO jne tasto_continuo bit.w #(FLAG_TASTOCONTINUO + FLAG_TASTOSOLO),FLAG_VARI jne tastiera_exit bis.w #FLAG_TASTOSOLO, FLAG_VARI bic.b #FLAG_TASTOCONTINUO, FLAG_VARI br #tastiera_exit tasto_continuo: bis.b #TIMER_BLINK800, TIMER_TASTOSOLO bis.w #FLAG_TASTOCONTINUO, FLAG_VARI bic.w #FLAG_TASTOSOLO, FLAG_VARI tastiera_exit: pop.w R5 ret .endasmfunc /************************************************************************************************************ * Routine_Tastiera.c ***********************************************************************************************************/ /* Created on: 26 luglio 2017 * Author: Maria Angela Cianci */ #include #include #include #include void botton_pushed (unsigned char tasto) { unsigned char tasto_up; unsigned char tasto_down; tasto_up=TASTO_UP; tasto_down=TASTO_DOWN; tasto=TASTO; if(tasto==tasto_up) { VALUE++; Temp_Setpoint=VALUE; } if(tasto==tasto_down) { VALUE--; Temp_Setpoint=VALUE; } else { VALUE; Temp_Setpoint=VALUE; } } /************************************************************************************************************ * Definizioni_Tastiera.h ***********************************************************************************************************/ /* Created on: 24 luglio 2017 * Author: Maria Angela Cianci */ /************************************************************************************************************ * DEFINIZIONI DELLE MASCHERE DEI TASTI * Associa ogni PIN della porta 2 ad un determinato tasto sulla tastiera. * ***********************************************************************************************************/ #define TASTO_UP 0b00001000 #define TASTO_DOWN 0b00000010 extern unsigned char TASTO; extern unsigned char OLD_TASTO; unsigned int Temp_Setpoint; extern void tastiera_standard(); void botton_pushed (unsigned char tasto); /************************************************************************** * PROGETTO EL_0002_17_V00 * Created on: 22 giugno 2017 * Poject Name: SOUS COOKER SEMIPROFESSIONAL * Mcu: MSP430G2744 * Author: Maria Angela Cianci *************************************************************************/ #include #include #include #include #include #include #include #include /************************************************************************** * MAIN * *************************************************************************/ int main(void) { WDTCTL = WDTPW | WDTHOLD; //watchdog_disable; /* Inizializzo lo stack pointer al valore 0x5FF in fondo alla RAM */ __asm (" MOV.W #0x0600,SP"); clear_RAM(); delay_watchdog(wdt_delay); watchdog_enable(); configurazione_iniziale(); Temp_Setpoint=100; VALUE=Temp_Setpoint; display_initialization(); while (1) { watchdog(); botton_pushed(TASTO); display_startup(VALUE); --> routine to display the value on 8-segment 4 digit display } }