Andrew Boyson / lpc1768

Dependents:   test-lpc1768 oldheating gps motorhome ... more

reset/reset.c

Committer:
andrewboyson
Date:
2019-05-08
Revision:
49:d056e2c5c4ee
Child:
50:e90c6aaa2645

File content as of revision 49:d056e2c5c4ee:

#include <stdio.h>
#include <string.h>

#include "rsid.h"
#include "restart.h"
#include "watchdog.h"
#include "led.h"
#include "mstimer.h"

bool ResetAccepted = false;

bool ResetWasPushButton()
{
    return RsidExtr && RestartGetLastCause() == RESTART_CAUSE_RESET_BUTTON;
}

void ResetInit()
{
        RsidInit();
     RestartInit();
    WatchdogInit();
}
void ResetMain()
{
    //Feed the watchdog
    WatchdogMain();
    
    //Flash an led
    bool doFlash = true;
    if (ResetAccepted) doFlash = false;
    if (RsidExtr)
    {
        if (RestartGetLastCause() == RESTART_CAUSE_RESET_BUTTON  ) doFlash = false;
        if (RestartGetLastCause() == RESTART_CAUSE_SOFTWARE_RESET) doFlash = false;
    }
    static uint32_t ledFlashTimer = 0;
    if (doFlash)
    {
        if (MsTimerRepetitive(&ledFlashTimer, 100)) Led4Tgl();
    }
    else
    {
        Led4Set(false);
    }
}