Checking for unnecessary added libraries.
Dependencies: battery-charger-bq24295 gnss ublox-cellular-base ublox-cellular-driver-gen
Fork of example-C030-out-of-box-demo by
main.cpp
00001 /* mbed Microcontroller Library 00002 * Copyright (c) 2017 u-blox 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #include "mbed.h" 00018 #include "gnss.h" 00019 #include "battery_charger_bq24295.h" 00020 #include "onboard_modem_api.h" 00021 00022 // Set the minimum input voltage limit for the BQ24295 to 3.8 Volt 00023 #define MIN_INPUT_VOLTAGE_LIMIT_MV 3880 00024 00025 // User LEDs 00026 DigitalOut ledRed(LED1, 1); 00027 DigitalOut ledGreen(LED2, 1); 00028 DigitalOut ledBlue(LED3, 1); 00029 00030 //GNSS 1V8_MAX IO power 00031 DigitalOut GNSSOn(GNSSEN, 1); 00032 00033 // Ethernet socket LED 00034 DigitalOut ledYellow(LED4,1); 00035 00036 // User Button 00037 #ifdef TARGET_UBLOX_C027 00038 // No user button on C027 00039 InterruptIn userButton(NC); 00040 #else 00041 InterruptIn userButton(SW0); 00042 #endif 00043 00044 // GNSS 00045 GnssSerial gnss; 00046 00047 // i2c3 Bus 00048 I2C i2c3(I2C_SDA_B, I2C_SCL_B); 00049 00050 // Battery Charger BQ24295 00051 BatteryChargerBq24295 charger; 00052 00053 // Delay between LED changes in second 00054 volatile float delay = 0.5; 00055 00056 // To check if the user pressed the User Button or not 00057 void threadBodyUserButtonCheck(void const *args){ 00058 while (1){ 00059 if (userButton.read() == 1 ) { 00060 // User Button is pressed 00061 delay = 0.1; 00062 //Indicate the button is pressed 00063 ledYellow = 0; 00064 } 00065 else { 00066 // User button is released 00067 delay = 0.5; 00068 //Turn off the Yellow LED on Ethernet socket 00069 ledYellow = 1; 00070 } 00071 } 00072 } 00073 00074 /* 00075 ** Out of the Box Demo for C030 variants 00076 ** 00077 ** Sets the modem then 00078 */ 00079 00080 int main() 00081 { 00082 printf("u-blox C030 Out-of-the-Box Demo\n\r"); 00083 00084 // GNSS initialisation 00085 if(gnss.init()) { 00086 printf("GNSS initialised.\n\r"); 00087 } 00088 else { 00089 printf("GNSS initialisation failure.\n\r"); 00090 } 00091 00092 // The battery charger initialisation 00093 charger.init(&i2c3); 00094 charger.setInputVoltageLimit(MIN_INPUT_VOLTAGE_LIMIT_MV); 00095 // Disable the battery charger's watchdog, otherwise it resets the battry charger 00096 charger.setWatchdog(0); 00097 00098 // Initialised the modem 00099 onboard_modem_init(); 00100 00101 // Power up the modem 00102 onboard_modem_power_up(); 00103 00104 // Create threadUserButtonCheck thread 00105 Thread user_button(osPriorityNormal); 00106 user_button.start(callback(threadBodyUserButtonCheck, (void *)"User Button Thread")); 00107 00108 00109 //Set GNSS IO On 00110 GNSSOn = 1; 00111 00112 // Set the LED states 00113 ledRed = 0; 00114 ledGreen = 1; 00115 ledBlue = 1; 00116 00117 printf("u-blox C030 Out-of-the-Box Demo: LED loop\n\r"); 00118 00119 //Main loop 00120 while(1) { 00121 wait(delay); 00122 //Shift the LED states 00123 int carry = ledBlue; 00124 ledBlue = ledRed; 00125 ledRed = ledGreen; 00126 ledGreen = carry; 00127 } 00128 } 00129 00130 // End Of File
Generated on Thu Jul 14 2022 18:14:26 by 1.7.2