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