Browse Source

added stepper includes

alice
Gregor Wüst 3 years ago
parent
commit
337ebd0d91
3 changed files with 72 additions and 4 deletions
  1. 6
    0
      RTC/Core/Inc/main.h
  2. 1
    1
      RTC/Core/Inc/stm32f4xx_hal_conf.h
  3. 65
    3
      RTC/Core/Src/main.c

+ 6
- 0
RTC/Core/Inc/main.h View File



/* Includes ------------------------------------------------------------------*/ /* Includes ------------------------------------------------------------------*/
#include "stm32f4xx_hal.h" #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 ----------------------------------------------------------*/ /* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */ /* USER CODE BEGIN Includes */

+ 1
- 1
RTC/Core/Inc/stm32f4xx_hal_conf.h View File

/* #define HAL_SD_MODULE_ENABLED */ /* #define HAL_SD_MODULE_ENABLED */
/* #define HAL_MMC_MODULE_ENABLED */ /* #define HAL_MMC_MODULE_ENABLED */
/* #define HAL_SPI_MODULE_ENABLED */ /* #define HAL_SPI_MODULE_ENABLED */
/* #define HAL_TIM_MODULE_ENABLED */
#define HAL_TIM_MODULE_ENABLED
#define HAL_UART_MODULE_ENABLED #define HAL_UART_MODULE_ENABLED
/* #define HAL_USART_MODULE_ENABLED */ /* #define HAL_USART_MODULE_ENABLED */
/* #define HAL_IRDA_MODULE_ENABLED */ /* #define HAL_IRDA_MODULE_ENABLED */

+ 65
- 3
RTC/Core/Src/main.c View File

RTC_TimeTypeDef sTime; RTC_TimeTypeDef sTime;
RTC_DateTypeDef sDate; RTC_DateTypeDef sDate;
RTC_AlarmTypeDef sAlarmA, sAlarmB; RTC_AlarmTypeDef sAlarmA, sAlarmB;
static volatile uint16_t gLastError;
static volatile bool gButtonPressed = FALSE;
static volatile float sunWindow;


//Nuremberg coordinates //Nuremberg coordinates
int latitude_nbg = 49; int latitude_nbg = 49;
int day; int day;
int year; int year;
} timeAndDate; } timeAndDate;

/* USER CODE END PV */ /* USER CODE END PV */


/* Private function prototypes -----------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/
static void MX_GPIO_Init(void); static void MX_GPIO_Init(void);
static void MX_USART2_UART_Init(void); static void MX_USART2_UART_Init(void);
static void MX_RTC_Init(void); static void MX_RTC_Init(void);
static void MyFlagInterruptHandler(void);
void ButtonHandler(void);
/* USER CODE BEGIN PFP */ /* USER CODE BEGIN PFP */


/* USER CODE END PFP */ /* USER CODE END PFP */
HAL_Init(); HAL_Init();


/* USER CODE BEGIN 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 */ /* USER CODE END Init */


/* Configure the system clock */ /* Configure the system clock */
0 0
}; };


int32_t pos;
uint32_t freqPwm, timeToNextStep;

/* USER CODE END 2 */ /* USER CODE END 2 */


/* Infinite loop */ /* Infinite loop */
/* USER CODE BEGIN WHILE */ /* USER CODE BEGIN WHILE */
while (1) while (1)
{ {
/* USER CODE END WHILE */
HAL_Delay(2000);
freqPwm = BSP_MotorControl_GetBridgeInputPwmFreq(0);
BSP_MotorControl_SetBridgeInputPwmFreq(0, freqPwm>>1);

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 */
/* USER CODE BEGIN 3 */
setTime(&initialDate); setTime(&initialDate);
setDate(&initialDate); setDate(&initialDate);
leap_year_check(initialDate.year); leap_year_check(initialDate.year);
/* Alarm generation */ /* Alarm generation */
transmit_uart("B: Alarm!!!!\r\n"); 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 */ /* USER CODE END 4 */


/** /**

Loading…
Cancel
Save