Compare commits
11 Commits
Author | SHA1 | Date |
---|---|---|
|
424a1df2e4 | |
|
37c1b4e343 | |
|
ce04a54b9d | |
|
7ac6baf560 | |
|
e4a9aff8b3 | |
|
4313204135 | |
|
08e310c72a | |
|
76736247f5 | |
|
5dd03a2628 | |
|
87a7d76f6d | |
|
a8ca2d69f1 |
|
@ -28,3 +28,4 @@ dist
|
|||
/MDK-ARM/*.bin
|
||||
/MDK-ARM/.pack
|
||||
.vscode/settings.json
|
||||
|
||||
|
|
|
@ -23,10 +23,11 @@
|
|||
#define __MAIN_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
|
||||
#include "stm32f1xx_ll_dma.h"
|
||||
#include "stm32f1xx_ll_rcc.h"
|
||||
|
@ -49,28 +50,29 @@ extern "C" {
|
|||
/* USER CODE BEGIN Includes */
|
||||
#include "sys.h"
|
||||
#include "delay.h"
|
||||
#include "btn.h"
|
||||
#include "lib.h"
|
||||
#include "bsp.h"
|
||||
|
||||
/* USER CODE END Includes */
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN ET */
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN ET */
|
||||
|
||||
/* USER CODE END ET */
|
||||
/* USER CODE END ET */
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EC */
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EC */
|
||||
|
||||
/* USER CODE END EC */
|
||||
/* USER CODE END EC */
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EM */
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EM */
|
||||
|
||||
/* USER CODE END EM */
|
||||
/* USER CODE END EM */
|
||||
|
||||
/* Exported functions prototypes ---------------------------------------------*/
|
||||
void Error_Handler(void);
|
||||
/* Exported functions prototypes ---------------------------------------------*/
|
||||
void Error_Handler(void);
|
||||
|
||||
/* USER CODE BEGIN EFP */
|
||||
|
||||
|
@ -89,26 +91,32 @@ void Error_Handler(void);
|
|||
#define TMC2240_MISO_GPIO_Port GPIOA
|
||||
#define TMC2240_MOSI_Pin LL_GPIO_PIN_7
|
||||
#define TMC2240_MOSI_GPIO_Port GPIOA
|
||||
#define TMC2240_STEP_Pin LL_GPIO_PIN_0
|
||||
#define TMC2240_STEP_GPIO_Port GPIOB
|
||||
#define TMC2240_DIR_Pin LL_GPIO_PIN_1
|
||||
#define TMC2240_DIR_GPIO_Port GPIOB
|
||||
#define OLED_SDA_Pin LL_GPIO_PIN_12
|
||||
#define OLED_SDA_GPIO_Port GPIOB
|
||||
#define OLDE_SCK_Pin LL_GPIO_PIN_13
|
||||
#define OLDE_SCK_GPIO_Port GPIOB
|
||||
#define KEY_1_Pin LL_GPIO_PIN_14
|
||||
#define KEY_1_GPIO_Port GPIOB
|
||||
#ifndef NVIC_PRIORITYGROUP_0
|
||||
#define NVIC_PRIORITYGROUP_0 ((uint32_t)0x00000007) /*!< 0 bit for pre-emption priority,
|
||||
4 bits for subpriority */
|
||||
#define NVIC_PRIORITYGROUP_1 ((uint32_t)0x00000006) /*!< 1 bit for pre-emption priority,
|
||||
3 bits for subpriority */
|
||||
#define NVIC_PRIORITYGROUP_2 ((uint32_t)0x00000005) /*!< 2 bits for pre-emption priority,
|
||||
2 bits for subpriority */
|
||||
#define NVIC_PRIORITYGROUP_3 ((uint32_t)0x00000004) /*!< 3 bits for pre-emption priority,
|
||||
1 bit for subpriority */
|
||||
#define NVIC_PRIORITYGROUP_4 ((uint32_t)0x00000003) /*!< 4 bits for pre-emption priority,
|
||||
0 bit for subpriority */
|
||||
#define NVIC_PRIORITYGROUP_0 ((uint32_t)0x00000007) /*!< 0 bit for pre-emption priority, \
|
||||
4 bits for subpriority */
|
||||
#define NVIC_PRIORITYGROUP_1 ((uint32_t)0x00000006) /*!< 1 bit for pre-emption priority, \
|
||||
3 bits for subpriority */
|
||||
#define NVIC_PRIORITYGROUP_2 ((uint32_t)0x00000005) /*!< 2 bits for pre-emption priority, \
|
||||
2 bits for subpriority */
|
||||
#define NVIC_PRIORITYGROUP_3 ((uint32_t)0x00000004) /*!< 3 bits for pre-emption priority, \
|
||||
1 bit for subpriority */
|
||||
#define NVIC_PRIORITYGROUP_4 ((uint32_t)0x00000003) /*!< 4 bits for pre-emption priority, \
|
||||
0 bit for subpriority */
|
||||
#endif
|
||||
|
||||
/* USER CODE BEGIN Private defines */
|
||||
/* USER CODE BEGIN Private defines */
|
||||
|
||||
/* USER CODE END Private defines */
|
||||
/* USER CODE END Private defines */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -37,7 +37,6 @@ extern "C" {
|
|||
/* USER CODE END Private defines */
|
||||
|
||||
void MX_TIM1_Init(void);
|
||||
void MX_TIM2_Init(void);
|
||||
void MX_TIM3_Init(void);
|
||||
|
||||
/* USER CODE BEGIN Prototypes */
|
||||
|
|
|
@ -59,7 +59,7 @@ void MX_GPIO_Init(void)
|
|||
LL_GPIO_ResetOutputPin(GPIOA, TMC2240_EN_Pin|TMC2240_CS_Pin);
|
||||
|
||||
/**/
|
||||
LL_GPIO_ResetOutputPin(GPIOB, OLED_SDA_Pin|OLDE_SCK_Pin);
|
||||
LL_GPIO_ResetOutputPin(GPIOB, TMC2240_DIR_Pin|OLED_SDA_Pin|OLDE_SCK_Pin);
|
||||
|
||||
/**/
|
||||
GPIO_InitStruct.Pin = LED_BLUE_Pin;
|
||||
|
@ -74,8 +74,8 @@ void MX_GPIO_Init(void)
|
|||
LL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
||||
|
||||
/**/
|
||||
GPIO_InitStruct.Pin = LL_GPIO_PIN_0|LL_GPIO_PIN_2|LL_GPIO_PIN_8|LL_GPIO_PIN_11
|
||||
|LL_GPIO_PIN_12|LL_GPIO_PIN_15;
|
||||
GPIO_InitStruct.Pin = LL_GPIO_PIN_0|LL_GPIO_PIN_1|LL_GPIO_PIN_2|LL_GPIO_PIN_8
|
||||
|LL_GPIO_PIN_11|LL_GPIO_PIN_12|LL_GPIO_PIN_15;
|
||||
GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG;
|
||||
LL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
|
||||
|
@ -87,10 +87,16 @@ void MX_GPIO_Init(void)
|
|||
LL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
|
||||
/**/
|
||||
GPIO_InitStruct.Pin = LL_GPIO_PIN_0|LL_GPIO_PIN_1|LL_GPIO_PIN_2|LL_GPIO_PIN_10
|
||||
|LL_GPIO_PIN_11|LL_GPIO_PIN_14|LL_GPIO_PIN_15|LL_GPIO_PIN_3
|
||||
|LL_GPIO_PIN_4|LL_GPIO_PIN_5|LL_GPIO_PIN_6|LL_GPIO_PIN_7
|
||||
|LL_GPIO_PIN_8|LL_GPIO_PIN_9;
|
||||
GPIO_InitStruct.Pin = TMC2240_DIR_Pin;
|
||||
GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;
|
||||
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW;
|
||||
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
|
||||
LL_GPIO_Init(TMC2240_DIR_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
/**/
|
||||
GPIO_InitStruct.Pin = LL_GPIO_PIN_2|LL_GPIO_PIN_10|LL_GPIO_PIN_11|LL_GPIO_PIN_15
|
||||
|LL_GPIO_PIN_3|LL_GPIO_PIN_4|LL_GPIO_PIN_5|LL_GPIO_PIN_6
|
||||
|LL_GPIO_PIN_7|LL_GPIO_PIN_8|LL_GPIO_PIN_9;
|
||||
GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG;
|
||||
LL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||
|
||||
|
@ -102,6 +108,12 @@ void MX_GPIO_Init(void)
|
|||
GPIO_InitStruct.Pull = LL_GPIO_PULL_UP;
|
||||
LL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||
|
||||
/**/
|
||||
GPIO_InitStruct.Pin = KEY_1_Pin;
|
||||
GPIO_InitStruct.Mode = LL_GPIO_MODE_INPUT;
|
||||
GPIO_InitStruct.Pull = LL_GPIO_PULL_UP;
|
||||
LL_GPIO_Init(KEY_1_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 2 */
|
||||
|
|
|
@ -99,7 +99,6 @@ int main(void)
|
|||
/* Initialize all configured peripherals */
|
||||
MX_GPIO_Init();
|
||||
MX_DMA_Init();
|
||||
MX_TIM2_Init();
|
||||
MX_USART1_UART_Init();
|
||||
MX_TIM1_Init();
|
||||
MX_TIM3_Init();
|
||||
|
|
|
@ -47,7 +47,7 @@ void MX_SPI1_Init(void)
|
|||
*/
|
||||
GPIO_InitStruct.Pin = TMC2240_SCK_Pin|TMC2240_MOSI_Pin;
|
||||
GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
|
||||
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH;
|
||||
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_MEDIUM;
|
||||
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
|
||||
LL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
|
||||
|
@ -64,7 +64,7 @@ void MX_SPI1_Init(void)
|
|||
SPI_InitStruct.ClockPolarity = LL_SPI_POLARITY_HIGH;
|
||||
SPI_InitStruct.ClockPhase = LL_SPI_PHASE_2EDGE;
|
||||
SPI_InitStruct.NSS = LL_SPI_NSS_SOFT;
|
||||
SPI_InitStruct.BaudRate = LL_SPI_BAUDRATEPRESCALER_DIV32;
|
||||
SPI_InitStruct.BaudRate = LL_SPI_BAUDRATEPRESCALER_DIV16;
|
||||
SPI_InitStruct.BitOrder = LL_SPI_MSB_FIRST;
|
||||
SPI_InitStruct.CRCCalculation = LL_SPI_CRCCALCULATION_DISABLE;
|
||||
SPI_InitStruct.CRCPoly = 10;
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include "sys.h"
|
||||
#include "flow.h"
|
||||
#include "board.h"
|
||||
|
||||
#include "btn.h"
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
|
@ -243,6 +243,7 @@ void TIM1_UP_IRQHandler(void)
|
|||
{
|
||||
TIM_IRQ_HANDLER(TASK_TIM);
|
||||
LL_IncTick();
|
||||
button_ticks();
|
||||
FLOW_TICK_UPDATE();
|
||||
}
|
||||
/* USER CODE END TIM1_UP_IRQn 1 */
|
||||
|
@ -257,9 +258,13 @@ void TIM3_IRQHandler(void)
|
|||
|
||||
/* USER CODE END TIM3_IRQn 0 */
|
||||
/* USER CODE BEGIN TIM3_IRQn 1 */
|
||||
if (IS_TIM_IT_FLAG(WORK_TIM))
|
||||
if (IS_TIM_IT_FLAG(TMC2240_TIM))
|
||||
{
|
||||
TIM_IRQ_HANDLER(WORK_TIM);
|
||||
if (LL_TIM_IsActiveFlag_CC3(TMC2240_TIM))
|
||||
{
|
||||
tmc2240_motor_update(TMC2240_1);
|
||||
}
|
||||
TIM_IRQ_HANDLER(TMC2240_TIM);
|
||||
}
|
||||
/* USER CODE END TIM3_IRQn 1 */
|
||||
}
|
||||
|
|
|
@ -58,55 +58,6 @@ void MX_TIM1_Init(void)
|
|||
|
||||
/* USER CODE END TIM1_Init 2 */
|
||||
|
||||
}
|
||||
/* TIM2 init function */
|
||||
void MX_TIM2_Init(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN TIM2_Init 0 */
|
||||
|
||||
/* USER CODE END TIM2_Init 0 */
|
||||
|
||||
LL_TIM_InitTypeDef TIM_InitStruct = {0};
|
||||
LL_TIM_OC_InitTypeDef TIM_OC_InitStruct = {0};
|
||||
|
||||
LL_GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||
/* Peripheral clock enable */
|
||||
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_TIM2);
|
||||
|
||||
/* USER CODE BEGIN TIM2_Init 1 */
|
||||
|
||||
/* USER CODE END TIM2_Init 1 */
|
||||
TIM_InitStruct.Prescaler = 0;
|
||||
TIM_InitStruct.CounterMode = LL_TIM_COUNTERMODE_UP;
|
||||
TIM_InitStruct.Autoreload = 7199;
|
||||
TIM_InitStruct.ClockDivision = LL_TIM_CLOCKDIVISION_DIV1;
|
||||
LL_TIM_Init(TIM2, &TIM_InitStruct);
|
||||
LL_TIM_EnableARRPreload(TIM2);
|
||||
LL_TIM_SetClockSource(TIM2, LL_TIM_CLOCKSOURCE_INTERNAL);
|
||||
LL_TIM_OC_EnablePreload(TIM2, LL_TIM_CHANNEL_CH2);
|
||||
TIM_OC_InitStruct.OCMode = LL_TIM_OCMODE_PWM2;
|
||||
TIM_OC_InitStruct.OCState = LL_TIM_OCSTATE_DISABLE;
|
||||
TIM_OC_InitStruct.OCNState = LL_TIM_OCSTATE_DISABLE;
|
||||
TIM_OC_InitStruct.CompareValue = 0;
|
||||
TIM_OC_InitStruct.OCPolarity = LL_TIM_OCPOLARITY_LOW;
|
||||
LL_TIM_OC_Init(TIM2, LL_TIM_CHANNEL_CH2, &TIM_OC_InitStruct);
|
||||
LL_TIM_OC_EnableFast(TIM2, LL_TIM_CHANNEL_CH2);
|
||||
LL_TIM_SetTriggerOutput(TIM2, LL_TIM_TRGO_RESET);
|
||||
LL_TIM_DisableMasterSlaveMode(TIM2);
|
||||
/* USER CODE BEGIN TIM2_Init 2 */
|
||||
|
||||
/* USER CODE END TIM2_Init 2 */
|
||||
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOA);
|
||||
/**TIM2 GPIO Configuration
|
||||
PA1 ------> TIM2_CH2
|
||||
*/
|
||||
GPIO_InitStruct.Pin = LL_GPIO_PIN_1;
|
||||
GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
|
||||
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW;
|
||||
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
|
||||
LL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
|
||||
}
|
||||
/* TIM3 init function */
|
||||
void MX_TIM3_Init(void)
|
||||
|
@ -117,29 +68,47 @@ void MX_TIM3_Init(void)
|
|||
/* USER CODE END TIM3_Init 0 */
|
||||
|
||||
LL_TIM_InitTypeDef TIM_InitStruct = {0};
|
||||
LL_TIM_OC_InitTypeDef TIM_OC_InitStruct = {0};
|
||||
|
||||
LL_GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||
/* Peripheral clock enable */
|
||||
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_TIM3);
|
||||
|
||||
/* TIM3 interrupt Init */
|
||||
NVIC_SetPriority(TIM3_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(),3, 0));
|
||||
NVIC_SetPriority(TIM3_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(),0, 0));
|
||||
NVIC_EnableIRQ(TIM3_IRQn);
|
||||
|
||||
/* USER CODE BEGIN TIM3_Init 1 */
|
||||
|
||||
/* USER CODE END TIM3_Init 1 */
|
||||
TIM_InitStruct.Prescaler = 7199;
|
||||
TIM_InitStruct.Prescaler = 71;
|
||||
TIM_InitStruct.CounterMode = LL_TIM_COUNTERMODE_UP;
|
||||
TIM_InitStruct.Autoreload = 99;
|
||||
TIM_InitStruct.Autoreload = 1000;
|
||||
TIM_InitStruct.ClockDivision = LL_TIM_CLOCKDIVISION_DIV1;
|
||||
LL_TIM_Init(TIM3, &TIM_InitStruct);
|
||||
LL_TIM_DisableARRPreload(TIM3);
|
||||
LL_TIM_SetClockSource(TIM3, LL_TIM_CLOCKSOURCE_INTERNAL);
|
||||
LL_TIM_OC_EnablePreload(TIM3, LL_TIM_CHANNEL_CH3);
|
||||
TIM_OC_InitStruct.OCMode = LL_TIM_OCMODE_PWM1;
|
||||
TIM_OC_InitStruct.OCState = LL_TIM_OCSTATE_DISABLE;
|
||||
TIM_OC_InitStruct.OCNState = LL_TIM_OCSTATE_DISABLE;
|
||||
TIM_OC_InitStruct.CompareValue = 0;
|
||||
TIM_OC_InitStruct.OCPolarity = LL_TIM_OCPOLARITY_HIGH;
|
||||
LL_TIM_OC_Init(TIM3, LL_TIM_CHANNEL_CH3, &TIM_OC_InitStruct);
|
||||
LL_TIM_OC_DisableFast(TIM3, LL_TIM_CHANNEL_CH3);
|
||||
LL_TIM_SetTriggerOutput(TIM3, LL_TIM_TRGO_RESET);
|
||||
LL_TIM_DisableMasterSlaveMode(TIM3);
|
||||
/* USER CODE BEGIN TIM3_Init 2 */
|
||||
|
||||
/* USER CODE END TIM3_Init 2 */
|
||||
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOB);
|
||||
/**TIM3 GPIO Configuration
|
||||
PB0 ------> TIM3_CH3
|
||||
*/
|
||||
GPIO_InitStruct.Pin = TMC2240_STEP_Pin;
|
||||
GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
|
||||
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW;
|
||||
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
|
||||
LL_GPIO_Init(TMC2240_STEP_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -125,7 +125,7 @@
|
|||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>CMSIS_AGDI</Key>
|
||||
<Name>-X"" -O206 -S0 -C0 -P00000000 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO65554 -TC10000000 -TT10000000 -TP20 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC1000 -FN1 -FF0CS32F10x_128.FLM -FS08000000 -FL020000 -FP0($$Device:CS32F103C8$Flash\CS32F10x_128.FLM)</Name>
|
||||
<Name>-X"Any" -UAny -O206 -S8 -C0 -P00000000 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO65554 -TC10000000 -TT10000000 -TP20 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC1000 -FN1 -FF0CS32F10x_128.FLM -FS08000000 -FL020000 -FP0($$Device:CS32F103C8$Flash\CS32F10x_128.FLM)</Name>
|
||||
</SetRegEntry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
|
@ -153,64 +153,19 @@
|
|||
<Ww>
|
||||
<count>0</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>buffer</ItemText>
|
||||
<ItemText>_tmc2240,0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>1</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>app,0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>2</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>work,0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>3</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>ch</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>4</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>dd</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>5</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>i,0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>6</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>progress_text</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>7</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>x,0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>8</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>_tmc2240</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>9</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>wdata</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>10</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>rdata</ItemText>
|
||||
</Ww>
|
||||
</WatchWindow1>
|
||||
<MemoryWindow1>
|
||||
<Mm>
|
||||
<WinNumber>1</WinNumber>
|
||||
<SubType>0</SubType>
|
||||
<ItemText>0x20003440</ItemText>
|
||||
<ItemText>0x20003450</ItemText>
|
||||
<AccSizeX>0</AccSizeX>
|
||||
</Mm>
|
||||
</MemoryWindow1>
|
||||
|
@ -409,6 +364,18 @@
|
|||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>4</GroupNumber>
|
||||
<FileNumber>11</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\User\application\key.c</PathWithFileName>
|
||||
<FilenameWithoutPath>key.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
</Group>
|
||||
|
||||
<Group>
|
||||
|
@ -419,7 +386,7 @@
|
|||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>11</FileNumber>
|
||||
<FileNumber>12</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -431,7 +398,7 @@
|
|||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>12</FileNumber>
|
||||
<FileNumber>13</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -443,7 +410,7 @@
|
|||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>13</FileNumber>
|
||||
<FileNumber>14</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -455,7 +422,7 @@
|
|||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>14</FileNumber>
|
||||
<FileNumber>15</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -467,7 +434,7 @@
|
|||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>15</FileNumber>
|
||||
<FileNumber>16</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -479,7 +446,7 @@
|
|||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>16</FileNumber>
|
||||
<FileNumber>17</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -491,7 +458,7 @@
|
|||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>17</FileNumber>
|
||||
<FileNumber>18</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -503,7 +470,7 @@
|
|||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>18</FileNumber>
|
||||
<FileNumber>19</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -515,7 +482,7 @@
|
|||
</File>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>19</FileNumber>
|
||||
<FileNumber>20</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -527,194 +494,6 @@
|
|||
</File>
|
||||
</Group>
|
||||
|
||||
<Group>
|
||||
<GroupName>User/lib</GroupName>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>20</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\User\lib\src\aes.c</PathWithFileName>
|
||||
<FilenameWithoutPath>aes.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>21</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\User\lib\src\clist.c</PathWithFileName>
|
||||
<FilenameWithoutPath>clist.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>22</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\User\lib\src\cmac.c</PathWithFileName>
|
||||
<FilenameWithoutPath>cmac.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>23</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\User\lib\src\cmd.c</PathWithFileName>
|
||||
<FilenameWithoutPath>cmd.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>24</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\User\lib\src\data_analysis.c</PathWithFileName>
|
||||
<FilenameWithoutPath>data_analysis.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>25</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\User\lib\src\debug.c</PathWithFileName>
|
||||
<FilenameWithoutPath>debug.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>26</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\User\lib\src\filter.c</PathWithFileName>
|
||||
<FilenameWithoutPath>filter.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>27</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\User\lib\src\lib.c</PathWithFileName>
|
||||
<FilenameWithoutPath>lib.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>28</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\User\lib\src\malloc.c</PathWithFileName>
|
||||
<FilenameWithoutPath>malloc.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>29</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\User\lib\src\mlist.c</PathWithFileName>
|
||||
<FilenameWithoutPath>mlist.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>30</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\User\lib\src\pbuf.c</PathWithFileName>
|
||||
<FilenameWithoutPath>pbuf.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>31</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\User\lib\src\sqqueue.c</PathWithFileName>
|
||||
<FilenameWithoutPath>sqqueue.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>32</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\User\lib\src\storage.c</PathWithFileName>
|
||||
<FilenameWithoutPath>storage.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>33</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\User\lib\src\wl_flash.c</PathWithFileName>
|
||||
<FilenameWithoutPath>wl_flash.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>34</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\User\lib\flow\flow_core.c</PathWithFileName>
|
||||
<FilenameWithoutPath>flow_core.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
</Group>
|
||||
|
||||
<Group>
|
||||
<GroupName>Drivers/STM32F1xx_HAL_Driver</GroupName>
|
||||
<tvExp>0</tvExp>
|
||||
|
@ -722,8 +501,8 @@
|
|||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>35</FileNumber>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>21</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -734,8 +513,8 @@
|
|||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>36</FileNumber>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>22</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -746,8 +525,8 @@
|
|||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>37</FileNumber>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>23</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -758,8 +537,8 @@
|
|||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>38</FileNumber>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>24</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -770,8 +549,8 @@
|
|||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>39</FileNumber>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>25</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -782,8 +561,8 @@
|
|||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>40</FileNumber>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>26</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -794,8 +573,8 @@
|
|||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>41</FileNumber>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>27</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -806,8 +585,8 @@
|
|||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>42</FileNumber>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>28</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -818,8 +597,8 @@
|
|||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>43</FileNumber>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>29</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -833,13 +612,13 @@
|
|||
|
||||
<Group>
|
||||
<GroupName>User/board</GroupName>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>8</GroupNumber>
|
||||
<FileNumber>44</FileNumber>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>30</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -849,6 +628,182 @@
|
|||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>31</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\User\system\lib\driver\ssd1306_oled.c</PathWithFileName>
|
||||
<FilenameWithoutPath>ssd1306_oled.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>32</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\User\system\lib\driver\tmc2240.c</PathWithFileName>
|
||||
<FilenameWithoutPath>tmc2240.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
</Group>
|
||||
|
||||
<Group>
|
||||
<GroupName>User/system/lib</GroupName>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>8</GroupNumber>
|
||||
<FileNumber>33</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\User\system\lib\src\aes.c</PathWithFileName>
|
||||
<FilenameWithoutPath>aes.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>8</GroupNumber>
|
||||
<FileNumber>34</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\User\system\lib\src\clist.c</PathWithFileName>
|
||||
<FilenameWithoutPath>clist.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>8</GroupNumber>
|
||||
<FileNumber>35</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\User\system\lib\src\cmac.c</PathWithFileName>
|
||||
<FilenameWithoutPath>cmac.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>8</GroupNumber>
|
||||
<FileNumber>36</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\User\system\lib\src\cmd.c</PathWithFileName>
|
||||
<FilenameWithoutPath>cmd.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>8</GroupNumber>
|
||||
<FileNumber>37</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\User\system\lib\src\data_analysis.c</PathWithFileName>
|
||||
<FilenameWithoutPath>data_analysis.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>8</GroupNumber>
|
||||
<FileNumber>38</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\User\system\lib\src\debug.c</PathWithFileName>
|
||||
<FilenameWithoutPath>debug.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>8</GroupNumber>
|
||||
<FileNumber>39</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\User\system\lib\src\filter.c</PathWithFileName>
|
||||
<FilenameWithoutPath>filter.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>8</GroupNumber>
|
||||
<FileNumber>40</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\User\system\lib\src\lib.c</PathWithFileName>
|
||||
<FilenameWithoutPath>lib.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>8</GroupNumber>
|
||||
<FileNumber>41</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\User\system\lib\src\malloc.c</PathWithFileName>
|
||||
<FilenameWithoutPath>malloc.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>8</GroupNumber>
|
||||
<FileNumber>42</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\User\system\lib\src\mlist.c</PathWithFileName>
|
||||
<FilenameWithoutPath>mlist.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>8</GroupNumber>
|
||||
<FileNumber>43</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\User\system\lib\src\pbuf.c</PathWithFileName>
|
||||
<FilenameWithoutPath>pbuf.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>8</GroupNumber>
|
||||
<FileNumber>44</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\User\system\lib\src\sqqueue.c</PathWithFileName>
|
||||
<FilenameWithoutPath>sqqueue.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>8</GroupNumber>
|
||||
<FileNumber>45</FileNumber>
|
||||
|
@ -856,8 +811,8 @@
|
|||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\User\lib\driver\ssd1306_oled.c</PathWithFileName>
|
||||
<FilenameWithoutPath>ssd1306_oled.c</FilenameWithoutPath>
|
||||
<PathWithFileName>..\User\system\lib\src\storage.c</PathWithFileName>
|
||||
<FilenameWithoutPath>storage.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
|
@ -868,76 +823,20 @@
|
|||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\User\lib\driver\tmc2240.c</PathWithFileName>
|
||||
<FilenameWithoutPath>tmc2240.c</FilenameWithoutPath>
|
||||
<PathWithFileName>..\User\system\lib\src\wl_flash.c</PathWithFileName>
|
||||
<FilenameWithoutPath>wl_flash.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
</Group>
|
||||
|
||||
<Group>
|
||||
<GroupName>User/lib/control</GroupName>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>9</GroupNumber>
|
||||
<GroupNumber>8</GroupNumber>
|
||||
<FileNumber>47</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\User\lib\control\src\pid.c</PathWithFileName>
|
||||
<FilenameWithoutPath>pid.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>9</GroupNumber>
|
||||
<FileNumber>48</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\User\lib\control\src\pid_auto_tune.c</PathWithFileName>
|
||||
<FilenameWithoutPath>pid_auto_tune.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>9</GroupNumber>
|
||||
<FileNumber>49</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\User\lib\control\src\pid_common.c</PathWithFileName>
|
||||
<FilenameWithoutPath>pid_common.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>9</GroupNumber>
|
||||
<FileNumber>50</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\User\lib\control\src\pid_fuzzy.c</PathWithFileName>
|
||||
<FilenameWithoutPath>pid_fuzzy.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>9</GroupNumber>
|
||||
<FileNumber>51</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\User\lib\control\src\pid_neural.c</PathWithFileName>
|
||||
<FilenameWithoutPath>pid_neural.c</FilenameWithoutPath>
|
||||
<PathWithFileName>..\User\system\lib\flow\flow_core.c</PathWithFileName>
|
||||
<FilenameWithoutPath>flow_core.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
|
|
|
@ -134,7 +134,7 @@
|
|||
<RunIndependent>0</RunIndependent>
|
||||
<UpdateFlashBeforeDebugging>1</UpdateFlashBeforeDebugging>
|
||||
<Capability>1</Capability>
|
||||
<DriverSelection>4101</DriverSelection>
|
||||
<DriverSelection>4096</DriverSelection>
|
||||
</Flash1>
|
||||
<bUseTDR>1</bUseTDR>
|
||||
<Flash2>BIN\UL2CM3.DLL</Flash2>
|
||||
|
@ -339,7 +339,7 @@
|
|||
<MiscControls></MiscControls>
|
||||
<Define>STM32,STM32F103xB,USE_FULL_LL_DRIVER,HSE_VALUE=8000000,HSE_STARTUP_TIMEOUT=100,LSE_STARTUP_TIMEOUT=5000,LSE_VALUE=32768,HSI_VALUE=8000000,LSI_VALUE=40000,VDD_VALUE=3300,PREFETCH_ENABLE=1</Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath>../Core/Inc;../Drivers/STM32F1xx_HAL_Driver/Inc;../Drivers/CMSIS/Device/ST/STM32F1xx/Include;../Drivers/CMSIS/Include;../User;../User/application;../User/board;../User/system/inc;../User/system/bsp;../User/lib/inc;../User/lib/flow;../User/lib/control/inc;../User/lib/driver</IncludePath>
|
||||
<IncludePath>../Core/Inc;../Drivers/STM32F1xx_HAL_Driver/Inc;../Drivers/CMSIS/Device/ST/STM32F1xx/Include;../Drivers/CMSIS/Include;../User;../User/application;../User/board;../User/system/inc;../User/system/bsp;../User/system/lib/inc;../User/system/lib/flow;../User/system/lib/control/inc;../User/system/lib/driver</IncludePath>
|
||||
</VariousControls>
|
||||
</Cads>
|
||||
<Aads>
|
||||
|
@ -652,6 +652,11 @@
|
|||
<FileType>1</FileType>
|
||||
<FilePath>..\User\application\app.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>key.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\User\application\key.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
|
@ -704,86 +709,6 @@
|
|||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>User/lib</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>aes.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\User\lib\src\aes.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>clist.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\User\lib\src\clist.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>cmac.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\User\lib\src\cmac.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>cmd.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\User\lib\src\cmd.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>data_analysis.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\User\lib\src\data_analysis.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>debug.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\User\lib\src\debug.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>filter.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\User\lib\src\filter.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>lib.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\User\lib\src\lib.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>malloc.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\User\lib\src\malloc.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>mlist.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\User\lib\src\mlist.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>pbuf.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\User\lib\src\pbuf.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>sqqueue.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\User\lib\src\sqqueue.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>storage.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\User\lib\src\storage.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>wl_flash.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\User\lib\src\wl_flash.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>flow_core.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\User\lib\flow\flow_core.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>Drivers/STM32F1xx_HAL_Driver</GroupName>
|
||||
<GroupOption>
|
||||
|
@ -1373,42 +1298,92 @@
|
|||
<File>
|
||||
<FileName>ssd1306_oled.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\User\lib\driver\ssd1306_oled.c</FilePath>
|
||||
<FilePath>..\User\system\lib\driver\ssd1306_oled.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>tmc2240.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\User\lib\driver\tmc2240.c</FilePath>
|
||||
<FilePath>..\User\system\lib\driver\tmc2240.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>User/lib/control</GroupName>
|
||||
<GroupName>User/system/lib</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>pid.c</FileName>
|
||||
<FileName>aes.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\User\lib\control\src\pid.c</FilePath>
|
||||
<FilePath>..\User\system\lib\src\aes.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>pid_auto_tune.c</FileName>
|
||||
<FileName>clist.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\User\lib\control\src\pid_auto_tune.c</FilePath>
|
||||
<FilePath>..\User\system\lib\src\clist.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>pid_common.c</FileName>
|
||||
<FileName>cmac.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\User\lib\control\src\pid_common.c</FilePath>
|
||||
<FilePath>..\User\system\lib\src\cmac.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>pid_fuzzy.c</FileName>
|
||||
<FileName>cmd.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\User\lib\control\src\pid_fuzzy.c</FilePath>
|
||||
<FilePath>..\User\system\lib\src\cmd.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>pid_neural.c</FileName>
|
||||
<FileName>data_analysis.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\User\lib\control\src\pid_neural.c</FilePath>
|
||||
<FilePath>..\User\system\lib\src\data_analysis.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>debug.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\User\system\lib\src\debug.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>filter.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\User\system\lib\src\filter.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>lib.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\User\system\lib\src\lib.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>malloc.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\User\system\lib\src\malloc.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>mlist.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\User\system\lib\src\mlist.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>pbuf.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\User\system\lib\src\pbuf.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>sqqueue.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\User\system\lib\src\sqqueue.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>storage.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\User\system\lib\src\storage.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>wl_flash.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\User\system\lib\src\wl_flash.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>flow_core.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\User\system\lib\flow\flow_core.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -2,18 +2,28 @@
|
|||
#include "app.h"
|
||||
#include "board.h"
|
||||
#include "flow.h"
|
||||
|
||||
#include "key.h"
|
||||
static struct flow business_fw; // 业务流程
|
||||
static struct flow idle_fw; // 空闲任务
|
||||
|
||||
app_t app;
|
||||
|
||||
void key_1_callback(PressEvent e)
|
||||
{
|
||||
app.angel = 360;
|
||||
}
|
||||
|
||||
static uint8_t business_inspection(struct flow *fl)
|
||||
{
|
||||
FL_HEAD(fl);
|
||||
for (;;)
|
||||
{
|
||||
tmc2240_position_read(TMC2240_1);
|
||||
if (app.angel != 0)
|
||||
{
|
||||
tmc2240_motor_set_angle(TMC2240_1, app.angel);
|
||||
app.angel = 0;
|
||||
}
|
||||
|
||||
FL_LOCK_DELAY(fl, FL_CLOCK_SEC);
|
||||
}
|
||||
FL_TAIL(fl);
|
||||
|
@ -34,8 +44,11 @@ static uint8_t idle_inspection(struct flow *fl)
|
|||
for (;;)
|
||||
{
|
||||
GPIO_TOGGLE(LED_BLUE_GPIO_Port, LED_BLUE_Pin);
|
||||
tmc2240_config_read(TMC2240_1);
|
||||
ssd1306_f6x8_string(0, 2, " tick:");
|
||||
ssd1306_f6x8_number(40, 2, tick++, 0);
|
||||
ssd1306_f6x8_string(0, 4, " cfg:");
|
||||
ssd1306_f6x8_number(40, 4, tmc2240_get(TMC2240_1)->config.gconf.data, 0);
|
||||
ssd1306_update_screen();
|
||||
FL_LOCK_DELAY(fl, FL_CLOCK_SEC);
|
||||
}
|
||||
|
@ -70,12 +83,11 @@ void app_init(void)
|
|||
{
|
||||
ssd1306_draw_progress_bar(i);
|
||||
}
|
||||
|
||||
ssd1306_clear();
|
||||
key_init();
|
||||
FL_INIT(&business_fw); // 业务流程
|
||||
FL_INIT(&idle_fw); // 空闲任务
|
||||
|
||||
ENABLE_TIM(TASK_TIM);
|
||||
ENABLE_TIM(WORK_TIM);
|
||||
|
||||
ssd1306_clear();
|
||||
ENABLE_TIM(TMC2240_TIM);
|
||||
}
|
||||
|
|
|
@ -11,10 +11,12 @@
|
|||
|
||||
typedef struct
|
||||
{
|
||||
int32_t angel;
|
||||
} app_t;
|
||||
|
||||
extern app_t app;
|
||||
|
||||
void app_init(void);
|
||||
void app_run(void);
|
||||
|
||||
#endif // APP_H
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
#include "key.h"
|
||||
#include "btn.h"
|
||||
|
||||
#define INVALID_BUTTON_TICKS 200 // 无效按键时间 毫秒
|
||||
static uint32_t key_start_ticks = 0;
|
||||
/* 按钮 */
|
||||
struct Button key_1;
|
||||
struct Button key_2;
|
||||
struct Button key_3;
|
||||
struct Button key_4;
|
||||
struct Button key_5;
|
||||
struct Button key_6;
|
||||
|
||||
static BOOL allow_condition(void)
|
||||
{
|
||||
/**
|
||||
* key的初始化在LCD板子上电之前,因为是低电平有效,所以会误判为按键按下
|
||||
*/
|
||||
if (sys_millis() - key_start_ticks < INVALID_BUTTON_TICKS) // 仿真的时候按键会有毛刺,在xx秒之后按下有效
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static uint8_t read_button_gpio(button_id_e button_id)
|
||||
{
|
||||
if (allow_condition() == FALSE)
|
||||
{
|
||||
return ACTIVE_LEVEL_HIGH;
|
||||
}
|
||||
switch (button_id)
|
||||
{
|
||||
case KEY_1:
|
||||
return GPIO_READ(KEY_1_GPIO_Port, KEY_1_Pin);
|
||||
|
||||
default:
|
||||
return ACTIVE_LEVEL_LOW;
|
||||
}
|
||||
}
|
||||
|
||||
static void key_1_press_down_handler(void *btn)
|
||||
{
|
||||
key_1_callback(PRESS_DOWN);
|
||||
}
|
||||
|
||||
void key_init(void)
|
||||
{
|
||||
key_start_ticks = sys_millis();
|
||||
GPIO_SET_INPUT(KEY_1_GPIO_Port, KEY_1_Pin);
|
||||
|
||||
button_init(&key_1, read_button_gpio, ACTIVE_LEVEL_LOW, KEY_1, KEY_1);
|
||||
|
||||
button_attach(&key_1, PRESS_DOWN, key_1_press_down_handler);
|
||||
|
||||
button_start(&key_1);
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
#ifndef _KEY_H_
|
||||
#define _KEY_H_
|
||||
#include "main.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
KEY_1 = 1,
|
||||
} button_id_e;
|
||||
|
||||
void key_1_callback(PressEvent e);
|
||||
|
||||
void key_init(void);
|
||||
#endif // _KEY_H_
|
|
@ -42,7 +42,6 @@ void board_init(void)
|
|||
ssd1306_init();
|
||||
|
||||
{
|
||||
GPIO_RESET(TMC2240_EN_GPIO_Port, TMC2240_EN_Pin);
|
||||
spi_gpio_group_t gpios;
|
||||
gpios.cs = gpio_create(TMC2240_CS_GPIO_Port, TMC2240_CS_Pin);
|
||||
gpios.mosi = gpio_create(TMC2240_MOSI_GPIO_Port, TMC2240_MOSI_Pin);
|
||||
|
@ -50,8 +49,8 @@ void board_init(void)
|
|||
gpios.miso = gpio_create(TMC2240_MISO_GPIO_Port, TMC2240_MISO_Pin);
|
||||
gpios.rst = gpio_create(NULL, 0);
|
||||
gpios.rdy = gpio_create(NULL, 0);
|
||||
tmc2240_init(TMC2240_1, &gpios);
|
||||
tmc2240_get(TMC2240_1)->spi->interface.hardware_enable(tmc2240_get(TMC2240_1)->spi, SPI1);
|
||||
tmc2240_config(TMC2240_1);
|
||||
tmc2240_init(TMC2240_1, SPI1, TMC2240_TIM, TMC2240_TIM_CH3, &gpios);
|
||||
tmc2240_get(TMC2240_1)->en = gpio_create(TMC2240_EN_GPIO_Port, TMC2240_EN_Pin);
|
||||
tmc2240_get(TMC2240_1)->dir = gpio_create(TMC2240_DIR_GPIO_Port, TMC2240_DIR_Pin);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,10 +7,8 @@
|
|||
#define UART_TXSIZE (240u) // 发送240个字节
|
||||
|
||||
#define TASK_TIM TIM1
|
||||
#define PWM_TIM TIM2
|
||||
#define PWM_CHANNEL LL_TIM_CHANNEL_CH2
|
||||
#define WORK_TIM TIM3
|
||||
|
||||
#define TMC2240_TIM TIM3
|
||||
#define TMC2240_TIM_CH3 LL_TIM_CHANNEL_CH3
|
||||
typedef struct
|
||||
{
|
||||
/* data */
|
||||
|
|
|
@ -1,96 +0,0 @@
|
|||
#include "tmc2240.h"
|
||||
|
||||
tmc2240_t _tmc2240[TMC2240_MAX];
|
||||
|
||||
static void tmc2240_write(tmc2240_index_e index, uint8_t *data)
|
||||
{
|
||||
DBG_ASSERT(index < TMC2240_MAX __DBG_LINE);
|
||||
tmc2240_t *tmc = &_tmc2240[index];
|
||||
|
||||
tmc->spi->gpios.cs->reset(*tmc->spi->gpios.cs);
|
||||
for (uint16_t i = 0; i < 5; i++)
|
||||
{
|
||||
tmc->spi->interface.u.normal.spi_send(tmc->spi, data[i]);
|
||||
}
|
||||
|
||||
tmc->spi->gpios.cs->set(*tmc->spi->gpios.cs);
|
||||
}
|
||||
|
||||
static void tmc2240_read(tmc2240_index_e index, uint8_t *wdata, uint8_t *rdata)
|
||||
{
|
||||
DBG_ASSERT(index < TMC2240_MAX __DBG_LINE);
|
||||
tmc2240_t *tmc = &_tmc2240[index];
|
||||
|
||||
tmc->spi->gpios.cs->reset(*tmc->spi->gpios.cs);
|
||||
for (uint16_t i = 0; i < 5; i++) // 循环读取数据
|
||||
{
|
||||
rdata[i] = tmc->spi->interface.u.normal.spi_send(tmc->spi, wdata[i]);
|
||||
}
|
||||
tmc->spi->gpios.cs->set(*tmc->spi->gpios.cs);
|
||||
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
|
||||
tmc->spi->gpios.cs->reset(*tmc->spi->gpios.cs);
|
||||
for (uint16_t i = 0; i < 5; i++) // 循环读取数据
|
||||
{
|
||||
rdata[i] = tmc->spi->interface.u.normal.spi_send(tmc->spi, wdata[i]);
|
||||
}
|
||||
tmc->spi->gpios.cs->set(*tmc->spi->gpios.cs);
|
||||
}
|
||||
|
||||
void tmc2240_config(tmc2240_index_e index)
|
||||
{
|
||||
uint8_t wdata[5];
|
||||
wdata[0] = 0x80 | TMC2240_REG_GCONF; // 写入 GCONF 寄存器
|
||||
wdata[1] = 0x00;
|
||||
wdata[2] = 0x00;
|
||||
wdata[3] = 0x00;
|
||||
wdata[4] = 0x01;
|
||||
tmc2240_write(index, wdata);
|
||||
|
||||
// 读取 GCONF 寄存器
|
||||
uint8_t rdata[5] = {0};
|
||||
wdata[0] = TMC2240_REG_GCONF;
|
||||
tmc2240_read(index, wdata, rdata);
|
||||
_tmc2240[index].data.gconf = rdata[4];
|
||||
}
|
||||
|
||||
void tmc2240_init(tmc2240_index_e index, spi_gpio_group_t *gpios)
|
||||
{
|
||||
DBG_ASSERT(index < TMC2240_MAX __DBG_LINE);
|
||||
tmc2240_t *tmc = &_tmc2240[index];
|
||||
|
||||
tmc->spi = spi_create(SPI_TYPE_NORMAL, *gpios, 0);
|
||||
DBG_ASSERT(tmc->spi != NULL __DBG_LINE);
|
||||
}
|
||||
|
||||
tmc2240_t *tmc2240_get(tmc2240_index_e index)
|
||||
{
|
||||
DBG_ASSERT(index < TMC2240_MAX __DBG_LINE);
|
||||
return &_tmc2240[index];
|
||||
}
|
||||
|
||||
int32_t tmc2240_position_read(tmc2240_index_e index)
|
||||
{
|
||||
DBG_ASSERT(index < TMC2240_MAX __DBG_LINE);
|
||||
tmc2240_t *tmc = &_tmc2240[index];
|
||||
uint8_t wdata[5] = {0};
|
||||
uint8_t rdata[5] = {0};
|
||||
|
||||
wdata[0] = 0x21; // XACTUAL register address
|
||||
tmc2240_read(index, wdata, rdata);
|
||||
|
||||
int32_t response = 0;
|
||||
|
||||
response |= (rdata[1]);
|
||||
response <<= 8;
|
||||
response |= (rdata[2]);
|
||||
response <<= 8;
|
||||
response |= (rdata[3]);
|
||||
response <<= 8;
|
||||
response |= (rdata[4]);
|
||||
tmc->data.position = response;
|
||||
return response;
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
#ifndef __TMC2240_H
|
||||
#define __TMC2240_H
|
||||
#include "main.h"
|
||||
#include "spis.h"
|
||||
#define TMC2240_REG_GCONF 0x00
|
||||
|
||||
typedef enum
|
||||
{
|
||||
TMC2240_1,
|
||||
TMC2240_MAX,
|
||||
} tmc2240_index_e;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
spi_t *spi;
|
||||
struct
|
||||
{
|
||||
int32_t gconf;
|
||||
int32_t position;
|
||||
} data;
|
||||
} tmc2240_t;
|
||||
|
||||
void tmc2240_init(tmc2240_index_e index, spi_gpio_group_t *gpios);
|
||||
void tmc2240_config(tmc2240_index_e index);
|
||||
tmc2240_t *tmc2240_get(tmc2240_index_e index);
|
||||
|
||||
int32_t tmc2240_position_read(tmc2240_index_e index);
|
||||
#endif // __TMC2240_H
|
|
@ -8,8 +8,8 @@
|
|||
"args": [],
|
||||
"stopAtEntry": false,
|
||||
"externalConsole": true,
|
||||
"cwd": "e:/work/stm32/epm/User/lib/flow",
|
||||
"program": "e:/work/stm32/epm/User/lib/flow/build/Debug/outDebug",
|
||||
"cwd": "e:/work/stm32/study/motor_cs103/User/system/lib/driver",
|
||||
"program": "e:/work/stm32/study/motor_cs103/User/system/lib/driver/build/Debug/outDebug",
|
||||
"MIMode": "gdb",
|
||||
"miDebuggerPath": "gdb",
|
||||
"setupCommands": [
|
|
@ -4,7 +4,7 @@
|
|||
"C_Cpp_Runner.debuggerPath": "gdb",
|
||||
"C_Cpp_Runner.cStandard": "",
|
||||
"C_Cpp_Runner.cppStandard": "",
|
||||
"C_Cpp_Runner.msvcBatchPath": "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Auxiliary/Build/vcvarsall.bat",
|
||||
"C_Cpp_Runner.msvcBatchPath": "C:/Program Files/Microsoft Visual Studio/VR_NR/Community/VC/Auxiliary/Build/vcvarsall.bat",
|
||||
"C_Cpp_Runner.useMsvc": false,
|
||||
"C_Cpp_Runner.warnings": [
|
||||
"-Wall",
|
||||
|
@ -54,5 +54,6 @@
|
|||
"C_Cpp_Runner.useUndefinedSanitizer": false,
|
||||
"C_Cpp_Runner.useLeakSanitizer": false,
|
||||
"C_Cpp_Runner.showCompilationTime": false,
|
||||
"C_Cpp_Runner.useLinkTimeOptimization": false
|
||||
"C_Cpp_Runner.useLinkTimeOptimization": false,
|
||||
"C_Cpp_Runner.msvcSecureNoWarnings": false
|
||||
}
|
|
@ -40,7 +40,9 @@
|
|||
} while (__LINE__ == -1)
|
||||
|
||||
#define PWM_GET_ARR(TIMx) LL_TIM_GetAutoReload(TIMx)
|
||||
#define PWM_SET_ARR(TIMx, ARR) LL_TIM_SetAutoReload(TIMx, ARR - 1)
|
||||
#define PWM_GET_PSC(TIMx) LL_TIM_GetPrescaler(TIMx)
|
||||
#define PWM_SET_PSC(TIMx, PSC) LL_TIM_SetPrescaler(TIMx, PSC - 1)
|
||||
|
||||
/**
|
||||
* @brief Sets the PWM frequency
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "spis.h"
|
||||
#include "delay.h"
|
||||
|
||||
#define SPI_TIMEOUT 2000
|
||||
#define SPI_TIMEOUT 0xffffffff
|
||||
|
||||
#define CMD_RDSR 0x05 /*!< Read Status Register instruction */
|
||||
#define CMD_WRSR 0x01 /*!< Write Status Register instruction */
|
||||
|
@ -460,6 +460,10 @@ static uint8_t spi_read_write_byte(spi_t *handle, uint8_t tx_data)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (spi_wait_flag(handle, LL_SPI_SR_TXE, SPI_TIMEOUT) == FALSE)
|
||||
{
|
||||
return 0xff;
|
||||
}
|
||||
LL_SPI_TransmitData8(handle->spi, tx_data);
|
||||
|
||||
if (spi_wait_flag(handle, LL_SPI_SR_RXNE, SPI_TIMEOUT) == FALSE)
|
||||
|
|
|
@ -1,8 +1,14 @@
|
|||
#include "dac161p997.h"
|
||||
#include "delay.h"
|
||||
|
||||
#include "tims.h"
|
||||
static dac161p997_t _handle;
|
||||
|
||||
static void delay_us(uint32_t us)
|
||||
{
|
||||
RESET_TIM_COUNT(TIME_1US);
|
||||
while (LL_TIM_GetCounter(TIME_1US) < us)
|
||||
; // 等待计数器达到指定值
|
||||
}
|
||||
|
||||
static void dac161p997_output_0()
|
||||
{
|
||||
_handle.io->set(*_handle.io);
|
||||
|
@ -124,17 +130,8 @@ void dac161p997_swif_write_reg(uint16_t data, uint8_t tag)
|
|||
*/
|
||||
void dac161p997_output_current(float32 current)
|
||||
{
|
||||
uint8_t adc = (uint16_t)(current * DAC161P997_CURRENT_SLOPE) >> 8;
|
||||
static uint8_t last_adc;
|
||||
if (adc == last_adc)
|
||||
{
|
||||
last_adc = adc;
|
||||
return;
|
||||
}
|
||||
|
||||
dac161p997_swif_write_reg(DAC161P997_LCK_REG_UNLOCK, CONFIG_WRITE);
|
||||
dac161p997_swif_write_reg(DAC161P997_ERR_LOW_REG + adc, CONFIG_WRITE);
|
||||
dac161p997_swif_write_reg(DAC161P997_LCK_REG_LOCK, CONFIG_WRITE);
|
||||
uint16_t adc = (uint16_t)(current * DAC161P997_CURRENT_SLOPE);
|
||||
dac161p997_swif_write_reg(adc, DACCODE_WRITE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -149,13 +146,9 @@ void dac161p997_output_current(float32 current)
|
|||
*/
|
||||
void dac161p997_init()
|
||||
{
|
||||
ENABLE_TIM_COUNT(TIME_1US);
|
||||
_handle.io = gpio_create(DAC161P997_IO_PORT, DAC161P997_IO_PIN);
|
||||
dac161p997_swif_write_reg(DAC161P997_LCK_REG_UNLOCK, CONFIG_WRITE);
|
||||
dac161p997_swif_write_reg(DAC161P997_CONFIG2_REG +
|
||||
DAC161P997_CONFIG2_REG_LOOP +
|
||||
DAC161P997_CONFIG2_REG_CHANNEL +
|
||||
DAC161P997_CONFIG2_REG_PARITY +
|
||||
DAC161P997_CONFIG2_REG_FRAME,
|
||||
CONFIG_WRITE);
|
||||
dac161p997_swif_write_reg(DAC161P997_LCK_REG_LOCK, CONFIG_WRITE);
|
||||
dac161p997_swif_write_reg(DAC161P997_LCK_REG + DAC161P997_LCK_REG_UNLOCK, CONFIG_WRITE);
|
||||
dac161p997_swif_write_reg(DAC161P997_CONFIG2_REG, CONFIG_WRITE);
|
||||
dac161p997_swif_write_reg(DAC161P997_LCK_REG + DAC161P997_LCK_REG_LOCK, CONFIG_WRITE);
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
#define __DAC161P997_H__
|
||||
#include "main.h"
|
||||
#include "gpios.h"
|
||||
|
||||
#define TIME_1US TIM1
|
||||
#define DAC161P997_IO_PORT (DAC161P997_GPIO_Port)
|
||||
#define DAC161P997_IO_PIN (DAC161P997_Pin)
|
||||
|
||||
|
@ -60,15 +60,15 @@
|
|||
#define DACCODE_20mA (0xD555)
|
||||
#define DACCODE_24mA (0xFFFF)
|
||||
|
||||
// cycles
|
||||
// #define QUARTER_CYCLES (625)
|
||||
// #define HALF_CYCLES (1250)
|
||||
// #define THREE_CYCLES (1875)
|
||||
// #define FULL_CYCLES (2500)
|
||||
typedef enum
|
||||
{
|
||||
DAC161P997_IDLE_SYM,
|
||||
|
||||
} dac161p997_e;
|
||||
typedef struct
|
||||
{
|
||||
gpio_t *io;
|
||||
uint8_t count;
|
||||
} dac161p997_t;
|
||||
|
||||
void dac161p997_output_0(void);
|
||||
|
@ -76,6 +76,7 @@ void dac161p997_output_1(void);
|
|||
void dac161p997_output_d(void);
|
||||
void dac161p997_output_symbol(uint8_t sym);
|
||||
void dac161p997_swif_write_reg(uint16_t data, uint8_t tag);
|
||||
|
||||
extern void dac161p997_output_current(float32 current);
|
||||
extern void dac161p997_init(void);
|
||||
#endif
|
|
@ -0,0 +1,368 @@
|
|||
#include "tmc2240.h"
|
||||
|
||||
tmc2240_t _tmc2240[TMC2240_MAX];
|
||||
|
||||
static void tmc2240_write(tmc2240_index_e index, uint8_t *data)
|
||||
{
|
||||
DBG_ASSERT(index < TMC2240_MAX __DBG_LINE);
|
||||
tmc2240_t *tmc = &_tmc2240[index];
|
||||
DBG_ASSERT(tmc != NULL __DBG_LINE);
|
||||
DBG_ASSERT(tmc->spi != NULL __DBG_LINE);
|
||||
|
||||
tmc->spi->gpios.cs->reset(*tmc->spi->gpios.cs);
|
||||
for (uint16_t i = 0; i < 5; i++)
|
||||
{
|
||||
tmc->spi->interface.u.normal.spi_send(tmc->spi, data[i]);
|
||||
}
|
||||
tmc->spi->gpios.cs->set(*tmc->spi->gpios.cs);
|
||||
}
|
||||
|
||||
static void tmc2240_read(tmc2240_index_e index, uint8_t *wdata, uint8_t *rdata)
|
||||
{
|
||||
DBG_ASSERT(index < TMC2240_MAX __DBG_LINE);
|
||||
tmc2240_t *tmc = &_tmc2240[index];
|
||||
DBG_ASSERT(tmc != NULL __DBG_LINE);
|
||||
DBG_ASSERT(tmc->spi != NULL __DBG_LINE);
|
||||
|
||||
tmc->spi->gpios.cs->reset(*tmc->spi->gpios.cs);
|
||||
for (uint16_t i = 0; i < 5; i++)
|
||||
{
|
||||
rdata[i] = tmc->spi->interface.u.normal.spi_send(tmc->spi, wdata[i]);
|
||||
}
|
||||
tmc->spi->gpios.cs->set(*tmc->spi->gpios.cs);
|
||||
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
|
||||
tmc->spi->gpios.cs->reset(*tmc->spi->gpios.cs);
|
||||
for (uint16_t i = 0; i < 5; i++)
|
||||
{
|
||||
rdata[i] = tmc->spi->interface.u.normal.spi_send(tmc->spi, wdata[i]);
|
||||
}
|
||||
tmc->spi->gpios.cs->set(*tmc->spi->gpios.cs);
|
||||
}
|
||||
|
||||
static void tmc2240_reg_write(tmc2240_index_e index, uint8_t reg, uint32_t data)
|
||||
{
|
||||
DBG_ASSERT(index < TMC2240_MAX __DBG_LINE);
|
||||
tmc2240_t *tmc = &_tmc2240[index];
|
||||
DBG_ASSERT(tmc != NULL __DBG_LINE);
|
||||
DBG_ASSERT(tmc->spi != NULL __DBG_LINE);
|
||||
|
||||
uint8_t wdata[5] = {0};
|
||||
wdata[0] = TMC2240_HIGHT_BIT | reg;
|
||||
wdata[1] = (data >> 24) & 0xFF;
|
||||
wdata[2] = (data >> 16) & 0xFF;
|
||||
wdata[3] = (data >> 8) & 0xFF;
|
||||
wdata[4] = data & 0xFF;
|
||||
tmc2240_write(index, wdata);
|
||||
}
|
||||
|
||||
static uint32_t tmc2240_reg_read(tmc2240_index_e index, uint8_t reg)
|
||||
{
|
||||
DBG_ASSERT(index < TMC2240_MAX __DBG_LINE);
|
||||
tmc2240_t *tmc = &_tmc2240[index];
|
||||
DBG_ASSERT(tmc != NULL __DBG_LINE);
|
||||
DBG_ASSERT(tmc->spi != NULL __DBG_LINE);
|
||||
|
||||
uint8_t wdata[5] = {0};
|
||||
uint8_t rdata[5] = {0};
|
||||
wdata[0] = reg;
|
||||
tmc2240_read(index, wdata, rdata);
|
||||
return (rdata[1] << 24) | (rdata[2] << 16) | (rdata[3] << 8) | rdata[4];
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 配置TMC2240步进电机驱动器
|
||||
*
|
||||
* 该函数用于配置TMC2240步进电机驱动器的各种参数,包括步进电机的工作模式、加减速曲线等。
|
||||
*
|
||||
* @param index TMC2240步进电机驱动器的索引,用于指定要配置的驱动器。
|
||||
*/
|
||||
static void tmc2240_config_write(tmc2240_index_e index)
|
||||
{
|
||||
DBG_ASSERT(index < TMC2240_MAX __DBG_LINE);
|
||||
tmc2240_t *tmc = &_tmc2240[index];
|
||||
DBG_ASSERT(tmc != NULL __DBG_LINE);
|
||||
|
||||
tmc->config.gconf.data = 0x00000000;
|
||||
|
||||
tmc->config.chopconf.data = 0x00410153;
|
||||
tmc->config.chopconf.bits.mres = TMC2240_MRES_8;
|
||||
|
||||
tmc->config.drvconf.data = 0x00000021;
|
||||
tmc->config.global_scaler.data = 0x00000000;
|
||||
|
||||
tmc->config.ihold_irun.bits.ihold = 31;
|
||||
tmc->config.ihold_irun.bits.irun = 31;
|
||||
tmc->config.ihold_irun.bits.iholddelay = 0;
|
||||
tmc->config.ihold_irun.bits.irundelay = 0;
|
||||
|
||||
tmc->config.pwmconf.data = 0xC44C261E;
|
||||
tmc->config.gstat.data = 0x00000007;
|
||||
tmc2240_reg_write(index, TMC2240_GCONF, tmc->config.gconf.data);
|
||||
tmc2240_reg_write(index, TMC2240_CHOPCONF, tmc->config.chopconf.data);
|
||||
tmc2240_reg_write(index, TMC2240_DRV_CONF, tmc->config.drvconf.data);
|
||||
tmc2240_reg_write(index, TMC2240_GLOBAL_SCALER, tmc->config.global_scaler.data);
|
||||
tmc2240_reg_write(index, TMC2240_IHOLD_IRUN, tmc->config.ihold_irun.data);
|
||||
tmc2240_reg_write(index, TMC2240_PWMCONF, tmc->config.pwmconf.data);
|
||||
tmc2240_reg_write(index, TMC2240_GSTAT, tmc->config.gstat.data);
|
||||
}
|
||||
|
||||
static void _tmc2240_motor_update(tmc2240_index_e index)
|
||||
{
|
||||
DBG_ASSERT(index < TMC2240_MAX __DBG_LINE);
|
||||
tmc2240_t *tmc = &_tmc2240[index];
|
||||
DBG_ASSERT(tmc != NULL __DBG_LINE);
|
||||
|
||||
switch (tmc->config.chopconf.bits.mres)
|
||||
{
|
||||
case TMC2240_MRES_256:
|
||||
tmc->motor.step_angle = MOTOR_42_STEP_ANGLE / 256;
|
||||
break;
|
||||
case TMC2240_MRES_128:
|
||||
tmc->motor.step_angle = MOTOR_42_STEP_ANGLE / 128;
|
||||
break;
|
||||
case TMC2240_MRES_64:
|
||||
tmc->motor.step_angle = MOTOR_42_STEP_ANGLE / 64;
|
||||
break;
|
||||
case TMC2240_MRES_32:
|
||||
tmc->motor.step_angle = MOTOR_42_STEP_ANGLE / 32;
|
||||
break;
|
||||
case TMC2240_MRES_16:
|
||||
tmc->motor.step_angle = MOTOR_42_STEP_ANGLE / 16;
|
||||
break;
|
||||
case TMC2240_MRES_8:
|
||||
tmc->motor.step_angle = MOTOR_42_STEP_ANGLE / 8;
|
||||
break;
|
||||
case TMC2240_MRES_4:
|
||||
tmc->motor.step_angle = MOTOR_42_STEP_ANGLE / 4;
|
||||
break;
|
||||
case TMC2240_MRES_2:
|
||||
tmc->motor.step_angle = MOTOR_42_STEP_ANGLE / 2;
|
||||
break;
|
||||
case TMC2240_MRES_1:
|
||||
tmc->motor.step_angle = MOTOR_42_STEP_ANGLE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
tmc->motor.circle_pulse = 360 / tmc->motor.step_angle;
|
||||
}
|
||||
|
||||
static void _tmc2240_enable(tmc2240_index_e index, BOOL enable)
|
||||
{
|
||||
DBG_ASSERT(index < TMC2240_MAX __DBG_LINE);
|
||||
tmc2240_t *tmc = &_tmc2240[index];
|
||||
DBG_ASSERT(tmc != NULL __DBG_LINE);
|
||||
|
||||
BOOL state = tmc->en->read(*tmc->en) == 0 ? TRUE : FALSE;
|
||||
|
||||
if (state == enable)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (enable == TRUE)
|
||||
{
|
||||
PWM_START(tmc->timer, tmc->time_ch);
|
||||
tmc->en->reset(*tmc->en);
|
||||
tmc2240_reg_write(index, TMC2240_CHOPCONF, tmc->config.chopconf.data);
|
||||
}
|
||||
else
|
||||
{
|
||||
PWM_STOP(tmc->timer, tmc->time_ch);
|
||||
tmc->en->set(*tmc->en);
|
||||
chopconf_u chopconf;
|
||||
osel_memset((uint8_t *)&chopconf, 0, sizeof(chopconf_u));
|
||||
chopconf.bits.mres = TMC2240_MRES_1;
|
||||
tmc2240_reg_write(index, TMC2240_CHOPCONF, chopconf.data);
|
||||
}
|
||||
}
|
||||
|
||||
static void _tmc2240_direction(tmc2240_index_e index, tmc2240_direction_e dir)
|
||||
{
|
||||
DBG_ASSERT(index < TMC2240_MAX __DBG_LINE);
|
||||
tmc2240_t *tmc = &_tmc2240[index];
|
||||
DBG_ASSERT(tmc != NULL __DBG_LINE);
|
||||
|
||||
if (dir == TMC2240_FORWARD)
|
||||
{
|
||||
tmc->dir->reset(*tmc->dir);
|
||||
}
|
||||
else
|
||||
{
|
||||
tmc->dir->set(*tmc->dir);
|
||||
}
|
||||
}
|
||||
|
||||
void tmc2240_init(tmc2240_index_e index, SPI_TypeDef *SPIx, TIM_TypeDef *timer, uint32_t time_ch, spi_gpio_group_t *gpios)
|
||||
{
|
||||
DBG_ASSERT(index < TMC2240_MAX __DBG_LINE);
|
||||
tmc2240_t *tmc = &_tmc2240[index];
|
||||
osel_memset((uint8_t *)tmc, 0, sizeof(tmc2240_t));
|
||||
|
||||
tmc->timer = timer;
|
||||
tmc->time_ch = time_ch;
|
||||
tmc->spi = spi_create(SPI_TYPE_NORMAL, *gpios, 0);
|
||||
DBG_ASSERT(tmc->spi != NULL __DBG_LINE);
|
||||
tmc->spi->interface.hardware_enable(tmc->spi, SPIx);
|
||||
{
|
||||
tmc->default_tm.sysclk = SystemCoreClock / 1000;
|
||||
tmc->default_tm.psc = PWM_GET_PSC(tmc->timer);
|
||||
tmc->default_tm.arr = PWM_GET_ARR(tmc->timer);
|
||||
tmc->default_tm.freq = PWM_GET_FREQ(tmc->timer);
|
||||
}
|
||||
tmc->params.percent = TMC2240_PWM_DUTY_DEFAULT;
|
||||
tmc->params.arr = 0;
|
||||
tmc->params.freq = 0;
|
||||
tmc->params.enable = FALSE;
|
||||
tmc->params.direction = TMC2240_FORWARD;
|
||||
tmc2240_config_write(index);
|
||||
_tmc2240_motor_update(index);
|
||||
}
|
||||
|
||||
tmc2240_t *tmc2240_get(tmc2240_index_e index)
|
||||
{
|
||||
DBG_ASSERT(index < TMC2240_MAX __DBG_LINE);
|
||||
return &_tmc2240[index];
|
||||
}
|
||||
|
||||
void tmc2240_percent(tmc2240_index_e index, float32 percent)
|
||||
{
|
||||
DBG_ASSERT(index < TMC2240_MAX __DBG_LINE);
|
||||
tmc2240_t *tmc = &_tmc2240[index];
|
||||
DBG_ASSERT(tmc != NULL __DBG_LINE);
|
||||
|
||||
PWM_SET_DUTY(tmc->timer, tmc->time_ch, ABS(percent));
|
||||
}
|
||||
|
||||
void tmc2240_config_read(tmc2240_index_e index)
|
||||
{
|
||||
DBG_ASSERT(index < TMC2240_MAX __DBG_LINE);
|
||||
tmc2240_t *tmc = &_tmc2240[index];
|
||||
DBG_ASSERT(tmc != NULL __DBG_LINE);
|
||||
|
||||
tmc->read_config.gconf.data = tmc2240_reg_read(index, TMC2240_GCONF);
|
||||
tmc->read_config.chopconf.data = tmc2240_reg_read(index, TMC2240_CHOPCONF);
|
||||
tmc->read_config.drvconf.data = tmc2240_reg_read(index, TMC2240_DRV_CONF);
|
||||
tmc->read_config.global_scaler.data = tmc2240_reg_read(index, TMC2240_GLOBAL_SCALER);
|
||||
tmc->read_config.ihold_irun.data = tmc2240_reg_read(index, TMC2240_IHOLD_IRUN);
|
||||
tmc->read_config.pwmconf.data = tmc2240_reg_read(index, TMC2240_PWMCONF);
|
||||
tmc->read_config.gstat.data = tmc2240_reg_read(index, TMC2240_GSTAT);
|
||||
tmc->data.tmc2240_adc_temp = tmc2240_reg_read(index, TMC2240_ADC_TEMP);
|
||||
tmc->data.tmc2240_temperature = (float32)(tmc->data.tmc2240_adc_temp - 2038) / 7.7;
|
||||
}
|
||||
|
||||
void tmc2240_test(tmc2240_index_e index)
|
||||
{
|
||||
DBG_ASSERT(index < TMC2240_MAX __DBG_LINE);
|
||||
tmc2240_t *tmc = &_tmc2240[index];
|
||||
DBG_ASSERT(tmc != NULL __DBG_LINE);
|
||||
|
||||
_tmc2240_enable(index, tmc->params.enable);
|
||||
|
||||
if (tmc->params.enable == TRUE)
|
||||
{
|
||||
_tmc2240_direction(index, tmc->params.direction);
|
||||
|
||||
if (PWM_GET_ARR(tmc->timer) != tmc->params.arr)
|
||||
{
|
||||
if (tmc->params.arr == 0)
|
||||
{
|
||||
tmc->params.arr = tmc->default_tm.arr;
|
||||
}
|
||||
PWM_SET_ARR(tmc->timer, tmc->params.arr);
|
||||
tmc->params.freq = PWM_GET_FREQ(tmc->timer);
|
||||
}
|
||||
|
||||
tmc2240_percent(index, tmc->params.percent);
|
||||
|
||||
if (tmc->config.chopconf.bits.mres != tmc->read_config.chopconf.bits.mres)
|
||||
{
|
||||
tmc2240_reg_write(index, TMC2240_CHOPCONF, tmc->config.chopconf.data);
|
||||
_tmc2240_motor_update(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void tmc2240_motor_set_angle(tmc2240_index_e index, int32_t angle)
|
||||
{
|
||||
DBG_ASSERT(index < TMC2240_MAX __DBG_LINE);
|
||||
tmc2240_t *tmc = &_tmc2240[index];
|
||||
DBG_ASSERT(tmc != NULL __DBG_LINE);
|
||||
|
||||
if (angle == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
tmc->params.enable = FALSE;
|
||||
_tmc2240_enable(index, tmc->params.enable);
|
||||
tmc->motor.pulse_count = 0;
|
||||
|
||||
if (angle > 0)
|
||||
{
|
||||
tmc->params.direction = TMC2240_FORWARD;
|
||||
}
|
||||
else
|
||||
{
|
||||
tmc->params.direction = TMC2240_BACKWARD;
|
||||
}
|
||||
|
||||
tmc->motor.pulse_count = ABS(angle) / tmc->motor.step_angle;
|
||||
tmc->motor.step_angle_count = 0;
|
||||
|
||||
tmc->params.enable = TRUE;
|
||||
|
||||
_tmc2240_direction(index, tmc->params.direction);
|
||||
if (PWM_GET_ARR(tmc->timer) != tmc->params.arr)
|
||||
{
|
||||
if (tmc->params.arr == 0)
|
||||
{
|
||||
tmc->params.arr = tmc->default_tm.arr;
|
||||
}
|
||||
PWM_SET_ARR(tmc->timer, tmc->params.arr);
|
||||
tmc->params.freq = PWM_GET_FREQ(tmc->timer);
|
||||
}
|
||||
|
||||
tmc2240_percent(index, tmc->params.percent);
|
||||
|
||||
if (tmc->config.chopconf.bits.mres != tmc->read_config.chopconf.bits.mres)
|
||||
{
|
||||
tmc2240_reg_write(index, TMC2240_CHOPCONF, tmc->config.chopconf.data);
|
||||
_tmc2240_motor_update(index);
|
||||
}
|
||||
_tmc2240_enable(index, tmc->params.enable);
|
||||
}
|
||||
|
||||
void tmc2240_motor_update(tmc2240_index_e index)
|
||||
{
|
||||
DBG_ASSERT(index < TMC2240_MAX __DBG_LINE);
|
||||
tmc2240_t *tmc = &_tmc2240[index];
|
||||
DBG_ASSERT(tmc != NULL __DBG_LINE);
|
||||
|
||||
if (tmc->motor.pulse_count > 0)
|
||||
{
|
||||
tmc->motor.pulse_count--; // 脉冲数
|
||||
tmc->motor.step_angle_count++; // 步距个数
|
||||
if (tmc->params.direction == TMC2240_FORWARD)
|
||||
{
|
||||
tmc->motor.add_pulse_count++; /* 绝对位置++ */
|
||||
}
|
||||
else
|
||||
{
|
||||
tmc->motor.add_pulse_count--; /* 绝对位置-- */
|
||||
}
|
||||
}
|
||||
|
||||
/* 当脉冲数等于0的时候 代表需要发送的脉冲个数已完成,停止输出 */
|
||||
|
||||
if (tmc->motor.pulse_count <= 0)
|
||||
{
|
||||
tmc->params.enable = FALSE;
|
||||
_tmc2240_enable(index, tmc->params.enable);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,372 @@
|
|||
/**
|
||||
* @file tmc2240.h
|
||||
* @author xushenghao
|
||||
* @brief TMC2240驱动头文件
|
||||
* @version 0.1
|
||||
* @note
|
||||
* 1. 芯片VM需要供电,否则SPI无法正常通信
|
||||
* 2. 42步进电机每步1.8度,1圈200步。1/8细分,1步=0.225度,电机转一周需要1600个脉冲
|
||||
*/
|
||||
|
||||
#ifndef __TMC2240_H
|
||||
#define __TMC2240_H
|
||||
#include "main.h"
|
||||
#include "spis.h"
|
||||
|
||||
#define MOTOR_42_STEP_ANGLE 1.8f // 42步进电机每步1.8度
|
||||
#define TMC2240_PWM_DUTY_DEFAULT 50 // PWM默认占空比
|
||||
|
||||
/*
|
||||
0x00 = 0x00002108 ;; writing GCONF @ address 0=0x00 with 0x00002108=8456=0.0
|
||||
0x03 = 0x00000000 ;; writing SLAVECONF @ address 1=0x03 with 0x00000000=0=0.0
|
||||
0x04 = 0x4001682C ;; writing IOIN @ address 2=0x04 with 0x4001682C=1073834028=0.0
|
||||
0x0A = 0x00000021 ;; writing DRV_CONF @ address 3=0x0A with 0x00000021=33=0.0
|
||||
0x0B = 0x00000000 ;; writing GLOBAL_SCALER @ address 4=0x0B with 0x00000000=0=0.0
|
||||
0x10 = 0x00001208 ;; writing IHOLD_IRUN @ address 5=0x10 with 0x00001208=4616=0.0
|
||||
0x11 = 0x00000000 ;; writing TPOWERDOWN @ address 6=0x11 with 0x00000000=0=0.0
|
||||
0x13 = 0x00000000 ;; writing TPWMTHRS @ address 7=0x13 with 0x00000000=0=0.0
|
||||
0x14 = 0x000003BE ;; writing TCOOLTHRS @ address 8=0x14 with 0x000003BE=958=0.0
|
||||
0x15 = 0x00000000 ;; writing THIGH @ address 9=0x15 with 0x00000000=0=0.0
|
||||
0x2D = 0x00000000 ;; writing DIRECT_MODE @ address 10=0x2D with 0x00000000=0=0.0
|
||||
0x38 = 0x00000000 ;; writing ENCMODE @ address 11=0x38 with 0x00000000=0=0.0
|
||||
0x39 = 0x00000000 ;; writing X_ENC @ address 12=0x39 with 0x00000000=0=0.0
|
||||
0x3A = 0x00010000 ;; writing ENC_CONST @ address 13=0x3A with 0x00010000=65536=0.0
|
||||
0x52 = 0x0B920F25 ;; writing OTW_OV_VTH @ address 14=0x52 with 0x0B920F25=194121509=0.0
|
||||
0x60 = 0xAAAAB554 ;; writing MSLUT[0] @ address 15=0x60 with 0xAAAAB554=0=0.0
|
||||
0x61 = 0x4A9554AA ;; writing MSLUT[1] @ address 16=0x61 with 0x4A9554AA=1251300522=0.0
|
||||
0x62 = 0x24492929 ;; writing MSLUT[2] @ address 17=0x62 with 0x24492929=608774441=0.0
|
||||
0x63 = 0x10104222 ;; writing MSLUT[3] @ address 18=0x63 with 0x10104222=269500962=0.0
|
||||
0x64 = 0xFBFFFFFF ;; writing MSLUT[4] @ address 19=0x64 with 0xFBFFFFFF=0=0.0
|
||||
0x65 = 0xB5BB777D ;; writing MSLUT[5] @ address 20=0x65 with 0xB5BB777D=0=0.0
|
||||
0x66 = 0x49295556 ;; writing MSLUT[6] @ address 21=0x66 with 0x49295556=1227445590=0.0
|
||||
0x67 = 0x00404222 ;; writing MSLUT[7] @ address 22=0x67 with 0x00404222=4211234=0.0
|
||||
0x68 = 0xFFFF8056 ;; writing MSLUTSEL @ address 23=0x68 with 0xFFFF8056=0=0.0
|
||||
0x69 = 0x00F70000 ;; writing MSLUTSTART @ address 24=0x69 with 0x00F70000=16187392=0.0
|
||||
0x6C = 0x00410153 ;; writing CHOPCONF @ address 25=0x6C with 0x00410153=4260179=0.0
|
||||
0x6D = 0x00040000 ;; writing COOLCONF @ address 26=0x6D with 0x00040000=262144=0.0
|
||||
0x70 = 0xC44C001E ;; writing PWMCONF @ address 27=0x70 with 0xC44C001E=0=0.0
|
||||
0x74 = 0x00000000 ;; writing SG4_THRS @ address 28=0x74 with 0x00000000=0=0.0
|
||||
*/
|
||||
|
||||
#define TMC2240_GCONF 0x00
|
||||
#define TMC2240_GSTAT 0x01
|
||||
#define TMC2240_IFCNT 0x02
|
||||
#define TMC2240_SLAVECONF 0x03
|
||||
#define TMC2240_IOIN 0x04
|
||||
#define TMC2240_DRV_CONF 0x0A
|
||||
#define TMC2240_GLOBAL_SCALER 0x0B
|
||||
|
||||
#define TMC2240_IHOLD_IRUN 0x10
|
||||
#define TMC2240_TPOWERDOWN 0x11
|
||||
#define TMC2240_TSTEP 0x12
|
||||
#define TMC2240_TPWMTHRS 0x13
|
||||
#define TMC2240_TCOOLTHRS 0x14
|
||||
#define TMC2240_THIGH 0x15
|
||||
|
||||
#define TMC2240_DIRECT_MODE 0x2D
|
||||
|
||||
#define TMC2240_ENCMODE 0x38
|
||||
#define TMC2240_XENC 0x39
|
||||
#define TMC2240_ENC_CONST 0x3A
|
||||
#define TMC2240_ENC_STATUS 0x3B
|
||||
#define TMC2240_ENC_LATCH 0x3C
|
||||
|
||||
#define TMC2240_ADC_VSUPPLY_AIN 0x50
|
||||
#define TMC2240_ADC_TEMP 0x51
|
||||
#define TMC2240_OTW_OV_VTH 0x52
|
||||
|
||||
#define TMC2240_MSLUT0 0x60
|
||||
#define TMC2240_MSLUT1 0x61
|
||||
#define TMC2240_MSLUT2 0x62
|
||||
#define TMC2240_MSLUT3 0x63
|
||||
#define TMC2240_MSLUT4 0x64
|
||||
#define TMC2240_MSLUT5 0x65
|
||||
#define TMC2240_MSLUT6 0x66
|
||||
#define TMC2240_MSLUT7 0x67
|
||||
#define TMC2240_MSLUTSEL 0x68
|
||||
#define TMC2240_MSLUTSTART 0x69
|
||||
#define TMC2240_MSCNT 0x6A
|
||||
#define TMC2240_MSCURACT 0x6B
|
||||
#define TMC2240_CHOPCONF 0x6C
|
||||
#define TMC2240_COOLCONF 0x6D
|
||||
#define TMC2240_DCCTRL 0x6E
|
||||
#define TMC2240_DRVSTATUS 0x6F
|
||||
|
||||
#define TMC2240_PWMCONF 0x70
|
||||
#define TMC2240_PWMSCALE 0x71
|
||||
#define TMC2240_PWM_AUTO 0x72
|
||||
#define TMC2240_SG4_THRS 0x74
|
||||
#define TMC2240_SG4_RESULT 0x75
|
||||
#define TMC2240_SG4_IND 0x76
|
||||
|
||||
#define TMC2240_HIGHT_BIT 0x80
|
||||
|
||||
typedef enum
|
||||
{
|
||||
TMC2240_1,
|
||||
TMC2240_MAX,
|
||||
} tmc2240_index_e;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
TMC2240_FORWARD, // 正转
|
||||
TMC2240_BACKWARD, // 反转
|
||||
} tmc2240_direction_e;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
TMC2240_MRES_256,
|
||||
TMC2240_MRES_128,
|
||||
TMC2240_MRES_64,
|
||||
TMC2240_MRES_32,
|
||||
TMC2240_MRES_16,
|
||||
TMC2240_MRES_8,
|
||||
TMC2240_MRES_4,
|
||||
TMC2240_MRES_2,
|
||||
TMC2240_MRES_1, // FULL STEP
|
||||
} tmc2240_mres_e;
|
||||
|
||||
// 0x00 GCONF
|
||||
typedef union
|
||||
{
|
||||
uint32_t data;
|
||||
struct
|
||||
{
|
||||
|
||||
uint32_t reserved1 : 1;
|
||||
/**
|
||||
* 停止之前的步骤执行超时检测。
|
||||
* 0x0:正常时间:2^20个时钟
|
||||
* 0x1:短时间:2^18个时钟
|
||||
*/
|
||||
uint32_t fast_standstill : 1;
|
||||
/**
|
||||
* 启用StealthChop2模式。
|
||||
* 0x0:无StealthChop2
|
||||
* 0x1:StealthChop2电压PWM模式使能(取决于速度阈值)。从关闭状态切换
|
||||
在静止状态下和在lHOLD = 时为开状态 仅限额定电流。
|
||||
*/
|
||||
uint32_t en_pwm_mode : 1;
|
||||
/**
|
||||
* 启用StealthChop2的步进输入筛选
|
||||
* 0x0:无StealthChop2
|
||||
* 0x1:StealthChop2电压PWM模式使能
|
||||
(取决于速度阈值)。从关闭状态切换
|
||||
在静止状态下和在lHOLD=时为开状态
|
||||
仅限额定电流。
|
||||
*/
|
||||
uint32_t multistep_filt : 1;
|
||||
/**
|
||||
* 更改电机方向/方向标志
|
||||
* 0x0:默认电机方向
|
||||
* 0x1:电机方向相反
|
||||
*/
|
||||
uint32_t shaft : 1;
|
||||
uint32_t diag0_error : 1;
|
||||
uint32_t diag0_otpw : 1;
|
||||
uint32_t diag0_stall : 1;
|
||||
uint32_t diag1_stall : 1;
|
||||
uint32_t diag1_index : 1;
|
||||
uint32_t diag1_onstate : 1;
|
||||
uint32_t reserved2 : 1;
|
||||
uint32_t diag0_pushpull : 1;
|
||||
uint32_t diag1_pushpull : 1;
|
||||
uint32_t small_hysteresis : 1;
|
||||
/**
|
||||
* 电机硬停止功能启用。
|
||||
* 0x0:正常运行
|
||||
* 0x1:紧急停止:ENCA停止定序器
|
||||
当绑得很高时(不执行任何步骤
|
||||
定序器、电机进入停顿状态)。
|
||||
*/
|
||||
uint32_t stop_enable : 1;
|
||||
/**
|
||||
* 通过以下方式启用直接motpr相电流控制
|
||||
* 0x0:正常运行
|
||||
* 0x1:电机线圈电流和极性直接
|
||||
通过串口编程:寄存器
|
||||
直接模式(0x2D)指定带符号线圈A
|
||||
电流(位8..0)和线圈B电流(位24..16)。在……里面
|
||||
在此模式下,电流按lHOLD设置进行定标。
|
||||
基于速度的StealthChop2电流调节
|
||||
在此模式下不可用。自动的
|
||||
StealthChop2电流调节仅适用于
|
||||
步进电机速度低。
|
||||
*/
|
||||
uint32_t direct_mode : 1;
|
||||
} bits;
|
||||
} gconf_u;
|
||||
|
||||
// 0x01 GSTAT
|
||||
typedef union
|
||||
{
|
||||
uint32_t data;
|
||||
struct
|
||||
{
|
||||
uint32_t reset : 1;
|
||||
uint32_t drv_err : 1;
|
||||
uint32_t uv_cp : 1;
|
||||
uint32_t register_reset : 1;
|
||||
uint32_t vm_uvlo : 1;
|
||||
} bits;
|
||||
} gstat_u;
|
||||
|
||||
// 0x0A DRVCONF
|
||||
typedef union
|
||||
{
|
||||
uint32_t data;
|
||||
struct
|
||||
{
|
||||
uint32_t current_range : 2; // 0-1
|
||||
uint32_t reserved1 : 2; // 2-3
|
||||
uint32_t slope_control : 2; // 4-5
|
||||
} bits;
|
||||
} drvconf_u;
|
||||
|
||||
// 0x0B GLOBAL_SCALER
|
||||
typedef union
|
||||
{
|
||||
uint32_t data;
|
||||
struct
|
||||
{
|
||||
uint32_t global_scale : 8; // 0-7
|
||||
} bits;
|
||||
} global_scaler_u;
|
||||
|
||||
// 0x10 IHOLD_IRUN
|
||||
typedef union
|
||||
{
|
||||
uint32_t data;
|
||||
struct
|
||||
{
|
||||
uint32_t ihold : 5; // 0-4
|
||||
uint32_t reserved1 : 3; // 5-7
|
||||
uint32_t irun : 5; // 8-12
|
||||
uint32_t reserved2 : 3; // 13-15
|
||||
uint32_t iholddelay : 4; // 16-19
|
||||
uint32_t reserved3 : 4; // 20-23
|
||||
uint32_t irundelay : 4; // 24-27
|
||||
} bits;
|
||||
} ihold_irun_u;
|
||||
|
||||
// 0x6C CHOPCONF
|
||||
typedef union
|
||||
{
|
||||
uint32_t data;
|
||||
struct
|
||||
{
|
||||
uint32_t toff : 4; // 0-3
|
||||
uint32_t hstrt : 3; // 4-6
|
||||
uint32_t hend : 4; // 7-10
|
||||
uint32_t fd3 : 1; // 11
|
||||
uint32_t disfdcc : 1; // 12
|
||||
uint32_t reserved1 : 1;
|
||||
uint32_t chm : 1; // 14
|
||||
uint32_t tbl : 2; // 15-16
|
||||
uint32_t reserved2 : 1;
|
||||
uint32_t vhighfs : 1; // 18
|
||||
uint32_t vhighchm : 1; // 19
|
||||
uint32_t tpfd : 4; // 20-23
|
||||
uint32_t mres : 4; // 24-27
|
||||
uint32_t intpol : 1; // 28
|
||||
uint32_t dedge : 1; // 29
|
||||
uint32_t diss2g : 1; // 30
|
||||
uint32_t diss2vs : 1; // 31
|
||||
} bits;
|
||||
} chopconf_u;
|
||||
|
||||
// 0x70 PWMCONF
|
||||
typedef union
|
||||
{
|
||||
uint32_t data;
|
||||
struct
|
||||
{
|
||||
/**
|
||||
* 用户定义的 PWM 幅度偏移(0-255)与静止状态下的全电机电流(CS_ACTUAL=31)相关。 (重置默认值=30) 使用 PWM_OFS 作为自动缩放的初始值,
|
||||
* 以加快自动调谐过程。为此,请将 PWM_OFS 设置为确定的、特定于应用的值,并将 pwm_autoscale 设置为 0。之后,将 pwm_autoscale 设置为 1。
|
||||
* 完成后启用 StealthChop2。 PWM_OFS = 0 将禁用将电机电流缩放到低于电机特定的较低测量阈值。此设置应仅在某些条件下使用,
|
||||
* 例如当电源电压可以上下变化两倍或更多时。它可以防止电机超出调节范围,但也会防止电流降到调节限制以下。 PWM_OFS > 0 允许自动缩放到低 PWM 占空比,
|
||||
* 甚至低于较低的调节阈值。这允许基于实际(保持)电流比例(寄存器 IHOLD_IRUN)的低(静止)电流设置。
|
||||
*/
|
||||
uint32_t pwm_ofs : 8;
|
||||
/**
|
||||
* PWM 幅度的速度依赖梯度: PWM_GRAD x 256 / TSTEP 此值加到 PWM_OFS 以补偿速度依赖的电机反电动势。 使用 PWM_GRAD 作为自动缩放的初始值,
|
||||
* 以加快自动调谐过程。为此,请将 PWM_GRAD 设置为确定的、特定于应用的值,并将 pwm_autoscale 设置为 0。之后,将 pwm_autoscale 设置为 1。
|
||||
* 完成后启用 StealthChop2。 提示: 初始调谐后,可以从 PWM_GRAD_AUTO 中读取所需的初始值。
|
||||
*/
|
||||
uint32_t pwm_grad : 8;
|
||||
uint32_t pwm_freq : 2;
|
||||
uint32_t pwm_autoscale : 1;
|
||||
uint32_t pwm_autograd : 1;
|
||||
} bits;
|
||||
} pwmconf_u;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
gconf_u gconf; // 0x00 GCONF
|
||||
gstat_u gstat; // 0x01 GSTAT
|
||||
drvconf_u drvconf; // 0x0A DRVCONF
|
||||
global_scaler_u global_scaler; // 0x0B GLOBAL_SCALER
|
||||
ihold_irun_u ihold_irun; // 0x10 IHOLD_IRUN
|
||||
chopconf_u chopconf; // 0x6C CHOPCONF
|
||||
pwmconf_u pwmconf; // 0x70 PWMCONF
|
||||
} tmc2240_config_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
gpio_t *en; ///< EN_PIN
|
||||
gpio_t *dir; ///< DIR_PIN
|
||||
TIM_TypeDef *timer;
|
||||
uint32_t time_ch;
|
||||
spi_t *spi;
|
||||
|
||||
tmc2240_config_t config;
|
||||
tmc2240_config_t read_config;
|
||||
|
||||
uint32_t step;
|
||||
__IO uint32_t step_count;
|
||||
|
||||
// PRIVATE
|
||||
struct
|
||||
{
|
||||
uint32_t sysclk; // 系统时钟
|
||||
uint32_t psc; // 预分频系数
|
||||
uint16_t arr; // 自动重装值 auto reload value
|
||||
uint32_t freq; // 频率
|
||||
} default_tm;
|
||||
struct
|
||||
{
|
||||
BOOL enable; // 使能
|
||||
tmc2240_direction_e direction; // 方向
|
||||
float32 percent; // 占空比
|
||||
uint16_t arr; // 自动重装值(改变速度)
|
||||
uint32_t freq; // 频率
|
||||
} params;
|
||||
|
||||
struct
|
||||
{
|
||||
float32 step_angle; // 步进角度
|
||||
uint16_t circle_pulse; // 一圈脉冲数
|
||||
|
||||
__IO int32_t add_pulse_count; /* 脉冲个数累计 */
|
||||
__IO uint32_t pulse_count; /* 脉冲个数记录 */
|
||||
__IO uint32_t step_angle_count; /* 步距个数 */
|
||||
} motor;
|
||||
|
||||
struct
|
||||
{
|
||||
uint16_t tmc2240_adc_temp; // 温度ADC值
|
||||
float32 tmc2240_temperature; // 温度
|
||||
} data;
|
||||
|
||||
} tmc2240_t;
|
||||
|
||||
void tmc2240_init(tmc2240_index_e index, SPI_TypeDef *SPIx, TIM_TypeDef *timer, uint32_t time_ch, spi_gpio_group_t *gpios);
|
||||
tmc2240_t *tmc2240_get(tmc2240_index_e index);
|
||||
|
||||
void tmc2240_motor_set_angle(tmc2240_index_e index, int32_t angle);
|
||||
void tmc2240_motor_update(tmc2240_index_e index);
|
||||
|
||||
void tmc2240_test(tmc2240_index_e index);
|
||||
void tmc2240_config_read(tmc2240_index_e index);
|
||||
#endif // __TMC2240_H
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue