Also, make the LED polarity compile-time configurable.
[Note: This is a slightly modified version of a patch from Maciej Kurc.]
*/
if ((IBNIRQ & bmEP2IBN) && (gpif_acquiring == PREPARED)) {
ledcounter = 1;
- PA1 = 0;
+ LED_OFF();
gpif_acquisition_start();
}
/* Blink LED during acquisition, keep it on otherwise. */
if (gpif_acquiring == RUNNING) {
if (--ledcounter == 0) {
- PA1 = !PA1;
+ LED_TOGGLE();
ledcounter = 1000;
}
} else if (gpif_acquiring == STOPPED) {
- PA1 = 1; /* LED on. */
+ LED_ON();
}
TF2 = 0;
}
ENABLE_HISPEED();
ENABLE_USBRESET();
- /* PA1 (LED) is an output. */
- PORTACFG = 0;
- OEA = (1 << 1);
- PA1 = 1; /* LED on. */
+ LED_INIT();
+ LED_ON();
/* Init timer2. */
RCAP2L = -500 & 0xff;
#define FX2LAFW_VERSION_MAJOR 1
#define FX2LAFW_VERSION_MINOR 2
+#define LED_POLARITY 1 /* 1: active-high, 0: active-low */
+
+#define LED_INIT() do { PORTACFG = 0; OEA = (1 << 1); } while (0)
+#define LED_ON() do { PA1 = LED_POLARITY; } while (0)
+#define LED_OFF() do { PA1 = !LED_POLARITY; } while (0)
+#define LED_TOGGLE() do { PA1 = !PA1; } while (0)
+
#endif