Trying to log data from UM6 sensor with GPS receiver LS20031. I have two problems: - I can't log to file at a fast rate (<0.5s) without data values freezing to a fixed value. Print to pc screen it works fine. Ideally I would do this with an interrupt (e.g. ticker) so that the time of each reading is a fixed interval - I removed this as I thought this was causing the problem. - I want to record GPS lat and long. I have setup the GPS ground speed so I know the sensor are communicating. So I possibly havent set the config file to correctly interpet these two signals.

Dependencies:   MODSERIAL mbed

Fork of UM6_IMU_AHRS_2012 by lhiggs CSUM

Committer:
njewin
Date:
Sat May 04 09:34:15 2013 +0000
Revision:
6:43029c69b9ac
Parent:
0:03c649c76388
publish version ; bugs need correcting for:; - logging to file at 10ms rate; - reading GPS lat and long data

Who changed what in which revision?

UserRevisionLine numberNew contents of line
lhiggs 0:03c649c76388 1 /*
lhiggs 0:03c649c76388 2 Copyright (c) 2010 Andy Kirkham
lhiggs 0:03c649c76388 3
lhiggs 0:03c649c76388 4 Permission is hereby granted, free of charge, to any person obtaining a copy
lhiggs 0:03c649c76388 5 of this software and associated documentation files (the "Software"), to deal
lhiggs 0:03c649c76388 6 in the Software without restriction, including without limitation the rights
lhiggs 0:03c649c76388 7 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
lhiggs 0:03c649c76388 8 copies of the Software, and to permit persons to whom the Software is
lhiggs 0:03c649c76388 9 furnished to do so, subject to the following conditions:
lhiggs 0:03c649c76388 10
lhiggs 0:03c649c76388 11 The above copyright notice and this permission notice shall be included in
lhiggs 0:03c649c76388 12 all copies or substantial portions of the Software.
lhiggs 0:03c649c76388 13
lhiggs 0:03c649c76388 14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
lhiggs 0:03c649c76388 15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
lhiggs 0:03c649c76388 16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
lhiggs 0:03c649c76388 17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
lhiggs 0:03c649c76388 18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
lhiggs 0:03c649c76388 19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
lhiggs 0:03c649c76388 20 THE SOFTWARE.
lhiggs 0:03c649c76388 21 */
lhiggs 0:03c649c76388 22
lhiggs 0:03c649c76388 23 #include "MODSERIAL.h"
lhiggs 0:03c649c76388 24 #include "MACROS.h"
lhiggs 0:03c649c76388 25
lhiggs 0:03c649c76388 26 namespace AjK {
lhiggs 0:03c649c76388 27
lhiggs 0:03c649c76388 28 int
lhiggs 0:03c649c76388 29 MODSERIAL::__putc(int c, bool block) {
lhiggs 0:03c649c76388 30
lhiggs 0:03c649c76388 31 // If no buffer is in use fall back to standard TX FIFO usage.
lhiggs 0:03c649c76388 32 // Note, we must block in this case and ignore bool "block"
lhiggs 0:03c649c76388 33 // so as to maintain compat with Mbed Serial.
lhiggs 0:03c649c76388 34 if (buffer[TxIrq] == (char *)NULL || buffer_size[TxIrq] == 0) {
lhiggs 0:03c649c76388 35 while (! MODSERIAL_THR_HAS_SPACE) ; // Wait for space in the TX FIFO.
lhiggs 0:03c649c76388 36 _THR = (uint32_t)c;
lhiggs 0:03c649c76388 37 return 0;
lhiggs 0:03c649c76388 38 }
lhiggs 0:03c649c76388 39
lhiggs 0:03c649c76388 40 if ( MODSERIAL_THR_HAS_SPACE && MODSERIAL_TX_BUFFER_EMPTY && dmaSendChannel == -1 ) {
lhiggs 0:03c649c76388 41 _THR = (uint32_t)c;
lhiggs 0:03c649c76388 42 }
lhiggs 0:03c649c76388 43 else {
lhiggs 0:03c649c76388 44 if (block) {
lhiggs 0:03c649c76388 45 uint32_t ier = _IER; _IER = 1;
lhiggs 0:03c649c76388 46 while ( MODSERIAL_TX_BUFFER_FULL ) { // Blocks!
lhiggs 0:03c649c76388 47 // If putc() is called from an ISR then we are stuffed
lhiggs 0:03c649c76388 48 // because in an ISR no bytes from the TX buffer will
lhiggs 0:03c649c76388 49 // get transferred to teh TX FIFOs while we block here.
lhiggs 0:03c649c76388 50 // So, to work around this, instead of sitting in a
lhiggs 0:03c649c76388 51 // loop waiting for space in the TX buffer (which will
lhiggs 0:03c649c76388 52 // never happen in IRQ context), check to see if the
lhiggs 0:03c649c76388 53 // TX FIFO has space available to move bytes from the
lhiggs 0:03c649c76388 54 // TX buffer to TX FIFO to make space. The easiest way
lhiggs 0:03c649c76388 55 // to do this is to poll the isr_tx() function while we
lhiggs 0:03c649c76388 56 // are blocking.
lhiggs 0:03c649c76388 57 isr_tx(false);
lhiggs 0:03c649c76388 58 }
lhiggs 0:03c649c76388 59 _IER = ier;
lhiggs 0:03c649c76388 60 }
lhiggs 0:03c649c76388 61 else if( MODSERIAL_TX_BUFFER_FULL ) {
lhiggs 0:03c649c76388 62 buffer_overflow[TxIrq] = c; // Oh dear, no room in buffer.
lhiggs 0:03c649c76388 63 _isr[TxOvIrq].call(&this->callbackInfo);
lhiggs 0:03c649c76388 64 return -1;
lhiggs 0:03c649c76388 65 }
lhiggs 0:03c649c76388 66 _IER &= ~2;
lhiggs 0:03c649c76388 67 buffer[TxIrq][buffer_in[TxIrq]] = c;
lhiggs 0:03c649c76388 68 __disable_irq();
lhiggs 0:03c649c76388 69 buffer_count[TxIrq]++;
lhiggs 0:03c649c76388 70 __enable_irq();
lhiggs 0:03c649c76388 71 buffer_in[TxIrq]++;
lhiggs 0:03c649c76388 72 if (buffer_in[TxIrq] >= buffer_size[TxIrq]) {
lhiggs 0:03c649c76388 73 buffer_in[TxIrq] = 0;
lhiggs 0:03c649c76388 74 }
lhiggs 0:03c649c76388 75 _IER |= 2;
lhiggs 0:03c649c76388 76 }
lhiggs 0:03c649c76388 77
lhiggs 0:03c649c76388 78 return 0;
lhiggs 0:03c649c76388 79 }
lhiggs 0:03c649c76388 80
lhiggs 0:03c649c76388 81 }; // namespace AjK ends