HL-PDJ-1/app/Inc/IoControl.h
xiaozhengsheng 6df0f7d96e 初始版本
2025-08-19 09:49:41 +08:00

109 lines
3.2 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/********************************************************************
Copyright (c) 2021 Xiangyu Medical Co.Ltd. All rights reserved.
FileName : IoControl.h
Author : zhangdawei
Version : V1.0
Date :
Note :
History :
********************************************************************/
#ifndef _IOCONTROL_H__
#define _IOCONTROL_H__
/* Includes ------------------------------------------------------*/
#include "nrf52.h"
#include "nrf_gpio.h"
#include "timer.h"
#include "drv_saadc.h"
#include "drv_uart.h"
#include "nrf_drv_gpiote.h"
//Log需要引用的头文件
#include "nrf_log.h"
#include "nrf_log_ctrl.h"
#include "nrf_log_default_backends.h"
#include "nrf_delay.h"
/* Public define -------------------------------------------------*/
#define MERGE(Msb,Lsb) ((Msb<<8)|Lsb)
/* 按键检测 */
#define KEY_PWR_SWITICH ( 16 )
/* 电源锁定 */
#define KEY_POWER ( 13 )
/* 指示灯 */
#define LED_YELLOW ( 11 )
#define LED_WHITE ( 12 )
/* DAC 引脚*/
#define PWM_DAC_GPIO ( 26 )
/* 充电芯片引脚定义,低电平是充电中,高电平是充电完成或未充电 */
#define CHG_MANAGER_EN ( 15 ) //充电管理芯片的EN引脚内部200K下拉电阻。 高电平:禁用充电器 低电平Low或悬空Floating启用充电器
#define CHG_MANAGER_PPR ( 23 ) //充电管理芯片的PPR引脚 开漏输出外部上拉3.0V,低电平:输入充电电压正常,高电平:输入充电电压异常
#define CHG_MANAGER_CHG ( 14 ) //充电指示引脚,低电平是充电中,充电结束为高电平
#define STIM_RMS_RELAY_PIN ( 27 ) // 肌电采集继电器控制引脚
#define STIM_RELAY_PIN ( 28 ) //刺激继电器控制引脚
#define SAMPLE_POWER_PIN ( 20 ) //采样电源控制引脚
#define BOOST_DISCHARGE_PIN ( 18 ) //boost升压放电引脚
#define BASE_WAVE_06_PIN ( 6 ) //刺激基础波形控制引脚6
#define BASE_WAVE_07_PIN ( 7 ) //刺激基础波形控制引脚7
#define BASE_WAVE_08_PIN ( 8 ) //刺激基础波形控制引脚8
#define BOOST_VOLTAGE_CONTROL_PIN ( 25 ) //boost电压控制引脚
/* Public typedef ------------------------------------------------*/
//设备开关机状态
typedef enum
{
POWER_OPEN = 0,
POWER_CLOSE
}DeviceStateInfo_e;
// 充电状态
typedef enum
{
Uncharged = 0,
Charging,
ChargeComplete
}ChargingStateInfo_e;
typedef enum
{
Bit_RESET = 0,
Bit_SET
}BitAction;
typedef struct{
nrf_drv_gpiote_pin_t KeyPinNumber;
bool shineng;
}KeyStateInfo_t;
/* Public constants ----------------------------------------------*/
/* Public variables ----------------------------------------------*/
extern DeviceStateInfo_e DeviceState;
extern ChargingStateInfo_e ChargeState;
extern ChargingStateInfo_e ChargeLastState;
/* Public function prototypes ------------------------------------*/
void StartAdv(void);
void StopAdv(void);
void GpioInit(void);
void EXIT_KEY_Init(void);
void open_acquisition_relay(void);
void close_acquisition_relay(void);
void LedControl(void);
void StimStateInfoStructInit(SchemeData_t SchemeDataIn);
void VariableInit(void);
void StimOutCtlOpen(void);
void StimOutCtlClose(void);
void StimReleaseOpen(void);
void StimReleaseClose(void);
void PreStorageSchemeDataInit(void);
void KeyPinHandler(void);
void close_stimulate_relay(void);
void open_stimulate_relay(void);
#endif
/*************************** END OF FILE ***************************/