87 lines
2.9 KiB
C
87 lines
2.9 KiB
C
/**
|
|
******************************************************************************
|
|
* @file dev_addr.c
|
|
* @author AMG Energy Solution Team
|
|
* @version V1.0.0
|
|
* @date 07-Feb-2022
|
|
* @brief This file provides all the codes of device address 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 "dev_addr.h"
|
|
|
|
/* Private typedef -----------------------------------------------------------*/
|
|
/* Private define ------------------------------------------------------------*/
|
|
|
|
/* Define port and pin for device address */
|
|
#define DEV_ADDR_0_PORT (PortB)
|
|
#define DEV_ADDR_0_PIN (Pin10)
|
|
|
|
#define DEV_ADDR_1_PORT (PortE)
|
|
#define DEV_ADDR_1_PIN (Pin15)
|
|
|
|
#define DEV_ADDR_2_PORT (PortE)
|
|
#define DEV_ADDR_2_PIN (Pin14)
|
|
|
|
#define DEV_ADDR_3_PORT (PortE)
|
|
#define DEV_ADDR_3_PIN (Pin13)
|
|
|
|
//#define DEV_ADDR_4_PORT (PortE)
|
|
//#define DEV_ADDR_4_PIN (Pin01)
|
|
|
|
//#define DEV_ADDR_5_PORT (PortE)
|
|
//#define DEV_ADDR_5_PIN (Pin01)
|
|
|
|
/* Private macro -------------------------------------------------------------*/
|
|
/* Private variables ---------------------------------------------------------*/
|
|
/* Private function prototypes -----------------------------------------------*/
|
|
/* Private functions ---------------------------------------------------------*/
|
|
|
|
//Relay IO Initialize
|
|
void DevAddrInit(void)
|
|
{
|
|
stc_port_init_t stcPortInit;
|
|
|
|
/* configuration structure initialization */
|
|
MEM_ZERO_STRUCT(stcPortInit);
|
|
|
|
stcPortInit.enPinMode = Pin_Mode_In;
|
|
stcPortInit.enExInt = Disable;
|
|
stcPortInit.enPullUp = Enable;
|
|
|
|
/* LED Port/Pin initialization */
|
|
PORT_Init(DEV_ADDR_0_PORT, DEV_ADDR_0_PIN, &stcPortInit);
|
|
PORT_Init(DEV_ADDR_1_PORT, DEV_ADDR_1_PIN, &stcPortInit);
|
|
PORT_Init(DEV_ADDR_2_PORT, DEV_ADDR_2_PIN, &stcPortInit);
|
|
PORT_Init(DEV_ADDR_3_PORT, DEV_ADDR_3_PIN, &stcPortInit);
|
|
}
|
|
|
|
uint8_t GetDevAddr(void)
|
|
{
|
|
uint8_t result = 0;
|
|
|
|
result |= (!PORT_GetBit(DEV_ADDR_0_PORT, DEV_ADDR_0_PIN) << 3);
|
|
result |= (!PORT_GetBit(DEV_ADDR_1_PORT, DEV_ADDR_1_PIN) << 2);
|
|
result |= (!PORT_GetBit(DEV_ADDR_2_PORT, DEV_ADDR_2_PIN) << 1);
|
|
result |= (!PORT_GetBit(DEV_ADDR_3_PORT, DEV_ADDR_3_PIN) << 0);
|
|
|
|
return result;
|
|
}
|
|
|