Ejemplo n.º 1
0
//*****************************************************************************
//
// This function initializes the state of the button handler and prepares it
// to debounce the state of the button.  If the button is initially pressed,
// the state of the motor controller is reverted to the factory settings.
//
//*****************************************************************************
void
ButtonInit(void)
{
    //
    // Set the GPIO as an input and enable the weak pull up.  When pressed, the
    // button is read as 0.
    //
    ROM_GPIODirModeSet(BUTTON_PORT, BUTTON_PIN, GPIO_DIR_MODE_IN);
    ROM_GPIOPadConfigSet(BUTTON_PORT, BUTTON_PIN,
                         GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);

    //
    // Delay for a bit before sampling the reset state of the button.
    //
    SysCtlDelay(1000);

    //
    // Read the current state of the button and consider it to be the debounced
    // state.
    //
    g_ulDebouncedState = ROM_GPIOPinRead(BUTTON_PORT, BUTTON_PIN);

    //
    // Reset the debounce and hold counters.
    //
    g_ulDebounceCount = BUTTON_DEBOUNCE_COUNT;
    g_ulHoldCount = 0;

    //
    // See if the button was initially pressed.
    //
    if(g_ulDebouncedState == BUTTON_DOWN)
    {
        //
        // Reset the parameters to the default values.
        //
        ParamLoadDefault();

        //
        // Save the default parameters.
        //
        ParamSave();

        //
        // Indicate that the configuration was just reset to the default
        // settings.
        //
        LEDParameterReset();

        //
        // Set the hold count such that the power-on hold of the push button
        // will not cause the servo calibration process to start.
        //
        g_ulHoldCount = BUTTON_HOLD_COUNT;
    }
}
Ejemplo n.º 2
0
//*****************************************************************************
//
// This function initializes the parameter block.  If there is a parameter
// block stored in flash, then those values will be used.  Otherwise, the
// default parameter values will be used.
//
//*****************************************************************************
void
ParamInit(void)
{
    //
    // Initialize the flash parameter block driver.
    //
    FlashPBInit(FLASH_PB_START, FLASH_PB_END, FLASH_PB_SIZE);

    //
    // First, load the parameter block with the default values.
    //
    ParamLoadDefault();

    //
    // Then, if available, load the latest non-volatile set of values.
    //
    ParamLoad();
}