CaryCoders
/
demo_SX1276_standalone
standalone sx1276 demo program
Fork of SX1276_GPS by
main.cpp@0:88d87b1c1f8b, 2010-12-18 (annotated)
- Committer:
- wim
- Date:
- Sat Dec 18 19:44:49 2010 +0000
- Revision:
- 0:88d87b1c1f8b
- Child:
- 1:45e2e7c0754d
Initial version
Who changed what in which revision?
User | Revision | Line number | New 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); |
wim | 0:88d87b1c1f8b | 8 | I2C i2c(p9, p10); |
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 | |
wim | 0:88d87b1c1f8b | 14 | pc.printf("Hello World\n"); |
wim | 0:88d87b1c1f8b | 15 | |
wim | 0:88d87b1c1f8b | 16 | // I2C init |
wim | 0:88d87b1c1f8b | 17 | i2c.frequency(100000); |
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; |
wim | 0:88d87b1c1f8b | 25 | pc.printf("MPC Init done\n"); |
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 | } |