alix-usv/alix-usv.h

33 lines
875 B
C

#ifndef _MAIN_H_
#define _MAIN_H_
#include <avr/io.h>
#define F_CPU 8000000
#include <util/delay.h>
#define EN_POWER (1<<PORTB0)
#define EN_CHARGER (1<<PORTB1)
#define EN_TEST (1<<PORTB2)
#define AIN_REF (1<<PINA0)
#define AIN_CURRENT_N (1<<PINA1)
#define AIN_CURRENT_P (1<<PINA2)
#define AIN_VOLTAGE_BAT (1<<PINA3)
#define I2C_SCL (1<<PORTA4)
#define LED_GN (1<<PORTA5)
#define I2C_SDA (1<<PORTA6)
#define AIN_VOLTAGE_SUP (1<<PINA7)
#define I2C_ADDRESS (0x10 << 1)
#define CH_CURRENT_P ((1<<REFS0) | 0x0d) /* current A1->A2, 20x gain */
#define CH_CURRENT_N ((1<<REFS0) | 0x2d) /* current A2->A1, 20x gain */
#define CH_VOLTAGE_BAT ((1<<REFS0) | 0x03) /* voltage A3->gnd, 1x gain */
#define CH_VOLTAGE_SUP ((1<<REFS0) | 0x07) /* voltage A7->gnd, 1x gain */
void usi_write(uint8_t data, uint8_t bcnt);
uint8_t usi_read(uint8_t bcnt);
#endif // _USI_I2C_SLAVE_H_