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.
Fork of UM6_IMU_AHRS_2012 by
UM6_usart/UM6_usart.h@6:43029c69b9ac, 2013-05-04 (annotated)
- 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?
User | Revision | Line number | New contents of line |
---|---|---|---|
lhiggs | 0:03c649c76388 | 1 | /* ______________________________________________________________________________________ |
lhiggs | 0:03c649c76388 | 2 | File: UM6_usart.h |
lhiggs | 0:03c649c76388 | 3 | Author: CH Robotics, adapted for mbed by lhiggs |
lhiggs | 0:03c649c76388 | 4 | Version: 1.0 |
lhiggs | 0:03c649c76388 | 5 | |
lhiggs | 0:03c649c76388 | 6 | Description: Function declarations for USART communucation |
lhiggs | 0:03c649c76388 | 7 | -------------------------------------------------------------------------------------- */ |
lhiggs | 0:03c649c76388 | 8 | |
lhiggs | 0:03c649c76388 | 9 | #ifndef _CHR_USART_H |
lhiggs | 0:03c649c76388 | 10 | #define _CHR_USART_H |
lhiggs | 0:03c649c76388 | 11 | |
lhiggs | 0:03c649c76388 | 12 | #define MAX_PACKET_DATA 40 |
lhiggs | 0:03c649c76388 | 13 | |
lhiggs | 0:03c649c76388 | 14 | // Definitions of states for USART receiver state machine (for receiving packets) |
lhiggs | 0:03c649c76388 | 15 | #define USART_STATE_WAIT 1 |
lhiggs | 0:03c649c76388 | 16 | #define USART_STATE_TYPE 2 |
lhiggs | 0:03c649c76388 | 17 | #define USART_STATE_ADDRESS 3 |
lhiggs | 0:03c649c76388 | 18 | #define USART_STATE_DATA 4 |
lhiggs | 0:03c649c76388 | 19 | #define USART_STATE_CHECKSUM 5 |
lhiggs | 0:03c649c76388 | 20 | |
lhiggs | 0:03c649c76388 | 21 | // Flags for interpreting the packet type byte in communication packets |
lhiggs | 0:03c649c76388 | 22 | #define PACKET_HAS_DATA (1 << 7) |
lhiggs | 0:03c649c76388 | 23 | #define PACKET_IS_BATCH (1 << 6) |
lhiggs | 0:03c649c76388 | 24 | #define PACKET_BATCH_LENGTH_MASK ( 0x0F ) |
lhiggs | 0:03c649c76388 | 25 | |
lhiggs | 0:03c649c76388 | 26 | #define PACKET_BATCH_LENGTH_OFFSET 2 |
lhiggs | 0:03c649c76388 | 27 | |
lhiggs | 0:03c649c76388 | 28 | #define BATCH_SIZE_2 2 |
lhiggs | 0:03c649c76388 | 29 | #define BATCH_SIZE_3 3 |
lhiggs | 0:03c649c76388 | 30 | |
lhiggs | 0:03c649c76388 | 31 | #define PACKET_NO_DATA 0 |
lhiggs | 0:03c649c76388 | 32 | #define PACKET_COMMAND_FAILED (1 << 0) |
lhiggs | 0:03c649c76388 | 33 | |
lhiggs | 0:03c649c76388 | 34 | |
lhiggs | 0:03c649c76388 | 35 | // Define flags for identifying the type of packet address received |
lhiggs | 0:03c649c76388 | 36 | #define ADDRESS_TYPE_CONFIG 0 |
lhiggs | 0:03c649c76388 | 37 | #define ADDRESS_TYPE_DATA 1 |
lhiggs | 0:03c649c76388 | 38 | #define ADDRESS_TYPE_COMMAND 2 |
lhiggs | 0:03c649c76388 | 39 | |
lhiggs | 0:03c649c76388 | 40 | |
lhiggs | 0:03c649c76388 | 41 | extern uint8_t gUSART_State; |
lhiggs | 0:03c649c76388 | 42 | |
lhiggs | 0:03c649c76388 | 43 | // Structure for storing TX and RX packet data |
lhiggs | 0:03c649c76388 | 44 | typedef struct _USARTPacket |
lhiggs | 0:03c649c76388 | 45 | { |
lhiggs | 0:03c649c76388 | 46 | uint8_t PT; // Packet type |
lhiggs | 0:03c649c76388 | 47 | uint8_t address; // Packet address |
lhiggs | 0:03c649c76388 | 48 | uint16_t checksum; // Checksum |
lhiggs | 0:03c649c76388 | 49 | |
lhiggs | 0:03c649c76388 | 50 | // Data included for convenience, but that isn't stored in the packet itself |
lhiggs | 0:03c649c76388 | 51 | uint8_t data_length; // Number of bytes in data section |
lhiggs | 0:03c649c76388 | 52 | uint8_t address_type; // Specified the address type (DATA, CONFIG, OR COMMAND) |
lhiggs | 0:03c649c76388 | 53 | |
lhiggs | 0:03c649c76388 | 54 | uint8_t packet_data[MAX_PACKET_DATA]; |
lhiggs | 0:03c649c76388 | 55 | |
lhiggs | 0:03c649c76388 | 56 | } USARTPacket; |
lhiggs | 0:03c649c76388 | 57 | |
lhiggs | 0:03c649c76388 | 58 | uint16_t ComputeChecksum( USARTPacket* new_packet ); |
lhiggs | 0:03c649c76388 | 59 | |
lhiggs | 0:03c649c76388 | 60 | #endif |