142 lines
2.5 KiB
C
142 lines
2.5 KiB
C
|
|
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
#include <avr/interrupt.h>
|
|
#include <util/delay.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 filter 5 output */
|
|
void ampl_init(void) {
|
|
REG_SETUP_BIT(DDRD, PD4);
|
|
}
|
|
void ampl_on(void) {
|
|
REG_SETUP_BIT(PORTD, PD4);
|
|
}
|
|
void ampl_off(void) {
|
|
REG_SETDOWN_BIT(PORTD, PD4);
|
|
}
|
|
void ampl_onoff(void) {
|
|
if (REG_BIT_VALUE(PIND, PD4)) {
|
|
ampl_off();
|
|
} else {
|
|
ampl_on();
|
|
}
|
|
}
|
|
/* D6 PD6: Set 10M filter 1 output */
|
|
void filter10m_init(void) {
|
|
REG_SETUP_BIT(DDRD, PD6);
|
|
}
|
|
void filter10m_on(void) {
|
|
REG_SETUP_BIT(PORTD, PD6);
|
|
}
|
|
void filter10m_off(void) {
|
|
REG_SETDOWN_BIT(PORTD, PD6);
|
|
}
|
|
|
|
/* D7 PD7: Set 20M filter 2 output */
|
|
void filter20m_init(void) {
|
|
REG_SETUP_BIT(DDRD, PD7);
|
|
}
|
|
void filter20m_on(void) {
|
|
REG_SETUP_BIT(PORTD, PD7);
|
|
}
|
|
void filter20m_off(void) {
|
|
REG_SETDOWN_BIT(PORTD, PD7);
|
|
}
|
|
|
|
/* D8 PB0: Set 40M filter 3 output */
|
|
void filter40m_init(void) {
|
|
REG_SETUP_BIT(DDRB, PB0);
|
|
}
|
|
void filter40m_on(void) {
|
|
REG_SETUP_BIT(PORTB, PB0);
|
|
}
|
|
void filter40m_off(void) {
|
|
REG_SETDOWN_BIT(PORTB, PB0);
|
|
}
|
|
|
|
/* D9 PB1: Set 80M filter 4 output */
|
|
void filter80m_init(void) {
|
|
REG_SETUP_BIT(DDRB, PB1);
|
|
}
|
|
void filter80m_on(void) {
|
|
REG_SETUP_BIT(PORTB, PB1);
|
|
}
|
|
void filter80m_off(void) {
|
|
REG_SETDOWN_BIT(PORTB, PB1);
|
|
}
|
|
|
|
/* D10 PB2: Set buzzer output */
|
|
void buzzer_init(void) {
|
|
REG_SETUP_BIT(DDRB, PB2);
|
|
}
|
|
void buzzer_on(void) {
|
|
REG_SETUP_BIT(PORTB, PB2);
|
|
}
|
|
void buzzer_off(void) {
|
|
REG_SETDOWN_BIT(PORTB, PB2);
|
|
}
|
|
void buzzer_onoff(void) {
|
|
if (REG_BIT_VALUE(PINB, PB2)) {
|
|
buzzer_off();
|
|
} else {
|
|
buzzer_on();
|
|
}
|
|
}
|
|
|
|
/* D12 PB4: Set fan output */
|
|
void fan_init(void) {
|
|
REG_SETUP_BIT(DDRB, PB4);
|
|
}
|
|
void fan_on(void) {
|
|
REG_SETUP_BIT(PORTB, PB4);
|
|
}
|
|
void fan_off(void) {
|
|
REG_SETDOWN_BIT(PORTB, PB4);
|
|
}
|
|
void fan_onoff(void) {
|
|
if (REG_BIT_VALUE(PINB, PB4)) {
|
|
fan_off();
|
|
} else {
|
|
fan_on();
|
|
}
|
|
}
|
|
bool fan_is_on(void) {
|
|
if (REG_BIT_VALUE(PINB, PB4)) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
/* D13 PB5: Set attenuator filter output */
|
|
void atten_init(void) {
|
|
REG_SETUP_BIT(DDRB, PB5);
|
|
}
|
|
void atten_on(void) {
|
|
REG_SETUP_BIT(PORTB, PB5);
|
|
}
|
|
void atten_off(void) {
|
|
REG_SETDOWN_BIT(PORTB, PB5);
|
|
}
|
|
|