No reply form CR95HF over UART interface.
We have designed a motherboard based on the NXP imx8 processor family running linux, and added the CR95HF chip on board connected to MCU over UART interface.
We have been successful in sending data in the form of 0x00 (LOW level pulse on IRQ_IN/RX), wait for 110ms and then send echo 0x55, measured on ocilloscope, however we have not yet received any data back from the chip, eg. no response.
See code and schematics below. Our main code just runs cr95fh_init() then cr95hf_idn() once before terminating.
#include "cr95hf.h"
int cr95hf_init(void) {
printf("Before open\n");
fd = open(CR95HF_PORT, O_RDWR | O_NOCTTY | O_SYNC);
printf("After open\n");
if(fd < 0) {
printf("Could not open %s\n", CR95HF_PORT);
return -1;
}
return CR95HF_SET_INTERFACE(B57600);
}
int CR95HF_SET_INTERFACE(int speed) {
printf("Setting interface\n");
struct termios tty;
if(tcgetattr(fd, &tty)) {
printf("Error from tcgetattr: %s\n", strerror(errno));
return -1;
}
printf("Setting baud speed\n");
//Set baud
cfsetospeed(&tty, (speed_t)speed);
cfsetispeed(&tty, (speed_t)speed);
printf("Setting c flags\n");
// Flags
tty.c_cflag |= (CLOCAL | CREAD);
tty.c_cflag &= ~CSIZE;
tty.c_cflag |= CS8;
tty.c_cflag &= ~PARENB;
tty.c_cflag &= ~CSTOPB;
tty.c_cflag &= ~CRTSCTS;
printf("Setting l flags\n");
tty.c_lflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON);
tty.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
printf("Setting cc flags\n");
tty.c_cc[VMIN] = 1;
tty.c_cc[VTIME] = 1;
if(tcsetattr(fd, TCSANOW, &tty) != 0) {
printf("Error from tcsetattr: %s\n", strerror(errno));
return -1;
}
printf("Port is open..\n");
usleep(10000);
unsigned char start[] = {0x00};
wlen = write(fd, start, sizeof(start));
usleep(110000);
return 0;
}
void cr95hf_idn(void) {
unsigned char snd1[] = {0x55};
printf("Sending...\n");
wlen = write(fd, snd1, sizeof(snd1));
usleep(2000);
close(fd);
}
