diff --git a/Makefile b/Makefile index 2a2b28f..9656d51 100644 --- a/Makefile +++ b/Makefile @@ -9,14 +9,14 @@ STCGALOPTS ?= STCGALPORT ?= /dev/ttyUSB0 STCGALPROT ?= auto FLASHFILE ?= main.ihx -SYSCLK ?= 11056 -FOSC ?=11056000L +#SYSCLK ?= 11056 +#FOSC ?=11056000L CFLAGS ?= -DWITH_ALT_LED9 -DWITHOUT_LEDTABLE_RELOC -DSHOW_TEMP_DATE_WEEKDAY LIBSRC = uart_init.c uart_send_chr.c uart_send_str.c \ rotary_encoder_stat.c \ sevenseg_dec.c sevenseg_dec_inv.c \ - int_to_bcd.c + int_to_bcd.c getbutton.c LIBOBJ =$(patsubst %.c,%.rel, $(LIBSRC)) LIBNAME=mc8051fun.lib diff --git a/mc8051fun.h b/mc8051fun.h index a47823a..71e274b 100644 --- a/mc8051fun.h +++ b/mc8051fun.h @@ -18,9 +18,33 @@ int8_t rotary_encoder_stat(uint8_t b); extern uint8_t sevenseg_dec[10]; extern uint8_t sevenseg_dec_inv[10]; +/** + * Minimum frequency is 15 Hz @ FOSC of 11 Mhz + */ +#define default_timer16_init_val(freq) ((65536L)-FOSC/12L/freq) +#define default_timer8_init_val(freq) ((256L)-FOSC/12L/freq) + +#define at89xx_6t_timer16_init_val(freq) ((65536L)-FOSC/6L/freq) +#define at89xx_6t_timer8_init_val(freq) ((256L)-FOSC/6L/freq) + + +#define STC15XX 1 // STC15xx family +#define AT89XX 2 // AT89XX family +#define AT89XX_6T 3 // AT89C89C52 in 6T mode + +#if MCU==AT89XX_6T +#define timer8_init_val(freq) at89xx_6t_timer8_init_val(freq) +#define timer16_init_val(freq) at89xx_6t_timer16_init_val(freq) +#else +#define timer8_init_val(freq) default_timer8_init_val(freq) +#define timer16_init_val(freq) default_timer16_init_val(freq) +#endif -#define timer_init_val(freq) ((65536)-FOSC/12L/freq) uint16_t int_to_bcd(uint16_t i); +int getbutton(uint8_t pinval, uint8_t *button); +extern uint8_t getbutton_time; + + #endif