00001 /* 00002 * Copyright (c) 2005-2006 David A. Mellis 00003 * 00004 * This program is free software: you can redistribute it and/or modify 00005 * it under the terms of the GNU Lesser General Public License as published by 00006 * the Free Software Foundation, either version 2.1 of the License, or 00007 * (at your option) any later version. 00008 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU Lesser General Public License for more details. 00013 00014 * You should have received a copy of the GNU Lesser General Public License 00015 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00016 */ 00017 00018 #include "wiring_private.h" 00019 00020 void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, byte val) 00021 { 00022 int i; 00023 00024 for (i = 0; i < 8; i++) { 00025 if (bitOrder == LSBFIRST) 00026 digitalWrite(dataPin, !!(val & (1 << i))); 00027 else 00028 digitalWrite(dataPin, !!(val & (1 << (7 - i)))); 00029 00030 digitalWrite(clockPin, HIGH); 00031 digitalWrite(clockPin, LOW); 00032 } 00033 }
1.5.6