Commit 40b0a44b authored by Lawrence Wu's avatar Lawrence Wu

SWO IMU debugging

parent 77b0b3cb
This diff is collapsed.
......@@ -197,6 +197,9 @@ int main(void)
//HAL_RTC_GetTime(&hrtc, &sensorReadTime, FORMAT_BIN);
readIMUAcceleration();
readIMUAngularVelocity();
// printf("gx:%f, gy:%f, gz:%f, ax:%f, ay:%f, az:%f\n",
// acceleration_mg[0], acceleration_mg[1], acceleration_mg[2],
// angular_rate_mdps[0], angular_rate_mdps[1], angular_rate_mdps[2]);
if(isTracking + isScrolling != 1){
isCalibration = 1;
if ( reg.status_imu.xlda && reg.status_imu.gda ){
......@@ -239,34 +242,6 @@ int main(void)
/* USER CODE END 3 */
}
void calibration(void){
int maxCalCount = 20;
int cal_int = 0;
int cnt = 0;
while(cal_int < maxCalCount){
lsm9ds1_dev_status_get(&dev_ctx_mag, &dev_ctx_imu, &reg);
if ( reg.status_imu.xlda && reg.status_imu.gda ){
readIMUAcceleration();
readIMUAngularVelocity();
gyro_x_cal += acceleration_mg[0];
gyro_y_cal += acceleration_mg[1];
gyro_z_cal += acceleration_mg[2];
cal_int++;
acc_z = angular_rate_mdps[2];
if (cnt <= 20)
{
tap_buffer[cnt++] = acc_z;
}
}
}
gyro_x_cal /= maxCalCount;
gyro_y_cal /= maxCalCount;
gyro_z_cal /= maxCalCount;
}
/**
* @brief System Clock Configuration
* @retval None
......@@ -504,6 +479,46 @@ static void MX_GPIO_Init(void)
}
/* USER CODE BEGIN 4 */
int __io_putchar(int ch){
ITM_SendChar(ch);
return ch;
}
int __write(int file, char *ptr, int len) {
int DataIdx;
for (DataIdx = 0; DataIdx < len; DataIdx++) {
__io_putchar(*ptr++);
}
}
void calibration(void){
int maxCalCount = 20;
int cal_int = 0;
int cnt = 0;
while(cal_int < maxCalCount){
lsm9ds1_dev_status_get(&dev_ctx_mag, &dev_ctx_imu, &reg);
if ( reg.status_imu.xlda && reg.status_imu.gda ){
readIMUAcceleration();
readIMUAngularVelocity();
gyro_x_cal += acceleration_mg[0];
gyro_y_cal += acceleration_mg[1];
gyro_z_cal += acceleration_mg[2];
cal_int++;
acc_z = angular_rate_mdps[2];
if (cnt <= 20)
{
tap_buffer[cnt++] = acc_z;
}
}
}
gyro_x_cal /= maxCalCount;
gyro_y_cal /= maxCalCount;
gyro_z_cal /= maxCalCount;
}
static void lsm9ds1_Init(void)
{
/* Initialize platform specific hardware */
......
......@@ -64,8 +64,10 @@ OSC_IN.Signal=RCC_OSC_IN
OSC_OUT.Mode=HSE-External-Oscillator
OSC_OUT.Signal=RCC_OSC_OUT
PA13.Locked=true
PA13.Mode=Trace_Asynchronous_SW
PA13.Signal=SYS_JTMS-SWDIO
PA14.Locked=true
PA14.Mode=Trace_Asynchronous_SW
PA14.Signal=SYS_JTCK-SWCLK
PA7.Locked=true
PA7.Mode=I2C
......@@ -89,6 +91,7 @@ PB15.GPIO_PuPd=GPIO_PULLUP
PB15.Locked=true
PB15.Signal=GPXTI15
PB3.Locked=true
PB3.Mode=Trace_Asynchronous_SW
PB3.Signal=SYS_JTDO-SWO
PB6.Locked=true
PB6.Mode=I2C
......
......@@ -25,13 +25,13 @@
#include "ble.h"
#include "p2p_server_app.h"
#include "stm32_seq.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "app_entry.h"
#include "hw_conf.h"
#include "otp.h"
#include "stm32_lpm.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment