Electronic Load 1.0 Programmable Constant Current Sink

led.h
Go to the documentation of this file.
1
51 #ifndef LED_H_
52 #define LED_H_
53
54 #include "Eload.h"
55 #include "spi.h"
56
57 #define LED_USE_TIMER
58 static const uint8_t LED_TIMER_SLOWDOWN=20;
59
60 #define LEDREDPORT PORTC
61 #define LEDREDMASK 0b00000001
62
68 typedef uint8_t LED_FLASH_t;
69
74 static const LED_FLASH_t LED_BLINK_ON = 0b11111111;
75 static const LED_FLASH_t LED_BLINK_OFF = 0b00000000;
76 static const LED_FLASH_t LED_BLINK_SLOW = 0b00001111;
77 static const LED_FLASH_t LED_BLINK_NORMAL = 0b00110011;
78 static const LED_FLASH_t LED_BLINK_FAST = 0b01010101;
79 static const LED_FLASH_t LED_BLINK_BEACON = 0b00000001;
80
81 typedef union
82 {
83 struct
84 {
85 LED_FLASH_t powerGreen;
86 LED_FLASH_t powerRed;
87 LED_FLASH_t rangeGreen;
88 LED_FLASH_t rangeBlue;
89 LED_FLASH_t overTemp;
90 LED_FLASH_t SOA;
91 LED_FLASH_t fuse;
92 LED_FLASH_t spare;
93 } named;
94 LED_FLASH_t array[8];
95 } LED_DATA_t;
96 extern LED_DATA_t ledData;
97
99 static inline void LEDRedOn(void)
100 {
101 LEDREDPORT &= ~LEDREDMASK;
102 }
103
105 static inline void LEDRedOff(void)
106 {
107 LEDREDPORT |= LEDREDMASK;
108 }
109
111 static inline void SetSOAError(void)
112 {
113 ledData.named.SOA=LED_BLINK_SLOW;
114 eflags|=EFLAG_SOA;
115 }
116
118 static inline void ClearSOAError(void)
119 {
120 ledData.named.SOA=LED_BLINK_OFF;
121 eflags&= ~EFLAG_SOA;
122 }
123
125 static inline void SetOvertempError(void)
126 {
127 ledData.named.overTemp=LED_BLINK_FAST;
128 eflags|=EFLAG_TEMP;
129 }
130
132 static inline void ClearOvertempError(void)
133 {
134 ledData.named.overTemp=LED_BLINK_OFF;
135 eflags&= ~EFLAG_TEMP;
136 }
137
138 extern LED_FLASH_t ledRedData;
139 void LedTimerCallback(void);
140
141
142 #endif /* LED_H_ */
Eload.h
eflags
volatile uint8_t eflags
Error Flags.
Definition: Eload.c:64
LED_DATA_t::named
struct LED_DATA_t::@1 named
LED_BLINK_SLOW
static const LED_FLASH_t LED_BLINK_SLOW
slow blinking, period=1.6s
Definition: led.h:76
EFLAG_TEMP
static const uint8_t EFLAG_TEMP
Heat Sink Overtemp.
Definition: Eload.h:60
LEDRedOff
static void LEDRedOff(void)
Switches the red LED off.
Definition: led.h:105
LED_BLINK_NORMAL
static const LED_FLASH_t LED_BLINK_NORMAL
normal speed blinking, period=0.8s
Definition: led.h:77
ClearOvertempError
static void ClearOvertempError(void)
Clears the Overtemp Error Flag and the LED.
Definition: led.h:132
LED_DATA_t
Definition: led.h:81
LEDREDMASK
#define LEDREDMASK
Definition: led.h:61
LED_DATA_t::overTemp
LED_FLASH_t overTemp
Definition: led.h:89
LED_DATA_t::fuse
LED_FLASH_t fuse
Definition: led.h:91
spi.h
LEDREDPORT
#define LEDREDPORT
Definition: led.h:60
EFLAG_SOA
static const uint8_t EFLAG_SOA
Indicates Limits caused by the SOA of the Transistor. Should be somehow displayed!
Definition: Eload.h:59
ClearSOAError
static void ClearSOAError(void)
Clears the SOA Error Flag and the LED.
Definition: led.h:118
LED_BLINK_ON
static const LED_FLASH_t LED_BLINK_ON
always on
Definition: led.h:74
SetSOAError
static void SetSOAError(void)
Sets the SOA Error Flag and the LED.
Definition: led.h:111
LED_DATA_t::powerRed
LED_FLASH_t powerRed
Definition: led.h:86
LEDRedOn
static void LEDRedOn(void)
Switches the red LED on.
Definition: led.h:99
LedTimerCallback
void LedTimerCallback(void)
Timer Callback Function.
Definition: led.c:29
LED_BLINK_OFF
static const LED_FLASH_t LED_BLINK_OFF
always off
Definition: led.h:75
SetOvertempError
static void SetOvertempError(void)
Sets the Overtemp Error Flag and the LED.
Definition: led.h:125
LED_DATA_t::spare
LED_FLASH_t spare
Definition: led.h:92
LED_FLASH_t
uint8_t LED_FLASH_t
Typedef for LED flashing.
Definition: led.h:68
LED_BLINK_FAST
static const LED_FLASH_t LED_BLINK_FAST
fast blinking, period=0.4s
Definition: led.h:78
LED_BLINK_BEACON
static const LED_FLASH_t LED_BLINK_BEACON
short pulse, 200ms on, 1.4s off
Definition: led.h:79
LED_DATA_t::rangeBlue
LED_FLASH_t rangeBlue
Definition: led.h:88
ledData
LED_DATA_t ledData
This is the pattern the eight leds should blink. Every '1'-bit means the LED is on....
Definition: Eload.c:71
LED_DATA_t::powerGreen
LED_FLASH_t powerGreen
Definition: led.h:85
LED_DATA_t::rangeGreen
LED_FLASH_t rangeGreen
Definition: led.h:87
ledRedData
LED_FLASH_t ledRedData
This is the pattern the debug led should blink.
Definition: Eload.c:70
LED_DATA_t::SOA
LED_FLASH_t SOA
Definition: led.h:90