driver for the WNC M14A2A Cellular Data Module

Committer:
JMF
Date:
Tue Feb 06 16:10:48 2018 +0000
Revision:
0:6a2d96c2a520
Incorporating changes suggested by ARM

Who changed what in which revision?

UserRevisionLine numberNew contents of line
JMF 0:6a2d96c2a520 1 /*
JMF 0:6a2d96c2a520 2 Copyright (c) 2016 Fred Kellerman
JMF 0:6a2d96c2a520 3
JMF 0:6a2d96c2a520 4 Permission is hereby granted, free of charge, to any person obtaining a copy
JMF 0:6a2d96c2a520 5 of this software and associated documentation files (the "Software"), to deal
JMF 0:6a2d96c2a520 6 in the Software without restriction, including without limitation the rights
JMF 0:6a2d96c2a520 7 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
JMF 0:6a2d96c2a520 8 copies of the Software, and to permit persons to whom the Software is
JMF 0:6a2d96c2a520 9 furnished to do so, subject to the following conditions:
JMF 0:6a2d96c2a520 10
JMF 0:6a2d96c2a520 11 The above copyright notice and this permission notice shall be included in
JMF 0:6a2d96c2a520 12 all copies or substantial portions of the Software.
JMF 0:6a2d96c2a520 13
JMF 0:6a2d96c2a520 14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
JMF 0:6a2d96c2a520 15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
JMF 0:6a2d96c2a520 16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
JMF 0:6a2d96c2a520 17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
JMF 0:6a2d96c2a520 18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
JMF 0:6a2d96c2a520 19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
JMF 0:6a2d96c2a520 20 THE SOFTWARE.
JMF 0:6a2d96c2a520 21
JMF 0:6a2d96c2a520 22 @file WncControllerK64F.h
JMF 0:6a2d96c2a520 23 @purpose Contains K64F and mbed specifics to control the WNC modem using the WncController base class.
JMF 0:6a2d96c2a520 24 @version 1.0
JMF 0:6a2d96c2a520 25 @date July 2016
JMF 0:6a2d96c2a520 26 @author Fred Kellerman
JMF 0:6a2d96c2a520 27 */
JMF 0:6a2d96c2a520 28
JMF 0:6a2d96c2a520 29 #ifndef __WNCCONTROLLERK64F_H_
JMF 0:6a2d96c2a520 30 #define __WNCCONTROLLERK64F_H_
JMF 0:6a2d96c2a520 31
JMF 0:6a2d96c2a520 32 #include <string>
JMF 0:6a2d96c2a520 33 #include <stdint.h>
JMF 0:6a2d96c2a520 34 #include "mbed.h"
JMF 0:6a2d96c2a520 35 #include "WNCDebug.h"
JMF 0:6a2d96c2a520 36 #include "WncController.h"
JMF 0:6a2d96c2a520 37
JMF 0:6a2d96c2a520 38 namespace WncControllerK64F_fk {
JMF 0:6a2d96c2a520 39
JMF 0:6a2d96c2a520 40 using namespace WncController_fk;
JMF 0:6a2d96c2a520 41 using namespace std;
JMF 0:6a2d96c2a520 42
JMF 0:6a2d96c2a520 43 /** List of K64F pins that are used to control and setup the ATT IoT Kit WNC Shield */
JMF 0:6a2d96c2a520 44 struct WncGpioPinListK64F {
JMF 0:6a2d96c2a520 45 /////////////////////////////////////////////////////
JMF 0:6a2d96c2a520 46 // NXP GPIO Pins that are used to initialize the WNC Shield
JMF 0:6a2d96c2a520 47 /////////////////////////////////////////////////////
JMF 0:6a2d96c2a520 48 DigitalOut * mdm_uart2_rx_boot_mode_sel; // on powerup, 0 = boot mode, 1 = normal boot
JMF 0:6a2d96c2a520 49 DigitalOut * mdm_power_on; // 0 = turn modem on, 1 = turn modem off (should be held high for >5 seconds to cycle modem)
JMF 0:6a2d96c2a520 50 DigitalOut * mdm_wakeup_in; // 0 = let modem sleep, 1 = keep modem awake -- Note: pulled high on shield
JMF 0:6a2d96c2a520 51 DigitalOut * mdm_reset; // active high
JMF 0:6a2d96c2a520 52 DigitalOut * shield_3v3_1v8_sig_trans_ena; // 0 = disabled (all signals high impedence, 1 = translation active
JMF 0:6a2d96c2a520 53 DigitalOut * mdm_uart1_cts;
JMF 0:6a2d96c2a520 54 };
JMF 0:6a2d96c2a520 55
JMF 0:6a2d96c2a520 56
JMF 0:6a2d96c2a520 57 /**
JMF 0:6a2d96c2a520 58 * @author Fred Kellerman
JMF 0:6a2d96c2a520 59 * @see API
JMF 0:6a2d96c2a520 60 *
JMF 0:6a2d96c2a520 61 * <b>WncControllerK64F</b> This mbed C++ class is for controlling the WNC
JMF 0:6a2d96c2a520 62 * Cellular modem from the NXP K64F Freedom board. It uses the control code
JMF 0:6a2d96c2a520 63 * from it's base class WncController to handle the WNC Modem AT cmds. This
JMF 0:6a2d96c2a520 64 * class fulfills various pure virtual methods of the base class. The point of
JMF 0:6a2d96c2a520 65 * this class is to have the platform specific code in it thus isolating the
JMF 0:6a2d96c2a520 66 * control code logic from any particular platform or OS.
JMF 0:6a2d96c2a520 67 */
JMF 0:6a2d96c2a520 68 class WncControllerK64F : public WncController
JMF 0:6a2d96c2a520 69 {
JMF 0:6a2d96c2a520 70 public:
JMF 0:6a2d96c2a520 71
JMF 0:6a2d96c2a520 72 /**
JMF 0:6a2d96c2a520 73 *
JMF 0:6a2d96c2a520 74 * Sets up the resources to control the WNC modem shield.
JMF 0:6a2d96c2a520 75 * @ingroup API
JMF 0:6a2d96c2a520 76 * @param pPins - pointer to a list of K64F pins that are used to setup and control the ATT IoT Kit's WNC Shield.
JMF 0:6a2d96c2a520 77 * @param wnc_uart - a pointer to the serial uart that is used to communicate with the WNC modem.
JMF 0:6a2d96c2a520 78 * @param debug_uart - a pointer to a serial uart for the debug output to go out of, if NULL debug will not be output.
JMF 0:6a2d96c2a520 79 */
JMF 0:6a2d96c2a520 80 WncControllerK64F(struct WncGpioPinListK64F * pPins, BufferedSerial * wnc_uart, WNCDebug * debug_uart = NULL);
JMF 0:6a2d96c2a520 81
JMF 0:6a2d96c2a520 82 /**
JMF 0:6a2d96c2a520 83 *
JMF 0:6a2d96c2a520 84 * Activates a mode where the user can send text to and from the K64F
JMF 0:6a2d96c2a520 85 * debug Serial port directly to the WNC. The mode is entered via this
JMF 0:6a2d96c2a520 86 * call. The mode is exited when the user types CTRL-Q. While in this
JMF 0:6a2d96c2a520 87 * mode all text to and from the WNC is consumed by the debug Serial port.
JMF 0:6a2d96c2a520 88 * No other methods in the class will receive any of the WNC output.
JMF 0:6a2d96c2a520 89 * @ingroup API
JMF 0:6a2d96c2a520 90 * @param pUart - a pointer to a uart to use to collect the user input and put the output from the WNC.
JMF 0:6a2d96c2a520 91 * @param echoOn - set to true to echo what is input back to the output of pUart.
JMF 0:6a2d96c2a520 92 */
JMF 0:6a2d96c2a520 93 bool enterWncTerminalMode(BufferedSerial *pUart, bool echoOn);
JMF 0:6a2d96c2a520 94
JMF 0:6a2d96c2a520 95 private:
JMF 0:6a2d96c2a520 96
JMF 0:6a2d96c2a520 97 // Disallow copy
JMF 0:6a2d96c2a520 98 WncControllerK64F operator=(WncControllerK64F lhs);
JMF 0:6a2d96c2a520 99
JMF 0:6a2d96c2a520 100 // Users must define these functionalities:
JMF 0:6a2d96c2a520 101 virtual int putc(char c);
JMF 0:6a2d96c2a520 102 virtual int puts(const char * s);
JMF 0:6a2d96c2a520 103 virtual char getc(void);
JMF 0:6a2d96c2a520 104 virtual int charReady(void);
JMF 0:6a2d96c2a520 105 virtual int dbgWriteChar(char b);
JMF 0:6a2d96c2a520 106 virtual int dbgWriteChars(const char *b);
JMF 0:6a2d96c2a520 107 virtual bool initWncModem(uint8_t powerUpTimeoutSecs);
JMF 0:6a2d96c2a520 108 virtual void waitMs(int t);
JMF 0:6a2d96c2a520 109 virtual void waitUs(int t);
JMF 0:6a2d96c2a520 110
JMF 0:6a2d96c2a520 111 virtual int getLogTimerTicks(void);
JMF 0:6a2d96c2a520 112 virtual void startTimerA(void);
JMF 0:6a2d96c2a520 113 virtual void stopTimerA(void);
JMF 0:6a2d96c2a520 114 virtual int getTimerTicksA_mS(void);
JMF 0:6a2d96c2a520 115 virtual void startTimerB(void);
JMF 0:6a2d96c2a520 116 virtual void stopTimerB(void);
JMF 0:6a2d96c2a520 117 virtual int getTimerTicksB_mS(void);
JMF 0:6a2d96c2a520 118
JMF 0:6a2d96c2a520 119 WNCDebug * m_pDbgUart;
JMF 0:6a2d96c2a520 120 BufferedSerial * m_pWncUart;
JMF 0:6a2d96c2a520 121 WncGpioPinListK64F m_gpioPinList;
JMF 0:6a2d96c2a520 122 Timer m_logTimer;
JMF 0:6a2d96c2a520 123 Timer m_timerA;
JMF 0:6a2d96c2a520 124 Timer m_timerB;
JMF 0:6a2d96c2a520 125 };
JMF 0:6a2d96c2a520 126
JMF 0:6a2d96c2a520 127 }; // End namespace WncController_fk
JMF 0:6a2d96c2a520 128
JMF 0:6a2d96c2a520 129 #endif
JMF 0:6a2d96c2a520 130