Revision f4df665c

View differences:

toolbox/current.c
15 15

  
16 16
void current_init() {
17 17

  
18
  /*
19
   * COM0A = 0, disconnect pin
20
   * WGM0 = 2, clear timer on compare
21
   */
22
  TCCR0A |= _BV(WGM01);
18
  /* TODO reduce power consumption with DIDR* */
23 19

  
24 20
  /*
25
   * CS0 = 5, 1024 prescaler
21
   * COM1A = COM1B = 0, disconnect pins
22
   * WGM1 = 4, clear timer on compare A
23
   * CS1 = 5, 1024 prescaler
26 24
   */
27
  TCCR0B |= _BV(CS02) | _BV(CS00);
25
  TCCR1B |= _BV(WGM12) | _BV(CS12) | _BV(CS10);
28 26

  
29
  OCR0A = F_CPU / 1024 / SAMPLES_PER_CYCLE / CYCLES_PER_SECOND;
27
  /* Timer is cleared on A, ADC is triggered on B */
28
  OCR1A = F_CPU / 1024 / SAMPLES_PER_CYCLE / CYCLES_PER_SECOND;
29
  OCR1B = 0;
30 30

  
31 31
  /*
32 32
   * REFS = 0, Vcc reference (set to 2 for internal 1.1V reference)
......
34 34
   */
35 35
  ADMUX = _BV(MUX3);
36 36

  
37
  /* TODO reduce power consumption with DIDR* */
38

  
39 37
  /*
40 38
   * ADLAR = 0, right adjust result
41
   * ADTS = 3, start on timer 0 compare match A
39
   * ADTS = 5, start on timer 1 compare match B
42 40
   */
43
  ADCSRB = _BV(ADTS1) | _BV(ADTS0);
41
  ADCSRB = _BV(ADTS2) | _BV(ADTS0);
44 42

  
45 43
  /*
46 44
   * ADEN = 1, enable
toolbox/main.c
29 29
static uint8_t latest_reading[RFID_SERNO_SIZE];
30 30
static uint8_t current_user[RFID_SERNO_SIZE];
31 31
static uint16_t current;
32
static uint16_t current_max_warn, current_max_hard;
32
//static uint16_t current_max_warn, current_max_hard;
33 33

  
34 34
static inline void set_coil(char coil, char bit) {
35 35
  coils = (coils & ~(1 << coil)) | (bit << coil);

Also available in: Unified diff