added stepper includes
This commit is contained in:
parent
e4893ce0dd
commit
337ebd0d91
@ -29,6 +29,12 @@ extern "C" {
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32f4xx_hal.h"
|
||||
#include "x_nucleo_ihmxx.h"
|
||||
#include "l6208.h"
|
||||
#include "x_nucleo_ihm05a1_stm32f4xx.h"
|
||||
#ifdef USE_STM32F4XX_NUCLEO
|
||||
#include "x_nucleo_ihm05a1_stm32f4xx.h"
|
||||
#endif
|
||||
|
||||
/* Private includes ----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
@ -62,7 +62,7 @@
|
||||
/* #define HAL_SD_MODULE_ENABLED */
|
||||
/* #define HAL_MMC_MODULE_ENABLED */
|
||||
/* #define HAL_SPI_MODULE_ENABLED */
|
||||
/* #define HAL_TIM_MODULE_ENABLED */
|
||||
#define HAL_TIM_MODULE_ENABLED
|
||||
#define HAL_UART_MODULE_ENABLED
|
||||
/* #define HAL_USART_MODULE_ENABLED */
|
||||
/* #define HAL_IRDA_MODULE_ENABLED */
|
||||
|
@ -50,6 +50,9 @@ UART_HandleTypeDef huart2;
|
||||
RTC_TimeTypeDef sTime;
|
||||
RTC_DateTypeDef sDate;
|
||||
RTC_AlarmTypeDef sAlarmA, sAlarmB;
|
||||
static volatile uint16_t gLastError;
|
||||
static volatile bool gButtonPressed = FALSE;
|
||||
static volatile float sunWindow;
|
||||
|
||||
//Nuremberg coordinates
|
||||
int latitude_nbg = 49;
|
||||
@ -73,6 +76,7 @@ typedef struct {
|
||||
int day;
|
||||
int year;
|
||||
} timeAndDate;
|
||||
|
||||
/* USER CODE END PV */
|
||||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
@ -80,6 +84,8 @@ void SystemClock_Config(void);
|
||||
static void MX_GPIO_Init(void);
|
||||
static void MX_USART2_UART_Init(void);
|
||||
static void MX_RTC_Init(void);
|
||||
static void MyFlagInterruptHandler(void);
|
||||
void ButtonHandler(void);
|
||||
/* USER CODE BEGIN PFP */
|
||||
|
||||
/* USER CODE END PFP */
|
||||
@ -418,7 +424,20 @@ int main(void)
|
||||
HAL_Init();
|
||||
|
||||
/* USER CODE BEGIN Init */
|
||||
|
||||
//----- Init of the Motor control library
|
||||
/* Set the L6208 library to use 1 device */
|
||||
BSP_MotorControl_SetNbDevices(BSP_MOTOR_CONTROL_BOARD_ID_L6208, 1);
|
||||
BSP_MotorControl_Init(BSP_MOTOR_CONTROL_BOARD_ID_L6208, NULL);
|
||||
/* Attach the function MyFlagInterruptHandler (defined below) to the flag interrupt */
|
||||
BSP_MotorControl_AttachFlagInterrupt(MyFlagInterruptHandler);
|
||||
/* Attach the function MyErrorHandler (defined below) to the error Handler*/
|
||||
BSP_MotorControl_AttachErrorHandler(Error_Handler);
|
||||
/* Set Systick Interrupt priority highest to ensure no lock by using HAL_Delay */
|
||||
HAL_NVIC_SetPriority(SysTick_IRQn, 0x0, 0x0);
|
||||
/* Configure KEY Button */
|
||||
BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_EXTI);
|
||||
/* Disable the power bridges after initialization */
|
||||
BSP_MotorControl_CmdDisable(0);
|
||||
/* USER CODE END Init */
|
||||
|
||||
/* Configure the system clock */
|
||||
@ -445,15 +464,37 @@ int main(void)
|
||||
0
|
||||
};
|
||||
|
||||
int32_t pos;
|
||||
uint32_t freqPwm, timeToNextStep;
|
||||
|
||||
/* USER CODE END 2 */
|
||||
|
||||
/* Infinite loop */
|
||||
/* USER CODE BEGIN WHILE */
|
||||
while (1)
|
||||
{
|
||||
/* USER CODE END WHILE */
|
||||
HAL_Delay(2000);
|
||||
freqPwm = BSP_MotorControl_GetBridgeInputPwmFreq(0);
|
||||
BSP_MotorControl_SetBridgeInputPwmFreq(0, freqPwm>>1);
|
||||
|
||||
/* USER CODE BEGIN 3 */
|
||||
pos = BSP_MotorControl_GetPosition(0);
|
||||
|
||||
BSP_MotorControl_SetHome(0, pos);
|
||||
|
||||
BSP_MotorControl_SelectStepMode(0, STEP_MODE_FULL);
|
||||
|
||||
BSP_MotorControl_Move(0, FORWARD, 25);
|
||||
BSP_MotorControl_WaitWhileActive(0);
|
||||
|
||||
BSP_MotorControl_Move(0, FORWARD, 25);
|
||||
BSP_MotorControl_WaitWhileActive(0);
|
||||
|
||||
BSP_MotorControl_Move(0, FORWARD, 25);
|
||||
BSP_MotorControl_WaitWhileActive(0);
|
||||
|
||||
/* USER CODE END WHILE */
|
||||
|
||||
/* USER CODE BEGIN 3 */
|
||||
setTime(&initialDate);
|
||||
setDate(&initialDate);
|
||||
leap_year_check(initialDate.year);
|
||||
@ -731,6 +772,27 @@ void HAL_RTCEx_AlarmBEventCallback(RTC_HandleTypeDef *hrtc)
|
||||
/* Alarm generation */
|
||||
transmit_uart("B: Alarm!!!!\r\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function is the User handler for the flag interrupt
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void MyFlagInterruptHandler(void)
|
||||
{
|
||||
//When EN pin is forced low by a failure, configure the GPIO as an ouput low
|
||||
BSP_MotorControl_CmdDisable(0);
|
||||
}
|
||||
|
||||
void ButtonHandler(void)
|
||||
{
|
||||
gButtonPressed = TRUE;
|
||||
/* Let 200 ms before clearing the IT for key debouncing */
|
||||
HAL_Delay(200);
|
||||
__HAL_GPIO_EXTI_CLEAR_IT(KEY_BUTTON_PIN);
|
||||
HAL_NVIC_ClearPendingIRQ(KEY_BUTTON_EXTI_IRQn);
|
||||
}
|
||||
|
||||
/* USER CODE END 4 */
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user