A small USV for ALIX boards with i2c support
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

alix-usv.h 875B

1234567891011121314151617181920212223242526272829303132
  1. #ifndef _MAIN_H_
  2. #define _MAIN_H_
  3. #include <avr/io.h>
  4. #define F_CPU 8000000
  5. #include <util/delay.h>
  6. #define EN_POWER (1<<PORTB0)
  7. #define EN_CHARGER (1<<PORTB1)
  8. #define EN_TEST (1<<PORTB2)
  9. #define AIN_REF (1<<PINA0)
  10. #define AIN_CURRENT_N (1<<PINA1)
  11. #define AIN_CURRENT_P (1<<PINA2)
  12. #define AIN_VOLTAGE_BAT (1<<PINA3)
  13. #define I2C_SCL (1<<PORTA4)
  14. #define LED_GN (1<<PORTA5)
  15. #define I2C_SDA (1<<PORTA6)
  16. #define AIN_VOLTAGE_SUP (1<<PINA7)
  17. #define I2C_ADDRESS (0x10 << 1)
  18. #define CH_CURRENT_P ((1<<REFS0) | 0x0d) /* current A1->A2, 20x gain */
  19. #define CH_CURRENT_N ((1<<REFS0) | 0x2d) /* current A2->A1, 20x gain */
  20. #define CH_VOLTAGE_BAT ((1<<REFS0) | 0x03) /* voltage A3->gnd, 1x gain */
  21. #define CH_VOLTAGE_SUP ((1<<REFS0) | 0x07) /* voltage A7->gnd, 1x gain */
  22. void usi_write(uint8_t data, uint8_t bcnt);
  23. uint8_t usi_read(uint8_t bcnt);
  24. #endif // _USI_I2C_SLAVE_H_