New functions

This commit is contained in:
7u83 2024-05-23 22:48:41 +02:00
parent 815d9c94ba
commit 18c6fc5220
2 changed files with 28 additions and 4 deletions

View File

@ -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

View File

@ -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