iforce2d Chris / Mbed 2 deprecated ubxDistanceMeter

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers u8g_com_arduino_common.c Source File

u8g_com_arduino_common.c

00001 /*
00002   
00003   u8g_com_arduino_common.c
00004   
00005   shared procedures for the arduino communication procedures
00006 
00007   Universal 8bit Graphics Library
00008   
00009   Copyright (c) 2011, olikraus@gmail.com
00010   All rights reserved.
00011 
00012   Redistribution and use in source and binary forms, with or without modification, 
00013   are permitted provided that the following conditions are met:
00014 
00015   * Redistributions of source code must retain the above copyright notice, this list 
00016     of conditions and the following disclaimer.
00017     
00018   * Redistributions in binary form must reproduce the above copyright notice, this 
00019     list of conditions and the following disclaimer in the documentation and/or other 
00020     materials provided with the distribution.
00021 
00022   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
00023   CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
00024   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
00025   MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
00026   DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
00027   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
00028   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
00029   NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
00030   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
00031   CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
00032   STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
00033   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
00034   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
00035   
00036 
00037 */
00038 
00039 #include "u8g.h"
00040 
00041 #if defined(ARDUINO)
00042 
00043 #if ARDUINO < 100 
00044 #include <WProgram.h> 
00045 #else 
00046 #include <Arduino.h> 
00047 #endif
00048 
00049 void u8g_com_arduino_digital_write(u8g_t *u8g, uint8_t pin_index, uint8_t value)
00050 {
00051   uint8_t pin;
00052   pin = u8g->pin_list[pin_index];
00053   if ( pin != U8G_PIN_NONE )
00054     digitalWrite(pin, value);
00055 }
00056 
00057 /* this procedure does not set the RW pin */
00058 void u8g_com_arduino_assign_pin_output_high(u8g_t *u8g)
00059 {
00060   uint8_t i;
00061   /* skip the RW pin, which is the last pin in the list */
00062   for( i = 0; i < U8G_PIN_LIST_LEN-1; i++ )
00063   {
00064     if ( u8g->pin_list[i] != U8G_PIN_NONE )
00065     {
00066       pinMode(u8g->pin_list[i], OUTPUT);    
00067       digitalWrite(u8g->pin_list[i], HIGH);
00068     }
00069   }
00070 }
00071 
00072 
00073 #endif
00074 
00075 
00076