/******************************************************************************* * * structure.c * * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * ******************************************************************************/ //****************************************************************************** // structure.c // // RO_PINOSC_TA0_One_Button_Compact example // Touch the middle element to turn on/off the center button LED // Uses the low-level API function calls for reduced memory footprint. // Note: Baseline tracking is implemented in the Application Layer // RO method capactiance measurement using PinOsc IO, TimerA0, and WDT+ // //****************************************************************************** // //****************************************************************************** #include "structure.h" //PinOsc Wheel: middle button P2.5 const struct Element middle_element = { .inputPxselRegister = (uint8_t *)&P2SEL, .inputPxsel2Register = (uint8_t *)&P2SEL2, .inputBits = BIT5, // When using an abstracted function to measure the element // the 100*(maxResponse - threshold) < 0xFFFF // ie maxResponse - threshold < 655 .maxResponse = 350+655, .threshold = 350 }; //*** CAP TOUCH HANDLER *******************************************************/ // This defines the grouping of sensors, the method to measure change in // capacitance, and the function of the group const struct Sensor middle_button = { .halDefinition = RO_PINOSC_TA0_WDTp, .numElements = 1, .baseOffset = 0, // Pointer to elements .arrayPtr[0] = &middle_element, // point to first element // Timer Information .measGateSource= GATE_WDTp_ACLK, // 0->SMCLK, 1-> ACLK //.accumulationCycles= WDTp_GATE_32768 //32768 //.accumulationCycles= WDTp_GATE_8192 // 8192 //.accumulationCycles= WDTp_GATE_512 //512 .accumulationCycles= WDTp_GATE_64 //64 }; //PinOsc Wheel: middle button P2.5 const struct Element middle_element2 = { .inputPxselRegister = (uint8_t *)&P2SEL, .inputPxsel2Register = (uint8_t *)&P2SEL2, .inputBits = BIT4, // When using an abstracted function to measure the element // the 100*(maxResponse - threshold) < 0xFFFF // ie maxResponse - threshold < 655 .maxResponse = 350+655, .threshold = 350 }; //*** CAP TOUCH HANDLER *******************************************************/ // This defines the grouping of sensors, the method to measure change in // capacitance, and the function of the group const struct Sensor middle_button2 = { .halDefinition = RO_PINOSC_TA0_WDTp, .numElements = 1, .baseOffset = 0, // Pointer to elements .arrayPtr[0] = &middle_element2, // point to first element // Timer Information .measGateSource= GATE_WDTp_ACLK, // 0->SMCLK, 1-> ACLK //.accumulationCycles= WDTp_GATE_32768 //32768 //.accumulationCycles= WDTp_GATE_8192 // 8192 //.accumulationCycles= WDTp_GATE_512 //512 .accumulationCycles= WDTp_GATE_64 //64 };