Commits

F Malpartida  committed 7329d2d

Minor code comments to align coding style for all the libraries.
Created rel 1.2.0 preparation branch.

  • Participants
  • Parent commits bd0a1c7
  • Branches V 1.2.0 preparation

Comments (0)

Files changed (3)

 // This software is furnished "as is", without technical support, and with no
 // warranty, express or implied, as to its usefulness for any purpose.
 // ---------------------------------------------------------------------------
-// fio_shiftOut1 functions are based on Shif1 protocol developed by Roman Black (http://www.romanblack.com/shift1.htm)
+// fio_shiftOut1 functions are based on Shif1 protocol developed by Roman Black 
+// (http://www.romanblack.com/shift1.htm)
 //
-// TODO:
-//  support chipkit (https://github.com/chipKIT32/chipKIT32-MAX/blob/master/hardware/pic32/cores/pic32/wiring_digital.c)
-// maybe improve fio_digitalRead
+// Thread Safe: No
+// Extendable: Yes
+//
+// @file FastIO.h
+// This file implements basic fast IO routines.
+// 
+// @brief 
+//
+// @version API 1.0.0
+//
+// @author Florial Fida - 
+//
+// @todo:
+//  support chipkit:
+// (https://github.com/chipKIT32/chipKIT32-MAX/blob/master/hardware/pic32/
+//   cores/pic32/wiring_digital.c)
+// ---------------------------------------------------------------------------
 
 #include <FastIO.h>
 
-fio_register fio_pinToOutputRegister(uint8_t pin, uint8_t initial_state){
+fio_register fio_pinToOutputRegister(uint8_t pin, uint8_t initial_state)
+{
 	pinMode(pin, OUTPUT);
-	if(initial_state != SKIP) digitalWrite(pin, initial_state); // also turns off pwm timer
+   
+	if(initial_state != SKIP) 
+   {
+      digitalWrite(pin, initial_state); // also turns off pwm timer
+   }
 #ifdef FIO_FALLBACK
 	//  just wasting memory if not using fast io...
 	return 0;
 #endif
 }
 
-fio_register fio_pinToInputRegister(uint8_t pin){
+fio_register fio_pinToInputRegister(uint8_t pin)
+{
 	pinMode(pin, INPUT);
 	digitalWrite(pin, LOW); // also turns off pwm timer and pullup
 #ifdef FIO_FALLBACK
 #endif
 }
 
-uint8_t fio_pinToBit(uint8_t pin){
+uint8_t fio_pinToBit(uint8_t pin)
+{
 #ifdef FIO_FALLBACK
 	// (ab)use the bit variable to store the pin
 	return pin;
 #endif
 }
 
-void fio_digitalWrite(fio_register pinRegister, uint8_t pinBit, uint8_t value) {
+void fio_digitalWrite(fio_register pinRegister, uint8_t pinBit, uint8_t value) 
+{
 #ifdef FIO_FALLBACK
 	digitalWrite(pinBit, value);
 #else
-	if(value == LOW){
+	if(value == LOW)
+   {
 		fio_digitalWrite_LOW(pinRegister,pinBit);
-	}else{
+	}
+   else
+   {
 		fio_digitalWrite_HIGH(pinRegister,pinBit);
 	}
 #endif
 }
 
-int fio_digitalRead(fio_register pinRegister, uint8_t pinBit){
+int fio_digitalRead(fio_register pinRegister, uint8_t pinBit)
+{
 #ifdef FIO_FALLBACK
 	return digitalRead(pinBit);
 #else
 #endif
 }
 
-void fio_shiftOut(fio_register dataRegister, fio_bit dataBit, fio_register clockRegister, fio_bit clockBit, uint8_t value, uint8_t bitOrder){
+void fio_shiftOut ( fio_register dataRegister, fio_bit dataBit, fio_register clockRegister, 
+                    fio_bit clockBit, uint8_t value, uint8_t bitOrder)
+{
 	// # disable interrupts
 	// uint8_t oldSREG = SREG;
 	// cli();
-
 	int8_t i;
 
-	for(i = 0; i < 8; i++){
-		if (bitOrder == LSBFIRST){
+	for(i = 0; i < 8; i++)
+   {
+		if (bitOrder == LSBFIRST)
+      {
 			fio_digitalWrite(dataRegister, dataBit, !!(value & (1 << i)));
-		}else{
+		}
+      else
+      {
 			fio_digitalWrite(dataRegister, dataBit, !!(value & (1 << (7 - i))));
 		}
-		fio_digitalWrite_HIGH(clockRegister, clockBit);
+		fio_digitalWrite_HIGH (clockRegister, clockBit);
 		// Switching is a little bit faster
-		fio_digitalWrite_SWITCH(clockRegister,clockBit);
+		fio_digitalWrite_SWITCH (clockRegister,clockBit);
 	}
-
 	// # enable interrupts
 	// SREG = oldSREG;
 }
 
-void fio_shiftOut(fio_register dataRegister, uint8_t dataBit, fio_register clockRegister, uint8_t clockBit){
+void fio_shiftOut(fio_register dataRegister, uint8_t dataBit, fio_register clockRegister, uint8_t clockBit)
+{
 	// shift out 0x0 (B00000000) fast, byte order is irrelevant
-	fio_digitalWrite_LOW(dataRegister, dataBit);
-	for(uint8_t i = 0; i<8; ++i){
-		fio_digitalWrite_HIGH(clockRegister, clockBit);
-		fio_digitalWrite_SWITCH(clockRegister,clockBit);
+	fio_digitalWrite_LOW (dataRegister, dataBit);
+
+	for(uint8_t i = 0; i<8; ++i)
+   {
+		fio_digitalWrite_HIGH (clockRegister, clockBit);
+		fio_digitalWrite_SWITCH (clockRegister, clockBit);
 	}
 }
-void fio_shiftOut1_init(uint8_t pin){
+void fio_shiftOut1_init(uint8_t pin)
+{
 	fio_shiftOut1_init(fio_pinToOutputRegister(pin,HIGH),fio_pinToBit(pin));
 }
-void fio_shiftOut1_init(fio_register shift1Register, fio_bit shift1Bit){
+
+void fio_shiftOut1_init(fio_register shift1Register, fio_bit shift1Bit)
+{
 	// Make sure that capacitors are charged
 	// 300us is an educated guess...
 	fio_digitalWrite(shift1Register,shift1Bit,HIGH);
 	delayMicroseconds(300);
 }
-void fio_shiftOut1(fio_register shift1Register, fio_bit shift1Bit, uint8_t value, boolean noLatch){
+void fio_shiftOut1(fio_register shift1Register, fio_bit shift1Bit, uint8_t value, boolean noLatch)
+{
 	/*
 	 * this function are based on Shif1 protocol developed by Roman Black (http://www.romanblack.com/shift1.htm)
 	 *
 	cli();
 
 	// iterate but ignore last bit (is it correct now?)
-	for(int8_t i = 7; i>=0; --i){
+	for(int8_t i = 7; i>=0; --i)
+   {
 
 		// assume that pin is HIGH (smokin' pot all day... :) - requires initialization
-		if(LOW==!!(value & (1 << i))){
+		if(LOW==!!(value & (1 << i)))
+      {
 			// LOW = 0 Bit
 			fio_digitalWrite_SWITCHTO(shift1Register,shift1Bit,LOW);
 			// hold pin LOW for 15us
 			fio_digitalWrite_SWITCHTO(shift1Register,shift1Bit,HIGH);
 			// hold pin HIGH for 30us
 			delayMicroseconds(30);
-		}else{
+		}
+      else
+      {
 			// HIGH = 1 Bit
 			fio_digitalWrite_SWITCHTO(shift1Register,shift1Bit,LOW);
 			//hold pin LOW for 1us - done! :)
 			//hold pin HIGH for 15us
 			delayMicroseconds(15);
 		}
-		if(!noLatch && i==1) break;
+		if(!noLatch && i==1)
+      {
+         break;
+      }
 	}
-	if(!noLatch){
+   
+	if(!noLatch)
+   {
 		// send last bit (=LOW) and Latch command
 		fio_digitalWrite_SWITCHTO(shift1Register,shift1Bit,LOW);
 		// Hold pin low for 200us
 	SREG = oldSREG;
 
 }
-void fio_shiftOut1(uint8_t pin, uint8_t value, boolean noLatch){
+void fio_shiftOut1(uint8_t pin, uint8_t value, boolean noLatch)
+{
 	fio_shiftOut1(fio_pinToOutputRegister(pin, SKIP),fio_pinToBit(pin),value, noLatch);
 }
 // This software is furnished "as is", without technical support, and with no
 // warranty, express or implied, as to its usefulness for any purpose.
 // ---------------------------------------------------------------------------
-// fio_shiftOut1 functions are based on Shif1 protocol developed by Roman Black (http://www.romanblack.com/shift1.htm)
+// fio_shiftOut1 functions are based on Shif1 protocol developed by Roman Black 
+// (http://www.romanblack.com/shift1.htm)
 //
-// TODO:
-//  support chipkit (https://github.com/chipKIT32/chipKIT32-MAX/blob/master/hardware/pic32/cores/pic32/wiring_digital.c)
-
+// Thread Safe: No
+// Extendable: Yes
+//
+// @file FastIO.h
+// This file implements basic fast IO routines.
+// 
+// @brief 
+//
+// @version API 1.0.0
+//
+// @author Florial Fida - 
+//
+// @todo:
+//  support chipkit:
+// (https://github.com/chipKIT32/chipKIT32-MAX/blob/master/hardware/pic32/
+//   cores/pic32/wiring_digital.c)
+// ---------------------------------------------------------------------------
 #ifndef FAST_IO_H
 #define FAST_IO_H
 
 #define FIO_FALLBACK
 #endif
 
+// PUBLIC CONSTANTS DEFINITIONS
+// ---------------------------------------------------------------------------
+#define SKIP 0x23
+
+// PUBLIC TYPE DEFINITIONS
+// ---------------------------------------------------------------------------
 typedef uint8_t fio_bit;
-#define SKIP 0x23
+
 
 #ifndef FALLBACK
 typedef volatile uint8_t * fio_register;
  @param value[in] desired output
  */
 // __attribute__ ((always_inline)) /* let the optimizer decide that for now */
-void fio_digitalWrite(fio_register pinRegister, fio_bit pinBit,uint8_t value);
+void fio_digitalWrite(fio_register pinRegister, fio_bit pinBit, uint8_t value);
 
 /**
  * This is where the magic happens that makes things fast.
  @param clockBit[in] Bit of data pin - Pin if fast digital write is disabled
  @param bitOrder[in] bit order
  */
-void fio_shiftOut(fio_register dataRegister, fio_bit dataBit, fio_register clockRegister, fio_bit clockBit, uint8_t value, uint8_t bitOrder);
+void fio_shiftOut(fio_register dataRegister, fio_bit dataBit, fio_register clockRegister, 
+                  fio_bit clockBit, uint8_t value, uint8_t bitOrder);
 
 /*!
  @method
 // Thread Safe: No
 // Extendable: Yes
 //
-// @file HD44780.h
+// @file LCD.h
 // This file implements a basic liquid crystal library that comes as standard
 // in the Arduino SDK.
 //