Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: STM32F3-Discovery-minimal
Revision 4:7502a660b77f, committed 2018-05-02
- Comitter:
- MartinJohnson
- Date:
- Wed May 02 04:14:23 2018 +0000
- Parent:
- 0:ed38888a34c2
- Commit message:
- A few small changes
Changed in this revision
| STM32F3-Discovery.lib | Show annotated file Show diff for this revision Revisions of this file |
| main.c | Show annotated file Show diff for this revision Revisions of this file |
--- a/STM32F3-Discovery.lib Sun May 22 23:34:31 2016 +0000 +++ b/STM32F3-Discovery.lib Wed May 02 04:14:23 2018 +0000 @@ -1,1 +1,1 @@ -https://developer.mbed.org/users/MartinJohnson/code/STM32F3-Discovery/#404f5a4f1385 +https://developer.mbed.org/users/MartinJohnson/code/STM32F3-Discovery/#f8e3e71af478
--- a/main.c Sun May 22 23:34:31 2016 +0000
+++ b/main.c Wed May 02 04:14:23 2018 +0000
@@ -1,6 +1,6 @@
#include <stm32f3_discovery.h>
-#include "stm32f3_discovery_lsm303dlhc.h"
+#include <stm32f3_discovery_lsm303dlhc.h>
void AccelerometerConfig(void)
{
@@ -36,15 +36,8 @@
LSM303DLHC_AccFilterConfig(&LSM303DLHCFilter_InitStructure);
}
-void ReadAccelerometer(int16_t * data)
-{
- uint8_t buffer[6];
-
- LSM303DLHC_Read(ACC_I2C_ADDRESS, LSM303DLHC_OUT_X_L_A, buffer, 6);
-
- for(int i=0; i<3; i++) {
- data[i]=((int16_t)((uint16_t)buffer[2*i+1] << 8) + buffer[2*i])/16;
- }
+void ReadAccelerometer(int16_t * data) {
+ LSM303DLHC_Read(ACC_I2C_ADDRESS, LSM303DLHC_OUT_X_L_A, (uint8_t *)data, 6);
}
volatile unsigned sysTiming;
@@ -71,10 +64,11 @@
AccelerometerConfig();
int16_t acc[3];
int b=0;
- int TH=200;
+ int TH=200*16;
while(1) {
ReadAccelerometer(acc);
+ printf("Accelerometer: %d %d %d\n",acc[0]/16,acc[1]/16,acc[2]/16);
GPIOE->BSRR=b<<(8+16);
b=0;
if(acc[1]<-TH) {