EV Logger
A MSP430 based datalogger for an electric vehicle
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
accel.h
Go to the documentation of this file.
1 
43 #ifndef HAL_CMA3000_H
44 #define HAL_CMA3000_H
45 
46 #include <stdint.h>
47 #include "logger.h"
48 
49 #define DOUTX 0x06
50 #define DOUTY 0x07
51 #define DOUTZ 0x08
52 
53 // CONSTANTS
54 #define TICKSPERUS (F_CPU/ 1000000)
55 
56 // PORT DEFINITIONS
57 #define ACCEL_INT_IN P2IN
58 #define ACCEL_INT_OUT P2OUT
59 #define ACCEL_INT_DIR P2DIR
60 #define ACCEL_SCK_SEL P2SEL
61 #define ACCEL_INT_IE P2IE
62 #define ACCEL_INT_IES P2IES
63 #define ACCEL_INT_IFG P2IFG
64 #define ACCEL_INT_VECTOR PORT2_VECTOR
65 #define ACCEL_OUT P3OUT
66 #define ACCEL_DIR P3DIR
67 #define ACCEL_SEL P3SEL
68 
69 // PIN DEFINITIONS
70 #define ACCEL_INT BIT5
71 #define ACCEL_CS BIT5
72 #define ACCEL_SIMO BIT3
73 #define ACCEL_SOMI BIT4
74 #define ACCEL_SCK BIT7
75 #define ACCEL_PWR BIT6
76 
77 // ACCELEROMETER REGISTER DEFINITIONS
78 #define REVID 0x01
79 #define CTRL 0x02
80 #define MODE_400 0x04 // Measurement mode 400 Hz ODR
81 #define DOUTX 0x06
82 #define DOUTY 0x07
83 #define DOUTZ 0x08
84 #define G_RANGE_2 0x80 // 2g range
85 #define I2C_DIS 0x10 // I2C disabled
86 
95 extern int8_t Cma3000_xAccel;
96 extern int8_t Cma3000_yAccel;
97 extern int8_t Cma3000_zAccel;
98 
102 typedef enum accel_state_t
103 {
121 } accel_state_t;
122 
123 extern void Cma3000_init(volatile SampleBuffer *samplebuffer);
124 extern void Cma3000_disable(void);
125 extern void Cma3000_readAccel(void);
126 extern int8_t Cma3000_readRegister(uint8_t Address);
127 void Cma3000_readAccelFSM(void);
129 extern int8_t Cma3000_writeRegister(uint8_t Address, int8_t Data);
130 
131 #endif /* HAL_MENU_H */
132 
accel_state_t
Enumerate possible states for the accelerometer finite state machine (FSM)
Definition: accel.h:102
We have completed, there is a full set of valid data in the SampleBuffer.
Definition: accel.h:120
int8_t Cma3000_writeRegister(uint8_t Address, int8_t accelData)
Writes data to the accelerometer.
Definition: accel.c:272
int8_t Cma3000_xAccel
Data value x from the accelerometer.
Definition: accel.c:58
We have no or invalid data in the SampleBuffer.
Definition: accel.h:105
A structure to contain one 'set' of samples from the vehicle.
Definition: logger.h:92
int8_t Cma3000_zAccel
Data value z from the accelerometer.
Definition: accel.c:60
int8_t Cma3000_readRegister(uint8_t Address)
Reads data from the accelerometer.
Definition: accel.c:193
void Cma3000_disable(void)
Disables the CMA3000-D01 3-Axis Ultra Low Power Accelerometer.
Definition: accel.c:148
void Cma3000_readAccelFSM(void)
Commence reading of data into the SampleBuffer.
Definition: accel.c:243
void Cma3000_readAccel(void)
Reads data from the accelerometer.
Definition: accel.c:173
We have requested the data value for Y.
Definition: accel.h:111
We have requested the data value for Z.
Definition: accel.h:115
A data value for Y is ready.
Definition: accel.h:113
int8_t Cma3000_yAccel
Data value y from the accelerometer.
Definition: accel.c:59
A data value for X is ready.
Definition: accel.h:109
void Cma3000_init(volatile SampleBuffer *samplebuffer)
Configures the CMA3000-D01 3-Axis Ultra Low Power Accelerometer.
Definition: accel.c:76
A data value for Z is ready.
Definition: accel.h:117
accel_state_t Cma3000_getState(void)
Get the current state of the accelerometer.
Definition: accel.c:261
Logger header.
We have requested the data value for X.
Definition: accel.h:107