/* freedom.h ========= */ #include #pragma config FOSC = HS #pragma config WDT = OFF, LVP = OFF, PBADEN = OFF // --------------------------- #define BT1 PORTBbits.RB4 #define BT2 PORTBbits.RB5 #define BT3 PORTBbits.RB6 #define BT4 PORTBbits.RB7 #ifdef LCD #define LCD_DEFAULT #include #else #define LED1 LATDbits.LATD0 #define LED2 LATDbits.LATD1 #define LED3 LATDbits.LATD2 #define LED4 LATDbits.LATD3 #define LED5 LATDbits.LATD4 #define LED6 LATDbits.LATD5 #define LED7 LATDbits.LATD6 #define LED8 LATDbits.LATD7 #define PORTA_LED LATD #endif #define BACK_LIGHT LATCbits.LATC1 #define BUZZER LATCbits.LATC0 #define SENSORE_LUCE ADC_CH0 //AN0 #define TRIMMER ADC_CH1 //AN1 #define SENSORE_TEMPERATURA ADC_CH2 //AN2 void InitFreedom(); void InitFreedom() { //ADCON1 = 0x0F; //imposta tutte le porte come I/O digitali ADCON1 = 0b1100; INTCON2bits.RBPU = 0; //abilita le R di pull-up sulla porta B LATA = 0; TRISA = 0b00000111; //analogical input LATB = 0; TRISB = 0b11110000; //four user buttons LATC = 0; TRISC = 0b00000000; LATD = 0; TRISD = 0b00000000; //leds + LCD LATE = 0; TRISE = 0b00000000; #ifdef LCD OpenLCD(20); BacklightLCD(TURN_ON); CursorLCD(TURN_ON, BLINK_OFF); #endif }