![](/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/MODSERIAL/INIT.cpp@29:537df716ba0b, 2017-04-05 (annotated)
- Committer:
- peyo
- Date:
- Wed Apr 05 16:05:41 2017 +0000
- Revision:
- 29:537df716ba0b
- Parent:
- 15:6f2798e45099
Use IKS01A1 sensors
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ampembeng | 15:6f2798e45099 | 1 | /* |
ampembeng | 15:6f2798e45099 | 2 | Copyright (c) 2010 Andy Kirkham |
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 | |
ampembeng | 15:6f2798e45099 | 23 | #include "MODSERIAL.h" |
ampembeng | 15:6f2798e45099 | 24 | #include "MACROS.h" |
ampembeng | 15:6f2798e45099 | 25 | |
ampembeng | 15:6f2798e45099 | 26 | #define MODSERIAL_FCR 0x08 |
ampembeng | 15:6f2798e45099 | 27 | #define _FCR *((char *)_base+MODSERIAL_FCR) |
ampembeng | 15:6f2798e45099 | 28 | |
ampembeng | 15:6f2798e45099 | 29 | #define MODSERIAL_FIFO_ENABLE 1 |
ampembeng | 15:6f2798e45099 | 30 | #define MODSERIAL_FIFO_RX_RESET 2 |
ampembeng | 15:6f2798e45099 | 31 | #define MODSERIAL_FIFO_TX_RESET 4 |
ampembeng | 15:6f2798e45099 | 32 | |
ampembeng | 15:6f2798e45099 | 33 | |
ampembeng | 15:6f2798e45099 | 34 | namespace AjK { |
ampembeng | 15:6f2798e45099 | 35 | |
ampembeng | 15:6f2798e45099 | 36 | void |
ampembeng | 15:6f2798e45099 | 37 | MODSERIAL::init( int txSize, int rxSize, PinName rx ) |
ampembeng | 15:6f2798e45099 | 38 | { |
ampembeng | 15:6f2798e45099 | 39 | |
ampembeng | 15:6f2798e45099 | 40 | NVIC_DisableIRQ(_IRQ); |
ampembeng | 15:6f2798e45099 | 41 | setBase(); |
ampembeng | 15:6f2798e45099 | 42 | |
ampembeng | 15:6f2798e45099 | 43 | callbackInfo.setSerial(this); |
ampembeng | 15:6f2798e45099 | 44 | |
ampembeng | 15:6f2798e45099 | 45 | |
ampembeng | 15:6f2798e45099 | 46 | if ( _base != NULL ) { |
ampembeng | 15:6f2798e45099 | 47 | buffer_size[RxIrq] = rxSize; |
ampembeng | 15:6f2798e45099 | 48 | buffer[RxIrq] = rxSize > 0 ? (char *)malloc(buffer_size[RxIrq]) : (char *)NULL; |
ampembeng | 15:6f2798e45099 | 49 | buffer_in[RxIrq] = 0; |
ampembeng | 15:6f2798e45099 | 50 | buffer_out[RxIrq] = 0; |
ampembeng | 15:6f2798e45099 | 51 | buffer_count[RxIrq] = 0; |
ampembeng | 15:6f2798e45099 | 52 | buffer_overflow[RxIrq] = 0; |
ampembeng | 15:6f2798e45099 | 53 | Serial::attach( this, &MODSERIAL::isr_rx, Serial::RxIrq ); |
ampembeng | 15:6f2798e45099 | 54 | |
ampembeng | 15:6f2798e45099 | 55 | buffer_size[TxIrq] = txSize; |
ampembeng | 15:6f2798e45099 | 56 | buffer[TxIrq] = txSize > 0 ? (char *)malloc(buffer_size[TxIrq]) : (char *)NULL; |
ampembeng | 15:6f2798e45099 | 57 | buffer_in[TxIrq] = 0; |
ampembeng | 15:6f2798e45099 | 58 | buffer_out[TxIrq] = 0; |
ampembeng | 15:6f2798e45099 | 59 | buffer_count[TxIrq] = 0; |
ampembeng | 15:6f2798e45099 | 60 | buffer_overflow[TxIrq] = 0; |
ampembeng | 15:6f2798e45099 | 61 | Serial::attach( this, &MODSERIAL::isr_tx, Serial::TxIrq ); |
ampembeng | 15:6f2798e45099 | 62 | } |
ampembeng | 15:6f2798e45099 | 63 | else { |
ampembeng | 15:6f2798e45099 | 64 | error("MODSERIAL must have a defined UART to function."); |
ampembeng | 15:6f2798e45099 | 65 | } |
ampembeng | 15:6f2798e45099 | 66 | |
ampembeng | 15:6f2798e45099 | 67 | |
ampembeng | 15:6f2798e45099 | 68 | initDevice(); |
ampembeng | 15:6f2798e45099 | 69 | |
ampembeng | 15:6f2798e45099 | 70 | //_FCR = MODSERIAL_FIFO_ENABLE | MODSERIAL_FIFO_RX_RESET | MODSERIAL_FIFO_TX_RESET; |
ampembeng | 15:6f2798e45099 | 71 | |
ampembeng | 15:6f2798e45099 | 72 | auto_detect_char = 0; |
ampembeng | 15:6f2798e45099 | 73 | |
ampembeng | 15:6f2798e45099 | 74 | NVIC_EnableIRQ(_IRQ); |
ampembeng | 15:6f2798e45099 | 75 | } |
ampembeng | 15:6f2798e45099 | 76 | |
ampembeng | 15:6f2798e45099 | 77 | }; // namespace AjK ends |
ampembeng | 15:6f2798e45099 | 78 | |
ampembeng | 15:6f2798e45099 | 79 |