Initial commit

Dependencies:   FastPWM

Committer:
lypinator
Date:
Wed Sep 16 01:11:49 2020 +0000
Revision:
0:bb348c97df44
Added PWM

Who changed what in which revision?

UserRevisionLine numberNew 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 "cellular/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 static void press_power_button(int time_ms)
lypinator 0:bb348c97df44 27 {
lypinator 0:bb348c97df44 28 gpio_t gpio;
lypinator 0:bb348c97df44 29
lypinator 0:bb348c97df44 30 gpio_init_out_ex(&gpio, PWRKEY, 1);
lypinator 0:bb348c97df44 31 gpio_write(&gpio, 1);
lypinator 0:bb348c97df44 32 wait_ms(time_ms);
lypinator 0:bb348c97df44 33 gpio_write(&gpio, 0);
lypinator 0:bb348c97df44 34 }
lypinator 0:bb348c97df44 35
lypinator 0:bb348c97df44 36 void onboard_modem_init()
lypinator 0:bb348c97df44 37 {
lypinator 0:bb348c97df44 38 gpio_t gpio;
lypinator 0:bb348c97df44 39 // start with modem disabled
lypinator 0:bb348c97df44 40 gpio_init_out_ex(&gpio, RESET_MODULE, 0);
lypinator 0:bb348c97df44 41 gpio_init_in_ex(&gpio, MDMSTAT, PullUp);
lypinator 0:bb348c97df44 42 gpio_init_out_ex(&gpio, MDMDTR, 0);
lypinator 0:bb348c97df44 43 gpio_init_out_ex(&gpio, M_POWR, 1);
lypinator 0:bb348c97df44 44
lypinator 0:bb348c97df44 45 // gpio_write(&gpio, M_POWR, 1);
lypinator 0:bb348c97df44 46 wait_ms(500);
lypinator 0:bb348c97df44 47 }
lypinator 0:bb348c97df44 48
lypinator 0:bb348c97df44 49 void onboard_modem_deinit()
lypinator 0:bb348c97df44 50 {
lypinator 0:bb348c97df44 51 // wio3g_mdm_powerOff();
lypinator 0:bb348c97df44 52 }
lypinator 0:bb348c97df44 53
lypinator 0:bb348c97df44 54 void onboard_modem_power_up()
lypinator 0:bb348c97df44 55 {
lypinator 0:bb348c97df44 56 /* keep the power line HIGH for 200 milisecond */
lypinator 0:bb348c97df44 57 press_power_button(200);
lypinator 0:bb348c97df44 58 /* give modem a little time to respond */
lypinator 0:bb348c97df44 59 wait_ms(100);
lypinator 0:bb348c97df44 60 }
lypinator 0:bb348c97df44 61
lypinator 0:bb348c97df44 62 void onboard_modem_power_down()
lypinator 0:bb348c97df44 63 {
lypinator 0:bb348c97df44 64 /* keep the power line low for 1 second */
lypinator 0:bb348c97df44 65 // press_power_button(1000);
lypinator 0:bb348c97df44 66
lypinator 0:bb348c97df44 67 // gpio_write(&mpowr, M_POWR, 0);
lypinator 0:bb348c97df44 68 }
lypinator 0:bb348c97df44 69 #endif //MODEM_ON_BOARD
lypinator 0:bb348c97df44 70 #endif //MBED_CONF_NSAPI_PRESENT