Erik Gilling | 51f1751 | 2011-02-17 20:39:36 -0800 | [diff] [blame^] | 1 | /* Copyright 2009-2011 Oleg Mazurov, Circuits At Home, http://www.circuitsathome.com */
|
| 2 | /* MAX3421E functions */
|
| 3 | #ifndef _MAX3421E_H_
|
| 4 | #define _MAX3421E_H_
|
| 5 |
|
| 6 |
|
| 7 | //#include <Spi.h>
|
| 8 | //#include <WProgram.h>
|
| 9 | #include "WProgram.h"
|
| 10 | #include "Max3421e_constants.h"
|
| 11 |
|
| 12 | class MAX3421E /* : public SPI */ {
|
| 13 | // byte vbusState;
|
| 14 | public:
|
| 15 | MAX3421E( void );
|
| 16 | byte getVbusState( void );
|
| 17 | // void toggle( byte pin );
|
| 18 | static void regWr( byte, byte );
|
| 19 | char * bytesWr( byte, byte, char * );
|
| 20 | static void gpioWr( byte );
|
| 21 | byte regRd( byte );
|
| 22 | char * bytesRd( byte, byte, char * );
|
| 23 | byte gpioRd( void );
|
| 24 | boolean reset();
|
| 25 | boolean vbusPwr ( boolean );
|
| 26 | void busprobe( void );
|
| 27 | void powerOn();
|
| 28 | byte IntHandler();
|
| 29 | byte GpxHandler();
|
| 30 | byte Task();
|
| 31 | private:
|
| 32 | static void spi_init() {
|
| 33 | uint8_t tmp;
|
| 34 | // initialize SPI pins
|
| 35 | pinMode(SCK_PIN, OUTPUT);
|
| 36 | pinMode(MOSI_PIN, OUTPUT);
|
| 37 | pinMode(MISO_PIN, INPUT);
|
| 38 | pinMode(SS_PIN, OUTPUT);
|
| 39 | digitalWrite( SS_PIN, HIGH );
|
| 40 | /* mode 00 (CPOL=0, CPHA=0) master, fclk/2. Mode 11 (CPOL=11, CPHA=11) is also supported by MAX3421E */
|
| 41 | SPCR = 0x50;
|
| 42 | SPSR = 0x01;
|
| 43 | /**/
|
| 44 | tmp = SPSR;
|
| 45 | tmp = SPDR;
|
| 46 | }
|
| 47 | // void init();
|
| 48 | friend class Max_LCD;
|
| 49 | };
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 | #endif //_MAX3421E_H_
|