Solved! Go to Solution.
typedef enum { LED0 = 0x01, /* bit masks for the port */ LED1 = 0x02, LED2 = 0x04, ... } LedType; static const unsigned char LED_MASK[N] = { LED0, LED1, LED2, ... }; static volatile unsigned char* leds[N] = { &PTAD, &PTCD, ... }; void set_led (unsigned int n, BOOL active) { if(active) { *leds[n] |= LED_MASK[n]; } else { *leds[n] &= (unsigned char) ~LED_MASK[n]; } }
typedef enum { LED0 = 0x01, /* bit masks for the port */ LED1 = 0x02, LED2 = 0x04, ... } LedType; static const unsigned char LED_MASK[N] = { LED0, LED1, LED2, ... }; static volatile unsigned char* leds[N] = { &PTAD, &PTCD, ... }; void set_led (unsigned int n, BOOL active) { if(active) { *leds[n] |= LED_MASK[n]; } else { *leds[n] &= (unsigned char) ~LED_MASK[n]; } }