加入按键
This commit is contained in:
parent
7ac6baf560
commit
ce04a54b9d
|
@ -23,10 +23,11 @@
|
||||||
#define __MAIN_H
|
#define __MAIN_H
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C"
|
||||||
|
{
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "stm32f1xx_ll_dma.h"
|
#include "stm32f1xx_ll_dma.h"
|
||||||
#include "stm32f1xx_ll_rcc.h"
|
#include "stm32f1xx_ll_rcc.h"
|
||||||
|
@ -49,28 +50,29 @@ extern "C" {
|
||||||
/* USER CODE BEGIN Includes */
|
/* USER CODE BEGIN Includes */
|
||||||
#include "sys.h"
|
#include "sys.h"
|
||||||
#include "delay.h"
|
#include "delay.h"
|
||||||
|
#include "btn.h"
|
||||||
#include "lib.h"
|
#include "lib.h"
|
||||||
#include "bsp.h"
|
#include "bsp.h"
|
||||||
|
|
||||||
/* USER CODE END Includes */
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
/* Exported types ------------------------------------------------------------*/
|
/* Exported types ------------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN ET */
|
/* USER CODE BEGIN ET */
|
||||||
|
|
||||||
/* USER CODE END ET */
|
/* USER CODE END ET */
|
||||||
|
|
||||||
/* Exported constants --------------------------------------------------------*/
|
/* Exported constants --------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN EC */
|
/* USER CODE BEGIN EC */
|
||||||
|
|
||||||
/* USER CODE END EC */
|
/* USER CODE END EC */
|
||||||
|
|
||||||
/* Exported macro ------------------------------------------------------------*/
|
/* Exported macro ------------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN EM */
|
/* USER CODE BEGIN EM */
|
||||||
|
|
||||||
/* USER CODE END EM */
|
/* USER CODE END EM */
|
||||||
|
|
||||||
/* Exported functions prototypes ---------------------------------------------*/
|
/* Exported functions prototypes ---------------------------------------------*/
|
||||||
void Error_Handler(void);
|
void Error_Handler(void);
|
||||||
|
|
||||||
/* USER CODE BEGIN EFP */
|
/* USER CODE BEGIN EFP */
|
||||||
|
|
||||||
|
@ -97,22 +99,24 @@ void Error_Handler(void);
|
||||||
#define OLED_SDA_GPIO_Port GPIOB
|
#define OLED_SDA_GPIO_Port GPIOB
|
||||||
#define OLDE_SCK_Pin LL_GPIO_PIN_13
|
#define OLDE_SCK_Pin LL_GPIO_PIN_13
|
||||||
#define OLDE_SCK_GPIO_Port GPIOB
|
#define OLDE_SCK_GPIO_Port GPIOB
|
||||||
|
#define KEY_1_Pin LL_GPIO_PIN_14
|
||||||
|
#define KEY_1_GPIO_Port GPIOB
|
||||||
#ifndef NVIC_PRIORITYGROUP_0
|
#ifndef NVIC_PRIORITYGROUP_0
|
||||||
#define NVIC_PRIORITYGROUP_0 ((uint32_t)0x00000007) /*!< 0 bit for pre-emption priority,
|
#define NVIC_PRIORITYGROUP_0 ((uint32_t)0x00000007) /*!< 0 bit for pre-emption priority, \
|
||||||
4 bits for subpriority */
|
4 bits for subpriority */
|
||||||
#define NVIC_PRIORITYGROUP_1 ((uint32_t)0x00000006) /*!< 1 bit for pre-emption priority,
|
#define NVIC_PRIORITYGROUP_1 ((uint32_t)0x00000006) /*!< 1 bit for pre-emption priority, \
|
||||||
3 bits for subpriority */
|
3 bits for subpriority */
|
||||||
#define NVIC_PRIORITYGROUP_2 ((uint32_t)0x00000005) /*!< 2 bits for pre-emption priority,
|
#define NVIC_PRIORITYGROUP_2 ((uint32_t)0x00000005) /*!< 2 bits for pre-emption priority, \
|
||||||
2 bits for subpriority */
|
2 bits for subpriority */
|
||||||
#define NVIC_PRIORITYGROUP_3 ((uint32_t)0x00000004) /*!< 3 bits for pre-emption priority,
|
#define NVIC_PRIORITYGROUP_3 ((uint32_t)0x00000004) /*!< 3 bits for pre-emption priority, \
|
||||||
1 bit for subpriority */
|
1 bit for subpriority */
|
||||||
#define NVIC_PRIORITYGROUP_4 ((uint32_t)0x00000003) /*!< 4 bits for pre-emption priority,
|
#define NVIC_PRIORITYGROUP_4 ((uint32_t)0x00000003) /*!< 4 bits for pre-emption priority, \
|
||||||
0 bit for subpriority */
|
0 bit for subpriority */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* USER CODE BEGIN Private defines */
|
/* USER CODE BEGIN Private defines */
|
||||||
|
|
||||||
/* USER CODE END Private defines */
|
/* USER CODE END Private defines */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,9 +94,9 @@ void MX_GPIO_Init(void)
|
||||||
LL_GPIO_Init(TMC2240_DIR_GPIO_Port, &GPIO_InitStruct);
|
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_14
|
GPIO_InitStruct.Pin = LL_GPIO_PIN_2|LL_GPIO_PIN_10|LL_GPIO_PIN_11|LL_GPIO_PIN_15
|
||||||
|LL_GPIO_PIN_15|LL_GPIO_PIN_3|LL_GPIO_PIN_4|LL_GPIO_PIN_5
|
|LL_GPIO_PIN_3|LL_GPIO_PIN_4|LL_GPIO_PIN_5|LL_GPIO_PIN_6
|
||||||
|LL_GPIO_PIN_6|LL_GPIO_PIN_7|LL_GPIO_PIN_8|LL_GPIO_PIN_9;
|
|LL_GPIO_PIN_7|LL_GPIO_PIN_8|LL_GPIO_PIN_9;
|
||||||
GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG;
|
GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG;
|
||||||
LL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
LL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
@ -108,6 +108,12 @@ void MX_GPIO_Init(void)
|
||||||
GPIO_InitStruct.Pull = LL_GPIO_PULL_UP;
|
GPIO_InitStruct.Pull = LL_GPIO_PULL_UP;
|
||||||
LL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
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 */
|
/* USER CODE BEGIN 2 */
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#include "sys.h"
|
#include "sys.h"
|
||||||
#include "flow.h"
|
#include "flow.h"
|
||||||
#include "board.h"
|
#include "board.h"
|
||||||
|
#include "btn.h"
|
||||||
/* USER CODE END Includes */
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
/* Private typedef -----------------------------------------------------------*/
|
/* Private typedef -----------------------------------------------------------*/
|
||||||
|
@ -68,8 +68,8 @@
|
||||||
/* Cortex-M3 Processor Interruption and Exception Handlers */
|
/* Cortex-M3 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 Memory management fault.
|
* @brief This function handles Memory management fault.
|
||||||
*/
|
*/
|
||||||
void MemManage_Handler(void)
|
void MemManage_Handler(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN MemoryManagement_IRQn 0 */
|
/* USER CODE BEGIN MemoryManagement_IRQn 0 */
|
||||||
|
@ -113,8 +113,8 @@ void MemManage_Handler(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles Prefetch fault, memory access fault.
|
* @brief This function handles Prefetch fault, memory access fault.
|
||||||
*/
|
*/
|
||||||
void BusFault_Handler(void)
|
void BusFault_Handler(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN BusFault_IRQn 0 */
|
/* USER CODE BEGIN BusFault_IRQn 0 */
|
||||||
|
@ -128,8 +128,8 @@ void BusFault_Handler(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles Undefined instruction or illegal state.
|
* @brief This function handles Undefined instruction or illegal state.
|
||||||
*/
|
*/
|
||||||
void UsageFault_Handler(void)
|
void UsageFault_Handler(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN UsageFault_IRQn 0 */
|
/* USER CODE BEGIN UsageFault_IRQn 0 */
|
||||||
|
@ -143,8 +143,8 @@ void UsageFault_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 SVCall_IRQn 0 */
|
/* USER CODE BEGIN SVCall_IRQn 0 */
|
||||||
|
@ -156,8 +156,8 @@ void SVC_Handler(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles Debug monitor.
|
* @brief This function handles Debug monitor.
|
||||||
*/
|
*/
|
||||||
void DebugMon_Handler(void)
|
void DebugMon_Handler(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN DebugMonitor_IRQn 0 */
|
/* USER CODE BEGIN DebugMonitor_IRQn 0 */
|
||||||
|
@ -169,8 +169,8 @@ void DebugMon_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 */
|
||||||
|
@ -182,8 +182,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 */
|
||||||
|
@ -203,8 +203,8 @@ void SysTick_Handler(void)
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles DMA1 channel4 global interrupt.
|
* @brief This function handles DMA1 channel4 global interrupt.
|
||||||
*/
|
*/
|
||||||
void DMA1_Channel4_IRQHandler(void)
|
void DMA1_Channel4_IRQHandler(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN DMA1_Channel4_IRQn 0 */
|
/* USER CODE BEGIN DMA1_Channel4_IRQn 0 */
|
||||||
|
@ -217,8 +217,8 @@ void DMA1_Channel4_IRQHandler(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles DMA1 channel5 global interrupt.
|
* @brief This function handles DMA1 channel5 global interrupt.
|
||||||
*/
|
*/
|
||||||
void DMA1_Channel5_IRQHandler(void)
|
void DMA1_Channel5_IRQHandler(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN DMA1_Channel5_IRQn 0 */
|
/* USER CODE BEGIN DMA1_Channel5_IRQn 0 */
|
||||||
|
@ -231,8 +231,8 @@ void DMA1_Channel5_IRQHandler(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles TIM1 update interrupt.
|
* @brief This function handles TIM1 update interrupt.
|
||||||
*/
|
*/
|
||||||
void TIM1_UP_IRQHandler(void)
|
void TIM1_UP_IRQHandler(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN TIM1_UP_IRQn 0 */
|
/* USER CODE BEGIN TIM1_UP_IRQn 0 */
|
||||||
|
@ -243,14 +243,15 @@ void TIM1_UP_IRQHandler(void)
|
||||||
{
|
{
|
||||||
TIM_IRQ_HANDLER(TASK_TIM);
|
TIM_IRQ_HANDLER(TASK_TIM);
|
||||||
LL_IncTick();
|
LL_IncTick();
|
||||||
|
button_ticks();
|
||||||
FLOW_TICK_UPDATE();
|
FLOW_TICK_UPDATE();
|
||||||
}
|
}
|
||||||
/* USER CODE END TIM1_UP_IRQn 1 */
|
/* USER CODE END TIM1_UP_IRQn 1 */
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles TIM3 global interrupt.
|
* @brief This function handles TIM3 global interrupt.
|
||||||
*/
|
*/
|
||||||
void TIM3_IRQHandler(void)
|
void TIM3_IRQHandler(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN TIM3_IRQn 0 */
|
/* USER CODE BEGIN TIM3_IRQn 0 */
|
||||||
|
@ -269,8 +270,8 @@ void TIM3_IRQHandler(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles USART1 global interrupt.
|
* @brief This function handles USART1 global interrupt.
|
||||||
*/
|
*/
|
||||||
void USART1_IRQHandler(void)
|
void USART1_IRQHandler(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN USART1_IRQn 0 */
|
/* USER CODE BEGIN USART1_IRQn 0 */
|
||||||
|
|
|
@ -364,6 +364,18 @@
|
||||||
<RteFlg>0</RteFlg>
|
<RteFlg>0</RteFlg>
|
||||||
<bShared>0</bShared>
|
<bShared>0</bShared>
|
||||||
</File>
|
</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>
|
||||||
|
|
||||||
<Group>
|
<Group>
|
||||||
|
@ -374,7 +386,7 @@
|
||||||
<RteFlg>0</RteFlg>
|
<RteFlg>0</RteFlg>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>5</GroupNumber>
|
<GroupNumber>5</GroupNumber>
|
||||||
<FileNumber>11</FileNumber>
|
<FileNumber>12</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
@ -386,7 +398,7 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>5</GroupNumber>
|
<GroupNumber>5</GroupNumber>
|
||||||
<FileNumber>12</FileNumber>
|
<FileNumber>13</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
@ -398,7 +410,7 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>5</GroupNumber>
|
<GroupNumber>5</GroupNumber>
|
||||||
<FileNumber>13</FileNumber>
|
<FileNumber>14</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
@ -410,7 +422,7 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>5</GroupNumber>
|
<GroupNumber>5</GroupNumber>
|
||||||
<FileNumber>14</FileNumber>
|
<FileNumber>15</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
@ -422,7 +434,7 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>5</GroupNumber>
|
<GroupNumber>5</GroupNumber>
|
||||||
<FileNumber>15</FileNumber>
|
<FileNumber>16</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
@ -434,7 +446,7 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>5</GroupNumber>
|
<GroupNumber>5</GroupNumber>
|
||||||
<FileNumber>16</FileNumber>
|
<FileNumber>17</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
@ -446,7 +458,7 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>5</GroupNumber>
|
<GroupNumber>5</GroupNumber>
|
||||||
<FileNumber>17</FileNumber>
|
<FileNumber>18</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
@ -458,7 +470,7 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>5</GroupNumber>
|
<GroupNumber>5</GroupNumber>
|
||||||
<FileNumber>18</FileNumber>
|
<FileNumber>19</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
@ -470,7 +482,7 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>5</GroupNumber>
|
<GroupNumber>5</GroupNumber>
|
||||||
<FileNumber>19</FileNumber>
|
<FileNumber>20</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
@ -490,7 +502,7 @@
|
||||||
<RteFlg>0</RteFlg>
|
<RteFlg>0</RteFlg>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>6</GroupNumber>
|
<GroupNumber>6</GroupNumber>
|
||||||
<FileNumber>20</FileNumber>
|
<FileNumber>21</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
@ -502,7 +514,7 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>6</GroupNumber>
|
<GroupNumber>6</GroupNumber>
|
||||||
<FileNumber>21</FileNumber>
|
<FileNumber>22</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
@ -514,7 +526,7 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>6</GroupNumber>
|
<GroupNumber>6</GroupNumber>
|
||||||
<FileNumber>22</FileNumber>
|
<FileNumber>23</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
@ -526,7 +538,7 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>6</GroupNumber>
|
<GroupNumber>6</GroupNumber>
|
||||||
<FileNumber>23</FileNumber>
|
<FileNumber>24</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
@ -538,7 +550,7 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>6</GroupNumber>
|
<GroupNumber>6</GroupNumber>
|
||||||
<FileNumber>24</FileNumber>
|
<FileNumber>25</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
@ -550,7 +562,7 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>6</GroupNumber>
|
<GroupNumber>6</GroupNumber>
|
||||||
<FileNumber>25</FileNumber>
|
<FileNumber>26</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
@ -562,7 +574,7 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>6</GroupNumber>
|
<GroupNumber>6</GroupNumber>
|
||||||
<FileNumber>26</FileNumber>
|
<FileNumber>27</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
@ -574,7 +586,7 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>6</GroupNumber>
|
<GroupNumber>6</GroupNumber>
|
||||||
<FileNumber>27</FileNumber>
|
<FileNumber>28</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
@ -586,7 +598,7 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>6</GroupNumber>
|
<GroupNumber>6</GroupNumber>
|
||||||
<FileNumber>28</FileNumber>
|
<FileNumber>29</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
@ -606,7 +618,7 @@
|
||||||
<RteFlg>0</RteFlg>
|
<RteFlg>0</RteFlg>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>7</GroupNumber>
|
<GroupNumber>7</GroupNumber>
|
||||||
<FileNumber>29</FileNumber>
|
<FileNumber>30</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
@ -618,7 +630,7 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>7</GroupNumber>
|
<GroupNumber>7</GroupNumber>
|
||||||
<FileNumber>30</FileNumber>
|
<FileNumber>31</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
@ -630,7 +642,7 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>7</GroupNumber>
|
<GroupNumber>7</GroupNumber>
|
||||||
<FileNumber>31</FileNumber>
|
<FileNumber>32</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
@ -650,7 +662,7 @@
|
||||||
<RteFlg>0</RteFlg>
|
<RteFlg>0</RteFlg>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>8</GroupNumber>
|
<GroupNumber>8</GroupNumber>
|
||||||
<FileNumber>32</FileNumber>
|
<FileNumber>33</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
@ -662,7 +674,7 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>8</GroupNumber>
|
<GroupNumber>8</GroupNumber>
|
||||||
<FileNumber>33</FileNumber>
|
<FileNumber>34</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
@ -674,7 +686,7 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>8</GroupNumber>
|
<GroupNumber>8</GroupNumber>
|
||||||
<FileNumber>34</FileNumber>
|
<FileNumber>35</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
@ -686,7 +698,7 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>8</GroupNumber>
|
<GroupNumber>8</GroupNumber>
|
||||||
<FileNumber>35</FileNumber>
|
<FileNumber>36</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
@ -698,7 +710,7 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>8</GroupNumber>
|
<GroupNumber>8</GroupNumber>
|
||||||
<FileNumber>36</FileNumber>
|
<FileNumber>37</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
@ -710,7 +722,7 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>8</GroupNumber>
|
<GroupNumber>8</GroupNumber>
|
||||||
<FileNumber>37</FileNumber>
|
<FileNumber>38</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
@ -722,7 +734,7 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>8</GroupNumber>
|
<GroupNumber>8</GroupNumber>
|
||||||
<FileNumber>38</FileNumber>
|
<FileNumber>39</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
@ -734,7 +746,7 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>8</GroupNumber>
|
<GroupNumber>8</GroupNumber>
|
||||||
<FileNumber>39</FileNumber>
|
<FileNumber>40</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
@ -746,7 +758,7 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>8</GroupNumber>
|
<GroupNumber>8</GroupNumber>
|
||||||
<FileNumber>40</FileNumber>
|
<FileNumber>41</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
@ -758,7 +770,7 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>8</GroupNumber>
|
<GroupNumber>8</GroupNumber>
|
||||||
<FileNumber>41</FileNumber>
|
<FileNumber>42</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
@ -770,7 +782,7 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>8</GroupNumber>
|
<GroupNumber>8</GroupNumber>
|
||||||
<FileNumber>42</FileNumber>
|
<FileNumber>43</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
@ -782,7 +794,7 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>8</GroupNumber>
|
<GroupNumber>8</GroupNumber>
|
||||||
<FileNumber>43</FileNumber>
|
<FileNumber>44</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
@ -794,7 +806,7 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>8</GroupNumber>
|
<GroupNumber>8</GroupNumber>
|
||||||
<FileNumber>44</FileNumber>
|
<FileNumber>45</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
@ -806,7 +818,7 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>8</GroupNumber>
|
<GroupNumber>8</GroupNumber>
|
||||||
<FileNumber>45</FileNumber>
|
<FileNumber>46</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
@ -818,7 +830,7 @@
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>8</GroupNumber>
|
<GroupNumber>8</GroupNumber>
|
||||||
<FileNumber>46</FileNumber>
|
<FileNumber>47</FileNumber>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
|
|
@ -652,6 +652,11 @@
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<FilePath>..\User\application\app.c</FilePath>
|
<FilePath>..\User\application\app.c</FilePath>
|
||||||
</File>
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>key.c</FileName>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<FilePath>..\User\application\key.c</FilePath>
|
||||||
|
</File>
|
||||||
</Files>
|
</Files>
|
||||||
</Group>
|
</Group>
|
||||||
<Group>
|
<Group>
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -2,12 +2,17 @@
|
||||||
#include "app.h"
|
#include "app.h"
|
||||||
#include "board.h"
|
#include "board.h"
|
||||||
#include "flow.h"
|
#include "flow.h"
|
||||||
|
#include "key.h"
|
||||||
static struct flow business_fw; // 业务流程
|
static struct flow business_fw; // 业务流程
|
||||||
static struct flow idle_fw; // 空闲任务
|
static struct flow idle_fw; // 空闲任务
|
||||||
|
|
||||||
app_t app;
|
app_t app;
|
||||||
|
|
||||||
|
void key_1_callback(PressEvent e)
|
||||||
|
{
|
||||||
|
app.angel = 360;
|
||||||
|
}
|
||||||
|
|
||||||
static uint8_t business_inspection(struct flow *fl)
|
static uint8_t business_inspection(struct flow *fl)
|
||||||
{
|
{
|
||||||
FL_HEAD(fl);
|
FL_HEAD(fl);
|
||||||
|
@ -40,7 +45,6 @@ static uint8_t idle_inspection(struct flow *fl)
|
||||||
{
|
{
|
||||||
GPIO_TOGGLE(LED_BLUE_GPIO_Port, LED_BLUE_Pin);
|
GPIO_TOGGLE(LED_BLUE_GPIO_Port, LED_BLUE_Pin);
|
||||||
tmc2240_config_read(TMC2240_1);
|
tmc2240_config_read(TMC2240_1);
|
||||||
tmc2240_process(TMC2240_1);
|
|
||||||
ssd1306_f6x8_string(0, 2, " tick:");
|
ssd1306_f6x8_string(0, 2, " tick:");
|
||||||
ssd1306_f6x8_number(40, 2, tick++, 0);
|
ssd1306_f6x8_number(40, 2, tick++, 0);
|
||||||
ssd1306_f6x8_string(0, 4, " cfg:");
|
ssd1306_f6x8_string(0, 4, " cfg:");
|
||||||
|
@ -79,11 +83,11 @@ void app_init(void)
|
||||||
{
|
{
|
||||||
ssd1306_draw_progress_bar(i);
|
ssd1306_draw_progress_bar(i);
|
||||||
}
|
}
|
||||||
|
ssd1306_clear();
|
||||||
|
key_init();
|
||||||
FL_INIT(&business_fw); // 业务流程
|
FL_INIT(&business_fw); // 业务流程
|
||||||
FL_INIT(&idle_fw); // 空闲任务
|
FL_INIT(&idle_fw); // 空闲任务
|
||||||
|
|
||||||
ENABLE_TIM(TASK_TIM);
|
ENABLE_TIM(TASK_TIM);
|
||||||
ENABLE_TIM(TMC2240_TIM);
|
ENABLE_TIM(TMC2240_TIM);
|
||||||
ssd1306_clear();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,4 +18,5 @@ extern app_t app;
|
||||||
|
|
||||||
void app_init(void);
|
void app_init(void);
|
||||||
void app_run(void);
|
void app_run(void);
|
||||||
|
|
||||||
#endif // APP_H
|
#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_
|
|
@ -256,7 +256,7 @@ void tmc2240_config_read(tmc2240_index_e index)
|
||||||
tmc->data.tmc2240_temperature = (float32)(tmc->data.tmc2240_adc_temp - 2038) / 7.7;
|
tmc->data.tmc2240_temperature = (float32)(tmc->data.tmc2240_adc_temp - 2038) / 7.7;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tmc2240_process(tmc2240_index_e index)
|
void tmc2240_test(tmc2240_index_e index)
|
||||||
{
|
{
|
||||||
DBG_ASSERT(index < TMC2240_MAX __DBG_LINE);
|
DBG_ASSERT(index < TMC2240_MAX __DBG_LINE);
|
||||||
tmc2240_t *tmc = &_tmc2240[index];
|
tmc2240_t *tmc = &_tmc2240[index];
|
||||||
|
@ -310,7 +310,27 @@ void tmc2240_motor_set_angle(tmc2240_index_e index, int32_t angle)
|
||||||
|
|
||||||
tmc->motor.pulse_count = ABS(angle) / tmc->motor.step_angle;
|
tmc->motor.pulse_count = ABS(angle) / tmc->motor.step_angle;
|
||||||
tmc->motor.step_angle_count = 0;
|
tmc->motor.step_angle_count = 0;
|
||||||
|
|
||||||
tmc->params.enable = TRUE;
|
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);
|
_tmc2240_enable(index, tmc->params.enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -367,6 +367,6 @@ tmc2240_t *tmc2240_get(tmc2240_index_e index);
|
||||||
void tmc2240_motor_set_angle(tmc2240_index_e index, int32_t angle);
|
void tmc2240_motor_set_angle(tmc2240_index_e index, int32_t angle);
|
||||||
void tmc2240_motor_update(tmc2240_index_e index);
|
void tmc2240_motor_update(tmc2240_index_e index);
|
||||||
|
|
||||||
void tmc2240_process(tmc2240_index_e index);
|
void tmc2240_test(tmc2240_index_e index);
|
||||||
void tmc2240_config_read(tmc2240_index_e index);
|
void tmc2240_config_read(tmc2240_index_e index);
|
||||||
#endif // __TMC2240_H
|
#endif // __TMC2240_H
|
||||||
|
|
19
motor.ioc
19
motor.ioc
|
@ -43,12 +43,13 @@ Mcu.Pin0=PC13-TAMPER-RTC
|
||||||
Mcu.Pin1=PD0-OSC_IN
|
Mcu.Pin1=PD0-OSC_IN
|
||||||
Mcu.Pin10=PB12
|
Mcu.Pin10=PB12
|
||||||
Mcu.Pin11=PB13
|
Mcu.Pin11=PB13
|
||||||
Mcu.Pin12=PA9
|
Mcu.Pin12=PB14
|
||||||
Mcu.Pin13=PA10
|
Mcu.Pin13=PA9
|
||||||
Mcu.Pin14=PA13
|
Mcu.Pin14=PA10
|
||||||
Mcu.Pin15=PA14
|
Mcu.Pin15=PA13
|
||||||
Mcu.Pin16=VP_SYS_VS_Systick
|
Mcu.Pin16=PA14
|
||||||
Mcu.Pin17=VP_TIM1_VS_ClockSourceINT
|
Mcu.Pin17=VP_SYS_VS_Systick
|
||||||
|
Mcu.Pin18=VP_TIM1_VS_ClockSourceINT
|
||||||
Mcu.Pin2=PD1-OSC_OUT
|
Mcu.Pin2=PD1-OSC_OUT
|
||||||
Mcu.Pin3=PA3
|
Mcu.Pin3=PA3
|
||||||
Mcu.Pin4=PA4
|
Mcu.Pin4=PA4
|
||||||
|
@ -57,7 +58,7 @@ Mcu.Pin6=PA6
|
||||||
Mcu.Pin7=PA7
|
Mcu.Pin7=PA7
|
||||||
Mcu.Pin8=PB0
|
Mcu.Pin8=PB0
|
||||||
Mcu.Pin9=PB1
|
Mcu.Pin9=PB1
|
||||||
Mcu.PinsNb=18
|
Mcu.PinsNb=19
|
||||||
Mcu.ThirdParty0=RealThread.RT-Thread.3.1.5
|
Mcu.ThirdParty0=RealThread.RT-Thread.3.1.5
|
||||||
Mcu.ThirdPartyNb=1
|
Mcu.ThirdPartyNb=1
|
||||||
Mcu.UserConstants=
|
Mcu.UserConstants=
|
||||||
|
@ -130,6 +131,10 @@ PB13.GPIO_PuPd=GPIO_PULLUP
|
||||||
PB13.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
|
PB13.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
|
||||||
PB13.PinState=GPIO_PIN_RESET
|
PB13.PinState=GPIO_PIN_RESET
|
||||||
PB13.Signal=GPIO_Output
|
PB13.Signal=GPIO_Output
|
||||||
|
PB14.GPIOParameters=GPIO_PuPd,GPIO_Label
|
||||||
|
PB14.GPIO_Label=KEY_1
|
||||||
|
PB14.GPIO_PuPd=GPIO_PULLUP
|
||||||
|
PB14.Signal=GPIO_Input
|
||||||
PC13-TAMPER-RTC.GPIOParameters=GPIO_Label
|
PC13-TAMPER-RTC.GPIOParameters=GPIO_Label
|
||||||
PC13-TAMPER-RTC.GPIO_Label=LED_BLUE
|
PC13-TAMPER-RTC.GPIO_Label=LED_BLUE
|
||||||
PC13-TAMPER-RTC.Signal=GPIO_Output
|
PC13-TAMPER-RTC.Signal=GPIO_Output
|
||||||
|
|
Loading…
Reference in New Issue