Added working Alarm A and B
This commit is contained in:
parent
10f8906648
commit
aee0133856
@ -9,17 +9,17 @@ CDefines=USE_HAL_DRIVER;STM32F401xE;USE_HAL_DRIVER;USE_HAL_DRIVER;
|
|||||||
[PreviousGenFiles]
|
[PreviousGenFiles]
|
||||||
AdvancedFolderStructure=true
|
AdvancedFolderStructure=true
|
||||||
HeaderFileListSize=3
|
HeaderFileListSize=3
|
||||||
HeaderFiles#0=C:/Users/Gregor/Desktop/Projektarbeit/Workspace/RTC/Core/Inc/stm32f4xx_it.h
|
HeaderFiles#0=C:/Users/wuest/Desktop/Studium/Master/Sem2/Projekt/Arbeit/uC/Motorsteuerung/RTC/Core/Inc/stm32f4xx_it.h
|
||||||
HeaderFiles#1=C:/Users/Gregor/Desktop/Projektarbeit/Workspace/RTC/Core/Inc/stm32f4xx_hal_conf.h
|
HeaderFiles#1=C:/Users/wuest/Desktop/Studium/Master/Sem2/Projekt/Arbeit/uC/Motorsteuerung/RTC/Core/Inc/stm32f4xx_hal_conf.h
|
||||||
HeaderFiles#2=C:/Users/Gregor/Desktop/Projektarbeit/Workspace/RTC/Core/Inc/main.h
|
HeaderFiles#2=C:/Users/wuest/Desktop/Studium/Master/Sem2/Projekt/Arbeit/uC/Motorsteuerung/RTC/Core/Inc/main.h
|
||||||
HeaderFolderListSize=1
|
HeaderFolderListSize=1
|
||||||
HeaderPath#0=C:/Users/Gregor/Desktop/Projektarbeit/Workspace/RTC/Core/Inc
|
HeaderPath#0=C:/Users/wuest/Desktop/Studium/Master/Sem2/Projekt/Arbeit/uC/Motorsteuerung/RTC/Core/Inc
|
||||||
HeaderFiles=;
|
HeaderFiles=;
|
||||||
SourceFileListSize=3
|
SourceFileListSize=3
|
||||||
SourceFiles#0=C:/Users/Gregor/Desktop/Projektarbeit/Workspace/RTC/Core/Src/stm32f4xx_it.c
|
SourceFiles#0=C:/Users/wuest/Desktop/Studium/Master/Sem2/Projekt/Arbeit/uC/Motorsteuerung/RTC/Core/Src/stm32f4xx_it.c
|
||||||
SourceFiles#1=C:/Users/Gregor/Desktop/Projektarbeit/Workspace/RTC/Core/Src/stm32f4xx_hal_msp.c
|
SourceFiles#1=C:/Users/wuest/Desktop/Studium/Master/Sem2/Projekt/Arbeit/uC/Motorsteuerung/RTC/Core/Src/stm32f4xx_hal_msp.c
|
||||||
SourceFiles#2=C:/Users/Gregor/Desktop/Projektarbeit/Workspace/RTC/Core/Src/main.c
|
SourceFiles#2=C:/Users/wuest/Desktop/Studium/Master/Sem2/Projekt/Arbeit/uC/Motorsteuerung/RTC/Core/Src/main.c
|
||||||
SourceFolderListSize=1
|
SourceFolderListSize=1
|
||||||
SourcePath#0=C:/Users/Gregor/Desktop/Projektarbeit/Workspace/RTC/Core/Src
|
SourcePath#0=C:/Users/wuest/Desktop/Studium/Master/Sem2/Projekt/Arbeit/uC/Motorsteuerung/RTC/Core/Src
|
||||||
SourceFiles=;
|
SourceFiles=;
|
||||||
|
|
||||||
|
@ -19,13 +19,12 @@
|
|||||||
/* USER CODE END Header */
|
/* USER CODE END Header */
|
||||||
/* Includes ------------------------------------------------------------------*/
|
/* Includes ------------------------------------------------------------------*/
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "math.h"
|
|
||||||
#include "stdbool.h"
|
|
||||||
#include "string.h"
|
|
||||||
|
|
||||||
/* Private includes ----------------------------------------------------------*/
|
/* Private includes ----------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN Includes */
|
/* USER CODE BEGIN Includes */
|
||||||
|
#include "math.h"
|
||||||
|
#include "stdbool.h"
|
||||||
|
#include "string.h"
|
||||||
/* USER CODE END Includes */
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
/* Private typedef -----------------------------------------------------------*/
|
/* Private typedef -----------------------------------------------------------*/
|
||||||
@ -46,9 +45,11 @@
|
|||||||
/* Private variables ---------------------------------------------------------*/
|
/* Private variables ---------------------------------------------------------*/
|
||||||
RTC_HandleTypeDef hrtc;
|
RTC_HandleTypeDef hrtc;
|
||||||
UART_HandleTypeDef huart2;
|
UART_HandleTypeDef huart2;
|
||||||
|
|
||||||
|
/* USER CODE BEGIN PV */
|
||||||
RTC_TimeTypeDef sTime;
|
RTC_TimeTypeDef sTime;
|
||||||
RTC_DateTypeDef sDate;
|
RTC_DateTypeDef sDate;
|
||||||
RTC_AlarmTypeDef sAlarm;
|
RTC_AlarmTypeDef sAlarmA, sAlarmB;
|
||||||
|
|
||||||
//Nuremberg coordinates
|
//Nuremberg coordinates
|
||||||
int latitude_nbg = 49;
|
int latitude_nbg = 49;
|
||||||
@ -72,9 +73,6 @@ typedef struct {
|
|||||||
int day;
|
int day;
|
||||||
int year;
|
int year;
|
||||||
} timeAndDate;
|
} timeAndDate;
|
||||||
|
|
||||||
/* USER CODE BEGIN PV */
|
|
||||||
|
|
||||||
/* USER CODE END PV */
|
/* USER CODE END PV */
|
||||||
|
|
||||||
/* Private function prototypes -----------------------------------------------*/
|
/* Private function prototypes -----------------------------------------------*/
|
||||||
@ -346,28 +344,28 @@ void calc_tomorrows_date(timeAndDate* initialDate, timeAndDate* tomorrowsDate)
|
|||||||
* Function Name : set_Alarm
|
* Function Name : set_Alarm
|
||||||
* Description : sets the wake up Alarm
|
* Description : sets the wake up Alarm
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
void set_Alarm(int h, int min, int weekDay, char* alarm)
|
void set_Alarm(int h, int min, int weekDay, char* alarm, RTC_AlarmTypeDef* alarmInstance)
|
||||||
{
|
{
|
||||||
/** Enable the Alarm A*/
|
/** Enable the Alarm A*/
|
||||||
|
|
||||||
sAlarm.AlarmTime.Hours = h;
|
alarmInstance->AlarmTime.Hours = h;
|
||||||
sAlarm.AlarmTime.Minutes = min;
|
alarmInstance->AlarmTime.Minutes = min;
|
||||||
sAlarm.AlarmTime.Seconds = 0;
|
alarmInstance->AlarmTime.Seconds = 0;
|
||||||
sAlarm.AlarmTime.SubSeconds = 0;
|
alarmInstance->AlarmTime.SubSeconds = 0;
|
||||||
sAlarm.AlarmTime.DayLightSaving = RTC_DAYLIGHTSAVING_NONE;
|
alarmInstance->AlarmTime.DayLightSaving = RTC_DAYLIGHTSAVING_NONE;
|
||||||
sAlarm.AlarmTime.StoreOperation = RTC_STOREOPERATION_RESET;
|
alarmInstance->AlarmTime.StoreOperation = RTC_STOREOPERATION_RESET;
|
||||||
sAlarm.AlarmMask = RTC_ALARMMASK_NONE; //only by specific time
|
alarmInstance->AlarmMask = RTC_ALARMMASK_NONE; //only by specific time
|
||||||
sAlarm.AlarmSubSecondMask = RTC_ALARMSUBSECONDMASK_ALL;
|
alarmInstance->AlarmSubSecondMask = RTC_ALARMSUBSECONDMASK_ALL;
|
||||||
sAlarm.AlarmDateWeekDaySel = RTC_ALARMDATEWEEKDAYSEL_WEEKDAY;
|
alarmInstance->AlarmDateWeekDaySel = RTC_ALARMDATEWEEKDAYSEL_WEEKDAY;
|
||||||
sAlarm.AlarmDateWeekDay = weekDay;
|
alarmInstance->AlarmDateWeekDay = weekDay;
|
||||||
|
|
||||||
if (strcmp("A", alarm) == 0) {
|
if (strcmp("A", alarm) == 0) {
|
||||||
sAlarm.Alarm = RTC_ALARM_A;
|
alarmInstance->Alarm = RTC_ALARM_A;
|
||||||
} else {
|
} else {
|
||||||
sAlarm.Alarm = RTC_ALARM_B;
|
alarmInstance->Alarm = RTC_ALARM_B;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (HAL_RTC_SetAlarm_IT(&hrtc, &sAlarm, RTC_FORMAT_BIN) != HAL_OK)
|
if (HAL_RTC_SetAlarm_IT(&hrtc, alarmInstance, RTC_FORMAT_BIN) != HAL_OK)
|
||||||
{
|
{
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
}
|
}
|
||||||
@ -451,9 +449,11 @@ int main(void)
|
|||||||
|
|
||||||
/* Infinite loop */
|
/* Infinite loop */
|
||||||
/* USER CODE BEGIN WHILE */
|
/* USER CODE BEGIN WHILE */
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
/* USER CODE END WHILE */
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 3 */
|
||||||
setTime(&initialDate);
|
setTime(&initialDate);
|
||||||
setDate(&initialDate);
|
setDate(&initialDate);
|
||||||
leap_year_check(initialDate.year);
|
leap_year_check(initialDate.year);
|
||||||
@ -475,8 +475,8 @@ int main(void)
|
|||||||
// Go to Sleep
|
// Go to Sleep
|
||||||
|
|
||||||
|
|
||||||
set_Alarm(16, 18, 4, "A");
|
set_Alarm(16, 18, 4, "A", &sAlarmA);
|
||||||
set_Alarm(16, 20, 4, "B");
|
set_Alarm(16, 20, 4, "B", &sAlarmB);
|
||||||
|
|
||||||
HAL_Delay(5000);
|
HAL_Delay(5000);
|
||||||
|
|
||||||
@ -525,8 +525,7 @@ void SystemClock_Config(void)
|
|||||||
*/
|
*/
|
||||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_LSI;
|
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_LSI;
|
||||||
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
|
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
|
||||||
//RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
|
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
|
||||||
RCC_OscInitStruct.HSICalibrationValue = 16;
|
|
||||||
RCC_OscInitStruct.LSIState = RCC_LSI_ON;
|
RCC_OscInitStruct.LSIState = RCC_LSI_ON;
|
||||||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
||||||
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
|
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
|
||||||
@ -571,6 +570,10 @@ static void MX_RTC_Init(void)
|
|||||||
|
|
||||||
/* USER CODE END RTC_Init 0 */
|
/* USER CODE END RTC_Init 0 */
|
||||||
|
|
||||||
|
RTC_TimeTypeDef sTime = {0};
|
||||||
|
RTC_DateTypeDef sDate = {0};
|
||||||
|
//RTC_AlarmTypeDef sAlarm = {0};
|
||||||
|
|
||||||
/* USER CODE BEGIN RTC_Init 1 */
|
/* USER CODE BEGIN RTC_Init 1 */
|
||||||
|
|
||||||
/* USER CODE END RTC_Init 1 */
|
/* USER CODE END RTC_Init 1 */
|
||||||
@ -612,7 +615,33 @@ static void MX_RTC_Init(void)
|
|||||||
{
|
{
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
}
|
}
|
||||||
|
/** Enable the Alarm A
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
sAlarm.AlarmTime.Hours = 0;
|
||||||
|
sAlarm.AlarmTime.Minutes = 0;
|
||||||
|
sAlarm.AlarmTime.Seconds = 0;
|
||||||
|
sAlarm.AlarmTime.SubSeconds = 0;
|
||||||
|
sAlarm.AlarmTime.DayLightSaving = RTC_DAYLIGHTSAVING_NONE;
|
||||||
|
sAlarm.AlarmTime.StoreOperation = RTC_STOREOPERATION_RESET;
|
||||||
|
sAlarm.AlarmMask = RTC_ALARMMASK_NONE;
|
||||||
|
sAlarm.AlarmSubSecondMask = RTC_ALARMSUBSECONDMASK_ALL;
|
||||||
|
sAlarm.AlarmDateWeekDaySel = RTC_ALARMDATEWEEKDAYSEL_DATE;
|
||||||
|
sAlarm.AlarmDateWeekDay = 1;
|
||||||
|
sAlarm.Alarm = RTC_ALARM_A;
|
||||||
|
if (HAL_RTC_SetAlarm_IT(&hrtc, &sAlarm, RTC_FORMAT_BIN) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
/** Enable the Alarm B
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
sAlarm.AlarmDateWeekDay = 1;
|
||||||
|
sAlarm.Alarm = RTC_ALARM_B;
|
||||||
|
if (HAL_RTC_SetAlarm_IT(&hrtc, &sAlarm, RTC_FORMAT_BIN) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
/* USER CODE BEGIN RTC_Init 2 */
|
/* USER CODE BEGIN RTC_Init 2 */
|
||||||
|
|
||||||
/* USER CODE END RTC_Init 2 */
|
/* USER CODE END RTC_Init 2 */
|
||||||
@ -686,7 +715,22 @@ static void MX_GPIO_Init(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* USER CODE BEGIN 4 */
|
/* USER CODE BEGIN 4 */
|
||||||
|
/**
|
||||||
|
* @brief Alarm callback
|
||||||
|
* @param hrtc: RTC handle
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef *hrtc)
|
||||||
|
{
|
||||||
|
/* Alarm generation */
|
||||||
|
transmit_uart("A: Alarm!!!!\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void HAL_RTCEx_AlarmBEventCallback(RTC_HandleTypeDef *hrtc)
|
||||||
|
{
|
||||||
|
/* Alarm generation */
|
||||||
|
transmit_uart("B: Alarm!!!!\r\n");
|
||||||
|
}
|
||||||
/* USER CODE END 4 */
|
/* USER CODE END 4 */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -704,24 +748,6 @@ void Error_Handler(void)
|
|||||||
/* USER CODE END Error_Handler_Debug */
|
/* USER CODE END Error_Handler_Debug */
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Alarm callback
|
|
||||||
* @param hrtc: RTC handle
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef *hrtc)
|
|
||||||
{
|
|
||||||
/* Alarm generation */
|
|
||||||
transmit_uart("A: Alarm!!!!\r\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
void HAL_RTC_AlarmBEventCallback(RTC_HandleTypeDef *hrtc)
|
|
||||||
{
|
|
||||||
/* Alarm generation */
|
|
||||||
transmit_uart("B: Alarm!!!!\r\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef USE_FULL_ASSERT
|
#ifdef USE_FULL_ASSERT
|
||||||
/**
|
/**
|
||||||
* @brief Reports the name of the source file and the source line number
|
* @brief Reports the name of the source file and the source line number
|
||||||
|
14
RTC/RTC.ioc
14
RTC/RTC.ioc
@ -15,8 +15,9 @@ Mcu.Pin1=PC14-OSC32_IN
|
|||||||
Mcu.Pin10=PB3
|
Mcu.Pin10=PB3
|
||||||
Mcu.Pin11=VP_RTC_VS_RTC_Activate
|
Mcu.Pin11=VP_RTC_VS_RTC_Activate
|
||||||
Mcu.Pin12=VP_RTC_VS_RTC_Calendar
|
Mcu.Pin12=VP_RTC_VS_RTC_Calendar
|
||||||
Mcu.Pin13=VP_RTC_VS_RTC_Alarm_A_Intern
|
Mcu.Pin13=VP_RTC_VS_RTC_Alarm_B_Intern
|
||||||
Mcu.Pin14=VP_SYS_VS_Systick
|
Mcu.Pin14=VP_RTC_VS_RTC_Alarm_A_Intern
|
||||||
|
Mcu.Pin15=VP_SYS_VS_Systick
|
||||||
Mcu.Pin2=PC15-OSC32_OUT
|
Mcu.Pin2=PC15-OSC32_OUT
|
||||||
Mcu.Pin3=PH0 - OSC_IN
|
Mcu.Pin3=PH0 - OSC_IN
|
||||||
Mcu.Pin4=PH1 - OSC_OUT
|
Mcu.Pin4=PH1 - OSC_OUT
|
||||||
@ -25,7 +26,7 @@ Mcu.Pin6=PA3
|
|||||||
Mcu.Pin7=PA5
|
Mcu.Pin7=PA5
|
||||||
Mcu.Pin8=PA13
|
Mcu.Pin8=PA13
|
||||||
Mcu.Pin9=PA14
|
Mcu.Pin9=PA14
|
||||||
Mcu.PinsNb=15
|
Mcu.PinsNb=16
|
||||||
Mcu.ThirdPartyNb=0
|
Mcu.ThirdPartyNb=0
|
||||||
Mcu.UserConstants=
|
Mcu.UserConstants=
|
||||||
Mcu.UserName=STM32F401RETx
|
Mcu.UserName=STM32F401RETx
|
||||||
@ -157,9 +158,10 @@ RCC.VCOInputFreq_Value=1000000
|
|||||||
RCC.VCOOutputFreq_Value=336000000
|
RCC.VCOOutputFreq_Value=336000000
|
||||||
RCC.VcooutputI2S=96000000
|
RCC.VcooutputI2S=96000000
|
||||||
RTC.Alarm=RTC_ALARM_A
|
RTC.Alarm=RTC_ALARM_A
|
||||||
|
RTC.Alarm_B=RTC_ALARM_B
|
||||||
RTC.Date=8
|
RTC.Date=8
|
||||||
RTC.Format=RTC_FORMAT_BIN
|
RTC.Format=RTC_FORMAT_BIN
|
||||||
RTC.IPParameters=Format,Date,Year,Alarm
|
RTC.IPParameters=Format,Date,Year,Alarm,Alarm_B
|
||||||
RTC.Year=21
|
RTC.Year=21
|
||||||
SH.GPXTI13.0=GPIO_EXTI13
|
SH.GPXTI13.0=GPIO_EXTI13
|
||||||
SH.GPXTI13.ConfNb=1
|
SH.GPXTI13.ConfNb=1
|
||||||
@ -169,10 +171,12 @@ VP_RTC_VS_RTC_Activate.Mode=RTC_Enabled
|
|||||||
VP_RTC_VS_RTC_Activate.Signal=RTC_VS_RTC_Activate
|
VP_RTC_VS_RTC_Activate.Signal=RTC_VS_RTC_Activate
|
||||||
VP_RTC_VS_RTC_Alarm_A_Intern.Mode=Alarm A
|
VP_RTC_VS_RTC_Alarm_A_Intern.Mode=Alarm A
|
||||||
VP_RTC_VS_RTC_Alarm_A_Intern.Signal=RTC_VS_RTC_Alarm_A_Intern
|
VP_RTC_VS_RTC_Alarm_A_Intern.Signal=RTC_VS_RTC_Alarm_A_Intern
|
||||||
|
VP_RTC_VS_RTC_Alarm_B_Intern.Mode=Alarm B
|
||||||
|
VP_RTC_VS_RTC_Alarm_B_Intern.Signal=RTC_VS_RTC_Alarm_B_Intern
|
||||||
VP_RTC_VS_RTC_Calendar.Mode=RTC_Calendar
|
VP_RTC_VS_RTC_Calendar.Mode=RTC_Calendar
|
||||||
VP_RTC_VS_RTC_Calendar.Signal=RTC_VS_RTC_Calendar
|
VP_RTC_VS_RTC_Calendar.Signal=RTC_VS_RTC_Calendar
|
||||||
VP_SYS_VS_Systick.Mode=SysTick
|
VP_SYS_VS_Systick.Mode=SysTick
|
||||||
VP_SYS_VS_Systick.Signal=SYS_VS_Systick
|
VP_SYS_VS_Systick.Signal=SYS_VS_Systick
|
||||||
board=NUCLEO-F401RE
|
board=NUCLEO-F401RE
|
||||||
boardIOC=true
|
boardIOC=true
|
||||||
isbadioc=true
|
isbadioc=false
|
||||||
|
Loading…
x
Reference in New Issue
Block a user