Compare commits

...

10 Commits

Author SHA1 Message Date
wanghao
4d6eb10686 add readme 2024-09-02 14:33:45 +08:00
wanghao
c363c5fb85 adaptation for vofa+(FireWater) 2024-08-30 14:47:36 +08:00
wanghao
c2950b3055 add sr_narrow & change to sr_narrow 2024-08-30 10:08:15 +08:00
wanghao
a168d30241 check 2024-08-29 16:17:13 +08:00
wanghao
14dd173c31 GPR_SR FW OK 2024-08-28 16:35:08 +08:00
wanghao
3b1a24d8a1 test commit 2024-08-28 11:49:57 +08:00
wanghao
de349ebdf6 done 2024-08-28 11:42:05 +08:00
wanghao
fedc3042be change led to timer int 2024-08-14 17:02:31 +08:00
wanghao
27a1f5624e timer int LED 2024-08-09 16:34:11 +08:00
hulk
673db2d79f rm doc 2024-08-09 08:43:39 +08:00
9 changed files with 187 additions and 125 deletions

View File

@ -57,7 +57,7 @@
*/
/* CH101 GPR - general purpose rangefinding, standard range */
#define CHIRP_SENSOR_FW_INIT_FUNC ch101_gpr_init
// #define CHIRP_SENSOR_FW_INIT_FUNC ch101_gpr_init
/* CH101 GPR NARROW - general purpose rangefinding, narrow FoV */
// #define CHIRP_SENSOR_FW_INIT_FUNC ch101_gpr_narrow_init
@ -66,7 +66,7 @@
// #define CHIRP_SENSOR_FW_INIT_FUNC ch101_gpr_sr_init
/* CH101 GPR SR NARROW - general purpose rangefinding, short range, narrow FoV */
// #define CHIRP_SENSOR_FW_INIT_FUNC ch101_gpr_sr_narrow_init
#define CHIRP_SENSOR_FW_INIT_FUNC ch101_gpr_sr_narrow_init
/* CH201 GPRMT - general purpose rangefinding / multi threshold */
// #define CHIRP_SENSOR_FW_INIT_FUNC ch201_gprmt_init
@ -81,14 +81,14 @@
* here is greater than the maximum possible range, the maximum possible range
* will be used.
*/
#define CHIRP_SENSOR_MAX_RANGE_MM (750) /* maximum range, in mm */
#define CHIRP_SENSOR_MAX_RANGE_MM (250) /* maximum range, in mm */
/* Static target rejection range
* This value specifies if static target rejection (STR) will be used. If
* CHIRP_SENSOR_STATIC_RANGE is non-zero, STR will be enabled and will apply
* to the specified number of samples at the beginning of a measurement.
*/
#define CHIRP_SENSOR_STATIC_RANGE (100) /* static target rejection sample
#define CHIRP_SENSOR_STATIC_RANGE (40) /* static target rejection sample
range, in samples (0=disabled) */

38
CHIRP/board/timer.c Normal file
View File

@ -0,0 +1,38 @@
#include <stdio.h>
#include <stdint.h>
#include "gd32e23x.h"
#include "timer.h"
#include "gd32e23x.h"
#include "chirp_board_config.h"
#include "board_init.h"
void timer_config(void)
{
timer_oc_parameter_struct timer_ocinitpara;
timer_parameter_struct timer_initpara;
rcu_periph_clock_enable(RCU_TIMER2);
timer_deinit(TIMER2);
timer_struct_para_init(&timer_initpara);
timer_initpara.prescaler = (8) - 1;
timer_initpara.alignedmode = TIMER_COUNTER_EDGE;
timer_initpara.counterdirection = TIMER_COUNTER_UP;
timer_initpara.period = 19999;
timer_initpara.clockdivision = TIMER_CKDIV_DIV1;
timer_initpara.repetitioncounter = 0;
timer_init(TIMER2, &timer_initpara);
timer_initpara.period = 9999;
timer_init(TIMER2, &timer_initpara);
timer_channel_output_struct_para_init(&timer_ocinitpara);
timer_ocinitpara.outputstate = TIMER_CCX_ENABLE;
timer_ocinitpara.ocpolarity = TIMER_OC_POLARITY_HIGH;
timer_ocinitpara.ocidlestate = TIMER_OC_IDLE_STATE_LOW;
timer_channel_output_config(TIMER2, TIMER_CH_0, &timer_ocinitpara);
timer_auto_reload_shadow_enable(TIMER2);
timer_interrupt_enable(TIMER2, TIMER_INT_CH0);
timer_enable(TIMER2);
nvic_irq_enable(TIMER2_IRQn, 2);
}

6
CHIRP/board/timer.h Normal file
View File

@ -0,0 +1,6 @@
#ifndef TIMER_H
#define TIMER_H
void timer_config(void);
#endif /* TIMER_H */

5
README.md Normal file
View File

@ -0,0 +1,5 @@
# XLSW CH101 Code Project
> branch: ch101_sr_narrow
窄FoV声学喇叭短距固件有效距离8-25cm。

View File

@ -606,26 +606,6 @@
</File>
</Group>
<Group>
<GroupName>Doc</GroupName>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>27</FileNumber>
<FileType>5</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\readme.txt</PathWithFileName>
<FilenameWithoutPath>readme.txt</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group>
<Group>
<GroupName>BSP</GroupName>
<tvExp>1</tvExp>
@ -633,8 +613,8 @@
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
<File>
<GroupNumber>7</GroupNumber>
<FileNumber>28</FileNumber>
<GroupNumber>6</GroupNumber>
<FileNumber>27</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@ -645,8 +625,8 @@
<bShared>0</bShared>
</File>
<File>
<GroupNumber>7</GroupNumber>
<FileNumber>29</FileNumber>
<GroupNumber>6</GroupNumber>
<FileNumber>28</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@ -657,8 +637,8 @@
<bShared>0</bShared>
</File>
<File>
<GroupNumber>7</GroupNumber>
<FileNumber>30</FileNumber>
<GroupNumber>6</GroupNumber>
<FileNumber>29</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@ -668,6 +648,18 @@
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>30</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\CHIRP\board\timer.c</PathWithFileName>
<FilenameWithoutPath>timer.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group>
<Group>
@ -677,7 +669,7 @@
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
<File>
<GroupNumber>8</GroupNumber>
<GroupNumber>7</GroupNumber>
<FileNumber>31</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
@ -689,7 +681,7 @@
<bShared>0</bShared>
</File>
<File>
<GroupNumber>8</GroupNumber>
<GroupNumber>7</GroupNumber>
<FileNumber>32</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
@ -701,7 +693,7 @@
<bShared>0</bShared>
</File>
<File>
<GroupNumber>8</GroupNumber>
<GroupNumber>7</GroupNumber>
<FileNumber>33</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
@ -713,7 +705,7 @@
<bShared>0</bShared>
</File>
<File>
<GroupNumber>8</GroupNumber>
<GroupNumber>7</GroupNumber>
<FileNumber>34</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
@ -725,7 +717,7 @@
<bShared>0</bShared>
</File>
<File>
<GroupNumber>8</GroupNumber>
<GroupNumber>7</GroupNumber>
<FileNumber>35</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
@ -737,7 +729,7 @@
<bShared>0</bShared>
</File>
<File>
<GroupNumber>8</GroupNumber>
<GroupNumber>7</GroupNumber>
<FileNumber>36</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
@ -749,7 +741,7 @@
<bShared>0</bShared>
</File>
<File>
<GroupNumber>8</GroupNumber>
<GroupNumber>7</GroupNumber>
<FileNumber>37</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
@ -760,6 +752,54 @@
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>7</GroupNumber>
<FileNumber>38</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\CHIRP\drivers\src\ch101_gpr_sr.c</PathWithFileName>
<FilenameWithoutPath>ch101_gpr_sr.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>7</GroupNumber>
<FileNumber>39</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\CHIRP\drivers\src\ch101_gpr_sr_fw.c</PathWithFileName>
<FilenameWithoutPath>ch101_gpr_sr_fw.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>7</GroupNumber>
<FileNumber>40</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\CHIRP\drivers\src\ch101_gpr_sr_narrow.c</PathWithFileName>
<FilenameWithoutPath>ch101_gpr_sr_narrow.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>7</GroupNumber>
<FileNumber>41</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\CHIRP\drivers\src\ch101_gpr_sr_narrow_fw.c</PathWithFileName>
<FilenameWithoutPath>ch101_gpr_sr_narrow_fw.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group>
<Group>
@ -769,10 +809,10 @@
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
<File>
<GroupNumber>9</GroupNumber>
<FileNumber>38</FileNumber>
<GroupNumber>8</GroupNumber>
<FileNumber>42</FileNumber>
<FileType>1</FileType>
<tvExp>1</tvExp>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\CHIRP\ultrasound\src\ultrasound_display_config_info.c</PathWithFileName>

View File

@ -535,16 +535,6 @@
</File>
</Files>
</Group>
<Group>
<GroupName>Doc</GroupName>
<Files>
<File>
<FileName>readme.txt</FileName>
<FileType>5</FileType>
<FilePath>..\readme.txt</FilePath>
</File>
</Files>
</Group>
<Group>
<GroupName>BSP</GroupName>
<Files>
@ -563,6 +553,11 @@
<FileType>1</FileType>
<FilePath>..\..\CHIRP\board\i2c.c</FilePath>
</File>
<File>
<FileName>timer.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\CHIRP\board\timer.c</FilePath>
</File>
</Files>
</Group>
<Group>
@ -603,6 +598,26 @@
<FileType>1</FileType>
<FilePath>..\..\CHIRP\drivers\src\chbsp_dummy.c</FilePath>
</File>
<File>
<FileName>ch101_gpr_sr.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\CHIRP\drivers\src\ch101_gpr_sr.c</FilePath>
</File>
<File>
<FileName>ch101_gpr_sr_fw.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\CHIRP\drivers\src\ch101_gpr_sr_fw.c</FilePath>
</File>
<File>
<FileName>ch101_gpr_sr_narrow.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\CHIRP\drivers\src\ch101_gpr_sr_narrow.c</FilePath>
</File>
<File>
<FileName>ch101_gpr_sr_narrow_fw.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\CHIRP\drivers\src\ch101_gpr_sr_narrow_fw.c</FilePath>
</File>
</Files>
</Group>
<Group>

View File

@ -35,6 +35,7 @@ OF SUCH DAMAGE.
#include "gd32e23x_it.h"
#include "main.h"
#include "systick.h"
#include "chirp_bsp.h"
/*!
\brief this function handles NMI exception
@ -105,3 +106,25 @@ void EXTI4_15_IRQHandler(void){
}
}
int i = 0;
/**
* @brief This function handles TIMER2 interrupt request.
* @param None
* @retval None
*/
void TIMER2_IRQHandler(void)
{
if (SET == timer_interrupt_flag_get(TIMER2, TIMER_INT_FLAG_CH0))
{
i++;
timer_interrupt_flag_clear(TIMER2, TIMER_INT_FLAG_CH0);
if (i == 10)
{
chbsp_led_toggle(0);
i = 0;
}
}
}

View File

@ -1,42 +1,9 @@
/*!
\file main.c
\brief led spark with systick, USART print and key example
\version 2023-02-27, V1.2.0, firmware for GD32E23x
*/
/*
Copyright (c) 2023, GigaDevice Semiconductor Inc.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
#include "gd32e23x.h"
#include "systick.h"
#include <stdio.h>
#include "main.h"
// #include "gd32e230c_eval.h"
#include "timer.h"
#include "board_init.h"
#include "chirp_board_config.h"
#include "chirp_bsp.h"
@ -277,10 +244,12 @@ int main(void)
}
printf("Starting measurements\n");
timer_config();
while (1)
{
handle_data_ready(grp_ptr);
chbsp_led_toggle(dev_num);
// chbsp_led_toggle(dev_num);
delay_ms(MEASUREMENT_INTERVAL_MS);
}
}
@ -420,7 +389,8 @@ static uint8_t handle_data_ready(ch_group_t *grp_ptr) {
chirp_data[dev_num].amplitude = 0; /* no updated amplitude */
printf("Port %d: no target found ", dev_num);
// printf("Port %d: no target found ", dev_num);
printf("UltraSnoic0:%0.1f, %u\n", 0.0, 0);
} else {
/* Target object was successfully detected (range available) */
@ -428,9 +398,10 @@ static uint8_t handle_data_ready(ch_group_t *grp_ptr) {
* was successfully measured. */
chirp_data[dev_num].amplitude = ch_get_amplitude(dev_ptr);
printf("Port %d: Range: %0.1f mm Amp: %u ", dev_num,
(float) chirp_data[dev_num].range/32.0f,
chirp_data[dev_num].amplitude);
// printf("Port %d: Range: %0.1f mm Amp: %u ", dev_num,
// (float) chirp_data[dev_num].range/32.0f,
// chirp_data[dev_num].amplitude);
printf("UltraSnoic0:%0.1f, %u\n", (float) chirp_data[dev_num].range/32.0f, chirp_data[dev_num].amplitude);
}
/* Store number of active samples in this measurement */

View File

@ -1,36 +0,0 @@
/*!
\file readme.txt
\brief description of led spark with systick, USART print and key example
\version 2023-02-27, V1.2.0, firmware for GD32E23x
*/
/*
Copyright (c) 2023, GigaDevice Semiconductor Inc.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
This example is based on the GD32E230C-EVAL-V1.1 board, it provides a
description of SysTick configuration, use of EVAL_COM and key.