feat: KT mBMS 펌웨어 3종(HW1/2/3) 및 통합 빌드 환경 초기 커밋 (V4.0.0.1)
This commit is contained in:
53
mBMS_APP_V3117/HARDWARE/dev_addr.c
Normal file
53
mBMS_APP_V3117/HARDWARE/dev_addr.c
Normal file
@@ -0,0 +1,53 @@
|
||||
#include "dev_addr.h"
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
//This program is for educational purposes only, without the author's permission, may not be used for any other purpose
|
||||
//ALIENTEK STM32F407 Development Board
|
||||
//RELAY driver code
|
||||
//Hot Atomic @ALIENTEK
|
||||
//Forum: www.openedv.com
|
||||
//Date created: 2014/6/10
|
||||
//Version: V1.0
|
||||
//All rights reserved pirated reserved.
|
||||
//Copyright(C) Guangzhou wing electronic technology limited company 2014-2024
|
||||
//All rights reserved
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//Relay IO Initialize
|
||||
void DevAddrInit(void)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
|
||||
// Device addr configuration - Charge Relay
|
||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE); // GPIOB clock
|
||||
|
||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; // ADDR 0
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; // input
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; // Pull Up
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; // High-speed GPIO
|
||||
GPIO_Init(GPIOB, &GPIO_InitStructure);
|
||||
|
||||
// Relay output configuration - Discharge Relay
|
||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOE, ENABLE); // GPIOD clock
|
||||
|
||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15 // ADDR 1
|
||||
| GPIO_Pin_14 // ADDR 2
|
||||
| GPIO_Pin_13 // ADDR 3
|
||||
;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; // input
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; // Pull Up
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; // High-speed GPIO
|
||||
GPIO_Init(GPIOE, &GPIO_InitStructure);
|
||||
}
|
||||
|
||||
u8 GetDevAddr(void)
|
||||
{
|
||||
u8 result = 0;
|
||||
|
||||
result |= (!GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_10) << 3);
|
||||
result |= (!GPIO_ReadInputDataBit(GPIOE, GPIO_Pin_15) << 2);
|
||||
result |= (!GPIO_ReadInputDataBit(GPIOE, GPIO_Pin_14) << 1);
|
||||
result |= (!GPIO_ReadInputDataBit(GPIOE, GPIO_Pin_13) << 0);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user