初始版本
This commit is contained in:
201
app/Src/IoControl.c
Normal file
201
app/Src/IoControl.c
Normal file
@@ -0,0 +1,201 @@
|
||||
/********************************************************************
|
||||
Copyright (c) 2021 Xiangyu Medical Co.,Ltd. All rights reserved.
|
||||
FileName : IoControl.c
|
||||
Author : zhangdawei
|
||||
Version : V1.0
|
||||
Date :
|
||||
Note :
|
||||
History :
|
||||
********************************************************************/
|
||||
/* Includes ------------------------------------------------------*/
|
||||
#include "IoControl.h"
|
||||
#include "drv_uart.h"
|
||||
#include "nrf_drv_gpiote.h"
|
||||
/* Private define ------------------------------------------------*/
|
||||
/* Private typedef -----------------------------------------------*/
|
||||
/* Private constants ---------------------------------------------*/
|
||||
/* Private variables ---------------------------------------------*/
|
||||
uint8_t LastState = Null; //保存上一次的状态
|
||||
/* Private function prototypes -----------------------------------*/
|
||||
/* Public constants ----------------------------------------------*/
|
||||
/* Public variables ----------------------------------------------*/
|
||||
DeviceStateInfo_e DeviceState = POWER_CLOSE; //设备开关机状态
|
||||
ChargingStateInfo_e ChargeState = Uncharged;
|
||||
ChargingStateInfo_e ChargeLastState = Uncharged;
|
||||
KeyStateInfo_t KeyStateInfo;
|
||||
/********************************************************************
|
||||
* name : void GpioInit(void)
|
||||
* description : GPIO引脚初始化
|
||||
* Input : void
|
||||
* Output : void
|
||||
* Return :
|
||||
********************************************************************/
|
||||
void GpioInit(void)
|
||||
{
|
||||
NRF_UICR->NFCPINS = 0;
|
||||
|
||||
nrf_gpio_cfg_output(KEY_POWER);
|
||||
nrf_gpio_cfg_output(LED_YELLOW);
|
||||
// nrf_gpio_cfg_output(CHARGE_LED);
|
||||
|
||||
nrf_gpio_cfg_output(STIM_RMS_RELAY_PIN);
|
||||
nrf_gpio_cfg_output(STIM_RELAY_PIN);
|
||||
nrf_gpio_cfg_output(SAMPLE_POWER_PIN);
|
||||
|
||||
|
||||
// nrf_gpio_pin_clear(KEY_POWER);
|
||||
nrf_gpio_pin_clear(LED_YELLOW);
|
||||
|
||||
// nrf_gpio_pin_clear(CHARGE_LED);
|
||||
|
||||
nrf_gpio_pin_clear(STIM_RMS_RELAY_PIN);
|
||||
nrf_gpio_pin_clear(STIM_RELAY_PIN);
|
||||
nrf_gpio_pin_clear(SAMPLE_POWER_PIN);
|
||||
|
||||
/////////
|
||||
nrf_gpio_cfg_input(CHG_MANAGER_CHG, NRF_GPIO_PIN_NOPULL);//检测充电状态
|
||||
|
||||
}
|
||||
/* 电刺激输出使能脚 */
|
||||
void StimOutCtlOpen(void)
|
||||
{
|
||||
|
||||
}
|
||||
void StimOutCtlClose(void)
|
||||
{
|
||||
|
||||
}
|
||||
/* 能量释放控制 */
|
||||
void StimReleaseOpen(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void StimReleaseClose(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// OK按键处理函数
|
||||
void KEY_PWR_SWITICH_Handler(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//GPIOTE事件处理函回调函数,事件回调函数里面可以获取pin编号和引脚状态变化
|
||||
void in_pin_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
|
||||
{
|
||||
if(pin == KEY_PWR_SWITICH)
|
||||
{
|
||||
|
||||
KeyStateInfo.shineng = true;
|
||||
KeyStateInfo.KeyPinNumber = KEY_PWR_SWITICH;
|
||||
}
|
||||
}
|
||||
void EXIT_KEY_Init(void)
|
||||
{
|
||||
ret_code_t err_code;
|
||||
|
||||
nrf_gpio_cfg_input(KEY_PWR_SWITICH, NRF_GPIO_PIN_PULLUP);//检测开关机信号
|
||||
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
* name : void open_acquisition_relay(void)
|
||||
* description : 打开采样继电器
|
||||
* Input : void
|
||||
* Output : void
|
||||
* Return :
|
||||
********************************************************************/
|
||||
void open_acquisition_relay(void)
|
||||
{
|
||||
nrf_gpio_pin_set(STIM_RMS_RELAY_PIN); //闭合继电器
|
||||
nrf_gpio_pin_clear(STIM_RELAY_PIN); //打开刺激继电器
|
||||
}
|
||||
/********************************************************************
|
||||
* name : void close_acquisition_relay(void)
|
||||
* description : 关闭采样继电器
|
||||
* Input : void
|
||||
* Output : void
|
||||
* Return :
|
||||
********************************************************************/
|
||||
void close_acquisition_relay(void)
|
||||
{
|
||||
nrf_gpio_pin_clear(STIM_RMS_RELAY_PIN);
|
||||
nrf_gpio_pin_clear(STIM_RELAY_PIN);
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************
|
||||
* name : void open_stimulate_relay(void)
|
||||
* description : 打开刺激继电器
|
||||
* Input : void
|
||||
* Output : void
|
||||
* Return :
|
||||
********************************************************************/
|
||||
void open_stimulate_relay(void)
|
||||
{
|
||||
nrf_gpio_pin_clear(STIM_RMS_RELAY_PIN);
|
||||
nrf_gpio_pin_set(STIM_RELAY_PIN);
|
||||
}
|
||||
/********************************************************************
|
||||
* name : void close_stimulate_relay(void)
|
||||
* description : 关闭刺激继电器
|
||||
* Input : void
|
||||
* Output : void
|
||||
* Return :
|
||||
********************************************************************/
|
||||
void close_stimulate_relay(void)
|
||||
{
|
||||
nrf_gpio_pin_clear(STIM_RMS_RELAY_PIN);
|
||||
nrf_gpio_pin_clear(STIM_RELAY_PIN);
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************
|
||||
* name : void StimStateInfoStructInit(SchemeData_t SchemeDataIn)
|
||||
* description : 初始化通道信息描述结构体
|
||||
* Input : void
|
||||
* Output : void
|
||||
* Return :
|
||||
********************************************************************/
|
||||
void StimStateInfoStructInit(SchemeData_t SchemeDataIn)
|
||||
{
|
||||
|
||||
}
|
||||
// 设备预存信息初始化ID :101 腹直肌分离
|
||||
void PreStorageSchemeDataInit(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void KeyPinHandler(void)
|
||||
{
|
||||
if(KeyStateInfo.shineng == true)
|
||||
{
|
||||
switch(KeyStateInfo.KeyPinNumber)
|
||||
{
|
||||
case KEY_PWR_SWITICH:
|
||||
{
|
||||
KEY_PWR_SWITICH_Handler();
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
KeyStateInfo.shineng = false;
|
||||
}
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
* name : void VariableInit(void)
|
||||
* description : 初始化变量
|
||||
* Input : void
|
||||
* Output : void
|
||||
* Return :
|
||||
********************************************************************/
|
||||
void VariableInit(void)
|
||||
{
|
||||
|
||||
}
|
||||
/*************************** END OF FILE ***************************/
|
||||
|
||||
Reference in New Issue
Block a user