for SC16IS750 test program. Confirming register access method
SC16IS750.h@0:bae17cf3178e, 2012-07-18 (annotated)
- Committer:
- okano
- Date:
- Wed Jul 18 01:24:33 2012 +0000
- Revision:
- 0:bae17cf3178e
- Child:
- 1:d9a4b7a4a159
re-written in C++ style
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
okano | 0:bae17cf3178e | 1 | #ifndef MBED_SC16IS750 |
okano | 0:bae17cf3178e | 2 | #define MBED_SC16IS750 |
okano | 0:bae17cf3178e | 3 | |
okano | 0:bae17cf3178e | 4 | |
okano | 0:bae17cf3178e | 5 | #define DEFAULT_SC16IS750_ADDR 0x9A |
okano | 0:bae17cf3178e | 6 | #define DEFAULT_BAUD_RATE 9600 |
okano | 0:bae17cf3178e | 7 | |
okano | 0:bae17cf3178e | 8 | class SC16IS750 { |
okano | 0:bae17cf3178e | 9 | public: |
okano | 0:bae17cf3178e | 10 | |
okano | 0:bae17cf3178e | 11 | typedef enum { |
okano | 0:bae17cf3178e | 12 | RHR = 0x00 << 3, |
okano | 0:bae17cf3178e | 13 | THR = 0x00 << 3, |
okano | 0:bae17cf3178e | 14 | IER = 0x01 << 3, |
okano | 0:bae17cf3178e | 15 | FCR = 0x02 << 3, |
okano | 0:bae17cf3178e | 16 | IIR = 0x02 << 3, |
okano | 0:bae17cf3178e | 17 | LCR = 0x03 << 3, |
okano | 0:bae17cf3178e | 18 | MCR = 0x04 << 3, |
okano | 0:bae17cf3178e | 19 | LSR = 0x05 << 3, |
okano | 0:bae17cf3178e | 20 | MSR = 0x06 << 3, |
okano | 0:bae17cf3178e | 21 | SPR = 0x07 << 3, |
okano | 0:bae17cf3178e | 22 | TCR = 0x06 << 3, |
okano | 0:bae17cf3178e | 23 | TLR = 0x07 << 3, |
okano | 0:bae17cf3178e | 24 | TXLVL = 0x08 << 3, |
okano | 0:bae17cf3178e | 25 | RXLVL = 0x09 << 3, |
okano | 0:bae17cf3178e | 26 | IODir = 0x0A << 3, |
okano | 0:bae17cf3178e | 27 | IOState = 0x0B << 3, |
okano | 0:bae17cf3178e | 28 | IOIntEna = 0x0C << 3, |
okano | 0:bae17cf3178e | 29 | reserved = 0x0D << 3, |
okano | 0:bae17cf3178e | 30 | IOControl = 0x0E << 3, |
okano | 0:bae17cf3178e | 31 | EFCR = 0x0F << 3, |
okano | 0:bae17cf3178e | 32 | DLL = 0x00 << 3, |
okano | 0:bae17cf3178e | 33 | DLH = 0x01 << 3, |
okano | 0:bae17cf3178e | 34 | EFR = 0x02 << 3, |
okano | 0:bae17cf3178e | 35 | XON1 = 0x04 << 3, |
okano | 0:bae17cf3178e | 36 | XON2 = 0x05 << 3, |
okano | 0:bae17cf3178e | 37 | XOFF1 = 0x06 << 3, |
okano | 0:bae17cf3178e | 38 | XOFF2 = 0x07 << 3, |
okano | 0:bae17cf3178e | 39 | } RegisterName; |
okano | 0:bae17cf3178e | 40 | |
okano | 0:bae17cf3178e | 41 | SC16IS750( |
okano | 0:bae17cf3178e | 42 | PinName I2C_sda, |
okano | 0:bae17cf3178e | 43 | PinName I2C_scl, |
okano | 0:bae17cf3178e | 44 | int baud_rate = DEFAULT_BAUD_RATE, |
okano | 0:bae17cf3178e | 45 | char I2C_address = DEFAULT_SC16IS750_ADDR |
okano | 0:bae17cf3178e | 46 | ); |
okano | 0:bae17cf3178e | 47 | |
okano | 0:bae17cf3178e | 48 | void init_registers( void ); |
okano | 0:bae17cf3178e | 49 | void set_baud( int ); |
okano | 0:bae17cf3178e | 50 | void send_str( char *s ); |
okano | 0:bae17cf3178e | 51 | void register_write( char register_address, char data ); |
okano | 0:bae17cf3178e | 52 | char register_read( char register_address ); |
okano | 0:bae17cf3178e | 53 | |
okano | 0:bae17cf3178e | 54 | private: |
okano | 0:bae17cf3178e | 55 | I2C i2c; |
okano | 0:bae17cf3178e | 56 | int baud_rate; |
okano | 0:bae17cf3178e | 57 | char i2c_addr; |
okano | 0:bae17cf3178e | 58 | }; |
okano | 0:bae17cf3178e | 59 | |
okano | 0:bae17cf3178e | 60 | #endif // MBED_SC16IS750 |