Compare commits
8 Commits
Author | SHA1 | Date |
---|---|---|
|
c5ea18f629 | |
|
290fe0f827 | |
|
922d376bcc | |
|
2514a1efe7 | |
|
542ff3208c | |
|
5870cee759 | |
|
4c3cb563ee | |
|
fba5f0720c |
|
@ -5,7 +5,9 @@
|
||||||
"motor.h": "c",
|
"motor.h": "c",
|
||||||
"main.h": "c",
|
"main.h": "c",
|
||||||
"app.h": "c",
|
"app.h": "c",
|
||||||
"type_traits": "c"
|
"type_traits": "c",
|
||||||
|
"adcs.h": "c",
|
||||||
|
"uarts.h": "c"
|
||||||
},
|
},
|
||||||
"C_Cpp.errorSquiggles": "disabled"
|
"C_Cpp.errorSquiggles": "disabled"
|
||||||
}
|
}
|
|
@ -41,14 +41,40 @@ void MX_ADC_Init(void)
|
||||||
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_ADC1);
|
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_ADC1);
|
||||||
|
|
||||||
LL_IOP_GRP1_EnableClock(LL_IOP_GRP1_PERIPH_GPIOC);
|
LL_IOP_GRP1_EnableClock(LL_IOP_GRP1_PERIPH_GPIOC);
|
||||||
|
LL_IOP_GRP1_EnableClock(LL_IOP_GRP1_PERIPH_GPIOA);
|
||||||
|
LL_IOP_GRP1_EnableClock(LL_IOP_GRP1_PERIPH_GPIOB);
|
||||||
/**ADC GPIO Configuration
|
/**ADC GPIO Configuration
|
||||||
|
PC0 ------> ADC_IN10
|
||||||
PC3 ------> ADC_IN13
|
PC3 ------> ADC_IN13
|
||||||
|
PA7 ------> ADC_IN7
|
||||||
|
PB0 ------> ADC_IN8
|
||||||
|
PB1 ------> ADC_IN9
|
||||||
*/
|
*/
|
||||||
|
GPIO_InitStruct.Pin = LL_GPIO_PIN_0;
|
||||||
|
GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG;
|
||||||
|
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
||||||
|
LL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
||||||
|
|
||||||
GPIO_InitStruct.Pin = MG_ADC_IN13_Pin;
|
GPIO_InitStruct.Pin = MG_ADC_IN13_Pin;
|
||||||
GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG;
|
GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG;
|
||||||
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
||||||
LL_GPIO_Init(MG_ADC_IN13_GPIO_Port, &GPIO_InitStruct);
|
LL_GPIO_Init(MG_ADC_IN13_GPIO_Port, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
GPIO_InitStruct.Pin = LL_GPIO_PIN_7;
|
||||||
|
GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG;
|
||||||
|
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
||||||
|
LL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
GPIO_InitStruct.Pin = LL_GPIO_PIN_0;
|
||||||
|
GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG;
|
||||||
|
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
||||||
|
LL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
GPIO_InitStruct.Pin = LL_GPIO_PIN_1;
|
||||||
|
GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG;
|
||||||
|
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
||||||
|
LL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||||
|
|
||||||
/* ADC DMA Init */
|
/* ADC DMA Init */
|
||||||
|
|
||||||
/* ADC Init */
|
/* ADC Init */
|
||||||
|
@ -72,6 +98,22 @@ void MX_ADC_Init(void)
|
||||||
|
|
||||||
/* USER CODE END ADC_Init 1 */
|
/* USER CODE END ADC_Init 1 */
|
||||||
|
|
||||||
|
/** Configure Regular Channel
|
||||||
|
*/
|
||||||
|
LL_ADC_REG_SetSequencerChAdd(ADC1, LL_ADC_CHANNEL_7);
|
||||||
|
|
||||||
|
/** Configure Regular Channel
|
||||||
|
*/
|
||||||
|
LL_ADC_REG_SetSequencerChAdd(ADC1, LL_ADC_CHANNEL_8);
|
||||||
|
|
||||||
|
/** Configure Regular Channel
|
||||||
|
*/
|
||||||
|
LL_ADC_REG_SetSequencerChAdd(ADC1, LL_ADC_CHANNEL_9);
|
||||||
|
|
||||||
|
/** Configure Regular Channel
|
||||||
|
*/
|
||||||
|
LL_ADC_REG_SetSequencerChAdd(ADC1, LL_ADC_CHANNEL_10);
|
||||||
|
|
||||||
/** Configure Regular Channel
|
/** Configure Regular Channel
|
||||||
*/
|
*/
|
||||||
LL_ADC_REG_SetSequencerChAdd(ADC1, LL_ADC_CHANNEL_13);
|
LL_ADC_REG_SetSequencerChAdd(ADC1, LL_ADC_CHANNEL_13);
|
||||||
|
|
|
@ -78,12 +78,6 @@ void MX_GPIO_Init(void)
|
||||||
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
||||||
LL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
LL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
||||||
|
|
||||||
/**/
|
|
||||||
GPIO_InitStruct.Pin = LL_GPIO_PIN_0;
|
|
||||||
GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG;
|
|
||||||
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
|
||||||
LL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
GPIO_InitStruct.Pin = LL_GPIO_PIN_1;
|
GPIO_InitStruct.Pin = LL_GPIO_PIN_1;
|
||||||
GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG;
|
GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG;
|
||||||
|
@ -138,12 +132,6 @@ void MX_GPIO_Init(void)
|
||||||
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
||||||
LL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
LL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||||
|
|
||||||
/**/
|
|
||||||
GPIO_InitStruct.Pin = LL_GPIO_PIN_7;
|
|
||||||
GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG;
|
|
||||||
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
|
||||||
LL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
GPIO_InitStruct.Pin = LL_GPIO_PIN_4;
|
GPIO_InitStruct.Pin = LL_GPIO_PIN_4;
|
||||||
GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG;
|
GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG;
|
||||||
|
@ -156,18 +144,6 @@ void MX_GPIO_Init(void)
|
||||||
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
||||||
LL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
LL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
||||||
|
|
||||||
/**/
|
|
||||||
GPIO_InitStruct.Pin = LL_GPIO_PIN_0;
|
|
||||||
GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG;
|
|
||||||
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
|
||||||
LL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
|
||||||
|
|
||||||
/**/
|
|
||||||
GPIO_InitStruct.Pin = LL_GPIO_PIN_1;
|
|
||||||
GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG;
|
|
||||||
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
|
||||||
LL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
GPIO_InitStruct.Pin = LL_GPIO_PIN_2;
|
GPIO_InitStruct.Pin = LL_GPIO_PIN_2;
|
||||||
GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG;
|
GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG;
|
||||||
|
|
|
@ -68,8 +68,8 @@ extern motor_t *motor;
|
||||||
/* Cortex-M0+ Processor Interruption and Exception Handlers */
|
/* Cortex-M0+ Processor Interruption and Exception Handlers */
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
/**
|
/**
|
||||||
* @brief This function handles Non maskable Interrupt.
|
* @brief This function handles Non maskable Interrupt.
|
||||||
*/
|
*/
|
||||||
void NMI_Handler(void)
|
void NMI_Handler(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN NonMaskableInt_IRQn 0 */
|
/* USER CODE BEGIN NonMaskableInt_IRQn 0 */
|
||||||
|
@ -83,8 +83,8 @@ void NMI_Handler(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles Hard fault interrupt.
|
* @brief This function handles Hard fault interrupt.
|
||||||
*/
|
*/
|
||||||
void HardFault_Handler(void)
|
void HardFault_Handler(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN HardFault_IRQn 0 */
|
/* USER CODE BEGIN HardFault_IRQn 0 */
|
||||||
|
@ -98,8 +98,8 @@ void HardFault_Handler(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles System service call via SWI instruction.
|
* @brief This function handles System service call via SWI instruction.
|
||||||
*/
|
*/
|
||||||
void SVC_Handler(void)
|
void SVC_Handler(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN SVC_IRQn 0 */
|
/* USER CODE BEGIN SVC_IRQn 0 */
|
||||||
|
@ -111,8 +111,8 @@ void SVC_Handler(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles Pendable request for system service.
|
* @brief This function handles Pendable request for system service.
|
||||||
*/
|
*/
|
||||||
void PendSV_Handler(void)
|
void PendSV_Handler(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN PendSV_IRQn 0 */
|
/* USER CODE BEGIN PendSV_IRQn 0 */
|
||||||
|
@ -124,8 +124,8 @@ void PendSV_Handler(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles System tick timer.
|
* @brief This function handles System tick timer.
|
||||||
*/
|
*/
|
||||||
void SysTick_Handler(void)
|
void SysTick_Handler(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN SysTick_IRQn 0 */
|
/* USER CODE BEGIN SysTick_IRQn 0 */
|
||||||
|
@ -145,8 +145,8 @@ void SysTick_Handler(void)
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles DMA1 channel 1 interrupt.
|
* @brief This function handles DMA1 channel 1 interrupt.
|
||||||
*/
|
*/
|
||||||
void DMA1_Channel1_IRQHandler(void)
|
void DMA1_Channel1_IRQHandler(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN DMA1_Channel1_IRQn 0 */
|
/* USER CODE BEGIN DMA1_Channel1_IRQn 0 */
|
||||||
|
@ -159,8 +159,8 @@ void DMA1_Channel1_IRQHandler(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles DMA1 channel 2 and channel 3 interrupts.
|
* @brief This function handles DMA1 channel 2 and channel 3 interrupts.
|
||||||
*/
|
*/
|
||||||
void DMA1_Channel2_3_IRQHandler(void)
|
void DMA1_Channel2_3_IRQHandler(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN DMA1_Channel2_3_IRQn 0 */
|
/* USER CODE BEGIN DMA1_Channel2_3_IRQn 0 */
|
||||||
|
@ -173,8 +173,8 @@ void DMA1_Channel2_3_IRQHandler(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles TIM6 global interrupt and DAC1/DAC2 underrun error interrupts.
|
* @brief This function handles TIM6 global interrupt and DAC1/DAC2 underrun error interrupts.
|
||||||
*/
|
*/
|
||||||
void TIM6_DAC_IRQHandler(void)
|
void TIM6_DAC_IRQHandler(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN TIM6_DAC_IRQn 0 */
|
/* USER CODE BEGIN TIM6_DAC_IRQn 0 */
|
||||||
|
@ -191,25 +191,25 @@ void TIM6_DAC_IRQHandler(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles TIM21 global interrupt.
|
* @brief This function handles TIM21 global interrupt.
|
||||||
*/
|
*/
|
||||||
void TIM21_IRQHandler(void)
|
void TIM21_IRQHandler(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN TIM21_IRQn 0 */
|
/* USER CODE BEGIN TIM21_IRQn 0 */
|
||||||
|
|
||||||
/* USER CODE END TIM21_IRQn 0 */
|
/* USER CODE END TIM21_IRQn 0 */
|
||||||
|
|
||||||
/* USER CODE BEGIN TIM21_IRQn 1 */
|
/* USER CODE BEGIN TIM21_IRQn 1 */
|
||||||
if (LL_TIM_IsActiveFlag_UPDATE(TIM21))
|
if (LL_TIM_IsActiveFlag_UPDATE(TIM21))
|
||||||
{
|
{
|
||||||
|
step_motor_update(motor);
|
||||||
LL_TIM_ClearFlag_UPDATE(TIM21);
|
LL_TIM_ClearFlag_UPDATE(TIM21);
|
||||||
}
|
}
|
||||||
/* USER CODE END TIM21_IRQn 1 */
|
/* USER CODE END TIM21_IRQn 1 */
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles USART1 global interrupt / USART1 wake-up interrupt through EXTI line 25.
|
* @brief This function handles USART1 global interrupt / USART1 wake-up interrupt through EXTI line 25.
|
||||||
*/
|
*/
|
||||||
void USART1_IRQHandler(void)
|
void USART1_IRQHandler(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN USART1_IRQn 0 */
|
/* USER CODE BEGIN USART1_IRQn 0 */
|
||||||
|
|
|
@ -145,27 +145,10 @@
|
||||||
<SetRegEntry>
|
<SetRegEntry>
|
||||||
<Number>0</Number>
|
<Number>0</Number>
|
||||||
<Key>ST-LINKIII-KEIL_SWO</Key>
|
<Key>ST-LINKIII-KEIL_SWO</Key>
|
||||||
<Name>-U-O142 -O2254 -SF10000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP (ARM Core") -D00(0BC11477) -L00(0) -TO131090 -TC10000000 -TT10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC800 -FN1 -FF0STM32L0xx_128.FLM -FS08000000 -FL020000 -FP0($$Device:STM32L072RBTx$CMSIS\Flash\STM32L0xx_128.FLM) -WA0 -WE0 -WVCE4 -WS2710 -WM0 -WP2</Name>
|
<Name>-US -O2254 -SF10000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP (ARM Core") -D00(0BC11477) -L00(0) -TO131090 -TC10000000 -TT10000000 -TP21 -TDS8000 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO15 -FD20000000 -FC800 -FN1 -FF0STM32L0xx_128.FLM -FS08000000 -FL020000 -FP0($$Device:STM32L072RBTx$CMSIS\Flash\STM32L0xx_128.FLM) -WA0 -WE0 -WVCE4 -WS2710 -WM0 -WP2</Name>
|
||||||
</SetRegEntry>
|
</SetRegEntry>
|
||||||
</TargetDriverDllRegistry>
|
</TargetDriverDllRegistry>
|
||||||
<Breakpoint>
|
<Breakpoint/>
|
||||||
<Bp>
|
|
||||||
<Number>0</Number>
|
|
||||||
<Type>0</Type>
|
|
||||||
<LineNumber>207</LineNumber>
|
|
||||||
<EnabledFlag>1</EnabledFlag>
|
|
||||||
<Address>134223234</Address>
|
|
||||||
<ByteObject>0</ByteObject>
|
|
||||||
<HtxType>0</HtxType>
|
|
||||||
<ManyObjects>0</ManyObjects>
|
|
||||||
<SizeOfObject>0</SizeOfObject>
|
|
||||||
<BreakByAccess>0</BreakByAccess>
|
|
||||||
<BreakIfRCount>1</BreakIfRCount>
|
|
||||||
<Filename>../Core/Src/stm32l0xx_it.c</Filename>
|
|
||||||
<ExecCommand></ExecCommand>
|
|
||||||
<Expression>\\motor\../Core/Src/stm32l0xx_it.c\207</Expression>
|
|
||||||
</Bp>
|
|
||||||
</Breakpoint>
|
|
||||||
<WatchWindow1>
|
<WatchWindow1>
|
||||||
<Ww>
|
<Ww>
|
||||||
<count>0</count>
|
<count>0</count>
|
||||||
|
@ -175,29 +158,37 @@
|
||||||
<Ww>
|
<Ww>
|
||||||
<count>1</count>
|
<count>1</count>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<ItemText>motor_state</ItemText>
|
<ItemText>test_buffer,0x10</ItemText>
|
||||||
</Ww>
|
</Ww>
|
||||||
<Ww>
|
<Ww>
|
||||||
<count>2</count>
|
<count>2</count>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<ItemText>motor_ccr</ItemText>
|
<ItemText>self_test,0x0A</ItemText>
|
||||||
</Ww>
|
</Ww>
|
||||||
<Ww>
|
<Ww>
|
||||||
<count>3</count>
|
<count>3</count>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<ItemText>step_motor_flag</ItemText>
|
<ItemText>motor,0x0A</ItemText>
|
||||||
</Ww>
|
</Ww>
|
||||||
<Ww>
|
<Ww>
|
||||||
<count>4</count>
|
<count>4</count>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<ItemText>motor->handle.step_motor.attribute,0x0A</ItemText>
|
<ItemText>motor_param,0x0A</ItemText>
|
||||||
</Ww>
|
</Ww>
|
||||||
<Ww>
|
<Ww>
|
||||||
<count>5</count>
|
<count>5</count>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<ItemText>motor_dir</ItemText>
|
<ItemText>detect_result,0x0A</ItemText>
|
||||||
</Ww>
|
</Ww>
|
||||||
</WatchWindow1>
|
</WatchWindow1>
|
||||||
|
<MemoryWindow1>
|
||||||
|
<Mm>
|
||||||
|
<WinNumber>1</WinNumber>
|
||||||
|
<SubType>0</SubType>
|
||||||
|
<ItemText>0x20000090</ItemText>
|
||||||
|
<AccSizeX>0</AccSizeX>
|
||||||
|
</Mm>
|
||||||
|
</MemoryWindow1>
|
||||||
<Tracepoint>
|
<Tracepoint>
|
||||||
<THDelay>0</THDelay>
|
<THDelay>0</THDelay>
|
||||||
</Tracepoint>
|
</Tracepoint>
|
||||||
|
@ -240,16 +231,6 @@
|
||||||
<pszMrulep></pszMrulep>
|
<pszMrulep></pszMrulep>
|
||||||
<pSingCmdsp></pSingCmdsp>
|
<pSingCmdsp></pSingCmdsp>
|
||||||
<pMultCmdsp></pMultCmdsp>
|
<pMultCmdsp></pMultCmdsp>
|
||||||
<SystemViewers>
|
|
||||||
<Entry>
|
|
||||||
<Name>System Viewer\TIM21</Name>
|
|
||||||
<WinId>35905</WinId>
|
|
||||||
</Entry>
|
|
||||||
<Entry>
|
|
||||||
<Name>System Viewer\TIM6</Name>
|
|
||||||
<WinId>35904</WinId>
|
|
||||||
</Entry>
|
|
||||||
</SystemViewers>
|
|
||||||
<DebugDescription>
|
<DebugDescription>
|
||||||
<Enable>1</Enable>
|
<Enable>1</Enable>
|
||||||
<EnableFlashSeq>0</EnableFlashSeq>
|
<EnableFlashSeq>0</EnableFlashSeq>
|
||||||
|
@ -282,7 +263,7 @@
|
||||||
|
|
||||||
<Group>
|
<Group>
|
||||||
<GroupName>Application/User/Core</GroupName>
|
<GroupName>Application/User/Core</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>
|
||||||
|
|
|
@ -54,7 +54,7 @@
|
||||||
<CreateLib>0</CreateLib>
|
<CreateLib>0</CreateLib>
|
||||||
<CreateHexFile>1</CreateHexFile>
|
<CreateHexFile>1</CreateHexFile>
|
||||||
<DebugInformation>1</DebugInformation>
|
<DebugInformation>1</DebugInformation>
|
||||||
<BrowseInformation>1</BrowseInformation>
|
<BrowseInformation>0</BrowseInformation>
|
||||||
<ListingPath></ListingPath>
|
<ListingPath></ListingPath>
|
||||||
<HexFormatSelection>1</HexFormatSelection>
|
<HexFormatSelection>1</HexFormatSelection>
|
||||||
<Merge32K>0</Merge32K>
|
<Merge32K>0</Merge32K>
|
||||||
|
@ -138,7 +138,7 @@
|
||||||
</Flash1>
|
</Flash1>
|
||||||
<bUseTDR>1</bUseTDR>
|
<bUseTDR>1</bUseTDR>
|
||||||
<Flash2>BIN\UL2V8M.DLL</Flash2>
|
<Flash2>BIN\UL2V8M.DLL</Flash2>
|
||||||
<Flash3></Flash3>
|
<Flash3>"" ()</Flash3>
|
||||||
<Flash4></Flash4>
|
<Flash4></Flash4>
|
||||||
<pFcarmOut></pFcarmOut>
|
<pFcarmOut></pFcarmOut>
|
||||||
<pFcarmGrp></pFcarmGrp>
|
<pFcarmGrp></pFcarmGrp>
|
||||||
|
@ -314,7 +314,7 @@
|
||||||
</ArmAdsMisc>
|
</ArmAdsMisc>
|
||||||
<Cads>
|
<Cads>
|
||||||
<interw>1</interw>
|
<interw>1</interw>
|
||||||
<Optim>0</Optim>
|
<Optim>1</Optim>
|
||||||
<oTime>0</oTime>
|
<oTime>0</oTime>
|
||||||
<SplitLS>0</SplitLS>
|
<SplitLS>0</SplitLS>
|
||||||
<OneElfS>1</OneElfS>
|
<OneElfS>1</OneElfS>
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,938 +0,0 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ARM Macro Assembler Page 1
|
|
||||||
|
|
||||||
|
|
||||||
1 00000000 ;*******************************************************
|
|
||||||
***********************
|
|
||||||
2 00000000 ;* File Name : startup_stm32l072xx.s
|
|
||||||
3 00000000 ;* Author : MCD Application Team
|
|
||||||
4 00000000 ;* Description : STM32l072xx Devices vector table
|
|
||||||
for MDK-ARM toolchain.
|
|
||||||
5 00000000 ;* This module performs:
|
|
||||||
6 00000000 ;* - Set the initial SP
|
|
||||||
7 00000000 ;* - Set the initial PC == Reset_Ha
|
|
||||||
ndler
|
|
||||||
8 00000000 ;* - Set the vector table entries w
|
|
||||||
ith the exceptions ISR address
|
|
||||||
9 00000000 ;* - Branches to __main in the C lb
|
|
||||||
rary (which eventually
|
|
||||||
10 00000000 ;* calls main()).
|
|
||||||
11 00000000 ;* After Reset the Cortex-M0+ proce
|
|
||||||
ssor is in Thread mode,
|
|
||||||
12 00000000 ;* priority is Privileged, and the
|
|
||||||
Stack is set to Main.
|
|
||||||
13 00000000 ;*******************************************************
|
|
||||||
***********************
|
|
||||||
14 00000000 ;* @attention
|
|
||||||
15 00000000 ;*
|
|
||||||
16 00000000 ;* Copyright (c) 2016 STMicroelectronics.
|
|
||||||
17 00000000 ;* All rights reserved.
|
|
||||||
18 00000000 ;*
|
|
||||||
19 00000000 ;* This software is licensed under terms that can be fou
|
|
||||||
nd in the LICENSE file
|
|
||||||
20 00000000 ;* in the root directory of this software component.
|
|
||||||
21 00000000 ;* If no LICENSE file comes with this software, it is pr
|
|
||||||
ovided AS-IS.
|
|
||||||
22 00000000 ;*
|
|
||||||
23 00000000 ;*******************************************************
|
|
||||||
***********************
|
|
||||||
24 00000000
|
|
||||||
25 00000000 ; Amount of memory (in bytes) allocated for Stack
|
|
||||||
26 00000000 ; Tailor this value to your application needs
|
|
||||||
27 00000000 ; <h> Stack Configuration
|
|
||||||
28 00000000 ; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
|
|
||||||
29 00000000 ; </h>
|
|
||||||
30 00000000
|
|
||||||
31 00000000 00000600
|
|
||||||
Stack_Size
|
|
||||||
EQU 0x600
|
|
||||||
32 00000000
|
|
||||||
33 00000000 AREA STACK, NOINIT, READWRITE, ALIGN
|
|
||||||
=3
|
|
||||||
34 00000000 Stack_Mem
|
|
||||||
SPACE Stack_Size
|
|
||||||
35 00000600 __initial_sp
|
|
||||||
36 00000600
|
|
||||||
37 00000600
|
|
||||||
38 00000600 ; <h> Heap Configuration
|
|
||||||
39 00000600 ; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
|
|
||||||
40 00000600 ; </h>
|
|
||||||
41 00000600
|
|
||||||
42 00000600 00000400
|
|
||||||
Heap_Size
|
|
||||||
EQU 0x400
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ARM Macro Assembler Page 2
|
|
||||||
|
|
||||||
|
|
||||||
43 00000600
|
|
||||||
44 00000600 AREA HEAP, NOINIT, READWRITE, ALIGN=
|
|
||||||
3
|
|
||||||
45 00000000 __heap_base
|
|
||||||
46 00000000 Heap_Mem
|
|
||||||
SPACE Heap_Size
|
|
||||||
47 00000400 __heap_limit
|
|
||||||
48 00000400
|
|
||||||
49 00000400 PRESERVE8
|
|
||||||
50 00000400 THUMB
|
|
||||||
51 00000400
|
|
||||||
52 00000400
|
|
||||||
53 00000400 ; Vector Table Mapped to Address 0 at Reset
|
|
||||||
54 00000400 AREA RESET, DATA, READONLY
|
|
||||||
55 00000000 EXPORT __Vectors
|
|
||||||
56 00000000 EXPORT __Vectors_End
|
|
||||||
57 00000000 EXPORT __Vectors_Size
|
|
||||||
58 00000000
|
|
||||||
59 00000000 00000000
|
|
||||||
__Vectors
|
|
||||||
DCD __initial_sp ; Top of Stack
|
|
||||||
60 00000004 00000000 DCD Reset_Handler ; Reset Handler
|
|
||||||
61 00000008 00000000 DCD NMI_Handler ; NMI Handler
|
|
||||||
62 0000000C 00000000 DCD HardFault_Handler ; Hard Fault
|
|
||||||
Handler
|
|
||||||
63 00000010 00000000 DCD 0 ; Reserved
|
|
||||||
64 00000014 00000000 DCD 0 ; Reserved
|
|
||||||
65 00000018 00000000 DCD 0 ; Reserved
|
|
||||||
66 0000001C 00000000 DCD 0 ; Reserved
|
|
||||||
67 00000020 00000000 DCD 0 ; Reserved
|
|
||||||
68 00000024 00000000 DCD 0 ; Reserved
|
|
||||||
69 00000028 00000000 DCD 0 ; Reserved
|
|
||||||
70 0000002C 00000000 DCD SVC_Handler ; SVCall Handler
|
|
||||||
71 00000030 00000000 DCD 0 ; Reserved
|
|
||||||
72 00000034 00000000 DCD 0 ; Reserved
|
|
||||||
73 00000038 00000000 DCD PendSV_Handler ; PendSV Handler
|
|
||||||
|
|
||||||
74 0000003C 00000000 DCD SysTick_Handler
|
|
||||||
; SysTick Handler
|
|
||||||
75 00000040
|
|
||||||
76 00000040 ; External Interrupts
|
|
||||||
77 00000040 00000000 DCD WWDG_IRQHandler
|
|
||||||
; Window Watchdog
|
|
||||||
78 00000044 00000000 DCD PVD_IRQHandler ; PVD through EX
|
|
||||||
TI Line detect
|
|
||||||
79 00000048 00000000 DCD RTC_IRQHandler ; RTC through EX
|
|
||||||
TI Line
|
|
||||||
80 0000004C 00000000 DCD FLASH_IRQHandler ; FLASH
|
|
||||||
81 00000050 00000000 DCD RCC_CRS_IRQHandler
|
|
||||||
; RCC and CRS
|
|
||||||
82 00000054 00000000 DCD EXTI0_1_IRQHandler
|
|
||||||
; EXTI Line 0 and 1
|
|
||||||
|
|
||||||
83 00000058 00000000 DCD EXTI2_3_IRQHandler
|
|
||||||
; EXTI Line 2 and 3
|
|
||||||
|
|
||||||
84 0000005C 00000000 DCD EXTI4_15_IRQHandler
|
|
||||||
; EXTI Line 4 to 15
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ARM Macro Assembler Page 3
|
|
||||||
|
|
||||||
|
|
||||||
85 00000060 00000000 DCD TSC_IRQHandler ; TSC
|
|
||||||
86 00000064 00000000 DCD DMA1_Channel1_IRQHandler
|
|
||||||
; DMA1 Channel 1
|
|
||||||
87 00000068 00000000 DCD DMA1_Channel2_3_IRQHandler ; DM
|
|
||||||
A1 Channel 2 and Ch
|
|
||||||
annel 3
|
|
||||||
88 0000006C 00000000 DCD DMA1_Channel4_5_6_7_IRQHandler
|
|
||||||
; DMA1 Channel 4, C
|
|
||||||
hannel 5, Channel 6
|
|
||||||
and Channel 7
|
|
||||||
89 00000070 00000000 DCD ADC1_COMP_IRQHandler ; ADC1, CO
|
|
||||||
MP1 and COMP2
|
|
||||||
90 00000074 00000000 DCD LPTIM1_IRQHandler ; LPTIM1
|
|
||||||
91 00000078 00000000 DCD USART4_5_IRQHandler
|
|
||||||
; USART4 and USART5
|
|
||||||
|
|
||||||
92 0000007C 00000000 DCD TIM2_IRQHandler ; TIM2
|
|
||||||
93 00000080 00000000 DCD TIM3_IRQHandler ; TIM3
|
|
||||||
94 00000084 00000000 DCD TIM6_DAC_IRQHandler
|
|
||||||
; TIM6 and DAC
|
|
||||||
95 00000088 00000000 DCD TIM7_IRQHandler ; TIM7
|
|
||||||
96 0000008C 00000000 DCD 0 ; Reserved
|
|
||||||
97 00000090 00000000 DCD TIM21_IRQHandler ; TIM21
|
|
||||||
98 00000094 00000000 DCD I2C3_IRQHandler ; I2C3
|
|
||||||
99 00000098 00000000 DCD TIM22_IRQHandler ; TIM22
|
|
||||||
100 0000009C 00000000 DCD I2C1_IRQHandler ; I2C1
|
|
||||||
101 000000A0 00000000 DCD I2C2_IRQHandler ; I2C2
|
|
||||||
102 000000A4 00000000 DCD SPI1_IRQHandler ; SPI1
|
|
||||||
103 000000A8 00000000 DCD SPI2_IRQHandler ; SPI2
|
|
||||||
104 000000AC 00000000 DCD USART1_IRQHandler ; USART1
|
|
||||||
105 000000B0 00000000 DCD USART2_IRQHandler ; USART2
|
|
||||||
106 000000B4 00000000 DCD RNG_LPUART1_IRQHandler
|
|
||||||
; RNG and LPUART1
|
|
||||||
107 000000B8 00000000 DCD 0 ; Reserved
|
|
||||||
108 000000BC 00000000 DCD USB_IRQHandler ; USB
|
|
||||||
109 000000C0
|
|
||||||
110 000000C0 __Vectors_End
|
|
||||||
111 000000C0
|
|
||||||
112 000000C0 000000C0
|
|
||||||
__Vectors_Size
|
|
||||||
EQU __Vectors_End - __Vectors
|
|
||||||
113 000000C0
|
|
||||||
114 000000C0 AREA |.text|, CODE, READONLY
|
|
||||||
115 00000000
|
|
||||||
116 00000000 ; Reset handler routine
|
|
||||||
117 00000000 Reset_Handler
|
|
||||||
PROC
|
|
||||||
118 00000000 EXPORT Reset_Handler [
|
|
||||||
WEAK]
|
|
||||||
119 00000000 IMPORT __main
|
|
||||||
120 00000000 IMPORT SystemInit
|
|
||||||
121 00000000 4807 LDR R0, =SystemInit
|
|
||||||
122 00000002 4780 BLX R0
|
|
||||||
123 00000004 4807 LDR R0, =__main
|
|
||||||
124 00000006 4700 BX R0
|
|
||||||
125 00000008 ENDP
|
|
||||||
126 00000008
|
|
||||||
127 00000008 ; Dummy Exception Handlers (infinite loops which can be
|
|
||||||
modified)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ARM Macro Assembler Page 4
|
|
||||||
|
|
||||||
|
|
||||||
128 00000008
|
|
||||||
129 00000008 NMI_Handler
|
|
||||||
PROC
|
|
||||||
130 00000008 EXPORT NMI_Handler
|
|
||||||
[WEAK]
|
|
||||||
131 00000008 E7FE B .
|
|
||||||
132 0000000A ENDP
|
|
||||||
134 0000000A HardFault_Handler
|
|
||||||
PROC
|
|
||||||
135 0000000A EXPORT HardFault_Handler
|
|
||||||
[WEAK]
|
|
||||||
136 0000000A E7FE B .
|
|
||||||
137 0000000C ENDP
|
|
||||||
138 0000000C SVC_Handler
|
|
||||||
PROC
|
|
||||||
139 0000000C EXPORT SVC_Handler
|
|
||||||
[WEAK]
|
|
||||||
140 0000000C E7FE B .
|
|
||||||
141 0000000E ENDP
|
|
||||||
142 0000000E PendSV_Handler
|
|
||||||
PROC
|
|
||||||
143 0000000E EXPORT PendSV_Handler
|
|
||||||
[WEAK]
|
|
||||||
144 0000000E E7FE B .
|
|
||||||
145 00000010 ENDP
|
|
||||||
146 00000010 SysTick_Handler
|
|
||||||
PROC
|
|
||||||
147 00000010 EXPORT SysTick_Handler
|
|
||||||
[WEAK]
|
|
||||||
148 00000010 E7FE B .
|
|
||||||
149 00000012 ENDP
|
|
||||||
150 00000012
|
|
||||||
151 00000012 Default_Handler
|
|
||||||
PROC
|
|
||||||
152 00000012
|
|
||||||
153 00000012 EXPORT WWDG_IRQHandler
|
|
||||||
[WEAK]
|
|
||||||
154 00000012 EXPORT PVD_IRQHandler
|
|
||||||
[WEAK]
|
|
||||||
155 00000012 EXPORT RTC_IRQHandler
|
|
||||||
[WEAK]
|
|
||||||
156 00000012 EXPORT FLASH_IRQHandler
|
|
||||||
[WEAK]
|
|
||||||
157 00000012 EXPORT RCC_CRS_IRQHandler
|
|
||||||
[WEAK]
|
|
||||||
158 00000012 EXPORT EXTI0_1_IRQHandler
|
|
||||||
[WEAK]
|
|
||||||
159 00000012 EXPORT EXTI2_3_IRQHandler
|
|
||||||
[WEAK]
|
|
||||||
160 00000012 EXPORT EXTI4_15_IRQHandler
|
|
||||||
[WEAK]
|
|
||||||
161 00000012 EXPORT TSC_IRQHandler
|
|
||||||
[WEAK]
|
|
||||||
162 00000012 EXPORT DMA1_Channel1_IRQHandler
|
|
||||||
[WEAK]
|
|
||||||
163 00000012 EXPORT DMA1_Channel2_3_IRQHandler
|
|
||||||
[WEAK]
|
|
||||||
164 00000012 EXPORT DMA1_Channel4_5_6_7_IRQHandler
|
|
||||||
[WEAK]
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ARM Macro Assembler Page 5
|
|
||||||
|
|
||||||
|
|
||||||
165 00000012 EXPORT ADC1_COMP_IRQHandler
|
|
||||||
[WEAK]
|
|
||||||
166 00000012 EXPORT LPTIM1_IRQHandler
|
|
||||||
[WEAK]
|
|
||||||
167 00000012 EXPORT USART4_5_IRQHandler
|
|
||||||
[WEAK]
|
|
||||||
168 00000012 EXPORT TIM2_IRQHandler
|
|
||||||
[WEAK]
|
|
||||||
169 00000012 EXPORT TIM3_IRQHandler
|
|
||||||
[WEAK]
|
|
||||||
170 00000012 EXPORT TIM6_DAC_IRQHandler
|
|
||||||
[WEAK]
|
|
||||||
171 00000012 EXPORT TIM7_IRQHandler
|
|
||||||
[WEAK]
|
|
||||||
172 00000012 EXPORT TIM21_IRQHandler
|
|
||||||
[WEAK]
|
|
||||||
173 00000012 EXPORT TIM22_IRQHandler
|
|
||||||
[WEAK]
|
|
||||||
174 00000012 EXPORT I2C1_IRQHandler
|
|
||||||
[WEAK]
|
|
||||||
175 00000012 EXPORT I2C2_IRQHandler
|
|
||||||
[WEAK]
|
|
||||||
176 00000012 EXPORT I2C3_IRQHandler
|
|
||||||
[WEAK]
|
|
||||||
177 00000012 EXPORT SPI1_IRQHandler
|
|
||||||
[WEAK]
|
|
||||||
178 00000012 EXPORT SPI2_IRQHandler
|
|
||||||
[WEAK]
|
|
||||||
179 00000012 EXPORT USART1_IRQHandler
|
|
||||||
[WEAK]
|
|
||||||
180 00000012 EXPORT USART2_IRQHandler
|
|
||||||
[WEAK]
|
|
||||||
181 00000012 EXPORT RNG_LPUART1_IRQHandler
|
|
||||||
[WEAK]
|
|
||||||
182 00000012 EXPORT USB_IRQHandler
|
|
||||||
[WEAK]
|
|
||||||
183 00000012
|
|
||||||
184 00000012
|
|
||||||
185 00000012 WWDG_IRQHandler
|
|
||||||
186 00000012 PVD_IRQHandler
|
|
||||||
187 00000012 RTC_IRQHandler
|
|
||||||
188 00000012 FLASH_IRQHandler
|
|
||||||
189 00000012 RCC_CRS_IRQHandler
|
|
||||||
190 00000012 EXTI0_1_IRQHandler
|
|
||||||
191 00000012 EXTI2_3_IRQHandler
|
|
||||||
192 00000012 EXTI4_15_IRQHandler
|
|
||||||
193 00000012 TSC_IRQHandler
|
|
||||||
194 00000012 DMA1_Channel1_IRQHandler
|
|
||||||
195 00000012 DMA1_Channel2_3_IRQHandler
|
|
||||||
196 00000012 DMA1_Channel4_5_6_7_IRQHandler
|
|
||||||
197 00000012 ADC1_COMP_IRQHandler
|
|
||||||
198 00000012 LPTIM1_IRQHandler
|
|
||||||
199 00000012 USART4_5_IRQHandler
|
|
||||||
200 00000012 TIM2_IRQHandler
|
|
||||||
201 00000012 TIM3_IRQHandler
|
|
||||||
202 00000012 TIM6_DAC_IRQHandler
|
|
||||||
203 00000012 TIM7_IRQHandler
|
|
||||||
204 00000012 TIM21_IRQHandler
|
|
||||||
205 00000012 TIM22_IRQHandler
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ARM Macro Assembler Page 6
|
|
||||||
|
|
||||||
|
|
||||||
206 00000012 I2C1_IRQHandler
|
|
||||||
207 00000012 I2C2_IRQHandler
|
|
||||||
208 00000012 I2C3_IRQHandler
|
|
||||||
209 00000012 SPI1_IRQHandler
|
|
||||||
210 00000012 SPI2_IRQHandler
|
|
||||||
211 00000012 USART1_IRQHandler
|
|
||||||
212 00000012 USART2_IRQHandler
|
|
||||||
213 00000012 RNG_LPUART1_IRQHandler
|
|
||||||
214 00000012 USB_IRQHandler
|
|
||||||
215 00000012
|
|
||||||
216 00000012 E7FE B .
|
|
||||||
217 00000014
|
|
||||||
218 00000014 ENDP
|
|
||||||
219 00000014
|
|
||||||
220 00000014 ALIGN
|
|
||||||
221 00000014
|
|
||||||
222 00000014 ;*******************************************************
|
|
||||||
************************
|
|
||||||
223 00000014 ; User Stack and Heap initialization
|
|
||||||
224 00000014 ;*******************************************************
|
|
||||||
************************
|
|
||||||
225 00000014 IF :DEF:__MICROLIB
|
|
||||||
232 00000014
|
|
||||||
233 00000014 IMPORT __use_two_region_memory
|
|
||||||
234 00000014 EXPORT __user_initial_stackheap
|
|
||||||
235 00000014
|
|
||||||
236 00000014 __user_initial_stackheap
|
|
||||||
237 00000014
|
|
||||||
238 00000014 4804 LDR R0, = Heap_Mem
|
|
||||||
239 00000016 4905 LDR R1, =(Stack_Mem + Stack_Size)
|
|
||||||
240 00000018 4A05 LDR R2, = (Heap_Mem + Heap_Size)
|
|
||||||
241 0000001A 4B06 LDR R3, = Stack_Mem
|
|
||||||
242 0000001C 4770 BX LR
|
|
||||||
243 0000001E
|
|
||||||
244 0000001E 00 00 ALIGN
|
|
||||||
245 00000020
|
|
||||||
246 00000020 ENDIF
|
|
||||||
247 00000020
|
|
||||||
248 00000020 END
|
|
||||||
00000000
|
|
||||||
00000000
|
|
||||||
00000000
|
|
||||||
00000600
|
|
||||||
00000400
|
|
||||||
00000000
|
|
||||||
Command Line: --debug --xref --diag_suppress=9931 --cpu=Cortex-M0+ --apcs=inter
|
|
||||||
work --depend=motor\startup_stm32l072xx.d -omotor\startup_stm32l072xx.o -I.\RTE
|
|
||||||
\_motor -IS:\software\MDK\ARM\Packs\ARM\CMSIS\5.9.0\CMSIS\Core\Include -IS:\sof
|
|
||||||
tware\MDK\ARM\Packs\Keil\STM32L0xx_DFP\2.2.0\Drivers\CMSIS\Device\ST\STM32L0xx\
|
|
||||||
Include --predefine="__UVISION_VERSION SETA 538" --predefine="_RTE_ SETA 1" --p
|
|
||||||
redefine="STM32L072xx SETA 1" --predefine="_RTE_ SETA 1" --list=startup_stm32l0
|
|
||||||
72xx.lst startup_stm32l072xx.s
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ARM Macro Assembler Page 1 Alphabetic symbol ordering
|
|
||||||
Relocatable symbols
|
|
||||||
|
|
||||||
STACK 00000000
|
|
||||||
|
|
||||||
Symbol: STACK
|
|
||||||
Definitions
|
|
||||||
At line 33 in file startup_stm32l072xx.s
|
|
||||||
Uses
|
|
||||||
None
|
|
||||||
Comment: STACK unused
|
|
||||||
Stack_Mem 00000000
|
|
||||||
|
|
||||||
Symbol: Stack_Mem
|
|
||||||
Definitions
|
|
||||||
At line 34 in file startup_stm32l072xx.s
|
|
||||||
Uses
|
|
||||||
At line 239 in file startup_stm32l072xx.s
|
|
||||||
At line 241 in file startup_stm32l072xx.s
|
|
||||||
|
|
||||||
__initial_sp 00000600
|
|
||||||
|
|
||||||
Symbol: __initial_sp
|
|
||||||
Definitions
|
|
||||||
At line 35 in file startup_stm32l072xx.s
|
|
||||||
Uses
|
|
||||||
At line 59 in file startup_stm32l072xx.s
|
|
||||||
Comment: __initial_sp used once
|
|
||||||
3 symbols
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ARM Macro Assembler Page 1 Alphabetic symbol ordering
|
|
||||||
Relocatable symbols
|
|
||||||
|
|
||||||
HEAP 00000000
|
|
||||||
|
|
||||||
Symbol: HEAP
|
|
||||||
Definitions
|
|
||||||
At line 44 in file startup_stm32l072xx.s
|
|
||||||
Uses
|
|
||||||
None
|
|
||||||
Comment: HEAP unused
|
|
||||||
Heap_Mem 00000000
|
|
||||||
|
|
||||||
Symbol: Heap_Mem
|
|
||||||
Definitions
|
|
||||||
At line 46 in file startup_stm32l072xx.s
|
|
||||||
Uses
|
|
||||||
At line 238 in file startup_stm32l072xx.s
|
|
||||||
At line 240 in file startup_stm32l072xx.s
|
|
||||||
|
|
||||||
__heap_base 00000000
|
|
||||||
|
|
||||||
Symbol: __heap_base
|
|
||||||
Definitions
|
|
||||||
At line 45 in file startup_stm32l072xx.s
|
|
||||||
Uses
|
|
||||||
None
|
|
||||||
Comment: __heap_base unused
|
|
||||||
__heap_limit 00000400
|
|
||||||
|
|
||||||
Symbol: __heap_limit
|
|
||||||
Definitions
|
|
||||||
At line 47 in file startup_stm32l072xx.s
|
|
||||||
Uses
|
|
||||||
None
|
|
||||||
Comment: __heap_limit unused
|
|
||||||
4 symbols
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ARM Macro Assembler Page 1 Alphabetic symbol ordering
|
|
||||||
Relocatable symbols
|
|
||||||
|
|
||||||
RESET 00000000
|
|
||||||
|
|
||||||
Symbol: RESET
|
|
||||||
Definitions
|
|
||||||
At line 54 in file startup_stm32l072xx.s
|
|
||||||
Uses
|
|
||||||
None
|
|
||||||
Comment: RESET unused
|
|
||||||
__Vectors 00000000
|
|
||||||
|
|
||||||
Symbol: __Vectors
|
|
||||||
Definitions
|
|
||||||
At line 59 in file startup_stm32l072xx.s
|
|
||||||
Uses
|
|
||||||
At line 55 in file startup_stm32l072xx.s
|
|
||||||
At line 112 in file startup_stm32l072xx.s
|
|
||||||
|
|
||||||
__Vectors_End 000000C0
|
|
||||||
|
|
||||||
Symbol: __Vectors_End
|
|
||||||
Definitions
|
|
||||||
At line 110 in file startup_stm32l072xx.s
|
|
||||||
Uses
|
|
||||||
At line 56 in file startup_stm32l072xx.s
|
|
||||||
At line 112 in file startup_stm32l072xx.s
|
|
||||||
|
|
||||||
3 symbols
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ARM Macro Assembler Page 1 Alphabetic symbol ordering
|
|
||||||
Relocatable symbols
|
|
||||||
|
|
||||||
.text 00000000
|
|
||||||
|
|
||||||
Symbol: .text
|
|
||||||
Definitions
|
|
||||||
At line 114 in file startup_stm32l072xx.s
|
|
||||||
Uses
|
|
||||||
None
|
|
||||||
Comment: .text unused
|
|
||||||
ADC1_COMP_IRQHandler 00000012
|
|
||||||
|
|
||||||
Symbol: ADC1_COMP_IRQHandler
|
|
||||||
Definitions
|
|
||||||
At line 197 in file startup_stm32l072xx.s
|
|
||||||
Uses
|
|
||||||
At line 89 in file startup_stm32l072xx.s
|
|
||||||
At line 165 in file startup_stm32l072xx.s
|
|
||||||
|
|
||||||
DMA1_Channel1_IRQHandler 00000012
|
|
||||||
|
|
||||||
Symbol: DMA1_Channel1_IRQHandler
|
|
||||||
Definitions
|
|
||||||
At line 194 in file startup_stm32l072xx.s
|
|
||||||
Uses
|
|
||||||
At line 86 in file startup_stm32l072xx.s
|
|
||||||
At line 162 in file startup_stm32l072xx.s
|
|
||||||
|
|
||||||
DMA1_Channel2_3_IRQHandler 00000012
|
|
||||||
|
|
||||||
Symbol: DMA1_Channel2_3_IRQHandler
|
|
||||||
Definitions
|
|
||||||
At line 195 in file startup_stm32l072xx.s
|
|
||||||
Uses
|
|
||||||
At line 87 in file startup_stm32l072xx.s
|
|
||||||
At line 163 in file startup_stm32l072xx.s
|
|
||||||
|
|
||||||
DMA1_Channel4_5_6_7_IRQHandler 00000012
|
|
||||||
|
|
||||||
Symbol: DMA1_Channel4_5_6_7_IRQHandler
|
|
||||||
Definitions
|
|
||||||
At line 196 in file startup_stm32l072xx.s
|
|
||||||
Uses
|
|
||||||
At line 88 in file startup_stm32l072xx.s
|
|
||||||
At line 164 in file startup_stm32l072xx.s
|
|
||||||
|
|
||||||
Default_Handler 00000012
|
|
||||||
|
|
||||||
Symbol: Default_Handler
|
|
||||||
Definitions
|
|
||||||
At line 151 in file startup_stm32l072xx.s
|
|
||||||
Uses
|
|
||||||
None
|
|
||||||
Comment: Default_Handler unused
|
|
||||||
EXTI0_1_IRQHandler 00000012
|
|
||||||
|
|
||||||
Symbol: EXTI0_1_IRQHandler
|
|
||||||
Definitions
|
|
||||||
At line 190 in file startup_stm32l072xx.s
|
|
||||||
Uses
|
|
||||||
At line 82 in file startup_stm32l072xx.s
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ARM Macro Assembler Page 2 Alphabetic symbol ordering
|
|
||||||
Relocatable symbols
|
|
||||||
|
|
||||||
At line 158 in file startup_stm32l072xx.s
|
|
||||||
|
|
||||||
EXTI2_3_IRQHandler 00000012
|
|
||||||
|
|
||||||
Symbol: EXTI2_3_IRQHandler
|
|
||||||
Definitions
|
|
||||||
At line 191 in file startup_stm32l072xx.s
|
|
||||||
Uses
|
|
||||||
At line 83 in file startup_stm32l072xx.s
|
|
||||||
At line 159 in file startup_stm32l072xx.s
|
|
||||||
|
|
||||||
EXTI4_15_IRQHandler 00000012
|
|
||||||
|
|
||||||
Symbol: EXTI4_15_IRQHandler
|
|
||||||
Definitions
|
|
||||||
At line 192 in file startup_stm32l072xx.s
|
|
||||||
Uses
|
|
||||||
At line 84 in file startup_stm32l072xx.s
|
|
||||||
At line 160 in file startup_stm32l072xx.s
|
|
||||||
|
|
||||||
FLASH_IRQHandler 00000012
|
|
||||||
|
|
||||||
Symbol: FLASH_IRQHandler
|
|
||||||
Definitions
|
|
||||||
At line 188 in file startup_stm32l072xx.s
|
|
||||||
Uses
|
|
||||||
At line 80 in file startup_stm32l072xx.s
|
|
||||||
At line 156 in file startup_stm32l072xx.s
|
|
||||||
|
|
||||||
HardFault_Handler 0000000A
|
|
||||||
|
|
||||||
Symbol: HardFault_Handler
|
|
||||||
Definitions
|
|
||||||
At line 134 in file startup_stm32l072xx.s
|
|
||||||
Uses
|
|
||||||
At line 62 in file startup_stm32l072xx.s
|
|
||||||
At line 135 in file startup_stm32l072xx.s
|
|
||||||
|
|
||||||
I2C1_IRQHandler 00000012
|
|
||||||
|
|
||||||
Symbol: I2C1_IRQHandler
|
|
||||||
Definitions
|
|
||||||
At line 206 in file startup_stm32l072xx.s
|
|
||||||
Uses
|
|
||||||
At line 100 in file startup_stm32l072xx.s
|
|
||||||
At line 174 in file startup_stm32l072xx.s
|
|
||||||
|
|
||||||
I2C2_IRQHandler 00000012
|
|
||||||
|
|
||||||
Symbol: I2C2_IRQHandler
|
|
||||||
Definitions
|
|
||||||
At line 207 in file startup_stm32l072xx.s
|
|
||||||
Uses
|
|
||||||
At line 101 in file startup_stm32l072xx.s
|
|
||||||
At line 175 in file startup_stm32l072xx.s
|
|
||||||
|
|
||||||
I2C3_IRQHandler 00000012
|
|
||||||
|
|
||||||
Symbol: I2C3_IRQHandler
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ARM Macro Assembler Page 3 Alphabetic symbol ordering
|
|
||||||
Relocatable symbols
|
|
||||||
|
|
||||||
Definitions
|
|
||||||
At line 208 in file startup_stm32l072xx.s
|
|
||||||
Uses
|
|
||||||
At line 98 in file startup_stm32l072xx.s
|
|
||||||
At line 176 in file startup_stm32l072xx.s
|
|
||||||
|
|
||||||
LPTIM1_IRQHandler 00000012
|
|
||||||
|
|
||||||
Symbol: LPTIM1_IRQHandler
|
|
||||||
Definitions
|
|
||||||
At line 198 in file startup_stm32l072xx.s
|
|
||||||
Uses
|
|
||||||
At line 90 in file startup_stm32l072xx.s
|
|
||||||
At line 166 in file startup_stm32l072xx.s
|
|
||||||
|
|
||||||
NMI_Handler 00000008
|
|
||||||
|
|
||||||
Symbol: NMI_Handler
|
|
||||||
Definitions
|
|
||||||
At line 129 in file startup_stm32l072xx.s
|
|
||||||
Uses
|
|
||||||
At line 61 in file startup_stm32l072xx.s
|
|
||||||
At line 130 in file startup_stm32l072xx.s
|
|
||||||
|
|
||||||
PVD_IRQHandler 00000012
|
|
||||||
|
|
||||||
Symbol: PVD_IRQHandler
|
|
||||||
Definitions
|
|
||||||
At line 186 in file startup_stm32l072xx.s
|
|
||||||
Uses
|
|
||||||
At line 78 in file startup_stm32l072xx.s
|
|
||||||
At line 154 in file startup_stm32l072xx.s
|
|
||||||
|
|
||||||
PendSV_Handler 0000000E
|
|
||||||
|
|
||||||
Symbol: PendSV_Handler
|
|
||||||
Definitions
|
|
||||||
At line 142 in file startup_stm32l072xx.s
|
|
||||||
Uses
|
|
||||||
At line 73 in file startup_stm32l072xx.s
|
|
||||||
At line 143 in file startup_stm32l072xx.s
|
|
||||||
|
|
||||||
RCC_CRS_IRQHandler 00000012
|
|
||||||
|
|
||||||
Symbol: RCC_CRS_IRQHandler
|
|
||||||
Definitions
|
|
||||||
At line 189 in file startup_stm32l072xx.s
|
|
||||||
Uses
|
|
||||||
At line 81 in file startup_stm32l072xx.s
|
|
||||||
At line 157 in file startup_stm32l072xx.s
|
|
||||||
|
|
||||||
RNG_LPUART1_IRQHandler 00000012
|
|
||||||
|
|
||||||
Symbol: RNG_LPUART1_IRQHandler
|
|
||||||
Definitions
|
|
||||||
At line 213 in file startup_stm32l072xx.s
|
|
||||||
Uses
|
|
||||||
At line 106 in file startup_stm32l072xx.s
|
|
||||||
At line 181 in file startup_stm32l072xx.s
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ARM Macro Assembler Page 4 Alphabetic symbol ordering
|
|
||||||
Relocatable symbols
|
|
||||||
|
|
||||||
|
|
||||||
RTC_IRQHandler 00000012
|
|
||||||
|
|
||||||
Symbol: RTC_IRQHandler
|
|
||||||
Definitions
|
|
||||||
At line 187 in file startup_stm32l072xx.s
|
|
||||||
Uses
|
|
||||||
At line 79 in file startup_stm32l072xx.s
|
|
||||||
At line 155 in file startup_stm32l072xx.s
|
|
||||||
|
|
||||||
Reset_Handler 00000000
|
|
||||||
|
|
||||||
Symbol: Reset_Handler
|
|
||||||
Definitions
|
|
||||||
At line 117 in file startup_stm32l072xx.s
|
|
||||||
Uses
|
|
||||||
At line 60 in file startup_stm32l072xx.s
|
|
||||||
At line 118 in file startup_stm32l072xx.s
|
|
||||||
|
|
||||||
SPI1_IRQHandler 00000012
|
|
||||||
|
|
||||||
Symbol: SPI1_IRQHandler
|
|
||||||
Definitions
|
|
||||||
At line 209 in file startup_stm32l072xx.s
|
|
||||||
Uses
|
|
||||||
At line 102 in file startup_stm32l072xx.s
|
|
||||||
At line 177 in file startup_stm32l072xx.s
|
|
||||||
|
|
||||||
SPI2_IRQHandler 00000012
|
|
||||||
|
|
||||||
Symbol: SPI2_IRQHandler
|
|
||||||
Definitions
|
|
||||||
At line 210 in file startup_stm32l072xx.s
|
|
||||||
Uses
|
|
||||||
At line 103 in file startup_stm32l072xx.s
|
|
||||||
At line 178 in file startup_stm32l072xx.s
|
|
||||||
|
|
||||||
SVC_Handler 0000000C
|
|
||||||
|
|
||||||
Symbol: SVC_Handler
|
|
||||||
Definitions
|
|
||||||
At line 138 in file startup_stm32l072xx.s
|
|
||||||
Uses
|
|
||||||
At line 70 in file startup_stm32l072xx.s
|
|
||||||
At line 139 in file startup_stm32l072xx.s
|
|
||||||
|
|
||||||
SysTick_Handler 00000010
|
|
||||||
|
|
||||||
Symbol: SysTick_Handler
|
|
||||||
Definitions
|
|
||||||
At line 146 in file startup_stm32l072xx.s
|
|
||||||
Uses
|
|
||||||
At line 74 in file startup_stm32l072xx.s
|
|
||||||
At line 147 in file startup_stm32l072xx.s
|
|
||||||
|
|
||||||
TIM21_IRQHandler 00000012
|
|
||||||
|
|
||||||
Symbol: TIM21_IRQHandler
|
|
||||||
Definitions
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ARM Macro Assembler Page 5 Alphabetic symbol ordering
|
|
||||||
Relocatable symbols
|
|
||||||
|
|
||||||
At line 204 in file startup_stm32l072xx.s
|
|
||||||
Uses
|
|
||||||
At line 97 in file startup_stm32l072xx.s
|
|
||||||
At line 172 in file startup_stm32l072xx.s
|
|
||||||
|
|
||||||
TIM22_IRQHandler 00000012
|
|
||||||
|
|
||||||
Symbol: TIM22_IRQHandler
|
|
||||||
Definitions
|
|
||||||
At line 205 in file startup_stm32l072xx.s
|
|
||||||
Uses
|
|
||||||
At line 99 in file startup_stm32l072xx.s
|
|
||||||
At line 173 in file startup_stm32l072xx.s
|
|
||||||
|
|
||||||
TIM2_IRQHandler 00000012
|
|
||||||
|
|
||||||
Symbol: TIM2_IRQHandler
|
|
||||||
Definitions
|
|
||||||
At line 200 in file startup_stm32l072xx.s
|
|
||||||
Uses
|
|
||||||
At line 92 in file startup_stm32l072xx.s
|
|
||||||
At line 168 in file startup_stm32l072xx.s
|
|
||||||
|
|
||||||
TIM3_IRQHandler 00000012
|
|
||||||
|
|
||||||
Symbol: TIM3_IRQHandler
|
|
||||||
Definitions
|
|
||||||
At line 201 in file startup_stm32l072xx.s
|
|
||||||
Uses
|
|
||||||
At line 93 in file startup_stm32l072xx.s
|
|
||||||
At line 169 in file startup_stm32l072xx.s
|
|
||||||
|
|
||||||
TIM6_DAC_IRQHandler 00000012
|
|
||||||
|
|
||||||
Symbol: TIM6_DAC_IRQHandler
|
|
||||||
Definitions
|
|
||||||
At line 202 in file startup_stm32l072xx.s
|
|
||||||
Uses
|
|
||||||
At line 94 in file startup_stm32l072xx.s
|
|
||||||
At line 170 in file startup_stm32l072xx.s
|
|
||||||
|
|
||||||
TIM7_IRQHandler 00000012
|
|
||||||
|
|
||||||
Symbol: TIM7_IRQHandler
|
|
||||||
Definitions
|
|
||||||
At line 203 in file startup_stm32l072xx.s
|
|
||||||
Uses
|
|
||||||
At line 95 in file startup_stm32l072xx.s
|
|
||||||
At line 171 in file startup_stm32l072xx.s
|
|
||||||
|
|
||||||
TSC_IRQHandler 00000012
|
|
||||||
|
|
||||||
Symbol: TSC_IRQHandler
|
|
||||||
Definitions
|
|
||||||
At line 193 in file startup_stm32l072xx.s
|
|
||||||
Uses
|
|
||||||
At line 85 in file startup_stm32l072xx.s
|
|
||||||
At line 161 in file startup_stm32l072xx.s
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ARM Macro Assembler Page 6 Alphabetic symbol ordering
|
|
||||||
Relocatable symbols
|
|
||||||
|
|
||||||
USART1_IRQHandler 00000012
|
|
||||||
|
|
||||||
Symbol: USART1_IRQHandler
|
|
||||||
Definitions
|
|
||||||
At line 211 in file startup_stm32l072xx.s
|
|
||||||
Uses
|
|
||||||
At line 104 in file startup_stm32l072xx.s
|
|
||||||
At line 179 in file startup_stm32l072xx.s
|
|
||||||
|
|
||||||
USART2_IRQHandler 00000012
|
|
||||||
|
|
||||||
Symbol: USART2_IRQHandler
|
|
||||||
Definitions
|
|
||||||
At line 212 in file startup_stm32l072xx.s
|
|
||||||
Uses
|
|
||||||
At line 105 in file startup_stm32l072xx.s
|
|
||||||
At line 180 in file startup_stm32l072xx.s
|
|
||||||
|
|
||||||
USART4_5_IRQHandler 00000012
|
|
||||||
|
|
||||||
Symbol: USART4_5_IRQHandler
|
|
||||||
Definitions
|
|
||||||
At line 199 in file startup_stm32l072xx.s
|
|
||||||
Uses
|
|
||||||
At line 91 in file startup_stm32l072xx.s
|
|
||||||
At line 167 in file startup_stm32l072xx.s
|
|
||||||
|
|
||||||
USB_IRQHandler 00000012
|
|
||||||
|
|
||||||
Symbol: USB_IRQHandler
|
|
||||||
Definitions
|
|
||||||
At line 214 in file startup_stm32l072xx.s
|
|
||||||
Uses
|
|
||||||
At line 108 in file startup_stm32l072xx.s
|
|
||||||
At line 182 in file startup_stm32l072xx.s
|
|
||||||
|
|
||||||
WWDG_IRQHandler 00000012
|
|
||||||
|
|
||||||
Symbol: WWDG_IRQHandler
|
|
||||||
Definitions
|
|
||||||
At line 185 in file startup_stm32l072xx.s
|
|
||||||
Uses
|
|
||||||
At line 77 in file startup_stm32l072xx.s
|
|
||||||
At line 153 in file startup_stm32l072xx.s
|
|
||||||
|
|
||||||
__user_initial_stackheap 00000014
|
|
||||||
|
|
||||||
Symbol: __user_initial_stackheap
|
|
||||||
Definitions
|
|
||||||
At line 236 in file startup_stm32l072xx.s
|
|
||||||
Uses
|
|
||||||
At line 234 in file startup_stm32l072xx.s
|
|
||||||
Comment: __user_initial_stackheap used once
|
|
||||||
39 symbols
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ARM Macro Assembler Page 1 Alphabetic symbol ordering
|
|
||||||
Absolute symbols
|
|
||||||
|
|
||||||
Heap_Size 00000400
|
|
||||||
|
|
||||||
Symbol: Heap_Size
|
|
||||||
Definitions
|
|
||||||
At line 42 in file startup_stm32l072xx.s
|
|
||||||
Uses
|
|
||||||
At line 46 in file startup_stm32l072xx.s
|
|
||||||
At line 240 in file startup_stm32l072xx.s
|
|
||||||
|
|
||||||
Stack_Size 00000600
|
|
||||||
|
|
||||||
Symbol: Stack_Size
|
|
||||||
Definitions
|
|
||||||
At line 31 in file startup_stm32l072xx.s
|
|
||||||
Uses
|
|
||||||
At line 34 in file startup_stm32l072xx.s
|
|
||||||
At line 239 in file startup_stm32l072xx.s
|
|
||||||
|
|
||||||
__Vectors_Size 000000C0
|
|
||||||
|
|
||||||
Symbol: __Vectors_Size
|
|
||||||
Definitions
|
|
||||||
At line 112 in file startup_stm32l072xx.s
|
|
||||||
Uses
|
|
||||||
At line 57 in file startup_stm32l072xx.s
|
|
||||||
Comment: __Vectors_Size used once
|
|
||||||
3 symbols
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ARM Macro Assembler Page 1 Alphabetic symbol ordering
|
|
||||||
External symbols
|
|
||||||
|
|
||||||
SystemInit 00000000
|
|
||||||
|
|
||||||
Symbol: SystemInit
|
|
||||||
Definitions
|
|
||||||
At line 120 in file startup_stm32l072xx.s
|
|
||||||
Uses
|
|
||||||
At line 121 in file startup_stm32l072xx.s
|
|
||||||
Comment: SystemInit used once
|
|
||||||
__main 00000000
|
|
||||||
|
|
||||||
Symbol: __main
|
|
||||||
Definitions
|
|
||||||
At line 119 in file startup_stm32l072xx.s
|
|
||||||
Uses
|
|
||||||
At line 123 in file startup_stm32l072xx.s
|
|
||||||
Comment: __main used once
|
|
||||||
__use_two_region_memory 00000000
|
|
||||||
|
|
||||||
Symbol: __use_two_region_memory
|
|
||||||
Definitions
|
|
||||||
At line 233 in file startup_stm32l072xx.s
|
|
||||||
Uses
|
|
||||||
None
|
|
||||||
Comment: __use_two_region_memory unused
|
|
||||||
3 symbols
|
|
||||||
392 symbols in table
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "app.h"
|
#include "app.h"
|
||||||
// #include "board.h"
|
#include "board.h"
|
||||||
#include "uarts.h"
|
#include "uarts.h"
|
||||||
#include "sys.h"
|
#include "sys.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -12,6 +12,7 @@ uint8_t mem_percent = 0; // 内存使用率
|
||||||
|
|
||||||
void app_init(void)
|
void app_init(void)
|
||||||
{
|
{
|
||||||
|
motor_process_init();
|
||||||
flow_init(); // 流程初始化
|
flow_init(); // 流程初始化
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,13 +8,17 @@
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
bool is_open;
|
bool is_open;
|
||||||
uint32_t calibration_value;
|
float32 calibration_value;
|
||||||
uint32_t original_value;
|
uint32_t original_value;
|
||||||
} calibration_sensor_data_t;
|
} calibration_sensor_data_t;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
calibration_sensor_data_t torsion_in13; // 扭力
|
calibration_sensor_data_t torsion_in13; // 扭力
|
||||||
|
calibration_sensor_data_t ipressure_in7; // 压力
|
||||||
|
calibration_sensor_data_t iflow_in8; // 流量
|
||||||
|
calibration_sensor_data_t opressure_in9; // 压力
|
||||||
|
calibration_sensor_data_t oflow_in10; // 流量
|
||||||
} adcs_t;
|
} adcs_t;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
extern __IO app_t app;
|
extern __IO app_t app;
|
||||||
extern motor_t *motor;
|
extern motor_t *motor;
|
||||||
|
extern uint8_t detect_result;
|
||||||
|
|
||||||
static struct flow fl_adc_inspection; // ADC
|
static struct flow fl_adc_inspection; // ADC
|
||||||
static struct flow fl_systom_inspection; // 系统
|
static struct flow fl_systom_inspection; // 系统
|
||||||
|
@ -17,8 +18,29 @@ static uint8_t adc_inspection(struct flow *fl)
|
||||||
FL_HEAD(fl);
|
FL_HEAD(fl);
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
app.adc.torsion_in13.original_value = adc_get_result_average(IN13);
|
detect_result = ST_DEV_NORMAL;
|
||||||
FL_LOCK_DELAY(fl, FL_CLOCK_100MSEC); /* 延时100毫秒 */
|
// 扭力
|
||||||
|
app.adc.torsion_in13.original_value = get_sensor_adc(GET_TORSION_VALUE);
|
||||||
|
app.adc.torsion_in13.calibration_value = torsion_detect();
|
||||||
|
sensor_adc[GET_TORSION_VALUE] = S2B_UINT16(app.adc.torsion_in13.original_value);
|
||||||
|
// 输入压力
|
||||||
|
app.adc.ipressure_in7.original_value = get_sensor_adc(GET_INPUT_PRESS_VALUE);
|
||||||
|
app.adc.ipressure_in7.calibration_value = pressure_detect(GET_INPUT_PRESS_VALUE);
|
||||||
|
sensor_adc[GET_INPUT_PRESS_VALUE] = S2B_UINT16(app.adc.ipressure_in7.original_value);
|
||||||
|
// 输出压力
|
||||||
|
app.adc.opressure_in9.original_value = get_sensor_adc(GET_OUTPUT_PRESS_VALUE);
|
||||||
|
app.adc.opressure_in9.calibration_value = pressure_detect(GET_OUTPUT_PRESS_VALUE);
|
||||||
|
sensor_adc[GET_OUTPUT_PRESS_VALUE] = S2B_UINT16(app.adc.opressure_in9.original_value);
|
||||||
|
// 输入流量
|
||||||
|
app.adc.iflow_in8.original_value = get_sensor_adc(GET_INPUT_FLOW_VALUE);
|
||||||
|
app.adc.iflow_in8.calibration_value = flow_detect(GET_INPUT_FLOW_VALUE);
|
||||||
|
sensor_adc[GET_INPUT_FLOW_VALUE] = S2B_UINT16(app.adc.iflow_in8.original_value);
|
||||||
|
// 输出流量
|
||||||
|
app.adc.oflow_in10.original_value = get_sensor_adc(GET_OUTPUT_FLOW_VALUE);
|
||||||
|
app.adc.oflow_in10.calibration_value = flow_detect(GET_OUTPUT_FLOW_VALUE);
|
||||||
|
sensor_adc[GET_OUTPUT_FLOW_VALUE] = S2B_UINT16(app.adc.oflow_in10.original_value);
|
||||||
|
|
||||||
|
FL_LOCK_DELAY(fl, FL_CLOCK_10MSEC); /* 延时10毫秒 */
|
||||||
}
|
}
|
||||||
FL_TAIL(fl);
|
FL_TAIL(fl);
|
||||||
}
|
}
|
||||||
|
@ -28,7 +50,8 @@ static uint8_t systom_inspection(struct flow *fl)
|
||||||
FL_HEAD(fl);
|
FL_HEAD(fl);
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
FL_LOCK_DELAY(fl, FL_CLOCK_100MSEC); /* 延时100毫秒 */
|
host_rx_msg_deal();
|
||||||
|
FL_LOCK_DELAY(fl, FL_CLOCK_10MSEC); /* 延时10毫秒 */
|
||||||
}
|
}
|
||||||
FL_TAIL(fl);
|
FL_TAIL(fl);
|
||||||
}
|
}
|
||||||
|
@ -38,8 +61,9 @@ static uint8_t idle_inspection(struct flow *fl)
|
||||||
FL_HEAD(fl);
|
FL_HEAD(fl);
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
|
test_process();
|
||||||
cpu_percent = scheduler_time_occupancy_get(1000);
|
cpu_percent = scheduler_time_occupancy_get(1000);
|
||||||
FL_LOCK_DELAY(fl, FL_CLOCK_SEC);
|
FL_LOCK_DELAY(fl, FL_CLOCK_10MSEC);
|
||||||
}
|
}
|
||||||
FL_TAIL(fl);
|
FL_TAIL(fl);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,17 @@
|
||||||
#include "board.h"
|
#include "board.h"
|
||||||
#include "motor.h"
|
#include "motor.h"
|
||||||
|
|
||||||
|
extern uint8_t detect_result;
|
||||||
void motor_process(frame_msg_t *rx, frame_msg_t *bk);
|
void motor_process(frame_msg_t *rx, frame_msg_t *bk);
|
||||||
void sensor_procss(frame_msg_t *rx, frame_msg_t *bk);
|
void sensor_process(frame_msg_t *rx, frame_msg_t *bk);
|
||||||
|
void error_process(uint8_t err, frame_msg_t *rx, frame_msg_t *bk);
|
||||||
|
|
||||||
/************************************* 串口通讯 *************************************/
|
/************************************* 串口通讯 *************************************/
|
||||||
uart_t *uarts[UART_NUM_MAX];
|
uart_t *uarts[UART_NUM_MAX];
|
||||||
__IO static BOOL deal_done_flag = FALSE; // 数据处理标志
|
__IO static BOOL execute_state = IDLE; // 数据处理标志
|
||||||
__IO static frame_msg_t rx_frame;
|
static frame_msg_t rx_msg; // 接收数据句柄
|
||||||
__IO static frame_msg_t bk_frame;
|
static frame_msg_t bk_msg; // 回复数据句柄
|
||||||
__IO static uint8_t send_buffer[UART_TXSIZE];
|
static uint8_t host_send_buffer[UART_TXSIZE] = {0}; // 数据发送缓存
|
||||||
|
|
||||||
// 串口发送
|
// 串口发送
|
||||||
static void host_send_msg(uint8_t *data, uint16_t len)
|
static void host_send_msg(uint8_t *data, uint16_t len)
|
||||||
|
@ -17,110 +19,30 @@ static void host_send_msg(uint8_t *data, uint16_t len)
|
||||||
uart_send_data(uarts[UART_NUM_1], data, len);
|
uart_send_data(uarts[UART_NUM_1], data, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 接收数据解码
|
// 数据有效性检查
|
||||||
static void host_data_decode(uint8_t *data, uint16_t len, frame_msg_t *msg)
|
|
||||||
{
|
|
||||||
DBG_ASSERT(data != NULL __DBG_LINE);
|
|
||||||
DBG_ASSERT(msg != NULL __DBG_LINE);
|
|
||||||
|
|
||||||
msg->state = data[1];
|
|
||||||
msg->dev_no = data[2];
|
|
||||||
msg->cmd_no = data[3];
|
|
||||||
msg->len = data[4];
|
|
||||||
osel_memcpy(msg->data, (uint8_t *)&data[5], msg->len);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 发送数据编码
|
|
||||||
static void send_data_encode(frame_msg_t *msg)
|
|
||||||
{
|
|
||||||
uint16_t ver_len = 0, ver_crc = 0;
|
|
||||||
uint8_t *sp = (uint8_t *)send_buffer;
|
|
||||||
DBG_ASSERT(msg != NULL __DBG_LINE);
|
|
||||||
|
|
||||||
*sp++ = PACKET_STX; // 包头
|
|
||||||
ver_len++;
|
|
||||||
*sp++ = msg->state; // 状态
|
|
||||||
ver_len++;
|
|
||||||
*sp++ = msg->dev_no; // 设备号
|
|
||||||
ver_len++;
|
|
||||||
*sp++ = msg->cmd_no; // 命令号
|
|
||||||
ver_len++;
|
|
||||||
*sp++ = msg->len; // 长度
|
|
||||||
ver_len++;
|
|
||||||
osel_memcpy(sp, msg->data, msg->len); // 数据
|
|
||||||
sp += msg->len;
|
|
||||||
ver_len += msg->len;
|
|
||||||
|
|
||||||
ver_crc = crc16_compute((uint8_t *)&send_buffer[1], (ver_len - 1)); // 减去包头
|
|
||||||
ver_crc = S2B_UINT16(ver_crc);
|
|
||||||
osel_memcpy(sp, (uint8_t *)&ver_crc, 2); // 校验
|
|
||||||
sp += 2;
|
|
||||||
ver_len += 2;
|
|
||||||
|
|
||||||
*sp++ = PACKET_ETX; // 包尾
|
|
||||||
ver_len++;
|
|
||||||
|
|
||||||
// 发送
|
|
||||||
host_send_msg((uint8_t *)send_buffer, ver_len);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 数据处理
|
|
||||||
void host_data_deal(uint8_t *data, uint16_t len)
|
|
||||||
{
|
|
||||||
frame_msg_t *rx_msg = (frame_msg_t *)&rx_frame;
|
|
||||||
frame_msg_t *bk_msg = (frame_msg_t *)&bk_frame;
|
|
||||||
|
|
||||||
if (deal_done_flag == TRUE)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 解析
|
|
||||||
host_data_decode(data, len, rx_msg);
|
|
||||||
// 执行
|
|
||||||
switch (rx_msg->dev_no)
|
|
||||||
{
|
|
||||||
case ADC_SENSOR:
|
|
||||||
sensor_procss(rx_msg, bk_msg);
|
|
||||||
break;
|
|
||||||
case MOTOR:
|
|
||||||
motor_process(rx_msg, bk_msg);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 回复(组包 + 发送)
|
|
||||||
send_data_encode(bk_msg);
|
|
||||||
// 修改标志位
|
|
||||||
deal_done_flag = TRUE;
|
|
||||||
osel_memset((uint8_t *)rx_msg, 0, sizeof(rx_frame));
|
|
||||||
osel_memset((uint8_t *)bk_msg, 0, sizeof(bk_frame));
|
|
||||||
}
|
|
||||||
|
|
||||||
// 数据完整性检查
|
|
||||||
static BOOL host_data_verify(uint8_t *data, uint16_t len)
|
static BOOL host_data_verify(uint8_t *data, uint16_t len)
|
||||||
{
|
{
|
||||||
BOOL ret = TRUE;
|
BOOL ret = TRUE;
|
||||||
uint16_t ver_len = 0;
|
uint8_t ver_len = 0;
|
||||||
uint16_t ver_crc = 0, rx_crc = 0;
|
uint8_t msg_crc = 0, ver_crc = 0;
|
||||||
|
|
||||||
// 包头包尾检查
|
// 包头包尾检查
|
||||||
if (data[0] != PACKET_STX || data[1] != MASTER_CODE || data[len - 1] != PACKET_ETX)
|
if (data[0] != PACKET_STX || data[1] != ST_DEV_NORMAL || data[len - 1] != PACKET_ETX)
|
||||||
{
|
{
|
||||||
ret = FALSE;
|
ret = FALSE;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
// 帧长度检查
|
// 长度检查
|
||||||
ver_len = data[4] + PACKET_MIN_LEN;
|
ver_len = PACKET_MIN_LEN + data[DATA_LEN_INDEX];
|
||||||
if (ver_len != len)
|
if (ver_len != len)
|
||||||
{
|
{
|
||||||
ret = FALSE;
|
ret = FALSE;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
// CRC校验
|
// CRC校验
|
||||||
ver_crc = crc16_compute((uint8_t *)(data + 1), (len - 4)); // 减去包头、包尾、校验
|
msg_crc = data[len - 2];
|
||||||
ver_crc = S2B_UINT16(ver_crc);
|
ver_crc = xor_compute((uint8_t *)&data[1], (len - 3)); // 减去包头、包尾、校验
|
||||||
osel_memcpy((uint8_t *)&rx_crc, (uint8_t *)(data + len - 3), 2);
|
if (msg_crc != ver_crc)
|
||||||
if (ver_crc != rx_crc)
|
|
||||||
{
|
{
|
||||||
ret = FALSE;
|
ret = FALSE;
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -129,22 +51,102 @@ static BOOL host_data_verify(uint8_t *data, uint16_t len)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 数据解码
|
||||||
|
static void host_data_decode(uint8_t *data, uint16_t len)
|
||||||
|
{
|
||||||
|
DBG_ASSERT(data != NULL __DBG_LINE);
|
||||||
|
|
||||||
|
// 获取数据长度和消息长度
|
||||||
|
uint8_t data_len = data[DATA_LEN_INDEX];
|
||||||
|
uint8_t msg_len = DATA_INDEX + data_len;
|
||||||
|
// 获取消息数据
|
||||||
|
osel_memcpy((uint8_t *)&rx_msg, data, msg_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 指令执行
|
||||||
|
static void host_cmd_execute(frame_msg_t *rx_msg, frame_msg_t *bk_msg)
|
||||||
|
{
|
||||||
|
DBG_ASSERT(rx_msg != NULL __DBG_LINE);
|
||||||
|
DBG_ASSERT(bk_msg != NULL __DBG_LINE);
|
||||||
|
|
||||||
|
switch (rx_msg->dev_no)
|
||||||
|
{
|
||||||
|
case ADC_SENSOR:
|
||||||
|
sensor_process(rx_msg, bk_msg);
|
||||||
|
break;
|
||||||
|
case MOTOR:
|
||||||
|
motor_process(rx_msg, bk_msg);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
error_process(ST_CMD_IVALID, rx_msg, bk_msg);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 数据编码
|
||||||
|
static void host_data_encode(frame_msg_t *msg)
|
||||||
|
{
|
||||||
|
DBG_ASSERT(msg != NULL __DBG_LINE);
|
||||||
|
|
||||||
|
uint8_t *pbuf = (uint8_t *)host_send_buffer;
|
||||||
|
uint8_t index = 0, len = 0;
|
||||||
|
|
||||||
|
// 消息数据
|
||||||
|
uint8_t msg_len = DATA_INDEX + msg->len;
|
||||||
|
osel_memcpy(pbuf, (uint8_t *)msg, msg_len);
|
||||||
|
// 校验码
|
||||||
|
index += msg_len;
|
||||||
|
pbuf[index] = xor_compute((uint8_t *)&pbuf[1], (msg_len - 1)); // 减去包头
|
||||||
|
// 包尾
|
||||||
|
index += 1;
|
||||||
|
pbuf[index] = PACKET_ETX;
|
||||||
|
|
||||||
|
// 计算报文长度
|
||||||
|
len = msg_len + 2; // 加上校验、包尾
|
||||||
|
// 发送
|
||||||
|
host_send_msg(pbuf, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 数据处理
|
||||||
|
void host_rx_msg_deal(void)
|
||||||
|
{
|
||||||
|
if (execute_state == IDLE)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
frame_msg_t *p_rx_msg = (frame_msg_t *)&rx_msg;
|
||||||
|
frame_msg_t *p_bk_msg = (frame_msg_t *)&bk_msg;
|
||||||
|
|
||||||
|
// 执行
|
||||||
|
host_cmd_execute(p_rx_msg, p_bk_msg);
|
||||||
|
// 回复(组包 + 发送)
|
||||||
|
host_data_encode(p_bk_msg);
|
||||||
|
// 复位
|
||||||
|
osel_memset((uint8_t *)host_send_buffer, 0, UART_TXSIZE);
|
||||||
|
osel_memset((uint8_t *)&rx_msg, 0, sizeof(frame_msg_t));
|
||||||
|
osel_memset((uint8_t *)&bk_msg, 0, sizeof(frame_msg_t));
|
||||||
|
execute_state = IDLE;
|
||||||
|
detect_result = ST_DEV_NORMAL;
|
||||||
|
}
|
||||||
|
|
||||||
// 串口接收回调
|
// 串口接收回调
|
||||||
static void host_rx_cb(uint8_t uart_index, uint8_t *data, uint16_t len)
|
static void host_rx_cb(uint8_t uart_index, uint8_t *data, uint16_t len)
|
||||||
{
|
{
|
||||||
BOOL ret = FALSE;
|
BOOL ret = FALSE;
|
||||||
|
|
||||||
// 数据完整性检查
|
// 数据有效性检查
|
||||||
ret = host_data_verify(data, len);
|
ret = host_data_verify(data, len);
|
||||||
// 数据处理
|
// 数据解码
|
||||||
if (ret == TRUE && deal_done_flag == TRUE)
|
if (ret == TRUE && execute_state == IDLE)
|
||||||
{
|
{
|
||||||
deal_done_flag = FALSE;
|
host_data_decode(data, len);
|
||||||
|
execute_state = BUSY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 串口初始化
|
// 串口初始化
|
||||||
void host_uart_init(void)
|
static void host_uart_init(void)
|
||||||
{
|
{
|
||||||
if (uarts[UART_NUM_1] == NULL)
|
if (uarts[UART_NUM_1] == NULL)
|
||||||
{
|
{
|
||||||
|
@ -160,6 +162,7 @@ void host_uart_init(void)
|
||||||
/************************************* 电机 *************************************/
|
/************************************* 电机 *************************************/
|
||||||
// 电机对象
|
// 电机对象
|
||||||
motor_t *motor;
|
motor_t *motor;
|
||||||
|
motor_ctrl_t *motor_param = NULL;
|
||||||
|
|
||||||
// 电机初始化
|
// 电机初始化
|
||||||
static void motor_init(void)
|
static void motor_init(void)
|
||||||
|
@ -176,32 +179,112 @@ static void motor_init(void)
|
||||||
motor->handle.step_motor.interface.init(motor, dir, en, MIN_STEP_ANGLE, TIM21, LL_TIM_CHANNEL_CH2);
|
motor->handle.step_motor.interface.init(motor, dir, en, MIN_STEP_ANGLE, TIM21, LL_TIM_CHANNEL_CH2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uint8_t motor_param_get(frame_msg_t *rx, motor_ctrl_t *param)
|
||||||
|
{
|
||||||
|
uint8_t state = ST_DEV_NORMAL;
|
||||||
|
|
||||||
|
// 检查数据长度,方向:1个字节,角度:4个字节
|
||||||
|
if (rx->len < 5)
|
||||||
|
{
|
||||||
|
state = ST_CMD_IVALID;
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
// 方向
|
||||||
|
param->dir = rx->data[0];
|
||||||
|
// 角度
|
||||||
|
osel_memcpy((uint8_t *)¶m->angle, (uint8_t *)&rx->data[1], 4);
|
||||||
|
param->angle = B2S_FLOAT32(param->angle);
|
||||||
|
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint8_t motor_ctrl(uint8_t sw, motor_ctrl_t *param)
|
||||||
|
{
|
||||||
|
step_motor_t *step_motor = &motor->handle.step_motor;
|
||||||
|
uint8_t state = detect_result;
|
||||||
|
if (sw == RUN && detect_result == ST_DEV_NORMAL)
|
||||||
|
{
|
||||||
|
step_motor->interface.set_angle(motor, param->angle, (dir_e)param->dir);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
step_motor->interface.stop(motor);
|
||||||
|
}
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void motor_state(frame_msg_t *rx, frame_msg_t *bk)
|
||||||
|
{
|
||||||
|
DBG_ASSERT(bk != NULL __DBG_LINE);
|
||||||
|
|
||||||
|
step_motor_t *step_motor = &motor->handle.step_motor;
|
||||||
|
uint8_t state = ST_DEV_NORMAL;
|
||||||
|
|
||||||
|
// 回复数据
|
||||||
|
bk->head = PACKET_STX;
|
||||||
|
bk->state = state;
|
||||||
|
bk->dev_no = rx->dev_no;
|
||||||
|
bk->cmd_no = rx->cmd_no;
|
||||||
|
bk->len = sizeof(uint8_t);
|
||||||
|
bk->data[0] = step_motor->attribute.state;
|
||||||
|
}
|
||||||
|
|
||||||
|
void motor_process_init(void)
|
||||||
|
{
|
||||||
|
motor_param = (motor_ctrl_t *)osel_mem_alloc(sizeof(motor_ctrl_t));
|
||||||
|
DBG_ASSERT(motor_param != NULL __DBG_LINE);
|
||||||
|
osel_memset((uint8_t *)motor_param, 0, sizeof(motor_ctrl_t));
|
||||||
|
}
|
||||||
|
|
||||||
// 电机任务
|
// 电机任务
|
||||||
void motor_process(frame_msg_t *rx, frame_msg_t *bk)
|
void motor_process(frame_msg_t *rx, frame_msg_t *bk)
|
||||||
{
|
{
|
||||||
// BOOL ret = TRUE;
|
DBG_ASSERT(rx != NULL __DBG_LINE);
|
||||||
|
DBG_ASSERT(bk != NULL __DBG_LINE);
|
||||||
|
|
||||||
|
motor_ctrl_t *ctrl_param = motor_param;
|
||||||
|
uint8_t state = ST_DEV_NORMAL;
|
||||||
|
|
||||||
switch (rx->cmd_no)
|
switch (rx->cmd_no)
|
||||||
{
|
{
|
||||||
case SET_MOTOR_SPEED: // 设置电机转速
|
case SET_MOTOR_SPEED: // 设置电机转速
|
||||||
break;
|
break;
|
||||||
case SET_DRIVER_PULSE: // 设置驱动器脉冲
|
|
||||||
break;
|
|
||||||
case GET_MIN_STEP: // 获取最小步距
|
|
||||||
break;
|
|
||||||
case GET_MOTOR_STATE: // 获取电机运行状态
|
|
||||||
break;
|
|
||||||
case MOTOR_MOVE: // 运行电机
|
case MOTOR_MOVE: // 运行电机
|
||||||
break;
|
{
|
||||||
case MOTOR_STOP: // 停止电机
|
// 读取参数
|
||||||
|
state = motor_param_get(rx, ctrl_param);
|
||||||
|
// 运行电机
|
||||||
|
if (state == ST_DEV_NORMAL)
|
||||||
|
{
|
||||||
|
state = motor_ctrl(RUN, ctrl_param);
|
||||||
|
}
|
||||||
|
// 回复数据
|
||||||
|
osel_memcpy((uint8_t *)bk, (uint8_t *)rx, sizeof(frame_msg_t));
|
||||||
|
bk->state = state;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case MOTOR_STOP: // 停止电机
|
||||||
|
{
|
||||||
|
// 停止电机
|
||||||
|
state = motor_ctrl(STOP, ctrl_param);
|
||||||
|
// 回复数据
|
||||||
|
osel_memcpy((uint8_t *)bk, (uint8_t *)rx, sizeof(frame_msg_t));
|
||||||
|
bk->state = state;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case MOTOR_STATE:
|
||||||
|
motor_state(rx, bk);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
error_process(ST_CMD_IVALID, rx, bk);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
bk->dev_no = MOTOR;
|
|
||||||
bk->cmd_no = rx->cmd_no;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************* ADc传感器 *************************************/
|
/************************************* ADc传感器 *************************************/
|
||||||
|
uint8_t detect_result = ST_DEV_NORMAL; // 数据转换结果
|
||||||
|
uint16_t sensor_adc[GET_ALL_VALUE] = {0};
|
||||||
|
|
||||||
// AD传感器
|
// AD传感器
|
||||||
adc_t adc1 = {
|
adc_t adc1 = {
|
||||||
.adc = ADC1,
|
.adc = ADC1,
|
||||||
|
@ -209,33 +292,224 @@ adc_t adc1 = {
|
||||||
.dma_channel = LL_DMA_CHANNEL_1,
|
.dma_channel = LL_DMA_CHANNEL_1,
|
||||||
};
|
};
|
||||||
|
|
||||||
// 获取扭力值
|
uint16_t get_sensor_adc(uint8_t id)
|
||||||
static BOOL get_tors_value(frame_msg_t *bk)
|
|
||||||
{
|
{
|
||||||
uint16_t value = 0;
|
uint16_t adc = 0;
|
||||||
|
|
||||||
bk->len = sizeof(uint16_t);
|
switch (id)
|
||||||
value = adc_get_result_average(IN13);
|
|
||||||
value = S2B_UINT16(value);
|
|
||||||
osel_memcpy(bk->data, (uint8_t *)&value, bk->len);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 传感器任务
|
|
||||||
void sensor_procss(frame_msg_t *rx, frame_msg_t *bk)
|
|
||||||
{
|
|
||||||
BOOL ret = TRUE;
|
|
||||||
|
|
||||||
switch (rx->cmd_no)
|
|
||||||
{
|
{
|
||||||
case GET_TORS_VALUE: // 获取扭力值
|
case GET_TORSION_VALUE: // 扭力,单位:N·m
|
||||||
ret = get_tors_value(bk);
|
adc = adc_get_result_average(IN13);
|
||||||
|
break;
|
||||||
|
case GET_INPUT_PRESS_VALUE: // 输入压力,单位:kPa
|
||||||
|
adc = adc_get_result_average(IN7);
|
||||||
|
break;
|
||||||
|
case GET_OUTPUT_PRESS_VALUE: // 输出压力,单位:kPa
|
||||||
|
adc = adc_get_result_average(IN9);
|
||||||
|
break;
|
||||||
|
case GET_INPUT_FLOW_VALUE: // 输入流量,单位:SLPM
|
||||||
|
adc = adc_get_result_average(IN8);
|
||||||
|
break;
|
||||||
|
case GET_OUTPUT_FLOW_VALUE: // 输出流量,单位:SLPM
|
||||||
|
adc = adc_get_result_average(IN10);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
bk->state = ret;
|
return adc;
|
||||||
bk->dev_no = ADC_SENSOR;
|
}
|
||||||
|
|
||||||
|
float32 torsion_detect(void)
|
||||||
|
{
|
||||||
|
float32 adc = 0.0, val = 0.0;
|
||||||
|
|
||||||
|
adc = get_sensor_adc(GET_TORSION_VALUE);
|
||||||
|
val = adc / 4096 * 3000;
|
||||||
|
if (val < 914 || val > 2086)
|
||||||
|
{
|
||||||
|
detect_result = ST_DEV_MISS;
|
||||||
|
}
|
||||||
|
val = (val - 1500) / 101 / (1.934 * 3) * 10;
|
||||||
|
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
float32 pressure_detect(uint8_t id)
|
||||||
|
{
|
||||||
|
float32 adc = 0.0, val = 0.0;
|
||||||
|
|
||||||
|
adc = get_sensor_adc(id);
|
||||||
|
val = adc / 4096 * 3000;
|
||||||
|
if (val < 500 || val > 3000)
|
||||||
|
{
|
||||||
|
detect_result = ST_DEV_MISS;
|
||||||
|
}
|
||||||
|
val = (val - 600) / (10 * 15) / 16 * 1600;
|
||||||
|
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
float32 flow_detect(uint8_t id)
|
||||||
|
{
|
||||||
|
float32 adc = 0.0, val = 0.0;
|
||||||
|
|
||||||
|
adc = get_sensor_adc(id);
|
||||||
|
val = adc / 4096 * 3000;
|
||||||
|
if (val < 500 || val > 3000)
|
||||||
|
{
|
||||||
|
detect_result = ST_DEV_MISS;
|
||||||
|
}
|
||||||
|
val = (val - 600) / (10 * 15) / 16 * 300;
|
||||||
|
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 传感器任务
|
||||||
|
void sensor_process(frame_msg_t *rx, frame_msg_t *bk)
|
||||||
|
{
|
||||||
|
DBG_ASSERT(rx != NULL __DBG_LINE);
|
||||||
|
DBG_ASSERT(bk != NULL __DBG_LINE);
|
||||||
|
|
||||||
|
uint8_t state = ST_DEV_NORMAL;
|
||||||
|
|
||||||
|
// 检查指令合法性
|
||||||
|
if (rx->cmd_no > GET_ALL_VALUE)
|
||||||
|
{
|
||||||
|
state = ST_CMD_IVALID;
|
||||||
|
goto encode;
|
||||||
|
}
|
||||||
|
|
||||||
|
encode:
|
||||||
|
// 回复数据
|
||||||
|
bk->head = PACKET_STX;
|
||||||
|
bk->state = state;
|
||||||
|
bk->dev_no = rx->dev_no;
|
||||||
bk->cmd_no = rx->cmd_no;
|
bk->cmd_no = rx->cmd_no;
|
||||||
|
if (rx->cmd_no >= GET_ALL_VALUE)
|
||||||
|
{
|
||||||
|
bk->len = sizeof(uint16_t) * GET_ALL_VALUE;
|
||||||
|
osel_memcpy((uint8_t *)bk->data, (uint8_t *)&sensor_adc, bk->len);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bk->len = sizeof(uint16_t);
|
||||||
|
osel_memcpy((uint8_t *)bk->data, (uint8_t *)&sensor_adc[bk->cmd_no], bk->len);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/************************************* 测试 *************************************/
|
||||||
|
#if SELF_TEST
|
||||||
|
test_t self_test = {TEST_DEV_IDEL, 0};
|
||||||
|
uint8_t test_buffer[UART_RXSIZE] = {0}; // 数据接收缓存
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// 传感器测试指令
|
||||||
|
static uint8_t test_sensor_cmd(uint8_t cmd, uint8_t *buf)
|
||||||
|
{
|
||||||
|
osel_memset(buf, 0, UART_RXSIZE);
|
||||||
|
|
||||||
|
uint8_t ver_len = 0;
|
||||||
|
uint8_t index = 0;
|
||||||
|
frame_msg_t msg;
|
||||||
|
msg.head = PACKET_STX;
|
||||||
|
msg.state = ST_DEV_NORMAL;
|
||||||
|
msg.dev_no = ADC_SENSOR;
|
||||||
|
msg.cmd_no = cmd;
|
||||||
|
msg.len = 0;
|
||||||
|
index = DATA_INDEX;
|
||||||
|
osel_memcpy(buf, (uint8_t *)&msg, index);
|
||||||
|
// 校验
|
||||||
|
buf[index] = xor_compute((uint8_t *)&buf[1], (index - 1)); // 减掉包头
|
||||||
|
index += 1;
|
||||||
|
// 包尾
|
||||||
|
buf[index] = PACKET_ETX;
|
||||||
|
index += 1;
|
||||||
|
// 帧长度
|
||||||
|
ver_len = index;
|
||||||
|
return ver_len;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 电机测试指令
|
||||||
|
static uint8_t test_motor_cmd(uint8_t cmd, uint8_t *buf)
|
||||||
|
{
|
||||||
|
uint8_t ver_len = 0;
|
||||||
|
uint8_t index = 0;
|
||||||
|
frame_msg_t msg;
|
||||||
|
motor_ctrl_t motor_param;
|
||||||
|
msg.head = PACKET_STX;
|
||||||
|
msg.state = ST_DEV_NORMAL;
|
||||||
|
msg.dev_no = MOTOR;
|
||||||
|
msg.cmd_no = cmd;
|
||||||
|
switch (cmd)
|
||||||
|
{
|
||||||
|
case MOTOR_MOVE:
|
||||||
|
msg.len = 5; // 方向1个字节,角度4个字节
|
||||||
|
break;
|
||||||
|
case MOTOR_STOP:
|
||||||
|
msg.len = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
index = DATA_INDEX;
|
||||||
|
osel_memcpy(buf, (uint8_t *)&msg, index);
|
||||||
|
|
||||||
|
if (cmd == MOTOR_MOVE)
|
||||||
|
{
|
||||||
|
motor_param.dir = DIR_CCW;
|
||||||
|
motor_param.angle = 90;
|
||||||
|
motor_param.angle = S2B_FLOAT32(motor_param.angle);
|
||||||
|
}
|
||||||
|
osel_memcpy((uint8_t *)&buf[index], (uint8_t *)&motor_param, sizeof(motor_ctrl_t));
|
||||||
|
index += sizeof(motor_ctrl_t);
|
||||||
|
// 校验
|
||||||
|
buf[index] = xor_compute((uint8_t *)&buf[1], (index - 1)); // 减掉包头
|
||||||
|
index += 1;
|
||||||
|
// 包尾
|
||||||
|
buf[index] = PACKET_ETX;
|
||||||
|
index += 1;
|
||||||
|
// 帧长度
|
||||||
|
ver_len = index;
|
||||||
|
return ver_len;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 发送测试数据
|
||||||
|
static void test_rx_cb(uint8_t *data, uint8_t len)
|
||||||
|
{
|
||||||
|
BOOL ret = FALSE;
|
||||||
|
|
||||||
|
// 数据有效性检查
|
||||||
|
ret = host_data_verify(data, len);
|
||||||
|
// 数据解码
|
||||||
|
if (ret == TRUE && execute_state == IDLE)
|
||||||
|
{
|
||||||
|
host_data_decode(data, len);
|
||||||
|
execute_state = BUSY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 测试任务
|
||||||
|
void test_process(void)
|
||||||
|
{
|
||||||
|
uint8_t len = 0;
|
||||||
|
uint8_t *buf = test_buffer;
|
||||||
|
|
||||||
|
if (self_test.dev_id >= TEST_DEV_MAX)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (self_test.dev_id)
|
||||||
|
{
|
||||||
|
case TEST_DEV_SENSOR:
|
||||||
|
len = test_sensor_cmd(self_test.cmd_id, buf);
|
||||||
|
break;
|
||||||
|
case TEST_DEV_MOTOR:
|
||||||
|
len = test_motor_cmd(self_test.cmd_id, buf);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
test_rx_cb(buf, len);
|
||||||
|
self_test.dev_id = TEST_DEV_IDEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************* 板卡 *************************************/
|
/************************************* 板卡 *************************************/
|
||||||
|
@ -243,10 +517,20 @@ void sensor_procss(frame_msg_t *rx, frame_msg_t *bk)
|
||||||
void board_init(void)
|
void board_init(void)
|
||||||
{
|
{
|
||||||
motor = NULL;
|
motor = NULL;
|
||||||
osel_memset((uint8_t *)uarts, 0, sizeof(uarts));
|
|
||||||
my_mem_init(SRAMIN);
|
my_mem_init(SRAMIN);
|
||||||
|
|
||||||
motor_init(); // 电机初始化
|
motor_init(); // 电机初始化
|
||||||
adc_init(adc1); // 初始化ADC1通道,默认采集AD
|
adc_init(adc1); // 初始化ADC1通道,默认采集AD
|
||||||
|
host_uart_init(); // 串口初始化
|
||||||
ENABLE_TIM(TIM6); // 任务流程定时器使能
|
ENABLE_TIM(TIM6); // 任务流程定时器使能
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 不支持的任务
|
||||||
|
void error_process(uint8_t err, frame_msg_t *rx, frame_msg_t *bk)
|
||||||
|
{
|
||||||
|
DBG_ASSERT(rx != NULL __DBG_LINE);
|
||||||
|
DBG_ASSERT(bk != NULL __DBG_LINE);
|
||||||
|
|
||||||
|
osel_memcpy((uint8_t *)bk, (uint8_t *)rx, sizeof(frame_msg_t));
|
||||||
|
bk->state = err;
|
||||||
|
}
|
||||||
|
|
|
@ -4,32 +4,41 @@
|
||||||
#include "adcs.h"
|
#include "adcs.h"
|
||||||
#include "uarts.h"
|
#include "uarts.h"
|
||||||
|
|
||||||
|
#define SELF_TEST 1
|
||||||
|
|
||||||
// 串口协议参数
|
// 串口协议参数
|
||||||
#define UART_RXSIZE (240u) // 接收缓冲区 240个字节
|
#define UART_RXSIZE (240u) // 接收缓冲区 240个字节
|
||||||
#define UART_TXSIZE (240u) // 发送缓冲区 240个字节
|
#define UART_TXSIZE (240u) // 发送缓冲区 240个字节
|
||||||
|
|
||||||
// 包头 + 状态码 + 设备号 + 命令号 + 长度 + 数据 + 校验 + 包尾
|
// 包头 + 状态码 + 设备号 + 命令号 + 长度 + 数据 + 校验 + 包尾
|
||||||
// 1 1 1 1 1 0~128 2 1
|
// 1 1 1 1 1 0~128 1 1
|
||||||
#define PACKET_STX 0xff // 包头
|
#define PACKET_STX 0xff // 包头
|
||||||
#define PACKET_ETX 0x3c // 包尾
|
#define PACKET_ETX 0x3c // 包尾
|
||||||
#define MASTER_CODE 0x00 // 状态码-主机
|
#define PACKET_
|
||||||
|
#define DATA_LEN_INDEX 4 // 数据长度偏移
|
||||||
|
#define DATA_INDEX 5 // 数据偏移
|
||||||
// 最大数据长度
|
// 最大数据长度
|
||||||
#define DATA_MAX_LEN 128
|
#define DATA_MAX_LEN 128
|
||||||
// 最小帧长度:包头 + 状态码 + 设备号 + 命令号 + 长度 + 校验 + 包尾
|
// 最小帧长度:包头 + 状态码 + 设备号 + 命令号 + 长度 + 校验 + 包尾
|
||||||
#define PACKET_MIN_LEN 8
|
#define PACKET_MIN_LEN 7
|
||||||
// 最大帧长度
|
// 最大帧长度
|
||||||
#define PACKET_MAX_LEN (DATA_MAX_LEN + PACKET_MIN_LEN)
|
#define PACKET_MAX_LEN (DATA_MAX_LEN + PACKET_MIN_LEN)
|
||||||
|
|
||||||
// 电机初始默认值
|
// 电机初始默认值
|
||||||
#define PULSE_REV 18000.0 // 每圈脉冲数(驱动器脉冲)
|
#define PULSE_REV (18000.0 * 5) // 每圈脉冲数(驱动器脉冲)
|
||||||
#define MIN_STEP_ANGLE (360 / PULSE_REV) // 最小步距
|
#define MIN_STEP_ANGLE (360 / PULSE_REV) // 最小步距
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
ADC_SENSOR,
|
IDLE = 0, // 空闲
|
||||||
MOTOR,
|
BUSY = 1, // 忙碌
|
||||||
} dev_id_e;
|
} host_state_e;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
STOP = 0, // 停止
|
||||||
|
RUN = 1, // 运行
|
||||||
|
} motor_state_e;
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
|
@ -41,39 +50,86 @@ typedef enum
|
||||||
UART_NUM_MAX,
|
UART_NUM_MAX,
|
||||||
} uart_num_e;
|
} uart_num_e;
|
||||||
|
|
||||||
|
// 设备号
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
SET_MOTOR_SPEED,
|
ADC_SENSOR, // 传感器
|
||||||
SET_DRIVER_PULSE,
|
MOTOR, // 电机
|
||||||
GET_MIN_STEP,
|
} dev_id_e;
|
||||||
GET_MOTOR_STATE,
|
|
||||||
MOTOR_MOVE,
|
// 电机命令号
|
||||||
MOTOR_STOP,
|
typedef enum
|
||||||
|
{
|
||||||
|
SET_MOTOR_SPEED, // 设置电机速度
|
||||||
|
MOTOR_MOVE, // 电机启动(参数1:方向,参数2:角度)
|
||||||
|
MOTOR_STOP, // 电机停止
|
||||||
|
MOTOR_STATE, // 电机状态
|
||||||
} motor_cmd_e;
|
} motor_cmd_e;
|
||||||
|
|
||||||
|
// 传感器命令号
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
GET_TORS_VALUE,
|
GET_TORSION_VALUE, // 扭力
|
||||||
|
GET_INPUT_PRESS_VALUE, // 输入压力
|
||||||
|
GET_OUTPUT_PRESS_VALUE, // 输出压力
|
||||||
|
GET_INPUT_FLOW_VALUE, // 输入流量
|
||||||
|
GET_OUTPUT_FLOW_VALUE, // 输出流量
|
||||||
|
GET_ALL_VALUE, // 全部
|
||||||
} sensor_cmd_e;
|
} sensor_cmd_e;
|
||||||
|
|
||||||
|
// 状态码
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
ST_DEV_NORMAL,
|
ST_DEV_NORMAL, // 正常
|
||||||
ST_DEV_BUSY,
|
ST_DEV_BUSY, // 忙碌
|
||||||
ST_MSG_MISS,
|
ST_DEV_MISS, // 故障
|
||||||
|
ST_CMD_IVALID, // 无效
|
||||||
} status_code_e;
|
} status_code_e;
|
||||||
|
|
||||||
|
// 测试
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
TEST_DEV_IDEL,
|
||||||
|
TEST_DEV_SENSOR,
|
||||||
|
TEST_DEV_MOTOR,
|
||||||
|
TEST_DEV_MAX,
|
||||||
|
} test_dev_e;
|
||||||
|
|
||||||
|
#pragma pack(1)
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
uint8_t head; // 包头
|
||||||
uint8_t state; // 状态
|
uint8_t state; // 状态
|
||||||
uint8_t dev_no; // 设备号
|
uint8_t dev_no; // 设备号
|
||||||
uint8_t cmd_no; // 命令号
|
uint8_t cmd_no; // 命令号
|
||||||
uint8_t len; // 长度
|
uint8_t len; // 长度
|
||||||
uint8_t data[DATA_MAX_LEN]; // 数据
|
uint8_t data[DATA_MAX_LEN]; // 数据
|
||||||
|
|
||||||
} frame_msg_t;
|
} frame_msg_t;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t dir;
|
||||||
|
float32 angle;
|
||||||
|
} motor_ctrl_t;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t dev_id;
|
||||||
|
uint8_t cmd_id;
|
||||||
|
} test_t;
|
||||||
|
|
||||||
|
#pragma pack()
|
||||||
|
|
||||||
|
extern uint16_t sensor_adc[GET_ALL_VALUE];
|
||||||
|
|
||||||
extern void board_init(void);
|
extern void board_init(void);
|
||||||
void host_data_deal(uint8_t *data, uint16_t len);
|
extern uint16_t get_sensor_adc(uint8_t id);
|
||||||
|
extern float32 torsion_detect(void);
|
||||||
|
extern float32 pressure_detect(uint8_t id);
|
||||||
|
extern float32 flow_detect(uint8_t id);
|
||||||
|
extern void host_rx_msg_deal(void);
|
||||||
|
extern void motor_process_init(void);
|
||||||
|
extern void test_process(void);
|
||||||
|
|
||||||
#endif // __BOARD_H__
|
#endif // __BOARD_H__
|
||||||
|
|
|
@ -21,6 +21,7 @@ static void step_motor_run(motor_t *motor, dir_e dir)
|
||||||
handle->attribute.en = TRUE;
|
handle->attribute.en = TRUE;
|
||||||
dir == DIR_CCW ? handle->gpios.dir->set(*handle->gpios.dir) : handle->gpios.dir->reset(*handle->gpios.dir);
|
dir == DIR_CCW ? handle->gpios.dir->set(*handle->gpios.dir) : handle->gpios.dir->reset(*handle->gpios.dir);
|
||||||
PWM_START(handle->pwm_timer, handle->pwm_channel);
|
PWM_START(handle->pwm_timer, handle->pwm_channel);
|
||||||
|
handle->attribute.state = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void step_motor_stop(motor_t *motor)
|
static void step_motor_stop(motor_t *motor)
|
||||||
|
@ -32,13 +33,14 @@ static void step_motor_stop(motor_t *motor)
|
||||||
handle->attribute.angle = 0;
|
handle->attribute.angle = 0;
|
||||||
handle->attribute.pulse_count = 0;
|
handle->attribute.pulse_count = 0;
|
||||||
PWM_STOP(handle->pwm_timer, handle->pwm_channel);
|
PWM_STOP(handle->pwm_timer, handle->pwm_channel);
|
||||||
|
handle->attribute.state = FALSE;
|
||||||
if (handle->interface.stop_cb != NULL)
|
if (handle->interface.stop_cb != NULL)
|
||||||
{
|
{
|
||||||
handle->interface.stop_cb(motor);
|
handle->interface.stop_cb(motor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void step_motor_set_angle(motor_t *motor, uint32_t angle, dir_e dir)
|
static void step_motor_set_angle(motor_t *motor, float32 angle, dir_e dir)
|
||||||
{
|
{
|
||||||
DBG_ASSERT(motor != NULL __DBG_LINE);
|
DBG_ASSERT(motor != NULL __DBG_LINE);
|
||||||
step_motor_t *handle = &motor->handle.step_motor;
|
step_motor_t *handle = &motor->handle.step_motor;
|
||||||
|
@ -60,6 +62,10 @@ static void step_motor_set_angle(motor_t *motor, uint32_t angle, dir_e dir)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void step_motor_set_speed(motor_t *motor, uint32_t psc)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 步进电机中断处理函数
|
* @brief 步进电机中断处理函数
|
||||||
* @param {motor_t} *motor
|
* @param {motor_t} *motor
|
||||||
|
@ -103,6 +109,7 @@ motor_t *motor_create(motor_type_e motor_type)
|
||||||
motor->handle.step_motor.interface.run = step_motor_run;
|
motor->handle.step_motor.interface.run = step_motor_run;
|
||||||
motor->handle.step_motor.interface.stop = step_motor_stop;
|
motor->handle.step_motor.interface.stop = step_motor_stop;
|
||||||
motor->handle.step_motor.interface.set_angle = step_motor_set_angle;
|
motor->handle.step_motor.interface.set_angle = step_motor_set_angle;
|
||||||
|
motor->handle.step_motor.interface.set_speed = step_motor_set_speed;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -15,8 +15,8 @@ typedef struct MOTOR motor_t;
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
DIR_CCW = 0, /* 逆时针旋转 */
|
DIR_CW = 0, /* 逆时针旋转 */
|
||||||
DIR_CW, /* 顺时针旋转 */
|
DIR_CCW, /* 顺时针旋转 */
|
||||||
} dir_e;
|
} dir_e;
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
|
@ -37,9 +37,9 @@ typedef struct
|
||||||
void (*init)(motor_t *motor, gpio_t dir, gpio_t en, float32 min_step_angle, TIM_TypeDef *pwm_timer, uint32_t pwm_channel); // 初始化
|
void (*init)(motor_t *motor, gpio_t dir, gpio_t en, float32 min_step_angle, TIM_TypeDef *pwm_timer, uint32_t pwm_channel); // 初始化
|
||||||
void (*run)(motor_t *motor, dir_e dir); // 运行
|
void (*run)(motor_t *motor, dir_e dir); // 运行
|
||||||
void (*stop)(motor_t *motor); // 停止
|
void (*stop)(motor_t *motor); // 停止
|
||||||
void (*set_angle)(motor_t *motor, uint32_t angle, dir_e dir); // 将角度转换成脉冲个数并运行
|
void (*set_angle)(motor_t *motor, float32 angle, dir_e dir); // 将角度转换成脉冲个数并运行
|
||||||
void (*stop_cb)(motor_t *motor); // 停止回调函数,在stop中执行
|
void (*stop_cb)(motor_t *motor); // 停止回调函数,在stop中执行
|
||||||
|
void (*set_speed)(motor_t *motor, uint32_t psc);
|
||||||
} step_motor_interface_t;
|
} step_motor_interface_t;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
@ -51,6 +51,7 @@ typedef struct
|
||||||
__IO uint32_t pulse_count; /* 脉冲个数记录 */
|
__IO uint32_t pulse_count; /* 脉冲个数记录 */
|
||||||
__IO int add_pulse_count; /* 脉冲个数累计 */
|
__IO int add_pulse_count; /* 脉冲个数累计 */
|
||||||
__IO uint32_t step_angle; /* 步距 */
|
__IO uint32_t step_angle; /* 步距 */
|
||||||
|
uint8_t state; // 运动状态
|
||||||
} step_motor_attribute_t;
|
} step_motor_attribute_t;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
|
|
@ -65,24 +65,24 @@
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
IN0 = 0,
|
// IN0 = 0,
|
||||||
IN1,
|
// IN1,
|
||||||
// IN2,
|
// IN2,
|
||||||
// IN3,
|
// IN3,
|
||||||
// IN4,
|
// IN4,
|
||||||
// IN5,
|
// IN5,
|
||||||
IN6,
|
// IN6,
|
||||||
IN7,
|
IN7,
|
||||||
IN8,
|
IN8,
|
||||||
IN9,
|
IN9,
|
||||||
IN10,
|
IN10,
|
||||||
IN11,
|
// IN11,
|
||||||
IN12,
|
// IN12,
|
||||||
IN13,
|
IN13,
|
||||||
// IN14,
|
// IN14,
|
||||||
// IN15,
|
// IN15,
|
||||||
INVREF,
|
// INVREF,
|
||||||
INTEMP,
|
// INTEMP,
|
||||||
INMAX,
|
INMAX,
|
||||||
} adc_num_t; // ADC通道号,根据cubemax配置的通道数量而定
|
} adc_num_t; // ADC通道号,根据cubemax配置的通道数量而定
|
||||||
|
|
||||||
|
|
|
@ -24,4 +24,31 @@
|
||||||
} while (__LINE__ == -1);
|
} while (__LINE__ == -1);
|
||||||
|
|
||||||
#define WATCHDOG_RESET() LL_IWDG_ReloadCounter(IWDG)
|
#define WATCHDOG_RESET() LL_IWDG_ReloadCounter(IWDG)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Clears the flags of a DMA channel
|
||||||
|
* @param DMAX DMAx register base
|
||||||
|
* @param CHx DMA channel number
|
||||||
|
* @param Flag a boolean variable that indicates if the transfer is complete
|
||||||
|
* @note This function should be called within the interrupt service routine of the DMA channel
|
||||||
|
*/
|
||||||
|
#define DMA_ClEAR_FLAG(DMAX, CHx, Flag) \
|
||||||
|
do \
|
||||||
|
{ \
|
||||||
|
if (LL_DMA_IsActiveFlag_TC##CHx(DMAX)) \
|
||||||
|
{ \
|
||||||
|
LL_DMA_ClearFlag_TC##CHx(DMAX); \
|
||||||
|
LL_DMA_ClearFlag_GI##CHx(DMAX); \
|
||||||
|
Flag = TRUE; \
|
||||||
|
} \
|
||||||
|
if (LL_DMA_IsActiveFlag_TE##CHx(DMAX)) \
|
||||||
|
{ \
|
||||||
|
LL_DMA_ClearFlag_TE##CHx(DMAX); \
|
||||||
|
} \
|
||||||
|
if (LL_DMA_IsActiveFlag_GI##CHx(DMAX)) \
|
||||||
|
{ \
|
||||||
|
LL_DMA_ClearFlag_GI##CHx(DMAX); \
|
||||||
|
} \
|
||||||
|
} while (__LINE__ == -1)
|
||||||
|
|
||||||
#endif // __BSP_H__
|
#endif // __BSP_H__
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
{ \
|
{ \
|
||||||
LL_TIM_EnableCounter(TIMx); \
|
LL_TIM_EnableCounter(TIMx); \
|
||||||
LL_TIM_CC_EnableChannel(TIMx, CHx); \
|
LL_TIM_CC_EnableChannel(TIMx, CHx); \
|
||||||
|
LL_TIM_EnableIT_UPDATE(TIMx); \
|
||||||
} while (__LINE__ == -1)
|
} while (__LINE__ == -1)
|
||||||
|
|
||||||
// 停止PWM输出
|
// 停止PWM输出
|
||||||
|
@ -16,6 +17,7 @@
|
||||||
{ \
|
{ \
|
||||||
LL_TIM_DisableCounter(TIMx); \
|
LL_TIM_DisableCounter(TIMx); \
|
||||||
LL_TIM_CC_DisableChannel(TIMx, CHx); \
|
LL_TIM_CC_DisableChannel(TIMx, CHx); \
|
||||||
|
LL_TIM_ClearFlag_UPDATE(TIMx); \
|
||||||
} while (__LINE__ == -1)
|
} while (__LINE__ == -1)
|
||||||
|
|
||||||
// 修改比较值,修改占空比
|
// 修改比较值,修改占空比
|
||||||
|
|
|
@ -365,12 +365,12 @@ void uart_dma_reception_callback(uart_t *uart)
|
||||||
LL_DMA_DisableChannel(uart->dma, uart->dma_tx_channel);
|
LL_DMA_DisableChannel(uart->dma, uart->dma_tx_channel);
|
||||||
|
|
||||||
// 清除发送中断标志位
|
// 清除发送中断标志位
|
||||||
DMA_CLEAR_FLAG_TC_CHANNEL(uart->dma, uart->dma_tx_channel + 1);
|
DMA_CLEAR_FLAG_TC_CHANNEL(uart->dma, uart->dma_tx_channel);
|
||||||
|
|
||||||
// 使能发送中断,用于关闭发送使能引脚
|
// 使能发送中断,用于关闭发送使能引脚
|
||||||
LL_USART_EnableIT_TC(uart->huart); // 使能发送中断,用于关闭发送使能引脚
|
LL_USART_EnableIT_TC(uart->huart); // 使能发送中断,用于关闭发送使能引脚
|
||||||
uart->tx_dma_ok = TRUE;
|
uart->tx_dma_ok = TRUE;
|
||||||
|
|
||||||
// 清除传输错误标志
|
// 清除传输错误标志
|
||||||
DMA_CLEAR_FLAG_TE_CHANNEL(uart->dma, uart->dma_tx_channel + 1);
|
DMA_CLEAR_FLAG_TE_CHANNEL(uart->dma, uart->dma_tx_channel);
|
||||||
}
|
}
|
||||||
|
|
36
motor.ioc
36
motor.ioc
|
@ -57,18 +57,22 @@ Mcu.Name=STM32L072R(B-Z)Tx
|
||||||
Mcu.Package=LQFP64
|
Mcu.Package=LQFP64
|
||||||
Mcu.Pin0=PH0-OSC_IN
|
Mcu.Pin0=PH0-OSC_IN
|
||||||
Mcu.Pin1=PH1-OSC_OUT
|
Mcu.Pin1=PH1-OSC_OUT
|
||||||
Mcu.Pin10=PA14
|
Mcu.Pin10=PB15
|
||||||
Mcu.Pin11=VP_SYS_VS_Systick
|
Mcu.Pin11=PA9
|
||||||
Mcu.Pin12=VP_TIM6_VS_ClockSourceINT
|
Mcu.Pin12=PA10
|
||||||
Mcu.Pin2=PC3
|
Mcu.Pin13=PA13
|
||||||
Mcu.Pin3=PB12
|
Mcu.Pin14=PA14
|
||||||
Mcu.Pin4=PB13
|
Mcu.Pin15=VP_SYS_VS_Systick
|
||||||
Mcu.Pin5=PB14
|
Mcu.Pin16=VP_TIM6_VS_ClockSourceINT
|
||||||
Mcu.Pin6=PB15
|
Mcu.Pin2=PC0
|
||||||
Mcu.Pin7=PA9
|
Mcu.Pin3=PC3
|
||||||
Mcu.Pin8=PA10
|
Mcu.Pin4=PA7
|
||||||
Mcu.Pin9=PA13
|
Mcu.Pin5=PB0
|
||||||
Mcu.PinsNb=13
|
Mcu.Pin6=PB1
|
||||||
|
Mcu.Pin7=PB12
|
||||||
|
Mcu.Pin8=PB13
|
||||||
|
Mcu.Pin9=PB14
|
||||||
|
Mcu.PinsNb=17
|
||||||
Mcu.ThirdPartyNb=0
|
Mcu.ThirdPartyNb=0
|
||||||
Mcu.UserConstants=
|
Mcu.UserConstants=
|
||||||
Mcu.UserName=STM32L072RBTx
|
Mcu.UserName=STM32L072RBTx
|
||||||
|
@ -91,8 +95,14 @@ PA13.Mode=Serial_Wire
|
||||||
PA13.Signal=SYS_SWDIO
|
PA13.Signal=SYS_SWDIO
|
||||||
PA14.Mode=Serial_Wire
|
PA14.Mode=Serial_Wire
|
||||||
PA14.Signal=SYS_SWCLK
|
PA14.Signal=SYS_SWCLK
|
||||||
|
PA7.Mode=IN7
|
||||||
|
PA7.Signal=ADC_IN7
|
||||||
PA9.Mode=Asynchronous
|
PA9.Mode=Asynchronous
|
||||||
PA9.Signal=USART1_TX
|
PA9.Signal=USART1_TX
|
||||||
|
PB0.Mode=IN8
|
||||||
|
PB0.Signal=ADC_IN8
|
||||||
|
PB1.Mode=IN9
|
||||||
|
PB1.Signal=ADC_IN9
|
||||||
PB12.GPIOParameters=GPIO_Speed,PinState,GPIO_Label
|
PB12.GPIOParameters=GPIO_Speed,PinState,GPIO_Label
|
||||||
PB12.GPIO_Label=ENA
|
PB12.GPIO_Label=ENA
|
||||||
PB12.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
|
PB12.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
|
||||||
|
@ -110,6 +120,8 @@ PB15.GPIOParameters=GPIO_PuPd,GPIO_Label
|
||||||
PB15.GPIO_Label=STOPPER
|
PB15.GPIO_Label=STOPPER
|
||||||
PB15.GPIO_PuPd=GPIO_PULLUP
|
PB15.GPIO_PuPd=GPIO_PULLUP
|
||||||
PB15.Signal=GPXTI15
|
PB15.Signal=GPXTI15
|
||||||
|
PC0.Mode=IN10
|
||||||
|
PC0.Signal=ADC_IN10
|
||||||
PC3.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_Mode
|
PC3.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_Mode
|
||||||
PC3.GPIO_Label=MG_ADC_IN13
|
PC3.GPIO_Label=MG_ADC_IN13
|
||||||
PC3.GPIO_Mode=GPIO_MODE_ANALOG
|
PC3.GPIO_Mode=GPIO_MODE_ANALOG
|
||||||
|
|
Reference in New Issue