63 lines
1.1 KiB
C
63 lines
1.1 KiB
C
/*
|
|
* @Description:
|
|
* @Version: 1.0
|
|
* @Autor: lzc
|
|
* @Date: 2022-09-09 08:31:26
|
|
* @LastEditors: lzc
|
|
* @LastEditTime: 2022-09-20 10:51:38
|
|
*/
|
|
#include "main.h"
|
|
#include "usart_send.h"
|
|
float send_d[4];
|
|
unsigned char led_times = 0;
|
|
|
|
#define ZHENG 0x03
|
|
void usart2_send_char(unsigned char c)
|
|
{
|
|
USART2->DR = c;
|
|
while ((USART2->SR & 0X40) == 0)
|
|
;
|
|
}
|
|
void sw_send_data(unsigned char *data, unsigned char len)
|
|
{
|
|
u8 i;
|
|
usart2_send_char(ZHENG);
|
|
usart2_send_char(~ZHENG);
|
|
for (i = 0; i < len; i++)
|
|
{
|
|
usart2_send_char(*data);
|
|
data++;
|
|
}
|
|
usart2_send_char(~ZHENG);
|
|
usart2_send_char(ZHENG);
|
|
}
|
|
void opm_send()
|
|
{
|
|
led_times++;
|
|
if (led_times > 10)
|
|
{
|
|
led_times = 0;
|
|
LED_B = !LED_B;
|
|
send_d[0] = ADC_1310;
|
|
send_d[1] = dbm_value_1310;
|
|
send_d[2] = (unsigned short int)(abs((int)(dbm_value_1310 * 1000)));
|
|
send_d[3] = (unsigned short int)((int)(ADC_1310 * 10000));
|
|
sw_send_data((unsigned char *)send_d, sizeof(send_d));
|
|
}
|
|
}
|
|
void cal_time()
|
|
{
|
|
BH_time++;
|
|
stage_time++;
|
|
if (BH_time >= 10 * 500)
|
|
{
|
|
BH_time = 0;
|
|
start_calculate_flg = 1;
|
|
}
|
|
if (stage_time >= 12 * 500)
|
|
{
|
|
stage_time = 0;
|
|
start_stage_flg = 1;
|
|
}
|
|
}
|