Files
pa50contr/contr_relay.c
Олег Бородин 8b5617655e update
2024-08-21 08:17:55 +02:00

132 lines
2.6 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>
//#include <uart.h>
//#include <i2c.h>
//#include <disp.h>
//#include <timer.h>
/* D4 PD4: Set input relay 5 output */
void contr_txrelay_init(void) {
REG_SETUP_BIT(DDRD, PD4);
}
void contr_txrelay_on(void) {
REG_SETUP_BIT(PORTD, PD4);
}
void contr_txrelay_off(void) {
REG_SETDOWN_BIT(PORTD, PD4);
}
void contr_txrelay_onoff(void) {
if (REG_BIT_VALUE(PIND, PD4)) {
contr_txrelay_off();
} else {
contr_txrelay_on();
}
}
/* D6 PD6: Set 10M relay 1 output */
void contr_relay10m_init(void) {
REG_SETUP_BIT(DDRD, PD6);
}
void contr_relay10m_on(void) {
REG_SETUP_BIT(PORTD, PD6);
}
void contr_relay10m_off(void) {
REG_SETDOWN_BIT(PORTD, PD6);
}
/* D7 PD7: Set 20M relay 2 output */
void contr_relay20m_init(void) {
REG_SETUP_BIT(DDRD, PD7);
}
void contr_relay20m_on(void) {
REG_SETUP_BIT(PORTD, PD7);
}
void contr_relay20m_off(void) {
REG_SETDOWN_BIT(PORTD, PD7);
}
/* D8 PB0: Set 40M relay 3 output */
void contr_relay40m_init(void) {
REG_SETUP_BIT(DDRB, PB0);
}
void contr_relay40m_on(void) {
REG_SETUP_BIT(PORTB, PB0);
}
void contr_relay40m_off(void) {
REG_SETDOWN_BIT(PORTB, PB0);
}
/* D9 PB1: Set 80M relay 4 output */
void contr_relay80m_init(void) {
REG_SETUP_BIT(DDRB, PB1);
}
void contr_relay80m_on(void) {
REG_SETUP_BIT(PORTB, PB1);
}
void contr_relay80m_off(void) {
REG_SETDOWN_BIT(PORTB, PB1);
}
/* D10 PB2: Set buzzer output */
void contr_buzzer_init(void) {
REG_SETUP_BIT(DDRB, PB2);
}
void contr_buzzer_on(void) {
REG_SETUP_BIT(PORTB, PB2);
}
void contr_buzzer_off(void) {
REG_SETDOWN_BIT(PORTB, PB2);
}
void contr_buzzer_onoff(void) {
if (REG_BIT_VALUE(PINB, PB2)) {
contr_buzzer_off();
} else {
contr_buzzer_on();
}
}
/* D12 PB4: Set fan output */
void contr_fan_init(void) {
REG_SETUP_BIT(DDRB, PB4);
}
void contr_fan_on(void) {
REG_SETUP_BIT(PORTB, PB4);
}
void contr_fan_off(void) {
REG_SETDOWN_BIT(PORTB, PB4);
}
void contr_fan_onoff(void) {
if (REG_BIT_VALUE(PINB, PB4)) {
contr_fan_off();
} else {
contr_fan_on();
}
}
bool contr_fan_is_on(void) {
if (REG_BIT_VALUE(PINB, PB4)) {
return true;
}
return false;
}
/* D13 PB5: Set attenuator relay output */
void contr_att_init(void) {
REG_SETUP_BIT(DDRB, PB5);
}
void contr_att_on(void) {
REG_SETUP_BIT(PORTB, PB5);
}
void contr_att_off(void) {
REG_SETDOWN_BIT(PORTB, PB5);
}