Commit 263131e0 authored by s89shah's avatar s89shah

Shilpan main

parent 6bae8fa9
......@@ -6,7 +6,7 @@
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/>
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-308326719993514325" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="102259925607727357" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
......@@ -18,7 +18,7 @@
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/>
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-308326719993514325" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="102259925607727357" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
......
......@@ -96,6 +96,22 @@ static lsm9ds1_id_t whoamI;
static lsm9ds1_status_t reg;
static uint8_t rst;
static uint8_t tx_buffer[1000];
static uint8_t mouse_buffer[3] ={0,0,0};
static unsigned int accx, accy, accz;
static int gyro_x, gyro_y, gyro_z;
static long acc_x, acc_y, acc_z, acc_total_vector;
static long gyro_x_cal, gyro_y_cal, gyro_z_cal;
extern int16_t acc_x_output , acc_y_output, acc_z_output;
static int16_t gyro_x_output=0 , gyro_y_output = 0, gyro_z_output = 0;
//static long loop_timer;
static float angle_pitch, angle_roll;
static int angle_pitch_buffer, angle_roll_buffer;
static float angle_roll_acc, angle_pitch_acc;
static float angle_pitch_output, angle_roll_output;
/* Initialize inertial + magnetic sensors (IMU) driver interface */
uint8_t i2c_add_mag = LSM9DS1_MAG_I2C_ADD_L;
......@@ -183,41 +199,74 @@ int main(void)
sprintf((char*)tx_buffer, "Finished all initialization.\r\n");
tx_com(tx_buffer, strlen((char const*)tx_buffer));
lsm9ds1_dev_status_get(&dev_ctx_mag, &dev_ctx_imu, &reg);
HAL_RTC_GetTime(&hrtc, &sensorReadTime, FORMAT_BIN);
if ( reg.status_imu.xlda && reg.status_imu.gda )
{
for (int cal_int = 0; cal_int < 500 ; cal_int ++){
readIMUAcceleration();
readIMUAngularVelocity();
gyro_x_cal += acceleration_mg[0];
gyro_y_cal += acceleration_mg[1];
gyro_z_cal += acceleration_mg[2];
HAL_Delay(10);
} //Run this code 500 times
gyro_x_cal /= 500;
gyro_y_cal /= 500;
gyro_z_cal /= 500;
}
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
/* Read device status register */
lsm9ds1_dev_status_get(&dev_ctx_mag, &dev_ctx_imu, &reg);
HAL_RTC_GetTime(&hrtc, &sensorReadTime, FORMAT_BIN);
//lsm9ds1_dev_status_get(&dev_ctx_mag, &dev_ctx_imu, &reg);
//HAL_RTC_GetTime(&hrtc, &sensorReadTime, FORMAT_BIN);
if(isTracking == 1){
if ( reg.status_imu.xlda && reg.status_imu.gda )
{
readIMUAcceleration();
readIMUAngularVelocity();
/*
sprintf((char*)tx_buffer, "IMU - [mg]:%4.2f\t%4.2f\t%4.2f\t[mdps]:%4.2f\t%4.2f\t%4.2f\r\n",
acceleration_mg[0], acceleration_mg[1], acceleration_mg[2],
angular_rate_mdps[0], angular_rate_mdps[1], angular_rate_mdps[2]);
*/
sprintf((char*)tx_buffer, "%d, %4.2f, %4.2f, %4.2f,%4.2f, %4.2f, %4.2f\r\n",
(int)sensorReadTime.Seconds, acceleration_mg[0], acceleration_mg[1], acceleration_mg[2],
angular_rate_mdps[0], angular_rate_mdps[1], angular_rate_mdps[2]);
tx_com(tx_buffer, strlen((char const*)tx_buffer));
}
if ( reg.status_mag.zyxda )
{
readMag();
/*
sprintf((char*)tx_buffer, "MAG - [mG]:%4.2f\t%4.2f\t%4.2f\r\n",
magnetic_field_mgauss[0], magnetic_field_mgauss[1], magnetic_field_mgauss[2]);
*/
sprintf((char*)tx_buffer, "%d, %4.2f, %4.2f, %4.2f\r\n",
(int)sensorReadTime.Seconds, magnetic_field_mgauss[0], magnetic_field_mgauss[1], magnetic_field_mgauss[2]);
tx_com(tx_buffer, strlen((char const*)tx_buffer));
}
if ( reg.status_imu.xlda && reg.status_imu.gda )
{
gyro_x = acceleration_mg[0] - gyro_x_cal;
gyro_y = acceleration_mg[1] - gyro_y_cal;
gyro_z = acceleration_mg[2] - gyro_z_cal;
acc_x = angular_rate_mdps[0];
acc_y = angular_rate_mdps[1];
acc_z = angular_rate_mdps[2];
// Applying the complementary filter
acc_x_output = 0.3 * acc_x + 0.7 * acc_x_output;
acc_y_output = 0.3 * acc_y + 0.7 * acc_y_output;
acc_z_output = 0.3 * acc_z + 0.7 * acc_z_output;
gyro_x_output = 0.3 * gyro_x + 0.7 * gyro_x_output;
gyro_y_output = 0.3 * gyro_y + 0.7 * gyro_y_output;
gyro_z_output = 0.3 * gyro_z + 0.7 * gyro_z_output;
HAL_Delay(10);
sprintf((char*)tx_buffer, "%d, %4.2f, %4.2f, %4.2f,%4.2f, %4.2f, %4.2f\r\n",
(int)sensorReadTime.Seconds, gyro_x_output, gyro_y_output, gyro_z_output,
acc_x_output, acc_y_output, acc_z_output);
tx_com(tx_buffer, strlen((char const*)tx_buffer));//this is for uart only
}
if ( reg.status_mag.zyxda )
{
readMag();
sprintf((char*)tx_buffer, "%d, %4.2f, %4.2f, %4.2f\r\n",
(int)sensorReadTime.Seconds, magnetic_field_mgauss[0], magnetic_field_mgauss[1], magnetic_field_mgauss[2]);
tx_com(tx_buffer, strlen((char const*)tx_buffer));
}
/* Bluetooth-related scheduler */
......@@ -297,8 +346,8 @@ void SystemClock_Config(void)
PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_PLLSAI1;
PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSE;
PeriphClkInitStruct.RFWakeUpClockSelection = RCC_RFWKPCLKSOURCE_LSE;
PeriphClkInitStruct.SmpsClockSelection = RCC_SMPSCLKSOURCE_HSE;
PeriphClkInitStruct.SmpsDivSelection = RCC_SMPSCLKDIV_RANGE0;
PeriphClkInitStruct.SmpsClockSelection = RCC_SMPSCLKSOURCE_HSI;
PeriphClkInitStruct.SmpsDivSelection = RCC_SMPSCLKDIV_RANGE1;
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
{
......
......@@ -209,7 +209,7 @@ ProjectManager.LastFirmware=true
ProjectManager.LibraryCopy=1
ProjectManager.MainLocation=Core/Src
ProjectManager.NoMain=false
ProjectManager.PreviousToolchain=
ProjectManager.PreviousToolchain=STM32CubeIDE
ProjectManager.ProjectBuild=false
ProjectManager.ProjectFileName=MoBIUS_Nucleo.ioc
ProjectManager.ProjectName=MoBIUS_Nucleo
......@@ -239,7 +239,7 @@ RCC.HSI48_VALUE=48000000
RCC.HSI_VALUE=16000000
RCC.I2C1Freq_Value=32000000
RCC.I2C3Freq_Value=32000000
RCC.IPParameters=ADCFreq_Value,AHBFreq_Value,APB1Freq_Value,APB1TimFreq_Value,APB2Freq_Value,APB2TimFreq_Value,APB3Freq_Value,Cortex2Freq_Value,CortexFreq_Value,FCLK2Freq_Value,FCLKCortexFreq_Value,FamilyName,HCLK2Freq_Value,HCLK3Freq_Value,HCLKFreq_Value,HCLKRFFreq_Value,HSE_VALUE,HSI48_VALUE,HSI_VALUE,I2C1Freq_Value,I2C3Freq_Value,LCDFreq_Value,LPTIM1Freq_Value,LPTIM2Freq_Value,LPUART1Freq_Value,LSCOPinFreq_Value,LSI_VALUE,MCO1PinFreq_Value,PLLN,PLLPoutputFreq_Value,PLLQoutputFreq_Value,PLLRCLKFreq_Value,PLLSAI1N,PLLSAI1PoutputFreq_Value,PLLSAI1QoutputFreq_Value,PLLSAI1RoutputFreq_Value,PWRFreq_Value,RFWKPClockSelection,RFWKPFreq_Value,RNGFreq_Value,RTCClockSelection,RTCFreq_Value,SAI1Freq_Value,SMPS1Freq_Value,SMPSCLockSelectionVirtualVirtual,SMPSFreq_Value,SYSCLKFreq_VALUE,SYSCLKSource,USART1Freq_Value,USBFreq_Value,VCOInputFreq_Value,VCOOutputFreq_Value,VCOSAI1OutputFreq_Value
RCC.IPParameters=ADCFreq_Value,AHBFreq_Value,APB1Freq_Value,APB1TimFreq_Value,APB2Freq_Value,APB2TimFreq_Value,APB3Freq_Value,Cortex2Freq_Value,CortexFreq_Value,FCLK2Freq_Value,FCLKCortexFreq_Value,FamilyName,HCLK2Freq_Value,HCLK3Freq_Value,HCLKFreq_Value,HCLKRFFreq_Value,HSE_VALUE,HSI48_VALUE,HSI_VALUE,I2C1Freq_Value,I2C3Freq_Value,LCDFreq_Value,LPTIM1Freq_Value,LPTIM2Freq_Value,LPUART1Freq_Value,LSCOPinFreq_Value,LSI_VALUE,MCO1PinFreq_Value,PLLN,PLLPoutputFreq_Value,PLLQoutputFreq_Value,PLLRCLKFreq_Value,PLLSAI1N,PLLSAI1PoutputFreq_Value,PLLSAI1QoutputFreq_Value,PLLSAI1RoutputFreq_Value,PWRFreq_Value,RFWKPClockSelection,RFWKPFreq_Value,RNGFreq_Value,RTCClockSelection,RTCFreq_Value,SAI1Freq_Value,SMPS1Freq_Value,SMPSCLockSelectionVirtual,SMPSCLockSelectionVirtualVirtual,SMPSFreq_Value,SYSCLKFreq_VALUE,SYSCLKSource,USART1Freq_Value,USBFreq_Value,VCOInputFreq_Value,VCOOutputFreq_Value,VCOSAI1OutputFreq_Value
RCC.LCDFreq_Value=32768
RCC.LPTIM1Freq_Value=32000000
RCC.LPTIM2Freq_Value=32000000
......@@ -262,9 +262,10 @@ RCC.RNGFreq_Value=32000
RCC.RTCClockSelection=RCC_RTCCLKSOURCE_LSE
RCC.RTCFreq_Value=32768
RCC.SAI1Freq_Value=48000000
RCC.SMPS1Freq_Value=16000000
RCC.SMPS1Freq_Value=8000000
RCC.SMPSCLockSelectionVirtual=RCC_SMPSCLKSOURCE_HSI
RCC.SMPSCLockSelectionVirtualVirtual=RCC_SMPSCLKSOURCE_HSI
RCC.SMPSFreq_Value=8000000
RCC.SMPSFreq_Value=4000000
RCC.SYSCLKFreq_VALUE=32000000
RCC.SYSCLKSource=RCC_SYSCLKSOURCE_HSE
RCC.USART1Freq_Value=32000000
......
......@@ -66,35 +66,5 @@
******************************************************************************/
#define BLE_CFG_OTA_REBOOT_CHAR 0/**< REBOOT OTA MODE CHARACTERISTIC */
/******************************************************************************
* Human Interface Device Service (HIDS)
******************************************************************************/
#define BLE_CFG_HIDS_NUMBER 1
#define BLE_CFG_HIDS_REPORT_MAP_MAX_LEN 80
#define BLE_CFG_HIDS_REPORT_REFERENCE_LEN 2
#define BLE_CFG_HIDS_REPORT_MAX_LEN 80
#define BLE_CFG_HIDS_EXTERNAL_REPORT_REFERENCE_LEN 2
#define BLE_CFG_HIDS_BOOT_KEYBOARD_INPUT_REPORT_MAX_LEN 80
#define BLE_CFG_HIDS_BOOT_KEYBOARD_OUTPUT_REPORT_MAX_LEN 80
#define BLE_CFG_HIDS_BOOT_MOUSE_INPUT_REPORT_MAX_LEN 80
#define BLE_CFG_HIDS_INFORMATION_LEN 4
#define BLE_CFG_HIDS_CONTROL_POINT_LEN 1
#define BLE_CFG_HIDS_PROTOCOL_MODE_LEN 1
#define BLE_CFG_HIDS_PROTOCOL_MODE_CHAR 0 /**< Support of Protocol Mode Characteristic */
#define BLE_CFG_HIDS_INPUT_REPORT_NB 1 /**< Number of Input Report */
#define BLE_CFG_HIDS_INPUT_WRITE 1 /**< Support of Input Write property */
#define BLE_CFG_HIDS_OUTPUT_REPORT_NB 0 /**< Number of Output Report */
#define BLE_CFG_HIDS_FEATURE_REPORT_NB 0 /**< Number of Feature Report */
#define BLE_CFG_HIDS_EXTERNAL_REPORT_REFERENCE 0 /**< Support of EXTERNAL REPORT Reference Descriptor */
#define BLE_CFG_HIDS_KEYBOARD_DEVICE 0 /**< Support of BOOT KEYBOARD Report Characteristic */
#define BLE_CFG_HIDS_KEYBOARD_INPUT_WRITE 0 /**< Support of Keyboard Input Write property */
#define BLE_CFG_HIDS_MOUSE_DEVICE 0 /**< Support of BOOT MOUSE Report Characteristic */
#define BLE_CFG_HIDS_MOUSE_INPUT_WRITE 0 /**< Support of Mouse Input Write property */
#define BLE_CFG_HIDS_REPORT_CHAR BLE_CFG_HIDS_INPUT_REPORT_NB +\
BLE_CFG_HIDS_OUTPUT_REPORT_NB +\
BLE_CFG_HIDS_FEATURE_REPORT_NB
#define BLE_CFG_HIDS_PROTOCOL_MODE 1 /**< Report Protocol Mode */
#endif /*BLE_CONF_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
......@@ -137,6 +137,10 @@ static void HIDSAPP_Change_SW3(void);
static void HIDSAPP_Change_Tracking(void);
static void HIDSAPP_Change_Scrolling(void);
extern int16_t acc_x_output , acc_y_output, acc_z_output;
/* USER CODE END PFP */
/* Functions Definition ------------------------------------------------------*/
......@@ -420,6 +424,41 @@ static void HIDSAPP_Tracking_UpdateChar(void)
int8_t xMotion = acceleration_mg[0];
int8_t yMotion = acceleration_mg[1];
/*usb mouse*/
//left//
if(acc_y_output > 250 ) //&& acc_x_output > -50 && acc_y_output < 250 && acc_y_output > -150 ) /* DO THRESHOLDING AS PER YOUR CONDITIONS */
{
xMotion = -10; // mouse x //
yMotion = 0; // mouse y //
}
//right//
else if(acc_y_output < -200) //&& acc_x_output > -50 && acc_y_output < 400 && acc_y_output > -250 )
{
xMotion = 10; // mouse x //
yMotion = 0; // mouse y //
}
//up//
else if(acc_z_output > 400) //&& acc_x_output > -400 && acc_y_output < 150 && acc_y_output > 0 )
{
HAL_Delay(20);
xMotion = 0; // mouse x //
yMotion = -10; // mouse y //
}
//down//
else if(acc_z_output < -400 ) //&& acc_x_output > -450 && acc_y_output < 50 && acc_y_output > -150 )
{
xMotion = 0; // mouse x //
yMotion = 10; // mouse y //
}
//stop//
else if(acc_x_output < 200 && acc_x_output > -200 && acc_y_output < 200 && acc_y_output > -200)
{
xMotion = 0; // mouse x //
yMotion = 0; // mouse y //
}
report[0] = leftClick;
report[0] |= rightClick << 1;
report[0] |= 0 << 2;
......
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