Browse Source

update多编码器封装

external_Interrupt
tianjialong 2 years ago
parent
commit
690cf2bb08
  1. 21
      MDK-ARM/LWIP.uvguix.29643
  2. 46
      MDK-ARM/LWIP.uvoptx
  3. 1088
      MDK-ARM/LWIP.uvprojx
  4. 26
      usersrc/encoder.c
  5. 2
      usersrc/zboard.h

21
MDK-ARM/LWIP.uvguix.29643
File diff suppressed because it is too large
View File

46
MDK-ARM/LWIP.uvoptx

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<ProjectOpt xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_optx.xsd">
<SchemaVersion>1.0</SchemaVersion>
@ -45,7 +45,7 @@
<PageWidth>79</PageWidth>
<PageLength>66</PageLength>
<TabStop>8</TabStop>
<ListingPath />
<ListingPath></ListingPath>
</OPTLEX>
<ListingPage>
<CreateCListing>1</CreateCListing>
@ -104,16 +104,16 @@
<bSchkAxf>0</bSchkAxf>
<bTchkAxf>0</bTchkAxf>
<nTsel>3</nTsel>
<sDll />
<sDllPa />
<sDlgDll />
<sDlgPa />
<sIfile />
<tDll />
<tDllPa />
<tDlgDll />
<tDlgPa />
<tIfile />
<sDll></sDll>
<sDllPa></sDllPa>
<sDlgDll></sDlgDll>
<sDlgPa></sDlgPa>
<sIfile></sIfile>
<tDll></tDll>
<tDllPa></tDllPa>
<tDlgDll></tDlgDll>
<tDlgPa></tDlgPa>
<tIfile></tIfile>
<pMon>BIN\CMSIS_AGDI.dll</pMon>
</DebugOpt>
<TargetDriverDllRegistry>
@ -133,7 +133,7 @@
<Name>-U-O142 -O2254 -S0 -C0 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC800 -FN1 -FF0STM32F4xx_512.FLM -FS08000000 -FL080000 -FP0($$Device:STM32F407ZETx$CMSIS\Flash\STM32F4xx_512.FLM)</Name>
</SetRegEntry>
</TargetDriverDllRegistry>
<Breakpoint />
<Breakpoint/>
<Tracepoint>
<THDelay>0</THDelay>
</Tracepoint>
@ -163,19 +163,19 @@
<newCpu>0</newCpu>
<uProt>0</uProt>
</DebugFlag>
<LintExecutable />
<LintConfigFile />
<LintExecutable></LintExecutable>
<LintConfigFile></LintConfigFile>
<bLintAuto>0</bLintAuto>
<bAutoGenD>0</bAutoGenD>
<LntExFlags>0</LntExFlags>
<pMisraName />
<pszMrule />
<pSingCmds />
<pMultCmds />
<pMisraNamep />
<pszMrulep />
<pSingCmdsp />
<pMultCmdsp />
<pMisraName></pMisraName>
<pszMrule></pszMrule>
<pSingCmds></pSingCmds>
<pMultCmds></pMultCmds>
<pMisraNamep></pMisraNamep>
<pszMrulep></pszMrulep>
<pSingCmdsp></pSingCmdsp>
<pMultCmdsp></pMultCmdsp>
<DebugDescription>
<Enable>1</Enable>
<EnableFlashSeq>0</EnableFlashSeq>

1088
MDK-ARM/LWIP.uvprojx
File diff suppressed because it is too large
View File

26
usersrc/encoder.c

@ -1,27 +1,37 @@
#include "encoder.h"
#include "zboard.h"
#include <stdio.h>
static int Direction;
static int CaptureNumber;
static encoder_t m_uarts[] = {
{&camera_encoder, TIM_CHANNEL_1 | TIM_CHANNEL_2}, //
{&driven_encoder_gear, TIM_CHANNEL_1 | TIM_CHANNEL_2} //
};
void encoder_start(void)
{
/* 不开启会导致程序无法启动,原因未知 */
HAL_TIM_Encoder_Start(&htim4, TIM_CHANNEL_1 | TIM_CHANNEL_2);
HAL_TIM_Encoder_Start(&camera_encoder, TIM_CHANNEL_1 | TIM_CHANNEL_2);
HAL_TIM_Encoder_Start(&driven_encoder_gear, TIM_CHANNEL_1 | TIM_CHANNEL_2);
}
void encoder_stop(void)
{
HAL_TIM_Encoder_Stop(&htim4, TIM_CHANNEL_1 | TIM_CHANNEL_2);
HAL_TIM_Encoder_Stop(&camera_encoder, TIM_CHANNEL_1 | TIM_CHANNEL_2);
HAL_TIM_Encoder_Stop(&driven_encoder_gear, TIM_CHANNEL_1 | TIM_CHANNEL_2);
}
void encoder_read_printf(void)
{
Direction = __HAL_TIM_IS_TIM_COUNTING_DOWN(&htim4); //
CaptureNumber = (short)__HAL_TIM_GET_COUNTER(&htim4); //
__HAL_TIM_GET_COUNTER(&htim4) = 0; //
if (CaptureNumber != 0)
for (uint8_t i = 0; i < (sizeof(m_uarts) / sizeof(encoder_t)); i++)
{
printf("Direction is %d,CaptureNumber is %d\r\n", Direction, CaptureNumber);
Direction = __HAL_TIM_IS_TIM_COUNTING_DOWN(m_uarts[i].tim_handler); //
CaptureNumber = (short)__HAL_TIM_GET_COUNTER(m_uarts[i].tim_handler); //
__HAL_TIM_GET_COUNTER(m_uarts[i].tim_handler) = 0; //
if (CaptureNumber != 0)
{
printf("Encoder number:%d,Direction is %d,CaptureNumber is %d\r\n", i, Direction, CaptureNumber);
}
}
}

2
usersrc/zboard.h

@ -14,4 +14,4 @@
* ************************************************************************************************************* *
***********************************************************************************************************************/
#define camera_encoder htim4
#define driven_encoder_gear htim8
#define driven_encoder_gear htim8
Loading…
Cancel
Save