This commit is contained in:
Олег Бородин
2024-08-21 19:48:25 +02:00
parent 5e922d155e
commit fbd0a7e6e8
4 changed files with 31 additions and 29 deletions

View File

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

39
contr.c
View File

@@ -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);
}

View File

@@ -7,6 +7,7 @@
#include <util/delay.h>
#include <tool.h>
#include <timer.h>
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);
}

View File

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