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