Initial commit
mbed-dev-master/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F437xG/TARGET_UBLOX_C030/onboard_modem_api.c@0:bb348c97df44, 2020-09-16 (annotated)
- Committer:
- lypinator
- Date:
- Wed Sep 16 01:11:49 2020 +0000
- Revision:
- 0:bb348c97df44
Added PWM
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
lypinator | 0:bb348c97df44 | 1 | /* mbed Microcontroller Library |
lypinator | 0:bb348c97df44 | 2 | * Copyright (c) 2017 ARM Limited |
lypinator | 0:bb348c97df44 | 3 | * |
lypinator | 0:bb348c97df44 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
lypinator | 0:bb348c97df44 | 5 | * you may not use this file except in compliance with the License. |
lypinator | 0:bb348c97df44 | 6 | * You may obtain a copy of the License at |
lypinator | 0:bb348c97df44 | 7 | * |
lypinator | 0:bb348c97df44 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
lypinator | 0:bb348c97df44 | 9 | * |
lypinator | 0:bb348c97df44 | 10 | * Unless required by applicable law or agreed to in writing, software |
lypinator | 0:bb348c97df44 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
lypinator | 0:bb348c97df44 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
lypinator | 0:bb348c97df44 | 13 | * See the License for the specific language governing permissions and |
lypinator | 0:bb348c97df44 | 14 | * limitations under the License. |
lypinator | 0:bb348c97df44 | 15 | */ |
lypinator | 0:bb348c97df44 | 16 | |
lypinator | 0:bb348c97df44 | 17 | #if MBED_CONF_NSAPI_PRESENT |
lypinator | 0:bb348c97df44 | 18 | |
lypinator | 0:bb348c97df44 | 19 | #include "onboard_modem_api.h" |
lypinator | 0:bb348c97df44 | 20 | #include "gpio_api.h" |
lypinator | 0:bb348c97df44 | 21 | #include "platform/mbed_wait_api.h" |
lypinator | 0:bb348c97df44 | 22 | #include "PinNames.h" |
lypinator | 0:bb348c97df44 | 23 | |
lypinator | 0:bb348c97df44 | 24 | #if MODEM_ON_BOARD |
lypinator | 0:bb348c97df44 | 25 | |
lypinator | 0:bb348c97df44 | 26 | // Note microseconds not milliseconds |
lypinator | 0:bb348c97df44 | 27 | static void press_power_button(int time_us) |
lypinator | 0:bb348c97df44 | 28 | { |
lypinator | 0:bb348c97df44 | 29 | gpio_t gpio; |
lypinator | 0:bb348c97df44 | 30 | |
lypinator | 0:bb348c97df44 | 31 | #if defined(TARGET_UBLOX_C030_R410M) |
lypinator | 0:bb348c97df44 | 32 | gpio_init_inout(&gpio, MDMPWRON, PIN_OUTPUT, OpenDrain, 0); |
lypinator | 0:bb348c97df44 | 33 | #else |
lypinator | 0:bb348c97df44 | 34 | gpio_init_out_ex(&gpio, MDMPWRON, 0); |
lypinator | 0:bb348c97df44 | 35 | #endif |
lypinator | 0:bb348c97df44 | 36 | |
lypinator | 0:bb348c97df44 | 37 | wait_us(time_us); |
lypinator | 0:bb348c97df44 | 38 | gpio_write(&gpio, 1); |
lypinator | 0:bb348c97df44 | 39 | } |
lypinator | 0:bb348c97df44 | 40 | |
lypinator | 0:bb348c97df44 | 41 | void onboard_modem_init() |
lypinator | 0:bb348c97df44 | 42 | { |
lypinator | 0:bb348c97df44 | 43 | gpio_t gpio; |
lypinator | 0:bb348c97df44 | 44 | |
lypinator | 0:bb348c97df44 | 45 | // Take us out of reset |
lypinator | 0:bb348c97df44 | 46 | gpio_init_out_ex(&gpio, MDMRST, 1); |
lypinator | 0:bb348c97df44 | 47 | } |
lypinator | 0:bb348c97df44 | 48 | |
lypinator | 0:bb348c97df44 | 49 | void onboard_modem_deinit() |
lypinator | 0:bb348c97df44 | 50 | { |
lypinator | 0:bb348c97df44 | 51 | gpio_t gpio; |
lypinator | 0:bb348c97df44 | 52 | |
lypinator | 0:bb348c97df44 | 53 | // Back into reset |
lypinator | 0:bb348c97df44 | 54 | gpio_init_out_ex(&gpio, MDMRST, 0); |
lypinator | 0:bb348c97df44 | 55 | } |
lypinator | 0:bb348c97df44 | 56 | |
lypinator | 0:bb348c97df44 | 57 | void onboard_modem_power_up() |
lypinator | 0:bb348c97df44 | 58 | { |
lypinator | 0:bb348c97df44 | 59 | #if defined(TARGET_UBLOX_C030_R410M) |
lypinator | 0:bb348c97df44 | 60 | /* keep the power line low for 1 seconds */ |
lypinator | 0:bb348c97df44 | 61 | press_power_button(1000000); |
lypinator | 0:bb348c97df44 | 62 | #else |
lypinator | 0:bb348c97df44 | 63 | /* keep the power line low for 50 microseconds */ |
lypinator | 0:bb348c97df44 | 64 | press_power_button(50); |
lypinator | 0:bb348c97df44 | 65 | #endif |
lypinator | 0:bb348c97df44 | 66 | |
lypinator | 0:bb348c97df44 | 67 | /* give modem a little time to respond */ |
lypinator | 0:bb348c97df44 | 68 | wait_ms(100); |
lypinator | 0:bb348c97df44 | 69 | } |
lypinator | 0:bb348c97df44 | 70 | |
lypinator | 0:bb348c97df44 | 71 | void onboard_modem_power_down() |
lypinator | 0:bb348c97df44 | 72 | { |
lypinator | 0:bb348c97df44 | 73 | #if defined(TARGET_UBLOX_C030_R410M) |
lypinator | 0:bb348c97df44 | 74 | /* keep the power line low for 1.5 seconds */ |
lypinator | 0:bb348c97df44 | 75 | press_power_button(1500000); |
lypinator | 0:bb348c97df44 | 76 | #else |
lypinator | 0:bb348c97df44 | 77 | /* keep the power line low for 1 seconds */ |
lypinator | 0:bb348c97df44 | 78 | press_power_button(1000000); |
lypinator | 0:bb348c97df44 | 79 | #endif |
lypinator | 0:bb348c97df44 | 80 | } |
lypinator | 0:bb348c97df44 | 81 | |
lypinator | 0:bb348c97df44 | 82 | #endif //MODEM_ON_BOARD |
lypinator | 0:bb348c97df44 | 83 | #endif //MBED_CONF_NSAPI_PRESENT |