Skip to content

Commit

Permalink
Add WWDG when hardware fault.
Browse files Browse the repository at this point in the history
  • Loading branch information
Anol Paisal committed Jun 2, 2019
1 parent f444be4 commit b940a4a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
20 changes: 15 additions & 5 deletions src/boards/SKiM980A/encoder-board.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ Encoder_t Encoder;
flow_t flow;
flow_t last_flow;
flow_config_t config;
#ifndef USE_GPIO
static TIM_HandleTypeDef TimHandle;
#endif
extern Gpio_t Led3;

/*!
Expand Down Expand Up @@ -116,7 +118,9 @@ void EncoderInit( Encoder_t *obj, EncoderId_t timId, PinNames pulse, PinNames di

void EncoderDeInit( Encoder_t *obj )
{
HAL_TIM_Encoder_DeInit(&TimHandle);
#ifndef USE_GPIO
// HAL_TIM_Encoder_DeInit(&TimHandle);
#endif
}

void OnTamperingIrq( void* context )
Expand All @@ -132,14 +136,18 @@ void OnTamperingIrq( void* context )
} else {
flow.status &= ~TAMPER_FLAG;
printf( "\r\n###### ===== Tampering released ==== ######\r\n\r\n" );
#ifndef USE_GPIO
// HAL_TIM_Encoder_Stop_IT(&TimHandle, TIM_CHANNEL_1);
#endif

}
CRITICAL_SECTION_END();

if (Encoder.OnSendOneshot != NULL)
{
Encoder.OnSendOneshot( );
}

CRITICAL_SECTION_END();
}

void OnAlarmIrq( void* context )
Expand All @@ -153,11 +161,13 @@ void OnAlarmIrq( void* context )
flow.status &= ~ALARM_FLAG;
printf( "\r\n###### ===== Silent ==== ######\r\n\r\n" );
}
CRITICAL_SECTION_END();

if (Encoder.OnSendOneshot != NULL && config.digital_alarm > 0)
{
Encoder.OnSendOneshot( );
}

CRITICAL_SECTION_END();
}

#ifdef USE_GPIO
Expand All @@ -183,15 +193,15 @@ void OnPulseDetected( void* context )
Encoder.OnShowPulseDetect();
}

CRITICAL_SECTION_END();

if(Encoder.ConfigData->isActiveMode == 0) {
Encoder.ConfigData->isActiveMode = 1;
if (Encoder.OnSendOneshot != NULL)
{
Encoder.OnSendOneshot( );
}
}

CRITICAL_SECTION_END();
}

#else
Expand Down
2 changes: 1 addition & 1 deletion src/boards/SKiM980A/wdt-board.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,5 @@ void WWDG_IRQHandler(void)

void HAL_WWDG_EarlyWakeupCallback(WWDG_HandleTypeDef *hwwdg)
{

printf("***Hardware fault****\r\n");
}
6 changes: 6 additions & 0 deletions src/boards/mcu/stm32/sysIrqHandlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
* \author Gregory Cristian ( Semtech )
*/

#include "wdt.h"

/*!
* \brief This function handles NMI exception.
* \param None
Expand Down Expand Up @@ -68,6 +70,10 @@ void HardFault_Handler_C( unsigned int *args )
( void )stacked_pc ;
( void )stacked_psr;

// WWDG start
Wdt_t wwdt;
WdtInit( &wwdt, WDT_WWDG);

while( 1 );
}

Expand Down

0 comments on commit b940a4a

Please sign in to comment.