LCD Library 1.2.1
LCD Library - LCD control class hierarchy library. Drop in replacement for the LiquidCrystal Library.
|
00001 // --------------------------------------------------------------------------- 00002 // Created by Florian Fida on 20/01/12 00003 // Copyright 2012 - Under creative commons license 3.0: 00004 // Attribution-ShareAlike CC BY-SA 00005 // http://creativecommons.org/licenses/by-sa/3.0/ 00006 // 00007 // This software is furnished "as is", without technical support, and with no 00008 // warranty, express or implied, as to its usefulness for any purpose. 00009 // --------------------------------------------------------------------------- 00010 // fio_shiftOut1 functions are based on Shif1 protocol developed by Roman Black 00011 // (http://www.romanblack.com/shift1.htm) 00012 // 00013 // Thread Safe: No 00014 // Extendable: Yes 00015 // 00016 // @file FastIO.h 00017 // This file implements basic fast IO routines. 00018 // 00019 // @brief 00020 // 00021 // @version API 1.0.0 00022 // 00023 // @author Florian Fida - 00024 // 2012-03-16 bperrybap mods for chipkit32 (pic32) Arduino 00025 // support chipkit: 00026 // (https://github.com/chipKIT32/chipKIT32-MAX/blob/master/hardware/pic32/ 00027 // cores/pic32/wiring_digital.c) 00028 // --------------------------------------------------------------------------- 00029 #ifndef _FAST_IO_H_ 00030 #define _FAST_IO_H_ 00031 00032 #if (ARDUINO < 100) 00033 #include <WProgram.h> 00034 #else 00035 #include <Arduino.h> 00036 #endif 00037 00038 #include <pins_arduino.h> // pleasing sanguino core 00039 #include <inttypes.h> 00040 00041 00042 #define SKIP 0x23 00043 00044 #if defined (__AVR__) 00045 #include <util/atomic.h> // for critical section management 00046 typedef uint8_t fio_bit; 00047 typedef volatile uint8_t *fio_register; 00048 00049 00050 #elif defined(__PIC32MX__) 00051 typedef uint32_t fio_bit; 00052 typedef volatile uint32_t *fio_register; 00053 00054 00055 #else 00056 // fallback to Arduino standard digital i/o routines 00057 #define FIO_FALLBACK 00058 #define ATOMIC_BLOCK(dummy) if(true) 00059 #define ATOMIC_RESTORESTATE 00060 typedef uint8_t fio_bit; 00061 typedef uint8_t fio_register; 00062 #endif 00063 00064 00065 00066 #if !defined(FIO_FALLBACK) && !defined(ATOMIC_BLOCK) 00067 /* 00068 * Define an ATOMIC_BLOCK that implements ATOMIC_FORCEON type 00069 * Using the portable Arduino interrupts() and noInterrupts() 00070 */ 00071 #define ATOMIC_RESTORESTATE ATOMIC_FORCEON // sorry, no support for save/restore yet. 00072 #define ATOMIC_FORCEON uint8_t sreg_save 00073 __attribute__((__cleanup__(__iSeiParam))) = 0 00074 00075 static __inline__ uint8_t __iCliRetVal(void) 00076 { 00077 noInterrupts(); 00078 return(1); 00079 } 00080 static __inline__ void __iSeiParam(const uint8_t *__s) 00081 { 00082 interrupts(); 00083 } 00084 #define ATOMIC_BLOCK(type) for(type, __Todo = __iCliRetVal(); __Todo; __Todo = 0) 00085 00086 #endif // end of block to create compatible ATOMIC_BLOCK() 00087 00088 00089 00097 fio_register fio_pinToOutputRegister(uint8_t pin, uint8_t initial_state = LOW); 00098 00106 fio_register fio_pinToInputRegister(uint8_t pin); 00107 00115 fio_bit fio_pinToBit(uint8_t pin); 00116 00117 00127 // __attribute__ ((always_inline)) /* let the optimizer decide that for now */ 00128 void fio_digitalWrite ( fio_register pinRegister, fio_bit pinBit, uint8_t value ); 00129 00136 #ifndef FIO_FALLBACK 00137 #define fio_digitalWrite_LOW(reg,bit) *reg &= ~bit 00138 #define fio_digitalWrite_HIGH(reg,bit) *reg |= bit 00139 #define fio_digitalWrite_SWITCH(reg,bit) *reg ^= bit 00140 #define fio_digitalWrite_SWITCHTO(reg,bit,val) fio_digitalWrite_SWITCH(reg,bit) 00141 #else 00142 // reg -> dummy NULL, bit -> pin 00143 #define fio_digitalWrite_HIGH(reg,bit) digitalWrite(bit,HIGH) 00144 #define fio_digitalWrite_LOW(reg,bit) digitalWrite(bit,LOW) 00145 #define fio_digitalWrite_SWITCH(reg,bit) digitalWrite(bit, !digitalRead(bit)) 00146 #define fio_digitalWrite_SWITCHTO(reg,bit,val) digitalWrite(bit,val); 00147 #endif 00148 00158 int fio_digitalRead ( fio_register pinRegister, fio_bit pinBit ); 00159 00171 void fio_shiftOut( fio_register dataRegister, fio_bit dataBit, fio_register clockRegister, 00172 fio_bit clockBit, uint8_t value, uint8_t bitOrder ); 00173 00184 void fio_shiftOut(fio_register dataRegister, fio_bit dataBit, fio_register clockRegister, fio_bit clockBit); 00185 00194 void fio_shiftOut1(fio_register shift1Register, fio_bit shift1Bit, uint8_t value, boolean noLatch = false); 00202 void fio_shiftOut1(uint8_t pin, uint8_t value, boolean noLatch = false); 00210 void fio_shiftOut1_init(fio_register shift1Register, fio_bit shift1Bit); 00217 void fio_shiftOut1_init(uint8_t pin); 00218 00219 #endif // FAST_IO_H