Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
qitas committed Oct 29, 2021
1 parent 13680d7 commit 90cbace
Show file tree
Hide file tree
Showing 7 changed files with 128 additions and 90 deletions.
4 changes: 2 additions & 2 deletions project/IAP/.mxproject

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion project/IAP/Core/Inc/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ extern "C" {

/* Includes ------------------------------------------------------------------*/
#include "stm32g0xx_hal.h"
#include "stm32g0xx_ll_iwdg.h"
#include "stm32g0xx_ll_rcc.h"
#include "stm32g0xx_ll_bus.h"
#include "stm32g0xx_ll_system.h"
Expand Down Expand Up @@ -78,7 +79,7 @@ void Error_Handler(void);
#define LED1_GPIO_Port GPIOB
/* USER CODE BEGIN Private defines */
// extern IWDG_HandleTypeDef hiwdg;
#define feed_dog() LL_mDelay(0) //LL_IWDG_ReloadCounter(IWDG) //HAL_IWDG_Refresh(&hiwdg) //
#define feed_dog() LL_IWDG_ReloadCounter(IWDG) //LL_mDelay(0) //HAL_IWDG_Refresh(&hiwdg) //
/* USER CODE END Private defines */

#ifdef __cplusplus
Expand Down
38 changes: 37 additions & 1 deletion project/IAP/Core/Src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_USART1_UART_Init(void);
static void MX_RTC_Init(void);
static void MX_IWDG_Init(void);
/* USER CODE BEGIN PFP */

/* USER CODE END PFP */
Expand Down Expand Up @@ -105,6 +106,7 @@ int main(void)
MX_GPIO_Init();
MX_USART1_UART_Init();
MX_RTC_Init();
MX_IWDG_Init();
/* USER CODE BEGIN 2 */
uart_init();
char buf[50];
Expand All @@ -120,6 +122,7 @@ int main(void)
sprintf((char *)buf, "BLT:%x-%x,%x-%x,%dk\r\n",IAP_Get(bkp_app1_addr),IAP_Get(bkp_app2_addr),IAP_Get(bkp_app1_mark),IAP_Get(bkp_app2_mark),fsize);
// HAL_UART_Transmit(&huart1,(uint8_t *)buf,strlen((char *)buf),100);
uart_tx_str((uint8_t *)buf,strlen((char *)buf));
feed_dog();
#endif
// FlashTestWR();
/* USER CODE END 2 */
Expand All @@ -131,15 +134,16 @@ int main(void)
/* USER CODE END WHILE */

/* USER CODE BEGIN 3 */
feed_dog();
rcnt++;
LL_mDelay(0);
feed_dog();
// HAL_Delay(2);
#ifdef BLT
bootloop();
// uart_tx_int(uwCRCValue);
if(rcnt%1000==0)
{
feed_dog();
memset((char *)buf,0,sizeof(buf));
sprintf((char *)buf, "\r\nBKP:%x,%x,%x,%x,%x\r\n",IAP_Get(bkp_app1_addr),IAP_Get(bkp_app2_addr),IAP_Get(bkp_app1_mark),IAP_Get(bkp_app2_mark),IAP_Get(bkp_boot_mark));
uart_tx_str((uint8_t *)buf,strlen((char *)buf));
Expand All @@ -149,6 +153,7 @@ int main(void)
#ifdef APP1
if(rcnt%1000==0)
{
feed_dog();
uart_tx_str("App1 Mark\r\n",15);
}
else if(rcnt>10000)
Expand All @@ -167,6 +172,7 @@ int main(void)
#ifdef APP2
if(rcnt%1000==0)
{
feed_dog();
// HAL_UART_Transmit(&huart1,"test app2\r\n",15,100);
uart_tx_str("app2 test\r\n",15);
}
Expand Down Expand Up @@ -248,6 +254,36 @@ void SystemClock_Config(void)
LL_RCC_SetUSARTClockSource(LL_RCC_USART1_CLKSOURCE_PCLK1);
}

/**
* @brief IWDG Initialization Function
* @param None
* @retval None
*/
static void MX_IWDG_Init(void)
{

/* USER CODE BEGIN IWDG_Init 0 */

/* USER CODE END IWDG_Init 0 */

/* USER CODE BEGIN IWDG_Init 1 */

/* USER CODE END IWDG_Init 1 */
LL_IWDG_Enable(IWDG);
LL_IWDG_EnableWriteAccess(IWDG);
LL_IWDG_SetPrescaler(IWDG, LL_IWDG_PRESCALER_4);
LL_IWDG_SetReloadCounter(IWDG, 4095);
while (LL_IWDG_IsReady(IWDG) != 1)
{
}

LL_IWDG_ReloadCounter(IWDG);
/* USER CODE BEGIN IWDG_Init 2 */

/* USER CODE END IWDG_Init 2 */

}

/**
* @brief RTC Initialization Function
* @param None
Expand Down
22 changes: 13 additions & 9 deletions project/IAP/IAP.ioc
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ File.Version=6
GPIO.groupedBy=Group By Peripherals
KeepUserPlacement=false
Mcu.Family=STM32G0
Mcu.IP0=NVIC
Mcu.IP1=RCC
Mcu.IP2=RTC
Mcu.IP3=SYS
Mcu.IP4=USART1
Mcu.IPNb=5
Mcu.IP0=IWDG
Mcu.IP1=NVIC
Mcu.IP2=RCC
Mcu.IP3=RTC
Mcu.IP4=SYS
Mcu.IP5=USART1
Mcu.IPNb=6
Mcu.Name=STM32G030C(6-8)Tx
Mcu.Package=LQFP48
Mcu.Pin0=PC13
Expand All @@ -17,9 +18,10 @@ Mcu.Pin2=PA10
Mcu.Pin3=PA13
Mcu.Pin4=PA14-BOOT0
Mcu.Pin5=PB4
Mcu.Pin6=VP_RTC_VS_RTC_Activate
Mcu.Pin7=VP_SYS_VS_Systick
Mcu.PinsNb=8
Mcu.Pin6=VP_IWDG_VS_IWDG
Mcu.Pin7=VP_RTC_VS_RTC_Activate
Mcu.Pin8=VP_SYS_VS_Systick
Mcu.PinsNb=9
Mcu.ThirdPartyNb=0
Mcu.UserConstants=
Mcu.UserName=STM32G030C8Tx
Expand Down Expand Up @@ -110,6 +112,8 @@ SH.GPXTI13.0=GPIO_EXTI13
SH.GPXTI13.ConfNb=1
USART1.IPParameters=VirtualMode-Asynchronous
USART1.VirtualMode-Asynchronous=VM_ASYNC
VP_IWDG_VS_IWDG.Mode=IWDG_Activate
VP_IWDG_VS_IWDG.Signal=IWDG_VS_IWDG
VP_RTC_VS_RTC_Activate.Mode=RTC_Enabled
VP_RTC_VS_RTC_Activate.Signal=RTC_VS_RTC_Activate
VP_SYS_VS_Systick.Mode=SysTick
Expand Down
50 changes: 25 additions & 25 deletions project/IAP/MDK-ARM/IAP.uvoptx
Original file line number Diff line number Diff line change
Expand Up @@ -764,26 +764,14 @@
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>../Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_ll_rtc.c</PathWithFileName>
<FilenameWithoutPath>stm32g0xx_ll_rtc.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>4</GroupNumber>
<FileNumber>13</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>../Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_ll_rcc.c</PathWithFileName>
<FilenameWithoutPath>stm32g0xx_ll_rcc.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>4</GroupNumber>
<FileNumber>14</FileNumber>
<FileNumber>13</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
Expand All @@ -795,7 +783,7 @@
</File>
<File>
<GroupNumber>4</GroupNumber>
<FileNumber>15</FileNumber>
<FileNumber>14</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
Expand All @@ -807,7 +795,7 @@
</File>
<File>
<GroupNumber>4</GroupNumber>
<FileNumber>16</FileNumber>
<FileNumber>15</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
Expand All @@ -819,7 +807,7 @@
</File>
<File>
<GroupNumber>4</GroupNumber>
<FileNumber>17</FileNumber>
<FileNumber>16</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
Expand All @@ -831,7 +819,7 @@
</File>
<File>
<GroupNumber>4</GroupNumber>
<FileNumber>18</FileNumber>
<FileNumber>17</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
Expand All @@ -843,7 +831,7 @@
</File>
<File>
<GroupNumber>4</GroupNumber>
<FileNumber>19</FileNumber>
<FileNumber>18</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
Expand All @@ -855,7 +843,7 @@
</File>
<File>
<GroupNumber>4</GroupNumber>
<FileNumber>20</FileNumber>
<FileNumber>19</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
Expand All @@ -867,7 +855,7 @@
</File>
<File>
<GroupNumber>4</GroupNumber>
<FileNumber>21</FileNumber>
<FileNumber>20</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
Expand All @@ -879,7 +867,7 @@
</File>
<File>
<GroupNumber>4</GroupNumber>
<FileNumber>22</FileNumber>
<FileNumber>21</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
Expand All @@ -891,7 +879,7 @@
</File>
<File>
<GroupNumber>4</GroupNumber>
<FileNumber>23</FileNumber>
<FileNumber>22</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
Expand All @@ -903,7 +891,7 @@
</File>
<File>
<GroupNumber>4</GroupNumber>
<FileNumber>24</FileNumber>
<FileNumber>23</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
Expand All @@ -915,7 +903,7 @@
</File>
<File>
<GroupNumber>4</GroupNumber>
<FileNumber>25</FileNumber>
<FileNumber>24</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
Expand All @@ -927,7 +915,7 @@
</File>
<File>
<GroupNumber>4</GroupNumber>
<FileNumber>26</FileNumber>
<FileNumber>25</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
Expand All @@ -937,6 +925,18 @@
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>4</GroupNumber>
<FileNumber>26</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>../Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_ll_rtc.c</PathWithFileName>
<FilenameWithoutPath>stm32g0xx_ll_rtc.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>4</GroupNumber>
<FileNumber>27</FileNumber>
Expand Down
Loading

0 comments on commit 90cbace

Please sign in to comment.