1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- #include <avr/io.h>
- #include <util/delay.h>
- #include <avr/pgmspace.h>
- #include "main.h"
- #include "1wire.h"
- #include "gtext.h"
- #include "sed1335.h"
- #include "ds18b20.h"
- #include "dac8571.h"
- #include "display.h"
- volatile struct timers timers;
- unsigned char getkey(void){
- static unsigned char old;
- unsigned char key;
- DDRA = 0;
- PORTA = 0xff;
- DDRC |= _BV(PC7);
- _delay_ms(2);
- key = ~PINA;
- DDRC &= ~_BV(PC7);
- PORTA = 0;
- DDRA = 0xff;
- if(key == old) return 0;
- old = key;
- return key;
- }
- void main(void){
- unsigned char i=0;
- /* unsigned char state = STATE_DEFAULT;
- unsigned char oldstate = state;*/
- unsigned int dac1 = 0, dac2 = 32768;
-
-
- OCR2A = 250; // 16ms
- TCCR2A = _BV(WGM21);
- TCCR2B = _BV(CS22) | _BV(CS21) | _BV(CS20);
- TIMSK2 = _BV(OCIE2A);
- sei();
- PORTC &= _BV(PC7);
- DDRB |= _BV(PB2);
-
- GLCD_Initialize();
- GLCD_Clear();
- for(;;){
- _delay_ms(1);
- if(i = getkey()){
- cursor(0,0);
- disp_num(i);
- clearline();
- }
- dac8571_set(++dac1, VOLT_DAC);
- dac8571_set(++dac2, CURR_DAC);
- /* gettemp();
- control();
- state = state_processors[state](state);
- if(oldstate != state){
- GLCD_Clear();
- settings_update = 1;
- }
- oldstate = state;
- send_595(&led, 1);*/
- }
- }
- ISR(TIMER2_COMPA_vect){ // 16ms
- unsigned int *volatile ctimer;
- unsigned char i;
-
- for(i=0; i<sizeof(timers)/sizeof(unsigned int); i++){
- ctimer = ((unsigned int *)&timers) + i;
- if(*ctimer)
- (*ctimer)--;
- }
- }
|