调压器io设置
This commit is contained in:
parent
8058ad615e
commit
9d0e953107
|
@ -0,0 +1,38 @@
|
|||
---
|
||||
BasedOnStyle: Microsoft
|
||||
Language: Cpp
|
||||
|
||||
###################################
|
||||
# indent conf
|
||||
###################################
|
||||
|
||||
UseTab: Never
|
||||
IndentWidth: 4
|
||||
TabWidth: 4
|
||||
ColumnLimit: 0
|
||||
AccessModifierOffset: -4
|
||||
NamespaceIndentation: All
|
||||
FixNamespaceComments: false
|
||||
BreakBeforeBraces: Allman
|
||||
|
||||
###################################
|
||||
# other styles
|
||||
###################################
|
||||
|
||||
#
|
||||
# for more conf, you can ref: https://clang.llvm.org/docs/ClangFormatStyleOptions.html
|
||||
#
|
||||
|
||||
AllowShortIfStatementsOnASingleLine: true
|
||||
|
||||
AllowShortLoopsOnASingleLine: true
|
||||
|
||||
AllowShortBlocksOnASingleLine: true
|
||||
|
||||
IndentCaseLabels: true
|
||||
|
||||
SortIncludes: false
|
||||
|
||||
AlignConsecutiveMacros: AcrossEmptyLines
|
||||
|
||||
AlignConsecutiveAssignments: Consecutive
|
17
.cproject
17
.cproject
|
@ -14,7 +14,7 @@
|
|||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release" cleanCommand="${cross_rm} -rf" description="" id="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.release.1008047074" name="obj" parent="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.release">
|
||||
<configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release" cleanCommand="${cross_rm} -rf" description="" id="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.release.1008047074" name="obj" parent="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.release" postbuildStep=" ${cross_prefix}${cross_objcopy}${cross_suffix} -O ihex "${ProjName}.elf" "${ProjName}.hex" && ${cross_prefix}${cross_objcopy}${cross_suffix} -O binary "${ProjName}.elf" "${ProjName}.bin"">
|
||||
<folderInfo id="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.release.1008047074." name="/" resourcePath="">
|
||||
<toolChain id="ilg.gnumcueclipse.managedbuild.cross.riscv.toolchain.elf.release.231146001" name="RISC-V Cross GCC" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.toolchain.elf.release">
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.createflash.1311852988" name="Create flash image" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.createflash" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
|
@ -47,7 +47,7 @@
|
|||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.atomic.985553432" name="Atomic extension (RVA)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.atomic" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.nocommon.1193890948" name="No common unitialized (-fno-common)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.nocommon" value="true" valueType="boolean"/>
|
||||
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="ilg.gnumcueclipse.managedbuild.cross.riscv.targetPlatform.1944008784" isAbstract="false" osList="all" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.targetPlatform"/>
|
||||
<builder buildPath="${workspace_loc:/BLE_TYQ_CH592F}/obj" id="ilg.gnumcueclipse.managedbuild.cross.riscv.builder.1421508906" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.builder"/>
|
||||
<builder buildPath="${workspace_loc:/BLE_TYQ_CH592F}/obj" id="ilg.gnumcueclipse.managedbuild.cross.riscv.builder.1421508906" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="GNU Make 构建器" parallelBuildOn="true" parallelizationNumber="optimal" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.builder"/>
|
||||
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler.1244756189" name="GNU RISC-V Cross Assembler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler">
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.usepreprocessor.1692176068" name="Use preprocessor" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.usepreprocessor" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="true" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.include.paths.1034038285" name="Include paths (-I)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.include.paths" useByScannerDiscovery="true" valueType="includePath"/>
|
||||
|
@ -56,8 +56,8 @@
|
|||
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.1731377187" name="GNU RISC-V Cross C Compiler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler">
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.include.paths.1567947810" name="Include paths (-I)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.include.paths" useByScannerDiscovery="true" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/Startup}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/APP/include}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/Profile/include}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/APP/include}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/StdPeriphDriver/inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/HAL/include}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/Ld}""/>
|
||||
|
@ -66,7 +66,8 @@
|
|||
</option>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.std.2020844713" name="Language standard" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.std" useByScannerDiscovery="true" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.std.gnu99" valueType="enumerated"/>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.defs.177116515" name="Defined symbols (-D)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.defs" useByScannerDiscovery="true" valueType="definedSymbols">
|
||||
<listOptionValue builtIn="false" value="DEBUG=1"/>
|
||||
<listOptionValue builtIn="false" value="DEBUG=0"/>
|
||||
<listOptionValue builtIn="false" value="CLK_OSC32K=0"/>
|
||||
</option>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="true" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.include.files.288896968" name="Include files (-include)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.include.files" useByScannerDiscovery="true" valueType="includeFiles"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.preprocessonly.1594987158" name="Preprocess only (-E)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.preprocessonly" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
|
@ -115,7 +116,9 @@
|
|||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.usenewlibnano.1540675679" name="Use newlib-nano (--specs=nano.specs)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.usenewlibnano" value="true" valueType="boolean"/>
|
||||
</tool>
|
||||
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.archiver.1292785366" name="GNU RISC-V Cross Archiver" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.archiver"/>
|
||||
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.createflash.1801165667" name="GNU RISC-V Cross Create Flash Image" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.createflash"/>
|
||||
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.createflash.1801165667" name="GNU RISC-V Cross Create Flash Image" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.createflash">
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.choice.777102436" name="Output file format (-O)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.choice" useByScannerDiscovery="false" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.choice.ihexAndbinary" valueType="enumerated"/>
|
||||
</tool>
|
||||
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.createlisting.1356766765" name="GNU RISC-V Cross Create Listing" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.createlisting">
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.source.2052761852" name="Display source (--source|-S)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.source" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.allheaders.439659821" name="Display all headers (--all-headers|-x)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.allheaders" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
|
@ -139,7 +142,7 @@
|
|||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Profile"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="RVMSIS"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Startup"/>
|
||||
<entry excluding="CH59x_pwm.c|CH59x_usbdev.c|CH59x_usbhostClass.c|CH59x_usbhostBase.c|CH59x_spi0.c|CH59x_timer0.c|CH59x_timer1.c|CH59x_timer2.c|CH59x_timer3.c|CH59x_uart0.c|CH59x_uart2.c|CH59x_uart3.c" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="StdPeriphDriver"/>
|
||||
<entry excluding="CH59x_pwm.c|CH59x_usbdev.c|CH59x_usbhostClass.c|CH59x_usbhostBase.c|CH59x_spi0.c|CH59x_timer0.c|CH59x_timer1.c|CH59x_timer2.c|CH59x_timer3.c|CH59x_uart2.c|CH59x_uart3.c" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="StdPeriphDriver"/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
|
@ -161,5 +164,5 @@
|
|||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
|
||||
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
|
||||
|
||||
<storageModule moduleId="refreshScope"/>
|
||||
</cproject>
|
||||
|
|
38
.project
38
.project
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>BLE_TYQ_CH592F</name>
|
||||
<comment/>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
|
@ -23,42 +23,10 @@
|
|||
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
|
||||
</natures>
|
||||
<linkedResources>
|
||||
<link>
|
||||
<name>HAL</name>
|
||||
<type>2</type>
|
||||
<locationURI>PARENT-1-PROJECT_LOC/HAL</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>LIB</name>
|
||||
<type>2</type>
|
||||
<locationURI>PARENT-1-PROJECT_LOC/LIB</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>Ld</name>
|
||||
<type>2</type>
|
||||
<locationURI>PARENT-2-PROJECT_LOC/SRC/Ld</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>RVMSIS</name>
|
||||
<type>2</type>
|
||||
<locationURI>PARENT-2-PROJECT_LOC/SRC/RVMSIS</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>Startup</name>
|
||||
<type>2</type>
|
||||
<locationURI>PARENT-2-PROJECT_LOC/SRC/Startup</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>StdPeriphDriver</name>
|
||||
<type>2</type>
|
||||
<locationURI>PARENT-2-PROJECT_LOC/SRC/StdPeriphDriver</locationURI>
|
||||
</link>
|
||||
</linkedResources>
|
||||
<filteredResources>
|
||||
<filter>
|
||||
<id>1602468250279</id>
|
||||
<name/>
|
||||
<name></name>
|
||||
<type>22</type>
|
||||
<matcher>
|
||||
<id>org.eclipse.ui.ide.multiFilter</id>
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<project>
|
||||
<configuration id="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.release.1008047074" name="obj">
|
||||
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
|
||||
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
||||
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
||||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
||||
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="-714121590444630656" id="ilg.gnumcueclipse.managedbuild.cross.riscv.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT RISC-V Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
||||
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
||||
<language-scope id="org.eclipse.cdt.core.g++"/>
|
||||
</provider>
|
||||
</extension>
|
||||
</configuration>
|
||||
</project>
|
|
@ -40,23 +40,23 @@
|
|||
#define SBP_PHY_UPDATE_DELAY 2400
|
||||
|
||||
// What is the advertising interval when device is discoverable (units of 625us, 80=50ms)
|
||||
#define DEFAULT_ADVERTISING_INTERVAL 80
|
||||
#define DEFAULT_ADVERTISING_INTERVAL (160 * 10)
|
||||
|
||||
// Limited discoverable mode advertises for 30.72s, and then stops
|
||||
// General discoverable mode advertises indefinitely
|
||||
#define DEFAULT_DISCOVERABLE_MODE GAP_ADTYPE_FLAGS_GENERAL
|
||||
|
||||
// Minimum connection interval (units of 1.25ms, 6=7.5ms)
|
||||
#define DEFAULT_DESIRED_MIN_CONN_INTERVAL 6
|
||||
#define DEFAULT_DESIRED_MIN_CONN_INTERVAL (100)
|
||||
|
||||
// Maximum connection interval (units of 1.25ms, 100=125ms)
|
||||
#define DEFAULT_DESIRED_MAX_CONN_INTERVAL 100
|
||||
#define DEFAULT_DESIRED_MAX_CONN_INTERVAL 400
|
||||
|
||||
// Slave latency to use parameter update
|
||||
#define DEFAULT_DESIRED_SLAVE_LATENCY 0
|
||||
#define DEFAULT_DESIRED_SLAVE_LATENCY 5
|
||||
|
||||
// Supervision timeout value (units of 10ms, 100=1s)
|
||||
#define DEFAULT_DESIRED_CONN_TIMEOUT 100
|
||||
#define DEFAULT_DESIRED_CONN_TIMEOUT 200
|
||||
|
||||
// Company Identifier: WCH
|
||||
#define WCH_COMPANY_ID 0x07D7
|
||||
|
|
|
@ -60,10 +60,37 @@ int main(void)
|
|||
GPIOA_ModeCfg(GPIO_Pin_All, GPIO_ModeIN_PU);
|
||||
GPIOB_ModeCfg(GPIO_Pin_All, GPIO_ModeIN_PU);
|
||||
#endif
|
||||
|
||||
// 12V_EN
|
||||
GPIOA_ResetBits(GPIO_Pin_13);
|
||||
GPIOA_ModeCfg(GPIO_Pin_13, GPIO_ModeOut_PP_5mA);
|
||||
|
||||
// EMV_CTRL
|
||||
GPIOB_ResetBits(GPIO_Pin_13);
|
||||
GPIOB_ModeCfg(GPIO_Pin_13, GPIO_ModeIN_PD);
|
||||
|
||||
// LED
|
||||
GPIOA_ResetBits(GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_15);
|
||||
GPIOA_ModeCfg(GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_15, GPIO_ModeIN_PD);
|
||||
|
||||
// KEY
|
||||
GPIOB_SetBits(GPIO_Pin_14);
|
||||
// ÓÉÍⲿÉÏÀµç×èÁË
|
||||
GPIOB_ModeCfg(GPIO_Pin_14, GPIO_ModeIN_Floating);
|
||||
|
||||
// ADC_VBAT
|
||||
// GPIOAGPPCfg(ENABLE, RB_PIN_PA4_15_DIS);
|
||||
// R16_PIN_ANALOG_IE != RB_PIN_PA4_15_DIS;
|
||||
|
||||
// R32_PIN_CONFIG2
|
||||
|
||||
// GPIOA_ResetBits(GPIO_Pin_1);
|
||||
GPIOA_ModeCfg(GPIO_Pin_14, GPIO_ModeIN_Floating);
|
||||
|
||||
#ifdef DEBUG
|
||||
GPIOA_SetBits(bTXD1);
|
||||
GPIOA_ModeCfg(bTXD1, GPIO_ModeOut_PP_5mA);
|
||||
UART1_DefInit();
|
||||
GPIOB_SetBits(bTXD0);
|
||||
GPIOB_ModeCfg(bTXD0, GPIO_ModeOut_PP_5mA);
|
||||
UART0_DefInit();
|
||||
#endif
|
||||
PRINT("%s\n", VER_LIB);
|
||||
CH59x_BLEInit();
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
#ifndef __BSP_TIM_H__
|
||||
#define __BSP_TIM_H__
|
||||
|
||||
|
||||
#include "CH59x_common.h"
|
||||
|
||||
|
||||
|
||||
uint32_t BSP_Get_Tick(void);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif //!@__BSP_TIM_H__
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
#ifndef __BSP_UART_H__
|
||||
#define __BSP_UART_H__
|
||||
|
||||
|
||||
#include "CH585SFR.h"
|
||||
|
||||
|
||||
#define UART3_RX_PIN GPIO_Pin_20 //PB20 ÈÕÖ¾´òÓ¡
|
||||
#define UART3_TX_PIN GPIO_Pin_21 // PB21
|
||||
|
||||
|
||||
void BSP_UART1_Init(void);
|
||||
unsigned int BSP_Uart1_Receive_Data(void *buf, unsigned int len);
|
||||
unsigned int BSP_Uart1_Send_Data(const void *buf, unsigned int len);
|
||||
|
||||
void BSP_UART3_Init(void);
|
||||
unsigned int BSP_Uart3_Receive_Data(void *buf, unsigned int len);
|
||||
unsigned int BSP_Uart3_Send_Data(const void *buf, unsigned int len);
|
||||
void BSP_Shell_Loop(void);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
#include "bsp_tim.h"
|
||||
|
||||
// tick_1ms_cnt在SysTick_Handler()中1ms +1
|
||||
volatile uint32_t tick_1ms_cnt = 0;
|
||||
|
||||
/**
|
||||
* @description: 以SysTick(1ms)为基础
|
||||
* @return {uint32_t}
|
||||
*/
|
||||
uint32_t BSP_Get_Tick(void)
|
||||
{
|
||||
/* Platform implementation */
|
||||
return tick_1ms_cnt;
|
||||
}
|
||||
|
||||
// SysTick中断函数
|
||||
__INTERRUPT
|
||||
__HIGH_CODE
|
||||
void SysTick_Handler()
|
||||
{
|
||||
static uint8_t cnt_ms = 0;
|
||||
|
||||
SysTick->SR = 0; // 清除中断标志
|
||||
tick_1ms_cnt++;
|
||||
|
||||
cnt_ms++;
|
||||
}
|
|
@ -0,0 +1,228 @@
|
|||
#include "bsp_uart.h"
|
||||
#include "bsp_ml307r.h"
|
||||
#include "lwrb.h"
|
||||
#include "CH58x_uart.h"
|
||||
#include "shell_port.h"
|
||||
|
||||
|
||||
|
||||
|
||||
#define UART1_RX_BUFFER_LENGTH 512U
|
||||
#define UART1_TX_BUFFER_LENGTH 512U
|
||||
|
||||
#define UART3_RX_BUFFER_LENGTH 1024U
|
||||
#define UART3_TX_BUFFER_LENGTH 1024U
|
||||
|
||||
|
||||
lwrb_t uart1_rx_t;
|
||||
lwrb_t uart1_tx_t;
|
||||
uint8_t uart1_tx_buf[UART1_TX_BUFFER_LENGTH] = {0};
|
||||
uint8_t uart1_rx_buf[UART1_RX_BUFFER_LENGTH] = {0};
|
||||
|
||||
lwrb_t uart3_rx_t;
|
||||
lwrb_t uart3_tx_t;
|
||||
uint8_t uart3_tx_buf[UART3_TX_BUFFER_LENGTH] = {0};
|
||||
uint8_t uart3_rx_buf[UART3_RX_BUFFER_LENGTH] = {0};
|
||||
|
||||
|
||||
//串口接收
|
||||
unsigned int BSP_Uart1_Receive_Data(void *buf, unsigned int len)
|
||||
{
|
||||
return lwrb_read(&uart1_rx_t, buf, len);
|
||||
}
|
||||
|
||||
//串口发送数据
|
||||
unsigned int BSP_Uart1_Send_Data(const void *buf, unsigned int len)
|
||||
{
|
||||
unsigned int ret;
|
||||
|
||||
ret = lwrb_write(&uart1_tx_t, buf, len);
|
||||
UART1_INTCfg(ENABLE, RB_IER_THR_EMPTY);
|
||||
return ret;
|
||||
}
|
||||
|
||||
//串口接收
|
||||
unsigned int BSP_Uart3_Receive_Data(void *buf, unsigned int len)
|
||||
{
|
||||
return lwrb_write(&uart3_rx_t, buf, len);
|
||||
}
|
||||
|
||||
//串口发送数据
|
||||
unsigned int BSP_Uart3_Send_Data(const void *buf, unsigned int len)
|
||||
{
|
||||
unsigned int ret;
|
||||
|
||||
ret = lwrb_write(&uart3_tx_t, buf, len);
|
||||
UART3_INTCfg(ENABLE, RB_IER_THR_EMPTY);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Buffer event function
|
||||
*/
|
||||
static void Uart1_evt_fn(struct lwrb* buff, lwrb_evt_type_t evt, lwrb_sz_t bp)
|
||||
{
|
||||
switch (evt)
|
||||
{
|
||||
case LWRB_EVT_RESET:
|
||||
printf("[EVT] Buffer reset event!\r\n");
|
||||
break;
|
||||
case LWRB_EVT_READ:
|
||||
printf("[EVT] Buffer read event: %d byte(s)!\r\n", (int)bp);
|
||||
break;
|
||||
case LWRB_EVT_WRITE:
|
||||
printf("[EVT] Buffer write event: %d byte(s)!\r\n", (int)bp);
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
void UART1_FifoInit(void)
|
||||
{
|
||||
lwrb_init(&uart1_tx_t, uart1_tx_buf, sizeof(uart1_tx_buf));
|
||||
lwrb_init(&uart1_rx_t, uart1_rx_buf, sizeof(uart1_rx_buf));
|
||||
|
||||
// lwrb_set_evt_fn(&uart1_rx_t, Uart1_evt_fn);
|
||||
}
|
||||
|
||||
void UART3_FifoInit(void)
|
||||
{
|
||||
lwrb_init(&uart3_tx_t, uart3_tx_buf, sizeof(uart3_tx_buf));
|
||||
lwrb_init(&uart3_rx_t, uart3_rx_buf, sizeof(uart3_rx_buf));
|
||||
|
||||
lwrb_set_evt_fn(&uart1_rx_t, Uart1_evt_fn);
|
||||
}
|
||||
|
||||
/*4G接口*/
|
||||
void BSP_UART1_Init(void)
|
||||
{
|
||||
GPIOPinRemap(ENABLE, RB_PIN_UART1);
|
||||
|
||||
/* 配置串口1:先配置IO口模式,再配置串口 */
|
||||
GPIOB_SetBits(ML307_UART_RX_PIN);
|
||||
GPIOB_ModeCfg(ML307_UART_RX_PIN, GPIO_ModeIN_PU); // RXD-配置上拉输入
|
||||
GPIOB_ModeCfg(ML307_UART_TX_PIN, GPIO_ModeOut_PP_5mA); // TXD-配置推挽输出,注意先让IO口输出高电平
|
||||
UART1_DefInit();
|
||||
UART1_ByteTrigCfg(UART_1BYTE_TRIG);
|
||||
// 中断方式接收数据
|
||||
UART1_INTCfg(ENABLE, RB_IER_LINE_STAT | RB_IER_RECV_RDY | RB_IER_THR_EMPTY);
|
||||
PFIC_EnableIRQ(UART1_IRQn);
|
||||
|
||||
UART1_FifoInit();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*调试接口*/
|
||||
void BSP_UART3_Init(void)
|
||||
{
|
||||
GPIOPinRemap(ENABLE, RB_PIN_UART3);
|
||||
/* 配置串口3:先配置IO口模式,再配置串口 */
|
||||
GPIOB_SetBits(UART3_TX_PIN);
|
||||
GPIOB_ModeCfg(UART3_RX_PIN, GPIO_ModeIN_PU); // RXD-配置上拉输入
|
||||
GPIOB_ModeCfg(UART3_TX_PIN, GPIO_ModeOut_PP_5mA); // TXD-配置推挽输出,注意先让IO口输出高电平
|
||||
UART3_DefInit();
|
||||
UART3_BaudRateCfg(460800);
|
||||
UART3_ByteTrigCfg(UART_1BYTE_TRIG);
|
||||
// 中断方式接收数据
|
||||
UART3_INTCfg(ENABLE, RB_IER_LINE_STAT | RB_IER_RECV_RDY | RB_IER_THR_EMPTY);
|
||||
PFIC_EnableIRQ(UART3_IRQn);
|
||||
|
||||
UART3_FifoInit();
|
||||
userShellInit();
|
||||
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn UART1_IRQHandler
|
||||
*
|
||||
* @brief UART1中断函数
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
__INTERRUPT
|
||||
__HIGH_CODE
|
||||
void UART1_IRQHandler(void)
|
||||
{
|
||||
uint8_t data;
|
||||
switch(UART1_GetITFlag())
|
||||
{
|
||||
case UART_II_LINE_STAT: // 线路状态错误
|
||||
{
|
||||
// UART1_GetLinSTA();
|
||||
break;
|
||||
}
|
||||
case UART_II_RECV_RDY:
|
||||
data = UART1_RecvByte();
|
||||
lwrb_write(&uart1_rx_t, &data, 1);
|
||||
break;
|
||||
case UART_II_RECV_TOUT: // 接收数据
|
||||
break;
|
||||
|
||||
case UART_II_THR_EMPTY: // 发送缓存区空,可继续发送
|
||||
if(lwrb_read(&uart1_tx_t, &data, 1))
|
||||
{
|
||||
UART1_SendByte(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
UART1_INTCfg(DISABLE, RB_IER_THR_EMPTY);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case UART_II_MODEM_CHG: // 只支持串口0
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn UART3_IRQHandler
|
||||
*
|
||||
* @brief UART1中断函数
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
__INTERRUPT
|
||||
__HIGH_CODE
|
||||
void UART3_IRQHandler(void)
|
||||
{
|
||||
uint8_t data;
|
||||
switch(UART3_GetITFlag())
|
||||
{
|
||||
case UART_II_LINE_STAT: // 线路状态错误
|
||||
{
|
||||
// UART1_GetLinSTA();
|
||||
break;
|
||||
}
|
||||
case UART_II_RECV_RDY:
|
||||
case UART_II_RECV_TOUT: //接收超时
|
||||
while(R8_UART3_RFC)
|
||||
{
|
||||
shellHandler(&shell, R8_UART3_RBR);
|
||||
}
|
||||
break;
|
||||
case UART_II_THR_EMPTY: // 发送缓存区空,可继续发送
|
||||
if(lwrb_get_full(&uart3_tx_t))
|
||||
{
|
||||
lwrb_read(&uart3_tx_t, &data, 1);
|
||||
UART3_SendByte(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
UART3_INTCfg(DISABLE, RB_IER_THR_EMPTY);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case UART_II_MODEM_CHG: // 只支持串口0
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
24
HAL/SLEEP.c
24
HAL/SLEEP.c
|
@ -31,31 +31,43 @@ uint32_t CH59x_LowPower(uint32_t time)
|
|||
unsigned long irq_status;
|
||||
|
||||
// 提前唤醒
|
||||
if (time <= WAKE_UP_RTC_MAX_TIME) {
|
||||
if (time <= WAKE_UP_RTC_MAX_TIME)
|
||||
{
|
||||
time = time + (RTC_MAX_COUNT - WAKE_UP_RTC_MAX_TIME);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
time = time - WAKE_UP_RTC_MAX_TIME;
|
||||
}
|
||||
|
||||
SYS_DisableAllIrq(&irq_status);
|
||||
time_curr = RTC_GetCycle32k();
|
||||
// 检测睡眠时间
|
||||
if (time < time_curr) {
|
||||
if (time < time_curr)
|
||||
{
|
||||
time_sleep = time + (RTC_MAX_COUNT - time_curr);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
time_sleep = time - time_curr;
|
||||
}
|
||||
|
||||
// 若睡眠时间小于最小睡眠时间或大于最大睡眠时间,则不睡眠
|
||||
if ((time_sleep < SLEEP_RTC_MIN_TIME) ||
|
||||
(time_sleep > SLEEP_RTC_MAX_TIME)) {
|
||||
(time_sleep > SLEEP_RTC_MAX_TIME))
|
||||
{
|
||||
SYS_RecoverIrq(irq_status);
|
||||
return 2;
|
||||
}
|
||||
|
||||
RTC_SetTignTime(time);
|
||||
SYS_RecoverIrq(irq_status);
|
||||
#if(DEBUG == Debug_UART1) // 使用其他串口输出打印信息需要修改这行代码
|
||||
#if (DEBUG == Debug_UART0) // 使用其他串口输出打印信息需要修改这行代码
|
||||
while ((R8_UART0_LSR & RB_LSR_TX_ALL_EMP) == 0)
|
||||
{
|
||||
__nop();
|
||||
}
|
||||
#elif (DEBUG == Debug_UART1) // 使用其他串口输出打印信息需要修改这行代码
|
||||
while ((R8_UART1_LSR & RB_LSR_TX_ALL_EMP) == 0)
|
||||
{
|
||||
__nop();
|
||||
|
|
|
@ -79,10 +79,10 @@
|
|||
#define BLE_MAC FALSE
|
||||
#endif
|
||||
#ifndef DCDC_ENABLE
|
||||
#define DCDC_ENABLE FALSE
|
||||
#define DCDC_ENABLE TRUE
|
||||
#endif
|
||||
#ifndef HAL_SLEEP
|
||||
#define HAL_SLEEP FALSE
|
||||
#define HAL_SLEEP TRUE
|
||||
#endif
|
||||
#ifndef SLEEP_RTC_MIN_TIME
|
||||
#define SLEEP_RTC_MIN_TIME US_TO_RTC(1000)
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
*/
|
||||
void UART0_DefInit(void)
|
||||
{
|
||||
UART0_BaudRateCfg(115200);
|
||||
UART0_BaudRateCfg(460800);
|
||||
R8_UART0_FCR = (2 << 6) | RB_FCR_TX_FIFO_CLR | RB_FCR_RX_FIFO_CLR | RB_FCR_FIFO_EN; // FIFO打开,触发点4字节
|
||||
R8_UART0_LCR = RB_LCR_WORD_SZ;
|
||||
R8_UART0_IER = RB_IER_TXD_EN;
|
||||
|
|
Loading…
Reference in New Issue