Library for controlling the WNC 14A2A from the K64F Freedom Board. It fulfills platform specific pure virtual methods from the WncControllerLibrary.

Dependencies:   WncControllerLibrary

Dependents:   WNC14A2AInterface

Fork of WncControllerK64F by Fred Kellerman

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers WncControllerK64F.h Source File

WncControllerK64F.h

00001 /*
00002     Copyright (c) 2016 Fred Kellerman
00003  
00004     Permission is hereby granted, free of charge, to any person obtaining a copy
00005     of this software and associated documentation files (the "Software"), to deal
00006     in the Software without restriction, including without limitation the rights
00007     to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00008     copies of the Software, and to permit persons to whom the Software is
00009     furnished to do so, subject to the following conditions:
00010  
00011     The above copyright notice and this permission notice shall be included in
00012     all copies or substantial portions of the Software.
00013  
00014     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00015     IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00016     FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00017     AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00018     LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00019     OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00020     THE SOFTWARE.
00021     
00022     @file          WncControllerK64F.h
00023     @purpose       Contains K64F and mbed specifics to control the WNC modem using the WncController base class.
00024     @version       1.0
00025     @date          July 2016
00026     @author        Fred Kellerman
00027 */
00028 
00029 #ifndef __WNCCONTROLLERK64F_H_
00030 #define __WNCCONTROLLERK64F_H_
00031 
00032 #include <string>
00033 #include <stdint.h>
00034 #include "mbed.h"
00035 #include "WNCDebug.h"
00036 #include "WncController.h"
00037 
00038 namespace WncControllerK64F_fk {
00039 
00040 using namespace WncController_fk;
00041 using namespace std;
00042 
00043 /** List of K64F pins that are used to control and setup the ATT IoT Kit WNC Shield */
00044 struct WncGpioPinListK64F {
00045     /////////////////////////////////////////////////////
00046     // NXP GPIO Pins that are used to initialize the WNC Shield
00047     /////////////////////////////////////////////////////
00048     DigitalOut * mdm_uart2_rx_boot_mode_sel;   // on powerup, 0 = boot mode, 1 = normal boot
00049     DigitalOut * mdm_power_on;                 // 0 = turn modem on, 1 = turn modem off (should be held high for >5 seconds to cycle modem)
00050     DigitalOut * mdm_wakeup_in;                // 0 = let modem sleep, 1 = keep modem awake -- Note: pulled high on shield
00051     DigitalOut * mdm_reset;                    // active high
00052     DigitalOut * shield_3v3_1v8_sig_trans_ena; // 0 = disabled (all signals high impedence, 1 = translation active
00053     DigitalOut * mdm_uart1_cts;
00054 };    
00055 
00056 
00057 /**
00058  * @author Fred Kellerman
00059  * @see API 
00060  *
00061  * <b>WncControllerK64F</b> This mbed C++ class is for controlling the WNC
00062  * Cellular modem from the NXP K64F Freedom board.  It uses the control code
00063  * from it's base class WncController to handle the WNC Modem AT cmds.  This
00064  * class fulfills various pure virtual methods of the base class.  The point of
00065  * this class is to have the platform specific code in it thus isolating the
00066  * control code logic from any particular platform or OS.
00067  */
00068 class WncControllerK64F  : public WncController
00069 {
00070 public:
00071 
00072     /**
00073      *
00074      * Sets up the resources to control the WNC modem shield.
00075      * @ingroup API
00076      * @param pPins - pointer to a list of K64F pins that are used to setup and control the ATT IoT Kit's WNC Shield.
00077      * @param wnc_uart - a pointer to the serial uart that is used to communicate with the WNC modem.
00078      * @param debug_uart - a pointer to a serial uart for the debug output to go out of, if NULL debug will not be output.
00079      */
00080     WncControllerK64F (struct WncGpioPinListK64F * pPins, BufferedSerial * wnc_uart, WNCDebug * debug_uart = NULL);
00081     
00082     /**
00083      *
00084      *  Activates a mode where the user can send text to and from the K64F
00085      *  debug Serial port directly to the WNC.  The mode is entered via this
00086      *  call.  The mode is exited when the user types CTRL-Q.  While in this
00087      *  mode all text to and from the WNC is consumed by the debug Serial port.
00088      *  No other methods in the class will receive any of the WNC output.
00089      * @ingroup API
00090      * @param pUart - a pointer to a uart to use to collect the user input and put the output from the WNC.
00091      * @param echoOn - set to true to echo what is input back to the output of pUart.
00092      */
00093     bool enterWncTerminalMode(BufferedSerial *pUart, bool echoOn);
00094     
00095 private:
00096 
00097     // Disallow copy
00098     WncControllerK64F  operator=(WncControllerK64F  lhs);
00099 
00100     // Users must define these functionalities:
00101     virtual int putc(char c);
00102     virtual int puts(const char * s);
00103     virtual char getc(void);
00104     virtual int charReady(void);
00105     virtual int dbgWriteChar(char b);
00106     virtual int dbgWriteChars(const char *b);
00107     virtual bool initWncModem(uint8_t powerUpTimeoutSecs);
00108     virtual void waitMs(int t);
00109     virtual void waitUs(int t);
00110     
00111     virtual int  getLogTimerTicks(void);
00112     virtual void startTimerA(void);
00113     virtual void stopTimerA(void);
00114     virtual int  getTimerTicksA_mS(void);
00115     virtual void startTimerB(void);
00116     virtual void stopTimerB(void);
00117     virtual int  getTimerTicksB_mS(void);
00118 
00119     WNCDebug * m_pDbgUart;
00120     BufferedSerial * m_pWncUart;
00121     WncGpioPinListK64F m_gpioPinList;
00122     Timer m_logTimer;
00123     Timer m_timerA;
00124     Timer m_timerB;
00125 };
00126 
00127 };  // End namespace WncController_fk
00128 
00129 #endif
00130