Commit 574f6c86 authored by 李梓源's avatar 李梓源

feat:一线通(暂时)

parent 9741bdae
......@@ -167,6 +167,12 @@ void RTE_GPIO_Init(void)
gpio_temp.enGPIODir = GPIO_DIR_IN;
gpio_temp.enGPIOAltFun = GPIO_ALTER_FUN_1;
GPIO_Config(&gpio_temp);
gpio_temp.enGPIOPort = GPIO_PORT_GROUP_0;
gpio_temp.enGPIOPIN = GPIO_PIN_8;
gpio_temp.enGPIOMode = GPIO_MODE_PORT;
gpio_temp.enGPIODir = GPIO_DIR_OUT;
gpio_temp.enGPIOAltFun = GPIO_ALTER_FUN_1;
GPIO_Config(&gpio_temp);
// queren = 0;
// LINE_OUT_NEG_01 = 1;
// LINE_OUT_NEG_02 = 1;
......
......@@ -40,6 +40,8 @@
#define ZXSW_AD GPIO_IN_APORT00_PIN13
#define ZYS_B GPIO_IN_APORT00_PIN14 //坐桶锁B
#define ZYS_A GPIO_IN_APORT00_PIN15 //坐桶锁A
#define TX_OUT GPIO_OUT_PORT00_PIN08 //一线通TX输出
/* ---------------------旧的-------------------------- */
......
......@@ -478,6 +478,7 @@ void Sys_Run_Mode_100ms_Tasks_Group(void)
/*==============================================================================
��ȷ��50us��ʱ���� ��ֹ�����޸��б��е�����
------------------------------------------------------------------------------*/
uint8_t flag_sync;
uint8_t flag_1;
uint8_t flag_0;
uint8_t flag_fin;
......@@ -487,7 +488,32 @@ void Sys_Exact_50us_Tasks(void)
static uint8_t flag1_flag = 0;
static uint8_t flag0_count = 0;
static uint8_t flag0_flag = 0;
static uint32_t flag_fin_count = 0;
static uint16_t flag_fin_count = 0;
static uint8_t sync_flag = 0;
static uint16_t sync_count = 0;
if(flag_sync == 1)
{
if(sync_count < 220)
{
sync_count++;
}
else
{
sync_count = 0;
flag_sync = 0;
}
if(sync_count < 200)
{
TX_OUT = 1;
}
else if (sync_count < 20)
{
TX_OUT = 0;
}
return;
}
if(flag_1 == 1)
{
......@@ -503,11 +529,11 @@ void Sys_Exact_50us_Tasks(void)
if(flag1_count < 30)
{
// set_pin_high();
TX_OUT = 1;
}
else if (flag1_count < 40)
{
// set_pin_low();
TX_OUT = 0;
}
}
......@@ -525,11 +551,11 @@ void Sys_Exact_50us_Tasks(void)
if(flag0_count < 10)
{
// set_pin_high();
TX_OUT = 1;
}
else if (flag0_count < 40)
{
// set_pin_low();
TX_OUT = 0;
}
}
......@@ -547,17 +573,39 @@ void Sys_Exact_50us_Tasks(void)
if(flag_fin_count < 10)
{
// set_pin_high();
TX_OUT = 1;
}
else if (flag_fin_count < 40)
{
// set_pin_low();
TX_OUT = 0;
}
}
GenDelay_Tick( );
DoCAN_Timer_Update(50u);
}
// 发送单个比特(逻辑"1"或"0")
void send_bit(uint8_t bit) {
if (bit) {
flag_1 = 1;
} else {
flag_0 = 1;
}
}
// 发送完整数据(按字节发送,高位优先)
void send_data(const uint8_t *data, uint32_t len) {
flag_sync == 1; // 发送同步信号
for (uint32_t i = 0; i < len; i++) {
uint8_t byte = data[i];
for (int j = 7; j >= 0; j--) { // 高位先发
send_bit((byte >> j) & 0x01);
}
}
flag_fin == 1; // 发送停止信号
}
/*============================================================================*/
/*******************************************************************************
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment