diff --git a/Makefile b/Makefile index 1160376..10e3e36 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ LDFLAGS += -Wl,-u,vfprintf -lprintf_flt MAIN_OBJS += main.o MAIN_OBJS += contr_main.o -MAIN_OBJS += contr_relay.o +MAIN_OBJS += relay.o MAIN_OBJS += contr_init.o MAIN_OBJS += eeprom.o MAIN_OBJS += i2c.o diff --git a/contr_main.c b/contr_main.c index 367bfa2..b9ffdf7 100644 --- a/contr_main.c +++ b/contr_main.c @@ -16,9 +16,9 @@ #include #include #include +#include #include -#include #include #define CONTR_BAND_OFF 0x01 @@ -36,8 +36,6 @@ void contr_key_reset(void); void contr_switch_band(void); void contr_set_band(uint8_t band); - - void contr_vcc_measure(void); float contr_vcc_calc(void); @@ -89,27 +87,8 @@ void contr_init(void) { void contr_setup(void) { contr_read_band(); - contr_txrelay_init(); - contr_txrelay_off(); - contr_att_init(); - contr_att_off(); - contr_relay10m_init(); - contr_relay20m_init(); - contr_relay40m_init(); - contr_relay80m_init(); - - contr_relay10m_off(); - contr_relay20m_off(); - contr_relay40m_off(); - contr_relay80m_off(); - - contr_buzzer_init(); - contr_buzzer_off(); - - contr_fan_init(); - contr_fan_off(); contr_key_init(); contr_adc_init(); @@ -118,29 +97,29 @@ void contr_setup(void) { void contr_switch_band(void) { - contr_txrelay_off(); + relaytx_off(); _delay_ms(100); - contr_relay80m_off(); - contr_relay40m_off(); - contr_relay20m_off(); - contr_relay10m_off(); + relay80m_off(); + relay40m_off(); + relay20m_off(); + relay10m_off(); _delay_ms(100); switch (contr.band) { case CONTR_BAND_10M: - contr_relay20m_on(); + relay20m_on(); contr.band = CONTR_BAND_20M; break; case CONTR_BAND_20M: - contr_relay40m_on(); + relay40m_on(); contr.band = CONTR_BAND_40M; break; case CONTR_BAND_40M: - contr_relay80m_on(); + relay80m_on(); contr.band = CONTR_BAND_80M; break; case CONTR_BAND_80M: - contr_relay10m_on(); + relay10m_on(); contr.band = CONTR_BAND_10M; break; default: @@ -148,7 +127,7 @@ void contr_switch_band(void) { } contr_write_band(); _delay_ms(100); - contr_att_on(); + atten_on(); _delay_ms(100); } @@ -187,11 +166,11 @@ void contr_key_eval(void) { break; case CONTR_KEY_BUZZER: contr_key_reset(); - contr_buzzer_onoff(); + buzzer_onoff(); break; case CONTR_KEY_FUN: contr_key_reset(); - contr_fan_onoff(); + fan_onoff(); break; default: contr_key_reset(); diff --git a/contr_relay.h b/contr_relay.h deleted file mode 100644 index 0ff2e32..0000000 --- a/contr_relay.h +++ /dev/null @@ -1,41 +0,0 @@ - -#ifndef CONTR_RELAY_H_QWERTY -#define CONTR_RELAY_H_QWERTY - -void contr_txrelay_init(void); -void contr_txrelay_on(void); -void contr_txrelay_off(void); -void contr_txrelay_onoff(void); - -void contr_relay10m_init(void); -void contr_relay10m_on(void); -void contr_relay10m_off(void); - -void contr_relay20m_init(void); -void contr_relay20m_on(void); -void contr_relay20m_off(void); - -void contr_relay40m_init(void); -void contr_relay40m_on(void); -void contr_relay40m_off(void); - -void contr_relay80m_init(void); -void contr_relay80m_on(void); -void contr_relay80m_off(void); - -void contr_buzzer_init(void); -void contr_buzzer_on(void); -void contr_buzzer_off(void); -void contr_buzzer_onoff(void); - -void contr_fan_init(void); -void contr_fan_on(void); -void contr_fan_off(void); -void contr_fan_onoff(void); -bool contr_fan_is_on(void); - -void contr_att_init(void); -void contr_att_on(void); -void contr_att_off(void); - -#endif diff --git a/main.c b/main.c index 8356261..26ddc9d 100644 --- a/main.c +++ b/main.c @@ -14,6 +14,7 @@ #include #include #include +#include #include @@ -22,6 +23,25 @@ int main(void) { i2c_init(); uartio_init(); disp_init(); + + atten_init(); + relaytx_init(); + relay10m_init(); + relay20m_init(); + relay40m_init(); + relay80m_init(); + buzzer_init(); + fan_init(); + + relaytx_off(); + atten_off(); + relay10m_off(); + relay20m_off(); + relay40m_off(); + relay80m_off(); + buzzer_off(); + fan_off(); + contr_init(); contr_setup(); sei(); diff --git a/contr_relay.c b/relay.c similarity index 61% rename from contr_relay.c rename to relay.c index f007208..21037d9 100644 --- a/contr_relay.c +++ b/relay.c @@ -16,102 +16,102 @@ //#include /* D4 PD4: Set input relay 5 output */ -void contr_txrelay_init(void) { +void relaytx_init(void) { REG_SETUP_BIT(DDRD, PD4); } -void contr_txrelay_on(void) { +void relaytx_on(void) { REG_SETUP_BIT(PORTD, PD4); } -void contr_txrelay_off(void) { +void relaytx_off(void) { REG_SETDOWN_BIT(PORTD, PD4); } -void contr_txrelay_onoff(void) { +void relaytx_onoff(void) { if (REG_BIT_VALUE(PIND, PD4)) { - contr_txrelay_off(); + relaytx_off(); } else { - contr_txrelay_on(); + relaytx_on(); } } /* D6 PD6: Set 10M relay 1 output */ -void contr_relay10m_init(void) { +void relay10m_init(void) { REG_SETUP_BIT(DDRD, PD6); } -void contr_relay10m_on(void) { +void relay10m_on(void) { REG_SETUP_BIT(PORTD, PD6); } -void contr_relay10m_off(void) { +void relay10m_off(void) { REG_SETDOWN_BIT(PORTD, PD6); } /* D7 PD7: Set 20M relay 2 output */ -void contr_relay20m_init(void) { +void relay20m_init(void) { REG_SETUP_BIT(DDRD, PD7); } -void contr_relay20m_on(void) { +void relay20m_on(void) { REG_SETUP_BIT(PORTD, PD7); } -void contr_relay20m_off(void) { +void relay20m_off(void) { REG_SETDOWN_BIT(PORTD, PD7); } /* D8 PB0: Set 40M relay 3 output */ -void contr_relay40m_init(void) { +void relay40m_init(void) { REG_SETUP_BIT(DDRB, PB0); } -void contr_relay40m_on(void) { +void relay40m_on(void) { REG_SETUP_BIT(PORTB, PB0); } -void contr_relay40m_off(void) { +void relay40m_off(void) { REG_SETDOWN_BIT(PORTB, PB0); } /* D9 PB1: Set 80M relay 4 output */ -void contr_relay80m_init(void) { +void relay80m_init(void) { REG_SETUP_BIT(DDRB, PB1); } -void contr_relay80m_on(void) { +void relay80m_on(void) { REG_SETUP_BIT(PORTB, PB1); } -void contr_relay80m_off(void) { +void relay80m_off(void) { REG_SETDOWN_BIT(PORTB, PB1); } /* D10 PB2: Set buzzer output */ -void contr_buzzer_init(void) { +void buzzer_init(void) { REG_SETUP_BIT(DDRB, PB2); } -void contr_buzzer_on(void) { +void buzzer_on(void) { REG_SETUP_BIT(PORTB, PB2); } -void contr_buzzer_off(void) { +void buzzer_off(void) { REG_SETDOWN_BIT(PORTB, PB2); } -void contr_buzzer_onoff(void) { +void buzzer_onoff(void) { if (REG_BIT_VALUE(PINB, PB2)) { - contr_buzzer_off(); + buzzer_off(); } else { - contr_buzzer_on(); + buzzer_on(); } } /* D12 PB4: Set fan output */ -void contr_fan_init(void) { +void fan_init(void) { REG_SETUP_BIT(DDRB, PB4); } -void contr_fan_on(void) { +void fan_on(void) { REG_SETUP_BIT(PORTB, PB4); } -void contr_fan_off(void) { +void fan_off(void) { REG_SETDOWN_BIT(PORTB, PB4); } -void contr_fan_onoff(void) { +void fan_onoff(void) { if (REG_BIT_VALUE(PINB, PB4)) { - contr_fan_off(); + fan_off(); } else { - contr_fan_on(); + fan_on(); } } -bool contr_fan_is_on(void) { +bool fan_is_on(void) { if (REG_BIT_VALUE(PINB, PB4)) { return true; } @@ -119,13 +119,13 @@ bool contr_fan_is_on(void) { } /* D13 PB5: Set attenuator relay output */ -void contr_att_init(void) { +void atten_init(void) { REG_SETUP_BIT(DDRB, PB5); } -void contr_att_on(void) { +void atten_on(void) { REG_SETUP_BIT(PORTB, PB5); } -void contr_att_off(void) { +void atten_off(void) { REG_SETDOWN_BIT(PORTB, PB5); } diff --git a/relay.h b/relay.h new file mode 100644 index 0000000..e5666e0 --- /dev/null +++ b/relay.h @@ -0,0 +1,41 @@ + +#ifndef CONTR_RELAY_H_QWERTY +#define CONTR_RELAY_H_QWERTY + +void relaytx_init(void); +void relaytx_on(void); +void relaytx_off(void); +void relaytx_onoff(void); + +void relay10m_init(void); +void relay10m_on(void); +void relay10m_off(void); + +void relay20m_init(void); +void relay20m_on(void); +void relay20m_off(void); + +void relay40m_init(void); +void relay40m_on(void); +void relay40m_off(void); + +void relay80m_init(void); +void relay80m_on(void); +void relay80m_off(void); + +void buzzer_init(void); +void buzzer_on(void); +void buzzer_off(void); +void buzzer_onoff(void); + +void fan_init(void); +void fan_on(void); +void fan_off(void); +void fan_onoff(void); +bool fan_is_on(void); + +void atten_init(void); +void atten_on(void); +void atten_off(void); + +#endif