|
|
|
@ -1,3 +1,68 @@
|
|
|
|
|
/**
|
|
|
|
|
* Texas Instruments HDQ implementation for the Arduino API
|
|
|
|
|
* (cleft) Matthieu Lalonde 2008 (matth@mlalonde.net)
|
|
|
|
|
* Creative Commons BY-SA-NC
|
|
|
|
|
*
|
|
|
|
|
* http://trac.mlalonde.net/cral/browser/HDQ/
|
|
|
|
|
*
|
|
|
|
|
* Revision 1
|
|
|
|
|
*
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
|
|
/* ***************** *
|
|
|
|
|
* HDQ Usage example *
|
|
|
|
|
** ***************** *
|
|
|
|
|
|
|
|
|
|
#include "hdq.h"
|
|
|
|
|
HDQ HDQ(HDQ_DEFAULT_PIN);
|
|
|
|
|
|
|
|
|
|
uint8_t r;
|
|
|
|
|
|
|
|
|
|
for (uint8_t jj = 0; jj < 0x10; jj++) {
|
|
|
|
|
r = HDQ.read(jj);
|
|
|
|
|
|
|
|
|
|
Serial.print("Register 0x");
|
|
|
|
|
Serial.print(jj, HEX);
|
|
|
|
|
Serial.print(": ");
|
|
|
|
|
Serial.print(r, BIN);
|
|
|
|
|
Serial.print(" 0x");
|
|
|
|
|
Serial.println(r, HEX);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
r = HDQ.read(0x1e);
|
|
|
|
|
|
|
|
|
|
Serial.print("Register 0x1e: ");
|
|
|
|
|
Serial.print(r, BIN);
|
|
|
|
|
Serial.print(" 0x");
|
|
|
|
|
Serial.println(r, HEX);
|
|
|
|
|
|
|
|
|
|
r = HDQ.read(0x7e);
|
|
|
|
|
|
|
|
|
|
Serial.print("Register 0x7e: ");
|
|
|
|
|
Serial.print(r, BIN);
|
|
|
|
|
Serial.print(" 0x");
|
|
|
|
|
Serial.println(r, HEX);
|
|
|
|
|
|
|
|
|
|
HDQ.write(0x05, B11011101);
|
|
|
|
|
|
|
|
|
|
r = HDQ.read(0x05);
|
|
|
|
|
|
|
|
|
|
Serial.print("Register 0x05: ");
|
|
|
|
|
Serial.print(r, BIN);
|
|
|
|
|
Serial.print(" 0x");
|
|
|
|
|
Serial.println(r, HEX);
|
|
|
|
|
|
|
|
|
|
HDQ.write(0x05, B00111001);
|
|
|
|
|
|
|
|
|
|
r = HDQ.read(0x05);
|
|
|
|
|
|
|
|
|
|
Serial.print("Register 0x05: ");
|
|
|
|
|
Serial.print(r, BIN);
|
|
|
|
|
Serial.print(" 0x");
|
|
|
|
|
Serial.println(r, HEX);
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
|
#include "WConstants.h"
|
|
|
|
|
#include "pins_arduino.h"
|
|
|
|
@ -6,11 +71,11 @@ extern "C" {
|
|
|
|
|
#include "avrmacros.h"
|
|
|
|
|
#include "hdq.h"
|
|
|
|
|
|
|
|
|
|
#define _HDQ_readPin() (*inputReg & bitmask)>>pin /* Change me to inline!*/
|
|
|
|
|
#define _HDQ_readPin() (*inputReg & bitmask)>>pin /* Change me to inline!*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Constructor
|
|
|
|
|
* @param pin: pin number to attach to
|
|
|
|
|
* @param pinArg: pin number to attach to
|
|
|
|
|
**/
|
|
|
|
|
HDQ::HDQ(uint8_t pinArg)
|
|
|
|
|
{
|
|
|
|
|