//************************************************************ // // readSwitch.c // // This program reads the state of switch 2. While the switch // is press, the leds will cycle: yellow, green, red, off. // // The goal of this program is to demonstrate how to read // from a gpio and how to control leds. The program is designed // for ease of understanding and not meant to demonstrate // best practices. // // ed c. epp // // Notice // This document, as well as the software described in it, is // furnished under license and may only be used or copied in // accordance with the terms of the license. The information in // this document is furnished for informational use only, is // subject to change without notice, and should not be construed // as a commitment by Intel Corporation. Intel Corporation // assumes no responsibility or liability for any errors or // inaccuracies that may appear in this document or any software // that may be provided in association with this document. // // Except as permitted by such license, no part of this // document may be reproduced, stored in a retrieval system, // or transmitted in any form or by any means without the // express written consent of Intel Corporation. // // Intel Corporation may have patents or pending patent // applications, trademarks, copyrights, or other intellectual // property rights that relate to the described subject matter. // The furnishing of this document does not provide any license, // express or implied, by estoppel or otherwise, to any such // patents, trademarks, copyrights, or other intellectual // property rights. // // Copyright© 2004 Intel Corporation. All rights reserved. // Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, // OR 97124-6497 // //************************************************************* #include #include #include #include #include "led.h" // GPIO constants #define GPIO_CONTROL "/proc/platx/gpio/GPCTL" #define SWITCH2 "/proc/platx/gpio/gpio10" #define BUF_SIZE 4 //--------------------- main ------------------------------- int main(int argc, char* argv[]) { int gpioControl; int switch2; int leds; int counter = 0; int color = 0; int i; char buffer[BUF_SIZE]; for (i=0; i