Remove DS3231
I made a mistake while initialising the internal RTC (with RC instead of external crystal) so it was super unprecise
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -10,14 +10,13 @@
|
||||
#include "debug.h"
|
||||
|
||||
extern RTC_HandleTypeDef hrtc;
|
||||
extern I2C_HandleTypeDef hi2c1;
|
||||
|
||||
void app_main(void *argument)
|
||||
{
|
||||
ts utc;
|
||||
ts rtc;
|
||||
//ts rtc;
|
||||
ts local;
|
||||
ts diff;
|
||||
//ts diff;
|
||||
RTC_TimeTypeDef sTime;
|
||||
RTC_DateTypeDef sDate;
|
||||
uint8_t sBefore;
|
||||
@@ -28,14 +27,11 @@ void app_main(void *argument)
|
||||
|
||||
debugln("LWIP is initialized");
|
||||
|
||||
DS3231_Init(&hi2c1);
|
||||
debugln("DS3231 is initialized");
|
||||
|
||||
// The stored time is always in UTC
|
||||
breakTime(NTPToEpochUnix(), &utc, 0);
|
||||
toTimeZone(&utc, &local, UTC_DELTA_HOURS, 1);
|
||||
debugln("Started: %02d:%02d:%02d", utc.Hour, utc.Minute, utc.Second);
|
||||
debugln(" \n \n \n"); // I don't know why, but my uart/Serial monitor doesn't show epoch and packet sent if I remove the spaces
|
||||
debugln(" \n"); // I don't know why, but my uart/Serial monitor doesn't show epoch and packet sent if I remove the spaces
|
||||
Ts_To_RTC(&utc, &sTime, &sDate);
|
||||
Set_Time(sTime, sDate);
|
||||
DS3231_SetTime(&utc);
|
||||
@@ -52,26 +48,26 @@ void app_main(void *argument)
|
||||
for (;;)
|
||||
{
|
||||
Get_Time(&sDate, &sTime);
|
||||
DS3231_GetTime(&utc);
|
||||
//DS3231_GetTime(&utc);
|
||||
if ((utc.Hour == 0) && (utc.Minute == 0) && (utc.Second == 0) && sBefore == 59)
|
||||
{
|
||||
debugln(" \nUpdating time");
|
||||
breakTime(NTPToEpochUnix(), &utc, 0);
|
||||
printf(" \n \n \n \n");
|
||||
printf(" \n");
|
||||
Ts_To_RTC(&utc, &sTime, &sDate);
|
||||
Set_Time(sTime, sDate);
|
||||
DS3231_SetTime(&utc);
|
||||
//DS3231_SetTime(&utc);
|
||||
}
|
||||
|
||||
RTC_To_Ts(&sTime, &sDate, &rtc);
|
||||
RTC_To_Ts(&sTime, &sDate, &utc);
|
||||
toTimeZone(&utc, &local, UTC_DELTA_HOURS, 1);
|
||||
if (local.Second != sBefore)
|
||||
{
|
||||
printf(CURSOR_PREV_N_LINES(3) ERASE_FROM_CURSOR_TO_END);
|
||||
debugln("RTC : %02d:%02d:%02d", sTime.Hours, sTime.Minutes, sTime.Seconds);
|
||||
printf(CURSOR_PREV_N_LINES(1) ERASE_FROM_CURSOR_TO_END);
|
||||
//debugln("RTC : %02d:%02d:%02d", sTime.Hours, sTime.Minutes, sTime.Seconds);
|
||||
debugln("DS3231: %02d:%02d:%02d", utc.Hour, utc.Minute, utc.Second);
|
||||
TimeDiff(&utc, &rtc, &diff);
|
||||
debugln("DIFF : %02d:%02d:%02d", diff.Hour, diff.Minute, diff.Second);
|
||||
//TimeDiff(&utc, &rtc, &diff);
|
||||
//debugln("DIFF : %02d:%02d:%02d", diff.Hour, diff.Minute, diff.Second);
|
||||
BSP_LCD_Clear(LCD_COLOR_TRANSPARENT);
|
||||
|
||||
Clock_Write_Date(0, 0, Y_CENTER, 40, local.Wday, local.Day, local.Month, local.Year + 1970);
|
||||
|
||||
@@ -45,8 +45,6 @@
|
||||
|
||||
DMA2D_HandleTypeDef hdma2d;
|
||||
|
||||
I2C_HandleTypeDef hi2c1;
|
||||
|
||||
LTDC_HandleTypeDef hltdc;
|
||||
|
||||
RTC_HandleTypeDef hrtc;
|
||||
@@ -68,7 +66,6 @@ static void MX_USART1_UART_Init(void);
|
||||
static void MX_DMA2D_Init(void);
|
||||
static void MX_FMC_Init(void);
|
||||
static void MX_RTC_Init(void);
|
||||
static void MX_I2C1_Init(void);
|
||||
void app_main(void const * argument);
|
||||
|
||||
/* USER CODE BEGIN PFP */
|
||||
@@ -113,7 +110,6 @@ int main(void)
|
||||
MX_DMA2D_Init();
|
||||
MX_FMC_Init();
|
||||
MX_RTC_Init();
|
||||
MX_I2C1_Init();
|
||||
/* USER CODE BEGIN 2 */
|
||||
ip_addr_t ip;
|
||||
/* set the default dns server for the NTP client*/
|
||||
@@ -285,54 +281,6 @@ static void MX_DMA2D_Init(void)
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief I2C1 Initialization Function
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
static void MX_I2C1_Init(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN I2C1_Init 0 */
|
||||
|
||||
/* USER CODE END I2C1_Init 0 */
|
||||
|
||||
/* USER CODE BEGIN I2C1_Init 1 */
|
||||
|
||||
/* USER CODE END I2C1_Init 1 */
|
||||
hi2c1.Instance = I2C1;
|
||||
hi2c1.Init.Timing = 0x00C0EAFF;
|
||||
hi2c1.Init.OwnAddress1 = 0;
|
||||
hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
|
||||
hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
|
||||
hi2c1.Init.OwnAddress2 = 0;
|
||||
hi2c1.Init.OwnAddress2Masks = I2C_OA2_NOMASK;
|
||||
hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
|
||||
hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
|
||||
if (HAL_I2C_Init(&hi2c1) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
/** Configure Analogue filter
|
||||
*/
|
||||
if (HAL_I2CEx_ConfigAnalogFilter(&hi2c1, I2C_ANALOGFILTER_ENABLE) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
/** Configure Digital filter
|
||||
*/
|
||||
if (HAL_I2CEx_ConfigDigitalFilter(&hi2c1, 0) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN I2C1_Init 2 */
|
||||
|
||||
/* USER CODE END I2C1_Init 2 */
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief LTDC Initialization Function
|
||||
* @param None
|
||||
|
||||
@@ -122,83 +122,6 @@ void HAL_DMA2D_MspDeInit(DMA2D_HandleTypeDef* hdma2d)
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief I2C MSP Initialization
|
||||
* This function configures the hardware resources used in this example
|
||||
* @param hi2c: I2C handle pointer
|
||||
* @retval None
|
||||
*/
|
||||
void HAL_I2C_MspInit(I2C_HandleTypeDef* hi2c)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};
|
||||
if(hi2c->Instance==I2C1)
|
||||
{
|
||||
/* USER CODE BEGIN I2C1_MspInit 0 */
|
||||
|
||||
/* USER CODE END I2C1_MspInit 0 */
|
||||
|
||||
/** Initializes the peripherals clock
|
||||
*/
|
||||
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_I2C1;
|
||||
PeriphClkInitStruct.I2c1ClockSelection = RCC_I2C1CLKSOURCE_PCLK1;
|
||||
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||
/**I2C1 GPIO Configuration
|
||||
PB8 ------> I2C1_SCL
|
||||
PB9 ------> I2C1_SDA
|
||||
*/
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
||||
GPIO_InitStruct.Alternate = GPIO_AF4_I2C1;
|
||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||
|
||||
/* Peripheral clock enable */
|
||||
__HAL_RCC_I2C1_CLK_ENABLE();
|
||||
/* USER CODE BEGIN I2C1_MspInit 1 */
|
||||
|
||||
/* USER CODE END I2C1_MspInit 1 */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief I2C MSP De-Initialization
|
||||
* This function freeze the hardware resources used in this example
|
||||
* @param hi2c: I2C handle pointer
|
||||
* @retval None
|
||||
*/
|
||||
void HAL_I2C_MspDeInit(I2C_HandleTypeDef* hi2c)
|
||||
{
|
||||
if(hi2c->Instance==I2C1)
|
||||
{
|
||||
/* USER CODE BEGIN I2C1_MspDeInit 0 */
|
||||
|
||||
/* USER CODE END I2C1_MspDeInit 0 */
|
||||
/* Peripheral clock disable */
|
||||
__HAL_RCC_I2C1_CLK_DISABLE();
|
||||
|
||||
/**I2C1 GPIO Configuration
|
||||
PB8 ------> I2C1_SCL
|
||||
PB9 ------> I2C1_SDA
|
||||
*/
|
||||
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_8);
|
||||
|
||||
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_9);
|
||||
|
||||
/* USER CODE BEGIN I2C1_MspDeInit 1 */
|
||||
|
||||
/* USER CODE END I2C1_MspDeInit 1 */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief LTDC MSP Initialization
|
||||
* This function configures the hardware resources used in this example
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
201
NTP/NTP.ioc
201
NTP/NTP.ioc
@@ -12,8 +12,6 @@ FREERTOS.configTOTAL_HEAP_SIZE=15360
|
||||
FREERTOS.configUSE_NEWLIB_REENTRANT=1
|
||||
File.Version=6
|
||||
GPIO.groupedBy=Group By Peripherals
|
||||
I2C1.IPParameters=Timing
|
||||
I2C1.Timing=0x00C0EAFF
|
||||
KeepUserPlacement=true
|
||||
LTDC.ActiveH=272
|
||||
LTDC.ActiveW=480
|
||||
@@ -57,113 +55,110 @@ Mcu.CPN=STM32F746NGH6
|
||||
Mcu.Family=STM32F7
|
||||
Mcu.IP0=CORTEX_M7
|
||||
Mcu.IP1=DMA2D
|
||||
Mcu.IP10=RTC
|
||||
Mcu.IP11=SYS
|
||||
Mcu.IP12=USART1
|
||||
Mcu.IP10=SYS
|
||||
Mcu.IP11=USART1
|
||||
Mcu.IP2=ETH
|
||||
Mcu.IP3=FMC
|
||||
Mcu.IP4=FREERTOS
|
||||
Mcu.IP5=I2C1
|
||||
Mcu.IP6=LTDC
|
||||
Mcu.IP7=LWIP
|
||||
Mcu.IP8=NVIC
|
||||
Mcu.IP9=RCC
|
||||
Mcu.IPNb=13
|
||||
Mcu.IP5=LTDC
|
||||
Mcu.IP6=LWIP
|
||||
Mcu.IP7=NVIC
|
||||
Mcu.IP8=RCC
|
||||
Mcu.IP9=RTC
|
||||
Mcu.IPNb=12
|
||||
Mcu.Name=STM32F746NGHx
|
||||
Mcu.Package=TFBGA216
|
||||
Mcu.Pin0=PE4
|
||||
Mcu.Pin1=PG14
|
||||
Mcu.Pin10=PJ13
|
||||
Mcu.Pin11=PD0
|
||||
Mcu.Pin12=PK7
|
||||
Mcu.Pin13=PK6
|
||||
Mcu.Pin14=PK5
|
||||
Mcu.Pin15=PG12
|
||||
Mcu.Pin16=PJ14
|
||||
Mcu.Pin17=PD1
|
||||
Mcu.Pin18=PF0
|
||||
Mcu.Pin19=PI10
|
||||
Mcu.Pin10=PK7
|
||||
Mcu.Pin11=PK6
|
||||
Mcu.Pin12=PK5
|
||||
Mcu.Pin13=PG12
|
||||
Mcu.Pin14=PJ14
|
||||
Mcu.Pin15=PD1
|
||||
Mcu.Pin16=PF0
|
||||
Mcu.Pin17=PI10
|
||||
Mcu.Pin18=PK4
|
||||
Mcu.Pin19=PK3
|
||||
Mcu.Pin2=PE1
|
||||
Mcu.Pin20=PK4
|
||||
Mcu.Pin21=PK3
|
||||
Mcu.Pin22=PJ15
|
||||
Mcu.Pin23=PI1
|
||||
Mcu.Pin24=PC14/OSC32_IN
|
||||
Mcu.Pin25=PF1
|
||||
Mcu.Pin26=PI12
|
||||
Mcu.Pin27=PI9
|
||||
Mcu.Pin28=PA9
|
||||
Mcu.Pin29=PC15/OSC32_OUT
|
||||
Mcu.Pin20=PJ15
|
||||
Mcu.Pin21=PI1
|
||||
Mcu.Pin22=PC14/OSC32_IN
|
||||
Mcu.Pin23=PF1
|
||||
Mcu.Pin24=PI12
|
||||
Mcu.Pin25=PI9
|
||||
Mcu.Pin26=PA9
|
||||
Mcu.Pin27=PC15/OSC32_OUT
|
||||
Mcu.Pin28=PI11
|
||||
Mcu.Pin29=PK1
|
||||
Mcu.Pin3=PE0
|
||||
Mcu.Pin30=PI11
|
||||
Mcu.Pin31=PK1
|
||||
Mcu.Pin32=PK2
|
||||
Mcu.Pin33=PH0/OSC_IN
|
||||
Mcu.Pin34=PF2
|
||||
Mcu.Pin35=PI15
|
||||
Mcu.Pin36=PJ11
|
||||
Mcu.Pin37=PK0
|
||||
Mcu.Pin38=PH1/OSC_OUT
|
||||
Mcu.Pin39=PF3
|
||||
Mcu.Pin4=PB8
|
||||
Mcu.Pin40=PI14
|
||||
Mcu.Pin41=PJ8
|
||||
Mcu.Pin42=PJ10
|
||||
Mcu.Pin43=PG8
|
||||
Mcu.Pin44=PF4
|
||||
Mcu.Pin45=PH5
|
||||
Mcu.Pin46=PH3
|
||||
Mcu.Pin47=PJ7
|
||||
Mcu.Pin48=PJ9
|
||||
Mcu.Pin49=PF5
|
||||
Mcu.Pin5=PG13
|
||||
Mcu.Pin50=PH2
|
||||
Mcu.Pin51=PJ6
|
||||
Mcu.Pin52=PD15
|
||||
Mcu.Pin53=PD10
|
||||
Mcu.Pin54=PD14
|
||||
Mcu.Pin55=PD9
|
||||
Mcu.Pin56=PD8
|
||||
Mcu.Pin57=PC1
|
||||
Mcu.Pin58=PF12
|
||||
Mcu.Pin59=PG1
|
||||
Mcu.Pin6=PB9
|
||||
Mcu.Pin60=PF15
|
||||
Mcu.Pin61=PJ4
|
||||
Mcu.Pin62=PJ5
|
||||
Mcu.Pin63=PA1
|
||||
Mcu.Pin64=PC4
|
||||
Mcu.Pin65=PF13
|
||||
Mcu.Pin66=PG0
|
||||
Mcu.Pin67=PJ3
|
||||
Mcu.Pin68=PE8
|
||||
Mcu.Pin69=PG5
|
||||
Mcu.Pin7=PB7
|
||||
Mcu.Pin70=PG4
|
||||
Mcu.Pin71=PA2
|
||||
Mcu.Pin72=PC5
|
||||
Mcu.Pin73=PF14
|
||||
Mcu.Pin74=PJ2
|
||||
Mcu.Pin75=PF11
|
||||
Mcu.Pin76=PE9
|
||||
Mcu.Pin77=PE11
|
||||
Mcu.Pin78=PE14
|
||||
Mcu.Pin79=PA7
|
||||
Mcu.Pin8=PG15
|
||||
Mcu.Pin80=PJ0
|
||||
Mcu.Pin81=PJ1
|
||||
Mcu.Pin82=PE7
|
||||
Mcu.Pin83=PE10
|
||||
Mcu.Pin84=PE12
|
||||
Mcu.Pin85=PE15
|
||||
Mcu.Pin86=PE13
|
||||
Mcu.Pin87=VP_DMA2D_VS_DMA2D
|
||||
Mcu.Pin88=VP_FREERTOS_VS_CMSIS_V1
|
||||
Mcu.Pin89=VP_LWIP_VS_Enabled
|
||||
Mcu.Pin9=PG11
|
||||
Mcu.Pin90=VP_RTC_VS_RTC_Activate
|
||||
Mcu.Pin91=VP_SYS_VS_tim1
|
||||
Mcu.PinsNb=92
|
||||
Mcu.Pin30=PK2
|
||||
Mcu.Pin31=PH0/OSC_IN
|
||||
Mcu.Pin32=PF2
|
||||
Mcu.Pin33=PI15
|
||||
Mcu.Pin34=PJ11
|
||||
Mcu.Pin35=PK0
|
||||
Mcu.Pin36=PH1/OSC_OUT
|
||||
Mcu.Pin37=PF3
|
||||
Mcu.Pin38=PI14
|
||||
Mcu.Pin39=PJ8
|
||||
Mcu.Pin4=PG13
|
||||
Mcu.Pin40=PJ10
|
||||
Mcu.Pin41=PG8
|
||||
Mcu.Pin42=PF4
|
||||
Mcu.Pin43=PH5
|
||||
Mcu.Pin44=PH3
|
||||
Mcu.Pin45=PJ7
|
||||
Mcu.Pin46=PJ9
|
||||
Mcu.Pin47=PF5
|
||||
Mcu.Pin48=PH2
|
||||
Mcu.Pin49=PJ6
|
||||
Mcu.Pin5=PB7
|
||||
Mcu.Pin50=PD15
|
||||
Mcu.Pin51=PD10
|
||||
Mcu.Pin52=PD14
|
||||
Mcu.Pin53=PD9
|
||||
Mcu.Pin54=PD8
|
||||
Mcu.Pin55=PC1
|
||||
Mcu.Pin56=PF12
|
||||
Mcu.Pin57=PG1
|
||||
Mcu.Pin58=PF15
|
||||
Mcu.Pin59=PJ4
|
||||
Mcu.Pin6=PG15
|
||||
Mcu.Pin60=PJ5
|
||||
Mcu.Pin61=PA1
|
||||
Mcu.Pin62=PC4
|
||||
Mcu.Pin63=PF13
|
||||
Mcu.Pin64=PG0
|
||||
Mcu.Pin65=PJ3
|
||||
Mcu.Pin66=PE8
|
||||
Mcu.Pin67=PG5
|
||||
Mcu.Pin68=PG4
|
||||
Mcu.Pin69=PA2
|
||||
Mcu.Pin7=PG11
|
||||
Mcu.Pin70=PC5
|
||||
Mcu.Pin71=PF14
|
||||
Mcu.Pin72=PJ2
|
||||
Mcu.Pin73=PF11
|
||||
Mcu.Pin74=PE9
|
||||
Mcu.Pin75=PE11
|
||||
Mcu.Pin76=PE14
|
||||
Mcu.Pin77=PA7
|
||||
Mcu.Pin78=PJ0
|
||||
Mcu.Pin79=PJ1
|
||||
Mcu.Pin8=PJ13
|
||||
Mcu.Pin80=PE7
|
||||
Mcu.Pin81=PE10
|
||||
Mcu.Pin82=PE12
|
||||
Mcu.Pin83=PE15
|
||||
Mcu.Pin84=PE13
|
||||
Mcu.Pin85=VP_DMA2D_VS_DMA2D
|
||||
Mcu.Pin86=VP_FREERTOS_VS_CMSIS_V1
|
||||
Mcu.Pin87=VP_LWIP_VS_Enabled
|
||||
Mcu.Pin88=VP_RTC_VS_RTC_Activate
|
||||
Mcu.Pin89=VP_SYS_VS_tim1
|
||||
Mcu.Pin9=PD0
|
||||
Mcu.PinsNb=90
|
||||
Mcu.ThirdPartyNb=0
|
||||
Mcu.UserConstants=
|
||||
Mcu.UserName=STM32F746NGHx
|
||||
@@ -198,12 +193,6 @@ PA9.Mode=Asynchronous
|
||||
PA9.Signal=USART1_TX
|
||||
PB7.Mode=Asynchronous
|
||||
PB7.Signal=USART1_RX
|
||||
PB8.Locked=true
|
||||
PB8.Mode=I2C
|
||||
PB8.Signal=I2C1_SCL
|
||||
PB9.Locked=true
|
||||
PB9.Mode=I2C
|
||||
PB9.Signal=I2C1_SDA
|
||||
PC1.Mode=RMII
|
||||
PC1.Signal=ETH_MDC
|
||||
PC14/OSC32_IN.Mode=LSE-External-Oscillator
|
||||
|
||||
Reference in New Issue
Block a user