Oh dear, I seem to have bricked mine already. I had it working with my Arduino, and the GET_IC_VER command was returning a sensible value. I connected the INT pin to one of my Arduino pins before I had configured it as an input, and now the data lines are stuck at 0xFF.
Here's the arduino code I have so far:
Code:
#define COMMAND true
#define DATA false
#define READ A0
#define WRITE A1
#define INTERRUPT A2
#define Ad0 B00000100
#define d27 B11111100
#define d01 B00000011
#define GET_IC_VER 0x01
#define RESET_ALL 0x05
#define CHECK_EXIST 0x06
void awaitInterrupt() {
}
void portWrite(byte data, bool mode) {
DDRD |= d27;
DDRB |= d01;
PORTD = data & d27;
PORTB = data & d01;
setMode(mode);
digitalWrite(WRITE, LOW);
digitalWrite(WRITE, HIGH);
}
void setMode(bool mode) {
if (mode == COMMAND) {
PORTB = PINB | Ad0;
} else {
PORTB = PINB & ~Ad0;
}
}
byte portRead(bool mode) {
DDRD &= ~d27;
DDRB &= ~d01;
setMode(mode);
digitalWrite(READ, LOW);
byte output = 0;
output |= PIND & d27;
output |= PINB & d01;
digitalWrite(READ, HIGH);
return output;
}
void setup() {
Serial.begin(115200);
//pinMode(INTERRUPT, INPUT);
pinMode(READ, OUTPUT);
pinMode(WRITE, OUTPUT);
digitalWrite(READ, HIGH);
digitalWrite(WRITE, HIGH);
DDRB |= Ad0;
portWrite(RESET_ALL, COMMAND);
delay(50);
portWrite(GET_IC_VER, COMMAND);
Serial.print("Device ID: ");
Serial.println(portRead(DATA), HEX);
portWrite(CHECK_EXIST, COMMAND);
portWrite(~0x42, DATA);
Serial.print("Check: ");
Serial.println(portRead(DATA), HEX);
}
void loop() {
// put your main code here, to run repeatedly:
}
I'm running it in parallel mode, with D2-D7 on the chip going to Arduino pins D2-D7, and D0-D1 on the chip going to Arduino pins D8-D9. The rest of the pins are specified in the #define statements.
I guess I'll have to order a CH376 now.
RE the pinout - I think my pinout is still correct, the TXD pin doubles as a switch between Serial and Parallel modes.