![](/media/cache/profiles/795c7a7a5ec6b460ec00c5841019b9e9.jpg.50x50_q85.jpg)
SC16IS750 TX sample
Revision 1:40c636cb6d09, committed 2012-07-18
- Comitter:
- okano
- Date:
- Wed Jul 18 02:15:05 2012 +0000
- Parent:
- 0:41dffa1b3405
- Commit message:
- bridge test. initializing registers with RESTARTs
Changed in this revision
SC16IS750.lib | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SC16IS750.lib Wed Jul 18 02:15:05 2012 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/okano/code/SC16IS750/#d9a4b7a4a159
--- a/main.cpp Tue Jul 17 08:48:07 2012 +0000 +++ b/main.cpp Wed Jul 18 02:15:05 2012 +0000 @@ -1,102 +1,12 @@ -#include "mbed.h" - -I2C i2c( p28, p27 ); - +#include "mbed.h" +#include "SC16IS750.h" -enum { - RHR = 0x00 << 3, - THR = 0x00 << 3, - IER = 0x01 << 3, - FCR = 0x02 << 3, - IIR = 0x02 << 3, - LCR = 0x03 << 3, - MCR = 0x04 << 3, - LSR = 0x05 << 3, - MSR = 0x06 << 3, - SPR = 0x07 << 3, - TCR = 0x06 << 3, - TLR = 0x07 << 3, - TXLVL = 0x08 << 3, - RXLVL = 0x09 << 3, - IODir = 0x0A << 3, - IOState = 0x0B << 3, - IOIntEna = 0x0C << 3, - reserved = 0x0D << 3, - IOControl = 0x0E << 3, - EFCR = 0x0F << 3, - DLL = 0x00 << 3, - DLH = 0x01 << 3, - EFR = 0x02 << 3, - XON1 = 0x04 << 3, - XON2 = 0x05 << 3, - XOFF1 = 0x06 << 3, - XOFF2 = 0x07 << 3, -}; - -#define ADDR 0x9A -char three[] = { 0x03, 0xBF }; -char data[] = { 0x0A, 0xBF }; - -#define N_OF_ACCESS 8 - -char init[ N_OF_ACCESS ][ 2 ] = { - { LCR, 0x80 }, -#ifdef BAUD_115200 - { DLL, 0x0C }, - { DLH, 0x00 }, -#else - { DLL, 0x60 }, // 9600 baud - { DLH, 0x00 }, -#endif - { LCR, 0xBF }, - { EFR, 0x10 }, - { LCR, 0x03 }, - { IER, 0x00 }, - { FCR, 0x07 }, -}; - -char *txt_data = "\x0NXP Semiconductors"; - -void init_registers( void ); -void register_write( char address, char data ); -char register_read( char address ); +SC16IS750 bridge( p28, p27, 9600 ); // SDA, SCL, Baud(option), I2C_Address(option) int main() { - char r; - init_registers(); - -#ifdef SINGLE_TX_BUFFER_WRITES - txt_data++; - for ( int i = 0; i < 18; i++ ) - register_write( THR, *txt_data++ ); -#else - i2c.write( ADDR, txt_data, 19 ); -#endif - + bridge.send_str( "NXP Semiconductors" ); + while ( 1 ) ; } - -void init_registers( void ) { - for ( int i = 0; i < N_OF_ACCESS; i++ ) - i2c.write( ADDR, init[ i ], 2 ); -} - -void register_write( char address, char data ) { - char w[ 2 ]; - - w[ 0 ] = address; - w[ 1 ] = data; - - i2c.write( 0x9A, w, 2 ); -} - -char register_read( char address ) { - char r; - - i2c.write( 0x9A, &address, 1 ); - i2c.read( 0x9A, &r, 1 ); - - return ( r ); -}