Exemplo n.º 1
0
/*
 * Initialises the max3421e host shield. Initialises the SPI bus and sets the required pin directions.
 * Must be called before powerOn.
 */
void max3421e_init()
{
	spi_begin();

#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)

	// Set MAX_INT and MAX_GPX pins to input mode.
	DDRH &= ~(0x40 | 0x20);

	// Set SPI !SS pint to output mode.
	DDRB |= 0x10;

	// Set RESET pin to output
	DDRH |= 0x10;

#elif defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__)

	// Set MAX_INT and MAX_GPX pins to input mode.
	DDRB &= ~0x3;

	// Set RESET pin to output
	DDRD |= 0x80;

	// Set SS pin to output
	DDRB |= 0x4;

#endif

	// Sparkfun botched their first attempt at cloning Oleg's max3421e shield and reversed the GPX and RESET pins.
	// This hack is in place to make MicroBridge work with those shields. (see http://www.sparkfun.com/products/9628)
#ifdef SFHACK

#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)

	// Set MAX_GPX pin to input mode.
	DDRH &= ~0x10;

	// Set RESET pin to output
	DDRH |= 0x20;

#elif defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__)

	// Set GPX pin to input
	DDRD &= ~0x80;

	// Set RESET pin to output
	DDRB |= 0x1;

#endif

#endif


	// Pull SPI !SS high
	MAX_SS(1);

	// Reset
	MAX_RESET(1);
}
Exemplo n.º 2
0
/*
 * Initialises the max3421e host shield. Initialises the SPI bus and sets the required pin directions.
 * Must be called before powerOn.
 */
void max3421e_init()
{

    SPI.begin();

#ifndef __AVR_ATmega2560__
    pinMode(PIN_MAX_INT, INPUT);
    pinMode(PIN_MAX_GPX, INPUT);
    pinMode(PIN_MAX_SS, OUTPUT);
    pinMode(PIN_MAX_RESET, OUTPUT);
#endif
#ifdef __AVR_ATmega2560__
    pinMode(PIN_MAX_SS, OUTPUT);
    DDRE &= ~ 0x40; // MAX_INT as input
    DDRJ &= ~ 0x08; //MAX_GPX as input
    DDRJ |= 0x04; //MAX_RESET as output
#endif


    /*
    #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)

    	// Set MAX_INT and MAX_GPX pins to input mode.
    	DDRH &= ~(0x40 | 0x20);

    	// Set SPI !SS pint to output mode.
    	DDRB |= 0x10;

    	// Set RESET pin to output
    	DDRH |= 0x10;

    #elif defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__)

    	// Set MAX_INT and MAX_GPX pins to input mode.
    	DDRB &= ~0x3;

    	// Set RESET pin to output
    	DDRD |= 0x80;

    	// Set SS pin to output
    	DDRB |= 0x4;

    #endif
    */

    // Pull SPI !SS high
    MAX_SS(1);

    // Reset
    MAX_RESET(1);
}