zhyinch
2019-07-13 d1563a9cafa83f7b4932e7885d5cb1b52f108375
广州200套出货程序,修改通讯时间参数
已修改9个文件
107 ■■■■■ 文件已修改
源码/核心板/Src/ExternalDevices/beep.c 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
源码/核心板/Src/ExternalDevices/beep.h 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
源码/核心板/Src/OnChipDevices/ADC.c 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
源码/核心板/Src/OnChipDevices/ADC.h 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
源码/核心板/Src/application/dw_app.c 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
源码/核心板/Src/application/dw_app.h 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
源码/核心板/Src/application/global_param.c 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
源码/核心板/Src/main.c 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
源码/核心板/Src/stm32f10x_it.c 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Ô´Âë/ºËÐİå/Src/ExternalDevices/beep.c
@@ -7,21 +7,26 @@
    /* Enable GPIO clock */
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,ENABLE);
    // Enable GPIO used for beep
    GPIO_InitStructure.GPIO_Pin = BEEP_PIN;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_Init(BEEP_GPIO, &GPIO_InitStructure);
      GPIO_InitStructure.GPIO_Pin = KEY0_PIN;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
    GPIO_Init(KEY0_GPIO, &GPIO_InitStructure);
    
    // Enable GPIO used for beep
    GPIO_InitStructure.GPIO_Pin = BEEP2_PIN;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_Init(BEEP2_GPIO, &GPIO_InitStructure);
    // Enable GPIO used for OUT
    GPIO_InitStructure.GPIO_Pin = OUT2_PIN;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_Init(OUT2_GPIO, &GPIO_InitStructure);
//    // Enable GPIO used for beep
//    GPIO_InitStructure.GPIO_Pin = BEEP_PIN;
//    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
//    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
//    GPIO_Init(BEEP_GPIO, &GPIO_InitStructure);
//
//    // Enable GPIO used for beep
//    GPIO_InitStructure.GPIO_Pin = BEEP2_PIN;
//    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
//    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
//    GPIO_Init(BEEP2_GPIO, &GPIO_InitStructure);
//
//    // Enable GPIO used for OUT
//    GPIO_InitStructure.GPIO_Pin = OUT2_PIN;
//    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
//    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
//    GPIO_Init(OUT2_GPIO, &GPIO_InitStructure);
}
Ô´Âë/ºËÐİå/Src/ExternalDevices/beep.h
@@ -4,6 +4,10 @@
#include "stm32f10x.h"
#define KEY0_PIN                    GPIO_Pin_14
#define KEY0_GPIO                    GPIOB
#define    READ_KEY0                 GPIO_ReadInputDataBit(KEY0_GPIO,KEY0_PIN)
#define BEEP_PIN                    GPIO_Pin_6
#define BEEP_GPIO                    GPIOB
#define BEEP_ON                        GPIO_WriteBit(BEEP_GPIO, BEEP_PIN, Bit_SET)
Ô´Âë/ºËÐİå/Src/OnChipDevices/ADC.c
@@ -11,6 +11,7 @@
    
ADC_DeInit(ADC1);//??
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1,ENABLE);
ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;//ADC1?ADC2????,????
ADC_InitStructure.ADC_ContinuousConvMode = DISABLE;//ADC????,????????
ADC_InitStructure.ADC_ScanConvMode = DISABLE;   //ADC?????(ENABLE??????)
@@ -41,12 +42,20 @@
float bat_volt;
uint8_t Get_Battary(void)
{static float last_value = 100;
static u8 first=1;
    bat_volt = (float)Get_ADC_Value()/621;  //(value/4096*3.3*2-3.5)/0.7
    if(bat_volt>=3.5)
    {
        if(first)
        {
        first = 0;
            last_value =(bat_volt-3.5)*143;
        }
    last_value = 0.9*last_value + (bat_volt-3.5)*14.3;
    if(last_value>100)
        last_value = 100;
    if(last_value<0)
        last_value = 0;
}
    return last_value;    
}
Ô´Âë/ºËÐİå/Src/OnChipDevices/ADC.h
@@ -3,5 +3,6 @@
#define __ADC_H__
#include "stm32f10x.h"
extern uint8_t Get_Battary(void);
extern void ADC_Configuration(void);
#endif
Ô´Âë/ºËÐİå/Src/application/dw_app.c
@@ -46,9 +46,9 @@
#define POLL_TX_TO_RESP_RX_DLY_UUS 150
/* This is the delay from Frame RX timestamp to TX reply timestamp used for calculating/setting the DW1000's delayed TX function. This includes the
 * frame length of approximately 2.66 ms with above configuration. */
#define RESP_RX_TO_FINAL_TX_DLY_UUS 1500
#define RESP_RX_TO_FINAL_TX_DLY_UUS 400
/* Receive response timeout. See NOTE 5 below. */
#define RESP_RX_TIMEOUT_UUS 2700
#define RESP_RX_TIMEOUT_UUS 600
#define POLL_RX_TO_RESP_TX_DLY_UUS 420
/* This is the delay from the end of the frame transmission to the enable of the receiver, as programmed for the DW1000's wait for response feature. */
@@ -93,7 +93,7 @@
};
/* Frames used in the ranging process. See NOTE 2 below. */
static uint8_t tx_poll_msg[18] = {0};
static uint8_t tx_poll_msg[19] = {0};
//static uint8_t rx_resp_msg[] = {0x41, 0x88, 0, 0xCA, 0xDE, 'V', 'E', 'W', 'A', 0x10, 0x02, 0, 0, 0, 0};
static uint8_t tx_final_msg[] = {0x41, 0x88, 0, 0xCA, 0xDE, 'W', 'A', 'V', 'E', 0x23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
    
@@ -300,12 +300,14 @@
    uint32_t final_tx_time;
    u32 start_poll;
    u8 i;
    LED0_ON;
    g_Resttimer=0;
    GPIO_ResetBits(SPIx_GPIO, SPIx_CS);
    delay_us(2500);
    GPIO_SetBits(SPIx_GPIO, SPIx_CS);
    tag_succ_times = 0;
    tx_poll_msg[BATTARY_IDX] = Get_Battary();
    tx_poll_msg[BUTTON_IDX] = !READ_KEY0;
    for(i=0;i<REPOET_ANC_NUM;i++)
    {
    /* Write frame data to DW1000 and prepare transmission. See NOTE 7 below. */
@@ -477,6 +479,8 @@
            dwt_writetxfctrl(sizeof(tx_resp_msg), 0);//设定发送长度
            result = dwt_starttx(DWT_START_TX_DELAYED | DWT_RESPONSE_EXPECTED);//延迟发送,等待接收
            battary = rx_buffer[BATTARY_IDX];
            button = rx_buffer[BUTTON_IDX];
            /* We assume that the transmission is achieved correctly, now poll for reception of expected "final" frame or error/timeout.
             * See NOTE 7 below. */
            if(result==0)
@@ -548,8 +552,11 @@
//                        printf("Pair Finish PairID: %d. \r\n",g_com_map[PAIR_ID]);
//                    }
                    // tag_time_recv[tag_id_recv] = tag_recv_timer;
                        if(tag_id_recv-TAG_ID_START<=TOTAL_TAG_NUM)
                        {
                    g_flag_Taggetdist[tag_id_recv-TAG_ID_START]=0;
                    anchor_dist_last_frm[tag_id_recv-TAG_ID_START] = dist_cm;
                        }
                    #ifdef HEX_OUTPUT
                    usart_send[2] = frame_seq_nb++;
                    //usart_send[6] = tag_id_recv;
@@ -564,7 +571,7 @@
                    memcpy(&usart_send[21],&checksum,2);
                    UART_PushFrame(usart_send,23);
                    #else
                    printf("Anchor ID: %d, Tag ID: %d, Dist = %d cm\n", g_com_map[DEV_ID], tag_id_recv, (uint16_t)dis_after_filter);
                    printf("Anchor ID: %d, Tag ID: %d, Dist = %d cm\n", g_com_map[DEV_ID_L]|g_com_map[DEV_ID_L]<<8, tag_id_recv, (uint16_t)dist_cm);
                    #endif
                    
                    //dis_after_filter = LP_Frac_Update(p_Dis_Filter, dist_cm);
Ô´Âë/ºËÐİå/Src/application/dw_app.h
@@ -4,12 +4,12 @@
#include "stm32f10x.h"
#include "filters.h"
#include "ADC.h"
//#define WORK_MODE_TAG
#define WORK_MODE_ANCHOR
//#define NEWBOARD
#define TAG_OUTPUT
//#define TAG_OUTPUT
#define HEX_OUTPUT
#define REPOET_ANC_NUM 6
Ô´Âë/ºËÐİå/Src/application/global_param.c
@@ -25,12 +25,12 @@
    if(g_com_map[0] != 0x55AA)
    {
        g_com_map[0] = 0x55AA;
        g_com_map[ALARM_DISTANCE1] = 100;    //默认报警距离50cm
        g_com_map[ALARM_DISTANCE2] = 600;    //默认报警距离50cm
        g_com_map[ALARM_DISTANCE3] = 900;    //默认报警距离50cm
        g_com_map[ALARM_DEV] = 1;
        g_com_map[DEV_ID_L] =0x9b;//DEFAULT_DEV_ID;    //默认设备ID
        g_com_map[DEV_ID_H] =0x76;//DEFAULT_DEV_ID;    //默认设备ID
//        g_com_map[ALARM_DISTANCE1] = 100;    //默认报警距离50cm
//        g_com_map[ALARM_DISTANCE2] = 600;    //默认报警距离50cm
//        g_com_map[ALARM_DISTANCE3] = 900;    //默认报警距离50cm
//        g_com_map[ALARM_DEV] = 1;
        g_com_map[DEV_ID_L] =0xdb;//DEFAULT_DEV_ID;    //默认设备ID
        g_com_map[DEV_ID_H] =0x00;//DEFAULT_DEV_ID;    //默认设备ID
        g_com_map[COM_INTERVAL]=1000;
        save_com_map_to_flash();
    }    
Ô´Âë/ºËÐİå/Src/main.c
@@ -9,7 +9,7 @@
#include "stm32f10x_it.h"
#include "serial_at_cmd_app.h"
#include "global_param.h"
#include "ADC.h"
void Device_Init(void)
@@ -23,7 +23,7 @@
    DW_GPIO_Init();
    Uart1_Init();
    Spi_Init();
    ADC_Configuration();
    
    GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE);
}
@@ -33,6 +33,7 @@
{uint16_t i;
    Usart1ParseDataCallback = UsartParseDataHandler;
    parameter_init();
    deca_sleep(1000);
    dev_id = g_com_map[DEV_ID_H]<<16|g_com_map[DEV_ID_L];
    #ifdef WORK_MODE_TAG    
    printf("标签ID: %d .\r\n",dev_id);
@@ -89,7 +90,7 @@
        Tag_App();
    }
//    UART_CheckReceive();
    PWR_EnterSTOPMode(PWR_Regulator_LowPower, PWR_STOPEntry_WFI);
    //PWR_EnterSTOPMode(PWR_Regulator_LowPower, PWR_STOPEntry_WFI);
#else 
        Anchor_App();
#endif
Ô´Âë/ºËÐİå/Src/stm32f10x_it.c
@@ -49,12 +49,12 @@
//    {    
//        dis_after_filter = DEFAULT_DISTANCE;
//    }
#ifdef WORK_MODE_ANCHOR
    tag_recv_timer++;
    TagDistClear();
    if(g_pairstart!=1)
        main_logic();
#endif
//#ifdef WORK_MODE_ANCHOR
    //tag_recv_timer++;
//    TagDistClear();
//    if(g_pairstart!=1)
//        main_logic();
//#endif
}