acdt/users/Src/gpios.c

54 lines
1.2 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"
uint8_t coil1 = 0,coil2 = 0;
void led_ctrl()
{
if(it_1000ms_flag == 1)
{
HAL_GPIO_TogglePin(GPIO_LED_GPIO_Port,GPIO_LED_Pin);
it_1000ms_flag = 0;
}
}
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();
}
DisState[0] = (_74hc165_read_byte()>>8) & 0x00FF;
DisState[1] = _74hc165_read_byte() & 0x00FF;
DisState[2] = DI_NAMUR1 + DI_NAMUR2 * 2;
//encoder reset
if( ((CoilState[3]>>7)&0x01) == 1 ) //CoilState[3]的D7位地址0x28
{
encoder_init();
}
}