
This is an example program that shows how to use the RadioHeadLite library, and does it using threads.
Dependencies: RadioHeadLite
Revision 0:f4015c8e84c3, committed 2018-11-24
- Comitter:
- rlanders73
- Date:
- Sat Nov 24 05:53:37 2018 +0000
- Child:
- 1:75d533f15c95
- Commit message:
- added modem stuff to form "blinky"
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.gitignore Sat Nov 24 05:53:37 2018 +0000 @@ -0,0 +1,4 @@ +.build +.mbed +projectfiles +*.py*
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/README.md Sat Nov 24 05:53:37 2018 +0000 @@ -0,0 +1,37 @@ +# Getting started with the Geneva platform example + +This guide reviews the steps required to get Blinky working on an mbed OS platform. + +Please install [mbed CLI](https://github.com/ARMmbed/mbed-cli#installing-mbed-cli). + +## Import the example application + +From the command-line, import the example: + +``` +mbed import mbed-os-example-blinky +cd mbed-os-example-blinky +``` + +### Now compile + +Invoke `mbed compile`, and specify the name of your platform and your favorite toolchain (`GCC_ARM`, `ARM`, `IAR`). For example, for the ARM Compiler 5: + +``` +mbed compile -m Geneva_R210 -t ARM +``` + +Your PC may take a few minutes to compile your code. +``` + +### Program your board + +1. Connect your Geneva module to the computer over USB. +2. Use the Geneva loader to load teh new binary to the module + +The LED on your module turns on and off. +You should be able to open a terminal program and be able to talk to the modem. + +## Troubleshooting + +If you have problems, you can review the [documentation](https://os.mbed.com/docs/latest/tutorials/debugging.html) for suggestions on what could be wrong and how to fix it.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/USBDevice.lib Sat Nov 24 05:53:37 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/teams/PointLabs/code/USBDeviceSTM32L476/#3d21c913753e
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/geneva-lib.lib Sat Nov 24 05:53:37 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/teams/PointLabs/code/geneva-lib/#72798cdc8d57
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Nov 24 05:53:37 2018 +0000 @@ -0,0 +1,204 @@ +#include "mbed.h" +#include "USBSerial.h" +#include "Geneva.h" + +#define PASSTHROUGH 1 + +/******************** Comms *********************/ +USBSerial pc; // moved the pc interface to the USB serial device +Serial modemSerial(MDMTXD, MDMRXD, 115200); + + +DigitalInOut cellRst(MDMRST); +DigitalInOut cellPwrKey(MDMPWRON); +DigitalOut cellVcc(MDMVCC, 0); +DigitalOut cellRts(MDMRTS, 0); // Flow control not supported by 410, but RTS must be low +DigitalOut cellCts(MDMCTS, 0); + +DigitalOut gpsEn(PC_3, 0); +DigitalOut bleRst(PB_5, 0); + +DigitalOut greenLed(LED_GREEN, 1); +DigitalOut blueLed(LED_BLUE, 1); +DigitalOut redLed(LED_RED, 1); + +InterruptIn buttonInt(USER_BUTTON); + +InterruptIn *rxPin; +DigitalOut samplePin(PA_0); + +Thread passThread; + + static char scanBuffer[512]; +static bool buttonWasPushed = false; + +typedef struct +{ + DigitalOut *resetPin; + DigitalOut *enablePin; + DigitalOut *dtrPin; + FileHandle *fileHandle; + ATCmdParser *rawParser; + UARTSerial *serial; +} cellContext_t; + +cellContext_t cell; + +uint8_t buffer[64]; + +#if PASSTHROUGH +static void passthroughThread(void) +{ + + while (1) + { + // Housekeeping - check button + if (pc.readable()) + { + char c = pc.getc(); // grab the available character + pc.putc(c); // provide local echo + modemSerial.putc(c);// push the charcter to the modem + } + + if (modemSerial.readable()) + { + pc.putc(modemSerial.getc()); + } + } +} +#endif + +static void buttonPushed(void) +{ + buttonWasPushed = true; +} + + + + +int main(void) +{ + // Enable flow control on MDM uart + //modemUartSerial.set_flow_control(SerialBase::RTSCTS, MDMRTS, MDMCTS); + + buttonInt.mode(PullUp); + buttonInt.fall(buttonPushed); + + cellRst.mode(OpenDrainNoPull); + cellRst.output(); + cellRst = 1; + + cellPwrKey.mode(OpenDrainNoPull); + cellPwrKey.output(); + cellPwrKey = 1; + + wait(1); // wait just a bit for the USB to enumerate + + pc.printf("Modem Test\r\n", 12); + + pc.set_blocking(false); + modemSerial.set_blocking(false); + + // Power up the modem! + cellVcc = 1; + pc.printf("Modem VCC UP\r\n", 14); + wait(3); + + cellPwrKey = 0; + wait(0.9); + cellPwrKey = 1; + pc.printf("Modem Power\r\n", 13); + + redLed = 0; + + wait(5); + +#if PASSTHROUGH + pc.printf("Passthrough mode\r\n", 18); + blueLed = 0; + passThread.start(passthroughThread); + +#else + pc.printf("Auto mode\r\n", 11); + + cell.fileHandle = &modemUartSerial; + cell.rawParser = new ATCmdParser(cell.fileHandle); + cell.rawParser->flush(); + cell.rawParser->debug_on(1); + cell.rawParser->set_timeout(2000); + + while (1) + { + cell.rawParser->send("AT"); + if (cell.rawParser->recv("OK")) + break; + wait(1.5); + } + + redLed = 1; + blueLed = 0; + pc.printf("Modem OK\r\n"); + wait(5); + + cell.rawParser->set_timeout(15000); + + while (1) + { + cell.rawParser->send("AT+CCID"); + if (cell.rawParser->recv("OK")) + { + break; + } + wait(4.5); + } + + blueLed = 1; + greenLed = 0; + pc.printf("SIM OK\r\n"); + wait(2); + + int act; + char plmn[8]; + bool result; + + cell.rawParser->set_timeout(20000); + cell.rawParser->send("AT+CMEE=2") && cell.rawParser->recv("OK"); + + while (1) + { + cell.rawParser->send("AT+COPS?"); + result = cell.rawParser->recv("+COPS: %[^\n]\nOK\n", scanBuffer); + if (true == result) + { + // Parse the registration status + if (sscanf(scanBuffer, "%*d, %*d, \"%[^\"]\", %d", plmn, &act) == 2) + { + if (act == 8) + break; + } + } + wait(3); + } + + pc.printf("Network OK\r\n"); + + while (1) + { + greenLed = 1; + wait(0.75); + greenLed = 0; + wait(0.75); + if (buttonWasPushed) + break; + } + + cell.rawParser->send("AT+COPS=2") && cell.rawParser->recv("OK"); + +#endif + + Thread::wait(osWaitForever); + + return 1; +} + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-os.lib Sat Nov 24 05:53:37 2018 +0000 @@ -0,0 +1,1 @@ +https://github.com/ARMmbed/mbed-os/#2fd0c5cfbd83fce62da6308f9d64c0ab64e1f0d6