x
Dependencies: gnss battery-charger-bq24295
main.cpp@1:e11c75d931b5, 2017-09-26 (annotated)
- Committer:
- euygun
- Date:
- Tue Sep 26 14:49:17 2017 +0000
- Revision:
- 1:e11c75d931b5
- Parent:
- 0:25fcf12b0ba2
- Child:
- 2:c95852ac6953
Added I2C3 Bus initialization; Added the battery charger BQ24295 initialization; Set minimum input voltage level for the battery charger to 3.88 Volt
Who changed what in which revision?
User | Revision | Line number | New 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 | 0:25fcf12b0ba2 | 18 | #include "UbloxCellularDriverGen.h" |
euygun | 0:25fcf12b0ba2 | 19 | #include "onboard_modem_api.h" |
euygun | 0:25fcf12b0ba2 | 20 | |
euygun | 0:25fcf12b0ba2 | 21 | // User LEDs |
euygun | 0:25fcf12b0ba2 | 22 | DigitalOut ledRed(LED1, 1); |
euygun | 0:25fcf12b0ba2 | 23 | DigitalOut ledGreen(LED2, 1); |
euygun | 0:25fcf12b0ba2 | 24 | DigitalOut ledBlue(LED3, 1); |
euygun | 0:25fcf12b0ba2 | 25 | |
euygun | 0:25fcf12b0ba2 | 26 | // Ethernet socket LED |
euygun | 0:25fcf12b0ba2 | 27 | DigitalOut ledYellow(LED4,1); |
euygun | 0:25fcf12b0ba2 | 28 | |
euygun | 0:25fcf12b0ba2 | 29 | // User Button |
euygun | 0:25fcf12b0ba2 | 30 | #ifdef TARGET_UBLOX_C027 |
euygun | 0:25fcf12b0ba2 | 31 | // No user button on C027 |
euygun | 0:25fcf12b0ba2 | 32 | InterruptIn userButton(NC); |
euygun | 0:25fcf12b0ba2 | 33 | #else |
euygun | 0:25fcf12b0ba2 | 34 | InterruptIn userButton(SW0); |
euygun | 0:25fcf12b0ba2 | 35 | #endif |
euygun | 0:25fcf12b0ba2 | 36 | |
euygun | 0:25fcf12b0ba2 | 37 | // Delay between LED changes in second |
euygun | 0:25fcf12b0ba2 | 38 | volatile float delay = 0.5; |
euygun | 0:25fcf12b0ba2 | 39 | |
euygun | 1:e11c75d931b5 | 40 | // To check if the user pressed the User Button or not |
euygun | 0:25fcf12b0ba2 | 41 | void threadBodyUserButtonCheck(void const *args){ |
euygun | 0:25fcf12b0ba2 | 42 | float delayToggle = delay; |
euygun | 0:25fcf12b0ba2 | 43 | while (1){ |
euygun | 0:25fcf12b0ba2 | 44 | if (userButton.read() == 1 ) { |
euygun | 1:e11c75d931b5 | 45 | // User Button is pressed |
euygun | 0:25fcf12b0ba2 | 46 | delay = 0.1; |
euygun | 0:25fcf12b0ba2 | 47 | //Indicate the button is pressed |
euygun | 0:25fcf12b0ba2 | 48 | ledYellow = 0; |
euygun | 0:25fcf12b0ba2 | 49 | } |
euygun | 0:25fcf12b0ba2 | 50 | else { |
euygun | 1:e11c75d931b5 | 51 | // User button is released |
euygun | 0:25fcf12b0ba2 | 52 | delay = 0.5; |
euygun | 0:25fcf12b0ba2 | 53 | //Turn off the Yellow LED on Ethernet socket |
euygun | 0:25fcf12b0ba2 | 54 | ledYellow = 1; |
euygun | 0:25fcf12b0ba2 | 55 | } |
euygun | 0:25fcf12b0ba2 | 56 | } |
euygun | 0:25fcf12b0ba2 | 57 | } |
euygun | 0:25fcf12b0ba2 | 58 | |
euygun | 0:25fcf12b0ba2 | 59 | /* |
euygun | 0:25fcf12b0ba2 | 60 | ** Out of the Box Demo for C030 variants |
euygun | 0:25fcf12b0ba2 | 61 | ** |
euygun | 0:25fcf12b0ba2 | 62 | ** Sets the modem then |
euygun | 0:25fcf12b0ba2 | 63 | */ |
euygun | 0:25fcf12b0ba2 | 64 | |
euygun | 0:25fcf12b0ba2 | 65 | int main() |
euygun | 0:25fcf12b0ba2 | 66 | { |
euygun | 1:e11c75d931b5 | 67 | // Initialised the modem |
euygun | 0:25fcf12b0ba2 | 68 | onboard_modem_init(); |
euygun | 0:25fcf12b0ba2 | 69 | |
euygun | 1:e11c75d931b5 | 70 | // Power up the modem |
euygun | 0:25fcf12b0ba2 | 71 | onboard_modem_power_up(); |
euygun | 0:25fcf12b0ba2 | 72 | |
euygun | 1:e11c75d931b5 | 73 | // Create threadUserButtonCheck thread |
euygun | 0:25fcf12b0ba2 | 74 | Thread threadUserButtonCheck(threadBodyUserButtonCheck); |
euygun | 0:25fcf12b0ba2 | 75 | |
euygun | 1:e11c75d931b5 | 76 | // Set the LED states |
euygun | 0:25fcf12b0ba2 | 77 | ledRed = 0; |
euygun | 0:25fcf12b0ba2 | 78 | ledGreen = 1; |
euygun | 0:25fcf12b0ba2 | 79 | ledBlue = 1; |
euygun | 0:25fcf12b0ba2 | 80 | |
euygun | 0:25fcf12b0ba2 | 81 | printf("u-blox C030 Out-of-the-Box Demo\n\r"); |
euygun | 0:25fcf12b0ba2 | 82 | |
euygun | 0:25fcf12b0ba2 | 83 | //Main loop |
euygun | 0:25fcf12b0ba2 | 84 | while(1) { |
euygun | 0:25fcf12b0ba2 | 85 | wait(delay); |
euygun | 0:25fcf12b0ba2 | 86 | //Shift the LED states |
euygun | 0:25fcf12b0ba2 | 87 | int carry = ledBlue; |
euygun | 0:25fcf12b0ba2 | 88 | ledBlue = ledRed; |
euygun | 0:25fcf12b0ba2 | 89 | ledRed = ledGreen; |
euygun | 0:25fcf12b0ba2 | 90 | ledGreen = carry; |
euygun | 0:25fcf12b0ba2 | 91 | } |
euygun | 0:25fcf12b0ba2 | 92 | } |
euygun | 0:25fcf12b0ba2 | 93 | |
euygun | 0:25fcf12b0ba2 | 94 | // End Of File |