A project similar to http://mbed.org/users/lhiggs/code/UM6_IMU_AHRS_2012/, where I'm trying to log data from a UM6 (CH Robotics orientation sensor) and a GPS transceiver to an sd card. I've adapted LHiggs code to include ModGPS. For sum reason a soon as I pick up a gps signal the UM6 data freezes i.e. the time and gps signals continue to print out but the UM6 signals fixes on a single value.
Dependencies: MODGPS MODSERIAL SDFileSystem mbed
UM6_usart/UM6_usart.h@4:8dcf0bdc25c8, 2013-05-24 (annotated)
- Committer:
- njewin
- Date:
- Fri May 24 12:47:22 2013 +0000
- Revision:
- 4:8dcf0bdc25c8
using mod serial, included UM6 folders
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
njewin | 4:8dcf0bdc25c8 | 1 | /* ______________________________________________________________________________________ |
njewin | 4:8dcf0bdc25c8 | 2 | File: UM6_usart.h |
njewin | 4:8dcf0bdc25c8 | 3 | Author: CH Robotics, adapted for mbed by lhiggs |
njewin | 4:8dcf0bdc25c8 | 4 | Version: 1.0 |
njewin | 4:8dcf0bdc25c8 | 5 | |
njewin | 4:8dcf0bdc25c8 | 6 | Description: Function declarations for USART communucation |
njewin | 4:8dcf0bdc25c8 | 7 | -------------------------------------------------------------------------------------- */ |
njewin | 4:8dcf0bdc25c8 | 8 | |
njewin | 4:8dcf0bdc25c8 | 9 | #ifndef _CHR_USART_H |
njewin | 4:8dcf0bdc25c8 | 10 | #define _CHR_USART_H |
njewin | 4:8dcf0bdc25c8 | 11 | |
njewin | 4:8dcf0bdc25c8 | 12 | #define MAX_PACKET_DATA 40 |
njewin | 4:8dcf0bdc25c8 | 13 | |
njewin | 4:8dcf0bdc25c8 | 14 | // Definitions of states for USART receiver state machine (for receiving packets) |
njewin | 4:8dcf0bdc25c8 | 15 | #define USART_STATE_WAIT 1 |
njewin | 4:8dcf0bdc25c8 | 16 | #define USART_STATE_TYPE 2 |
njewin | 4:8dcf0bdc25c8 | 17 | #define USART_STATE_ADDRESS 3 |
njewin | 4:8dcf0bdc25c8 | 18 | #define USART_STATE_DATA 4 |
njewin | 4:8dcf0bdc25c8 | 19 | #define USART_STATE_CHECKSUM 5 |
njewin | 4:8dcf0bdc25c8 | 20 | |
njewin | 4:8dcf0bdc25c8 | 21 | // Flags for interpreting the packet type byte in communication packets |
njewin | 4:8dcf0bdc25c8 | 22 | #define PACKET_HAS_DATA (1 << 7) |
njewin | 4:8dcf0bdc25c8 | 23 | #define PACKET_IS_BATCH (1 << 6) |
njewin | 4:8dcf0bdc25c8 | 24 | #define PACKET_BATCH_LENGTH_MASK ( 0x0F ) |
njewin | 4:8dcf0bdc25c8 | 25 | |
njewin | 4:8dcf0bdc25c8 | 26 | #define PACKET_BATCH_LENGTH_OFFSET 2 |
njewin | 4:8dcf0bdc25c8 | 27 | |
njewin | 4:8dcf0bdc25c8 | 28 | #define BATCH_SIZE_2 2 |
njewin | 4:8dcf0bdc25c8 | 29 | #define BATCH_SIZE_3 3 |
njewin | 4:8dcf0bdc25c8 | 30 | |
njewin | 4:8dcf0bdc25c8 | 31 | #define PACKET_NO_DATA 0 |
njewin | 4:8dcf0bdc25c8 | 32 | #define PACKET_COMMAND_FAILED (1 << 0) |
njewin | 4:8dcf0bdc25c8 | 33 | |
njewin | 4:8dcf0bdc25c8 | 34 | |
njewin | 4:8dcf0bdc25c8 | 35 | // Define flags for identifying the type of packet address received |
njewin | 4:8dcf0bdc25c8 | 36 | #define ADDRESS_TYPE_CONFIG 0 |
njewin | 4:8dcf0bdc25c8 | 37 | #define ADDRESS_TYPE_DATA 1 |
njewin | 4:8dcf0bdc25c8 | 38 | #define ADDRESS_TYPE_COMMAND 2 |
njewin | 4:8dcf0bdc25c8 | 39 | |
njewin | 4:8dcf0bdc25c8 | 40 | |
njewin | 4:8dcf0bdc25c8 | 41 | extern uint8_t gUSART_State; |
njewin | 4:8dcf0bdc25c8 | 42 | |
njewin | 4:8dcf0bdc25c8 | 43 | // Structure for storing TX and RX packet data |
njewin | 4:8dcf0bdc25c8 | 44 | typedef struct _USARTPacket |
njewin | 4:8dcf0bdc25c8 | 45 | { |
njewin | 4:8dcf0bdc25c8 | 46 | uint8_t PT; // Packet type |
njewin | 4:8dcf0bdc25c8 | 47 | uint8_t address; // Packet address |
njewin | 4:8dcf0bdc25c8 | 48 | uint16_t checksum; // Checksum |
njewin | 4:8dcf0bdc25c8 | 49 | |
njewin | 4:8dcf0bdc25c8 | 50 | // Data included for convenience, but that isn't stored in the packet itself |
njewin | 4:8dcf0bdc25c8 | 51 | uint8_t data_length; // Number of bytes in data section |
njewin | 4:8dcf0bdc25c8 | 52 | uint8_t address_type; // Specified the address type (DATA, CONFIG, OR COMMAND) |
njewin | 4:8dcf0bdc25c8 | 53 | |
njewin | 4:8dcf0bdc25c8 | 54 | uint8_t packet_data[MAX_PACKET_DATA]; |
njewin | 4:8dcf0bdc25c8 | 55 | |
njewin | 4:8dcf0bdc25c8 | 56 | } USARTPacket; |
njewin | 4:8dcf0bdc25c8 | 57 | |
njewin | 4:8dcf0bdc25c8 | 58 | uint16_t ComputeChecksum( USARTPacket* new_packet ); |
njewin | 4:8dcf0bdc25c8 | 59 | |
njewin | 4:8dcf0bdc25c8 | 60 | #endif |