SMS Scheduler that will automatically send and receive text messages using the Enfora 1308 GSM Modem. Please note that it uses a modified NetServices library and to set the baud rate for the GSM Modem to 19.2K.
MODSERIAL/INIT.cpp@1:5a7cce9994a3, 2011-10-13 (annotated)
- Committer:
- mafischl
- Date:
- Thu Oct 13 18:01:31 2011 +0000
- Revision:
- 1:5a7cce9994a3
- Parent:
- 0:d9266031f832
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mafischl | 0:d9266031f832 | 1 | /* |
mafischl | 0:d9266031f832 | 2 | Copyright (c) 2010 Andy Kirkham |
mafischl | 0:d9266031f832 | 3 | |
mafischl | 0:d9266031f832 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy |
mafischl | 0:d9266031f832 | 5 | of this software and associated documentation files (the "Software"), to deal |
mafischl | 0:d9266031f832 | 6 | in the Software without restriction, including without limitation the rights |
mafischl | 0:d9266031f832 | 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
mafischl | 0:d9266031f832 | 8 | copies of the Software, and to permit persons to whom the Software is |
mafischl | 0:d9266031f832 | 9 | furnished to do so, subject to the following conditions: |
mafischl | 0:d9266031f832 | 10 | |
mafischl | 0:d9266031f832 | 11 | The above copyright notice and this permission notice shall be included in |
mafischl | 0:d9266031f832 | 12 | all copies or substantial portions of the Software. |
mafischl | 0:d9266031f832 | 13 | |
mafischl | 0:d9266031f832 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
mafischl | 0:d9266031f832 | 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
mafischl | 0:d9266031f832 | 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
mafischl | 0:d9266031f832 | 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
mafischl | 0:d9266031f832 | 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
mafischl | 0:d9266031f832 | 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
mafischl | 0:d9266031f832 | 20 | THE SOFTWARE. |
mafischl | 0:d9266031f832 | 21 | */ |
mafischl | 0:d9266031f832 | 22 | |
mafischl | 0:d9266031f832 | 23 | #include "MODSERIAL.h" |
mafischl | 0:d9266031f832 | 24 | #include "MACROS.h" |
mafischl | 0:d9266031f832 | 25 | |
mafischl | 0:d9266031f832 | 26 | namespace AjK { |
mafischl | 0:d9266031f832 | 27 | |
mafischl | 0:d9266031f832 | 28 | void |
mafischl | 0:d9266031f832 | 29 | MODSERIAL::init(int txSize, int rxSize) |
mafischl | 0:d9266031f832 | 30 | { |
mafischl | 0:d9266031f832 | 31 | disableIrq(); |
mafischl | 0:d9266031f832 | 32 | |
mafischl | 0:d9266031f832 | 33 | callbackInfo.setSerial(this); |
mafischl | 0:d9266031f832 | 34 | |
mafischl | 0:d9266031f832 | 35 | switch(_uidx) { |
mafischl | 0:d9266031f832 | 36 | case 0: _base = LPC_UART0; break; |
mafischl | 0:d9266031f832 | 37 | case 1: _base = LPC_UART1; break; |
mafischl | 0:d9266031f832 | 38 | case 2: _base = LPC_UART2; break; |
mafischl | 0:d9266031f832 | 39 | case 3: _base = LPC_UART3; break; |
mafischl | 0:d9266031f832 | 40 | default : _base = NULL; break; |
mafischl | 0:d9266031f832 | 41 | } |
mafischl | 0:d9266031f832 | 42 | |
mafischl | 0:d9266031f832 | 43 | dmaSendChannel = -1; |
mafischl | 0:d9266031f832 | 44 | moddma_p = (void *)NULL; |
mafischl | 0:d9266031f832 | 45 | |
mafischl | 0:d9266031f832 | 46 | if (_base != NULL) { |
mafischl | 0:d9266031f832 | 47 | buffer_size[RxIrq] = rxSize; |
mafischl | 0:d9266031f832 | 48 | buffer[RxIrq] = rxSize > 0 ? (char *)malloc(buffer_size[RxIrq]) : (char *)NULL; |
mafischl | 0:d9266031f832 | 49 | buffer_in[RxIrq] = 0; |
mafischl | 0:d9266031f832 | 50 | buffer_out[RxIrq] = 0; |
mafischl | 0:d9266031f832 | 51 | buffer_count[RxIrq] = 0; |
mafischl | 0:d9266031f832 | 52 | buffer_overflow[RxIrq] = 0; |
mafischl | 0:d9266031f832 | 53 | Serial::attach(this, &MODSERIAL::isr_rx, Serial::RxIrq); |
mafischl | 0:d9266031f832 | 54 | |
mafischl | 0:d9266031f832 | 55 | buffer_size[TxIrq] = txSize; |
mafischl | 0:d9266031f832 | 56 | buffer[TxIrq] = txSize > 0 ? (char *)malloc(buffer_size[TxIrq]) : (char *)NULL; |
mafischl | 0:d9266031f832 | 57 | buffer_in[TxIrq] = 0; |
mafischl | 0:d9266031f832 | 58 | buffer_out[TxIrq] = 0; |
mafischl | 0:d9266031f832 | 59 | buffer_count[TxIrq] = 0; |
mafischl | 0:d9266031f832 | 60 | buffer_overflow[TxIrq] = 0; |
mafischl | 0:d9266031f832 | 61 | Serial::attach(this, &MODSERIAL::isr_tx, Serial::TxIrq); |
mafischl | 0:d9266031f832 | 62 | } |
mafischl | 0:d9266031f832 | 63 | else { |
mafischl | 0:d9266031f832 | 64 | error("MODSERIAL must have a defined UART to function."); |
mafischl | 0:d9266031f832 | 65 | } |
mafischl | 0:d9266031f832 | 66 | |
mafischl | 0:d9266031f832 | 67 | _FCR = MODSERIAL_FIFO_ENABLE | MODSERIAL_FIFO_RX_RESET | MODSERIAL_FIFO_TX_RESET; |
mafischl | 0:d9266031f832 | 68 | |
mafischl | 0:d9266031f832 | 69 | auto_detect_char = 0; |
mafischl | 0:d9266031f832 | 70 | |
mafischl | 0:d9266031f832 | 71 | enableIrq(); |
mafischl | 0:d9266031f832 | 72 | } |
mafischl | 0:d9266031f832 | 73 | |
mafischl | 0:d9266031f832 | 74 | }; // namespace AjK ends |