Wim Huiskamp
/
SC16IS750_Test
Testsoftware for SC16IS750
main.cpp@0:d83a90125711, 2014-01-22 (annotated)
- Committer:
- wim
- Date:
- Wed Jan 22 16:40:03 2014 +0000
- Revision:
- 0:d83a90125711
- Child:
- 1:f0d3984f2586
First Test version for SPI UART Bridge
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
wim | 0:d83a90125711 | 1 | #include "mbed.h" |
wim | 0:d83a90125711 | 2 | #include "SC16IS750.h" |
wim | 0:d83a90125711 | 3 | |
wim | 0:d83a90125711 | 4 | //SPI Version |
wim | 0:d83a90125711 | 5 | SPI spi(PTD2, PTD3, PTD1); //MOSI, MISO, SCK |
wim | 0:d83a90125711 | 6 | //DigitalOut CS(PTD0); //CS |
wim | 0:d83a90125711 | 7 | SC16IS750_SPI serial_spi(&spi, PTD0); |
wim | 0:d83a90125711 | 8 | |
wim | 0:d83a90125711 | 9 | //I2C Version |
wim | 0:d83a90125711 | 10 | I2C i2c(PTE0, PTE1); //SDA, SCL |
wim | 0:d83a90125711 | 11 | SC16IS750_I2C serial_i2c(&i2c, DEFAULT_SC16IS750_ADDR); |
wim | 0:d83a90125711 | 12 | |
wim | 0:d83a90125711 | 13 | DigitalOut myled1(LED_RED); |
wim | 0:d83a90125711 | 14 | DigitalOut myled2(LED_GREEN); |
wim | 0:d83a90125711 | 15 | //DigitalOut myled3(LED_BLUE); //same as PTD1 (SCK) |
wim | 0:d83a90125711 | 16 | |
wim | 0:d83a90125711 | 17 | Serial pc(USBTX,USBRX); |
wim | 0:d83a90125711 | 18 | |
wim | 0:d83a90125711 | 19 | int main() { |
wim | 0:d83a90125711 | 20 | pc.printf("\nHello World!\n"); |
wim | 0:d83a90125711 | 21 | |
wim | 0:d83a90125711 | 22 | myled1 = 1; // LED Off |
wim | 0:d83a90125711 | 23 | // CS = 1; |
wim | 0:d83a90125711 | 24 | |
wim | 0:d83a90125711 | 25 | spi.format(8, 0); |
wim | 0:d83a90125711 | 26 | // spi.frequency(100000); |
wim | 0:d83a90125711 | 27 | // spi.frequency(500000); |
wim | 0:d83a90125711 | 28 | spi.frequency(1000000); |
wim | 0:d83a90125711 | 29 | // spi.frequency(1500000); |
wim | 0:d83a90125711 | 30 | |
wim | 0:d83a90125711 | 31 | while(1) { |
wim | 0:d83a90125711 | 32 | // serial_spi.writeRegister(SC16IS750::IODIR, 0x81); // direct call to new method |
wim | 0:d83a90125711 | 33 | |
wim | 0:d83a90125711 | 34 | serial_spi.ioSetState(0x00); // indirect call to new method |
wim | 0:d83a90125711 | 35 | // wait(0.5); |
wim | 0:d83a90125711 | 36 | pc.putc('*'); |
wim | 0:d83a90125711 | 37 | } |
wim | 0:d83a90125711 | 38 | |
wim | 0:d83a90125711 | 39 | |
wim | 0:d83a90125711 | 40 | #if(0) |
wim | 0:d83a90125711 | 41 | while(1) { |
wim | 0:d83a90125711 | 42 | CS=0; |
wim | 0:d83a90125711 | 43 | spi.write(0xAA); |
wim | 0:d83a90125711 | 44 | spi.write(0x81); |
wim | 0:d83a90125711 | 45 | CS=1; |
wim | 0:d83a90125711 | 46 | wait_us(5); |
wim | 0:d83a90125711 | 47 | } |
wim | 0:d83a90125711 | 48 | #endif |
wim | 0:d83a90125711 | 49 | |
wim | 0:d83a90125711 | 50 | pc.printf("\nBye World!\n"); |
wim | 0:d83a90125711 | 51 | } |