Only odd addresses may be programmed to the ERXRDPT registers, so
initialize them to RX_BUF_END instead of RX_BUF_START.
Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
The Bit Field Set and Bit Field Clear commands are more efficient than
the Read Control Register + Write Control Register combination, so use
them whenever possible, i.e. for the ETH registers.
Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
This only applies to half duplex, so the actual configuration of MACON4
does not need to be changed.
Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
The register 0x01 in bank 2, named MACON2 in the code, is actually
reserved, so its contents must not be changed.
This register has been marked as reserved from the revision B of the
data sheet in July 2006. The current revision of the data sheet is E,
and it is quite clear about this register.
Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
This is useful as debug information since the revisions of this device
have notable differences.
Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
A delay of 1 ms must be added after the System Reset Command. Still wait
for ESTAT.CLKRDY afterwards as a precaution.
Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
The Read Control Register command requires that a dummy byte be read
before the register value for the MAC and MII registers.
Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
The read/writedatabyte() functions are just a special case of
read/writedata() with a simpler API, so reuse these instead of
duplicating code.
Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
Now the necessary settings are in adc.h. Refactored to allow repeated
ADC reads without reinitialization. Arduino allows setting
analogReference, this is now also implemented.
ADC is now initialized to sane values in apps/arduino/arduino-process.c
dev/arduino/arduino-compat.h now has all hardware independent settings
for arduino (some moved from platform/osd-merkur/dev/hw-arduino.h).
turnOffPWM re-implemented with hw_timer, removed from wiring_digital.c
ADC-specific arduino stuff moved to arduino-compat.h
Arduinos wiring_analog no longer necessary.
arduino-sketch example now reads analog inputs 1 and 5 using analogRead.
We can now directly compile arduino sketches (.pde) files.
Arduino compatible analogWrite works now.
But there is still a long way to go, serial I/O and timer stuff (delay,
millis etc) currently don't work (not tested but I don't expect this to
work).
It can be used in an arduino sketch or in a normal contiki program.
We get a PWM frequency of 490.2 Hz (a period of 2.040 ms), that's
Arduino compatible. If you need different frequencies see native timer
usage in examples/osd/pwm-example
In a contiki program you have to call arduino_pwm_timer_init to
initialize the timer before pwm works. The arduino sketch wrapper
already does this.
For running a sketch, see examples/osd/arduino-sketch