-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathix03.h
79 lines (71 loc) · 1.84 KB
/
ix03.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#pragma once
// #include <Arduino.h>
// #include <Wire.h>
#include <inttypes.h>
#include "pxt.h"
// #ifdef ESP32 | ESP8266
// #include <stdlib_noniso.h>
// #else
// #include <avr/dtostrf.h>
// #endif
#define SC16IS740_RHR 0x00
#define SC16IS740_THR 0x00
#define SC16IS740_IER 0x01
#define SC16IS740_FCR 0x02
#define SC16IS740_IIR 0x02
#define SC16IS740_LCR 0x03
#define SC16IS740_MCR 0x04
#define SC16IS740_LSR 0x05
#define SC16IS740_MSR 0x06
#define SC16IS740_SPR 0x07
#define SC16IS740_TCR 0x06
#define SC16IS740_TLR 0x07
#define SC16IS740_TXLVL 0x08
#define SC16IS740_RXLVL 0x09
#define SC16IS740_IODIR 0x0A
#define SC16IS740_IOSTATE 0x0B
#define SC16IS740_IOINTENA 0x0C
#define SC16IS740_RESERVED 0x0D
#define SC16IS740_IOCONTROL 0x0E
#define SC16IS740_EFCR 0x0F
#define SC16IS740_DLL 0x00
#define SC16IS740_DLH 0x01
#define SC16IS740_EFR 0x02
#define SC16IS740_XON1 0x04
#define SC16IS740_XON2 0x05
#define SC16IS740_XOFF1 0x06
#define SC16IS740_XOFF2 0x07
#define SC16IS740_I2C_ADDR 0x4D
#define DEC 1
#define OUTPUT 1
#define HIGH 1
class xIX03
{
public:
xIX03();
xIX03(uint8_t addr);
bool begin(uint16_t baudRate);
uint8_t available();
uint8_t availableForWrite();
void end();
void flush();
void config();
uint8_t read();
void pinMode(uint8_t pin, uint8_t mode);
void digitalWrite(uint8_t pin, uint8_t state);
bool digitalRead(uint8_t pin);
void write(uint8_t);
void write(const char *str);
void write(const uint8_t *buffer, uint8_t size);
void write(const char *buffer, uint8_t size);
private:
bool readLSR();
void setBaudRate(uint16_t baudRate);
void resetDevice();
bool ping();
void FIFOEnable(uint8_t fifo_enable);
uint8_t i2cAddr;
void writeByte(uint8_t reg, uint8_t val);
uint8_t readByte(uint8_t reg);
void writeBlock(uint8_t reg, uint8_t *val, uint8_t len);
};