standalone sx1276 demo program

Dependencies:   SX1276Lib mbed

Fork of SX1276_GPS by CaryCoders

Committer:
vtraveller
Date:
Sat Aug 02 11:00:33 2014 +0000
Revision:
1:45e2e7c0754d
Parent:
0:88d87b1c1f8b
Child:
2:ac3b92ebf17a
Working flash test

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wim 0:88d87b1c1f8b 1 #include "mbed.h"
wim 0:88d87b1c1f8b 2 #include "MCP23017.h"
wim 0:88d87b1c1f8b 3
wim 0:88d87b1c1f8b 4 DigitalOut myled1(LED1);
wim 0:88d87b1c1f8b 5 DigitalOut myled2(LED2);
wim 0:88d87b1c1f8b 6
wim 0:88d87b1c1f8b 7 Serial pc(USBTX, USBRX);
vtraveller 1:45e2e7c0754d 8 I2C i2c(I2C_SDA, I2C_SCL);
wim 0:88d87b1c1f8b 9
wim 0:88d87b1c1f8b 10 MCP23017 mcp23017 = MCP23017(i2c, 0x40);
wim 0:88d87b1c1f8b 11
wim 0:88d87b1c1f8b 12 int main() {
wim 0:88d87b1c1f8b 13
vtraveller 1:45e2e7c0754d 14 pc.printf("Hello World\n\r");
wim 0:88d87b1c1f8b 15
wim 0:88d87b1c1f8b 16 // I2C init
vtraveller 1:45e2e7c0754d 17 i2c.frequency(400000);
wim 0:88d87b1c1f8b 18
wim 0:88d87b1c1f8b 19 // Port A is databus - Output
wim 0:88d87b1c1f8b 20 mcp23017.direction(PORT_A, PORT_DIR_OUT);
wim 0:88d87b1c1f8b 21 // Port B is controlbus - Output
wim 0:88d87b1c1f8b 22 mcp23017.direction(PORT_B, PORT_DIR_OUT);
wim 0:88d87b1c1f8b 23
wim 0:88d87b1c1f8b 24 myled2 = 1;
vtraveller 1:45e2e7c0754d 25 pc.printf("MPC Init done\n\r");
wim 0:88d87b1c1f8b 26
wim 0:88d87b1c1f8b 27 while(1) {
wim 0:88d87b1c1f8b 28 myled1 = 1;
wim 0:88d87b1c1f8b 29 mcp23017.write(PORT_A, 0xFF);
wim 0:88d87b1c1f8b 30 mcp23017.write(PORT_B, 0xFF);
wim 0:88d87b1c1f8b 31 wait(0.2);
wim 0:88d87b1c1f8b 32
wim 0:88d87b1c1f8b 33 myled1 = 0;
wim 0:88d87b1c1f8b 34 mcp23017.write(PORT_A, 0x00);
wim 0:88d87b1c1f8b 35 mcp23017.write(PORT_B, 0x00);
wim 0:88d87b1c1f8b 36 wait(0.2);
wim 0:88d87b1c1f8b 37 pc.printf("*");
wim 0:88d87b1c1f8b 38 }
wim 0:88d87b1c1f8b 39 }