update
This commit is contained in:
@@ -32,6 +32,7 @@
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t band;
|
uint8_t band;
|
||||||
uint16_t vcc;
|
uint16_t vcc;
|
||||||
|
uint16_t cnt;
|
||||||
} contr_t;
|
} contr_t;
|
||||||
|
|
||||||
contr_t contr;
|
contr_t contr;
|
||||||
@@ -41,11 +42,6 @@ void contr_set_band(uint8_t band);
|
|||||||
void contr_write_band(void);
|
void contr_write_band(void);
|
||||||
void contr_read_band(void);
|
void contr_read_band(void);
|
||||||
|
|
||||||
ISR(TIMER0_OVF_vect) {
|
|
||||||
button_handle();
|
|
||||||
uart_handle();
|
|
||||||
}
|
|
||||||
|
|
||||||
void contr_init(void) {
|
void contr_init(void) {
|
||||||
contr.band = CONTR_BAND_OFF;
|
contr.band = CONTR_BAND_OFF;
|
||||||
}
|
}
|
||||||
@@ -109,7 +105,7 @@ void contr_set_band(uint8_t band) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
contr_write_band();
|
contr_write_band();
|
||||||
atten_on();
|
atten_off();
|
||||||
}
|
}
|
||||||
|
|
||||||
char* contr_get_bandname() {
|
char* contr_get_bandname() {
|
||||||
@@ -161,24 +157,71 @@ void contr_show_logo(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void contr_show_band(void) {
|
void contr_show_band(void) {
|
||||||
disp_string(0, 12, contr_get_bandname(contr.band));
|
disp_string(0, 13, contr_get_bandname(contr.band));
|
||||||
}
|
}
|
||||||
|
|
||||||
void contr_show_vcc(void) {
|
void contr_show_vcc(void) {
|
||||||
char buffer[12] = { '\0' };
|
char buffer[12] = { '\0' };
|
||||||
sprintf(buffer, "#%4.1fV", contr_get_vcc());
|
sprintf(buffer, "%03.1fv", contr_get_vcc());
|
||||||
disp_string(0, 0, buffer);
|
disp_string(3, 11, buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
void contr_show_ptt(void) {
|
||||||
|
if (ptt_is_pressed()) {
|
||||||
|
disp_string(3, 0, "TX");
|
||||||
|
} else {
|
||||||
|
disp_string(3, 0, " ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ISR(TIMER0_OVF_vect) {
|
||||||
|
//button_handle();
|
||||||
|
//uart_handle();
|
||||||
|
}
|
||||||
|
|
||||||
|
ISR(TIMER1_OVF_vect) {
|
||||||
|
contr.cnt++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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) {
|
||||||
|
char buffer[12] = { '\0' };
|
||||||
|
sprintf(buffer, "%8u", contr.cnt);
|
||||||
|
disp_string(2, 0, buffer);
|
||||||
|
}
|
||||||
|
|
||||||
void contr_main(void) {
|
void contr_main(void) {
|
||||||
|
|
||||||
contr_show_logo();
|
contr_show_logo();
|
||||||
uint16_t counter = 0;
|
uint16_t counter = 0;
|
||||||
|
sei();
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
|
contr_show_ptt();
|
||||||
contr_button_eval();
|
contr_button_eval();
|
||||||
contr_measure_vcc();
|
contr_measure_vcc();
|
||||||
contr_show_vcc();
|
contr_show_vcc();
|
||||||
contr_show_band();
|
contr_show_band();
|
||||||
|
contr_show_cnt();
|
||||||
counter++;
|
counter++;
|
||||||
_delay_ms(100);
|
_delay_ms(100);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ int main(void) {
|
|||||||
|
|
||||||
adc_init();
|
adc_init();
|
||||||
timer0_init();
|
timer0_init();
|
||||||
|
timer1_init();
|
||||||
|
|
||||||
atten_init();
|
atten_init();
|
||||||
relaytx_init();
|
relaytx_init();
|
||||||
@@ -37,6 +38,7 @@ int main(void) {
|
|||||||
relay80m_init();
|
relay80m_init();
|
||||||
buzzer_init();
|
buzzer_init();
|
||||||
fan_init();
|
fan_init();
|
||||||
|
ptt_init();
|
||||||
|
|
||||||
button_init();
|
button_init();
|
||||||
button_reset();
|
button_reset();
|
||||||
|
|||||||
@@ -11,6 +11,20 @@
|
|||||||
|
|
||||||
#include <tool.h>
|
#include <tool.h>
|
||||||
|
|
||||||
|
void ptt_init(void) {
|
||||||
|
/* D2 PD2: Set PTT input */
|
||||||
|
REG_SETDOWN_BIT(DDRD, PD2);
|
||||||
|
REG_SETUP_BIT(PORTD, PD2);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ptt_is_pressed(void) {
|
||||||
|
if (!REG_BIT_VALUE(PIND, PD2)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* D4 PD4: Set input relay 5 output */
|
/* D4 PD4: Set input relay 5 output */
|
||||||
void relaytx_init(void) {
|
void relaytx_init(void) {
|
||||||
REG_SETUP_BIT(DDRD, PD4);
|
REG_SETUP_BIT(DDRD, PD4);
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
#ifndef CONTR_RELAY_H_QWERTY
|
#ifndef CONTR_RELAY_H_QWERTY
|
||||||
#define CONTR_RELAY_H_QWERTY
|
#define CONTR_RELAY_H_QWERTY
|
||||||
|
|
||||||
|
void ptt_init(void);
|
||||||
|
bool ptt_is_pressed(void);
|
||||||
|
|
||||||
void relaytx_init(void);
|
void relaytx_init(void);
|
||||||
void relaytx_on(void);
|
void relaytx_on(void);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include <tool.h>
|
#include <tool.h>
|
||||||
|
|
||||||
void timer0_init(void) {
|
void timer0_init(void) {
|
||||||
|
/* TCCR0A */
|
||||||
/* Disable comparators */
|
/* Disable comparators */
|
||||||
REG_SETDOWN_BIT(TCCR0A, COM0A1);
|
REG_SETDOWN_BIT(TCCR0A, COM0A1);
|
||||||
REG_SETDOWN_BIT(TCCR0A, COM0A0);
|
REG_SETDOWN_BIT(TCCR0A, COM0A0);
|
||||||
@@ -17,11 +18,46 @@ void timer0_init(void) {
|
|||||||
/* Set normal mode */
|
/* Set normal mode */
|
||||||
REG_SETDOWN_BIT(TCCR0A, WGM01);
|
REG_SETDOWN_BIT(TCCR0A, WGM01);
|
||||||
REG_SETDOWN_BIT(TCCR0A, WGM00);
|
REG_SETDOWN_BIT(TCCR0A, WGM00);
|
||||||
|
|
||||||
|
/* TCCR0B */
|
||||||
/* Set clock to 1/64 */
|
/* Set clock to 1/64 */
|
||||||
REG_SETDOWN_BIT(TCCR0B, CS02);
|
REG_SETDOWN_BIT(TCCR0B, CS02);
|
||||||
REG_SETUP_BIT(TCCR0B, CS01);
|
REG_SETUP_BIT(TCCR0B, CS01);
|
||||||
REG_SETUP_BIT(TCCR0B, CS00);
|
REG_SETUP_BIT(TCCR0B, CS00);
|
||||||
|
|
||||||
|
/* TIMSK0 */
|
||||||
/* Enable timer interrupt */
|
/* Enable timer interrupt */
|
||||||
REG_SETUP_BIT(TIMSK0, TOIE0);
|
REG_SETUP_BIT(TIMSK0, TOIE0);
|
||||||
//REG_SETUP(TCNT0, TIMER_INITVAL);
|
}
|
||||||
|
|
||||||
|
void timer1_init(void) {
|
||||||
|
/* TCCR1A */
|
||||||
|
REG_SETDOWN_BIT(TCCR1A, COM1A1);
|
||||||
|
REG_SETDOWN_BIT(TCCR1A, COM1A0);
|
||||||
|
REG_SETDOWN_BIT(TCCR1A, COM1B1);
|
||||||
|
REG_SETDOWN_BIT(TCCR1A, COM1B0);
|
||||||
|
REG_SETDOWN_BIT(TCCR1A, WGM11);
|
||||||
|
REG_SETDOWN_BIT(TCCR1A, WGM10);
|
||||||
|
|
||||||
|
/* TCCR1B */
|
||||||
|
/* Disable capture noise canceler */
|
||||||
|
REG_SETDOWN_BIT(TCCR1B, ICNC1);
|
||||||
|
/* Set Capture Edge */
|
||||||
|
REG_SETUP_BIT(TCCR1B, ICES1);
|
||||||
|
/* Disable waveform generation */
|
||||||
|
REG_SETDOWN_BIT(TCCR1B, WGM13);
|
||||||
|
REG_SETDOWN_BIT(TCCR1B, WGM12);
|
||||||
|
/* Set prescaler */
|
||||||
|
REG_SETDOWN_BIT(TCCR1B, CS10);
|
||||||
|
REG_SETUP_BIT(TCCR1B, CS11);
|
||||||
|
REG_SETUP_BIT(TCCR1B, CS12);
|
||||||
|
|
||||||
|
/* TIMSK1 */
|
||||||
|
/* Disable capture interrupt */
|
||||||
|
REG_SETDOWN_BIT(TIMSK1, ICIE1);
|
||||||
|
/* Disable compare interrupt */
|
||||||
|
REG_SETDOWN_BIT(TIMSK1, OCIE1B);
|
||||||
|
REG_SETDOWN_BIT(TIMSK1, OCIE1A);
|
||||||
|
/* ENABLE overflow interrupt */
|
||||||
|
REG_SETUP_BIT(TIMSK1, TOIE1);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user