Commit 28967205 authored by Bc. Petr Elexa's avatar Bc. Petr Elexa

panel: Add communication status LED

parent b8d9124d
......@@ -61,11 +61,12 @@ static void _timer_callback(TimerHandle_t pxTimer)
if (id == _act_timer_id)
{
// Reset active master if timeout
// Active master timeout after T = 2 * MASTER_ALIVE_TIMEOUT
portENTER_CRITICAL();
if (_master_timeout == true)
{
_act_master = ACS_RESERVED_ADDR;
Board_LED_Set(BOARD_LED_STATUS, false);
}
_master_timeout = true;
portEXIT_CRITICAL();
......@@ -147,7 +148,11 @@ void term_can_recv(uint8_t msg_obj_num)
{
// update master address if timeout occurred
portENTER_CRITICAL();
if (_master_timeout == true) _act_master = head.src;
if (_master_timeout == true)
{
_act_master = head.src;
Board_LED_Set(BOARD_LED_STATUS, true);
}
_master_timeout = false;
portEXIT_CRITICAL();
DEBUGSTR("master alive\n");
......
......@@ -64,8 +64,8 @@ extern const uint16_t ACC_PANEL_B_ADDR;
#define DOOR_1_ACC_PANEL_RLED_PIN 0
#define DOOR_1_RELAY_PORT 1
#define DOOR_1_RELAY_PIN 10
#define DOOR_1_SENSOR_PORT 0
#define DOOR_1_SENSOR_PIN 6
#define DOOR_1_SENSOR_PORT 1
#define DOOR_1_SENSOR_PIN 8
#define DOOR_1_OPEN_TIME_MS 8000
#define DOOR_1_OK_GLED_TIME_MS 3000
......@@ -87,8 +87,8 @@ extern const uint16_t ACC_PANEL_B_ADDR;
#define DOOR_2_ACC_PANEL_RLED_PIN 2
#define DOOR_2_RELAY_PORT 1
#define DOOR_2_RELAY_PIN 11
#define DOOR_2_SENSOR_PORT 0
#define DOOR_2_SENSOR_PIN 7
#define DOOR_2_SENSOR_PORT 1
#define DOOR_2_SENSOR_PIN 5
#define DOOR_2_OPEN_TIME_MS 8000
#define DOOR_2_OK_GLED_TIME_MS 3000
......
......@@ -177,55 +177,96 @@ void Board_Console_Init(void)
#endif
}
#ifdef DEVEL_BOARD
/* Initializes board LED(s) */
static void Board_LED_Init(void)
{
/* Set the PIO_7 as output */
#ifdef DEVEL_BOARD
Chip_IOCON_PinMux(LPC_IOCON, IOCON_PIO0_7, IOCON_MODE_INACT, IOCON_FUNC0);
Chip_GPIO_SetPinDIROutput(LPC_GPIO, 0, 7);
Board_LED_Set(BOARD_LED_DBG_R, false);
Chip_IOCON_PinMux(LPC_IOCON, IOCON_PIO0_8, IOCON_MODE_INACT, IOCON_FUNC0);
Chip_GPIO_SetPinDIROutput(LPC_GPIO, 0, 8);
Board_LED_Set(BOARD_LED_DBG_G, false);
Chip_IOCON_PinMux(LPC_IOCON, IOCON_PIO0_9, IOCON_MODE_INACT, IOCON_FUNC0);
Chip_GPIO_SetPinDIROutput(LPC_GPIO, 0, 9);
Board_LED_Set(BOARD_LED_DBG_B, false);
#endif
Chip_IOCON_PinMux(LPC_IOCON,
CHIP_IOCON_PIO[ACS_PANEL_STATUS_LED_PORT][ACS_PANEL_STATUS_LED_PIN],
IOCON_MODE_INACT, IOCON_FUNC0);
Chip_GPIO_SetPinDIROutput(LPC_GPIO, ACS_PANEL_STATUS_LED_PORT, ACS_PANEL_STATUS_LED_PIN);
Board_LED_Set(BOARD_LED_STATUS, false);
}
/* Sets the state of a board LED to on or off */
void Board_LED_Set(uint8_t LEDNumber, bool On)
void Board_LED_Set(board_led_t led_number, bool on)
{
if(LEDNumber == 0)
Chip_GPIO_SetPinState(LPC_GPIO, 0, 7, !On);
else if (LEDNumber == 1)
Chip_GPIO_SetPinState(LPC_GPIO, 0, 8, !On);
else if (LEDNumber == 2)
Chip_GPIO_SetPinState(LPC_GPIO, 0, 9, !On);
switch (led_number)
{
#ifdef DEVEL_BOARD
case BOARD_LED_DBG_R:
Chip_GPIO_SetPinState(LPC_GPIO, 0, 7, !on);
return;
case BOARD_LED_DBG_G:
Chip_GPIO_SetPinState(LPC_GPIO, 0, 8, !on);
return;
case BOARD_LED_DBG_B:
Chip_GPIO_SetPinState(LPC_GPIO, 0, 9, !on);
return;
#endif
case BOARD_LED_STATUS:
Chip_GPIO_SetPinState(LPC_GPIO, ACS_PANEL_STATUS_LED_PORT, ACS_PANEL_STATUS_LED_PIN, !on);
return;
default:
return;
}
}
/* Returns the current state of a board LED */
bool Board_LED_Test(uint8_t LEDNumber)
bool Board_LED_Test(board_led_t led_number)
{
if(LEDNumber == 0)
return !Chip_GPIO_GetPinState(LPC_GPIO, 0, 7);
else if (LEDNumber == 1)
return !Chip_GPIO_GetPinState(LPC_GPIO, 0, 7);
else if (LEDNumber == 2)
return !Chip_GPIO_GetPinState(LPC_GPIO, 0, 7);
return 0;
switch (led_number)
{
#ifdef DEVEL_BOARD
case BOARD_LED_DBG_R:
return !Chip_GPIO_GetPinState(LPC_GPIO, 0, 7);
case BOARD_LED_DBG_G:
return !Chip_GPIO_GetPinState(LPC_GPIO, 0, 8);
case BOARD_LED_DBG_B:
return !Chip_GPIO_GetPinState(LPC_GPIO, 0, 9);
#endif
case BOARD_LED_STATUS:
return !Chip_GPIO_GetPinState(LPC_GPIO, ACS_PANEL_STATUS_LED_PORT, ACS_PANEL_STATUS_LED_PIN);
default:
return 0;
}
}
void Board_LED_Toggle(uint8_t LEDNumber)
void Board_LED_Toggle(board_led_t led_number)
{
if (LEDNumber == 0)
Chip_GPIO_SetPinToggle(LPC_GPIO, 0, 7);
else if (LEDNumber == 1)
Chip_GPIO_SetPinToggle(LPC_GPIO, 0, 8);
else if (LEDNumber == 2)
Chip_GPIO_SetPinToggle(LPC_GPIO, 0, 9);
switch (led_number)
{
#ifdef DEVEL_BOARD
case BOARD_LED_DBG_R:
Chip_GPIO_SetPinToggle(LPC_GPIO, 0, 7);
return;
case BOARD_LED_DBG_G:
Chip_GPIO_SetPinToggle(LPC_GPIO, 0, 8);
return;
case BOARD_LED_DBG_B:
Chip_GPIO_SetPinToggle(LPC_GPIO, 0, 9);
return;
#endif
case BOARD_LED_STATUS:
Chip_GPIO_SetPinToggle(LPC_GPIO, ACS_PANEL_STATUS_LED_PORT, ACS_PANEL_STATUS_LED_PIN);
return;
default:
return;
}
}
#endif // DEVEL_BOARD
/* Set up and initialize all required blocks and functions related to the
board hardware */
void Board_Init(void)
......@@ -239,13 +280,8 @@ void Board_Init(void)
/* Initialize GPIO */
Chip_GPIO_Init(LPC_GPIO);
#ifdef DEVEL_BOARD
/* Initialize LEDs */
Board_LED_Init();
Board_LED_Set(0, false);
Board_LED_Set(1, false);
Board_LED_Set(2, false);
#endif // DEVEL_BOARD
// Enable INTs for all GPIO ports
NVIC_EnableIRQ(EINT0_IRQn);
......
......@@ -61,6 +61,18 @@ extern "C" {
#endif
// Available LEDs on board
typedef enum
{
BOARD_LED_RESERVED = 0,
#ifdef DEVEL_BOARD
BOARD_LED_DBG_R,
BOARD_LED_DBG_G,
BOARD_LED_DBG_B,
#endif
BOARD_LED_STATUS,
} board_led_t;
/**
* @brief Set up and initialize hardware prior to call to main()
* @return None
......@@ -111,32 +123,21 @@ void Board_UARTPutSTR(char *str);
* @param State : true for on, false for off
* @return None
*/
void Board_LED_Set(uint8_t LEDNumber, bool State);
void Board_LED_Set(board_led_t led_number, bool on);
/**
* @brief Returns the current state of a board LED
* @param LEDNumber : LED number to set state for
* @return true if the LED is on, otherwise false
*/
bool Board_LED_Test(uint8_t LEDNumber);
bool Board_LED_Test(board_led_t led_number);
/**
* @brief Toggles the current state of a board LED
* @param LEDNumber : LED number to change state for
* @return None
*/
void Board_LED_Toggle(uint8_t LEDNumber);
/**
* @brief Turn on Board LCD Backlight
* @param Intensity : Backlight intensity (0 = off, >=1 = on)
* @return None
* @note On boards where a GPIO is used to control backlight on/off state, a '0' or '1'
* value will turn off or on the backlight. On some boards, a non-0 value will
* control backlight intensity via a PWN. For PWM systems, the intensity value
* is a percentage value between 0 and 100%.
*/
void Board_SetLCDBacklight(uint8_t Intensity);
void Board_LED_Toggle(board_led_t led_number);
/**
* @brief Function prototype for a MS delay function. Board layers or example code may
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment