feat: KT mBMS 펌웨어 3종(HW1/2/3) 및 통합 빌드 환경 초기 커밋 (V4.0.0.1)
This commit is contained in:
161
APP_R3323/App/Hardware/led.c
Normal file
161
APP_R3323/App/Hardware/led.c
Normal file
@@ -0,0 +1,161 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file led.c
|
||||
* @author AMG Energy Solution Team
|
||||
* @version V1.0.0
|
||||
* @date 07-Feb-2022
|
||||
* @brief This file provides all the code of the led control functions.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
||||
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
|
||||
* TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
|
||||
* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
|
||||
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2022 AMG</center></h2>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/** @addtogroup mBMS2
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "led.h"
|
||||
#include "delay.h"
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
//LED port definitions
|
||||
/* LED RUN(GREEN) Port/Pin definition */
|
||||
#define LED_BD_PORT (PortB)
|
||||
#define LED_BD_PIN (Pin08)
|
||||
|
||||
/* LED RUN(GREEN) Port/Pin definition */
|
||||
#define LED_G_PORT (PortE)
|
||||
#define LED_G_PIN (Pin08)
|
||||
|
||||
/* LED ALARM (RED) Port/Pin definition */
|
||||
#define LED_R_PORT (PortE)
|
||||
#define LED_R_PIN (Pin07)
|
||||
|
||||
/* LED SOC Port/Pin definition */
|
||||
#define LED_SOC_3_PORT (PortE)
|
||||
#define LED_SOC_3_PIN (Pin09)
|
||||
|
||||
#define LED_SOC_2_PORT (PortE)
|
||||
#define LED_SOC_2_PIN (Pin10)
|
||||
|
||||
#define LED_SOC_1_PORT (PortE)
|
||||
#define LED_SOC_1_PIN (Pin11)
|
||||
|
||||
#define LED_SOC_0_PORT (PortE)
|
||||
#define LED_SOC_0_PIN (Pin12)
|
||||
|
||||
/* LED0~3 toggle definition */
|
||||
#define LED_G_TOGGLE() (PORT_Toggle(LED_G_PORT, LED_G_PIN))
|
||||
#define LED_R_TOGGLE() (PORT_Toggle(LED_R_PORT, LED_R_PIN))
|
||||
#define LED_S0C_0_TOGGLE() (PORT_Toggle(LED_SOC_0_PIN, LED_SOC_0_PIN))
|
||||
#define LED_S0C_1_TOGGLE() (PORT_Toggle(LED_SOC_1_PIN, LED_SOC_1_PIN))
|
||||
#define LED_S0C_2_TOGGLE() (PORT_Toggle(LED_SOC_2_PIN, LED_SOC_2_PIN))
|
||||
#define LED_S0C_3_TOGGLE() (PORT_Toggle(LED_SOC_3_PIN, LED_SOC_3_PIN))
|
||||
|
||||
#define DLY_MS (200ul)
|
||||
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
|
||||
// LED class IO
|
||||
void LED_Init(void)
|
||||
{
|
||||
stc_port_init_t stcPortInit;
|
||||
|
||||
/* configuration structure initialization */
|
||||
MEM_ZERO_STRUCT(stcPortInit);
|
||||
|
||||
stcPortInit.enPinMode = Pin_Mode_Out;
|
||||
stcPortInit.enExInt = Disable;
|
||||
stcPortInit.enPullUp = Disable;
|
||||
|
||||
/* LED Port/Pin initialization */
|
||||
PORT_Init(LED_BD_PORT, LED_BD_PIN, &stcPortInit);
|
||||
|
||||
PORT_Init(LED_G_PORT, LED_G_PIN, &stcPortInit);
|
||||
PORT_Init(LED_R_PORT, LED_R_PIN, &stcPortInit);
|
||||
|
||||
PORT_Init(LED_SOC_0_PORT, LED_SOC_0_PIN, &stcPortInit);
|
||||
PORT_Init(LED_SOC_1_PORT, LED_SOC_1_PIN, &stcPortInit);
|
||||
PORT_Init(LED_SOC_2_PORT, LED_SOC_2_PIN, &stcPortInit);
|
||||
PORT_Init(LED_SOC_3_PORT, LED_SOC_3_PIN, &stcPortInit);
|
||||
}
|
||||
|
||||
void LED_SelfTest(void)
|
||||
{
|
||||
LED_Off(LED_ALL);
|
||||
delay_os_ms(DLY_MS);
|
||||
|
||||
for (int i = 0; i < 6; i++) {
|
||||
LED_On((LED_CONTROL)i);
|
||||
if (i > 0) LED_Off((LED_CONTROL)(i - 1));
|
||||
delay_os_ms(DLY_MS);
|
||||
}
|
||||
|
||||
LED_Off(LED_ALL);
|
||||
delay_os_ms(DLY_MS);
|
||||
|
||||
LED_On(LED_G);
|
||||
}
|
||||
|
||||
void LED_On(LED_CONTROL flag)
|
||||
{
|
||||
switch (flag) {
|
||||
case (LED_CONTROL)0: PORT_SetBits(LED_G_PORT, LED_G_PIN); break;
|
||||
case (LED_CONTROL)1: PORT_SetBits(LED_R_PORT, LED_R_PIN); break;
|
||||
case (LED_CONTROL)2: PORT_SetBits(LED_SOC_0_PORT, LED_SOC_0_PIN); break;
|
||||
case (LED_CONTROL)3: PORT_SetBits(LED_SOC_1_PORT, LED_SOC_1_PIN); break;
|
||||
case (LED_CONTROL)4: PORT_SetBits(LED_SOC_2_PORT, LED_SOC_2_PIN); break;
|
||||
case (LED_CONTROL)5: PORT_SetBits(LED_SOC_3_PORT, LED_SOC_3_PIN); break;
|
||||
case (LED_CONTROL)6: PORT_ResetBits(LED_BD_PORT, LED_BD_PIN); break;
|
||||
case (LED_CONTROL)7:
|
||||
PORT_SetBits(LED_G_PORT, LED_G_PIN);
|
||||
PORT_SetBits(LED_R_PORT, LED_R_PIN);
|
||||
PORT_SetBits(LED_SOC_0_PORT, LED_SOC_0_PIN);
|
||||
PORT_SetBits(LED_SOC_1_PORT, LED_SOC_1_PIN);
|
||||
PORT_SetBits(LED_SOC_2_PORT, LED_SOC_2_PIN);
|
||||
PORT_SetBits(LED_SOC_3_PORT, LED_SOC_3_PIN);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void LED_Off(LED_CONTROL flag)
|
||||
{
|
||||
switch (flag) {
|
||||
case (LED_CONTROL)0: PORT_ResetBits(LED_G_PORT, LED_G_PIN); break;
|
||||
case (LED_CONTROL)1: PORT_ResetBits(LED_R_PORT, LED_R_PIN); break;
|
||||
case (LED_CONTROL)2: PORT_ResetBits(LED_SOC_0_PORT, LED_SOC_0_PIN); break;
|
||||
case (LED_CONTROL)3: PORT_ResetBits(LED_SOC_1_PORT, LED_SOC_1_PIN); break;
|
||||
case (LED_CONTROL)4: PORT_ResetBits(LED_SOC_2_PORT, LED_SOC_2_PIN); break;
|
||||
case (LED_CONTROL)5: PORT_ResetBits(LED_SOC_3_PORT, LED_SOC_3_PIN); break;
|
||||
case (LED_CONTROL)6: PORT_SetBits(LED_BD_PORT, LED_BD_PIN); break;
|
||||
case (LED_CONTROL)7:
|
||||
PORT_ResetBits(LED_G_PORT, LED_G_PIN);
|
||||
PORT_ResetBits(LED_R_PORT, LED_R_PIN);
|
||||
PORT_ResetBits(LED_SOC_0_PORT, LED_SOC_0_PIN);
|
||||
PORT_ResetBits(LED_SOC_1_PORT, LED_SOC_1_PIN);
|
||||
PORT_ResetBits(LED_SOC_2_PORT, LED_SOC_2_PIN);
|
||||
PORT_ResetBits(LED_SOC_3_PORT, LED_SOC_3_PIN);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void BD_LED_Toggle(void)
|
||||
{
|
||||
PORT_Toggle(LED_BD_PORT, LED_BD_PIN);
|
||||
}
|
||||
|
||||
/*******************(C)COPYRIGHT 2022 AMG ********************END OF FILE******/
|
||||
Reference in New Issue
Block a user