WncControllerK64F
Fork of WncControllerK64F by
WncControllerK64F.h@0:98d149685c95, 2016-09-02 (annotated)
- Committer:
- fkellermavnet
- Date:
- Fri Sep 02 16:37:29 2016 +0000
- Revision:
- 0:98d149685c95
- Child:
- 13:ef379cdd57aa
Separate library for platform specific WNC controlling.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
fkellermavnet | 0:98d149685c95 | 1 | /* |
fkellermavnet | 0:98d149685c95 | 2 | Copyright (c) 2016 Fred Kellerman |
fkellermavnet | 0:98d149685c95 | 3 | |
fkellermavnet | 0:98d149685c95 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy |
fkellermavnet | 0:98d149685c95 | 5 | of this software and associated documentation files (the "Software"), to deal |
fkellermavnet | 0:98d149685c95 | 6 | in the Software without restriction, including without limitation the rights |
fkellermavnet | 0:98d149685c95 | 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
fkellermavnet | 0:98d149685c95 | 8 | copies of the Software, and to permit persons to whom the Software is |
fkellermavnet | 0:98d149685c95 | 9 | furnished to do so, subject to the following conditions: |
fkellermavnet | 0:98d149685c95 | 10 | |
fkellermavnet | 0:98d149685c95 | 11 | The above copyright notice and this permission notice shall be included in |
fkellermavnet | 0:98d149685c95 | 12 | all copies or substantial portions of the Software. |
fkellermavnet | 0:98d149685c95 | 13 | |
fkellermavnet | 0:98d149685c95 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
fkellermavnet | 0:98d149685c95 | 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
fkellermavnet | 0:98d149685c95 | 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
fkellermavnet | 0:98d149685c95 | 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
fkellermavnet | 0:98d149685c95 | 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
fkellermavnet | 0:98d149685c95 | 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
fkellermavnet | 0:98d149685c95 | 20 | THE SOFTWARE. |
fkellermavnet | 0:98d149685c95 | 21 | |
fkellermavnet | 0:98d149685c95 | 22 | @file WncController.h |
fkellermavnet | 0:98d149685c95 | 23 | @purpose Controls WNC Cellular Modem |
fkellermavnet | 0:98d149685c95 | 24 | @version 1.0 |
fkellermavnet | 0:98d149685c95 | 25 | @date July 2016 |
fkellermavnet | 0:98d149685c95 | 26 | @author Fred Kellerman |
fkellermavnet | 0:98d149685c95 | 27 | */ |
fkellermavnet | 0:98d149685c95 | 28 | |
fkellermavnet | 0:98d149685c95 | 29 | #ifndef __WNCCONTROLLERK64F_H_ |
fkellermavnet | 0:98d149685c95 | 30 | #define __WNCCONTROLLERK64F_H_ |
fkellermavnet | 0:98d149685c95 | 31 | |
fkellermavnet | 0:98d149685c95 | 32 | #include <string> |
fkellermavnet | 0:98d149685c95 | 33 | #include <stdint.h> |
fkellermavnet | 0:98d149685c95 | 34 | #include "mbed.h" |
fkellermavnet | 0:98d149685c95 | 35 | #include "MODSERIAL.h" |
fkellermavnet | 0:98d149685c95 | 36 | #include "WncController.h" |
fkellermavnet | 0:98d149685c95 | 37 | |
fkellermavnet | 0:98d149685c95 | 38 | namespace WncControllerK64F_fk { |
fkellermavnet | 0:98d149685c95 | 39 | |
fkellermavnet | 0:98d149685c95 | 40 | using namespace WncController_fk; |
fkellermavnet | 0:98d149685c95 | 41 | using namespace std; |
fkellermavnet | 0:98d149685c95 | 42 | |
fkellermavnet | 0:98d149685c95 | 43 | struct WncGpioPinListK64F { |
fkellermavnet | 0:98d149685c95 | 44 | ///////////////////////////////////////////////////// |
fkellermavnet | 0:98d149685c95 | 45 | // NXP GPIO Pins that are used to initialize the WNC Shield |
fkellermavnet | 0:98d149685c95 | 46 | ///////////////////////////////////////////////////// |
fkellermavnet | 0:98d149685c95 | 47 | DigitalOut * mdm_uart2_rx_boot_mode_sel; // on powerup, 0 = boot mode, 1 = normal boot |
fkellermavnet | 0:98d149685c95 | 48 | DigitalOut * mdm_power_on; // 0 = turn modem on, 1 = turn modem off (should be held high for >5 seconds to cycle modem) |
fkellermavnet | 0:98d149685c95 | 49 | DigitalOut * mdm_wakeup_in; // 0 = let modem sleep, 1 = keep modem awake -- Note: pulled high on shield |
fkellermavnet | 0:98d149685c95 | 50 | DigitalOut * mdm_reset; // active high |
fkellermavnet | 0:98d149685c95 | 51 | DigitalOut * shield_3v3_1v8_sig_trans_ena; // 0 = disabled (all signals high impedence, 1 = translation active |
fkellermavnet | 0:98d149685c95 | 52 | DigitalOut * mdm_uart1_cts; |
fkellermavnet | 0:98d149685c95 | 53 | }; |
fkellermavnet | 0:98d149685c95 | 54 | |
fkellermavnet | 0:98d149685c95 | 55 | class WncControllerK64F : public WncController |
fkellermavnet | 0:98d149685c95 | 56 | { |
fkellermavnet | 0:98d149685c95 | 57 | public: |
fkellermavnet | 0:98d149685c95 | 58 | /** |
fkellermavnet | 0:98d149685c95 | 59 | * \brief Constructor for UART controlled WNC |
fkellermavnet | 0:98d149685c95 | 60 | * |
fkellermavnet | 0:98d149685c95 | 61 | * \param [in] wnc_uart - Reference to a SerialBuffered object which will |
fkellermavnet | 0:98d149685c95 | 62 | * be used as the bus to control the WNC. apnStr = a text string for |
fkellermavnet | 0:98d149685c95 | 63 | * the cellular APN name. |
fkellermavnet | 0:98d149685c95 | 64 | * |
fkellermavnet | 0:98d149685c95 | 65 | * \return None. |
fkellermavnet | 0:98d149685c95 | 66 | * |
fkellermavnet | 0:98d149685c95 | 67 | * \details Adding another way to talk to the WNC, like I2C or USB, |
fkellermavnet | 0:98d149685c95 | 68 | * a constructor should be added for each type just like the SerialBuffered |
fkellermavnet | 0:98d149685c95 | 69 | * constructor below. Assumes UART is enabled, setup and ready to go. This |
fkellermavnet | 0:98d149685c95 | 70 | * class will read and write to this UART. |
fkellermavnet | 0:98d149685c95 | 71 | */ |
fkellermavnet | 0:98d149685c95 | 72 | WncControllerK64F(struct WncGpioPinListK64F * pPins, MODSERIAL * wnc_uart, MODSERIAL * debug_uart = NULL); |
fkellermavnet | 0:98d149685c95 | 73 | |
fkellermavnet | 0:98d149685c95 | 74 | /** |
fkellermavnet | 0:98d149685c95 | 75 | * \brief Activates a mode where the user can send text to and from the K64F |
fkellermavnet | 0:98d149685c95 | 76 | * debug Serial port directly to the WNC. |
fkellermavnet | 0:98d149685c95 | 77 | * |
fkellermavnet | 0:98d149685c95 | 78 | * \param [in] echoOn - set to true to enable terminal echo |
fkellermavnet | 0:98d149685c95 | 79 | * |
fkellermavnet | 0:98d149685c95 | 80 | * \return true - if terminal mode was successfully entered and exited. |
fkellermavnet | 0:98d149685c95 | 81 | * |
fkellermavnet | 0:98d149685c95 | 82 | * \details Activates a mode where the user can send text to and from the K64F |
fkellermavnet | 0:98d149685c95 | 83 | * debug Serial port directly to the WNC. The mode is entered via this |
fkellermavnet | 0:98d149685c95 | 84 | * call. The mode is exited when the user types CTRL-Q. While in this |
fkellermavnet | 0:98d149685c95 | 85 | * mode all text to and from the WNC is consumed by the debug Serial port. |
fkellermavnet | 0:98d149685c95 | 86 | * No other methods in the class will receive any of the WNC output. |
fkellermavnet | 0:98d149685c95 | 87 | */ |
fkellermavnet | 0:98d149685c95 | 88 | bool enterWncTerminalMode(bool echoOn); |
fkellermavnet | 0:98d149685c95 | 89 | |
fkellermavnet | 0:98d149685c95 | 90 | private: |
fkellermavnet | 0:98d149685c95 | 91 | |
fkellermavnet | 0:98d149685c95 | 92 | // Disallow copy |
fkellermavnet | 0:98d149685c95 | 93 | // WncControllerK64F operator=(WncControllerK64F lhs); |
fkellermavnet | 0:98d149685c95 | 94 | |
fkellermavnet | 0:98d149685c95 | 95 | // Users must define these functionalities: |
fkellermavnet | 0:98d149685c95 | 96 | virtual int putc(char c); |
fkellermavnet | 0:98d149685c95 | 97 | virtual int puts(const char * s); |
fkellermavnet | 0:98d149685c95 | 98 | virtual char getc(void); |
fkellermavnet | 0:98d149685c95 | 99 | virtual int charReady(void); |
fkellermavnet | 0:98d149685c95 | 100 | virtual int dbgWriteChar(char b); |
fkellermavnet | 0:98d149685c95 | 101 | virtual int dbgWriteChars(const char *b); |
fkellermavnet | 0:98d149685c95 | 102 | virtual bool initWncModem(uint8_t powerUpTimeoutSecs); |
fkellermavnet | 0:98d149685c95 | 103 | virtual void waitMs(int t); |
fkellermavnet | 0:98d149685c95 | 104 | virtual void waitUs(int t); |
fkellermavnet | 0:98d149685c95 | 105 | |
fkellermavnet | 0:98d149685c95 | 106 | virtual int getLogTimerTicks(void); |
fkellermavnet | 0:98d149685c95 | 107 | virtual void startTimerA(void); |
fkellermavnet | 0:98d149685c95 | 108 | virtual void stopTimerA(void); |
fkellermavnet | 0:98d149685c95 | 109 | virtual int getTimerTicksA_mS(void); |
fkellermavnet | 0:98d149685c95 | 110 | virtual void startTimerB(void); |
fkellermavnet | 0:98d149685c95 | 111 | virtual void stopTimerB(void); |
fkellermavnet | 0:98d149685c95 | 112 | virtual int getTimerTicksB_mS(void); |
fkellermavnet | 0:98d149685c95 | 113 | |
fkellermavnet | 0:98d149685c95 | 114 | MODSERIAL * m_pDbgUart; |
fkellermavnet | 0:98d149685c95 | 115 | MODSERIAL * m_pWncUart; |
fkellermavnet | 0:98d149685c95 | 116 | WncGpioPinListK64F m_gpioPinList; |
fkellermavnet | 0:98d149685c95 | 117 | Timer m_logTimer; |
fkellermavnet | 0:98d149685c95 | 118 | Timer m_timerA; |
fkellermavnet | 0:98d149685c95 | 119 | Timer m_timerB; |
fkellermavnet | 0:98d149685c95 | 120 | }; |
fkellermavnet | 0:98d149685c95 | 121 | |
fkellermavnet | 0:98d149685c95 | 122 | }; // End namespace WncController_fk |
fkellermavnet | 0:98d149685c95 | 123 | |
fkellermavnet | 0:98d149685c95 | 124 | #endif |