Test1 of cmsis and IMU/AHRS (sensor BMA180,HMC5883,ITG3200) IMU/AHRS is not ok

Dependencies:   mbed

Committer:
caroe
Date:
Mon Jun 11 12:02:30 2012 +0000
Revision:
0:cb04b53e6f9b

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
caroe 0:cb04b53e6f9b 1 /**
caroe 0:cb04b53e6f9b 2 * Configuration file interface class (Version 0.0.1)
caroe 0:cb04b53e6f9b 3 *
caroe 0:cb04b53e6f9b 4 * Copyright (C) 2010 Shinichiro Nakamura (CuBeatSystems)
caroe 0:cb04b53e6f9b 5 * http://shinta.main.jp/
caroe 0:cb04b53e6f9b 6 */
caroe 0:cb04b53e6f9b 7 #include "mbed.h"
caroe 0:cb04b53e6f9b 8 #include "cmsis_os.h"
caroe 0:cb04b53e6f9b 9 #ifndef _CONFIG_FILE_H_
caroe 0:cb04b53e6f9b 10 #define _CONFIG_FILE_H_
caroe 0:cb04b53e6f9b 11
caroe 0:cb04b53e6f9b 12 /**
caroe 0:cb04b53e6f9b 13 * Configuration File class.
caroe 0:cb04b53e6f9b 14 */
caroe 0:cb04b53e6f9b 15 class ConfigFile {
caroe 0:cb04b53e6f9b 16 public:
caroe 0:cb04b53e6f9b 17
caroe 0:cb04b53e6f9b 18 /**
caroe 0:cb04b53e6f9b 19 * Create a configuration file class.
caroe 0:cb04b53e6f9b 20 */
caroe 0:cb04b53e6f9b 21 ConfigFile();
caroe 0:cb04b53e6f9b 22
caroe 0:cb04b53e6f9b 23 /**
caroe 0:cb04b53e6f9b 24 * Destroy a configuration file class.
caroe 0:cb04b53e6f9b 25 */
caroe 0:cb04b53e6f9b 26 ~ConfigFile();
caroe 0:cb04b53e6f9b 27
caroe 0:cb04b53e6f9b 28 /**
caroe 0:cb04b53e6f9b 29 * Get a value for a key.
caroe 0:cb04b53e6f9b 30 *
caroe 0:cb04b53e6f9b 31 * @param key A target key name.
caroe 0:cb04b53e6f9b 32 * @param value A pointer to a value storage.
caroe 0:cb04b53e6f9b 33 * @param siz A size of a value storage.
caroe 0:cb04b53e6f9b 34 * @return A value or NULL.
caroe 0:cb04b53e6f9b 35 */
caroe 0:cb04b53e6f9b 36 bool getValue(char *key, char *value, size_t siz);
caroe 0:cb04b53e6f9b 37
caroe 0:cb04b53e6f9b 38 /**
caroe 0:cb04b53e6f9b 39 * Set a set of a key and value.
caroe 0:cb04b53e6f9b 40 *
caroe 0:cb04b53e6f9b 41 * @param key A key.
caroe 0:cb04b53e6f9b 42 * @param value A value.
caroe 0:cb04b53e6f9b 43 *
caroe 0:cb04b53e6f9b 44 * @return True if it succeed.
caroe 0:cb04b53e6f9b 45 */
caroe 0:cb04b53e6f9b 46 bool setValue(char *key, char *value);
caroe 0:cb04b53e6f9b 47
caroe 0:cb04b53e6f9b 48 /**
caroe 0:cb04b53e6f9b 49 * Remove a config.
caroe 0:cb04b53e6f9b 50 *
caroe 0:cb04b53e6f9b 51 * @param key A key.
caroe 0:cb04b53e6f9b 52 *
caroe 0:cb04b53e6f9b 53 * @return True if it succeed.
caroe 0:cb04b53e6f9b 54 */
caroe 0:cb04b53e6f9b 55 bool remove(char *key);
caroe 0:cb04b53e6f9b 56
caroe 0:cb04b53e6f9b 57 /**
caroe 0:cb04b53e6f9b 58 * Remove all config.
caroe 0:cb04b53e6f9b 59 *
caroe 0:cb04b53e6f9b 60 * @return True if it succeed.
caroe 0:cb04b53e6f9b 61 */
caroe 0:cb04b53e6f9b 62 bool removeAll(void);
caroe 0:cb04b53e6f9b 63
caroe 0:cb04b53e6f9b 64 /**
caroe 0:cb04b53e6f9b 65 * Get a number of configuration sets.
caroe 0:cb04b53e6f9b 66 *
caroe 0:cb04b53e6f9b 67 * @return number of configuration sets.
caroe 0:cb04b53e6f9b 68 */
caroe 0:cb04b53e6f9b 69 int getCount();
caroe 0:cb04b53e6f9b 70
caroe 0:cb04b53e6f9b 71 /**
caroe 0:cb04b53e6f9b 72 * Get a key and a value.
caroe 0:cb04b53e6f9b 73 *
caroe 0:cb04b53e6f9b 74 * @param index Index number of this list.
caroe 0:cb04b53e6f9b 75 * @param key A pointer to a buffer for key.
caroe 0:cb04b53e6f9b 76 * @param keybufsiz A size of the key buffer.
caroe 0:cb04b53e6f9b 77 * @param value A pointer to a buffer for value.
caroe 0:cb04b53e6f9b 78 * @param valuebufsiz A size of the value buffer.
caroe 0:cb04b53e6f9b 79 *
caroe 0:cb04b53e6f9b 80 * @return true if it succeed.
caroe 0:cb04b53e6f9b 81 */
caroe 0:cb04b53e6f9b 82 bool getKeyAndValue(int index, char *key, size_t keybufsiz, char *value, size_t valuebufsiz);
caroe 0:cb04b53e6f9b 83
caroe 0:cb04b53e6f9b 84 /**
caroe 0:cb04b53e6f9b 85 * Read from the target file.
caroe 0:cb04b53e6f9b 86 *
caroe 0:cb04b53e6f9b 87 * @param file A target file name.
caroe 0:cb04b53e6f9b 88 */
caroe 0:cb04b53e6f9b 89 bool read(char *file);
caroe 0:cb04b53e6f9b 90
caroe 0:cb04b53e6f9b 91 typedef enum {
caroe 0:cb04b53e6f9b 92 UNIX,
caroe 0:cb04b53e6f9b 93 MAC,
caroe 0:cb04b53e6f9b 94 DOS
caroe 0:cb04b53e6f9b 95 } FileFormat;
caroe 0:cb04b53e6f9b 96
caroe 0:cb04b53e6f9b 97 /**
caroe 0:cb04b53e6f9b 98 * Write from the target file.
caroe 0:cb04b53e6f9b 99 *
caroe 0:cb04b53e6f9b 100 * @param file A pointer to a file name.
caroe 0:cb04b53e6f9b 101 * @param header A pointer to a header.
caroe 0:cb04b53e6f9b 102 * @param ff File format.
caroe 0:cb04b53e6f9b 103 */
caroe 0:cb04b53e6f9b 104 bool write(char *file, char *header = NULL, FileFormat ff = UNIX);
caroe 0:cb04b53e6f9b 105
caroe 0:cb04b53e6f9b 106 private:
caroe 0:cb04b53e6f9b 107 typedef struct {
caroe 0:cb04b53e6f9b 108 char *key;
caroe 0:cb04b53e6f9b 109 char *value;
caroe 0:cb04b53e6f9b 110 } config_t;
caroe 0:cb04b53e6f9b 111 config_t **configlist;
caroe 0:cb04b53e6f9b 112 static const int MAXCONFIG = 64;
caroe 0:cb04b53e6f9b 113 static const int MAXLEN_KEY = 64;
caroe 0:cb04b53e6f9b 114 static const int MAXLEN_VALUE = 128;
caroe 0:cb04b53e6f9b 115 static const char SEPARATOR = '=';
caroe 0:cb04b53e6f9b 116
caroe 0:cb04b53e6f9b 117 config_t *search(char *key);
caroe 0:cb04b53e6f9b 118 bool add(config_t *cfg);
caroe 0:cb04b53e6f9b 119 };
caroe 0:cb04b53e6f9b 120
caroe 0:cb04b53e6f9b 121 #endif