C-Netz: Make memory card emulation work with AEG OLYMPIA phone
Now it is ok to have the first clock pulse after reset. The software does not care. At least there must be a clock after rising the reset.
This commit is contained in:
parent
20b5132ef7
commit
d09e9c95fd
|
@ -17,11 +17,13 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* NOTE: Reset must be an input pin, not the reset of the controller.
|
||||||
|
* The clock pulse must be detected during reset.
|
||||||
|
*/
|
||||||
#if defined(__AVR_ATtiny85__)
|
#if defined(__AVR_ATtiny85__)
|
||||||
#define RST_PIN 2
|
#define RST_PIN 2
|
||||||
#define CLK_PIN 3
|
#define CLK_PIN 3
|
||||||
#define DATA_PIN 4
|
#define DATA_PIN 4
|
||||||
#error UNTESTED!
|
|
||||||
#else
|
#else
|
||||||
#define CLK_PIN 5
|
#define CLK_PIN 5
|
||||||
#define RST_PIN 6
|
#define RST_PIN 6
|
||||||
|
@ -29,15 +31,14 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint8_t card_data[] = {
|
uint8_t card_data[] = {
|
||||||
|
/* Example: Service card for AEG OLYMPIA. */
|
||||||
0xff, 0xf7, 0x5c, 0xff, 0xff, 0xff, 0xff, 0xff,
|
0xff, 0xf7, 0x5c, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x4b, 0x90,
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x47, 0x38,
|
||||||
0x5f, 0x25, 0x07, 0x0c, 0x00, 0x00, 0xfe, 0xfd,
|
0x78, 0x28, 0x07, 0x8c, 0xc7, 0x03, 0xfe, 0xfd,
|
||||||
0xfb, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
0xfb, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||||
0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
|
0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00,
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
volatile uint8_t *rst_in, *clk_in, *data_in, *data_out, *data_mode;
|
volatile uint8_t *rst_in, *clk_in, *data_in, *data_out, *data_mode;
|
||||||
|
@ -70,6 +71,8 @@ void setup()
|
||||||
data_out = portOutputRegister(port);
|
data_out = portOutputRegister(port);
|
||||||
data_in = portInputRegister(port);
|
data_in = portInputRegister(port);
|
||||||
*data_mode |= data_bit; /* output */
|
*data_mode |= data_bit; /* output */
|
||||||
|
/* wait for reset */
|
||||||
|
while (!(*rst_in & rst_bit));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t byte_count;
|
uint8_t byte_count;
|
||||||
|
@ -78,22 +81,14 @@ uint8_t bit_count;
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
reset:
|
reset:
|
||||||
|
/* initial reset state */
|
||||||
byte_count = 0;
|
byte_count = 0;
|
||||||
bit_count = 0;
|
bit_count = 0;
|
||||||
|
*data_out |= data_bit; /* high */
|
||||||
/* wait for reset pulse */
|
/* now we have reset, so we wait for the first clock pulse */
|
||||||
while (!(*rst_in & rst_bit));
|
while (!(*clk_in & clk_bit));
|
||||||
/* now we have reset, so we wait for clock pulse */
|
while ((*clk_in & clk_bit));
|
||||||
while (!(*clk_in & clk_bit)) {
|
/* wait for reset to become low, if not already before first clock pulse (AEG phone) */
|
||||||
/* if we lost reset, go to start */
|
|
||||||
if (!(*rst_in & rst_bit))
|
|
||||||
goto reset;
|
|
||||||
}
|
|
||||||
while ((*clk_in & clk_bit)) {
|
|
||||||
/* if we lost reset, go to start */
|
|
||||||
if (!(*rst_in & rst_bit))
|
|
||||||
goto reset;
|
|
||||||
}
|
|
||||||
while ((*rst_in & rst_bit));
|
while ((*rst_in & rst_bit));
|
||||||
|
|
||||||
next_bit:
|
next_bit:
|
||||||
|
|
Loading…
Reference in New Issue