Demo application for using the AT&T IoT Starter Kit Powered by AWS.
Dependencies: SDFileSystem
Fork of ATT_AWS_IoT_demo by
INIT.cpp
00001 /* 00002 Copyright (c) 2010 Andy Kirkham 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 00023 #include "MODSERIAL.h" 00024 #include "MACROS.h" 00025 00026 #define MODSERIAL_FCR 0x08 00027 #define _FCR *((char *)_base+MODSERIAL_FCR) 00028 00029 #define MODSERIAL_FIFO_ENABLE 1 00030 #define MODSERIAL_FIFO_RX_RESET 2 00031 #define MODSERIAL_FIFO_TX_RESET 4 00032 00033 00034 namespace AjK { 00035 00036 void 00037 MODSERIAL::init( int txSize, int rxSize, PinName rx ) 00038 { 00039 00040 NVIC_DisableIRQ(_IRQ); 00041 setBase(); 00042 00043 callbackInfo.setSerial(this); 00044 00045 00046 if ( _base != NULL ) { 00047 buffer_size[RxIrq] = rxSize; 00048 buffer[RxIrq] = rxSize > 0 ? (char *)malloc(buffer_size[RxIrq]) : (char *)NULL; 00049 buffer_in[RxIrq] = 0; 00050 buffer_out[RxIrq] = 0; 00051 buffer_count[RxIrq] = 0; 00052 buffer_overflow[RxIrq] = 0; 00053 Serial::attach( this, &MODSERIAL::isr_rx, Serial::RxIrq ); 00054 00055 buffer_size[TxIrq] = txSize; 00056 buffer[TxIrq] = txSize > 0 ? (char *)malloc(buffer_size[TxIrq]) : (char *)NULL; 00057 buffer_in[TxIrq] = 0; 00058 buffer_out[TxIrq] = 0; 00059 buffer_count[TxIrq] = 0; 00060 buffer_overflow[TxIrq] = 0; 00061 Serial::attach( this, &MODSERIAL::isr_tx, Serial::TxIrq ); 00062 } 00063 else { 00064 error("MODSERIAL must have a defined UART to function."); 00065 } 00066 00067 00068 initDevice(); 00069 00070 //_FCR = MODSERIAL_FIFO_ENABLE | MODSERIAL_FIFO_RX_RESET | MODSERIAL_FIFO_TX_RESET; 00071 00072 auto_detect_char = 0; 00073 00074 NVIC_EnableIRQ(_IRQ); 00075 } 00076 00077 }; // namespace AjK ends 00078 00079
Generated on Tue Jul 12 2022 22:13:20 by 1.7.2