Rev 1612 | Rev 1796 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1612 | Rev 1775 | ||
---|---|---|---|
Line 52... | Line 52... | ||
52 | #include "output.h" |
52 | #include "output.h" |
53 | #include "eeprom.h" |
53 | #include "eeprom.h" |
Line 54... | Line 54... | ||
54 | 54 | ||
55 | // To access the DebugOut struct. |
55 | // To access the DebugOut struct. |
56 | #include "uart0.h" |
- | |
57 | - | ||
58 | uint8_t J16Blinkcount = 0, J16Mask = 1; |
56 | #include "uart0.h" |
59 | uint8_t J17Blinkcount = 0, J17Mask = 1; |
- | |
60 | 57 | uint8_t flashCnt[2], flashMask[2]; |
|
61 | // initializes the LED control outputs J16, J17 |
58 | // initializes the LED control outputs J16, J17 |
62 | void output_init(void) { |
59 | void output_init(void) { |
63 | // set PC2 & PC3 as output (control of J16 & J17) |
60 | // set PC2 & PC3 as output (control of J16 & J17) |
64 | DDRC |= (1<<DDC2)|(1<<DDC3); |
61 | DDRC |= (1<<DDC2)|(1<<DDC3); |
65 | J16_OFF; |
62 | OUTPUT_OFF(0); OUTPUT_OFF(1); |
66 | J17_OFF; |
63 | flashCnt[0] = flashCnt[1] = 0; |
- | 64 | flashMask[0] = flashMask[1] = 128; |
|
- | 65 | } |
|
- | 66 | ||
- | 67 | void flashingLight(uint8_t port, uint8_t timing, uint8_t bitmask, uint8_t manual) { |
|
- | 68 | if (timing > 250 && manual > 230) { |
|
67 | J16Blinkcount = 0; J16Mask = 128; |
69 | // "timing" is set to "manual" and the value is very high --> Set to the value in bitmask bit 7. |
- | 70 | OUTPUT_SET(port, bitmask & 128); |
|
- | 71 | } else if (timing > 250 && manual < 10) { |
|
- | 72 | // "timing" is set to "manual" and the value is very low --> Set to the negated value in bitmask bit 7. |
|
- | 73 | OUTPUT_SET(port, !(bitmask & 128)); |
|
- | 74 | } else if(!flashCnt[port]--) { |
|
- | 75 | // rotating mask over bitmask... |
|
- | 76 | flashCnt[port] = timing - 1; |
|
- | 77 | if(flashMask[port] == 1) flashMask[port] = 128; else flashMask[port] >>= 1; |
|
- | 78 | OUTPUT_SET(port, flashMask[port] & bitmask); |
|
68 | J17Blinkcount = 0; J17Mask = 128; |
79 | } |
Line 69... | Line 80... | ||
69 | } |
80 | } |
70 | 81 | ||
71 | void flashingLights(void) { |
82 | void flashingLights(void) { |
72 | static int8_t delay = 0; |
83 | static int8_t delay = 0; |
73 | if(!delay--) { // 10 ms intervall |
- | |
74 | delay = 4; |
- | |
75 | - | ||
76 | if ((staticParams.J16Timing > 250) && (dynamicParams.J16Timing > 230)) { |
- | |
77 | if(staticParams.J16Bitmask & 128) J16_ON; |
84 | if(!delay--) { // 10 ms intervals |
78 | else J16_OFF; |
- | |
79 | } else if ((staticParams.J16Timing > 250) && (dynamicParams.J16Timing < 10)) { |
- | |
80 | if(staticParams.J16Bitmask & 128) J16_OFF; |
- | |
81 | else J16_ON; |
- | |
82 | } else if(!J16Blinkcount--) { |
- | |
83 | J16Blinkcount = dynamicParams.J16Timing - 1; |
- | |
84 | if(J16Mask == 1) J16Mask = 128; else J16Mask = J16Mask >> 1; |
- | |
85 | if(J16Mask & staticParams.J16Bitmask) J16_ON; else J16_OFF; |
- | |
86 | } |
- | |
87 | - | ||
88 | if ((staticParams.J17Timing > 250) && (dynamicParams.J17Timing > 230)) { |
- | |
89 | if(staticParams.J17Bitmask & 128) J17_ON; |
85 | delay = 4; |
90 | else J17_OFF; |
- | |
91 | } else if ((staticParams.J17Timing > 250) && (dynamicParams.J17Timing < 10)) { |
- | |
92 | if(staticParams.J17Bitmask & 128) J17_OFF; |
- | |
93 | else J17_ON; |
- | |
94 | } else if(!J17Blinkcount--) { |
- | |
95 | J17Blinkcount = dynamicParams.J17Timing - 1; |
- | |
96 | if(J17Mask == 1) J17Mask = 128; else J17Mask = J17Mask >> 1; |
- | |
97 | if(J17Mask & staticParams.J17Bitmask) J17_ON; else J17_OFF; |
86 | flashingLight(0, staticParams.J16Timing, staticParams.J16Bitmask, dynamicParams.J16Timing); |
98 | } |
87 | flashingLight(1, staticParams.J17Timing, staticParams.J17Bitmask, dynamicParams.J17Timing); |
Line -... | Line 88... | ||
- | 88 | } |
|
- | 89 | } |
|
- | 90 | ||
- | 91 | #define DIGITAL_DEBUG_MASK 0 |
|
- | 92 | ||
99 | } |
93 | // invert means: An "1" bit in digital debug data will feed NO base current to output transistor. |
- | 94 | #define DIGITAL_DEBUG_INVERT 0 |
|
- | 95 | ||
100 | } |
96 | void output_update(void) { |
- | 97 | uint8_t output0, output1; |
|
- | 98 | if (!DIGITAL_DEBUG_MASK) |
|
- | 99 | flashingLights(); |
|
- | 100 | else { |
|
- | 101 | if (DIGITAL_DEBUG_MASK == DEBUG_LEDTEST) { |
|
101 | 102 | // Show the state for a SET bit. If inverse, then invert. |
|
102 | void output_update(void) { |
103 | output0 = output1 = ~DIGITAL_DEBUG_INVERT; |
- | 104 | } else if (DIGITAL_DEBUG_INVERT) { |
|
- | 105 | output0 = (~DebugOut.Digital[0]) & DIGITAL_DEBUG_MASK; |
|
- | 106 | output1 = (~DebugOut.Digital[1]) & DIGITAL_DEBUG_MASK; |
|
- | 107 | } else { |
|
- | 108 | output0 = DebugOut.Digital[0] & DIGITAL_DEBUG_MASK; |
|
- | 109 | output1 = DebugOut.Digital[1] & DIGITAL_DEBUG_MASK; |
|
- | 110 | } |
|
103 | // flashingLights(); |
111 | OUTPUT_SET(0, output0); |