bikegenerator/schaltungen/powerboard_v3/software/src/main.h

50 lines
1.3 KiB
C

#ifndef _main_h
#define _main_h
#define AD_V_GEN 0
#define AD_I_GEN 1
#define AD_V_REG 2
#define LOADSW PB0
#define BATSW PB1
#define GENSW PB2
#define PORT_SW PORTB
#define DDR_SW DDRB
#define PIN_SW PINB
#define TP1 PD7 // used for operating mode switching
#define TP2 PD6
#define TP3 PD5
#define PORT_TP PORTD
#define DDR_TP DDRD
#define PIN_TP PIND
#define LOAD_ON PORT_SW |= _BV(LOADSW)
#define LOAD_OFF PORT_SW &= ~_BV(LOADSW)
#define GEN_ON PORT_SW |= _BV(GENSW)
#define GEN_OFF PORT_SW &= ~_BV(GENSW)
#define BAT_ON PORT_SW |= _BV(BATSW)
#define BAT_OFF PORT_SW &= ~_BV(BATSW)
#define IS_LOAD_ON (PIN_SW & _BV(LOADSW)) >> LOADSW
#define IS_GEN_ON (PIN_SW & _BV(GENSW)) >> GENSW
#define IS_BAT_ON (PIN_SW & _BV(BATSW)) >> BATSW
#define GENERATOR 13000
#define GENERATOR_TIMEOUT 3
#define GENERATOR_OFF_TIMEOUT 1
#define UNDERVOLTAGE 11200
#define OVERVOLTAGE 15000
#define OVERVOLTAGE_TIMEOUT 5
#define OVERVOLTAGEOFF_TIMEOUT 3
#define UNDERVOLTAGE_TIMEOUT 5
#define UNDERVOLTAGEOFF_TIMEOUT 3
#define CURRENT_OFFSET 511
#define CURRENT_PER_TICK 72
#define VOLTAGE_PER_TICK 15
#endif