Cellular module AT Serial interface passthrough to Debug COM port. This program can be used on the C030 boards excluding the C030 N2xx version.
main.cpp
- Committer:
- fahimalavi
- Date:
- 2019-08-30
- Revision:
- 6:886ffd0f05fd
- Parent:
- 1:f39e92fcdf5e
File content as of revision 6:886ffd0f05fd:
/* mbed Microcontroller Library * Copyright (c) 2017 u-blox * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* The example program for the u-blox C030 boards. It sets up * - the GNSS module for automatic fix * - the I2C3 Bus to access bq27441 Battery Charger * - the bq27441 Battery Charger. * */ #include "mbed.h" #include "gnss.h" #include "battery_gauge_bq27441.h" #include "UbloxCellularDriverGen.h" #include "onboard_modem_api.h" // Set the Baudrate for mcu(pc) and modem(dev) #define BAUDRATE 115200 // Set the minimum input voltage limit for the bq27441 to 3.8 Volt #define MIN_INPUT_VOLTAGE_LIMIT_MV 3880 // User LEDs DigitalOut ledRed(LED1, 1); DigitalOut ledGreen(LED2, 1); DigitalOut ledBlue(LED3, 1); // Ethernet socket LED DigitalOut ledYellow(LED4,1); // User Button #ifdef TARGET_UBLOX_C027 // No user button on C027 InterruptIn userButton(NC); #else InterruptIn userButton(SW0); #endif // GNSS GnssSerial gnss; // i2c3 Bus I2C i2c3(I2C_SDA_B, I2C_SCL_B); // Battery Charger bq27441 BatteryGaugeBq27441 charger; RawSerial pc(PD_5, PD_6); RawSerial dev(PA_9, PA_10); // Delay between LED changes in second volatile float delay = 0.5; // To check if the user pressed the User Button or not void threadBodyUserButtonCheck(void const *args){ float delayToggle = delay; while (1){ if (userButton.read() == 1 ) { // User Button is pressed delay = 0.1; // Indicate with the Yellow LED on Ethernet socket ledYellow = 0; } else { // User button is released delay = 0.5; // Turn off the Yellow LED on Ethernet socket ledYellow = 1; } } } void dev_recv() { while(dev.readable()) { pc.putc(dev.getc()); } } void pc_recv() { while(pc.readable()) { dev.putc(pc.getc()); } } /* ** Out of the Box Demo for C030 variants ** */ int main() { printf("u-blox C030-R410M Bring-up baseline using Out-of-the-Box Demo\n\r"); // GNSS initialisation if(gnss.init()) { printf("GNSS initialized.\n\r"); } else { printf("GNSS initialization failure.\n\r"); } // The battery charger initialisation if(charger.init(&i2c3)) { printf("Battery charger initialized.\n\r"); } else { printf("Battery charger initialization failure.\n\r"); } printf("\n\r"); // The modem initialisation onboard_modem_init(); // Power up the modem onboard_modem_power_up(); // Create threadUserButtonCheck thread Thread threadUserButtonCheck(threadBodyUserButtonCheck); // Set the LED states ledRed = 0; ledGreen = 1; ledBlue = 1; pc.baud(BAUDRATE); dev.baud(BAUDRATE); pc.attach(&pc_recv, Serial::RxIrq); dev.attach(&dev_recv, Serial::RxIrq); // Main loop while(1) { wait(delay); // Shift the LED states int carry = ledBlue; ledBlue = ledRed; ledRed = ledGreen; ledGreen = carry; } } // End Of File