Mobile Life IoT project using the AT&T IoT Starter Kit Software and files for my device to monitor the status or our Airstream travel trailer RV. A full description of the project is at Hackster.IO here as part of the Realtime AT&T IoT Starter Kit Challenge: https://www.hackster.io/Anubus/mobile-life-iot-9c10be

Dependencies:   FXOS8700CQ MODSERIAL mbed

Committer:
Anubus
Date:
Sun Apr 02 12:28:21 2017 +0000
Revision:
0:bd276b1f1249
public version commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Anubus 0:bd276b1f1249 1 /* ===================================================================
Anubus 0:bd276b1f1249 2 Copyright © 2016, AVNET Inc.
Anubus 0:bd276b1f1249 3
Anubus 0:bd276b1f1249 4 Licensed under the Apache License, Version 2.0 (the "License");
Anubus 0:bd276b1f1249 5 you may not use this file except in compliance with the License.
Anubus 0:bd276b1f1249 6 You may obtain a copy of the License at
Anubus 0:bd276b1f1249 7
Anubus 0:bd276b1f1249 8 http://www.apache.org/licenses/LICENSE-2.0
Anubus 0:bd276b1f1249 9
Anubus 0:bd276b1f1249 10 Unless required by applicable law or agreed to in writing,
Anubus 0:bd276b1f1249 11 software distributed under the License is distributed on an
Anubus 0:bd276b1f1249 12 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
Anubus 0:bd276b1f1249 13 either express or implied. See the License for the specific
Anubus 0:bd276b1f1249 14 language governing permissions and limitations under the License.
Anubus 0:bd276b1f1249 15
Anubus 0:bd276b1f1249 16 ======================================================================== */
Anubus 0:bd276b1f1249 17
Anubus 0:bd276b1f1249 18 //Used for ULINK output only
Anubus 0:bd276b1f1249 19 //
Anubus 0:bd276b1f1249 20
Anubus 0:bd276b1f1249 21 /* ITM registers */
Anubus 0:bd276b1f1249 22 #define ITM_PORT0_U8 (*((volatile unsigned int *)0xE0000000))
Anubus 0:bd276b1f1249 23 #define ITM_PORT0_U32 (*((volatile unsigned long *)0xE0000000))
Anubus 0:bd276b1f1249 24 #define ITM_TER (*((volatile unsigned long *)0xE0000E00))
Anubus 0:bd276b1f1249 25 #define ITM_TCR (*((volatile unsigned long *)0xE0000E80))
Anubus 0:bd276b1f1249 26
Anubus 0:bd276b1f1249 27 #define ITM_TCR_ITMENA_Msk (1UL << 0)
Anubus 0:bd276b1f1249 28
Anubus 0:bd276b1f1249 29 /*!< Value identifying \ref ITM_RxBuffer is ready for next character. */
Anubus 0:bd276b1f1249 30 #define ITM_RXBUFFER_EMPTY 0x5AA55AA5
Anubus 0:bd276b1f1249 31
Anubus 0:bd276b1f1249 32 /*!< Variable to receive characters. */
Anubus 0:bd276b1f1249 33 extern
Anubus 0:bd276b1f1249 34 volatile int ITM_RxBuffer;
Anubus 0:bd276b1f1249 35 volatile int ITM_RxBuffer = ITM_RXBUFFER_EMPTY;
Anubus 0:bd276b1f1249 36
Anubus 0:bd276b1f1249 37 /** \brief ITM Send Character
Anubus 0:bd276b1f1249 38
Anubus 0:bd276b1f1249 39 The function transmits a character via the ITM channel 0, and
Anubus 0:bd276b1f1249 40 \li Just returns when no debugger is connected that has booked the output.
Anubus 0:bd276b1f1249 41 \li Is blocking when a debugger is connected, but the previous character
Anubus 0:bd276b1f1249 42 sent has not been transmitted.
Anubus 0:bd276b1f1249 43
Anubus 0:bd276b1f1249 44 \param [in] ch Character to transmit.
Anubus 0:bd276b1f1249 45
Anubus 0:bd276b1f1249 46 \returns Character to transmit.
Anubus 0:bd276b1f1249 47 */
Anubus 0:bd276b1f1249 48 int ITM_putc (int ch) {
Anubus 0:bd276b1f1249 49 if ((ITM_TCR & ITM_TCR_ITMENA_Msk) && /* ITM enabled */
Anubus 0:bd276b1f1249 50 (ITM_TER & (1UL << 0) )) { /* ITM Port #0 enabled */
Anubus 0:bd276b1f1249 51 while (ITM_PORT0_U32 == 0);
Anubus 0:bd276b1f1249 52 ITM_PORT0_U8 = (int)ch;
Anubus 0:bd276b1f1249 53 }
Anubus 0:bd276b1f1249 54 return (ch);
Anubus 0:bd276b1f1249 55 }
Anubus 0:bd276b1f1249 56
Anubus 0:bd276b1f1249 57 /** \brief ITM Receive Character
Anubus 0:bd276b1f1249 58
Anubus 0:bd276b1f1249 59 The function inputs a character via the external variable \ref ITM_RxBuffer.
Anubus 0:bd276b1f1249 60 This variable is monitored and altered by the debugger to provide input.
Anubus 0:bd276b1f1249 61
Anubus 0:bd276b1f1249 62 \return Received character.
Anubus 0:bd276b1f1249 63 \return -1 No character pending.
Anubus 0:bd276b1f1249 64 */
Anubus 0:bd276b1f1249 65 int ITM_getc (void) {
Anubus 0:bd276b1f1249 66 int ch = -1; /* no character available */
Anubus 0:bd276b1f1249 67
Anubus 0:bd276b1f1249 68 if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) {
Anubus 0:bd276b1f1249 69 ch = ITM_RxBuffer;
Anubus 0:bd276b1f1249 70 ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */
Anubus 0:bd276b1f1249 71 }
Anubus 0:bd276b1f1249 72
Anubus 0:bd276b1f1249 73 return (ch);
Anubus 0:bd276b1f1249 74 }
Anubus 0:bd276b1f1249 75
Anubus 0:bd276b1f1249 76 /** \brief ITM send string
Anubus 0:bd276b1f1249 77
Anubus 0:bd276b1f1249 78 The function sends a null terminated string via the external variable \ref ITM_RxBuffer.
Anubus 0:bd276b1f1249 79 This variable is monitored and altered by the debugger to provide input.
Anubus 0:bd276b1f1249 80
Anubus 0:bd276b1f1249 81 \return Received character.
Anubus 0:bd276b1f1249 82 \return -1 No character pending.
Anubus 0:bd276b1f1249 83 */
Anubus 0:bd276b1f1249 84 int ITM_puts (char * str) {
Anubus 0:bd276b1f1249 85 int i=0;
Anubus 0:bd276b1f1249 86
Anubus 0:bd276b1f1249 87 while(str[i])
Anubus 0:bd276b1f1249 88 ITM_putc(str[i++]);
Anubus 0:bd276b1f1249 89 return i;
Anubus 0:bd276b1f1249 90 }
Anubus 0:bd276b1f1249 91