Browse Source

patch up differences between ST RTC and time.h time representations

time.h uses 0-based weeks (Sunday=0) and months byt ST is 1-based
(Monday=1)
master
Daniel Peter Chokola 2 years ago
parent
commit
0969a84246
  1. 48
      .mxproject
  2. 2
      Core/Inc/main.h
  3. 2
      Core/Inc/stm32f4xx_hal_conf.h
  4. 1
      Core/Inc/stm32f4xx_it.h
  5. 2
      Core/Src/gpio.c
  6. 18
      Core/Src/main.c
  7. 15
      Core/Src/stm32f4xx_it.c
  8. 91
      hothouse-mon.ioc

48
.mxproject

File diff suppressed because one or more lines are too long

2
Core/Inc/main.h

@ -59,6 +59,8 @@ void Error_Handler(void); @@ -59,6 +59,8 @@ void Error_Handler(void);
/* Private defines -----------------------------------------------------------*/
#define BME280_PWR_Pin GPIO_PIN_13
#define BME280_PWR_GPIO_Port GPIOC
#define SOIL_Pin GPIO_PIN_0
#define SOIL_GPIO_Port GPIOA
#define SPI2_CS_Pin GPIO_PIN_12
#define SPI2_CS_GPIO_Port GPIOB
#define SPI1_CS_Pin GPIO_PIN_15

2
Core/Inc/stm32f4xx_hal_conf.h

@ -38,7 +38,7 @@ @@ -38,7 +38,7 @@
#define HAL_MODULE_ENABLED
/* #define HAL_CRYP_MODULE_ENABLED */
/* #define HAL_ADC_MODULE_ENABLED */
#define HAL_ADC_MODULE_ENABLED
/* #define HAL_CAN_MODULE_ENABLED */
/* #define HAL_CRC_MODULE_ENABLED */
/* #define HAL_CAN_LEGACY_MODULE_ENABLED */

1
Core/Inc/stm32f4xx_it.h

@ -55,6 +55,7 @@ void SVC_Handler(void); @@ -55,6 +55,7 @@ void SVC_Handler(void);
void DebugMon_Handler(void);
void PendSV_Handler(void);
void SysTick_Handler(void);
void DMA2_Stream0_IRQHandler(void);
void OTG_FS_IRQHandler(void);
/* USER CODE BEGIN EFP */

2
Core/Src/gpio.c

@ -47,8 +47,8 @@ void MX_GPIO_Init(void) @@ -47,8 +47,8 @@ void MX_GPIO_Init(void)
/* GPIO Ports Clock Enable */
__HAL_RCC_GPIOC_CLK_ENABLE();
__HAL_RCC_GPIOH_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(BME280_PWR_GPIO_Port, BME280_PWR_Pin, GPIO_PIN_RESET);

18
Core/Src/main.c

@ -116,15 +116,15 @@ int main(void) @@ -116,15 +116,15 @@ int main(void)
{
HAL_RTC_GetTime(&hrtc, &time, RTC_FORMAT_BIN);
HAL_RTC_GetDate(&hrtc, &date, RTC_FORMAT_BIN);
t.tm_sec = time.Seconds; /* Seconds [0, 60] */
t.tm_min = time.Minutes; /* Minutes [0, 59] */
t.tm_hour = time.Hours; /* Hour [0, 23] */
t.tm_mday = date.Date; /* Day of the month [1, 31] */
t.tm_mon = date.Month; /* Month [0, 11] (January = 0) */
t.tm_year = date.Year + 100; /* Year minus 1900 */
t.tm_wday = date.WeekDay; /* Day of the week [0, 6] (Sunday = 0) */
t.tm_yday = 0; /* Day of the year [0, 365] (Jan/01 = 0) */
t.tm_isdst = 0; /* Daylight savings flag */
t.tm_sec = time.Seconds; /* Seconds [0, 60] */
t.tm_min = time.Minutes; /* Minutes [0, 59] */
t.tm_hour = time.Hours; /* Hour [0, 23] */
t.tm_mday = date.Date; /* Day of the month [1, 31] */
t.tm_mon = date.Month - RTC_MONTH_JANUARY; /* Month [0, 11] (January = 0) */
t.tm_year = date.Year + 100; /* Year minus 1900 */
t.tm_wday = 0; /* Day of the week [0, 6] (Sunday = 0) */
t.tm_yday = 0; /* Day of the year [0, 365] (Jan/01 = 0) */
t.tm_isdst = 0; /* Daylight savings flag */
strftime(timebuf, 256, "%Y-%m-%d %H:%M:%S", &t);
len = snprintf((char *) buf, 200, "%s T: %.2f\xc2\xb0""C, P: %.2f hPa, RH: %.2f%%\r\n",
timebuf,

15
Core/Src/stm32f4xx_it.c

@ -56,6 +56,7 @@ @@ -56,6 +56,7 @@
/* External variables --------------------------------------------------------*/
extern PCD_HandleTypeDef hpcd_USB_OTG_FS;
extern DMA_HandleTypeDef hdma_adc1;
/* USER CODE BEGIN EV */
/* USER CODE END EV */
@ -198,6 +199,20 @@ void SysTick_Handler(void) @@ -198,6 +199,20 @@ void SysTick_Handler(void)
/* please refer to the startup file (startup_stm32f4xx.s). */
/******************************************************************************/
/**
* @brief This function handles DMA2 stream0 global interrupt.
*/
void DMA2_Stream0_IRQHandler(void)
{
/* USER CODE BEGIN DMA2_Stream0_IRQn 0 */
/* USER CODE END DMA2_Stream0_IRQn 0 */
HAL_DMA_IRQHandler(&hdma_adc1);
/* USER CODE BEGIN DMA2_Stream0_IRQn 1 */
/* USER CODE END DMA2_Stream0_IRQn 1 */
}
/**
* @brief This function handles USB On The Go FS global interrupt.
*/

91
hothouse-mon.ioc

@ -1,50 +1,77 @@ @@ -1,50 +1,77 @@
#MicroXplorer Configuration settings - do not modify
ADC1.Channel-0\#ChannelRegularConversion=ADC_CHANNEL_0
ADC1.ContinuousConvMode=ENABLE
ADC1.DMAContinuousRequests=ENABLE
ADC1.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,NbrOfConversionFlag,master,DMAContinuousRequests,ContinuousConvMode,ScanConvMode
ADC1.NbrOfConversionFlag=1
ADC1.Rank-0\#ChannelRegularConversion=1
ADC1.SamplingTime-0\#ChannelRegularConversion=ADC_SAMPLETIME_3CYCLES
ADC1.ScanConvMode=ENABLE
ADC1.master=1
CAD.formats=
CAD.pinconfig=
CAD.provider=
Dma.ADC1.0.Direction=DMA_PERIPH_TO_MEMORY
Dma.ADC1.0.FIFOMode=DMA_FIFOMODE_DISABLE
Dma.ADC1.0.Instance=DMA2_Stream0
Dma.ADC1.0.MemDataAlignment=DMA_MDATAALIGN_HALFWORD
Dma.ADC1.0.MemInc=DMA_MINC_ENABLE
Dma.ADC1.0.Mode=DMA_NORMAL
Dma.ADC1.0.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD
Dma.ADC1.0.PeriphInc=DMA_PINC_DISABLE
Dma.ADC1.0.Priority=DMA_PRIORITY_LOW
Dma.ADC1.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode
Dma.Request0=ADC1
Dma.RequestsNb=1
File.Version=6
KeepUserPlacement=false
Mcu.CPN=STM32F401CCU6
Mcu.Family=STM32F4
Mcu.IP0=NVIC
Mcu.IP1=RCC
Mcu.IP2=RTC
Mcu.IP3=SPI1
Mcu.IP4=SPI2
Mcu.IP5=SYS
Mcu.IP6=USB_DEVICE
Mcu.IP7=USB_OTG_FS
Mcu.IPNb=8
Mcu.IP0=ADC1
Mcu.IP1=DMA
Mcu.IP2=NVIC
Mcu.IP3=RCC
Mcu.IP4=RTC
Mcu.IP5=SPI1
Mcu.IP6=SPI2
Mcu.IP7=SYS
Mcu.IP8=USB_DEVICE
Mcu.IP9=USB_OTG_FS
Mcu.IPNb=10
Mcu.Name=STM32F401C(B-C)Ux
Mcu.Package=UFQFPN48
Mcu.Pin0=PC13-ANTI_TAMP
Mcu.Pin1=PC14-OSC32_IN
Mcu.Pin10=PA12
Mcu.Pin11=PA13
Mcu.Pin12=PA14
Mcu.Pin13=PA15
Mcu.Pin14=PB3
Mcu.Pin15=PB4
Mcu.Pin16=PB5
Mcu.Pin17=VP_RTC_VS_RTC_Activate
Mcu.Pin18=VP_RTC_VS_RTC_Calendar
Mcu.Pin19=VP_SYS_VS_Systick
Mcu.Pin10=PA11
Mcu.Pin11=PA12
Mcu.Pin12=PA13
Mcu.Pin13=PA14
Mcu.Pin14=PA15
Mcu.Pin15=PB3
Mcu.Pin16=PB4
Mcu.Pin17=PB5
Mcu.Pin18=VP_ADC1_Vref_Input
Mcu.Pin19=VP_ADC1_Vbat_Input
Mcu.Pin2=PC15-OSC32_OUT
Mcu.Pin20=VP_USB_DEVICE_VS_USB_DEVICE_CDC_FS
Mcu.Pin20=VP_RTC_VS_RTC_Activate
Mcu.Pin21=VP_RTC_VS_RTC_Calendar
Mcu.Pin22=VP_SYS_VS_Systick
Mcu.Pin23=VP_USB_DEVICE_VS_USB_DEVICE_CDC_FS
Mcu.Pin3=PH0 - OSC_IN
Mcu.Pin4=PH1 - OSC_OUT
Mcu.Pin5=PB12
Mcu.Pin6=PB13
Mcu.Pin7=PB14
Mcu.Pin8=PB15
Mcu.Pin9=PA11
Mcu.PinsNb=21
Mcu.Pin5=PA0-WKUP
Mcu.Pin6=PB12
Mcu.Pin7=PB13
Mcu.Pin8=PB14
Mcu.Pin9=PB15
Mcu.PinsNb=24
Mcu.ThirdPartyNb=0
Mcu.UserConstants=
Mcu.UserName=STM32F401CCUx
MxCube.Version=6.7.0
MxDb.Version=DB.6.0.70
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.DMA2_Stream0_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:true
NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.ForceEnableDMAVector=true
NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
@ -56,6 +83,10 @@ NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 @@ -56,6 +83,10 @@ NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4
NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:false\:true\:false
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
PA0-WKUP.GPIOParameters=GPIO_Label
PA0-WKUP.GPIO_Label=SOIL
PA0-WKUP.Locked=true
PA0-WKUP.Signal=ADCx_IN0
PA11.Mode=Device_Only
PA11.Signal=USB_OTG_FS_DM
PA12.Mode=Device_Only
@ -131,7 +162,7 @@ ProjectManager.StackSize=0x400 @@ -131,7 +162,7 @@ ProjectManager.StackSize=0x400
ProjectManager.TargetToolchain=STM32CubeIDE
ProjectManager.ToolChainLocation=
ProjectManager.UnderRoot=true
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_SPI2_Init-SPI2-false-HAL-true,4-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false,5-MX_SPI1_Init-SPI1-false-HAL-true,6-MX_RTC_Init-RTC-false-HAL-true
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_DMA_Init-DMA-false-HAL-true,4-MX_SPI2_Init-SPI2-false-HAL-true,5-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false,6-MX_SPI1_Init-SPI1-false-HAL-true,7-MX_RTC_Init-RTC-false-HAL-true,8-MX_ADC1_Init-ADC1-false-HAL-true
RCC.48MHZClocksFreq_Value=48000000
RCC.AHBFreq_Value=72000000
RCC.APB1CLKDivider=RCC_HCLK_DIV2
@ -171,6 +202,8 @@ RTC.Minutes=0 @@ -171,6 +202,8 @@ RTC.Minutes=0
RTC.Month=RTC_MONTH_JANUARY
RTC.WeekDay=RTC_WEEKDAY_MONDAY
RTC.Year=0
SH.ADCx_IN0.0=ADC1_IN0,IN0
SH.ADCx_IN0.ConfNb=1
SPI1.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_8
SPI1.CalculateBaudRate=9.0 MBits/s
SPI1.Direction=SPI_DIRECTION_2LINES
@ -189,6 +222,10 @@ USB_DEVICE.VirtualMode=Cdc @@ -189,6 +222,10 @@ USB_DEVICE.VirtualMode=Cdc
USB_DEVICE.VirtualModeFS=Cdc_FS
USB_OTG_FS.IPParameters=VirtualMode
USB_OTG_FS.VirtualMode=Device_Only
VP_ADC1_Vbat_Input.Mode=IN-Vbat
VP_ADC1_Vbat_Input.Signal=ADC1_Vbat_Input
VP_ADC1_Vref_Input.Mode=IN-Vrefint
VP_ADC1_Vref_Input.Signal=ADC1_Vref_Input
VP_RTC_VS_RTC_Activate.Mode=RTC_Enabled
VP_RTC_VS_RTC_Activate.Signal=RTC_VS_RTC_Activate
VP_RTC_VS_RTC_Calendar.Mode=RTC_Calendar

Loading…
Cancel
Save