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 Mudassar Hussain

Committer:
euygun
Date:
Tue Sep 26 15:41:17 2017 +0000
Revision:
2:c95852ac6953
Parent:
1:e11c75d931b5
Child:
3:b9051f3f2fcd
Fixing the missing code in the previous commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
euygun 0:25fcf12b0ba2 1 /* mbed Microcontroller Library
euygun 0:25fcf12b0ba2 2 * Copyright (c) 2017 u-blox
euygun 0:25fcf12b0ba2 3 *
euygun 0:25fcf12b0ba2 4 * Licensed under the Apache License, Version 2.0 (the "License");
euygun 0:25fcf12b0ba2 5 * you may not use this file except in compliance with the License.
euygun 0:25fcf12b0ba2 6 * You may obtain a copy of the License at
euygun 0:25fcf12b0ba2 7 *
euygun 0:25fcf12b0ba2 8 * http://www.apache.org/licenses/LICENSE-2.0
euygun 0:25fcf12b0ba2 9 *
euygun 0:25fcf12b0ba2 10 * Unless required by applicable law or agreed to in writing, software
euygun 0:25fcf12b0ba2 11 * distributed under the License is distributed on an "AS IS" BASIS,
euygun 0:25fcf12b0ba2 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
euygun 0:25fcf12b0ba2 13 * See the License for the specific language governing permissions and
euygun 0:25fcf12b0ba2 14 * limitations under the License.
euygun 0:25fcf12b0ba2 15 */
euygun 0:25fcf12b0ba2 16
euygun 0:25fcf12b0ba2 17 #include "mbed.h"
euygun 2:c95852ac6953 18 #include "battery_charger_bq24295.h"
euygun 0:25fcf12b0ba2 19 #include "UbloxCellularDriverGen.h"
euygun 0:25fcf12b0ba2 20 #include "onboard_modem_api.h"
euygun 0:25fcf12b0ba2 21
euygun 2:c95852ac6953 22 // Set the minimum input voltage limit for the BQ24295 to 3.8 Volt
euygun 2:c95852ac6953 23 #define MIN_INPUT_VOLTAGE_LIMIT_MV 3880
euygun 2:c95852ac6953 24
euygun 0:25fcf12b0ba2 25 // User LEDs
euygun 0:25fcf12b0ba2 26 DigitalOut ledRed(LED1, 1);
euygun 0:25fcf12b0ba2 27 DigitalOut ledGreen(LED2, 1);
euygun 0:25fcf12b0ba2 28 DigitalOut ledBlue(LED3, 1);
euygun 0:25fcf12b0ba2 29
euygun 0:25fcf12b0ba2 30 // Ethernet socket LED
euygun 0:25fcf12b0ba2 31 DigitalOut ledYellow(LED4,1);
euygun 0:25fcf12b0ba2 32
euygun 0:25fcf12b0ba2 33 // User Button
euygun 0:25fcf12b0ba2 34 #ifdef TARGET_UBLOX_C027
euygun 0:25fcf12b0ba2 35 // No user button on C027
euygun 0:25fcf12b0ba2 36 InterruptIn userButton(NC);
euygun 0:25fcf12b0ba2 37 #else
euygun 0:25fcf12b0ba2 38 InterruptIn userButton(SW0);
euygun 0:25fcf12b0ba2 39 #endif
euygun 0:25fcf12b0ba2 40
euygun 2:c95852ac6953 41 // i2c3 Bus
euygun 2:c95852ac6953 42 I2C i2c3(I2C_SDA_B, I2C_SCL_B);
euygun 2:c95852ac6953 43
euygun 2:c95852ac6953 44 // Battery Charger BQ24295
euygun 2:c95852ac6953 45 BatteryChargerBq24295 charger;
euygun 2:c95852ac6953 46
euygun 0:25fcf12b0ba2 47 // Delay between LED changes in second
euygun 0:25fcf12b0ba2 48 volatile float delay = 0.5;
euygun 0:25fcf12b0ba2 49
euygun 1:e11c75d931b5 50 // To check if the user pressed the User Button or not
euygun 0:25fcf12b0ba2 51 void threadBodyUserButtonCheck(void const *args){
euygun 0:25fcf12b0ba2 52 float delayToggle = delay;
euygun 0:25fcf12b0ba2 53 while (1){
euygun 0:25fcf12b0ba2 54 if (userButton.read() == 1 ) {
euygun 1:e11c75d931b5 55 // User Button is pressed
euygun 0:25fcf12b0ba2 56 delay = 0.1;
euygun 0:25fcf12b0ba2 57 //Indicate the button is pressed
euygun 0:25fcf12b0ba2 58 ledYellow = 0;
euygun 0:25fcf12b0ba2 59 }
euygun 0:25fcf12b0ba2 60 else {
euygun 1:e11c75d931b5 61 // User button is released
euygun 0:25fcf12b0ba2 62 delay = 0.5;
euygun 0:25fcf12b0ba2 63 //Turn off the Yellow LED on Ethernet socket
euygun 0:25fcf12b0ba2 64 ledYellow = 1;
euygun 0:25fcf12b0ba2 65 }
euygun 0:25fcf12b0ba2 66 }
euygun 0:25fcf12b0ba2 67 }
euygun 0:25fcf12b0ba2 68
euygun 0:25fcf12b0ba2 69 /*
euygun 0:25fcf12b0ba2 70 ** Out of the Box Demo for C030 variants
euygun 0:25fcf12b0ba2 71 **
euygun 0:25fcf12b0ba2 72 ** Sets the modem then
euygun 0:25fcf12b0ba2 73 */
euygun 0:25fcf12b0ba2 74
euygun 0:25fcf12b0ba2 75 int main()
euygun 0:25fcf12b0ba2 76 {
euygun 2:c95852ac6953 77 // The battery charger initialisation
euygun 2:c95852ac6953 78 charger.init(&i2c3);
euygun 2:c95852ac6953 79 charger.setInputVoltageLimit(MIN_INPUT_VOLTAGE_LIMIT_MV);
euygun 2:c95852ac6953 80 // Disable the battery charger's watchdog, otherwise it resets the battry charger
euygun 2:c95852ac6953 81 charger.setWatchdog(0);
euygun 2:c95852ac6953 82
euygun 1:e11c75d931b5 83 // Initialised the modem
euygun 0:25fcf12b0ba2 84 onboard_modem_init();
euygun 0:25fcf12b0ba2 85
euygun 1:e11c75d931b5 86 // Power up the modem
euygun 0:25fcf12b0ba2 87 onboard_modem_power_up();
euygun 0:25fcf12b0ba2 88
euygun 1:e11c75d931b5 89 // Create threadUserButtonCheck thread
euygun 0:25fcf12b0ba2 90 Thread threadUserButtonCheck(threadBodyUserButtonCheck);
euygun 0:25fcf12b0ba2 91
euygun 1:e11c75d931b5 92 // Set the LED states
euygun 0:25fcf12b0ba2 93 ledRed = 0;
euygun 0:25fcf12b0ba2 94 ledGreen = 1;
euygun 0:25fcf12b0ba2 95 ledBlue = 1;
euygun 0:25fcf12b0ba2 96
euygun 0:25fcf12b0ba2 97 printf("u-blox C030 Out-of-the-Box Demo\n\r");
euygun 0:25fcf12b0ba2 98
euygun 0:25fcf12b0ba2 99 //Main loop
euygun 0:25fcf12b0ba2 100 while(1) {
euygun 0:25fcf12b0ba2 101 wait(delay);
euygun 0:25fcf12b0ba2 102 //Shift the LED states
euygun 0:25fcf12b0ba2 103 int carry = ledBlue;
euygun 0:25fcf12b0ba2 104 ledBlue = ledRed;
euygun 0:25fcf12b0ba2 105 ledRed = ledGreen;
euygun 0:25fcf12b0ba2 106 ledGreen = carry;
euygun 0:25fcf12b0ba2 107 }
euygun 0:25fcf12b0ba2 108 }
euygun 0:25fcf12b0ba2 109
euygun 0:25fcf12b0ba2 110 // End Of File