Compare commits

..

No commits in common. "4d6eb106863d7ec374ee4257d328c275dad8ad22" and "ea9e742e72fc6fe4f440b7eff418e042958750e2" have entirely different histories.

9 changed files with 125 additions and 187 deletions

View File

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

View File

@ -1,38 +0,0 @@
#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);
}

View File

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

View File

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

View File

@ -607,14 +607,34 @@
</Group> </Group>
<Group> <Group>
<GroupName>BSP</GroupName> <GroupName>Doc</GroupName>
<tvExp>1</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel> <cbSel>0</cbSel>
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
<File> <File>
<GroupNumber>6</GroupNumber> <GroupNumber>6</GroupNumber>
<FileNumber>27</FileNumber> <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>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
<File>
<GroupNumber>7</GroupNumber>
<FileNumber>28</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -625,8 +645,8 @@
<bShared>0</bShared> <bShared>0</bShared>
</File> </File>
<File> <File>
<GroupNumber>6</GroupNumber> <GroupNumber>7</GroupNumber>
<FileNumber>28</FileNumber> <FileNumber>29</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -637,8 +657,8 @@
<bShared>0</bShared> <bShared>0</bShared>
</File> </File>
<File> <File>
<GroupNumber>6</GroupNumber> <GroupNumber>7</GroupNumber>
<FileNumber>29</FileNumber> <FileNumber>30</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
@ -648,18 +668,6 @@
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
<bShared>0</bShared> <bShared>0</bShared>
</File> </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>
<Group> <Group>
@ -669,7 +677,7 @@
<cbSel>0</cbSel> <cbSel>0</cbSel>
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
<File> <File>
<GroupNumber>7</GroupNumber> <GroupNumber>8</GroupNumber>
<FileNumber>31</FileNumber> <FileNumber>31</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
@ -681,7 +689,7 @@
<bShared>0</bShared> <bShared>0</bShared>
</File> </File>
<File> <File>
<GroupNumber>7</GroupNumber> <GroupNumber>8</GroupNumber>
<FileNumber>32</FileNumber> <FileNumber>32</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
@ -693,7 +701,7 @@
<bShared>0</bShared> <bShared>0</bShared>
</File> </File>
<File> <File>
<GroupNumber>7</GroupNumber> <GroupNumber>8</GroupNumber>
<FileNumber>33</FileNumber> <FileNumber>33</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
@ -705,7 +713,7 @@
<bShared>0</bShared> <bShared>0</bShared>
</File> </File>
<File> <File>
<GroupNumber>7</GroupNumber> <GroupNumber>8</GroupNumber>
<FileNumber>34</FileNumber> <FileNumber>34</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
@ -717,7 +725,7 @@
<bShared>0</bShared> <bShared>0</bShared>
</File> </File>
<File> <File>
<GroupNumber>7</GroupNumber> <GroupNumber>8</GroupNumber>
<FileNumber>35</FileNumber> <FileNumber>35</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
@ -729,7 +737,7 @@
<bShared>0</bShared> <bShared>0</bShared>
</File> </File>
<File> <File>
<GroupNumber>7</GroupNumber> <GroupNumber>8</GroupNumber>
<FileNumber>36</FileNumber> <FileNumber>36</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
@ -741,7 +749,7 @@
<bShared>0</bShared> <bShared>0</bShared>
</File> </File>
<File> <File>
<GroupNumber>7</GroupNumber> <GroupNumber>8</GroupNumber>
<FileNumber>37</FileNumber> <FileNumber>37</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
@ -752,54 +760,6 @@
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
<bShared>0</bShared> <bShared>0</bShared>
</File> </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>
<Group> <Group>
@ -809,10 +769,10 @@
<cbSel>0</cbSel> <cbSel>0</cbSel>
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
<File> <File>
<GroupNumber>8</GroupNumber> <GroupNumber>9</GroupNumber>
<FileNumber>42</FileNumber> <FileNumber>38</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\..\CHIRP\ultrasound\src\ultrasound_display_config_info.c</PathWithFileName> <PathWithFileName>..\..\CHIRP\ultrasound\src\ultrasound_display_config_info.c</PathWithFileName>

View File

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

View File

@ -35,7 +35,6 @@ OF SUCH DAMAGE.
#include "gd32e23x_it.h" #include "gd32e23x_it.h"
#include "main.h" #include "main.h"
#include "systick.h" #include "systick.h"
#include "chirp_bsp.h"
/*! /*!
\brief this function handles NMI exception \brief this function handles NMI exception
@ -105,26 +104,4 @@ void EXTI4_15_IRQHandler(void){
exti_interrupt_flag_clear(EXTI_7); exti_interrupt_flag_clear(EXTI_7);
} }
}
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,9 +1,42 @@
/*!
\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 "gd32e23x.h"
#include "systick.h" #include "systick.h"
#include <stdio.h> #include <stdio.h>
#include "main.h" #include "main.h"
// #include "gd32e230c_eval.h" // #include "gd32e230c_eval.h"
#include "timer.h"
#include "board_init.h" #include "board_init.h"
#include "chirp_board_config.h" #include "chirp_board_config.h"
#include "chirp_bsp.h" #include "chirp_bsp.h"
@ -244,12 +277,10 @@ int main(void)
} }
printf("Starting measurements\n"); printf("Starting measurements\n");
timer_config();
while (1) while (1)
{ {
handle_data_ready(grp_ptr); handle_data_ready(grp_ptr);
// chbsp_led_toggle(dev_num); chbsp_led_toggle(dev_num);
delay_ms(MEASUREMENT_INTERVAL_MS); delay_ms(MEASUREMENT_INTERVAL_MS);
} }
} }
@ -389,8 +420,7 @@ static uint8_t handle_data_ready(ch_group_t *grp_ptr) {
chirp_data[dev_num].amplitude = 0; /* no updated amplitude */ 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 { } else {
/* Target object was successfully detected (range available) */ /* Target object was successfully detected (range available) */
@ -398,10 +428,9 @@ static uint8_t handle_data_ready(ch_group_t *grp_ptr) {
* was successfully measured. */ * was successfully measured. */
chirp_data[dev_num].amplitude = ch_get_amplitude(dev_ptr); chirp_data[dev_num].amplitude = ch_get_amplitude(dev_ptr);
// printf("Port %d: Range: %0.1f mm Amp: %u ", dev_num, printf("Port %d: Range: %0.1f mm Amp: %u ", dev_num,
// (float) chirp_data[dev_num].range/32.0f, (float) chirp_data[dev_num].range/32.0f,
// chirp_data[dev_num].amplitude); 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 */ /* Store number of active samples in this measurement */

36
XLSW_SONIC/readme.txt Normal file
View File

@ -0,0 +1,36 @@
/*!
\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.