/**************************************************************************** Function: LED_Init Parameters banks: an unsigned char with a 1 in each position to set the bank as an LED bank, should be a bitwise OR of the #define'd LED_BANKx values. Returns char: SUCCESS or ERROR Description Initializes the LED subsystem, sets each pin in the bank as a digital output and turns the LED on. Notes: J3 SPI Jumpers should be set in MASTER position. Author: Gabriel Hugh Elkaim, 2011.12.25 01:16 ****************************************************************************/ char LED_Init(unsigned char banks) { char i; #ifdef DEBUG_VERBOSE printf("\nInitializing LED subsystem"); printf("\nNote that SPI jumpers should be set into MASTER position"); printf("\nand that the LED jumpers should be installed."); #endif if ((ledStatus.led_on) || (banks == 0) || (banks > 0x07)) { #ifdef DEBUG_VERBOSE printf("\nError: LED subsystem initialization failed"); #endif return ERROR; } ledStatus.led_on = TRUE; if (banks & LED_BANK1) { #ifdef DEBUG_VERBOSE printf("\nLED Bank1 enabled"); #endif ledStatus.one_on = TRUE; for (i = 0; i < NUMLEDSPERBANK; i++) { LED_SetPinOutput(i); LED_On(i); } } #ifdef DEBUG_VERBOSE printf("\nLED Subsystem Enabled"); #endif return SUCCESS; }
/** * @Function LED_AddBanks(unsigned char AddBanks) * @param banks - an unsigned char with a 1 in each position to set the bank as an LED bank, should be a bitwise OR of the #define'd LED_BANKx values. * @return SUCCESS or ERROR * @brief adds selected banks to the system and sets them to be digital outputs * @note J3 SPI Jumpers should be set in MASTER position. * @author Gabriel Hugh Elkaim, 2011.12.25 01:16 */ char LED_AddBanks(unsigned char AddBanks) { char i; dbprintf("\nInitializing LED subsystem"); if (!LEDActive) { dbprintf("\nError: LED subsystem not initialized\r\n"); return ERROR; } if ((AddBanks == 0) || (AddBanks > ALL_LED_BANKS)) { dbprintf("%s returning ERROR with Banks outside range: %X\r\n", __FUNCTION__, AddBanks); return ERROR; } if (ActiveLEDBanks & AddBanks) { dbprintf("%s Returning ERROR for pins already in state: %X \r\n", __FUNCTION__, AddBanks); return ERROR; } ActiveLEDBanks |= AddBanks; if (AddBanks & LED_BANK1) { dbprintf("\nLED Bank1 enabled"); for (i = 0; i < NUMLEDSPERBANK; i++) { LED_SetPinOutput(i); LED_On(i); } } if (AddBanks & LED_BANK2) { dbprintf("\nLED Bank2 enabled"); for (i = 0; i < NUMLEDSPERBANK; i++) { LED_SetPinOutput(i + BANK2OFFSET); LED_On(i + BANK2OFFSET); } } if (AddBanks & LED_BANK3) { dbprintf("\nLED Bank3 enabled"); for (i = 0; i < NUMLEDSPERBANK; i++) { LED_SetPinOutput(i + BANK3OFFSET); LED_On(i + BANK3OFFSET); } } return SUCCESS; }
/**************************************************************************** Function: LED_Init Parameters banks: an unsigned char with a 1 in each position to set the bank as an LED bank, should be a bitwise OR of the #define'd LED_BANKx values. Returns char: SUCCESS or ERROR Description Initializes the LED subsystem, sets each pin in the bank as a digital output and turns the LED on. Notes: J3 SPI Jumpers should be set in MASTER position. Author: Gabriel Hugh Elkaim, 2011.12.25 01:16 ****************************************************************************/ char LED_Init(unsigned char banks) { char i; dbprintf("\nInitializing LED subsystem"); dbprintf("\nNote that SPI jumpers should be set into MASTER position"); dbprintf("\nand that the LED jumpers should be installed."); if ((ledStatus.led_on)||(banks == 0)||(banks > 0x07)) { dbprintf("\nError: LED subsystem initialization failed"); return ERROR; } ledStatus.led_on = TRUE; if (banks & LED_BANK1) { dbprintf("\nLED Bank1 enabled"); ledStatus.one_on = TRUE; for (i = 0; i < NUMLEDSPERBANK; i++) { LED_SetPinOutput(i); LED_On(i); } } if (banks & LED_BANK2) { dbprintf("\nLED Bank2 enabled"); ledStatus.two_on = TRUE; for (i = 0; i < NUMLEDSPERBANK; i++) { LED_SetPinOutput(i+BANK2OFFSET); LED_On(i+BANK2OFFSET); } } if (banks & LED_BANK3) { dbprintf("\nLED Bank3 enabled"); ledStatus.three_on = TRUE; for (i = 0; i < NUMLEDSPERBANK; i++) { LED_SetPinOutput(i+BANK3OFFSET); LED_On(i+BANK3OFFSET); } } dbprintf("\nLED Subsystem Enabled"); return SUCCESS; }