From: Walter Fetter Lages Date: Fri, 1 Feb 2019 06:54:34 +0000 (-0200) Subject: Fix reset: Pull nRESET down and then up. X-Git-Tag: f1~9 X-Git-Url: http://git.ece.ufrgs.br/?a=commitdiff_plain;h=78bb9d10d6f98beb2b2574977c6699ff21234d70;p=bno055.git Fix reset: Pull nRESET down and then up. --- diff --git a/lib/bno055_tty.c b/lib/bno055_tty.c index 2e4847b..3a8c463 100644 --- a/lib/bno055_tty.c +++ b/lib/bno055_tty.c @@ -27,9 +27,20 @@ #include #include +#define BUFFER_LEN 128 + +#define BNO055_UART_START 0xaa +#define BNO055_UART_WRITE_CMD 0x00 +#define BNO055_UART_READ_CMD 0x01 +#define BNO055_UART_ACK 0xee +#define BNO055_UART_REPLY 0xbb + +#define BNO055_UART_SUCCESS 0x01 + s8 BNO055_tty_init(int fd,struct bno055_t *bno055) { struct termios tty; + int status; if(tcgetattr(fd,&tty)) return BNO055_ERROR; if(cfsetspeed(&tty,B115200)) return BNO055_OUT_OF_RANGE; @@ -38,8 +49,15 @@ s8 BNO055_tty_init(int fd,struct bno055_t *bno055) tty.c_cflag|=CLOCAL; if(tcsetattr(fd,TCSANOW,&tty)) return BNO055_ERROR; - int status=TIOCM_DTR | TIOCM_RTS; - ioctl(fd,TIOCMBIC,&status); + /* nRESET low*/ + status=TIOCM_DTR | TIOCM_RTS; + ioctl(fd,TIOCMBIS,&status); + usleep(1); + /* nRESET high */ + status=TIOCM_DTR | TIOCM_RTS; + ioctl(fd,TIOCMBIC,&status); + /* Wait BNO055 Power on Reset time */ + usleep(650000); bno055->bus_write=BNO055_tty_write; bno055->bus_read=BNO055_tty_read; @@ -49,16 +67,6 @@ s8 BNO055_tty_init(int fd,struct bno055_t *bno055) return BNO055_SUCCESS; } -#define BUFFER_LEN 128 - -#define BNO055_UART_START 0xaa -#define BNO055_UART_WRITE_CMD 0x00 -#define BNO055_UART_READ_CMD 0x01 -#define BNO055_UART_ACK 0xee -#define BNO055_UART_REPLY 0xbb - -#define BNO055_UART_SUCCESS 0x01 - s8 BNO055_tty_write(u8 dev_addr,u8 reg_addr,u8 *reg_data,u8 cnt) { u8 array[BUFFER_LEN];