Skip to content

Commit df28703

Browse files
committed
Update readme
1 parent 74e54b4 commit df28703

1 file changed

Lines changed: 72 additions & 3 deletions

File tree

README.md

Lines changed: 72 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,74 @@ This is the main code developed for the project for the lab sessions. This is wh
2626

2727
## 2 - Documentation
2828

29-
TODO
30-
31-
### 2.1 - Code flow
29+
**The following documentation is all about** `code/SLSTK3400A_ADXL362`.
30+
31+
<br/>
32+
33+
### 2.1 - File structure
34+
35+
#### 2.1.1 - Header and source files
36+
37+
The corresponding `header` (`.h`) and `source` (`.c`) files are placed in the respective folders `inc` and `src`.
38+
39+
In the **header** files we've put:
40+
41+
- PIN and REGISTER definitions
42+
- Method prototypes
43+
- Public variables
44+
45+
In the **source** files we've put:
46+
47+
- All of the documentation
48+
- The function implementations
49+
- The variable instantiations
50+
51+
<br/>
52+
53+
#### 2.1.2 - Used files
54+
55+
These are all of the files we've created to make the project more *readable*:
56+
57+
- `main.c`
58+
- Here is the **main method** where everything starts from. We've also added **two initialisation methods** that configure the `EMF32` to **wakeup from pin interrupts** and/or it's **`RTC compare` ability**.
59+
60+
- `debuging.h`
61+
- Here we can **enable or disable debugging over UART** by (un)commenting one `#define` line. This file is called in every other file where there are UART (`dbprint`) calls. Because these calls are surrounded by `#ifdef DEBUGGING ... #endif` tags, the statements are included/excluded in the uploaded code.
62+
63+
- `util.c` (& `util.h`)
64+
- Here we have some *utility functionality* like:
65+
- A **Delay** method with it's **interrupt handler** and a function to **enable or disable** `systicks`.
66+
- A method to **initialize the LED's**.
67+
- A method to **stop code execution when an error occured**.
68+
69+
- `handlers.c` (& `handlers.h`)
70+
- Here we've gathered the *interrupt handlers* for **`RTC compare`** and **odd and even pin interrupts**.
71+
72+
- `accel.c`(& `accel.h`)
73+
- Here we've gathered all the methods that have something to do with the accelerometer:
74+
- `void initADXL_VCC (void)`: Initialize and enable the GPIO pin wich powers the accelerometer.
75+
- `void powerADXL (bool enabled)`: Enable or disable the GPIO pin wich powers the accelerometer.
76+
- `void initADXL_SPI (void)`: Initialize the SPI pins and settings to communicate with the accelerometer.
77+
- `void testADXL (void)`: Test all the ODR (Output Data Rate) settings to see the effect they have on power.
78+
- `void readValuesADXL (void)`: Read and display the X-Y-Z g-values on UART.
79+
- `void resetHandlerADXL (void)`: This method tries to read the sensor ID. If this fails it tries to soft reset it and tries to read the ID again after a second. If this fails again the power to the sensor is turned off for one second. If the ID check fails again after this, the code stops executing and the `error` method is called.
80+
- `uint8_t readADXL (uint8_t address)`: Read one byte of data from a given register address. This method is called by other methods like `readADXL_XYZDATA`.
81+
- `void writeADXL (uint8_t address, uint8_t data)`: Write one byte of data to a given register address. This method is called by other methods like `configADXL_ODR`, `configADXL_range`, ... .
82+
- `void readADXL_XYZDATA (void)`: Read the X-Y-Z data registers using *burst reads* and put the response data in the global array.
83+
- `void configADXL_ODR (uint8_t givenODR)`: Configure the Output Data Rate (ODR).
84+
- `void configADXL_range (uint8_t givenRange)`: Configure the measurement range and store the selected one in a global variable.
85+
- `void configADXL_activity (uint8_t gThreshold)`: Configure the accelerometer to work in activity threshold mode with a given *g-value*. This way the accelerometer generates an interrupt to wakeup the microcontroller if a value higher than the given threshold is detected.
86+
- `void measureADXL (bool enabled)`: Enable or disable measurement mode.
87+
- `void softResetADXL (void)`: Write `'R'` to the *soft reset register* to soft-reset the accelerometer. This method is called by `resetHandlerADXL`.
88+
- `bool checkID_ADXL (void)`: Check if the ID is correct. This method is called by `resetHandlerADXL`.
89+
- `int32_t convertGRangeToGValue (int8_t sensorValue)`: Convert sensor readout-value in +-g range to mg value. This method is called by `readADXL_XYZDATA`.
90+
91+
- `dbprint.c` (& `dbprint.h`)
92+
- Here a lot of debugging methods are implemented. For more info see [dbprint GIT repo](https://github.com/Fescron/dbprint).
93+
94+
<br/>
95+
96+
### 2.2 - Code flow
3297

3398
TODO (flowchart)
3499

@@ -61,6 +126,7 @@ The same behaviour was observed when we tried to *read a register*. The first pi
61126
### 4.1 - Wakeup-mode
62127

63128
The accelerometer can be put in a `wakeup-mode` where he only consumes about **270 nA** (@2.0V) and measures the acceleration *about six times per second* to determine whether motion is present or absent. If motion is detected, the accelerometer can respond autonomously in the following ways:
129+
64130
- Switch into full bandwidth measurement mode.
65131
- Signal an interrupt to a microcontroller.
66132
- Wake up downstream circuitry, depending on the configuration.
@@ -69,6 +135,8 @@ In wake-up mode, all accelerometer features are available with the exception of
69135

70136
**This was not (yet) implemented since it would be very hard to measure these very small current differences. Therefor it would be hard to check if the accelerometer behaves like it should, and the time to get this working would perhaps better be used somewhere else...**
71137

138+
<br/>
139+
72140
### 4.2 - FIFO and wave frequency
73141

74142
We can perhaps use the `FIFO` to store measurements at an optimal `ODR` (Output Data Rate) so the **wave frequency** can be calculated using *FFT* functionality available in `CMSIS` libraries. The accelerometer could fill this FIFO on it's own and signal to the microcontroller when it is filled by using an interrupt (there is still one pin unused). Then the microcontroller can read all these values at once and calculate the frequency, after which he again goes to sleep. *We also need to look into the amount of samples we need for this to work.*
@@ -78,6 +146,7 @@ We can perhaps use the `FIFO` to store measurements at an optimal `ODR` (Output
78146
## 5 - Current measurements
79147

80148
These are rough measurements (16-12-2018), the values were not read from the sensor, it was only put in measurement mode at the given ODR:
149+
81150
- ODR 12,5 HZ ~ 29,60 - 30,41 µA
82151
- ODR 25 Hz ~ 28,43 µA (?)
83152
- ODR 50 Hz ~ 30,88 µA

0 commit comments

Comments
 (0)