Move network module initialisation into class.

git-svn-id: svn+ssh://oldsvn/home/mlalondesvn/svn/cral@90 3ee9b42a-b53c-0410-a25e-f0b6218d5d5b
master
follower 17 years ago
parent 732e4ac846
commit c61d2ef510

@ -98,33 +98,28 @@ SpiConfiguration SPI = SpiConfiguration();
/* ------ WIZ810MJ ------ */ /* ------ WIZ810MJ ------ */
class Wiz810MJ { class Wiz810MjDevice {
public: public:
Wiz810MJ(int resetPin); Wiz810MjDevice(int resetPin);
private: private:
void _init(void);
int _resetPin; int _resetPin;
}; };
Wiz810MJ::Wiz810MJ(int resetPin) {
Wiz810MjDevice::Wiz810MjDevice(int resetPin) {
// TODO: We should really allow the chip-select pin to be set here? // TODO: We should really allow the chip-select pin to be set here?
// Or require that it's defined. (Currently in the library file 'types.h'.) // Or require that it's defined. (Currently in the library file 'types.h'.)
_resetPin = resetPin; _resetPin = resetPin;
_init();
} }
/* ----------------------- */
// #define PIN_RESET 9 // WIZnet module /RESET
#define PIN_RESET 8 // WIZnet module /RESET
SOCKET testSocket;
byte ip[6];
void initModule() { void Wiz810MjDevice::_init(void) {
/* /*
Initialise the WIZ810MJ module and driver. Initialise the WIZ810MJ module and driver.
@ -138,14 +133,14 @@ void initModule() {
to function without a hardware reset but it to function without a hardware reset but it
seems not to be the case.) seems not to be the case.)
*/ */
pinMode(PIN_RESET, OUTPUT); pinMode(_resetPin, OUTPUT);
// We rely on the time between function calls to // We rely on the time between function calls to
// be long enough for the chip to recognise the // be long enough for the chip to recognise the
// reset. // reset.
digitalWrite(PIN_RESET, HIGH); digitalWrite(_resetPin, HIGH);
digitalWrite(PIN_RESET, LOW); // reset digitalWrite(_resetPin, LOW); // reset
digitalWrite(PIN_RESET, HIGH); digitalWrite(_resetPin, HIGH);
// Chip initialisation by driver // Chip initialisation by driver
// Might be redundant following the above reset, // Might be redundant following the above reset,
@ -156,10 +151,20 @@ void initModule() {
// (This is required to configure some variables used // (This is required to configure some variables used
// internally by the driver--even if the default chip // internally by the driver--even if the default chip
// configuration is used.) // configuration is used.)
sysinit(0x55, 0x55); sysinit(0x55, 0x55);
} }
/* ----------------------- */
// #define PIN_RESET 9 // WIZnet module /RESET
#define PIN_RESET 8 // WIZnet module /RESET
SOCKET testSocket;
byte ip[6];
#define PIN_LED 2 #define PIN_LED 2
void setup () { void setup () {
@ -168,7 +173,7 @@ void setup () {
SPI.begin(); SPI.begin();
initModule(); Wiz810MjDevice WIZ810MJ = Wiz810MjDevice(PIN_RESET);
Serial.println("Test W5100 configuration..."); Serial.println("Test W5100 configuration...");

Loading…
Cancel
Save