00001 /*This file has been prepared for Doxygen automatic documentation generation.*/ 00015 /* Copyright (c) 2009 Atmel Corporation. All rights reserved. 00016 * 00017 * Redistribution and use in source and binary forms, with or without 00018 * modification, are permitted provided that the following conditions are met: 00019 * 00020 * 1. Redistributions of source code must retain the above copyright notice, this 00021 * list of conditions and the following disclaimer. 00022 * 00023 * 2. Redistributions in binary form must reproduce the above copyright notice, 00024 * this list of conditions and the following disclaimer in the documentation 00025 * and/or other materials provided with the distribution. 00026 * 00027 * 3. The name of Atmel may not be used to endorse or promote products derived 00028 * from this software without specific prior written permission. 00029 * 00030 * 4. This software may only be redistributed and used in connection with an Atmel 00031 * AVR product. 00032 * 00033 * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 00034 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00035 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 00036 * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 00037 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00038 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00039 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00040 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00041 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00042 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE 00043 * 00044 */ 00045 //_____ I N C L U D E S ___________________________________________________ 00046 #include <string.h> 00047 #include <stdio.h> 00048 00049 #include "compiler.h" 00050 #include "s_pushb.h" 00051 #include "gpio.h" 00052 #include "FreeRTOS.h" 00053 00054 00055 //_____ M A C R O S ________________________________________________________ 00056 00058 #define PUSHB_EVENT_PRESS TRUE 00059 #define PUSHB_EVENT_RELEASE FALSE 00060 00061 #define SENSOR_PB1_CONFIG_FILE "CFG/PB1.TXT" 00062 #define SENSOR_PB2_CONFIG_FILE "CFG/PB2.TXT" 00063 #define SENSOR_PB3_CONFIG_FILE "CFG/PB3.TXT" 00064 00065 #define PB1_POSITION GPIO_PUSH_BUTTON_0 00066 #define PB2_POSITION GPIO_PUSH_BUTTON_1 00067 #define PB3_POSITION GPIO_PUSH_BUTTON_2 00068 00069 //_____ D E F I N I T I O N S ______________________________________________ 00070 00072 const signed portCHAR *acpc_pushb_events[2] = { 00073 (signed portCHAR *)"RELEASE", 00074 (signed portCHAR *)"PRESS" 00075 }; 00076 00078 static Bool b_pushb1 = PUSHB_EVENT_RELEASE; 00079 static Bool b_pushb2 = PUSHB_EVENT_RELEASE; 00080 #if BOARD == EVK1100 00081 static Bool b_pushb3 = PUSHB_EVENT_RELEASE; 00082 #endif 00083 00084 00085 //_____ D E C L A R A T I O N S ____________________________________________ 00086 00094 Bool b_pushb1_get_value( char* buf ) 00095 { 00096 // input is pulled up, if 1 : input is not active 00097 if (gpio_get_pin_value(PB1_POSITION)) { 00098 b_pushb1 = PUSHB_EVENT_RELEASE; 00099 } else { 00100 b_pushb1 = PUSHB_EVENT_PRESS; 00101 } 00102 // Build the log string. 00103 sprintf( buf, "%s\r\n", (portCHAR *)acpc_pushb_events[b_pushb1]); 00104 return TRUE; 00105 } 00106 00107 00108 00116 Bool b_pushb2_get_value( char* buf ) 00117 { 00118 // input is pulled up, if 1 : input is not active 00119 if (gpio_get_pin_value(PB2_POSITION)) { 00120 b_pushb2 = PUSHB_EVENT_RELEASE; 00121 } else { 00122 b_pushb2 = PUSHB_EVENT_PRESS; 00123 } 00124 // Build the log string. 00125 sprintf( buf, "%s\r\n", (portCHAR *)acpc_pushb_events[b_pushb2]); 00126 return TRUE; 00127 } 00128 00129 00130 00131 #if BOARD == EVK1100 00132 00139 Bool b_pushb3_get_value( char* buf ) 00140 { 00141 // input is pulled up, if 1 : input is not active 00142 if (gpio_get_pin_value(PB3_POSITION)) { 00143 b_pushb3 = PUSHB_EVENT_RELEASE; 00144 } else { 00145 b_pushb3 = PUSHB_EVENT_PRESS; 00146 } 00147 // Build the log string. 00148 sprintf( buf, "%s\r\n", (portCHAR *)acpc_pushb_events[b_pushb3]); 00149 return TRUE; 00150 } 00151 #endif