SAM3S8/SD8 Software Package: libraries/sam-gui/source/wgt/frontends/frontend_pushbuttons.c Source File

SAM3S8/SD8 Software Package 1.2

# frontend_pushbuttons.c

    00001 /* ----------------------------------------------------------------------------
    00002  *         ATMEL Microcontroller Software Support
    00003  * ----------------------------------------------------------------------------
    00004  * Copyright (c) 2009, Atmel Corporation
    00005  *
    00006  * All rights reserved.
    00007  *
    00008  * Redistribution and use in source and binary forms, with or without
    00009  * modification, are permitted provided that the following conditions are met:
    00010  *
    00011  * - Redistributions of source code must retain the above copyright notice,
    00012  * this list of conditions and the disclaimer below.
    00013  *
    00014  * Atmel's name may not be used to endorse or promote products derived from
    00015  * this software without specific prior written permission.
    00016  *
    00017  * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
    00018  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
    00019  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
    00020  * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
    00021  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    00022  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
    00023  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
    00024  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
    00025  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
    00026  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    00027  * ----------------------------------------------------------------------------
    00028  */
    00029
    00030 #include "libsam_gui.h"
    00031
    00032 /**
    00033  * \addtogroup SAMGUI_WGT_CORE_FRONTEND WGT Core Frontend
    00034  * @{
    00035  *   \addtogroup SAMGUI_WGT_frontend_Pushbuttons SAM-GUI WGT Pushbuttons Frontend
    00036  *   @{
    00037  */
    00038
    00039 /** VBus pin instance. */
    00040 static const Pin _gPinButton1 = PIN_PUSHBUTTON_1 ;
    00041 static const Pin _gPinButton2 = PIN_PUSHBUTTON_2 ;
    00042
    00043 /**
    00044  * \brief Handles Button2 interrupt.
    00045  */
    00046 static void _WFE_PushButtons_IRQHandler( const Pin* pPin )
    00047 {
    00048     uint32_t dwKey ;
    00049
    00050     if ( pPin == &_gPinButton1 )
    00051     {
    00052         dwKey=WGT_KEY_PB1 ;
    00053     }
    00054     else
    00055     {
    00056         if ( pPin == &_gPinButton2 )
    00057         {
    00058             dwKey=WGT_KEY_PB2 ;
    00059         }
    00060         else
    00061         {
    00062             return ;
    00063         }
    00064     }
    00065
    00066     if ( PIO_Get( pPin ) )
    00067     {
    00068         WGT_SendMessageISR( WGT_MSG_KEY_RELEASED, dwKey, 0 ) ;
    00069     }
    00070     else
    00071     {
    00072         WGT_SendMessageISR( WGT_MSG_KEY_PRESSED, dwKey, 0 ) ;
    00073     }
    00074 }
    00075
    00076 static uint32_t _WFE_PushButtons_Initialize( void )
    00077 {
    00078     /* Configure PIO */
    00079     PIO_Configure( &_gPinButton1, 1 ) ;
    00080     PIO_Configure( &_gPinButton2, 1 ) ;
    00081
    00082     PIO_ConfigureIt( &_gPinButton1, _WFE_PushButtons_IRQHandler ) ;
    00083     PIO_ConfigureIt( &_gPinButton2, _WFE_PushButtons_IRQHandler ) ;
    00084
    00085     /* Enable PIO interrupt */
    00086     PIO_EnableIt( &_gPinButton1 ) ;
    00087     PIO_EnableIt( &_gPinButton2 ) ;
    00088
    00089     return SAMGUI_E_OK ;
    00090 }
    00091
    00092 static uint32_t _WFE_PushButtons_IOCtl( uint32_t dwCommand, uint32_t* pdwValue, uint32_t* pdwValueLength )
    00093 {
    00094     return SAMGUI_E_OK ;
    00095 }
    00096
    00097 const SWGTFrontend sWGT_Frontend_PushButtons=
    00098 {
    00099     .sData={ .dwId=WGT_FRONTEND_PUSHBUTTONS },
    00100
    00101     .Initialize=_WFE_PushButtons_Initialize,
    00102
    00103     .IOCtl=_WFE_PushButtons_IOCtl
    00104 } ;
    00105
    00106 /**
    00107  *   @}
    00108  * @}
    00109  */

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines