mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2025-01-18 11:43:34 +08:00
[serial] 优化dma接收处理流程,解耦驱动调用串口框架的API接口
This commit is contained in:
parent
d94be14df5
commit
fac3c5cda1
@ -342,37 +342,42 @@ static void dma_recv_isr(struct rt_serial_device *serial, rt_uint8_t isr_flag)
|
||||
{
|
||||
struct stm32_uart *uart;
|
||||
rt_base_t level;
|
||||
rt_uint16_t recv_len = 0;
|
||||
rt_size_t recv_len, counter;
|
||||
|
||||
RT_ASSERT(serial != RT_NULL);
|
||||
uart = rt_container_of(serial, struct stm32_uart, serial);
|
||||
|
||||
struct rt_serial_rx_fifo *rx_fifo;
|
||||
rx_fifo = (struct rt_serial_rx_fifo *) serial->serial_rx;
|
||||
RT_ASSERT(rx_fifo != RT_NULL);
|
||||
|
||||
level = rt_hw_interrupt_disable();
|
||||
rt_uint16_t index = __HAL_DMA_GET_COUNTER(&(uart->dma_rx.handle));
|
||||
recv_len = 0;
|
||||
counter = __HAL_DMA_GET_COUNTER(&(uart->dma_rx.handle));
|
||||
|
||||
switch (isr_flag)
|
||||
{
|
||||
|
||||
case UART_RX_DMA_IT_TC_FLAG:
|
||||
if(index >= uart->dma_rx.remaining_cnt)
|
||||
recv_len = serial->config.rx_bufsz + uart->dma_rx.remaining_cnt - index;
|
||||
case UART_RX_DMA_IT_IDLE_FLAG:
|
||||
if (counter <= uart->dma_rx.remaining_cnt)
|
||||
recv_len = uart->dma_rx.remaining_cnt - counter;
|
||||
else
|
||||
recv_len = serial->config.rx_bufsz + uart->dma_rx.remaining_cnt - counter;
|
||||
break;
|
||||
|
||||
case UART_RX_DMA_IT_HT_FLAG:
|
||||
case UART_RX_DMA_IT_IDLE_FLAG:
|
||||
if(index < uart->dma_rx.remaining_cnt)
|
||||
recv_len = uart->dma_rx.remaining_cnt - index;
|
||||
if (counter < uart->dma_rx.remaining_cnt)
|
||||
recv_len = uart->dma_rx.remaining_cnt - counter;
|
||||
break;
|
||||
|
||||
case UART_RX_DMA_IT_TC_FLAG:
|
||||
if(counter >= uart->dma_rx.remaining_cnt)
|
||||
recv_len = serial->config.rx_bufsz + uart->dma_rx.remaining_cnt - counter;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
uart->dma_rx.remaining_cnt = index;
|
||||
rt_serial_update_write_index(&(rx_fifo->rb), recv_len);
|
||||
if (recv_len)
|
||||
{
|
||||
uart->dma_rx.remaining_cnt = counter;
|
||||
rt_hw_serial_isr(serial, RT_SERIAL_EVENT_RX_DMADONE | (recv_len << 8));
|
||||
}
|
||||
rt_hw_interrupt_enable(level);
|
||||
|
||||
}
|
||||
@ -444,7 +449,6 @@ static void uart_isr(struct rt_serial_device *serial)
|
||||
&& (__HAL_UART_GET_IT_SOURCE(&(uart->handle), UART_IT_IDLE) != RESET))
|
||||
{
|
||||
dma_recv_isr(serial, UART_RX_DMA_IT_IDLE_FLAG);
|
||||
rt_hw_serial_isr(serial, RT_SERIAL_EVENT_RX_IND);
|
||||
__HAL_UART_CLEAR_IDLEFLAG(&uart->handle);
|
||||
}
|
||||
#endif
|
||||
@ -1051,9 +1055,7 @@ void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
|
||||
struct stm32_uart *uart;
|
||||
RT_ASSERT(huart != NULL);
|
||||
uart = (struct stm32_uart *)huart;
|
||||
|
||||
dma_recv_isr(&uart->serial, UART_RX_DMA_IT_TC_FLAG);
|
||||
rt_hw_serial_isr(&uart->serial, RT_SERIAL_EVENT_RX_DMADONE);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1068,15 +1070,13 @@ void HAL_UART_RxHalfCpltCallback(UART_HandleTypeDef *huart)
|
||||
struct stm32_uart *uart;
|
||||
RT_ASSERT(huart != NULL);
|
||||
uart = (struct stm32_uart *)huart;
|
||||
|
||||
dma_recv_isr(&uart->serial, UART_RX_DMA_IT_HT_FLAG);
|
||||
rt_hw_serial_isr(&uart->serial, RT_SERIAL_EVENT_RX_DMADONE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief HAL_UART_TxCpltCallback
|
||||
* @param huart: UART handle
|
||||
* @note This callback can be called by two functions, first in UART_EndTransmit_IT when
|
||||
* @note This callback can be called by two functions, first in UART_EndTransmit_IT when
|
||||
* UART Tx complete and second in UART_DMATransmitCplt function in DMA Circular mode.
|
||||
* @retval None
|
||||
*/
|
||||
|
@ -197,21 +197,7 @@ CONFIG_RT_USING_PIN=y
|
||||
# CONFIG_RT_USING_RYM is not set
|
||||
# CONFIG_RT_USING_ULOG is not set
|
||||
# CONFIG_RT_USING_UTEST is not set
|
||||
CONFIG_RT_USING_RT_LINK=y
|
||||
CONFIG_RT_LINK_USING_SF_CRC=y
|
||||
# CONFIG_RT_LINK_USING_HW_CRC is not set
|
||||
|
||||
#
|
||||
# rt-link hardware device configuration
|
||||
#
|
||||
CONFIG_RT_LINK_HW_DEVICE_NAME="uart2"
|
||||
CONFIG_RT_LINK_USING_UART=y
|
||||
|
||||
#
|
||||
# rt link debug option
|
||||
#
|
||||
# CONFIG_USING_RT_LINK_DEBUG is not set
|
||||
# CONFIG_USING_RT_LINK_HW_DEBUG is not set
|
||||
# CONFIG_RT_USING_RT_LINK is not set
|
||||
# CONFIG_RT_USING_LWP is not set
|
||||
|
||||
#
|
||||
|
@ -1,7 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||
<Project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_projx.xsd">
|
||||
|
||||
<SchemaVersion>2.1</SchemaVersion>
|
||||
|
||||
<Header>### uVision Project, (C) Keil Software</Header>
|
||||
|
||||
<Targets>
|
||||
<Target>
|
||||
<TargetName>rt-thread</TargetName>
|
||||
@ -13,31 +16,31 @@
|
||||
<TargetCommonOption>
|
||||
<Device>STM32L475VETx</Device>
|
||||
<Vendor>STMicroelectronics</Vendor>
|
||||
<PackID>Keil.STM32L4xx_DFP.2.0.0</PackID>
|
||||
<PackID>Keil.STM32L4xx_DFP.2.2.0</PackID>
|
||||
<PackURL>http://www.keil.com/pack</PackURL>
|
||||
<Cpu>IRAM(0x20000000,0x00018000) IRAM2(0x10000000,0x00008000) IROM(0x08000000,0x00080000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLE</Cpu>
|
||||
<FlashUtilSpec />
|
||||
<StartupFile />
|
||||
<FlashUtilSpec></FlashUtilSpec>
|
||||
<StartupFile></StartupFile>
|
||||
<FlashDriverDll>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32L4xx_512 -FS08000000 -FL080000 -FP0($$Device:STM32L475VETx$CMSIS\Flash\STM32L4xx_512.FLM))</FlashDriverDll>
|
||||
<DeviceId>0</DeviceId>
|
||||
<RegisterFile>$$Device:STM32L475VETx$Drivers\CMSIS\Device\ST\STM32L4xx\Include\stm32l4xx.h</RegisterFile>
|
||||
<MemoryEnv />
|
||||
<Cmp />
|
||||
<Asm />
|
||||
<Linker />
|
||||
<OHString />
|
||||
<InfinionOptionDll />
|
||||
<SLE66CMisc />
|
||||
<SLE66AMisc />
|
||||
<SLE66LinkerMisc />
|
||||
<MemoryEnv></MemoryEnv>
|
||||
<Cmp></Cmp>
|
||||
<Asm></Asm>
|
||||
<Linker></Linker>
|
||||
<OHString></OHString>
|
||||
<InfinionOptionDll></InfinionOptionDll>
|
||||
<SLE66CMisc></SLE66CMisc>
|
||||
<SLE66AMisc></SLE66AMisc>
|
||||
<SLE66LinkerMisc></SLE66LinkerMisc>
|
||||
<SFDFile>$$Device:STM32L475VETx$CMSIS\SVD\STM32L4x5.svd</SFDFile>
|
||||
<bCustSvd>0</bCustSvd>
|
||||
<UseEnv>0</UseEnv>
|
||||
<BinPath />
|
||||
<IncludePath />
|
||||
<LibPath />
|
||||
<RegisterFilePath />
|
||||
<DBRegisterFilePath />
|
||||
<BinPath></BinPath>
|
||||
<IncludePath></IncludePath>
|
||||
<LibPath></LibPath>
|
||||
<RegisterFilePath></RegisterFilePath>
|
||||
<DBRegisterFilePath></DBRegisterFilePath>
|
||||
<TargetStatus>
|
||||
<Error>0</Error>
|
||||
<ExitCodeStop>0</ExitCodeStop>
|
||||
@ -59,8 +62,8 @@
|
||||
<BeforeCompile>
|
||||
<RunUserProg1>0</RunUserProg1>
|
||||
<RunUserProg2>0</RunUserProg2>
|
||||
<UserProg1Name />
|
||||
<UserProg2Name />
|
||||
<UserProg1Name></UserProg1Name>
|
||||
<UserProg2Name></UserProg2Name>
|
||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
||||
<nStopU1X>0</nStopU1X>
|
||||
@ -69,8 +72,8 @@
|
||||
<BeforeMake>
|
||||
<RunUserProg1>0</RunUserProg1>
|
||||
<RunUserProg2>0</RunUserProg2>
|
||||
<UserProg1Name />
|
||||
<UserProg2Name />
|
||||
<UserProg1Name></UserProg1Name>
|
||||
<UserProg2Name></UserProg2Name>
|
||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
||||
<nStopB1X>0</nStopB1X>
|
||||
@ -80,14 +83,14 @@
|
||||
<RunUserProg1>1</RunUserProg1>
|
||||
<RunUserProg2>0</RunUserProg2>
|
||||
<UserProg1Name>fromelf --bin !L --output rtthread.bin</UserProg1Name>
|
||||
<UserProg2Name />
|
||||
<UserProg2Name></UserProg2Name>
|
||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
||||
<nStopA1X>0</nStopA1X>
|
||||
<nStopA2X>0</nStopA2X>
|
||||
</AfterMake>
|
||||
<SelectedForBatchBuild>0</SelectedForBatchBuild>
|
||||
<SVCSIdString />
|
||||
<SVCSIdString></SVCSIdString>
|
||||
</TargetCommonOption>
|
||||
<CommonProperty>
|
||||
<UseCPPCompiler>0</UseCPPCompiler>
|
||||
@ -101,8 +104,8 @@
|
||||
<AssembleAssemblyFile>0</AssembleAssemblyFile>
|
||||
<PublicsOnly>0</PublicsOnly>
|
||||
<StopOnExitCode>3</StopOnExitCode>
|
||||
<CustomArgument />
|
||||
<IncludeLibraryModules />
|
||||
<CustomArgument></CustomArgument>
|
||||
<IncludeLibraryModules></IncludeLibraryModules>
|
||||
<ComprImg>1</ComprImg>
|
||||
</CommonProperty>
|
||||
<DllOption>
|
||||
@ -136,10 +139,10 @@
|
||||
<bUseTDR>1</bUseTDR>
|
||||
<Flash2>BIN\UL2CM3.DLL</Flash2>
|
||||
<Flash3>"" ()</Flash3>
|
||||
<Flash4 />
|
||||
<pFcarmOut />
|
||||
<pFcarmGrp />
|
||||
<pFcArmRoot />
|
||||
<Flash4></Flash4>
|
||||
<pFcarmOut></pFcarmOut>
|
||||
<pFcarmGrp></pFcarmGrp>
|
||||
<pFcArmRoot></pFcArmRoot>
|
||||
<FcArmLst>0</FcArmLst>
|
||||
</Utilities>
|
||||
<TargetArmAds>
|
||||
@ -172,7 +175,7 @@
|
||||
<RvctClst>0</RvctClst>
|
||||
<GenPPlst>0</GenPPlst>
|
||||
<AdsCpuType>"Cortex-M4"</AdsCpuType>
|
||||
<RvctDeviceName />
|
||||
<RvctDeviceName></RvctDeviceName>
|
||||
<mOS>0</mOS>
|
||||
<uocRom>0</uocRom>
|
||||
<uocRam>0</uocRam>
|
||||
@ -181,6 +184,7 @@
|
||||
<hadXRAM>0</hadXRAM>
|
||||
<uocXRam>0</uocXRam>
|
||||
<RvdsVP>2</RvdsVP>
|
||||
<RvdsMve>0</RvdsMve>
|
||||
<hadIRAM2>1</hadIRAM2>
|
||||
<hadIROM2>0</hadIROM2>
|
||||
<StupSel>8</StupSel>
|
||||
@ -304,7 +308,7 @@
|
||||
<Size>0x8000</Size>
|
||||
</OCR_RVCT10>
|
||||
</OnChipMemories>
|
||||
<RvctStartVector />
|
||||
<RvctStartVector></RvctStartVector>
|
||||
</ArmAdsMisc>
|
||||
<Cads>
|
||||
<interw>1</interw>
|
||||
@ -331,10 +335,10 @@
|
||||
<v6WtE>0</v6WtE>
|
||||
<v6Rtti>0</v6Rtti>
|
||||
<VariousControls>
|
||||
<MiscControls />
|
||||
<MiscControls></MiscControls>
|
||||
<Define>USE_HAL_DRIVER, __RTTHREAD__, STM32L475xx</Define>
|
||||
<Undefine />
|
||||
<IncludePath>.;applications;..\..\..\libcpu\arm\common;..\..\..\libcpu\arm\cortex-m4;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\drivers\include;board;board\CubeMX_Config\Inc;board\ports;..\libraries\HAL_Drivers;..\libraries\HAL_Drivers\config;..\..\..\components\finsh;.;..\..\..\include;..\..\..\components\libc\compilers\common;..\libraries\STM32L4xx_HAL\STM32L4xx_HAL_Driver\Inc;..\libraries\STM32L4xx_HAL\CMSIS\Device\ST\STM32L4xx\Include;..\libraries\STM32L4xx_HAL\CMSIS\Include</IncludePath>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath>.;applications;..\..\..\libcpu\arm\common;..\..\..\libcpu\arm\cortex-m4;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\drivers\include;board;board\CubeMX_Config\Inc;board\ports;..\libraries\HAL_Drivers;..\libraries\HAL_Drivers\config;..\..\..\components\finsh;.;..\..\..\include;..\libraries\STM32L4xx_HAL\STM32L4xx_HAL_Driver\Inc;..\libraries\STM32L4xx_HAL\CMSIS\Device\ST\STM32L4xx\Include;..\libraries\STM32L4xx_HAL\CMSIS\Include</IncludePath>
|
||||
</VariousControls>
|
||||
</Cads>
|
||||
<Aads>
|
||||
@ -349,10 +353,10 @@
|
||||
<useXO>0</useXO>
|
||||
<uClangAs>0</uClangAs>
|
||||
<VariousControls>
|
||||
<MiscControls />
|
||||
<Define />
|
||||
<Undefine />
|
||||
<IncludePath />
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath></IncludePath>
|
||||
</VariousControls>
|
||||
</Aads>
|
||||
<LDads>
|
||||
@ -364,13 +368,13 @@
|
||||
<useFile>0</useFile>
|
||||
<TextAddressRange>0x08000000</TextAddressRange>
|
||||
<DataAddressRange>0x20000000</DataAddressRange>
|
||||
<pXoBase />
|
||||
<pXoBase></pXoBase>
|
||||
<ScatterFile>.\board\linker_scripts\link.sct</ScatterFile>
|
||||
<IncludeLibs />
|
||||
<IncludeLibsPath />
|
||||
<Misc />
|
||||
<LinkerInputFile />
|
||||
<DisabledWarnings />
|
||||
<IncludeLibs></IncludeLibs>
|
||||
<IncludeLibsPath></IncludeLibsPath>
|
||||
<Misc></Misc>
|
||||
<LinkerInputFile></LinkerInputFile>
|
||||
<DisabledWarnings></DisabledWarnings>
|
||||
</LDads>
|
||||
</TargetArmAds>
|
||||
</TargetOption>
|
||||
@ -383,39 +387,36 @@
|
||||
<FileType>1</FileType>
|
||||
<FilePath>applications\main.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>uart_sample.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>.\applications\uart_sample.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>CPU</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>backtrace.c</FileName>
|
||||
<FileName>showmem.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\libcpu\arm\common\backtrace.c</FilePath>
|
||||
<FilePath>..\..\..\libcpu\arm\common\showmem.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>div0.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\libcpu\arm\common\div0.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>showmem.c</FileName>
|
||||
<FileName>backtrace.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\libcpu\arm\common\showmem.c</FilePath>
|
||||
<FilePath>..\..\..\libcpu\arm\common\backtrace.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>cpuport.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\libcpu\arm\cortex-m4\cpuport.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>context_rvds.S</FileName>
|
||||
<FileType>2</FileType>
|
||||
@ -431,57 +432,41 @@
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\components\drivers\misc\pin.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>serial.c</FileName>
|
||||
<FileName>serial_v2.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\components\drivers\serial\serial.c</FilePath>
|
||||
<FilePath>..\..\..\components\drivers\serial\serial_v2.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>completion.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\components\drivers\src\completion.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>dataqueue.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\components\drivers\src\dataqueue.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>pipe.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\components\drivers\src\pipe.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>ringblk_buf.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\components\drivers\src\ringblk_buf.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>ringbuffer.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\components\drivers\src\ringbuffer.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>waitqueue.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\components\drivers\src\waitqueue.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>ringblk_buf.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\components\drivers\src\ringblk_buf.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>dataqueue.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\components\drivers\src\dataqueue.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>pipe.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\components\drivers\src\pipe.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>workqueue.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
@ -491,42 +476,32 @@
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>Drivers</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>board.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>board\board.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_msp.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>board\CubeMX_Config\Src\stm32l4xx_hal_msp.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>board.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>board\board.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>startup_stm32l475xx.s</FileName>
|
||||
<FileType>2</FileType>
|
||||
<FilePath>..\libraries\STM32L4xx_HAL\CMSIS\Device\ST\STM32L4xx\Source\Templates\arm\startup_stm32l475xx.s</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>drv_gpio.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\libraries\HAL_Drivers\drv_gpio.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>drv_usart.c</FileName>
|
||||
<FileName>drv_usart_v2.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\libraries\HAL_Drivers\drv_usart.c</FilePath>
|
||||
<FilePath>..\libraries\HAL_Drivers\drv_usart_v2.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>drv_common.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
@ -542,116 +517,81 @@
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\components\finsh\shell.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>cmd.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\components\finsh\cmd.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>msh.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\components\finsh\msh.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>cmd.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\components\finsh\cmd.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>Kernel</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>clock.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\src\clock.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>components.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\src\components.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>device.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\src\device.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>idle.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\src\idle.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>ipc.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\src\ipc.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>irq.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\src\irq.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>kservice.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\src\kservice.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>mem.c</FileName>
|
||||
<FileName>device.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\src\mem.c</FilePath>
|
||||
<FilePath>..\..\..\src\device.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>clock.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\src\clock.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>mempool.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\src\mempool.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>object.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\src\object.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>scheduler.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\src\scheduler.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>signal.c</FileName>
|
||||
<FileName>mem.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\src\signal.c</FilePath>
|
||||
<FilePath>..\..\..\src\mem.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>components.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\src\components.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>ipc.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\src\ipc.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>irq.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\src\irq.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>object.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\src\object.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>thread.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\src\thread.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>timer.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
@ -659,172 +599,124 @@
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>libc</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>time.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\components\libc\compilers\common\time.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>Libraries</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>system_stm32l4xx.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\libraries\STM32L4xx_HAL\CMSIS\Device\ST\STM32L4xx\Source\Templates\system_stm32l4xx.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\libraries\STM32L4xx_HAL\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_comp.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\libraries\STM32L4xx_HAL\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_comp.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_cortex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\libraries\STM32L4xx_HAL\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_cortex.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_crc.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\libraries\STM32L4xx_HAL\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_crc.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_crc_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\libraries\STM32L4xx_HAL\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_crc_ex.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_cryp.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\libraries\STM32L4xx_HAL\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_cryp.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_uart.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\libraries\STM32L4xx_HAL\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_uart.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_usart.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\libraries\STM32L4xx_HAL\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_usart.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_cortex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\libraries\STM32L4xx_HAL\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_cortex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_gpio.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\libraries\STM32L4xx_HAL\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_gpio.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_dma.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\libraries\STM32L4xx_HAL\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_dma.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_pwr.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\libraries\STM32L4xx_HAL\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_pwr.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_rcc_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\libraries\STM32L4xx_HAL\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_rcc_ex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_rcc.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\libraries\STM32L4xx_HAL\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_rcc.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_dma_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\libraries\STM32L4xx_HAL\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_dma_ex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_exti.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\libraries\STM32L4xx_HAL\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_exti.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_crc.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\libraries\STM32L4xx_HAL\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_crc.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\libraries\STM32L4xx_HAL\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_usart_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\libraries\STM32L4xx_HAL\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_usart_ex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_uart_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\libraries\STM32L4xx_HAL\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_uart_ex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_crc_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\libraries\STM32L4xx_HAL\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_crc_ex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_comp.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\libraries\STM32L4xx_HAL\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_comp.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_pwr_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\libraries\STM32L4xx_HAL\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_pwr_ex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_rng.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\libraries\STM32L4xx_HAL\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_rng.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>system_stm32l4xx.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\libraries\STM32L4xx_HAL\CMSIS\Device\ST\STM32L4xx\Source\Templates\system_stm32l4xx.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_cryp_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\libraries\STM32L4xx_HAL\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_cryp_ex.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_dma.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\libraries\STM32L4xx_HAL\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_dma.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_dma_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\libraries\STM32L4xx_HAL\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_dma_ex.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_exti.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\libraries\STM32L4xx_HAL\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_exti.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_pwr.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\libraries\STM32L4xx_HAL\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_pwr.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_pwr_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\libraries\STM32L4xx_HAL\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_pwr_ex.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_rcc.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\libraries\STM32L4xx_HAL\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_rcc.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_rcc_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\libraries\STM32L4xx_HAL\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_rcc_ex.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_rng.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\libraries\STM32L4xx_HAL\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_rng.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_gpio.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\libraries\STM32L4xx_HAL\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_gpio.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_uart.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\libraries\STM32L4xx_HAL\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_uart.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_uart_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\libraries\STM32L4xx_HAL\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_uart_ex.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_usart.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\libraries\STM32L4xx_HAL\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_usart.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_usart_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\libraries\STM32L4xx_HAL\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_usart_ex.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
</Groups>
|
||||
</Target>
|
||||
</Targets>
|
||||
|
||||
<RTE>
|
||||
<apis />
|
||||
<components />
|
||||
<files />
|
||||
<apis/>
|
||||
<components/>
|
||||
<files/>
|
||||
</RTE>
|
||||
|
||||
</Project>
|
||||
|
@ -111,16 +111,6 @@
|
||||
|
||||
/* Utilities */
|
||||
|
||||
#define RT_USING_RT_LINK
|
||||
#define RT_LINK_USING_SF_CRC
|
||||
|
||||
/* rt-link hardware device configuration */
|
||||
|
||||
#define RT_LINK_HW_DEVICE_NAME "uart2"
|
||||
#define RT_LINK_USING_UART
|
||||
|
||||
/* rt link debug option */
|
||||
|
||||
|
||||
/* RT-Thread Utestcases */
|
||||
|
||||
|
@ -112,7 +112,7 @@ struct serial_configure
|
||||
};
|
||||
|
||||
/*
|
||||
* Serial FIFO mode
|
||||
* Serial Receive FIFO mode
|
||||
*/
|
||||
struct rt_serial_rx_fifo
|
||||
{
|
||||
@ -128,6 +128,9 @@ struct rt_serial_rx_fifo
|
||||
rt_uint8_t buffer[];
|
||||
};
|
||||
|
||||
/*
|
||||
* Serial Transmit FIFO mode
|
||||
*/
|
||||
struct rt_serial_tx_fifo
|
||||
{
|
||||
struct rt_ringbuffer rb;
|
||||
@ -174,15 +177,6 @@ struct rt_uart_ops
|
||||
rt_uint32_t tx_flag);
|
||||
};
|
||||
|
||||
rt_size_t rt_serial_get_linear_buffer(struct rt_ringbuffer *rb,
|
||||
rt_uint8_t **ptr);
|
||||
|
||||
rt_size_t rt_serial_update_read_index(struct rt_ringbuffer *rb,
|
||||
rt_uint16_t read_index);
|
||||
|
||||
rt_size_t rt_serial_update_write_index(struct rt_ringbuffer *rb,
|
||||
rt_uint16_t write_index);
|
||||
|
||||
void rt_hw_serial_isr(struct rt_serial_device *serial, int event);
|
||||
|
||||
rt_err_t rt_hw_serial_register(struct rt_serial_device *serial,
|
||||
|
@ -157,7 +157,7 @@ static int serial_fops_poll(struct dfs_fd *fd, struct rt_pollreq *req)
|
||||
rx_fifo = (struct rt_serial_rx_fifo*) serial->serial_rx;
|
||||
|
||||
level = rt_hw_interrupt_disable();
|
||||
|
||||
|
||||
if (rt_ringbuffer_data_len(&rx_fifo->rb))
|
||||
mask |= POLLIN;
|
||||
rt_hw_interrupt_enable(level);
|
||||
@ -180,8 +180,8 @@ const static struct dfs_file_ops _serial_fops =
|
||||
};
|
||||
#endif
|
||||
|
||||
rt_size_t rt_serial_get_linear_buffer(struct rt_ringbuffer *rb,
|
||||
rt_uint8_t **ptr)
|
||||
static rt_size_t rt_serial_get_linear_buffer(struct rt_ringbuffer *rb,
|
||||
rt_uint8_t **ptr)
|
||||
{
|
||||
rt_size_t size;
|
||||
|
||||
@ -206,8 +206,8 @@ rt_size_t rt_serial_get_linear_buffer(struct rt_ringbuffer *rb,
|
||||
return rb->buffer_size - rb->read_index;
|
||||
}
|
||||
|
||||
rt_size_t rt_serial_update_read_index(struct rt_ringbuffer *rb,
|
||||
rt_uint16_t read_index)
|
||||
static rt_size_t rt_serial_update_read_index(struct rt_ringbuffer *rb,
|
||||
rt_uint16_t read_index)
|
||||
{
|
||||
rt_size_t size;
|
||||
|
||||
@ -219,7 +219,7 @@ rt_size_t rt_serial_update_read_index(struct rt_ringbuffer *rb,
|
||||
/* no data */
|
||||
if (size == 0)
|
||||
return 0;
|
||||
|
||||
|
||||
/* less data */
|
||||
if(size < read_index)
|
||||
read_index = size;
|
||||
@ -239,8 +239,8 @@ rt_size_t rt_serial_update_read_index(struct rt_ringbuffer *rb,
|
||||
return read_index;
|
||||
}
|
||||
|
||||
rt_size_t rt_serial_update_write_index(struct rt_ringbuffer *rb,
|
||||
rt_uint16_t write_index)
|
||||
static rt_size_t rt_serial_update_write_index(struct rt_ringbuffer *rb,
|
||||
rt_uint16_t write_index)
|
||||
{
|
||||
rt_uint16_t size;
|
||||
RT_ASSERT(rb != RT_NULL);
|
||||
@ -499,7 +499,7 @@ static rt_size_t _serial_fifo_tx_blocking_buf(struct rt_device *dev,
|
||||
|
||||
while (size)
|
||||
{
|
||||
/* Copy one piece of data into the ringbuffer at a time
|
||||
/* Copy one piece of data into the ringbuffer at a time
|
||||
* until the length of the data is equal to size */
|
||||
tx_fifo->put_size = rt_ringbuffer_put(&(tx_fifo->rb),
|
||||
(rt_uint8_t *)buffer + offset,
|
||||
@ -629,7 +629,7 @@ static rt_err_t rt_serial_tx_enable(struct rt_device *dev,
|
||||
if (optmode == RT_SERIAL_TX_BLOCKING_BUFFER)
|
||||
{
|
||||
/* If use RT_SERIAL_TX_BLOCKING_BUFFER, the ringbuffer is initialized */
|
||||
tx_fifo = (struct rt_serial_tx_fifo *) rt_malloc
|
||||
tx_fifo = (struct rt_serial_tx_fifo *) rt_malloc
|
||||
(sizeof(struct rt_serial_tx_fifo) + serial->config.tx_bufsz);
|
||||
RT_ASSERT(tx_fifo != RT_NULL);
|
||||
|
||||
@ -641,9 +641,9 @@ static rt_err_t rt_serial_tx_enable(struct rt_device *dev,
|
||||
}
|
||||
else
|
||||
{
|
||||
/* If not use RT_SERIAL_TX_BLOCKING_BUFFER,
|
||||
/* If not use RT_SERIAL_TX_BLOCKING_BUFFER,
|
||||
* the control() API is called to configure the serial device */
|
||||
tx_fifo = (struct rt_serial_tx_fifo*) rt_malloc
|
||||
tx_fifo = (struct rt_serial_tx_fifo*) rt_malloc
|
||||
(sizeof(struct rt_serial_tx_fifo));
|
||||
RT_ASSERT(tx_fifo != RT_NULL);
|
||||
|
||||
@ -665,14 +665,14 @@ static rt_err_t rt_serial_tx_enable(struct rt_device *dev,
|
||||
/* When using RT_SERIAL_TX_NON_BLOCKING, ringbuffer needs to be initialized,
|
||||
* and initialize the tx_fifo->activated value is RT_FALSE.
|
||||
*/
|
||||
tx_fifo = (struct rt_serial_tx_fifo *) rt_malloc
|
||||
tx_fifo = (struct rt_serial_tx_fifo *) rt_malloc
|
||||
(sizeof(struct rt_serial_tx_fifo) + serial->config.tx_bufsz);
|
||||
RT_ASSERT(tx_fifo != RT_NULL);
|
||||
|
||||
tx_fifo->activated = RT_FALSE;
|
||||
tx_fifo->put_size = 0;
|
||||
rt_ringbuffer_init(&(tx_fifo->rb),
|
||||
tx_fifo->buffer,
|
||||
rt_ringbuffer_init(&(tx_fifo->rb),
|
||||
tx_fifo->buffer,
|
||||
serial->config.tx_bufsz);
|
||||
serial->serial_tx = tx_fifo;
|
||||
|
||||
@ -712,7 +712,7 @@ static rt_err_t rt_serial_rx_enable(struct rt_device *dev,
|
||||
return -RT_EINVAL;
|
||||
}
|
||||
|
||||
dev->read = _serial_poll_rx;
|
||||
dev->read = _serial_poll_rx;
|
||||
dev->open_flag |= RT_SERIAL_RX_BLOCKING;
|
||||
return RT_EOK;
|
||||
}
|
||||
@ -892,7 +892,7 @@ static rt_err_t rt_serial_open(struct rt_device *dev, rt_uint16_t oflag)
|
||||
dev->open_flag |= RT_SERIAL_TX_BLOCKING;
|
||||
|
||||
/* set steam flag */
|
||||
if ((oflag & RT_DEVICE_FLAG_STREAM) ||
|
||||
if ((oflag & RT_DEVICE_FLAG_STREAM) ||
|
||||
(dev->open_flag & RT_DEVICE_FLAG_STREAM))
|
||||
dev->open_flag |= RT_DEVICE_FLAG_STREAM;
|
||||
|
||||
@ -903,7 +903,7 @@ static rt_err_t rt_serial_open(struct rt_device *dev, rt_uint16_t oflag)
|
||||
|
||||
/* initialize the Tx structure according to open flag */
|
||||
if (serial->serial_tx == RT_NULL)
|
||||
rt_serial_tx_enable(dev, dev->open_flag &
|
||||
rt_serial_tx_enable(dev, dev->open_flag &
|
||||
(RT_SERIAL_TX_BLOCKING | RT_SERIAL_TX_NON_BLOCKING));
|
||||
|
||||
return RT_EOK;
|
||||
@ -925,10 +925,10 @@ static rt_err_t rt_serial_close(struct rt_device *dev)
|
||||
/* this device has more reference count */
|
||||
if (dev->ref_count > 1) return -RT_ERROR;
|
||||
/* Disable serial receive mode. */
|
||||
rt_serial_rx_disable(dev, dev->open_flag &
|
||||
rt_serial_rx_disable(dev, dev->open_flag &
|
||||
(RT_SERIAL_RX_BLOCKING | RT_SERIAL_RX_NON_BLOCKING));
|
||||
/* Disable serial tranmit mode. */
|
||||
rt_serial_tx_disable(dev, dev->open_flag &
|
||||
rt_serial_tx_disable(dev, dev->open_flag &
|
||||
(RT_SERIAL_TX_BLOCKING | RT_SERIAL_TX_NON_BLOCKING));
|
||||
|
||||
/* Call the control() API to close the serial device */
|
||||
@ -978,7 +978,7 @@ static rt_err_t rt_serial_control(struct rt_device *dev,
|
||||
}
|
||||
/* set serial configure */
|
||||
serial->config = *pconfig;
|
||||
serial->ops->configure(serial,
|
||||
serial->ops->configure(serial,
|
||||
(struct serial_configure *) args);
|
||||
}
|
||||
|
||||
@ -994,7 +994,7 @@ static rt_err_t rt_serial_control(struct rt_device *dev,
|
||||
}
|
||||
|
||||
#ifdef RT_USING_DEVICE_OPS
|
||||
const static struct rt_device_ops serial_ops =
|
||||
const static struct rt_device_ops serial_ops =
|
||||
{
|
||||
rt_serial_init,
|
||||
rt_serial_open,
|
||||
@ -1070,9 +1070,14 @@ void rt_hw_serial_isr(struct rt_serial_device *serial, int event)
|
||||
rx_fifo = (struct rt_serial_rx_fifo *)serial->serial_rx;
|
||||
RT_ASSERT(rx_fifo != RT_NULL);
|
||||
|
||||
/* If the event is RT_SERIAL_EVENT_RX_IND, rx_length is equal to 0 */
|
||||
rx_length = (event & (~0xff)) >> 8;
|
||||
|
||||
if (rx_length)
|
||||
rt_serial_update_write_index(&(rx_fifo->rb), rx_length);
|
||||
|
||||
/* Get the length of the data from the ringbuffer */
|
||||
rx_length = rt_ringbuffer_data_len(&rx_fifo->rb);
|
||||
|
||||
if (rx_length == 0) break;
|
||||
|
||||
if (serial->parent.open_flag & RT_SERIAL_RX_BLOCKING)
|
||||
|
Loading…
x
Reference in New Issue
Block a user