voqc/users/Src/gpios.c

72 lines
1.5 KiB
C
Raw 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.

#include "gpios.h"
#include "ds18b20.h"
uint8_t coil1 = 0,coil2 = 0;
//温度
short Temp = 0;
void led_ctrl()
{
if(it_1000ms_flag == 1)
{
it_1000ms_flag = 0;
HAL_GPIO_TogglePin(GPIO_LED_GPIO_Port,GPIO_LED_Pin);
Temp = ds18b20_get_temp(); //环境温度
InputReg[19] = Temp;
}
}
void digital_ctrl()
{
led_ctrl();//指示灯
//八位DO输出控制
PE2_DO1((GPIO_PinState)((CoilState[0]>>0)&0x01));
PE3_DO2((GPIO_PinState)((CoilState[0]>>1)&0x01));
PE4_DO3((GPIO_PinState)((CoilState[0]>>2)&0x01));
PE5_DO4((GPIO_PinState)((CoilState[0]>>3)&0x01));
PE6_DO5((GPIO_PinState)((CoilState[0]>>4)&0x01));
PC13_DO6((GPIO_PinState)((CoilState[0]>>5)&0x01));
PC14_DO7((GPIO_PinState)((CoilState[0]>>6)&0x01));
PC15_DO8((GPIO_PinState)((CoilState[0]>>7)&0x01));
coil1 = coil2;
coil2 = CoilState[2];
//当有595级联的时候先发的数据会级联到第二块595芯片中
if(coil1 != coil2)
{
hc595_write_data(CoilState[2]);
hc595_write_data(CoilState[1]);
disp_out();
}
else
{
hc595_write_data(CoilState[1]);
disp_out();
}
if((CoilState[3]>>0)&0x01)
{
//laser_handle.state = LASER_OPEN_STATUS;
CoilState[3] -= 0x01;
}
if((CoilState[3]>>1)&0x01)
{
//flow_state = 0;
CoilState[3] -= 0x02;
}
if((CoilState[3]>>2)&0x01)
{
__HAL_TIM_SetCounter(&htim1, 0x9718); //编码器初始值一千万
cnt_update = 152;
CoilState[3] -= 0x04;
}
DisState[0] = (_74hc165_read_byte()>>8) & 0x00FF;
DisState[1] = _74hc165_read_byte() & 0x00FF;
DisState[2] = DI_NAMUR1 + DI_NAMUR2 * 2;
}