diff --git a/README.md b/README.md index 20e87d8..0fff135 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,19 @@ # Micro PA50 controller + +set tx off; +while (ptt is on || have input power ) { + check freq; + if freq in { + set lpf for the freq if need; + calc vswr; + if (swr is good) { + set tx on; + } else { + show wrong swr; + } + } else { + show wron freq; + set tx off; + } +} diff --git a/contr.c b/contr.c index 16ef4ae..4b72f5f 100644 --- a/contr.c +++ b/contr.c @@ -33,6 +33,7 @@ typedef struct { uint8_t band; uint16_t vcc; uint16_t cnt; + uint16_t freq; } contr_t; contr_t contr; @@ -175,53 +176,33 @@ void contr_show_ptt(void) { } ISR(TIMER0_OVF_vect) { - //button_handle(); - //uart_handle(); + contr.freq = contr.cnt; + contr.cnt = 0; + button_handle(); + uart_handle(); } ISR(TIMER1_OVF_vect) { contr.cnt++; + REG_SETUP(TCNT1, TIMER1_PRESIZE); } - -void xxtimer0_init(void) { - /* Disable comparators */ - REG_SETDOWN_BIT(TCCR0A, COM0A1); - REG_SETDOWN_BIT(TCCR0A, COM0A0); - REG_SETDOWN_BIT(TCCR0A, COM0B1); - REG_SETDOWN_BIT(TCCR0A, COM0B0); - /* Set normal mode */ - REG_SETDOWN_BIT(TCCR0A, WGM01); - REG_SETDOWN_BIT(TCCR0A, WGM00); - /* Set clock to 1/64 */ - REG_SETDOWN_BIT(TCCR0B, CS02); - REG_SETUP_BIT(TCCR0B, CS01); - REG_SETUP_BIT(TCCR0B, CS00); - /* Enable timer interrupt */ - REG_SETUP_BIT(TIMSK0, TOIE0); -} - - - -void contr_show_cnt(void) { +void contr_show_freq(void) { char buffer[12] = { '\0' }; - sprintf(buffer, "%8u", contr.cnt); - disp_string(2, 0, buffer); + sprintf(buffer, "%2.0fM", (float)contr.freq / 16.05F); + disp_string(0, 0, buffer); } void contr_main(void) { - contr_show_logo(); uint16_t counter = 0; - sei(); - while (true) { contr_show_ptt(); contr_button_eval(); contr_measure_vcc(); contr_show_vcc(); contr_show_band(); - contr_show_cnt(); + contr_show_freq(); counter++; _delay_ms(100); } diff --git a/timer.c b/timer.c index 7f0fe00..6621d79 100644 --- a/timer.c +++ b/timer.c @@ -7,6 +7,7 @@ #include #include +#include void timer0_init(void) { /* TCCR0A */ @@ -59,5 +60,6 @@ void timer1_init(void) { REG_SETDOWN_BIT(TIMSK1, OCIE1B); REG_SETDOWN_BIT(TIMSK1, OCIE1A); /* ENABLE overflow interrupt */ + REG_SETUP(TCNT1, TIMER1_PRESIZE); REG_SETUP_BIT(TIMSK1, TOIE1); } diff --git a/timer.h b/timer.h index e43ddc3..1ae427c 100644 --- a/timer.h +++ b/timer.h @@ -1,6 +1,8 @@ #ifndef CONTR_INIT_H_QWERTY #define CONTR_INIT_H_QWERTY +#define TIMER1_PRESIZE 65532 // 65536 + void timer0_init(void); void timer1_init(void);