~toykeeper/flashlight-firmware/trunk

« back to all changes in this revision

Viewing changes to ToyKeeper/hwdef-Emisar_D4v2.h

  • Committer: Selene Scriven
  • Date: 2020-07-06 20:24:28 UTC
  • mfrom: (188.1.294 fsm)
  • Revision ID: bzr@toykeeper.net-20200706202428-7pyen2ow9q2rtd9p
merged nearly a year of updates from the fsm branch, including the new product map

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
 *   3    PA4   green aux LED
10
10
 *   4    PA3   blue aux LED
11
11
 *   5    PA2   e-switch
12
 
 *   6    PA1   (none)
 
12
 *   6    PA1   button LED
13
13
 *   7    PA0   (none)
14
14
 *   8    GND   GND
15
15
 *   9    VCC   VCC
48
48
#define PWM2_LVL OCR1B      // OCR1B is the output compare register for PB1
49
49
 
50
50
 
51
 
#define ADC_PRSCL   0x06    // clk/64
 
51
#define ADC_PRSCL   0x07    // clk/128
52
52
 
53
53
// average drop across diode on this hardware
54
54
#ifndef VOLTAGE_FUDGE_FACTOR
55
55
#define VOLTAGE_FUDGE_FACTOR 4  // add 0.20V  (measured 0.22V)
56
56
#endif
57
57
 
58
 
#define TEMP_CHANNEL 0b00001111
59
 
 
60
58
// this light has aux LEDs under the optic
61
59
#define AUXLED_R_PIN   PA5    // pin 2
62
60
#define AUXLED_G_PIN   PA4    // pin 3
65
63
#define AUXLED_RGB_DDR DDRA   // DDRA or DDRB or DDRC
66
64
#define AUXLED_RGB_PUE PUEA   // PUEA or PUEB or PUEC
67
65
 
 
66
#define BUTTON_LED_PIN  PA1    // pin 6
 
67
#define BUTTON_LED_PORT PORTA  // for all "PA" pins
 
68
#define BUTTON_LED_DDR  DDRA   // for all "PA" pins
 
69
#define BUTTON_LED_PUE  PUEA   // for all "PA" pins
 
70
 
68
71
// with so many pins, doing this all with #ifdefs gets awkward...
69
72
// ... so just hardcode it in each hwdef file instead
70
73
inline void hwdef_setup() {
71
74
  // enable output ports
72
75
  // 7135
73
76
  DDRB = (1 << PWM1_PIN);
74
 
  // FET, aux R/G/B
 
77
  // FET, aux R/G/B, button LED
75
78
  DDRA = (1 << PWM2_PIN)
76
79
       | (1 << AUXLED_R_PIN)
77
80
       | (1 << AUXLED_G_PIN)
78
81
       | (1 << AUXLED_B_PIN)
 
82
       | (1 << BUTTON_LED_PIN)
79
83
       ;
80
84
 
81
85
  // configure PWM