#ifndef __deffisar_h__ #define __deffisar_h__ /*--------- * Defines *---------*/ #define MSEC 0x1AE /* Millisecond */ #define FAN_CONNECTED 1 #define TEMP_CONNECTED 1 #define AD_NRCONNECTED 2 #define EEPROM_WAIT_TIME 20 typedef struct temp_t temp; typedef struct fan_t fan; /*--------- * Structs *---------*/ /* Strukt för en temperatursensor */ struct temp_t { unsigned short status; unsigned short curr_value; unsigned short min_value; unsigned short max_value; unsigned short fan_dep[8]; /* Mera bra saker som tex kalibreringstabell */ }; /* Strukt för en fläkt */ struct fan_t { unsigned short status; unsigned short curr_speed; }; /*------------------ * Global variables *------------------*/ unsigned short current_ad; unsigned short step_counter; unsigned short *eprom, *sram, *eeprom, *eeprom_fans, *eeprom_temps, *ad, *vippor, *lcd, *lcd_reg, *adstart; fan fans[8]; temp temps[8]; /*----------------------------- * Prototypes for mem routines *-----------------------------*/ /* Set all global pointers */ void set_ptrs(); /* Set a part of the memory to a desired value */ void memeset(void*, char, unsigned long); /*----------------------------- * Prototypes for lcd routines *-----------------------------*/ /* Check if the LCD is busy */ unsigned short lcd_busy(); /* Initiate LCD */ void lcd_init(); /* Write characters as quickly as possible */ void lcd_write(char *msg, unsigned short len); /* Write text with delay between characters */ void lcd_write_cool(char *, unsigned short); /* 1 - right, 0 - left */ void lcd_shift(unsigned short); /* Write an unsigned short as a hexadecimal value */ void lcd_puthex(char, unsigned short); /* Write an unsigned short as a decimal value */ void lcd_putdec(char, unsigned short); /* Same as putdec, but do not specify where to write on the screen */ void lcd_putdec_here(char); /* Write an unsigned short on the screen */ void lcd_putchar(char, unsigned short); /* Same as putchar, but do not specify where to write on the screen */ void lcd_putchar_here(char); /* Set the position of the internal memory pointer of the LCD */ void lcd_setpos(unsigned short); /* Clear the screen */ void lcd_clear(); /*------ * Wait *------*/ /* wait for a short while 430 ~ 1 millisecond */ void wait(unsigned long); /* wait for milliseconds */ void wait_millisec(unsigned long); /*--------------------------- Bra strukt <-> EEPROM saker --------------------------- */ /* Läser en fan-strukt från eeprom */ void read_fan(unsigned short); /* Skriver en fan-strukt i eeprom */ void write_fan(unsigned short); /* Läser en temp-strukt från eeprom */ void read_temp(unsigned short); /*Skriver en temp-strukt i eeprom */ void write_temp(unsigned short); unsigned short eeprom_read(unsigned short*); void eeprom_write(unsigned short, unsigned short*); /*------------------- * Control functions *-------------------*/ /* Enable interrupts */ void _avben(); /* Initiate data structures */ void init_everything(); /* Do one step of the inner control loop, return current motor status */ unsigned short step(); /* Show temp status on the LCD */ void show_tmps(); /* Show fan status on the LCD */ void show_fans(); #endif /* __deffisar_h__ */