2025-02-26 09:59:15 +00:00
|
|
|
|
#include "HD_GPIO.h"
|
|
|
|
|
|
2025-04-02 10:02:25 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief <EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>mcu<EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|
|
|
|
* @param
|
|
|
|
|
* @retval
|
|
|
|
|
*/
|
|
|
|
|
uint8_t mcu_GPIO_Init(void)
|
2025-02-26 09:59:15 +00:00
|
|
|
|
{
|
|
|
|
|
GPIO_InitTypeDef GPIO_InitStructure;
|
|
|
|
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOE, ENABLE);
|
2025-04-02 10:02:25 +00:00
|
|
|
|
|
|
|
|
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4;
|
2025-02-26 09:59:15 +00:00
|
|
|
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;
|
2025-04-02 10:02:25 +00:00
|
|
|
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
|
|
|
|
|
GPIO_Init(GPIOE, &GPIO_InitStructure);
|
|
|
|
|
|
|
|
|
|
return HD_InputGPIO_Read(GPIOE, GPIO_Pin_4);
|
|
|
|
|
}
|
2025-02-26 09:59:15 +00:00
|
|
|
|
|
|
|
|
|
|
2025-04-02 10:02:25 +00:00
|
|
|
|
/**
|
|
|
|
|
* @brief <EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD>˿ڵ<EFBFBD>Դ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param
|
|
|
|
|
* @retval
|
|
|
|
|
*/
|
|
|
|
|
void PwrCtrl_GPIO_Init(void)
|
|
|
|
|
{
|
2025-02-26 09:59:15 +00:00
|
|
|
|
/* <20><>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ţ<EFBFBD>Ĭ<EFBFBD>ϲ<EFBFBD><CFB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ */
|
2025-04-02 10:02:25 +00:00
|
|
|
|
GPIO_InitTypeDef GPIO_InitStructure;
|
|
|
|
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOE, ENABLE);
|
|
|
|
|
|
2025-02-26 09:59:15 +00:00
|
|
|
|
GPIO_InitStructure.GPIO_Pin = J1_PwrCtrl_GPIO_PIN;
|
2025-04-02 10:02:25 +00:00
|
|
|
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;
|
|
|
|
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
2025-02-26 09:59:15 +00:00
|
|
|
|
GPIO_Init(J1_PwrCtrl_GPIO_PROT, &GPIO_InitStructure);
|
|
|
|
|
GPIO_WriteBit(J1_PwrCtrl_GPIO_PROT, J1_PwrCtrl_GPIO_PIN, Bit_RESET);
|
|
|
|
|
|
|
|
|
|
GPIO_InitStructure.GPIO_Pin = J2_PwrCtrl_GPIO_PIN;
|
|
|
|
|
GPIO_Init(J2_PwrCtrl_GPIO_PROT, &GPIO_InitStructure);
|
|
|
|
|
GPIO_WriteBit(J2_PwrCtrl_GPIO_PROT, J2_PwrCtrl_GPIO_PIN, Bit_RESET);
|
|
|
|
|
|
|
|
|
|
GPIO_InitStructure.GPIO_Pin = J3_PwrCtrl_GPIO_PIN;
|
|
|
|
|
GPIO_Init(J3_PwrCtrl_GPIO_PROT, &GPIO_InitStructure);
|
|
|
|
|
GPIO_WriteBit(J3_PwrCtrl_GPIO_PROT, J3_PwrCtrl_GPIO_PIN, Bit_RESET);
|
|
|
|
|
|
|
|
|
|
GPIO_InitStructure.GPIO_Pin = J4_PwrCtrl_GPIO_PIN;
|
|
|
|
|
GPIO_Init(J4_PwrCtrl_GPIO_PROT, &GPIO_InitStructure);
|
|
|
|
|
GPIO_WriteBit(J4_PwrCtrl_GPIO_PROT, J4_PwrCtrl_GPIO_PIN, Bit_RESET);
|
|
|
|
|
|
|
|
|
|
GPIO_InitStructure.GPIO_Pin = J5_PwrCtrl_GPIO_PIN;
|
|
|
|
|
GPIO_Init(J5_PwrCtrl_GPIO_PROT, &GPIO_InitStructure);
|
|
|
|
|
GPIO_WriteBit(J5_PwrCtrl_GPIO_PROT, J5_PwrCtrl_GPIO_PIN, Bit_RESET);
|
|
|
|
|
|
|
|
|
|
GPIO_InitStructure.GPIO_Pin = J6_PwrCtrl_GPIO_PIN;
|
|
|
|
|
GPIO_Init(J6_PwrCtrl_GPIO_PROT, &GPIO_InitStructure);
|
|
|
|
|
GPIO_WriteBit(J6_PwrCtrl_GPIO_PROT, J6_PwrCtrl_GPIO_PIN, Bit_RESET);
|
|
|
|
|
|
|
|
|
|
GPIO_InitStructure.GPIO_Pin = J7_PwrCtrl_GPIO_PIN;
|
|
|
|
|
GPIO_Init(J7_PwrCtrl_GPIO_PROT, &GPIO_InitStructure);
|
|
|
|
|
GPIO_WriteBit(J7_PwrCtrl_GPIO_PROT, J7_PwrCtrl_GPIO_PIN, Bit_RESET);
|
|
|
|
|
|
|
|
|
|
GPIO_InitStructure.GPIO_Pin = J8_PwrCtrl_GPIO_PIN;
|
|
|
|
|
GPIO_Init(J8_PwrCtrl_GPIO_PROT, &GPIO_InitStructure);
|
|
|
|
|
GPIO_WriteBit(J8_PwrCtrl_GPIO_PROT, J8_PwrCtrl_GPIO_PIN, Bit_RESET);
|
|
|
|
|
|
|
|
|
|
GPIO_InitStructure.GPIO_Pin = J9_PwrCtrl_GPIO_PIN;
|
|
|
|
|
GPIO_Init(J9_PwrCtrl_GPIO_PROT, &GPIO_InitStructure);
|
|
|
|
|
GPIO_WriteBit(J9_PwrCtrl_GPIO_PROT, J9_PwrCtrl_GPIO_PIN, Bit_RESET);
|
2025-04-02 10:02:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief <EFBFBD><EFBFBD>ģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ų<EFBFBD>ʼ<EFBFBD><EFBFBD>
|
|
|
|
|
* @param
|
|
|
|
|
* @retval
|
|
|
|
|
*/
|
|
|
|
|
void Android_GPIO_Init(void)
|
|
|
|
|
{
|
|
|
|
|
GPIO_InitTypeDef GPIO_InitStructure;
|
|
|
|
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOE, ENABLE);
|
|
|
|
|
|
|
|
|
|
/* <20><>ģ<D7BF><C4A3><EFBFBD><EFBFBD>Դʹ<D4B4><CAB9><EFBFBD><EFBFBD><EFBFBD>ţ<EFBFBD>Ĭ<EFBFBD>ϲ<EFBFBD>ʹ<EFBFBD><CAB9> */
|
|
|
|
|
GPIO_InitStructure.GPIO_Pin = GPIO_PwrCtrl_GPIO_PIN;
|
|
|
|
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;
|
|
|
|
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
|
|
|
|
GPIO_Init(GPIO_PwrCtrl_GPIO_PROT, &GPIO_InitStructure);
|
|
|
|
|
GPIO_WriteBit(GPIO_PwrCtrl_GPIO_PROT, GPIO_PwrCtrl_GPIO_PIN, Bit_RESET);
|
|
|
|
|
|
|
|
|
|
/* <20><>λ<EFBFBD><CEBB>ģ<D7BF><C4A3><EFBFBD><EFBFBD><EFBFBD>ţ<EFBFBD>Ĭ<EFBFBD>ϵ͵<CFB5>ƽ */
|
|
|
|
|
GPIO_InitStructure.GPIO_Pin = GPIO_PwrKey_GPIO_PIN;
|
|
|
|
|
GPIO_Init(GPIO_PwrKey_GPIO_PROT, &GPIO_InitStructure);
|
|
|
|
|
GPIO_WriteBit(GPIO_PwrKey_GPIO_PROT, GPIO_PwrKey_GPIO_PIN, Bit_RESET);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief ι<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ų<EFBFBD>ʼ<EFBFBD><EFBFBD>
|
|
|
|
|
* @param
|
|
|
|
|
* @retval
|
|
|
|
|
*/
|
|
|
|
|
void WDI_GPIO_Init(void)
|
|
|
|
|
{
|
|
|
|
|
GPIO_InitTypeDef GPIO_InitStructure;
|
|
|
|
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
|
2025-02-26 09:59:15 +00:00
|
|
|
|
|
|
|
|
|
GPIO_InitStructure.GPIO_Pin = WDI_GPIO_PIN;
|
2025-04-02 10:02:25 +00:00
|
|
|
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;
|
|
|
|
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
2025-02-26 09:59:15 +00:00
|
|
|
|
GPIO_Init(WDI_GPIO_PROT, &GPIO_InitStructure);
|
|
|
|
|
GPIO_WriteBit(WDI_GPIO_PROT, WDI_GPIO_PIN, Bit_SET);
|
2025-04-02 10:02:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief led<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ų<EFBFBD>ʼ<EFBFBD><EFBFBD>
|
|
|
|
|
* @param
|
|
|
|
|
* @retval
|
|
|
|
|
*/
|
|
|
|
|
void LED_GPIO_Init(void)
|
|
|
|
|
{
|
|
|
|
|
GPIO_InitTypeDef GPIO_InitStructure;
|
|
|
|
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
|
|
|
|
|
|
2025-03-12 07:00:12 +00:00
|
|
|
|
GPIO_InitStructure.GPIO_Pin = LED_GPIO_PIN;
|
2025-04-02 10:02:25 +00:00
|
|
|
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;
|
|
|
|
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
2025-03-12 07:00:12 +00:00
|
|
|
|
GPIO_Init(LED_GPIO_PROT, &GPIO_InitStructure);
|
|
|
|
|
GPIO_WriteBit(LED_GPIO_PROT, LED_GPIO_PIN, Bit_SET);
|
2025-02-26 09:59:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2025-04-02 10:02:25 +00:00
|
|
|
|
/**
|
|
|
|
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD>485<EFBFBD><EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ų<EFBFBD>ʼ<EFBFBD><EFBFBD>
|
|
|
|
|
* @param
|
|
|
|
|
* @retval
|
|
|
|
|
*/
|
|
|
|
|
void Host485De_GPIO_Init(void)
|
|
|
|
|
{
|
|
|
|
|
GPIO_InitTypeDef GPIO_InitStructure;
|
|
|
|
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
|
|
|
|
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD, ENABLE);
|
|
|
|
|
|
|
|
|
|
GPIO_InitStructure.GPIO_Pin = J0De_GPIO_PIN;
|
|
|
|
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
|
|
|
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
|
|
|
|
GPIO_Init(J0De_GPIO_PROT, &GPIO_InitStructure);
|
|
|
|
|
GPIO_WriteBit(J0De_GPIO_PROT, J0De_GPIO_PIN, write);
|
|
|
|
|
|
|
|
|
|
GPIO_InitStructure.GPIO_Pin = J2De_GPIO_PIN;
|
|
|
|
|
GPIO_Init(J2De_GPIO_PROT, &GPIO_InitStructure);
|
|
|
|
|
GPIO_WriteBit(J2De_GPIO_PROT, J2De_GPIO_PIN, write);
|
|
|
|
|
|
|
|
|
|
GPIO_InitStructure.GPIO_Pin = J4De_GPIO_PIN;
|
|
|
|
|
GPIO_Init(J4De_GPIO_PROT, &GPIO_InitStructure);
|
|
|
|
|
GPIO_WriteBit(J4De_GPIO_PROT, J4De_GPIO_PIN, write);
|
|
|
|
|
|
|
|
|
|
GPIO_InitStructure.GPIO_Pin = J6De_GPIO_PIN;
|
|
|
|
|
GPIO_Init(J6De_GPIO_PROT, &GPIO_InitStructure);
|
|
|
|
|
GPIO_WriteBit(J6De_GPIO_PROT, J6De_GPIO_PIN, write);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief <EFBFBD>ӻ<EFBFBD>485<EFBFBD><EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ų<EFBFBD>ʼ<EFBFBD><EFBFBD>
|
|
|
|
|
* @param
|
|
|
|
|
* @retval
|
|
|
|
|
*/
|
|
|
|
|
void Slave485De_GPIO_Init(void)
|
|
|
|
|
{
|
|
|
|
|
GPIO_InitTypeDef GPIO_InitStructure;
|
|
|
|
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC,ENABLE);
|
|
|
|
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD,ENABLE);
|
|
|
|
|
|
|
|
|
|
GPIO_InitStructure.GPIO_Pin = J1De_GPIO_PIN;
|
|
|
|
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
|
|
|
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
|
|
|
|
GPIO_Init(J1De_GPIO_PROT, &GPIO_InitStructure);
|
|
|
|
|
GPIO_WriteBit(J1De_GPIO_PROT, J1De_GPIO_PIN, write);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GPIO_InitStructure.GPIO_Pin = J3De_GPIO_PIN;
|
|
|
|
|
GPIO_Init(J3De_GPIO_PROT, &GPIO_InitStructure);
|
|
|
|
|
GPIO_WriteBit(J3De_GPIO_PROT, J3De_GPIO_PIN, write);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GPIO_InitStructure.GPIO_Pin = J5De_GPIO_PIN;
|
|
|
|
|
GPIO_Init(J5De_GPIO_PROT, &GPIO_InitStructure);
|
|
|
|
|
GPIO_WriteBit(J5De_GPIO_PROT, J5De_GPIO_PIN, write);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GPIO_InitStructure.GPIO_Pin = J7De_GPIO_PIN;
|
|
|
|
|
GPIO_Init(J7De_GPIO_PROT, &GPIO_InitStructure);
|
|
|
|
|
GPIO_WriteBit(J7De_GPIO_PROT, J7De_GPIO_PIN, write);
|
|
|
|
|
|
|
|
|
|
GPIO_InitStructure.GPIO_Pin = J8De_GPIO_PIN;
|
|
|
|
|
GPIO_Init(J8De_GPIO_PROT, &GPIO_InitStructure);
|
|
|
|
|
GPIO_WriteBit(J8De_GPIO_PROT, J8De_GPIO_PIN, write);
|
|
|
|
|
|
|
|
|
|
GPIO_InitStructure.GPIO_Pin = J9De_GPIO_PIN;
|
|
|
|
|
GPIO_Init(J9De_GPIO_PROT, &GPIO_InitStructure);
|
|
|
|
|
GPIO_WriteBit(J9De_GPIO_PROT, J9De_GPIO_PIN, write);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief <EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƴ<EFBFBD>mcu<EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param
|
|
|
|
|
* @retval
|
|
|
|
|
*/
|
|
|
|
|
void ctrlSlave_GPIO_Init(void)
|
|
|
|
|
{
|
|
|
|
|
GPIO_InitTypeDef GPIO_InitStructure;
|
|
|
|
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD,ENABLE);
|
|
|
|
|
|
|
|
|
|
GPIO_InitStructure.GPIO_Pin = ctrlSlave_GPIO_PIN;
|
|
|
|
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;
|
|
|
|
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
|
|
|
|
GPIO_Init(ctrlSlave_GPIO_PROT, &GPIO_InitStructure);
|
|
|
|
|
GPIO_WriteBit(ctrlSlave_GPIO_PROT, ctrlSlave_GPIO_PIN, Bit_SET);
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-26 09:59:15 +00:00
|
|
|
|
/**
|
|
|
|
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD>IO<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƽ
|
|
|
|
|
* @param GPIOx
|
|
|
|
|
GPIO_Pin
|
|
|
|
|
BitVal
|
|
|
|
|
* @retval
|
|
|
|
|
*/
|
|
|
|
|
void HD_GPIO_Write(GPIOTypeDef *GPIOx, GPIOPin GPIO_Pin, BitOperation BitVal)
|
|
|
|
|
{
|
|
|
|
|
GPIO_WriteBit(GPIOx, GPIO_Pin, BitVal);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief <EFBFBD>õ<EFBFBD>IO<EFBFBD><EFBFBD>ƽ
|
|
|
|
|
* @param GPIOx
|
|
|
|
|
GPIO_Pin
|
|
|
|
|
* @retval
|
|
|
|
|
*/
|
|
|
|
|
uint8_t HD_InputGPIO_Read(GPIOTypeDef *GPIOx, GPIOPin GPIO_Pin)
|
|
|
|
|
{
|
|
|
|
|
return GPIO_ReadInputDataBit(GPIOx, GPIO_Pin);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief <EFBFBD>õ<EFBFBD>IO<EFBFBD><EFBFBD>ƽ
|
|
|
|
|
* @param GPIOx
|
|
|
|
|
GPIO_Pin
|
|
|
|
|
* @retval
|
|
|
|
|
*/
|
|
|
|
|
uint8_t HD_OutputGPIO_Read(GPIOTypeDef *GPIOx, GPIOPin GPIO_Pin)
|
|
|
|
|
{
|
|
|
|
|
return GPIO_ReadOutputDataBit(GPIOx, GPIO_Pin);
|
|
|
|
|
}
|