diff --git a/crazyflie_software/crazyflie-firmware-2021.06/src/drivers/src/motors.c b/crazyflie_software/crazyflie-firmware-2021.06/src/drivers/src/motors.c index 24bccfb7349e8a532374994104dc5438ace968cd..ea2712d948022198930dd865fd868ee27260a055 100644 --- a/crazyflie_software/crazyflie-firmware-2021.06/src/drivers/src/motors.c +++ b/crazyflie_software/crazyflie-firmware-2021.06/src/drivers/src/motors.c @@ -67,22 +67,22 @@ static bool isInit = false; static uint16_t motorsBLConvBitsTo16(uint16_t bits) { - return (0xFFFF * (bits - MOTORS_BL_PWM_CNT_FOR_HIGH) / MOTORS_BL_PWM_CNT_FOR_HIGH); + // return (0xFFFF * (bits - MOTORS_BL_PWM_CNT_FOR_HIGH) / MOTORS_BL_PWM_CNT_FOR_HIGH); } static uint16_t motorsBLConv16ToBits(uint16_t bits) { - return (MOTORS_BL_PWM_CNT_FOR_HIGH + ((bits * MOTORS_BL_PWM_CNT_FOR_HIGH) / 0xFFFF)); + // return (MOTORS_BL_PWM_CNT_FOR_HIGH + ((bits * MOTORS_BL_PWM_CNT_FOR_HIGH) / 0xFFFF)); } static uint16_t motorsConvBitsTo16(uint16_t bits) { - return ((bits) << (16 - MOTORS_PWM_BITS)); + // return ((bits) << (16 - MOTORS_PWM_BITS)); } static uint16_t motorsConv16ToBits(uint16_t bits) { - return ((bits) >> (16 - MOTORS_PWM_BITS) & ((1 << MOTORS_PWM_BITS) - 1)); + // return ((bits) >> (16 - MOTORS_PWM_BITS) & ((1 << MOTORS_PWM_BITS) - 1)); } // We have data that maps PWM to thrust at different supply voltage levels. @@ -130,12 +130,12 @@ static uint16_t motorsConv16ToBits(uint16_t bits) // Voltage needed with the Supply voltage. static uint16_t motorsCompensateBatteryVoltage(uint16_t ithrust) { - float thrust = ((float) ithrust / 65536.0f) * 60; - float volts = -0.0006239f * thrust * thrust + 0.088f * thrust; - float supply_voltage = pmGetBatteryVoltage(); - float percentage = volts / supply_voltage; - percentage = percentage > 1.0f ? 1.0f : percentage; - return percentage * UINT16_MAX; + // float thrust = ((float) ithrust / 65536.0f) * 60; + // float volts = -0.0006239f * thrust * thrust + 0.088f * thrust; + // float supply_voltage = pmGetBatteryVoltage(); + // float percentage = volts / supply_voltage; + // percentage = percentage > 1.0f ? 1.0f : percentage; + // return percentage * UINT16_MAX; } /* Public functions */ @@ -143,83 +143,83 @@ static uint16_t motorsCompensateBatteryVoltage(uint16_t ithrust) //Initialization. Will set all motors ratio to 0% void motorsInit(const MotorPerifDef** motorMapSelect) { - int i; - //Init structures - GPIO_InitTypeDef GPIO_InitStructure; - TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; - TIM_OCInitTypeDef TIM_OCInitStructure; - - if (isInit) - { - // First to init will configure it - return; - } - - motorMap = motorMapSelect; - - DEBUG_PRINT("Using %s motor driver\n", motorMap[0]->drvType == BRUSHED ? "brushed" : "brushless"); - - for (i = 0; i < NBR_OF_MOTORS; i++) - { - //Clock the gpio and the timers - MOTORS_RCC_GPIO_CMD(motorMap[i]->gpioPerif, ENABLE); - MOTORS_RCC_GPIO_CMD(motorMap[i]->gpioPowerswitchPerif, ENABLE); - MOTORS_RCC_TIM_CMD(motorMap[i]->timPerif, ENABLE); - - // If there is a power switch, as on Bolt, enable power to ESC by - // switching on mosfet. - if (motorMap[i]->gpioPowerswitchPin != 0) - { - GPIO_StructInit(&GPIO_InitStructure); - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; - GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; - GPIO_InitStructure.GPIO_Pin = motorMap[i]->gpioPowerswitchPin; - GPIO_Init(motorMap[i]->gpioPowerswitchPort, &GPIO_InitStructure); - GPIO_WriteBit(motorMap[i]->gpioPowerswitchPort, motorMap[i]->gpioPowerswitchPin, 1); - } - - // Configure the GPIO for the timer output - GPIO_StructInit(&GPIO_InitStructure); - GPIO_InitStructure.GPIO_Mode = MOTORS_GPIO_MODE; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; - GPIO_InitStructure.GPIO_OType = motorMap[i]->gpioOType; - GPIO_InitStructure.GPIO_Pin = motorMap[i]->gpioPin; - GPIO_Init(motorMap[i]->gpioPort, &GPIO_InitStructure); - - //Map timers to alternate functions - MOTORS_GPIO_AF_CFG(motorMap[i]->gpioPort, motorMap[i]->gpioPinSource, motorMap[i]->gpioAF); - - //Timer configuration - TIM_TimeBaseStructure.TIM_Period = motorMap[i]->timPeriod; - TIM_TimeBaseStructure.TIM_Prescaler = motorMap[i]->timPrescaler; - TIM_TimeBaseStructure.TIM_ClockDivision = 0; - TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; - TIM_TimeBaseStructure.TIM_RepetitionCounter = 0; - TIM_TimeBaseInit(motorMap[i]->tim, &TIM_TimeBaseStructure); - - // PWM channels configuration (All identical!) - TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1; - TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable; - TIM_OCInitStructure.TIM_Pulse = 0; - TIM_OCInitStructure.TIM_OCPolarity = motorMap[i]->timPolarity; - TIM_OCInitStructure.TIM_OCIdleState = TIM_OCIdleState_Set; - - // Configure Output Compare for PWM - motorMap[i]->ocInit(motorMap[i]->tim, &TIM_OCInitStructure); - motorMap[i]->preloadConfig(motorMap[i]->tim, TIM_OCPreload_Enable); - - MOTORS_TIM_DBG_CFG(motorMap[i]->timDbgStop, ENABLE); - //Enable the timer PWM outputs - TIM_CtrlPWMOutputs(motorMap[i]->tim, ENABLE); - } - - // Start the timers - for (i = 0; i < NBR_OF_MOTORS; i++) - { - TIM_Cmd(motorMap[i]->tim, ENABLE); - } - - isInit = true; + // int i; + // //Init structures + // GPIO_InitTypeDef GPIO_InitStructure; + // TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; + // TIM_OCInitTypeDef TIM_OCInitStructure; + + // if (isInit) + // { + // // First to init will configure it + // // return; + // } + + // // motorMap = motorMapSelect; + + // DEBUG_PRINT("Using %s motor driver\n", motorMap[0]->drvType == BRUSHED ? "brushed" : "brushless"); + + // for (i = 0; i < NBR_OF_MOTORS; i++) + // { + // // //Clock the gpio and the timers + // // MOTORS_RCC_GPIO_CMD(motorMap[i]->gpioPerif, ENABLE); + // // MOTORS_RCC_GPIO_CMD(motorMap[i]->gpioPowerswitchPerif, ENABLE); + // // MOTORS_RCC_TIM_CMD(motorMap[i]->timPerif, ENABLE); + + // // If there is a power switch, as on Bolt, enable power to ESC by + // // switching on mosfet. + // if (motorMap[i]->gpioPowerswitchPin != 0) + // { + // // GPIO_StructInit(&GPIO_InitStructure); + // // GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; + // // GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; + // // GPIO_InitStructure.GPIO_Pin = motorMap[i]->gpioPowerswitchPin; + // // GPIO_Init(motorMap[i]->gpioPowerswitchPort, &GPIO_InitStructure); + // // GPIO_WriteBit(motorMap[i]->gpioPowerswitchPort, motorMap[i]->gpioPowerswitchPin, 1); + // } + + // // Configure the GPIO for the timer output + // GPIO_StructInit(&GPIO_InitStructure); + // GPIO_InitStructure.GPIO_Mode = MOTORS_GPIO_MODE; + // GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + // GPIO_InitStructure.GPIO_OType = motorMap[i]->gpioOType; + // GPIO_InitStructure.GPIO_Pin = motorMap[i]->gpioPin; + // GPIO_Init(motorMap[i]->gpioPort, &GPIO_InitStructure); + + // //Map timers to alternate functions + // MOTORS_GPIO_AF_CFG(motorMap[i]->gpioPort, motorMap[i]->gpioPinSource, motorMap[i]->gpioAF); + + // //Timer configuration + // TIM_TimeBaseStructure.TIM_Period = motorMap[i]->timPeriod; + // TIM_TimeBaseStructure.TIM_Prescaler = motorMap[i]->timPrescaler; + // TIM_TimeBaseStructure.TIM_ClockDivision = 0; + // TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; + // TIM_TimeBaseStructure.TIM_RepetitionCounter = 0; + // TIM_TimeBaseInit(motorMap[i]->tim, &TIM_TimeBaseStructure); + + // // PWM channels configuration (All identical!) + // TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1; + // TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable; + // TIM_OCInitStructure.TIM_Pulse = 0; + // TIM_OCInitStructure.TIM_OCPolarity = motorMap[i]->timPolarity; + // TIM_OCInitStructure.TIM_OCIdleState = TIM_OCIdleState_Set; + + // // Configure Output Compare for PWM + // motorMap[i]->ocInit(motorMap[i]->tim, &TIM_OCInitStructure); + // motorMap[i]->preloadConfig(motorMap[i]->tim, TIM_OCPreload_Enable); + + // MOTORS_TIM_DBG_CFG(motorMap[i]->timDbgStop, ENABLE); + // //Enable the timer PWM outputs + // TIM_CtrlPWMOutputs(motorMap[i]->tim, ENABLE); + // } + + // // Start the timers + // for (i = 0; i < NBR_OF_MOTORS; i++) + // { + // TIM_Cmd(motorMap[i]->tim, ENABLE); + // } + + // isInit = true; // Output zero power motorsSetRatio(MOTOR_M1, 0); @@ -230,149 +230,149 @@ void motorsInit(const MotorPerifDef** motorMapSelect) void motorsDeInit(const MotorPerifDef** motorMapSelect) { - int i; - GPIO_InitTypeDef GPIO_InitStructure; - - for (i = 0; i < NBR_OF_MOTORS; i++) - { - // Configure default - GPIO_StructInit(&GPIO_InitStructure); - GPIO_InitStructure.GPIO_Pin = motorMap[i]->gpioPin; - GPIO_Init(motorMap[i]->gpioPort, &GPIO_InitStructure); - - //Map timers to alternate functions - GPIO_PinAFConfig(motorMap[i]->gpioPort, motorMap[i]->gpioPinSource, 0x00); - - //Deinit timer - TIM_DeInit(motorMap[i]->tim); - } + // int i; + // GPIO_InitTypeDef GPIO_InitStructure; + + // for (i = 0; i < NBR_OF_MOTORS; i++) + // { + // // Configure default + // GPIO_StructInit(&GPIO_InitStructure); + // GPIO_InitStructure.GPIO_Pin = motorMap[i]->gpioPin; + // GPIO_Init(motorMap[i]->gpioPort, &GPIO_InitStructure); + + // //Map timers to alternate functions + // GPIO_PinAFConfig(motorMap[i]->gpioPort, motorMap[i]->gpioPinSource, 0x00); + + // //Deinit timer + // TIM_DeInit(motorMap[i]->tim); + // } } bool motorsTest(void) { - int i; - - for (i = 0; i < sizeof(MOTORS) / sizeof(*MOTORS); i++) - { - if (motorMap[i]->drvType == BRUSHED) - { -#ifdef ACTIVATE_STARTUP_SOUND - motorsBeep(MOTORS[i], true, testsound[i], (uint16_t)(MOTORS_TIM_BEEP_CLK_FREQ / A4)/ 20); - vTaskDelay(M2T(MOTORS_TEST_ON_TIME_MS)); - motorsBeep(MOTORS[i], false, 0, 0); - vTaskDelay(M2T(MOTORS_TEST_DELAY_TIME_MS)); -#else - motorsSetRatio(MOTORS[i], MOTORS_TEST_RATIO); - vTaskDelay(M2T(MOTORS_TEST_ON_TIME_MS)); - motorsSetRatio(MOTORS[i], 0); - vTaskDelay(M2T(MOTORS_TEST_DELAY_TIME_MS)); -#endif - } - } - - return isInit; +// int i; + +// for (i = 0; i < sizeof(MOTORS) / sizeof(*MOTORS); i++) +// { +// if (motorMap[i]->drvType == BRUSHED) +// { +// #ifdef ACTIVATE_STARTUP_SOUND +// motorsBeep(MOTORS[i], true, testsound[i], (uint16_t)(MOTORS_TIM_BEEP_CLK_FREQ / A4)/ 20); +// vTaskDelay(M2T(MOTORS_TEST_ON_TIME_MS)); +// motorsBeep(MOTORS[i], false, 0, 0); +// vTaskDelay(M2T(MOTORS_TEST_DELAY_TIME_MS)); +// #else +// motorsSetRatio(MOTORS[i], MOTORS_TEST_RATIO); +// vTaskDelay(M2T(MOTORS_TEST_ON_TIME_MS)); +// motorsSetRatio(MOTORS[i], 0); +// vTaskDelay(M2T(MOTORS_TEST_DELAY_TIME_MS)); +// #endif +// } +// } + +// return isInit; } // Ithrust is thrust mapped for 65536 <==> 60 grams void motorsSetRatio(uint32_t id, uint16_t ithrust) { - if (isInit) { - uint16_t ratio; - - ASSERT(id < NBR_OF_MOTORS); - - ratio = ithrust; - -#ifdef ENABLE_THRUST_BAT_COMPENSATED - if (motorMap[id]->drvType == BRUSHED) - { - // To make sure we provide the correct PWM given current supply voltage - // from the battery, we do calculations based on measurements of PWM, - // voltage and thrust. See comment at function definition for details. - ratio = motorsCompensateBatteryVoltage(ithrust); - motor_ratios[id] = ratio; - } -#endif - if (motorMap[id]->drvType == BRUSHLESS) - { - motorMap[id]->setCompare(motorMap[id]->tim, motorsBLConv16ToBits(ratio)); - } - else - { - motorMap[id]->setCompare(motorMap[id]->tim, motorsConv16ToBits(ratio)); - } - } +// if (isInit) { +// uint16_t ratio; + +// ASSERT(id < NBR_OF_MOTORS); + +// ratio = ithrust; + +// #ifdef ENABLE_THRUST_BAT_COMPENSATED +// if (motorMap[id]->drvType == BRUSHED) +// { +// // To make sure we provide the correct PWM given current supply voltage +// // from the battery, we do calculations based on measurements of PWM, +// // voltage and thrust. See comment at function definition for details. +// ratio = motorsCompensateBatteryVoltage(ithrust); +// motor_ratios[id] = ratio; +// } +// #endif +// if (motorMap[id]->drvType == BRUSHLESS) +// { +// motorMap[id]->setCompare(motorMap[id]->tim, motorsBLConv16ToBits(ratio)); +// } +// else +// { +// motorMap[id]->setCompare(motorMap[id]->tim, motorsConv16ToBits(ratio)); +// } +// } } int motorsGetRatio(uint32_t id) { - int ratio; - - ASSERT(id < NBR_OF_MOTORS); - if (motorMap[id]->drvType == BRUSHLESS) - { - ratio = motorsBLConvBitsTo16(motorMap[id]->getCompare(motorMap[id]->tim)); - } - else - { - ratio = motorsConvBitsTo16(motorMap[id]->getCompare(motorMap[id]->tim)); - } - - return ratio; + // int ratio; + + // ASSERT(id < NBR_OF_MOTORS); + // if (motorMap[id]->drvType == BRUSHLESS) + // { + // ratio = motorsBLConvBitsTo16(motorMap[id]->getCompare(motorMap[id]->tim)); + // } + // else + // { + // ratio = motorsConvBitsTo16(motorMap[id]->getCompare(motorMap[id]->tim)); + // } + + // return ratio; } void motorsBeep(int id, bool enable, uint16_t frequency, uint16_t ratio) { - TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; - - ASSERT(id < NBR_OF_MOTORS); - - TIM_TimeBaseStructInit(&TIM_TimeBaseStructure); - - if (enable) - { - TIM_TimeBaseStructure.TIM_Prescaler = (5 - 1); - TIM_TimeBaseStructure.TIM_Period = (uint16_t)(MOTORS_TIM_BEEP_CLK_FREQ / frequency); - } - else - { - TIM_TimeBaseStructure.TIM_Period = motorMap[id]->timPeriod; - TIM_TimeBaseStructure.TIM_Prescaler = motorMap[id]->timPrescaler; - } - - // Timer configuration - TIM_TimeBaseInit(motorMap[id]->tim, &TIM_TimeBaseStructure); - motorMap[id]->setCompare(motorMap[id]->tim, ratio); + // TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; + + // ASSERT(id < NBR_OF_MOTORS); + + // TIM_TimeBaseStructInit(&TIM_TimeBaseStructure); + + // if (enable) + // { + // TIM_TimeBaseStructure.TIM_Prescaler = (5 - 1); + // TIM_TimeBaseStructure.TIM_Period = (uint16_t)(MOTORS_TIM_BEEP_CLK_FREQ / frequency); + // } + // else + // { + // TIM_TimeBaseStructure.TIM_Period = motorMap[id]->timPeriod; + // TIM_TimeBaseStructure.TIM_Prescaler = motorMap[id]->timPrescaler; + // } + + // // Timer configuration + // TIM_TimeBaseInit(motorMap[id]->tim, &TIM_TimeBaseStructure); + // motorMap[id]->setCompare(motorMap[id]->tim, ratio); } // Play a tone with a given frequency and a specific duration in milliseconds (ms) void motorsPlayTone(uint16_t frequency, uint16_t duration_msec) { - motorsBeep(MOTOR_M1, true, frequency, (uint16_t)(MOTORS_TIM_BEEP_CLK_FREQ / frequency)/ 20); - motorsBeep(MOTOR_M2, true, frequency, (uint16_t)(MOTORS_TIM_BEEP_CLK_FREQ / frequency)/ 20); - motorsBeep(MOTOR_M3, true, frequency, (uint16_t)(MOTORS_TIM_BEEP_CLK_FREQ / frequency)/ 20); - motorsBeep(MOTOR_M4, true, frequency, (uint16_t)(MOTORS_TIM_BEEP_CLK_FREQ / frequency)/ 20); - vTaskDelay(M2T(duration_msec)); - motorsBeep(MOTOR_M1, false, frequency, 0); - motorsBeep(MOTOR_M2, false, frequency, 0); - motorsBeep(MOTOR_M3, false, frequency, 0); - motorsBeep(MOTOR_M4, false, frequency, 0); + // motorsBeep(MOTOR_M1, true, frequency, (uint16_t)(MOTORS_TIM_BEEP_CLK_FREQ / frequency)/ 20); + // motorsBeep(MOTOR_M2, true, frequency, (uint16_t)(MOTORS_TIM_BEEP_CLK_FREQ / frequency)/ 20); + // motorsBeep(MOTOR_M3, true, frequency, (uint16_t)(MOTORS_TIM_BEEP_CLK_FREQ / frequency)/ 20); + // motorsBeep(MOTOR_M4, true, frequency, (uint16_t)(MOTORS_TIM_BEEP_CLK_FREQ / frequency)/ 20); + // vTaskDelay(M2T(duration_msec)); + // motorsBeep(MOTOR_M1, false, frequency, 0); + // motorsBeep(MOTOR_M2, false, frequency, 0); + // motorsBeep(MOTOR_M3, false, frequency, 0); + // motorsBeep(MOTOR_M4, false, frequency, 0); } // Plays a melody from a note array void motorsPlayMelody(uint16_t *notes) { - int i = 0; - uint16_t note; // Note in hz - uint16_t duration; // Duration in ms - - do - { - note = notes[i++]; - duration = notes[i++]; - motorsPlayTone(note, duration); - } while (duration != 0); + // int i = 0; + // uint16_t note; // Note in hz + // uint16_t duration; // Duration in ms + + // do + // { + // note = notes[i++]; + // duration = notes[i++]; + // motorsPlayTone(note, duration); + // } while (duration != 0); } /** * Logging variables of the motors PWM output diff --git a/crazyflie_software/crazyflie-firmware-2021.06/src/drivers/src/mpu6050.c b/crazyflie_software/crazyflie-firmware-2021.06/src/drivers/src/mpu6050.c index ba0aa1a148ff5104df6fd8d1e95d1c22ebaf6900..fd3ae6282c2e5429e078069fa78b5fd4a3c727d0 100644 --- a/crazyflie_software/crazyflie-firmware-2021.06/src/drivers/src/mpu6050.c +++ b/crazyflie_software/crazyflie-firmware-2021.06/src/drivers/src/mpu6050.c @@ -50,24 +50,25 @@ static bool isInit; */ void mpu6050Init(I2C_Dev *i2cPort) { - if (isInit) - return; +// if (isInit) +// return; - I2Cx = i2cPort; - devAddr = MPU6050_ADDRESS_AD0_HIGH; -//FIXME devAddr = MPU6050_ADDRESS_AD0_LOW; +// I2Cx = i2cPort; +// devAddr = MPU6050_ADDRESS_AD0_HIGH; +// //FIXME devAddr = MPU6050_ADDRESS_AD0_LOW; isInit = true; } bool mpu6050Test(void) { - bool testStatus; + // bool testStatus; + bool testStatus = true; - if (!isInit) - return false; + // if (!isInit) + // return false; - testStatus = mpu6050TestConnection(); + // testStatus = mpu6050TestConnection(); return testStatus; } @@ -78,7 +79,7 @@ bool mpu6050Test(void) */ bool mpu6050TestConnection() { - return mpu6050GetDeviceID() == 0b110100; + // return mpu6050GetDeviceID() == 0b110100; } /** Do a MPU6050 self test. @@ -86,99 +87,100 @@ bool mpu6050TestConnection() */ bool mpu6050SelfTest() { - bool testStatus = true; - int16_t axi16, ayi16, azi16; - int16_t gxi16, gyi16, gzi16; -// int8_t axfi8, ayfi8, azfi8; -// int8_t gxfi8, gyfi8, gzfi8; - float axf, ayf, azf; - float gxf, gyf, gzf; - float axfTst, ayfTst, azfTst; - float gxfTst, gyfTst, gzfTst; - float axfDiff, ayfDiff, azfDiff; - float gxfDiff, gyfDiff, gzfDiff; - float gRange, aRange; - uint32_t scrap; - - aRange = mpu6050GetFullScaleAccelGPL(); - gRange = mpu6050GetFullScaleGyroDPL(); - - // First values after startup can be read as zero. Scrap a couple to be sure. - for (scrap = 0; scrap < 20; scrap++) - { - mpu6050GetMotion6(&axi16, &ayi16, &azi16, &gxi16, &gyi16, &gzi16); - vTaskDelay(M2T(2)); - } - // First measurement - gxf = gxi16 * gRange; - gyf = gyi16 * gRange; - gzf = gzi16 * gRange; - axf = axi16 * aRange; - ayf = ayi16 * aRange; - azf = azi16 * aRange; - - // Enable self test - mpu6050SetGyroXSelfTest(true); - mpu6050SetGyroYSelfTest(true); - mpu6050SetGyroZSelfTest(true); - mpu6050SetAccelXSelfTest(true); - mpu6050SetAccelYSelfTest(true); - mpu6050SetAccelZSelfTest(true); - - // Wait for self test to take effect - vTaskDelay(M2T(MPU6050_SELF_TEST_DELAY_MS)); - // Take second measurement - mpu6050GetMotion6(&axi16, &ayi16, &azi16, &gxi16, &gyi16, &gzi16); - gxfTst = gxi16 * gRange; - gyfTst = gyi16 * gRange; - gzfTst = gzi16 * gRange; - axfTst = axi16 * aRange; - ayfTst = ayi16 * aRange; - azfTst = azi16 * aRange; - - // Disable self test - mpu6050SetGyroXSelfTest(false); - mpu6050SetGyroYSelfTest(false); - mpu6050SetGyroZSelfTest(false); - mpu6050SetAccelXSelfTest(false); - mpu6050SetAccelYSelfTest(false); - mpu6050SetAccelZSelfTest(false); - -// // Read factory values -// i2cdevReadByte(I2Cx, devAddr, 0x00, (uint8_t *)&gxfi8); -// i2cdevReadByte(I2Cx, devAddr, 0x01, (uint8_t *)&gyfi8); -// i2cdevReadByte(I2Cx, devAddr, 0x02, (uint8_t *)&gzfi8); -// i2cdevReadByte(I2Cx, devAddr, 0x0D, (uint8_t *)&axfi8); -// i2cdevReadByte(I2Cx, devAddr, 0x0E, (uint8_t *)&ayfi8); -// i2cdevReadByte(I2Cx, devAddr, 0x0F, (uint8_t *)&azfi8); -// -// DEBUG_PRINT("gxf:%i, gyf:%i, gzf:%i, axf:%i, ayf:%i, azf:%i\n", -// (int)gxfi8, (int)gyfi8, (int)gzfi8, (int)axfi8, (int)ayfi8, (int)azfi8); - - // Calculate difference - gxfDiff = gxfTst - gxf; - gyfDiff = gyfTst - gyf; - gzfDiff = gzfTst - gzf; - axfDiff = axfTst - axf; - ayfDiff = ayfTst - ayf; - azfDiff = azfTst - azf; - - // Check result - if (mpu6050EvaluateSelfTest(MPU6050_ST_GYRO_LOW, MPU6050_ST_GYRO_HIGH, gxfDiff, "gyro X") && - mpu6050EvaluateSelfTest(-MPU6050_ST_GYRO_HIGH, -MPU6050_ST_GYRO_LOW, gyfDiff, "gyro Y") && - mpu6050EvaluateSelfTest(MPU6050_ST_GYRO_LOW, MPU6050_ST_GYRO_HIGH, gzfDiff, "gyro Z") && - mpu6050EvaluateSelfTest(MPU6050_ST_ACCEL_LOW, MPU6050_ST_ACCEL_HIGH, axfDiff, "acc X") && - mpu6050EvaluateSelfTest(MPU6050_ST_ACCEL_LOW, MPU6050_ST_ACCEL_HIGH, ayfDiff, "acc Y") && - mpu6050EvaluateSelfTest(MPU6050_ST_ACCEL_LOW, MPU6050_ST_ACCEL_HIGH, azfDiff, "acc Z")) - { - DEBUG_PRINT("Self test [OK].\n"); - } - else - { - testStatus = false; - } - - return testStatus; +// bool testStatus = true; +// int16_t axi16, ayi16, azi16; +// int16_t gxi16, gyi16, gzi16; +// // int8_t axfi8, ayfi8, azfi8; +// // int8_t gxfi8, gyfi8, gzfi8; +// float axf, ayf, azf; +// float gxf, gyf, gzf; +// float axfTst, ayfTst, azfTst; +// float gxfTst, gyfTst, gzfTst; +// float axfDiff, ayfDiff, azfDiff; +// float gxfDiff, gyfDiff, gzfDiff; +// float gRange, aRange; +// uint32_t scrap; + +// aRange = mpu6050GetFullScaleAccelGPL(); +// gRange = mpu6050GetFullScaleGyroDPL(); + +// // First values after startup can be read as zero. Scrap a couple to be sure. +// for (scrap = 0; scrap < 20; scrap++) +// { +// mpu6050GetMotion6(&axi16, &ayi16, &azi16, &gxi16, &gyi16, &gzi16); +// vTaskDelay(M2T(2)); +// } +// // First measurement +// gxf = gxi16 * gRange; +// gyf = gyi16 * gRange; +// gzf = gzi16 * gRange; +// axf = axi16 * aRange; +// ayf = ayi16 * aRange; +// azf = azi16 * aRange; + +// // Enable self test +// mpu6050SetGyroXSelfTest(true); +// mpu6050SetGyroYSelfTest(true); +// mpu6050SetGyroZSelfTest(true); +// mpu6050SetAccelXSelfTest(true); +// mpu6050SetAccelYSelfTest(true); +// mpu6050SetAccelZSelfTest(true); + +// // Wait for self test to take effect +// vTaskDelay(M2T(MPU6050_SELF_TEST_DELAY_MS)); +// // Take second measurement +// mpu6050GetMotion6(&axi16, &ayi16, &azi16, &gxi16, &gyi16, &gzi16); +// gxfTst = gxi16 * gRange; +// gyfTst = gyi16 * gRange; +// gzfTst = gzi16 * gRange; +// axfTst = axi16 * aRange; +// ayfTst = ayi16 * aRange; +// azfTst = azi16 * aRange; + +// // Disable self test +// mpu6050SetGyroXSelfTest(false); +// mpu6050SetGyroYSelfTest(false); +// mpu6050SetGyroZSelfTest(false); +// mpu6050SetAccelXSelfTest(false); +// mpu6050SetAccelYSelfTest(false); +// mpu6050SetAccelZSelfTest(false); + +// // // Read factory values +// // i2cdevReadByte(I2Cx, devAddr, 0x00, (uint8_t *)&gxfi8); +// // i2cdevReadByte(I2Cx, devAddr, 0x01, (uint8_t *)&gyfi8); +// // i2cdevReadByte(I2Cx, devAddr, 0x02, (uint8_t *)&gzfi8); +// // i2cdevReadByte(I2Cx, devAddr, 0x0D, (uint8_t *)&axfi8); +// // i2cdevReadByte(I2Cx, devAddr, 0x0E, (uint8_t *)&ayfi8); +// // i2cdevReadByte(I2Cx, devAddr, 0x0F, (uint8_t *)&azfi8); +// // +// // DEBUG_PRINT("gxf:%i, gyf:%i, gzf:%i, axf:%i, ayf:%i, azf:%i\n", +// // (int)gxfi8, (int)gyfi8, (int)gzfi8, (int)axfi8, (int)ayfi8, (int)azfi8); + +// // Calculate difference +// gxfDiff = gxfTst - gxf; +// gyfDiff = gyfTst - gyf; +// gzfDiff = gzfTst - gzf; +// axfDiff = axfTst - axf; +// ayfDiff = ayfTst - ayf; +// azfDiff = azfTst - azf; + +// // Check result +// if (mpu6050EvaluateSelfTest(MPU6050_ST_GYRO_LOW, MPU6050_ST_GYRO_HIGH, gxfDiff, "gyro X") && +// mpu6050EvaluateSelfTest(-MPU6050_ST_GYRO_HIGH, -MPU6050_ST_GYRO_LOW, gyfDiff, "gyro Y") && +// mpu6050EvaluateSelfTest(MPU6050_ST_GYRO_LOW, MPU6050_ST_GYRO_HIGH, gzfDiff, "gyro Z") && +// mpu6050EvaluateSelfTest(MPU6050_ST_ACCEL_LOW, MPU6050_ST_ACCEL_HIGH, axfDiff, "acc X") && +// mpu6050EvaluateSelfTest(MPU6050_ST_ACCEL_LOW, MPU6050_ST_ACCEL_HIGH, ayfDiff, "acc Y") && +// mpu6050EvaluateSelfTest(MPU6050_ST_ACCEL_LOW, MPU6050_ST_ACCEL_HIGH, azfDiff, "acc Z")) +// { +// DEBUG_PRINT("Self test [OK].\n"); +// } +// else +// { +// testStatus = false; +// } + + // return testStatus; + return false; } /** Evaluate the values from a MPU6050 self test. @@ -190,12 +192,12 @@ bool mpu6050SelfTest() */ bool mpu6050EvaluateSelfTest(float low, float high, float value, char* string) { - if (value < low || value > high) - { - DEBUG_PRINT("Self test %s [FAIL]. low: %0.2f, high: %0.2f, measured: %0.2f\n", - string, (double)low, (double)high, (double)value); - return false; - } + // if (value < low || value > high) + // { + // DEBUG_PRINT("Self test %s [FAIL]. low: %0.2f, high: %0.2f, measured: %0.2f\n", + // string, (double)low, (double)high, (double)value); + // return false; + // } return true; } @@ -209,7 +211,7 @@ bool mpu6050EvaluateSelfTest(float low, float high, float value, char* string) */ uint8_t mpu6050GetAuxVDDIOLevel() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_YG_OFFS_TC, MPU6050_TC_PWR_MODE_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_YG_OFFS_TC, MPU6050_TC_PWR_MODE_BIT, buffer); return buffer[0]; } /** Set the auxiliary I2C supply voltage level. @@ -220,7 +222,7 @@ uint8_t mpu6050GetAuxVDDIOLevel() */ void mpu6050SetAuxVDDIOLevel(uint8_t level) { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_YG_OFFS_TC, MPU6050_TC_PWR_MODE_BIT, level); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_YG_OFFS_TC, MPU6050_TC_PWR_MODE_BIT, level); } // SMPLRT_DIV register @@ -248,7 +250,7 @@ void mpu6050SetAuxVDDIOLevel(uint8_t level) */ uint8_t mpu6050GetRate() { - i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_SMPLRT_DIV, buffer); + // i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_SMPLRT_DIV, buffer); return buffer[0]; } /** Set gyroscope sample rate divider. @@ -258,7 +260,7 @@ uint8_t mpu6050GetRate() */ void mpu6050SetRate(uint8_t rate) { - i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_SMPLRT_DIV, rate); + // i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_SMPLRT_DIV, rate); } // CONFIG register @@ -292,8 +294,8 @@ void mpu6050SetRate(uint8_t rate) */ uint8_t mpu6050GetExternalFrameSync() { - i2cdevReadBits(I2Cx, devAddr, MPU6050_RA_CONFIG, MPU6050_CFG_EXT_SYNC_SET_BIT, - MPU6050_CFG_EXT_SYNC_SET_LENGTH, buffer); + // i2cdevReadBits(I2Cx, devAddr, MPU6050_RA_CONFIG, MPU6050_CFG_EXT_SYNC_SET_BIT, + // MPU6050_CFG_EXT_SYNC_SET_LENGTH, buffer); return buffer[0]; } /** Set external FSYNC configuration. @@ -303,8 +305,8 @@ uint8_t mpu6050GetExternalFrameSync() */ void mpu6050SetExternalFrameSync(uint8_t sync) { - i2cdevWriteBits(I2Cx, devAddr, MPU6050_RA_CONFIG, MPU6050_CFG_EXT_SYNC_SET_BIT, - MPU6050_CFG_EXT_SYNC_SET_LENGTH, sync); + // i2cdevWriteBits(I2Cx, devAddr, MPU6050_RA_CONFIG, MPU6050_CFG_EXT_SYNC_SET_BIT, + // MPU6050_CFG_EXT_SYNC_SET_LENGTH, sync); } /** Get digital low-pass filter configuration. * The DLPF_CFG parameter sets the digital low pass filter configuration. It @@ -336,8 +338,8 @@ void mpu6050SetExternalFrameSync(uint8_t sync) */ uint8_t mpu6050GetDLPFMode() { - i2cdevReadBits(I2Cx, devAddr, MPU6050_RA_CONFIG, MPU6050_CFG_DLPF_CFG_BIT, - MPU6050_CFG_DLPF_CFG_LENGTH, buffer); + // i2cdevReadBits(I2Cx, devAddr, MPU6050_RA_CONFIG, MPU6050_CFG_DLPF_CFG_BIT, + // MPU6050_CFG_DLPF_CFG_LENGTH, buffer); return buffer[0]; } /** Set digital low-pass filter configuration. @@ -350,8 +352,8 @@ uint8_t mpu6050GetDLPFMode() */ void mpu6050SetDLPFMode(uint8_t mode) { - i2cdevWriteBits(I2Cx, devAddr, MPU6050_RA_CONFIG, MPU6050_CFG_DLPF_CFG_BIT, - MPU6050_CFG_DLPF_CFG_LENGTH, mode); + // i2cdevWriteBits(I2Cx, devAddr, MPU6050_RA_CONFIG, MPU6050_CFG_DLPF_CFG_BIT, + // MPU6050_CFG_DLPF_CFG_LENGTH, mode); } // GYRO_CONFIG register @@ -375,8 +377,8 @@ void mpu6050SetDLPFMode(uint8_t mode) */ uint8_t mpu6050GetFullScaleGyroRangeId() { - i2cdevReadBits(I2Cx, devAddr, MPU6050_RA_GYRO_CONFIG, MPU6050_GCONFIG_FS_SEL_BIT, - MPU6050_GCONFIG_FS_SEL_LENGTH, buffer); + // i2cdevReadBits(I2Cx, devAddr, MPU6050_RA_GYRO_CONFIG, MPU6050_GCONFIG_FS_SEL_BIT, + // MPU6050_GCONFIG_FS_SEL_LENGTH, buffer); return buffer[0]; } @@ -390,28 +392,30 @@ uint8_t mpu6050GetFullScaleGyroRangeId() */ float mpu6050GetFullScaleGyroDPL() { - int32_t rangeId; - float range; - - rangeId = mpu6050GetFullScaleGyroRangeId(); - switch (rangeId) - { - case MPU6050_GYRO_FS_250: - range = MPU6050_DEG_PER_LSB_250; - break; - case MPU6050_GYRO_FS_500: - range = MPU6050_DEG_PER_LSB_500; - break; - case MPU6050_GYRO_FS_1000: - range = MPU6050_DEG_PER_LSB_1000; - break; - case MPU6050_GYRO_FS_2000: - range = MPU6050_DEG_PER_LSB_2000; - break; - default: - range = MPU6050_DEG_PER_LSB_1000; - break; - } + float range = 1.0; + + // int32_t rangeId; + // float range; + + // rangeId = mpu6050GetFullScaleGyroRangeId(); + // switch (rangeId) + // { + // case MPU6050_GYRO_FS_250: + // range = MPU6050_DEG_PER_LSB_250; + // break; + // case MPU6050_GYRO_FS_500: + // range = MPU6050_DEG_PER_LSB_500; + // break; + // case MPU6050_GYRO_FS_1000: + // range = MPU6050_DEG_PER_LSB_1000; + // break; + // case MPU6050_GYRO_FS_2000: + // range = MPU6050_DEG_PER_LSB_2000; + // break; + // default: + // range = MPU6050_DEG_PER_LSB_1000; + // break; + // } return range; } @@ -426,23 +430,23 @@ float mpu6050GetFullScaleGyroDPL() */ void mpu6050SetFullScaleGyroRange(uint8_t range) { - i2cdevWriteBits(I2Cx, devAddr, MPU6050_RA_GYRO_CONFIG, MPU6050_GCONFIG_FS_SEL_BIT, - MPU6050_GCONFIG_FS_SEL_LENGTH, range); + // i2cdevWriteBits(I2Cx, devAddr, MPU6050_RA_GYRO_CONFIG, MPU6050_GCONFIG_FS_SEL_BIT, + // MPU6050_GCONFIG_FS_SEL_LENGTH, range); } void mpu6050SetGyroXSelfTest(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_GYRO_CONFIG, MPU6050_GCONFIG_XG_ST_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_GYRO_CONFIG, MPU6050_GCONFIG_XG_ST_BIT, enabled); } void mpu6050SetGyroYSelfTest(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_GYRO_CONFIG, MPU6050_GCONFIG_YG_ST_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_GYRO_CONFIG, MPU6050_GCONFIG_YG_ST_BIT, enabled); } void mpu6050SetGyroZSelfTest(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_GYRO_CONFIG, MPU6050_GCONFIG_ZG_ST_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_GYRO_CONFIG, MPU6050_GCONFIG_ZG_ST_BIT, enabled); } // ACCEL_CONFIG register @@ -453,7 +457,7 @@ void mpu6050SetGyroZSelfTest(bool enabled) */ bool mpu6050GetAccelXSelfTest() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_ACCEL_CONFIG, MPU6050_ACONFIG_XA_ST_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_ACCEL_CONFIG, MPU6050_ACONFIG_XA_ST_BIT, buffer); return buffer[0]; } /** Get self-test enabled setting for accelerometer X axis. @@ -462,7 +466,7 @@ bool mpu6050GetAccelXSelfTest() */ void mpu6050SetAccelXSelfTest(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_ACCEL_CONFIG, MPU6050_ACONFIG_XA_ST_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_ACCEL_CONFIG, MPU6050_ACONFIG_XA_ST_BIT, enabled); } /** Get self-test enabled value for accelerometer Y axis. * @return Self-test enabled value @@ -470,7 +474,7 @@ void mpu6050SetAccelXSelfTest(bool enabled) */ bool mpu6050GetAccelYSelfTest() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_ACCEL_CONFIG, MPU6050_ACONFIG_YA_ST_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_ACCEL_CONFIG, MPU6050_ACONFIG_YA_ST_BIT, buffer); return buffer[0]; } /** Get self-test enabled value for accelerometer Y axis. @@ -479,7 +483,7 @@ bool mpu6050GetAccelYSelfTest() */ void mpu6050SetAccelYSelfTest(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_ACCEL_CONFIG, MPU6050_ACONFIG_YA_ST_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_ACCEL_CONFIG, MPU6050_ACONFIG_YA_ST_BIT, enabled); } /** Get self-test enabled value for accelerometer Z axis. * @return Self-test enabled value @@ -487,7 +491,7 @@ void mpu6050SetAccelYSelfTest(bool enabled) */ bool mpu6050GetAccelZSelfTest() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_ACCEL_CONFIG, MPU6050_ACONFIG_ZA_ST_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_ACCEL_CONFIG, MPU6050_ACONFIG_ZA_ST_BIT, buffer); return buffer[0]; } /** Set self-test enabled value for accelerometer Z axis. @@ -496,7 +500,7 @@ bool mpu6050GetAccelZSelfTest() */ void mpu6050SetAccelZSelfTest(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_ACCEL_CONFIG, MPU6050_ACONFIG_ZA_ST_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_ACCEL_CONFIG, MPU6050_ACONFIG_ZA_ST_BIT, enabled); } /** Get full-scale accelerometer range. * The FS_SEL parameter allows setting the full-scale range of the accelerometer @@ -517,8 +521,8 @@ void mpu6050SetAccelZSelfTest(bool enabled) */ uint8_t mpu6050GetFullScaleAccelRangeId() { - i2cdevReadBits(I2Cx, devAddr, MPU6050_RA_ACCEL_CONFIG, MPU6050_ACONFIG_AFS_SEL_BIT, - MPU6050_ACONFIG_AFS_SEL_LENGTH, buffer); + // i2cdevReadBits(I2Cx, devAddr, MPU6050_RA_ACCEL_CONFIG, MPU6050_ACONFIG_AFS_SEL_BIT, + // MPU6050_ACONFIG_AFS_SEL_LENGTH, buffer); return buffer[0]; } @@ -532,28 +536,30 @@ uint8_t mpu6050GetFullScaleAccelRangeId() */ float mpu6050GetFullScaleAccelGPL() { - int32_t rangeId; - float range; - - rangeId = mpu6050GetFullScaleAccelRangeId(); - switch (rangeId) - { - case MPU6050_ACCEL_FS_2: - range = MPU6050_G_PER_LSB_2; - break; - case MPU6050_ACCEL_FS_4: - range = MPU6050_G_PER_LSB_4; - break; - case MPU6050_ACCEL_FS_8: - range = MPU6050_G_PER_LSB_8; - break; - case MPU6050_ACCEL_FS_16: - range = MPU6050_G_PER_LSB_16; - break; - default: - range = MPU6050_DEG_PER_LSB_1000; - break; - } + float range = 1.0; + + // int32_t rangeId; + // float range; + + // rangeId = mpu6050GetFullScaleAccelRangeId(); + // switch (rangeId) + // { + // case MPU6050_ACCEL_FS_2: + // range = MPU6050_G_PER_LSB_2; + // break; + // case MPU6050_ACCEL_FS_4: + // range = MPU6050_G_PER_LSB_4; + // break; + // case MPU6050_ACCEL_FS_8: + // range = MPU6050_G_PER_LSB_8; + // break; + // case MPU6050_ACCEL_FS_16: + // range = MPU6050_G_PER_LSB_16; + // break; + // default: + // range = MPU6050_DEG_PER_LSB_1000; + // break; + // } return range; } @@ -564,7 +570,7 @@ float mpu6050GetFullScaleAccelGPL() */ void mpu6050SetFullScaleAccelRange(uint8_t range) { - i2cdevWriteBits(I2Cx, devAddr, MPU6050_RA_ACCEL_CONFIG, MPU6050_ACONFIG_AFS_SEL_BIT, + // i2cdevWriteBits(I2Cx, devAddr, MPU6050_RA_ACCEL_CONFIG, MPU6050_ACONFIG_AFS_SEL_BIT, MPU6050_ACONFIG_AFS_SEL_LENGTH, range); } /** Get the high-pass filter configuration. @@ -604,8 +610,8 @@ void mpu6050SetFullScaleAccelRange(uint8_t range) */ uint8_t mpu6050GetDHPFMode() { - i2cdevReadBits(I2Cx, devAddr, MPU6050_RA_ACCEL_CONFIG, MPU6050_ACONFIG_ACCEL_HPF_BIT, - MPU6050_ACONFIG_ACCEL_HPF_LENGTH, buffer); + // i2cdevReadBits(I2Cx, devAddr, MPU6050_RA_ACCEL_CONFIG, MPU6050_ACONFIG_ACCEL_HPF_BIT, + // MPU6050_ACONFIG_ACCEL_HPF_LENGTH, buffer); return buffer[0]; } /** Set the high-pass filter configuration. @@ -616,8 +622,8 @@ uint8_t mpu6050GetDHPFMode() */ void mpu6050SetDHPFMode(uint8_t bandwidth) { - i2cdevWriteBits(I2Cx, devAddr, MPU6050_RA_ACCEL_CONFIG, MPU6050_ACONFIG_ACCEL_HPF_BIT, - MPU6050_ACONFIG_ACCEL_HPF_LENGTH, bandwidth); + // i2cdevWriteBits(I2Cx, devAddr, MPU6050_RA_ACCEL_CONFIG, MPU6050_ACONFIG_ACCEL_HPF_BIT, + // MPU6050_ACONFIG_ACCEL_HPF_LENGTH, bandwidth); } // FF_THR register @@ -639,7 +645,7 @@ void mpu6050SetDHPFMode(uint8_t bandwidth) */ uint8_t mpu6050GetFreefallDetectionThreshold() { - i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_FF_THR, buffer); + // i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_FF_THR, buffer); return buffer[0]; } /** Get free-fall event acceleration threshold. @@ -649,7 +655,7 @@ uint8_t mpu6050GetFreefallDetectionThreshold() */ void mpu6050SetFreefallDetectionThreshold(uint8_t threshold) { - i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_FF_THR, threshold); + // i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_FF_THR, threshold); } // FF_DUR register @@ -673,7 +679,7 @@ void mpu6050SetFreefallDetectionThreshold(uint8_t threshold) */ uint8_t mpu6050GetFreefallDetectionDuration() { - i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_FF_DUR, buffer); + // i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_FF_DUR, buffer); return buffer[0]; } /** Get free-fall event duration threshold. @@ -683,7 +689,7 @@ uint8_t mpu6050GetFreefallDetectionDuration() */ void mpu6050SetFreefallDetectionDuration(uint8_t duration) { - i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_FF_DUR, duration); + // i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_FF_DUR, duration); } // MOT_THR register @@ -709,7 +715,7 @@ void mpu6050SetFreefallDetectionDuration(uint8_t duration) */ uint8_t mpu6050GetMotionDetectionThreshold() { - i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_MOT_THR, buffer); + // i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_MOT_THR, buffer); return buffer[0]; } /** Set free-fall event acceleration threshold. @@ -719,7 +725,7 @@ uint8_t mpu6050GetMotionDetectionThreshold() */ void mpu6050SetMotionDetectionThreshold(uint8_t threshold) { - i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_MOT_THR, threshold); + // i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_MOT_THR, threshold); } // MOT_DUR register @@ -741,7 +747,7 @@ void mpu6050SetMotionDetectionThreshold(uint8_t threshold) */ uint8_t mpu6050GetMotionDetectionDuration() { - i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_MOT_DUR, buffer); + // i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_MOT_DUR, buffer); return buffer[0]; } /** Set motion detection event duration threshold. @@ -751,7 +757,7 @@ uint8_t mpu6050GetMotionDetectionDuration() */ void mpu6050SetMotionDetectionDuration(uint8_t duration) { - i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_MOT_DUR, duration); + // i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_MOT_DUR, duration); } // ZRMOT_THR register @@ -783,7 +789,7 @@ void mpu6050SetMotionDetectionDuration(uint8_t duration) */ uint8_t mpu6050GetZeroMotionDetectionThreshold() { - i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_ZRMOT_THR, buffer); + // i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_ZRMOT_THR, buffer); return buffer[0]; } /** Set zero motion detection event acceleration threshold. @@ -793,7 +799,7 @@ uint8_t mpu6050GetZeroMotionDetectionThreshold() */ void mpu6050SetZeroMotionDetectionThreshold(uint8_t threshold) { - i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_ZRMOT_THR, threshold); + // i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_ZRMOT_THR, threshold); } // ZRMOT_DUR register @@ -816,7 +822,7 @@ void mpu6050SetZeroMotionDetectionThreshold(uint8_t threshold) */ uint8_t mpu6050GetZeroMotionDetectionDuration() { - i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_ZRMOT_DUR, buffer); + // i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_ZRMOT_DUR, buffer); return buffer[0]; } /** Set zero motion detection event duration threshold. @@ -826,7 +832,7 @@ uint8_t mpu6050GetZeroMotionDetectionDuration() */ void mpu6050SetZeroMotionDetectionDuration(uint8_t duration) { - i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_ZRMOT_DUR, duration); + // i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_ZRMOT_DUR, duration); } // FIFO_EN register @@ -839,7 +845,7 @@ void mpu6050SetZeroMotionDetectionDuration(uint8_t duration) */ bool mpu6050GetTempFIFOEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_FIFO_EN, MPU6050_TEMP_FIFO_EN_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_FIFO_EN, MPU6050_TEMP_FIFO_EN_BIT, buffer); return buffer[0]; } /** Set temperature FIFO enabled value. @@ -849,7 +855,7 @@ bool mpu6050GetTempFIFOEnabled() */ void mpu6050SetTempFIFOEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_FIFO_EN, MPU6050_TEMP_FIFO_EN_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_FIFO_EN, MPU6050_TEMP_FIFO_EN_BIT, enabled); } /** Get gyroscope X-axis FIFO enabled value. * When set to 1, this bit enables GYRO_XOUT_H and GYRO_XOUT_L (Registers 67 and @@ -859,7 +865,7 @@ void mpu6050SetTempFIFOEnabled(bool enabled) */ bool mpu6050GetXGyroFIFOEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_FIFO_EN, MPU6050_XG_FIFO_EN_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_FIFO_EN, MPU6050_XG_FIFO_EN_BIT, buffer); return buffer[0]; } /** Set gyroscope X-axis FIFO enabled value. @@ -869,7 +875,7 @@ bool mpu6050GetXGyroFIFOEnabled() */ void mpu6050SetXGyroFIFOEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_FIFO_EN, MPU6050_XG_FIFO_EN_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_FIFO_EN, MPU6050_XG_FIFO_EN_BIT, enabled); } /** Get gyroscope Y-axis FIFO enabled value. * When set to 1, this bit enables GYRO_YOUT_H and GYRO_YOUT_L (Registers 69 and @@ -879,7 +885,7 @@ void mpu6050SetXGyroFIFOEnabled(bool enabled) */ bool mpu6050GetYGyroFIFOEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_FIFO_EN, MPU6050_YG_FIFO_EN_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_FIFO_EN, MPU6050_YG_FIFO_EN_BIT, buffer); return buffer[0]; } /** Set gyroscope Y-axis FIFO enabled value. @@ -889,7 +895,7 @@ bool mpu6050GetYGyroFIFOEnabled() */ void mpu6050SetYGyroFIFOEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_FIFO_EN, MPU6050_YG_FIFO_EN_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_FIFO_EN, MPU6050_YG_FIFO_EN_BIT, enabled); } /** Get gyroscope Z-axis FIFO enabled value. * When set to 1, this bit enables GYRO_ZOUT_H and GYRO_ZOUT_L (Registers 71 and @@ -899,7 +905,7 @@ void mpu6050SetYGyroFIFOEnabled(bool enabled) */ bool mpu6050GetZGyroFIFOEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_FIFO_EN, MPU6050_ZG_FIFO_EN_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_FIFO_EN, MPU6050_ZG_FIFO_EN_BIT, buffer); return buffer[0]; } /** Set gyroscope Z-axis FIFO enabled value. @@ -909,7 +915,7 @@ bool mpu6050GetZGyroFIFOEnabled() */ void mpu6050SetZGyroFIFOEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_FIFO_EN, MPU6050_ZG_FIFO_EN_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_FIFO_EN, MPU6050_ZG_FIFO_EN_BIT, enabled); } /** Get accelerometer FIFO enabled value. * When set to 1, this bit enables ACCEL_XOUT_H, ACCEL_XOUT_L, ACCEL_YOUT_H, @@ -920,7 +926,7 @@ void mpu6050SetZGyroFIFOEnabled(bool enabled) */ bool mpu6050GetAccelFIFOEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_FIFO_EN, MPU6050_ACCEL_FIFO_EN_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_FIFO_EN, MPU6050_ACCEL_FIFO_EN_BIT, buffer); return buffer[0]; } /** Set accelerometer FIFO enabled value. @@ -940,7 +946,7 @@ void mpu6050SetAccelFIFOEnabled(bool enabled) */ bool mpu6050GetSlave2FIFOEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_FIFO_EN, MPU6050_SLV2_FIFO_EN_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_FIFO_EN, MPU6050_SLV2_FIFO_EN_BIT, buffer); return buffer[0]; } /** Set Slave 2 FIFO enabled value. @@ -960,7 +966,7 @@ void mpu6050SetSlave2FIFOEnabled(bool enabled) */ bool mpu6050GetSlave1FIFOEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_FIFO_EN, MPU6050_SLV1_FIFO_EN_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_FIFO_EN, MPU6050_SLV1_FIFO_EN_BIT, buffer); return buffer[0]; } /** Set Slave 1 FIFO enabled value. @@ -970,7 +976,7 @@ bool mpu6050GetSlave1FIFOEnabled() */ void mpu6050SetSlave1FIFOEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_FIFO_EN, MPU6050_SLV1_FIFO_EN_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_FIFO_EN, MPU6050_SLV1_FIFO_EN_BIT, enabled); } /** Get Slave 0 FIFO enabled value. * When set to 1, this bit enables EXT_SENS_DATA registers (Registers 73 to 96) @@ -980,7 +986,7 @@ void mpu6050SetSlave1FIFOEnabled(bool enabled) */ bool mpu6050GetSlave0FIFOEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_FIFO_EN, MPU6050_SLV0_FIFO_EN_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_FIFO_EN, MPU6050_SLV0_FIFO_EN_BIT, buffer); return buffer[0]; } /** Set Slave 0 FIFO enabled value. @@ -990,7 +996,7 @@ bool mpu6050GetSlave0FIFOEnabled() */ void mpu6050SetSlave0FIFOEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_FIFO_EN, MPU6050_SLV0_FIFO_EN_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_FIFO_EN, MPU6050_SLV0_FIFO_EN_BIT, enabled); } // I2C_MST_CTRL register @@ -1012,7 +1018,7 @@ void mpu6050SetSlave0FIFOEnabled(bool enabled) */ bool mpu6050GetMultiMasterEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_CTRL, MPU6050_MULT_MST_EN_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_CTRL, MPU6050_MULT_MST_EN_BIT, buffer); return buffer[0]; } /** Set multi-master enabled value. @@ -1022,7 +1028,7 @@ bool mpu6050GetMultiMasterEnabled() */ void mpu6050SetMultiMasterEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_CTRL, MPU6050_MULT_MST_EN_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_CTRL, MPU6050_MULT_MST_EN_BIT, enabled); } /** Get wait-for-external-sensor-data enabled value. * When the WAIT_FOR_ES bit is set to 1, the Data Ready interrupt will be @@ -1037,7 +1043,7 @@ void mpu6050SetMultiMasterEnabled(bool enabled) */ bool mpu6050GetWaitForExternalSensorEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_CTRL, MPU6050_WAIT_FOR_ES_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_CTRL, MPU6050_WAIT_FOR_ES_BIT, buffer); return buffer[0]; } /** Set wait-for-external-sensor-data enabled value. @@ -1047,7 +1053,7 @@ bool mpu6050GetWaitForExternalSensorEnabled() */ void mpu6050SetWaitForExternalSensorEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_CTRL, MPU6050_WAIT_FOR_ES_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_CTRL, MPU6050_WAIT_FOR_ES_BIT, enabled); } /** Get Slave 3 FIFO enabled value. * When set to 1, this bit enables EXT_SENS_DATA registers (Registers 73 to 96) @@ -1057,7 +1063,7 @@ void mpu6050SetWaitForExternalSensorEnabled(bool enabled) */ bool mpu6050GetSlave3FIFOEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_CTRL, MPU6050_SLV_3_FIFO_EN_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_CTRL, MPU6050_SLV_3_FIFO_EN_BIT, buffer); return buffer[0]; } /** Set Slave 3 FIFO enabled value. @@ -1067,7 +1073,7 @@ bool mpu6050GetSlave3FIFOEnabled() */ void mpu6050SetSlave3FIFOEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_CTRL, MPU6050_SLV_3_FIFO_EN_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_CTRL, MPU6050_SLV_3_FIFO_EN_BIT, enabled); } /** Get slave read/write transition enabled value. * The I2C_MST_P_NSR bit configures the I2C Master's transition from one slave @@ -1081,7 +1087,7 @@ void mpu6050SetSlave3FIFOEnabled(bool enabled) */ bool mpu6050GetSlaveReadWriteTransitionEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_CTRL, MPU6050_I2C_MST_P_NSR_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_CTRL, MPU6050_I2C_MST_P_NSR_BIT, buffer); return buffer[0]; } /** Set slave read/write transition enabled value. @@ -1124,8 +1130,8 @@ void mpu6050SetSlaveReadWriteTransitionEnabled(bool enabled) */ uint8_t mpu6050GetMasterClockSpeed() { - i2cdevReadBits(I2Cx, devAddr, MPU6050_RA_I2C_MST_CTRL, MPU6050_I2C_MST_CLK_BIT, - MPU6050_I2C_MST_CLK_LENGTH, buffer); + // i2cdevReadBits(I2Cx, devAddr, MPU6050_RA_I2C_MST_CTRL, MPU6050_I2C_MST_CLK_BIT, + // MPU6050_I2C_MST_CLK_LENGTH, buffer); return buffer[0]; } /** Set I2C master clock speed. @@ -1134,8 +1140,8 @@ uint8_t mpu6050GetMasterClockSpeed() */ void mpu6050SetMasterClockSpeed(uint8_t speed) { - i2cdevWriteBits(I2Cx, devAddr, MPU6050_RA_I2C_MST_CTRL, MPU6050_I2C_MST_CLK_BIT, - MPU6050_I2C_MST_CLK_LENGTH, speed); + // i2cdevWriteBits(I2Cx, devAddr, MPU6050_RA_I2C_MST_CTRL, MPU6050_I2C_MST_CLK_BIT, + // MPU6050_I2C_MST_CLK_LENGTH, speed); } // I2C_SLV* registers (Slave 0-3) @@ -1183,9 +1189,9 @@ void mpu6050SetMasterClockSpeed(uint8_t speed) */ uint8_t mpu6050GetSlaveAddress(uint8_t num) { - if (num > 3) - return 0; - i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_I2C_SLV0_ADDR + num * 3, buffer); + // if (num > 3) + // return 0; + // i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_I2C_SLV0_ADDR + num * 3, buffer); return buffer[0]; } /** Set the I2C address of the specified slave (0-3). @@ -1196,9 +1202,9 @@ uint8_t mpu6050GetSlaveAddress(uint8_t num) */ void mpu6050SetSlaveAddress(uint8_t num, uint8_t address) { - if (num > 3) - return; - i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_I2C_SLV0_ADDR + num * 3, address); + // if (num > 3) + // return; + // i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_I2C_SLV0_ADDR + num * 3, address); } /** Get the active internal register for the specified slave (0-3). * Read/write operations for this slave will be done to whatever internal @@ -1213,9 +1219,9 @@ void mpu6050SetSlaveAddress(uint8_t num, uint8_t address) */ uint8_t mpu6050GetSlaveRegister(uint8_t num) { - if (num > 3) - return 0; - i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_I2C_SLV0_REG + num * 3, buffer); + // if (num > 3) + // return 0; + // i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_I2C_SLV0_REG + num * 3, buffer); return buffer[0]; } /** Set the active internal register for the specified slave (0-3). @@ -1226,9 +1232,9 @@ uint8_t mpu6050GetSlaveRegister(uint8_t num) */ void mpu6050SetSlaveRegister(uint8_t num, uint8_t reg) { - if (num > 3) - return; - i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_I2C_SLV0_REG + num * 3, reg); + // if (num > 3) + // return; + // i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_I2C_SLV0_REG + num * 3, reg); } /** Get the enabled value for the specified slave (0-3). * When set to 1, this bit enables Slave 0 for data transfer operations. When @@ -1239,10 +1245,11 @@ void mpu6050SetSlaveRegister(uint8_t num, uint8_t reg) */ bool mpu6050GetSlaveEnabled(uint8_t num) { - if (num > 3) - return 0; - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_SLV0_CTRL + num * 3, MPU6050_I2C_SLV_EN_BIT, buffer); - return buffer[0]; + // if (num > 3) + // return 0; + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_SLV0_CTRL + num * 3, MPU6050_I2C_SLV_EN_BIT, buffer); + // return buffer[0]; + return true; } /** Set the enabled value for the specified slave (0-3). * @param num Slave number (0-3) @@ -1252,10 +1259,10 @@ bool mpu6050GetSlaveEnabled(uint8_t num) */ void mpu6050SetSlaveEnabled(uint8_t num, bool enabled) { - if (num > 3) - return; - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_I2C_SLV0_CTRL + num * 3, MPU6050_I2C_SLV_EN_BIT, - enabled); + // if (num > 3) + // return; + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_I2C_SLV0_CTRL + num * 3, MPU6050_I2C_SLV_EN_BIT, + // enabled); } /** Get word pair byte-swapping enabled for the specified slave (0-3). * When set to 1, this bit enables byte swapping. When byte swapping is enabled, @@ -1270,11 +1277,12 @@ void mpu6050SetSlaveEnabled(uint8_t num, bool enabled) */ bool mpu6050GetSlaveWordByteSwap(uint8_t num) { - if (num > 3) - return 0; - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_SLV0_CTRL + num * 3, MPU6050_I2C_SLV_BYTE_SW_BIT, - buffer); - return buffer[0]; + // if (num > 3) + // return 0; + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_SLV0_CTRL + num * 3, MPU6050_I2C_SLV_BYTE_SW_BIT, + // buffer); + // return buffer[0]; + return true; } /** Set word pair byte-swapping enabled for the specified slave (0-3). * @param num Slave number (0-3) @@ -1284,10 +1292,10 @@ bool mpu6050GetSlaveWordByteSwap(uint8_t num) */ void mpu6050SetSlaveWordByteSwap(uint8_t num, bool enabled) { - if (num > 3) - return; - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_I2C_SLV0_CTRL + num * 3, MPU6050_I2C_SLV_BYTE_SW_BIT, - enabled); + // if (num > 3) + // return; + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_I2C_SLV0_CTRL + num * 3, MPU6050_I2C_SLV_BYTE_SW_BIT, + // enabled); } /** Get write mode for the specified slave (0-3). * When set to 1, the transaction will read or write data only. When cleared to @@ -1301,11 +1309,12 @@ void mpu6050SetSlaveWordByteSwap(uint8_t num, bool enabled) */ bool mpu6050GetSlaveWriteMode(uint8_t num) { - if (num > 3) - return 0; - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_SLV0_CTRL + num * 3, MPU6050_I2C_SLV_REG_DIS_BIT, - buffer); - return buffer[0]; + // if (num > 3) + // return 0; + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_SLV0_CTRL + num * 3, MPU6050_I2C_SLV_REG_DIS_BIT, + // buffer); + // return buffer[0]; + return true; } /** Set write mode for the specified slave (0-3). * @param num Slave number (0-3) @@ -1315,10 +1324,11 @@ bool mpu6050GetSlaveWriteMode(uint8_t num) */ void mpu6050SetSlaveWriteMode(uint8_t num, bool mode) { - if (num > 3) - return; - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_I2C_SLV0_CTRL + num * 3, MPU6050_I2C_SLV_REG_DIS_BIT, - mode); + // if (num > 3) + // return; + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_I2C_SLV0_CTRL + num * 3, MPU6050_I2C_SLV_REG_DIS_BIT, + // mode); + } /** Get word pair grouping order offset for the specified slave (0-3). * This sets specifies the grouping order of word pairs received from registers. @@ -1333,10 +1343,11 @@ void mpu6050SetSlaveWriteMode(uint8_t num, bool mode) */ bool mpu6050GetSlaveWordGroupOffset(uint8_t num) { - if (num > 3) - return 0; - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_SLV0_CTRL + num * 3, MPU6050_I2C_SLV_GRP_BIT, buffer); - return buffer[0]; + // if (num > 3) + // return 0; + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_SLV0_CTRL + num * 3, MPU6050_I2C_SLV_GRP_BIT, buffer); + // return buffer[0]; + return true; } /** Set word pair grouping order offset for the specified slave (0-3). * @param num Slave number (0-3) @@ -1346,10 +1357,10 @@ bool mpu6050GetSlaveWordGroupOffset(uint8_t num) */ void mpu6050SetSlaveWordGroupOffset(uint8_t num, bool enabled) { - if (num > 3) - return; - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_I2C_SLV0_CTRL + num * 3, MPU6050_I2C_SLV_GRP_BIT, - enabled); + // if (num > 3) + // return; + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_I2C_SLV0_CTRL + num * 3, MPU6050_I2C_SLV_GRP_BIT, + // enabled); } /** Get number of bytes to read for the specified slave (0-3). * Specifies the number of bytes transferred to and from Slave 0. Clearing this @@ -1360,11 +1371,12 @@ void mpu6050SetSlaveWordGroupOffset(uint8_t num, bool enabled) */ uint8_t mpu6050GetSlaveDataLength(uint8_t num) { - if (num > 3) - return 0; - i2cdevReadBits(I2Cx, devAddr, MPU6050_RA_I2C_SLV0_CTRL + num * 3, MPU6050_I2C_SLV_LEN_BIT, - MPU6050_I2C_SLV_LEN_LENGTH, buffer); - return buffer[0]; + // if (num > 3) + // return 0; + // i2cdevReadBits(I2Cx, devAddr, MPU6050_RA_I2C_SLV0_CTRL + num * 3, MPU6050_I2C_SLV_LEN_BIT, + // MPU6050_I2C_SLV_LEN_LENGTH, buffer); + // return buffer[0]; + return 1; } /** Set number of bytes to read for the specified slave (0-3). * @param num Slave number (0-3) @@ -1374,10 +1386,10 @@ uint8_t mpu6050GetSlaveDataLength(uint8_t num) */ void mpu6050SetSlaveDataLength(uint8_t num, uint8_t length) { - if (num > 3) - return; - i2cdevWriteBits(I2Cx, devAddr, MPU6050_RA_I2C_SLV0_CTRL + num * 3, MPU6050_I2C_SLV_LEN_BIT, - MPU6050_I2C_SLV_LEN_LENGTH, length); + // if (num > 3) + // return; + // i2cdevWriteBits(I2Cx, devAddr, MPU6050_RA_I2C_SLV0_CTRL + num * 3, MPU6050_I2C_SLV_LEN_BIT, + // MPU6050_I2C_SLV_LEN_LENGTH, length); } // I2C_SLV* registers (Slave 4) @@ -1393,8 +1405,10 @@ void mpu6050SetSlaveDataLength(uint8_t num, uint8_t length) */ uint8_t mpu6050GetSlave4Address() { - i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_I2C_SLV4_ADDR, buffer); - return buffer[0]; + // i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_I2C_SLV4_ADDR, buffer); + // return buffer[0]; + + return 1; } /** Set the I2C address of Slave 4. * @param address New address for Slave 4 @@ -1424,7 +1438,7 @@ uint8_t mpu6050GetSlave4Register() */ void mpu6050SetSlave4Register(uint8_t reg) { - i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_I2C_SLV4_REG, reg); + // i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_I2C_SLV4_REG, reg); } /** Set new byte to write to Slave 4. * This register stores the data to be written into the Slave 4. If I2C_SLV4_RW @@ -1434,7 +1448,7 @@ void mpu6050SetSlave4Register(uint8_t reg) */ void mpu6050SetSlave4OutputByte(uint8_t data) { - i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_I2C_SLV4_DO, data); + // i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_I2C_SLV4_DO, data); } /** Get the enabled value for the Slave 4. * When set to 1, this bit enables Slave 4 for data transfer operations. When @@ -1444,8 +1458,9 @@ void mpu6050SetSlave4OutputByte(uint8_t data) */ bool mpu6050GetSlave4Enabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_SLV4_CTRL, MPU6050_I2C_SLV4_EN_BIT, buffer); - return buffer[0]; + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_SLV4_CTRL, MPU6050_I2C_SLV4_EN_BIT, buffer); + // return buffer[0]; + return true; } /** Set the enabled value for Slave 4. * @param enabled New enabled value for Slave 4 @@ -1454,7 +1469,7 @@ bool mpu6050GetSlave4Enabled() */ void mpu6050SetSlave4Enabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_I2C_SLV4_CTRL, MPU6050_I2C_SLV4_EN_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_I2C_SLV4_CTRL, MPU6050_I2C_SLV4_EN_BIT, enabled); } /** Get the enabled value for Slave 4 transaction interrupts. * When set to 1, this bit enables the generation of an interrupt signal upon @@ -1467,8 +1482,9 @@ void mpu6050SetSlave4Enabled(bool enabled) */ bool mpu6050GetSlave4InterruptEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_SLV4_CTRL, MPU6050_I2C_SLV4_INT_EN_BIT, buffer); - return buffer[0]; + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_SLV4_CTRL, MPU6050_I2C_SLV4_INT_EN_BIT, buffer); + // return buffer[0]; + return true; } /** Set the enabled value for Slave 4 transaction interrupts. * @param enabled New enabled value for Slave 4 transaction interrupts. @@ -1477,7 +1493,7 @@ bool mpu6050GetSlave4InterruptEnabled() */ void mpu6050SetSlave4InterruptEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_I2C_SLV4_CTRL, MPU6050_I2C_SLV4_INT_EN_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_I2C_SLV4_CTRL, MPU6050_I2C_SLV4_INT_EN_BIT, enabled); } /** Get write mode for Slave 4. * When set to 1, the transaction will read or write data only. When cleared to @@ -1490,8 +1506,9 @@ void mpu6050SetSlave4InterruptEnabled(bool enabled) */ bool mpu6050GetSlave4WriteMode() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_SLV4_CTRL, MPU6050_I2C_SLV4_REG_DIS_BIT, buffer); - return buffer[0]; + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_SLV4_CTRL, MPU6050_I2C_SLV4_REG_DIS_BIT, buffer); + // return buffer[0]; + return true; } /** Set write mode for the Slave 4. * @param mode New write mode for Slave 4 (0 = register address + data, 1 = data only) @@ -1500,7 +1517,7 @@ bool mpu6050GetSlave4WriteMode() */ void mpu6050SetSlave4WriteMode(bool mode) { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_I2C_SLV4_CTRL, MPU6050_I2C_SLV4_REG_DIS_BIT, mode); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_I2C_SLV4_CTRL, MPU6050_I2C_SLV4_REG_DIS_BIT, mode); } /** Get Slave 4 master delay value. * This configures the reduced access rate of I2C slaves relative to the Sample @@ -1519,9 +1536,10 @@ void mpu6050SetSlave4WriteMode(bool mode) */ uint8_t mpu6050GetSlave4MasterDelay() { - i2cdevReadBits(I2Cx, devAddr, MPU6050_RA_I2C_SLV4_CTRL, MPU6050_I2C_SLV4_MST_DLY_BIT, - MPU6050_I2C_SLV4_MST_DLY_LENGTH, buffer); - return buffer[0]; + // i2cdevReadBits(I2Cx, devAddr, MPU6050_RA_I2C_SLV4_CTRL, MPU6050_I2C_SLV4_MST_DLY_BIT, + // MPU6050_I2C_SLV4_MST_DLY_LENGTH, buffer); + // return buffer[0]; + return 1; } /** Set Slave 4 master delay value. * @param delay New Slave 4 master delay value @@ -1530,8 +1548,8 @@ uint8_t mpu6050GetSlave4MasterDelay() */ void mpu6050SetSlave4MasterDelay(uint8_t delay) { - i2cdevWriteBits(I2Cx, devAddr, MPU6050_RA_I2C_SLV4_CTRL, MPU6050_I2C_SLV4_MST_DLY_BIT, - MPU6050_I2C_SLV4_MST_DLY_LENGTH, delay); + // i2cdevWriteBits(I2Cx, devAddr, MPU6050_RA_I2C_SLV4_CTRL, MPU6050_I2C_SLV4_MST_DLY_BIT, + // MPU6050_I2C_SLV4_MST_DLY_LENGTH, delay); } /** Get last available byte read from Slave 4. * This register stores the data read from Slave 4. This field is populated @@ -1541,8 +1559,9 @@ void mpu6050SetSlave4MasterDelay(uint8_t delay) */ uint8_t mpu6050GetSlate4InputByte() { - i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_I2C_SLV4_DI, buffer); - return buffer[0]; + // i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_I2C_SLV4_DI, buffer); + // return buffer[0]; + return 1; } // I2C_MST_STATUS register @@ -1558,8 +1577,9 @@ uint8_t mpu6050GetSlate4InputByte() */ bool mpu6050GetPassthroughStatus() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_STATUS, MPU6050_MST_PASS_THROUGH_BIT, buffer); - return buffer[0]; + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_STATUS, MPU6050_MST_PASS_THROUGH_BIT, buffer); + // return buffer[0]; + return true; } /** Get Slave 4 transaction done status. * Automatically sets to 1 when a Slave 4 transaction has completed. This @@ -1571,8 +1591,9 @@ bool mpu6050GetPassthroughStatus() */ bool mpu6050GetSlave4IsDone() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_STATUS, MPU6050_MST_I2C_SLV4_DONE_BIT, buffer); - return buffer[0]; + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_STATUS, MPU6050_MST_I2C_SLV4_DONE_BIT, buffer); + // return buffer[0]; + return 1; } /** Get master arbitration lost status. * This bit automatically sets to 1 when the I2C Master has lost arbitration of @@ -1583,8 +1604,9 @@ bool mpu6050GetSlave4IsDone() */ bool mpu6050GetLostArbitration() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_STATUS, MPU6050_MST_I2C_LOST_ARB_BIT, buffer); - return buffer[0]; + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_STATUS, MPU6050_MST_I2C_LOST_ARB_BIT, buffer); + // return buffer[0]; + return 1; } /** Get Slave 4 NACK status. * This bit automatically sets to 1 when the I2C Master receives a NACK in a @@ -1595,8 +1617,9 @@ bool mpu6050GetLostArbitration() */ bool mpu6050GetSlave4Nack() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_STATUS, MPU6050_MST_I2C_SLV4_NACK_BIT, buffer); - return buffer[0]; + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_STATUS, MPU6050_MST_I2C_SLV4_NACK_BIT, buffer); + // return buffer[0]; + return true; } /** Get Slave 3 NACK status. * This bit automatically sets to 1 when the I2C Master receives a NACK in a @@ -1607,8 +1630,9 @@ bool mpu6050GetSlave4Nack() */ bool mpu6050GetSlave3Nack() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_STATUS, MPU6050_MST_I2C_SLV3_NACK_BIT, buffer); - return buffer[0]; + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_STATUS, MPU6050_MST_I2C_SLV3_NACK_BIT, buffer); + // return buffer[0]; + return true; } /** Get Slave 2 NACK status. * This bit automatically sets to 1 when the I2C Master receives a NACK in a @@ -1619,8 +1643,9 @@ bool mpu6050GetSlave3Nack() */ bool mpu6050GetSlave2Nack() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_STATUS, MPU6050_MST_I2C_SLV2_NACK_BIT, buffer); - return buffer[0]; + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_STATUS, MPU6050_MST_I2C_SLV2_NACK_BIT, buffer); + // return buffer[0]; + return true; } /** Get Slave 1 NACK status. * This bit automatically sets to 1 when the I2C Master receives a NACK in a @@ -1631,8 +1656,9 @@ bool mpu6050GetSlave2Nack() */ bool mpu6050GetSlave1Nack() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_STATUS, MPU6050_MST_I2C_SLV1_NACK_BIT, buffer); - return buffer[0]; + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_STATUS, MPU6050_MST_I2C_SLV1_NACK_BIT, buffer); + // return buffer[0]; + return true; } /** Get Slave 0 NACK status. * This bit automatically sets to 1 when the I2C Master receives a NACK in a @@ -1643,8 +1669,9 @@ bool mpu6050GetSlave1Nack() */ bool mpu6050GetSlave0Nack() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_STATUS, MPU6050_MST_I2C_SLV0_NACK_BIT, buffer); - return buffer[0]; + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_STATUS, MPU6050_MST_I2C_SLV0_NACK_BIT, buffer); + // return buffer[0]; + return true; } // INT_PIN_CFG register @@ -1657,8 +1684,9 @@ bool mpu6050GetSlave0Nack() */ bool mpu6050GetInterruptMode() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_PIN_CFG, MPU6050_INTCFG_INT_LEVEL_BIT, buffer); - return buffer[0]; + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_PIN_CFG, MPU6050_INTCFG_INT_LEVEL_BIT, buffer); + // return buffer[0]; + return true; } /** Set interrupt logic level mode. * @param mode New interrupt mode (0=active-high, 1=active-low) @@ -1668,7 +1696,7 @@ bool mpu6050GetInterruptMode() */ void mpu6050SetInterruptMode(bool mode) { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_INT_PIN_CFG, MPU6050_INTCFG_INT_LEVEL_BIT, mode); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_INT_PIN_CFG, MPU6050_INTCFG_INT_LEVEL_BIT, mode); } /** Get interrupt drive mode. * Will be set 0 for push-pull, 1 for open-drain. @@ -1678,8 +1706,9 @@ void mpu6050SetInterruptMode(bool mode) */ bool mpu6050GetInterruptDrive() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_PIN_CFG, MPU6050_INTCFG_INT_OPEN_BIT, buffer); - return buffer[0]; + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_PIN_CFG, MPU6050_INTCFG_INT_OPEN_BIT, buffer); + // return buffer[0]; + return true; } /** Set interrupt drive mode. * @param drive New interrupt drive mode (0=push-pull, 1=open-drain) @@ -1689,7 +1718,7 @@ bool mpu6050GetInterruptDrive() */ void mpu6050SetInterruptDrive(bool drive) { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_INT_PIN_CFG, MPU6050_INTCFG_INT_OPEN_BIT, drive); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_INT_PIN_CFG, MPU6050_INTCFG_INT_OPEN_BIT, drive); } /** Get interrupt latch mode. * Will be set 0 for 50us-pulse, 1 for latch-until-int-cleared. @@ -1699,8 +1728,9 @@ void mpu6050SetInterruptDrive(bool drive) */ bool mpu6050GetInterruptLatch() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_PIN_CFG, MPU6050_INTCFG_LATCH_INT_EN_BIT, buffer); - return buffer[0]; + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_PIN_CFG, MPU6050_INTCFG_LATCH_INT_EN_BIT, buffer); + // return buffer[0]; + return true; } /** Set interrupt latch mode. * @param latch New latch mode (0=50us-pulse, 1=latch-until-int-cleared) @@ -1710,7 +1740,7 @@ bool mpu6050GetInterruptLatch() */ void mpu6050SetInterruptLatch(bool latch) { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_INT_PIN_CFG, MPU6050_INTCFG_LATCH_INT_EN_BIT, latch); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_INT_PIN_CFG, MPU6050_INTCFG_LATCH_INT_EN_BIT, latch); } /** Get interrupt latch clear mode. * Will be set 0 for status-read-only, 1 for any-register-read. @@ -1720,8 +1750,9 @@ void mpu6050SetInterruptLatch(bool latch) */ bool mpu6050GetInterruptLatchClear() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_PIN_CFG, MPU6050_INTCFG_INT_RD_CLEAR_BIT, buffer); - return buffer[0]; + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_PIN_CFG, MPU6050_INTCFG_INT_RD_CLEAR_BIT, buffer); + // return buffer[0]; + return true; } /** Set interrupt latch clear mode. * @param clear New latch clear mode (0=status-read-only, 1=any-register-read) @@ -1731,7 +1762,7 @@ bool mpu6050GetInterruptLatchClear() */ void mpu6050SetInterruptLatchClear(bool clear) { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_INT_PIN_CFG, MPU6050_INTCFG_INT_RD_CLEAR_BIT, clear); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_INT_PIN_CFG, MPU6050_INTCFG_INT_RD_CLEAR_BIT, clear); } /** Get FSYNC interrupt logic level mode. * @return Current FSYNC interrupt mode (0=active-high, 1=active-low) @@ -1741,8 +1772,9 @@ void mpu6050SetInterruptLatchClear(bool clear) */ bool mpu6050GetFSyncInterruptLevel() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_PIN_CFG, MPU6050_INTCFG_FSYNC_INT_LEVEL_BIT, buffer); - return buffer[0]; + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_PIN_CFG, MPU6050_INTCFG_FSYNC_INT_LEVEL_BIT, buffer); + // return buffer[0]; + return true; } /** Set FSYNC interrupt logic level mode. * @param mode New FSYNC interrupt mode (0=active-high, 1=active-low) @@ -1752,7 +1784,7 @@ bool mpu6050GetFSyncInterruptLevel() */ void mpu6050SetFSyncInterruptLevel(bool level) { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_INT_PIN_CFG, MPU6050_INTCFG_FSYNC_INT_LEVEL_BIT, level); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_INT_PIN_CFG, MPU6050_INTCFG_FSYNC_INT_LEVEL_BIT, level); } /** Get FSYNC pin interrupt enabled setting. * Will be set 0 for disabled, 1 for enabled. @@ -1762,8 +1794,9 @@ void mpu6050SetFSyncInterruptLevel(bool level) */ bool mpu6050GetFSyncInterruptEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_PIN_CFG, MPU6050_INTCFG_FSYNC_INT_EN_BIT, buffer); - return buffer[0]; + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_PIN_CFG, MPU6050_INTCFG_FSYNC_INT_EN_BIT, buffer); + // return buffer[0]; + return true; } /** Set FSYNC pin interrupt enabled setting. * @param enabled New FSYNC pin interrupt enabled setting @@ -1773,7 +1806,7 @@ bool mpu6050GetFSyncInterruptEnabled() */ void mpu6050SetFSyncInterruptEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_INT_PIN_CFG, MPU6050_INTCFG_FSYNC_INT_EN_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_INT_PIN_CFG, MPU6050_INTCFG_FSYNC_INT_EN_BIT, enabled); } /** Get I2C bypass enabled status. * When this bit is equal to 1 and I2C_MST_EN (Register 106 bit[5]) is equal to @@ -1788,8 +1821,9 @@ void mpu6050SetFSyncInterruptEnabled(bool enabled) */ bool mpu6050GetI2CBypassEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_PIN_CFG, MPU6050_INTCFG_I2C_BYPASS_EN_BIT, buffer); - return buffer[0]; + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_PIN_CFG, MPU6050_INTCFG_I2C_BYPASS_EN_BIT, buffer); + // return buffer[0]; + return true; } /** Set I2C bypass enabled status. * When this bit is equal to 1 and I2C_MST_EN (Register 106 bit[5]) is equal to @@ -1804,7 +1838,7 @@ bool mpu6050GetI2CBypassEnabled() */ void mpu6050SetI2CBypassEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_INT_PIN_CFG, MPU6050_INTCFG_I2C_BYPASS_EN_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_INT_PIN_CFG, MPU6050_INTCFG_I2C_BYPASS_EN_BIT, enabled); } /** Get reference clock output enabled status. * When this bit is equal to 1, a reference clock output is provided at the @@ -1817,8 +1851,9 @@ void mpu6050SetI2CBypassEnabled(bool enabled) */ bool mpu6050GetClockOutputEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_PIN_CFG, MPU6050_INTCFG_CLKOUT_EN_BIT, buffer); - return buffer[0]; + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_PIN_CFG, MPU6050_INTCFG_CLKOUT_EN_BIT, buffer); + // return buffer[0]; + return true; } /** Set reference clock output enabled status. * When this bit is equal to 1, a reference clock output is provided at the @@ -1831,7 +1866,7 @@ bool mpu6050GetClockOutputEnabled() */ void mpu6050SetClockOutputEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_INT_PIN_CFG, MPU6050_INTCFG_CLKOUT_EN_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_INT_PIN_CFG, MPU6050_INTCFG_CLKOUT_EN_BIT, enabled); } // INT_ENABLE register @@ -1845,8 +1880,9 @@ void mpu6050SetClockOutputEnabled(bool enabled) **/ uint8_t mpu6050GetIntEnabled() { - i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_INT_ENABLE, buffer); - return buffer[0]; + // i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_INT_ENABLE, buffer); + // return buffer[0]; + return 1; } /** Set full interrupt enabled status. * Full register byte for all interrupts, for quick reading. Each bit should be @@ -1858,7 +1894,7 @@ uint8_t mpu6050GetIntEnabled() **/ void mpu6050SetIntEnabled(uint8_t enabled) { - i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_INT_ENABLE, enabled); + // i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_INT_ENABLE, enabled); } /** Get Free Fall interrupt enabled status. * Will be set 0 for disabled, 1 for enabled. @@ -1868,8 +1904,9 @@ void mpu6050SetIntEnabled(uint8_t enabled) **/ bool mpu6050GetIntFreefallEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_ENABLE, MPU6050_INTERRUPT_FF_BIT, buffer); - return buffer[0]; + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_ENABLE, MPU6050_INTERRUPT_FF_BIT, buffer); + // return buffer[0]; + return true; } /** Set Free Fall interrupt enabled status. * @param enabled New interrupt enabled status @@ -1889,7 +1926,7 @@ void mpu6050SetIntFreefallEnabled(bool enabled) **/ bool mpu6050GetIntMotionEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_ENABLE, MPU6050_INTERRUPT_MOT_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_ENABLE, MPU6050_INTERRUPT_MOT_BIT, buffer); return buffer[0]; } /** Set Motion Detection interrupt enabled status. @@ -1900,7 +1937,7 @@ bool mpu6050GetIntMotionEnabled() **/ void mpu6050SetIntMotionEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_INT_ENABLE, MPU6050_INTERRUPT_MOT_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_INT_ENABLE, MPU6050_INTERRUPT_MOT_BIT, enabled); } /** Get Zero Motion Detection interrupt enabled status. * Will be set 0 for disabled, 1 for enabled. @@ -1910,7 +1947,7 @@ void mpu6050SetIntMotionEnabled(bool enabled) **/ bool mpu6050GetIntZeroMotionEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_ENABLE, MPU6050_INTERRUPT_ZMOT_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_ENABLE, MPU6050_INTERRUPT_ZMOT_BIT, buffer); return buffer[0]; } /** Set Zero Motion Detection interrupt enabled status. @@ -1921,7 +1958,7 @@ bool mpu6050GetIntZeroMotionEnabled() **/ void mpu6050SetIntZeroMotionEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_INT_ENABLE, MPU6050_INTERRUPT_ZMOT_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_INT_ENABLE, MPU6050_INTERRUPT_ZMOT_BIT, enabled); } /** Get FIFO Buffer Overflow interrupt enabled status. * Will be set 0 for disabled, 1 for enabled. @@ -1931,7 +1968,7 @@ void mpu6050SetIntZeroMotionEnabled(bool enabled) **/ bool mpu6050GetIntFIFOBufferOverflowEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_ENABLE, MPU6050_INTERRUPT_FIFO_OFLOW_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_ENABLE, MPU6050_INTERRUPT_FIFO_OFLOW_BIT, buffer); return buffer[0]; } /** Set FIFO Buffer Overflow interrupt enabled status. @@ -1942,7 +1979,7 @@ bool mpu6050GetIntFIFOBufferOverflowEnabled() **/ void mpu6050SetIntFIFOBufferOverflowEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_INT_ENABLE, MPU6050_INTERRUPT_FIFO_OFLOW_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_INT_ENABLE, MPU6050_INTERRUPT_FIFO_OFLOW_BIT, enabled); } /** Get I2C Master interrupt enabled status. * This enables any of the I2C Master interrupt sources to generate an @@ -1953,7 +1990,7 @@ void mpu6050SetIntFIFOBufferOverflowEnabled(bool enabled) **/ bool mpu6050GetIntI2CMasterEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_ENABLE, MPU6050_INTERRUPT_I2C_MST_INT_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_ENABLE, MPU6050_INTERRUPT_I2C_MST_INT_BIT, buffer); return buffer[0]; } /** Set I2C Master interrupt enabled status. @@ -1964,7 +2001,7 @@ bool mpu6050GetIntI2CMasterEnabled() **/ void mpu6050SetIntI2CMasterEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_INT_ENABLE, MPU6050_INTERRUPT_I2C_MST_INT_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_INT_ENABLE, MPU6050_INTERRUPT_I2C_MST_INT_BIT, enabled); } /** Get Data Ready interrupt enabled setting. * This event occurs each time a write operation to all of the sensor registers @@ -1975,7 +2012,7 @@ void mpu6050SetIntI2CMasterEnabled(bool enabled) */ bool mpu6050GetIntDataReadyEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_ENABLE, MPU6050_INTERRUPT_DATA_RDY_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_ENABLE, MPU6050_INTERRUPT_DATA_RDY_BIT, buffer); return buffer[0]; } /** Set Data Ready interrupt enabled status. @@ -1986,7 +2023,7 @@ bool mpu6050GetIntDataReadyEnabled() */ void mpu6050SetIntDataReadyEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_INT_ENABLE, MPU6050_INTERRUPT_DATA_RDY_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_INT_ENABLE, MPU6050_INTERRUPT_DATA_RDY_BIT, enabled); } // INT_STATUS register @@ -2000,7 +2037,7 @@ void mpu6050SetIntDataReadyEnabled(bool enabled) */ uint8_t mpu6050GetIntStatus() { - i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_INT_STATUS, buffer); + // i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_INT_STATUS, buffer); return buffer[0]; } /** Get Free Fall interrupt status. @@ -2012,7 +2049,7 @@ uint8_t mpu6050GetIntStatus() */ bool mpu6050GetIntFreefallStatus() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_STATUS, MPU6050_INTERRUPT_FF_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_STATUS, MPU6050_INTERRUPT_FF_BIT, buffer); return buffer[0]; } /** Get Motion Detection interrupt status. @@ -2024,7 +2061,7 @@ bool mpu6050GetIntFreefallStatus() */ bool mpu6050GetIntMotionStatus() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_STATUS, MPU6050_INTERRUPT_MOT_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_STATUS, MPU6050_INTERRUPT_MOT_BIT, buffer); return buffer[0]; } /** Get Zero Motion Detection interrupt status. @@ -2036,7 +2073,7 @@ bool mpu6050GetIntMotionStatus() */ bool mpu6050GetIntZeroMotionStatus() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_STATUS, MPU6050_INTERRUPT_ZMOT_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_STATUS, MPU6050_INTERRUPT_ZMOT_BIT, buffer); return buffer[0]; } /** Get FIFO Buffer Overflow interrupt status. @@ -2048,7 +2085,7 @@ bool mpu6050GetIntZeroMotionStatus() */ bool mpu6050GetIntFIFOBufferOverflowStatus() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_STATUS, MPU6050_INTERRUPT_FIFO_OFLOW_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_STATUS, MPU6050_INTERRUPT_FIFO_OFLOW_BIT, buffer); return buffer[0]; } /** Get I2C Master interrupt status. @@ -2061,7 +2098,7 @@ bool mpu6050GetIntFIFOBufferOverflowStatus() */ bool mpu6050GetIntI2CMasterStatus() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_STATUS, MPU6050_INTERRUPT_I2C_MST_INT_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_STATUS, MPU6050_INTERRUPT_I2C_MST_INT_BIT, buffer); return buffer[0]; } /** Get Data Ready interrupt status. @@ -2073,7 +2110,7 @@ bool mpu6050GetIntI2CMasterStatus() */ bool mpu6050GetIntDataReadyStatus() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_STATUS, MPU6050_INTERRUPT_DATA_RDY_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_STATUS, MPU6050_INTERRUPT_DATA_RDY_BIT, buffer); return buffer[0]; } @@ -2098,7 +2135,7 @@ bool mpu6050GetIntDataReadyStatus() void mpu6050GetMotion9(int16_t* ax, int16_t* ay, int16_t* az, int16_t* gx, int16_t* gy, int16_t* gz, int16_t* mx, int16_t* my, int16_t* mz) { - mpu6050GetMotion6(ax, ay, az, gx, gy, gz); + // mpu6050GetMotion6(ax, ay, az, gx, gy, gz); // TODO: magnetometer integration } /** Get raw 6-axis motion sensor readings (accel/gyro). @@ -2115,13 +2152,13 @@ void mpu6050GetMotion9(int16_t* ax, int16_t* ay, int16_t* az, int16_t* gx, int16 */ void mpu6050GetMotion6(int16_t* ax, int16_t* ay, int16_t* az, int16_t* gx, int16_t* gy, int16_t* gz) { - i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_ACCEL_XOUT_H, 14, buffer); - *ax = (((int16_t) buffer[0]) << 8) | buffer[1]; - *ay = (((int16_t) buffer[2]) << 8) | buffer[3]; - *az = (((int16_t) buffer[4]) << 8) | buffer[5]; - *gx = (((int16_t) buffer[8]) << 8) | buffer[9]; - *gy = (((int16_t) buffer[10]) << 8) | buffer[11]; - *gz = (((int16_t) buffer[12]) << 8) | buffer[13]; + // i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_ACCEL_XOUT_H, 14, buffer); + // *ax = (((int16_t) buffer[0]) << 8) | buffer[1]; + // *ay = (((int16_t) buffer[2]) << 8) | buffer[3]; + // *az = (((int16_t) buffer[4]) << 8) | buffer[5]; + // *gx = (((int16_t) buffer[8]) << 8) | buffer[9]; + // *gy = (((int16_t) buffer[10]) << 8) | buffer[11]; + // *gz = (((int16_t) buffer[12]) << 8) | buffer[13]; } /** Get 3-axis accelerometer readings. * These registers store the most recent accelerometer measurements. @@ -2161,10 +2198,10 @@ void mpu6050GetMotion6(int16_t* ax, int16_t* ay, int16_t* az, int16_t* gx, int16 */ void mpu6050GetAcceleration(int16_t* x, int16_t* y, int16_t* z) { - i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_ACCEL_XOUT_H, 6, buffer); - *x = (((int16_t) buffer[0]) << 8) | buffer[1]; - *y = (((int16_t) buffer[2]) << 8) | buffer[3]; - *z = (((int16_t) buffer[4]) << 8) | buffer[5]; + // i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_ACCEL_XOUT_H, 6, buffer); + // *x = (((int16_t) buffer[0]) << 8) | buffer[1]; + // *y = (((int16_t) buffer[2]) << 8) | buffer[3]; + // *z = (((int16_t) buffer[4]) << 8) | buffer[5]; } /** Get X-axis accelerometer reading. * @return X-axis acceleration measurement in 16-bit 2's complement format @@ -2173,7 +2210,7 @@ void mpu6050GetAcceleration(int16_t* x, int16_t* y, int16_t* z) */ int16_t mpu6050GetAccelerationX() { - i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_ACCEL_XOUT_H, 2, buffer); + // i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_ACCEL_XOUT_H, 2, buffer); return (((int16_t) buffer[0]) << 8) | buffer[1]; } /** Get Y-axis accelerometer reading. @@ -2183,7 +2220,7 @@ int16_t mpu6050GetAccelerationX() */ int16_t mpu6050GetAccelerationY() { - i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_ACCEL_YOUT_H, 2, buffer); + // i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_ACCEL_YOUT_H, 2, buffer); return (((int16_t) buffer[0]) << 8) | buffer[1]; } /** Get Z-axis accelerometer reading. @@ -2193,7 +2230,7 @@ int16_t mpu6050GetAccelerationY() */ int16_t mpu6050GetAccelerationZ() { - i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_ACCEL_ZOUT_H, 2, buffer); + // i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_ACCEL_ZOUT_H, 2, buffer); return (((int16_t) buffer[0]) << 8) | buffer[1]; } @@ -2205,7 +2242,7 @@ int16_t mpu6050GetAccelerationZ() */ int16_t mpu6050GetTemperature() { - i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_TEMP_OUT_H, 2, buffer); + // i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_TEMP_OUT_H, 2, buffer); return (((int16_t) buffer[0]) << 8) | buffer[1]; } @@ -2245,10 +2282,10 @@ int16_t mpu6050GetTemperature() */ void mpu6050GetRotation(int16_t* x, int16_t* y, int16_t* z) { - i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_GYRO_XOUT_H, 6, buffer); - *x = (((int16_t) buffer[0]) << 8) | buffer[1]; - *y = (((int16_t) buffer[2]) << 8) | buffer[3]; - *z = (((int16_t) buffer[4]) << 8) | buffer[5]; + // i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_GYRO_XOUT_H, 6, buffer); + // *x = (((int16_t) buffer[0]) << 8) | buffer[1]; + // *y = (((int16_t) buffer[2]) << 8) | buffer[3]; + // *z = (((int16_t) buffer[4]) << 8) | buffer[5]; } /** Get X-axis gyroscope reading. * @return X-axis rotation measurement in 16-bit 2's complement format @@ -2257,7 +2294,7 @@ void mpu6050GetRotation(int16_t* x, int16_t* y, int16_t* z) */ int16_t mpu6050GetRotationX() { - i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_GYRO_XOUT_H, 2, buffer); + // i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_GYRO_XOUT_H, 2, buffer); return (((int16_t) buffer[0]) << 8) | buffer[1]; } /** Get Y-axis gyroscope reading. @@ -2267,7 +2304,7 @@ int16_t mpu6050GetRotationX() */ int16_t mpu6050GetRotationY() { - i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_GYRO_YOUT_H, 2, buffer); + // i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_GYRO_YOUT_H, 2, buffer); return (((int16_t) buffer[0]) << 8) | buffer[1]; } /** Get Z-axis gyroscope reading. @@ -2277,7 +2314,7 @@ int16_t mpu6050GetRotationY() */ int16_t mpu6050GetRotationZ() { - i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_GYRO_ZOUT_H, 2, buffer); + // i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_GYRO_ZOUT_H, 2, buffer); return (((int16_t) buffer[0]) << 8) | buffer[1]; } @@ -2359,7 +2396,7 @@ int16_t mpu6050GetRotationZ() */ uint8_t mpu6050GetExternalSensorByte(int position) { - i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_EXT_SENS_DATA_00 + position, buffer); + // i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_EXT_SENS_DATA_00 + position, buffer); return buffer[0]; } /** Read word (2 bytes) from external sensor data registers. @@ -2369,7 +2406,7 @@ uint8_t mpu6050GetExternalSensorByte(int position) */ uint16_t mpu6050GetExternalSensorWord(int position) { - i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_EXT_SENS_DATA_00 + position, 2, buffer); + // i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_EXT_SENS_DATA_00 + position, 2, buffer); return (((uint16_t) buffer[0]) << 8) | buffer[1]; } /** Read double word (4 bytes) from external sensor data registers. @@ -2379,7 +2416,7 @@ uint16_t mpu6050GetExternalSensorWord(int position) */ uint32_t mpu6050GetExternalSensorDWord(int position) { - i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_EXT_SENS_DATA_00 + position, 4, buffer); + // i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_EXT_SENS_DATA_00 + position, 4, buffer); return (((uint32_t) buffer[0]) << 24) | (((uint32_t) buffer[1]) << 16) | (((uint16_t) buffer[2]) << 8) | buffer[3]; } @@ -2393,7 +2430,7 @@ uint32_t mpu6050GetExternalSensorDWord(int position) */ bool mpu6050GetXNegMotionDetected() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_MOT_DETECT_STATUS, MPU6050_MOTION_MOT_XNEG_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_MOT_DETECT_STATUS, MPU6050_MOTION_MOT_XNEG_BIT, buffer); return buffer[0]; } /** Get X-axis positive motion detection interrupt status. @@ -2403,7 +2440,7 @@ bool mpu6050GetXNegMotionDetected() */ bool mpu6050GetXPosMotionDetected() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_MOT_DETECT_STATUS, MPU6050_MOTION_MOT_XPOS_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_MOT_DETECT_STATUS, MPU6050_MOTION_MOT_XPOS_BIT, buffer); return buffer[0]; } /** Get Y-axis negative motion detection interrupt status. @@ -2413,7 +2450,7 @@ bool mpu6050GetXPosMotionDetected() */ bool mpu6050GetYNegMotionDetected() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_MOT_DETECT_STATUS, MPU6050_MOTION_MOT_YNEG_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_MOT_DETECT_STATUS, MPU6050_MOTION_MOT_YNEG_BIT, buffer); return buffer[0]; } /** Get Y-axis positive motion detection interrupt status. @@ -2423,7 +2460,7 @@ bool mpu6050GetYNegMotionDetected() */ bool mpu6050GetYPosMotionDetected() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_MOT_DETECT_STATUS, MPU6050_MOTION_MOT_YPOS_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_MOT_DETECT_STATUS, MPU6050_MOTION_MOT_YPOS_BIT, buffer); return buffer[0]; } /** Get Z-axis negative motion detection interrupt status. @@ -2433,7 +2470,7 @@ bool mpu6050GetYPosMotionDetected() */ bool mpu6050GetZNegMotionDetected() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_MOT_DETECT_STATUS, MPU6050_MOTION_MOT_ZNEG_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_MOT_DETECT_STATUS, MPU6050_MOTION_MOT_ZNEG_BIT, buffer); return buffer[0]; } /** Get Z-axis positive motion detection interrupt status. @@ -2443,7 +2480,7 @@ bool mpu6050GetZNegMotionDetected() */ bool mpu6050GetZPosMotionDetected() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_MOT_DETECT_STATUS, MPU6050_MOTION_MOT_ZPOS_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_MOT_DETECT_STATUS, MPU6050_MOTION_MOT_ZPOS_BIT, buffer); return buffer[0]; } /** Get zero motion detection interrupt status. @@ -2453,7 +2490,7 @@ bool mpu6050GetZPosMotionDetected() */ bool mpu6050GetZeroMotionDetected() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_MOT_DETECT_STATUS, MPU6050_MOTION_MOT_ZRMOT_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_MOT_DETECT_STATUS, MPU6050_MOTION_MOT_ZRMOT_BIT, buffer); return buffer[0]; } @@ -2469,9 +2506,9 @@ bool mpu6050GetZeroMotionDetected() */ void mpu6050SetSlaveOutputByte(uint8_t num, uint8_t data) { - if (num > 3) - return; - i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_I2C_SLV0_DO + num, data); + // if (num > 3) + // return; + // i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_I2C_SLV0_DO + num, data); } // I2C_MST_DELAY_CTRL register @@ -2486,8 +2523,8 @@ void mpu6050SetSlaveOutputByte(uint8_t num, uint8_t data) */ bool mpu6050GetExternalShadowDelayEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_DELAY_CTRL, MPU6050_DELAYCTRL_DELAY_ES_SHADOW_BIT, - buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_DELAY_CTRL, MPU6050_DELAYCTRL_DELAY_ES_SHADOW_BIT, + // buffer); return buffer[0]; } /** Set external data shadow delay enabled status. @@ -2498,8 +2535,8 @@ bool mpu6050GetExternalShadowDelayEnabled() */ void mpu6050SetExternalShadowDelayEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_DELAY_CTRL, - MPU6050_DELAYCTRL_DELAY_ES_SHADOW_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_DELAY_CTRL, + // MPU6050_DELAYCTRL_DELAY_ES_SHADOW_BIT, enabled); } /** Get slave delay enabled status. * When a particular slave delay is enabled, the rate of access for the that @@ -2524,7 +2561,7 @@ bool mpu6050GetSlaveDelayEnabled(uint8_t num) // MPU6050_DELAYCTRL_I2C_SLV4_DLY_EN_BIT is 4, SLV3 is 3, etc. if (num > 4) return 0; - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_DELAY_CTRL, num, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_DELAY_CTRL, num, buffer); return buffer[0]; } /** Set slave delay enabled status. @@ -2535,7 +2572,7 @@ bool mpu6050GetSlaveDelayEnabled(uint8_t num) */ void mpu6050SetSlaveDelayEnabled(uint8_t num, bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_DELAY_CTRL, num, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_I2C_MST_DELAY_CTRL, num, enabled); } // SIGNAL_PATH_RESET register @@ -2548,7 +2585,7 @@ void mpu6050SetSlaveDelayEnabled(uint8_t num, bool enabled) */ void mpu6050ResetGyroscopePath() { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_SIGNAL_PATH_RESET, MPU6050_PATHRESET_GYRO_RESET_BIT, 1); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_SIGNAL_PATH_RESET, MPU6050_PATHRESET_GYRO_RESET_BIT, 1); } /** Reset accelerometer signal path. * The reset will revert the signal path analog to digital converters and @@ -2558,7 +2595,7 @@ void mpu6050ResetGyroscopePath() */ void mpu6050ResetAccelerometerPath() { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_SIGNAL_PATH_RESET, MPU6050_PATHRESET_ACCEL_RESET_BIT, 1); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_SIGNAL_PATH_RESET, MPU6050_PATHRESET_ACCEL_RESET_BIT, 1); } /** Reset temperature sensor signal path. * The reset will revert the signal path analog to digital converters and @@ -2568,7 +2605,7 @@ void mpu6050ResetAccelerometerPath() */ void mpu6050ResetTemperaturePath() { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_SIGNAL_PATH_RESET, MPU6050_PATHRESET_TEMP_RESET_BIT, 1); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_SIGNAL_PATH_RESET, MPU6050_PATHRESET_TEMP_RESET_BIT, 1); } // MOT_DETECT_CTRL register @@ -2589,8 +2626,8 @@ void mpu6050ResetTemperaturePath() */ uint8_t mpu6050GetAccelerometerPowerOnDelay() { - i2cdevReadBits(I2Cx, devAddr, MPU6050_RA_MOT_DETECT_CTRL, MPU6050_DETECT_ACCEL_ON_DELAY_BIT, - MPU6050_DETECT_ACCEL_ON_DELAY_LENGTH, buffer); + // i2cdevReadBits(I2Cx, devAddr, MPU6050_RA_MOT_DETECT_CTRL, MPU6050_DETECT_ACCEL_ON_DELAY_BIT, + // MPU6050_DETECT_ACCEL_ON_DELAY_LENGTH, buffer); return buffer[0]; } /** Set accelerometer power-on delay. @@ -2601,8 +2638,8 @@ uint8_t mpu6050GetAccelerometerPowerOnDelay() */ void mpu6050SetAccelerometerPowerOnDelay(uint8_t delay) { - i2cdevWriteBits(I2Cx, devAddr, MPU6050_RA_MOT_DETECT_CTRL, MPU6050_DETECT_ACCEL_ON_DELAY_BIT, - MPU6050_DETECT_ACCEL_ON_DELAY_LENGTH, delay); + // i2cdevWriteBits(I2Cx, devAddr, MPU6050_RA_MOT_DETECT_CTRL, MPU6050_DETECT_ACCEL_ON_DELAY_BIT, + // MPU6050_DETECT_ACCEL_ON_DELAY_LENGTH, delay); } /** Get Free Fall detection counter decrement configuration. * Detection is registered by the Free Fall detection module after accelerometer @@ -2632,8 +2669,8 @@ void mpu6050SetAccelerometerPowerOnDelay(uint8_t delay) */ uint8_t mpu6050GetFreefallDetectionCounterDecrement() { - i2cdevReadBits(I2Cx, devAddr, MPU6050_RA_MOT_DETECT_CTRL, MPU6050_DETECT_FF_COUNT_BIT, - MPU6050_DETECT_FF_COUNT_LENGTH, buffer); + // i2cdevReadBits(I2Cx, devAddr, MPU6050_RA_MOT_DETECT_CTRL, MPU6050_DETECT_FF_COUNT_BIT, + // MPU6050_DETECT_FF_COUNT_LENGTH, buffer); return buffer[0]; } /** Set Free Fall detection counter decrement configuration. @@ -2644,8 +2681,8 @@ uint8_t mpu6050GetFreefallDetectionCounterDecrement() */ void mpu6050SetFreefallDetectionCounterDecrement(uint8_t decrement) { - i2cdevWriteBits(I2Cx, devAddr, MPU6050_RA_MOT_DETECT_CTRL, MPU6050_DETECT_FF_COUNT_BIT, - MPU6050_DETECT_FF_COUNT_LENGTH, decrement); + // i2cdevWriteBits(I2Cx, devAddr, MPU6050_RA_MOT_DETECT_CTRL, MPU6050_DETECT_FF_COUNT_BIT, + // MPU6050_DETECT_FF_COUNT_LENGTH, decrement); } /** Get Motion detection counter decrement configuration. * Detection is registered by the Motion detection module after accelerometer @@ -2672,8 +2709,8 @@ void mpu6050SetFreefallDetectionCounterDecrement(uint8_t decrement) */ uint8_t mpu6050GetMotionDetectionCounterDecrement() { - i2cdevReadBits(I2Cx, devAddr, MPU6050_RA_MOT_DETECT_CTRL, MPU6050_DETECT_MOT_COUNT_BIT, - MPU6050_DETECT_MOT_COUNT_LENGTH, buffer); + // i2cdevReadBits(I2Cx, devAddr, MPU6050_RA_MOT_DETECT_CTRL, MPU6050_DETECT_MOT_COUNT_BIT, + // MPU6050_DETECT_MOT_COUNT_LENGTH, buffer); return buffer[0]; } /** Set Motion detection counter decrement configuration. @@ -2684,8 +2721,8 @@ uint8_t mpu6050GetMotionDetectionCounterDecrement() */ void mpu6050SetMotionDetectionCounterDecrement(uint8_t decrement) { - i2cdevWriteBits(I2Cx, devAddr, MPU6050_RA_MOT_DETECT_CTRL, MPU6050_DETECT_MOT_COUNT_BIT, - MPU6050_DETECT_MOT_COUNT_LENGTH, decrement); + // i2cdevWriteBits(I2Cx, devAddr, MPU6050_RA_MOT_DETECT_CTRL, MPU6050_DETECT_MOT_COUNT_BIT, + // MPU6050_DETECT_MOT_COUNT_LENGTH, decrement); } // USER_CTRL register @@ -2700,7 +2737,7 @@ void mpu6050SetMotionDetectionCounterDecrement(uint8_t decrement) */ bool mpu6050GetFIFOEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_USER_CTRL, MPU6050_USERCTRL_FIFO_EN_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_USER_CTRL, MPU6050_USERCTRL_FIFO_EN_BIT, buffer); return buffer[0]; } /** Set FIFO enabled status. @@ -2711,7 +2748,7 @@ bool mpu6050GetFIFOEnabled() */ void mpu6050SetFIFOEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_USER_CTRL, MPU6050_USERCTRL_FIFO_EN_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_USER_CTRL, MPU6050_USERCTRL_FIFO_EN_BIT, enabled); } /** Get I2C Master Mode enabled status. * When this mode is enabled, the MPU-60X0 acts as the I2C Master to the @@ -2726,7 +2763,7 @@ void mpu6050SetFIFOEnabled(bool enabled) */ bool mpu6050GetI2CMasterModeEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_USER_CTRL, MPU6050_USERCTRL_I2C_MST_EN_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_USER_CTRL, MPU6050_USERCTRL_I2C_MST_EN_BIT, buffer); return buffer[0]; } /** Set I2C Master Mode enabled status. @@ -2737,7 +2774,7 @@ bool mpu6050GetI2CMasterModeEnabled() */ void mpu6050SetI2CMasterModeEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_USER_CTRL, MPU6050_USERCTRL_I2C_MST_EN_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_USER_CTRL, MPU6050_USERCTRL_I2C_MST_EN_BIT, enabled); } /** Switch from I2C to SPI mode (MPU-6000 only) * If this is set, the primary SPI interface will be enabled in place of the @@ -2745,7 +2782,7 @@ void mpu6050SetI2CMasterModeEnabled(bool enabled) */ void mpu6050SwitchSPIEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_USER_CTRL, MPU6050_USERCTRL_I2C_IF_DIS_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_USER_CTRL, MPU6050_USERCTRL_I2C_IF_DIS_BIT, enabled); } /** Reset the FIFO. * This bit resets the FIFO buffer when set to 1 while FIFO_EN equals 0. This @@ -2755,7 +2792,7 @@ void mpu6050SwitchSPIEnabled(bool enabled) */ void mpu6050ResetFIFO() { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_USER_CTRL, MPU6050_USERCTRL_FIFO_RESET_BIT, 1); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_USER_CTRL, MPU6050_USERCTRL_FIFO_RESET_BIT, 1); } /** Reset the I2C Master. * This bit resets the I2C Master when set to 1 while I2C_MST_EN equals 0. @@ -2765,7 +2802,7 @@ void mpu6050ResetFIFO() */ void mpu6050ResetI2CMaster() { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_USER_CTRL, MPU6050_USERCTRL_I2C_MST_RESET_BIT, 1); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_USER_CTRL, MPU6050_USERCTRL_I2C_MST_RESET_BIT, 1); } /** Reset all sensor registers and signal paths. * When set to 1, this bit resets the signal paths for all sensors (gyroscopes, @@ -2781,7 +2818,7 @@ void mpu6050ResetI2CMaster() */ void mpu6050ResetSensors() { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_USER_CTRL, MPU6050_USERCTRL_SIG_COND_RESET_BIT, 1); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_USER_CTRL, MPU6050_USERCTRL_SIG_COND_RESET_BIT, 1); } // PWR_MGMT_1 register @@ -2793,7 +2830,7 @@ void mpu6050ResetSensors() */ void mpu6050Reset() { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_1, MPU6050_PWR1_DEVICE_RESET_BIT, 1); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_1, MPU6050_PWR1_DEVICE_RESET_BIT, 1); } /** Get sleep mode status. * Setting the SLEEP bit in the register puts the device into very low power @@ -2808,7 +2845,7 @@ void mpu6050Reset() */ bool mpu6050GetSleepEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_1, MPU6050_PWR1_SLEEP_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_1, MPU6050_PWR1_SLEEP_BIT, buffer); return buffer[0]; } /** Set sleep mode status. @@ -2819,7 +2856,7 @@ bool mpu6050GetSleepEnabled() */ void mpu6050SetSleepEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_1, MPU6050_PWR1_SLEEP_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_1, MPU6050_PWR1_SLEEP_BIT, enabled); } /** Get wake cycle enabled status. * When this bit is set to 1 and SLEEP is disabled, the MPU-60X0 will cycle @@ -2831,7 +2868,7 @@ void mpu6050SetSleepEnabled(bool enabled) */ bool mpu6050GetWakeCycleEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_1, MPU6050_PWR1_CYCLE_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_1, MPU6050_PWR1_CYCLE_BIT, buffer); return buffer[0]; } /** Set wake cycle enabled status. @@ -2842,7 +2879,7 @@ bool mpu6050GetWakeCycleEnabled() */ void mpu6050SetWakeCycleEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_1, MPU6050_PWR1_CYCLE_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_1, MPU6050_PWR1_CYCLE_BIT, enabled); } /** Get temperature sensor enabled status. * Control the usage of the internal temperature sensor. @@ -2857,7 +2894,7 @@ void mpu6050SetWakeCycleEnabled(bool enabled) */ bool mpu6050GetTempSensorEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_1, MPU6050_PWR1_TEMP_DIS_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_1, MPU6050_PWR1_TEMP_DIS_BIT, buffer); return buffer[0] == 0; // 1 is actually disabled here } /** Set temperature sensor enabled status. @@ -2873,7 +2910,7 @@ bool mpu6050GetTempSensorEnabled() void mpu6050SetTempSensorEnabled(bool enabled) { // 1 is actually disabled here - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_1, MPU6050_PWR1_TEMP_DIS_BIT, !enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_1, MPU6050_PWR1_TEMP_DIS_BIT, !enabled); } /** Get clock source setting. * @return Current clock source setting @@ -2883,8 +2920,8 @@ void mpu6050SetTempSensorEnabled(bool enabled) */ uint8_t mpu6050GetClockSource() { - i2cdevReadBits(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_1, MPU6050_PWR1_CLKSEL_BIT, - MPU6050_PWR1_CLKSEL_LENGTH, buffer); + // i2cdevReadBits(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_1, MPU6050_PWR1_CLKSEL_BIT, + // MPU6050_PWR1_CLKSEL_LENGTH, buffer); return buffer[0]; } /** Set clock source setting. @@ -2919,8 +2956,8 @@ uint8_t mpu6050GetClockSource() */ void mpu6050SetClockSource(uint8_t source) { - i2cdevWriteBits(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_1, MPU6050_PWR1_CLKSEL_BIT, - MPU6050_PWR1_CLKSEL_LENGTH, source); + // i2cdevWriteBits(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_1, MPU6050_PWR1_CLKSEL_BIT, + // MPU6050_PWR1_CLKSEL_LENGTH, source); } // PWR_MGMT_2 register @@ -2950,8 +2987,8 @@ void mpu6050SetClockSource(uint8_t source) */ uint8_t mpu6050GetWakeFrequency() { - i2cdevReadBits(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_2, MPU6050_PWR2_LP_WAKE_CTRL_BIT, - MPU6050_PWR2_LP_WAKE_CTRL_LENGTH, buffer); + // i2cdevReadBits(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_2, MPU6050_PWR2_LP_WAKE_CTRL_BIT, + // MPU6050_PWR2_LP_WAKE_CTRL_LENGTH, buffer); return buffer[0]; } /** Set wake frequency in Accel-Only Low Power Mode. @@ -2960,8 +2997,8 @@ uint8_t mpu6050GetWakeFrequency() */ void mpu6050SetWakeFrequency(uint8_t frequency) { - i2cdevWriteBits(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_2, MPU6050_PWR2_LP_WAKE_CTRL_BIT, - MPU6050_PWR2_LP_WAKE_CTRL_LENGTH, frequency); + // i2cdevWriteBits(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_2, MPU6050_PWR2_LP_WAKE_CTRL_BIT, + // MPU6050_PWR2_LP_WAKE_CTRL_LENGTH, frequency); } /** Get X-axis accelerometer standby enabled status. @@ -2972,7 +3009,7 @@ void mpu6050SetWakeFrequency(uint8_t frequency) */ bool mpu6050GetStandbyXAccelEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_2, MPU6050_PWR2_STBY_XA_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_2, MPU6050_PWR2_STBY_XA_BIT, buffer); return buffer[0]; } /** Set X-axis accelerometer standby enabled status. @@ -2983,7 +3020,7 @@ bool mpu6050GetStandbyXAccelEnabled() */ void mpu6050SetStandbyXAccelEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_2, MPU6050_PWR2_STBY_XA_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_2, MPU6050_PWR2_STBY_XA_BIT, enabled); } /** Get Y-axis accelerometer standby enabled status. * If enabled, the Y-axis will not gather or report data (or use power). @@ -2993,7 +3030,7 @@ void mpu6050SetStandbyXAccelEnabled(bool enabled) */ bool mpu6050GetStandbyYAccelEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_2, MPU6050_PWR2_STBY_YA_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_2, MPU6050_PWR2_STBY_YA_BIT, buffer); return buffer[0]; } /** Set Y-axis accelerometer standby enabled status. @@ -3004,7 +3041,7 @@ bool mpu6050GetStandbyYAccelEnabled() */ void mpu6050SetStandbyYAccelEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_2, MPU6050_PWR2_STBY_YA_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_2, MPU6050_PWR2_STBY_YA_BIT, enabled); } /** Get Z-axis accelerometer standby enabled status. * If enabled, the Z-axis will not gather or report data (or use power). @@ -3014,7 +3051,7 @@ void mpu6050SetStandbyYAccelEnabled(bool enabled) */ bool mpu6050GetStandbyZAccelEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_2, MPU6050_PWR2_STBY_ZA_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_2, MPU6050_PWR2_STBY_ZA_BIT, buffer); return buffer[0]; } /** Set Z-axis accelerometer standby enabled status. @@ -3025,7 +3062,7 @@ bool mpu6050GetStandbyZAccelEnabled() */ void mpu6050SetStandbyZAccelEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_2, MPU6050_PWR2_STBY_ZA_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_2, MPU6050_PWR2_STBY_ZA_BIT, enabled); } /** Get X-axis gyroscope standby enabled status. * If enabled, the X-axis will not gather or report data (or use power). @@ -3035,7 +3072,7 @@ void mpu6050SetStandbyZAccelEnabled(bool enabled) */ bool mpu6050GetStandbyXGyroEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_2, MPU6050_PWR2_STBY_XG_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_2, MPU6050_PWR2_STBY_XG_BIT, buffer); return buffer[0]; } /** Set X-axis gyroscope standby enabled status. @@ -3046,7 +3083,7 @@ bool mpu6050GetStandbyXGyroEnabled() */ void mpu6050SetStandbyXGyroEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_2, MPU6050_PWR2_STBY_XG_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_2, MPU6050_PWR2_STBY_XG_BIT, enabled); } /** Get Y-axis gyroscope standby enabled status. * If enabled, the Y-axis will not gather or report data (or use power). @@ -3056,7 +3093,7 @@ void mpu6050SetStandbyXGyroEnabled(bool enabled) */ bool mpu6050GetStandbyYGyroEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_2, MPU6050_PWR2_STBY_YG_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_2, MPU6050_PWR2_STBY_YG_BIT, buffer); return buffer[0]; } /** Set Y-axis gyroscope standby enabled status. @@ -3067,7 +3104,7 @@ bool mpu6050GetStandbyYGyroEnabled() */ void mpu6050SetStandbyYGyroEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_2, MPU6050_PWR2_STBY_YG_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_2, MPU6050_PWR2_STBY_YG_BIT, enabled); } /** Get Z-axis gyroscope standby enabled status. * If enabled, the Z-axis will not gather or report data (or use power). @@ -3077,7 +3114,7 @@ void mpu6050SetStandbyYGyroEnabled(bool enabled) */ bool mpu6050GetStandbyZGyroEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_2, MPU6050_PWR2_STBY_ZG_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_2, MPU6050_PWR2_STBY_ZG_BIT, buffer); return buffer[0]; } /** Set Z-axis gyroscope standby enabled status. @@ -3088,7 +3125,7 @@ bool mpu6050GetStandbyZGyroEnabled() */ void mpu6050SetStandbyZGyroEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_2, MPU6050_PWR2_STBY_ZG_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_PWR_MGMT_2, MPU6050_PWR2_STBY_ZG_BIT, enabled); } // FIFO_COUNT* registers @@ -3102,7 +3139,7 @@ void mpu6050SetStandbyZGyroEnabled(bool enabled) */ uint16_t mpu6050GetFIFOCount() { - i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_FIFO_COUNTH, 2, buffer); + // i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_FIFO_COUNTH, 2, buffer); return (((uint16_t) buffer[0]) << 8) | buffer[1]; } @@ -3135,12 +3172,12 @@ uint16_t mpu6050GetFIFOCount() */ uint8_t mpu6050GetFIFOByte() { - i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_FIFO_R_W, buffer); + // i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_FIFO_R_W, buffer); return buffer[0]; } void mpu6050GetFIFOBytes(uint8_t *data, uint8_t length) { - i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_FIFO_R_W, length, data); + // i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_FIFO_R_W, length, data); } /** Write byte to FIFO buffer. * @see getFIFOByte() @@ -3148,7 +3185,7 @@ void mpu6050GetFIFOBytes(uint8_t *data, uint8_t length) */ void mpu6050SetFIFOByte(uint8_t data) { - i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_FIFO_R_W, data); + // i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_FIFO_R_W, data); } // WHO_AM_I register @@ -3162,8 +3199,8 @@ void mpu6050SetFIFOByte(uint8_t data) */ uint8_t mpu6050GetDeviceID() { - i2cdevReadBits(I2Cx, devAddr, MPU6050_RA_WHO_AM_I, MPU6050_WHO_AM_I_BIT, MPU6050_WHO_AM_I_LENGTH, - buffer); + // i2cdevReadBits(I2Cx, devAddr, MPU6050_RA_WHO_AM_I, MPU6050_WHO_AM_I_BIT, MPU6050_WHO_AM_I_LENGTH, + // buffer); return buffer[0]; } /** Set Device ID. @@ -3177,8 +3214,8 @@ uint8_t mpu6050GetDeviceID() */ void mpu6050SetDeviceID(uint8_t id) { - i2cdevWriteBits(I2Cx, devAddr, MPU6050_RA_WHO_AM_I, MPU6050_WHO_AM_I_BIT, MPU6050_WHO_AM_I_LENGTH, - id); + // i2cdevWriteBits(I2Cx, devAddr, MPU6050_RA_WHO_AM_I, MPU6050_WHO_AM_I_BIT, MPU6050_WHO_AM_I_LENGTH, + // id); } // ======== UNDOCUMENTED/DMP REGISTERS/METHODS ======== @@ -3187,212 +3224,212 @@ void mpu6050SetDeviceID(uint8_t id) uint8_t mpu6050GetOTPBankValid() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_XG_OFFS_TC, MPU6050_TC_OTP_BNK_VLD_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_XG_OFFS_TC, MPU6050_TC_OTP_BNK_VLD_BIT, buffer); return buffer[0]; } void mpu6050SetOTPBankValid(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_XG_OFFS_TC, MPU6050_TC_OTP_BNK_VLD_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_XG_OFFS_TC, MPU6050_TC_OTP_BNK_VLD_BIT, enabled); } int8_t mpu6050GetXGyroOffset() { - i2cdevReadBits(I2Cx, devAddr, MPU6050_RA_XG_OFFS_TC, MPU6050_TC_OFFSET_BIT, - MPU6050_TC_OFFSET_LENGTH, buffer); + // i2cdevReadBits(I2Cx, devAddr, MPU6050_RA_XG_OFFS_TC, MPU6050_TC_OFFSET_BIT, + // MPU6050_TC_OFFSET_LENGTH, buffer); return buffer[0]; } void mpu6050SetXGyroOffset(int8_t offset) { - i2cdevWriteBits(I2Cx, devAddr, MPU6050_RA_XG_OFFS_TC, MPU6050_TC_OFFSET_BIT, - MPU6050_TC_OFFSET_LENGTH, offset); + // i2cdevWriteBits(I2Cx, devAddr, MPU6050_RA_XG_OFFS_TC, MPU6050_TC_OFFSET_BIT, + // MPU6050_TC_OFFSET_LENGTH, offset); } // YG_OFFS_TC register int8_t mpu6050GetYGyroOffset() { - i2cdevReadBits(I2Cx, devAddr, MPU6050_RA_YG_OFFS_TC, MPU6050_TC_OFFSET_BIT, - MPU6050_TC_OFFSET_LENGTH, buffer); + // i2cdevReadBits(I2Cx, devAddr, MPU6050_RA_YG_OFFS_TC, MPU6050_TC_OFFSET_BIT, + // MPU6050_TC_OFFSET_LENGTH, buffer); return buffer[0]; } void mpu6050SetYGyroOffset(int8_t offset) { - i2cdevWriteBits(I2Cx, devAddr, MPU6050_RA_YG_OFFS_TC, MPU6050_TC_OFFSET_BIT, - MPU6050_TC_OFFSET_LENGTH, offset); + // i2cdevWriteBits(I2Cx, devAddr, MPU6050_RA_YG_OFFS_TC, MPU6050_TC_OFFSET_BIT, + // MPU6050_TC_OFFSET_LENGTH, offset); } // ZG_OFFS_TC register int8_t mpu6050GetZGyroOffset() { - i2cdevReadBits(I2Cx, devAddr, MPU6050_RA_ZG_OFFS_TC, MPU6050_TC_OFFSET_BIT, - MPU6050_TC_OFFSET_LENGTH, buffer); + // i2cdevReadBits(I2Cx, devAddr, MPU6050_RA_ZG_OFFS_TC, MPU6050_TC_OFFSET_BIT, + // MPU6050_TC_OFFSET_LENGTH, buffer); return buffer[0]; } void mpu6050SetZGyroOffset(int8_t offset) { - i2cdevWriteBits(I2Cx, devAddr, MPU6050_RA_ZG_OFFS_TC, MPU6050_TC_OFFSET_BIT, - MPU6050_TC_OFFSET_LENGTH, offset); + // i2cdevWriteBits(I2Cx, devAddr, MPU6050_RA_ZG_OFFS_TC, MPU6050_TC_OFFSET_BIT, + // MPU6050_TC_OFFSET_LENGTH, offset); } // X_FINE_GAIN register int8_t mpu6050GetXFineGain() { - i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_X_FINE_GAIN, buffer); + // i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_X_FINE_GAIN, buffer); return buffer[0]; } void mpu6050SetXFineGain(int8_t gain) { - i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_X_FINE_GAIN, gain); + // i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_X_FINE_GAIN, gain); } // Y_FINE_GAIN register int8_t mpu6050GetYFineGain() { - i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_Y_FINE_GAIN, buffer); + // i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_Y_FINE_GAIN, buffer); return buffer[0]; } void mpu6050SetYFineGain(int8_t gain) { - i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_Y_FINE_GAIN, gain); + // i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_Y_FINE_GAIN, gain); } // Z_FINE_GAIN register int8_t mpu6050GetZFineGain() { - i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_Z_FINE_GAIN, buffer); + // i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_Z_FINE_GAIN, buffer); return buffer[0]; } void mpu6050SetZFineGain(int8_t gain) { - i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_Z_FINE_GAIN, gain); + // i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_Z_FINE_GAIN, gain); } // XA_OFFS_* registers int16_t mpu6050GetXAccelOffset() { - i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_XA_OFFS_H, 2, buffer); + // i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_XA_OFFS_H, 2, buffer); return (((int16_t) buffer[0]) << 8) | buffer[1]; } void mpu6050SetXAccelOffset(int16_t offset) { - i2cdevWriteReg8(I2Cx, devAddr, MPU6050_RA_XA_OFFS_H, 2, (uint8_t *)&offset); + // i2cdevWriteReg8(I2Cx, devAddr, MPU6050_RA_XA_OFFS_H, 2, (uint8_t *)&offset); } // YA_OFFS_* register int16_t mpu6050GetYAccelOffset() { - i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_YA_OFFS_H, 2, buffer); + // i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_YA_OFFS_H, 2, buffer); return (((int16_t) buffer[0]) << 8) | buffer[1]; } void mpu6050SetYAccelOffset(int16_t offset) { - i2cdevWriteReg8(I2Cx, devAddr, MPU6050_RA_YA_OFFS_H, 2, (uint8_t *)&offset); + // i2cdevWriteReg8(I2Cx, devAddr, MPU6050_RA_YA_OFFS_H, 2, (uint8_t *)&offset); } // ZA_OFFS_* register int16_t mpu6050GetZAccelOffset() { - i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_ZA_OFFS_H, 2, buffer); + // i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_ZA_OFFS_H, 2, buffer); return (((int16_t) buffer[0]) << 8) | buffer[1]; } void mpu6050SetZAccelOffset(int16_t offset) { - i2cdevWriteReg8(I2Cx, devAddr, MPU6050_RA_ZA_OFFS_H, 2, (uint8_t *)&offset); + // i2cdevWriteReg8(I2Cx, devAddr, MPU6050_RA_ZA_OFFS_H, 2, (uint8_t *)&offset); } // XG_OFFS_USR* registers int16_t mpu6050GetXGyroOffsetUser() { - i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_XG_OFFS_USRH, 2, buffer); + // i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_XG_OFFS_USRH, 2, buffer); return (((int16_t) buffer[0]) << 8) | buffer[1]; } void mpu6050SetXGyroOffsetUser(int16_t offset) { - i2cdevWriteReg8(I2Cx, devAddr, MPU6050_RA_XG_OFFS_USRH, 2, (uint8_t *)&offset); + // i2cdevWriteReg8(I2Cx, devAddr, MPU6050_RA_XG_OFFS_USRH, 2, (uint8_t *)&offset); } // YG_OFFS_USR* register int16_t mpu6050GetYGyroOffsetUser() { - i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_YG_OFFS_USRH, 2, buffer); + // i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_YG_OFFS_USRH, 2, buffer); return (((int16_t) buffer[0]) << 8) | buffer[1]; } void mpu6050SetYGyroOffsetUser(int16_t offset) { - i2cdevWriteReg8(I2Cx, devAddr, MPU6050_RA_YG_OFFS_USRH, 2, (uint8_t *)&offset); + // i2cdevWriteReg8(I2Cx, devAddr, MPU6050_RA_YG_OFFS_USRH, 2, (uint8_t *)&offset); } // ZG_OFFS_USR* register int16_t mpu6050GetZGyroOffsetUser() { - i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_ZG_OFFS_USRH, 2, buffer); + // i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_ZG_OFFS_USRH, 2, buffer); return (((int16_t) buffer[0]) << 8) | buffer[1]; } void mpu6050SetZGyroOffsetUser(int16_t offset) { - i2cdevWriteReg8(I2Cx, devAddr, MPU6050_RA_ZG_OFFS_USRH, 2, (uint8_t *)&offset); + // i2cdevWriteReg8(I2Cx, devAddr, MPU6050_RA_ZG_OFFS_USRH, 2, (uint8_t *)&offset); } // INT_ENABLE register (DMP functions) bool mpu6050GetIntPLLReadyEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_ENABLE, MPU6050_INTERRUPT_PLL_RDY_INT_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_ENABLE, MPU6050_INTERRUPT_PLL_RDY_INT_BIT, buffer); return buffer[0]; } void mpu6050SetIntPLLReadyEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_INT_ENABLE, MPU6050_INTERRUPT_PLL_RDY_INT_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_INT_ENABLE, MPU6050_INTERRUPT_PLL_RDY_INT_BIT, enabled); } bool mpu6050GetIntDMPEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_ENABLE, MPU6050_INTERRUPT_DMP_INT_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_ENABLE, MPU6050_INTERRUPT_DMP_INT_BIT, buffer); return buffer[0]; } void mpu6050SetIntDMPEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_INT_ENABLE, MPU6050_INTERRUPT_DMP_INT_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_INT_ENABLE, MPU6050_INTERRUPT_DMP_INT_BIT, enabled); } // DMP_INT_STATUS bool mpu6050GetDMPInt5Status() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_DMP_INT_STATUS, MPU6050_DMPINT_5_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_DMP_INT_STATUS, MPU6050_DMPINT_5_BIT, buffer); return buffer[0]; } bool mpu6050GetDMPInt4Status() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_DMP_INT_STATUS, MPU6050_DMPINT_4_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_DMP_INT_STATUS, MPU6050_DMPINT_4_BIT, buffer); return buffer[0]; } bool mpu6050GetDMPInt3Status() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_DMP_INT_STATUS, MPU6050_DMPINT_3_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_DMP_INT_STATUS, MPU6050_DMPINT_3_BIT, buffer); return buffer[0]; } bool mpu6050GetDMPInt2Status() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_DMP_INT_STATUS, MPU6050_DMPINT_2_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_DMP_INT_STATUS, MPU6050_DMPINT_2_BIT, buffer); return buffer[0]; } bool mpu6050GetDMPInt1Status() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_DMP_INT_STATUS, MPU6050_DMPINT_1_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_DMP_INT_STATUS, MPU6050_DMPINT_1_BIT, buffer); return buffer[0]; } bool mpu6050GetDMPInt0Status() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_DMP_INT_STATUS, MPU6050_DMPINT_0_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_DMP_INT_STATUS, MPU6050_DMPINT_0_BIT, buffer); return buffer[0]; } @@ -3400,12 +3437,12 @@ bool mpu6050GetDMPInt0Status() bool mpu6050GetIntPLLReadyStatus() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_STATUS, MPU6050_INTERRUPT_PLL_RDY_INT_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_STATUS, MPU6050_INTERRUPT_PLL_RDY_INT_BIT, buffer); return buffer[0]; } bool mpu6050GetIntDMPStatus() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_STATUS, MPU6050_INTERRUPT_DMP_INT_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_INT_STATUS, MPU6050_INTERRUPT_DMP_INT_BIT, buffer); return buffer[0]; } @@ -3413,165 +3450,165 @@ bool mpu6050GetIntDMPStatus() bool mpu6050GetDMPEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_USER_CTRL, MPU6050_USERCTRL_DMP_EN_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6050_RA_USER_CTRL, MPU6050_USERCTRL_DMP_EN_BIT, buffer); return buffer[0]; } void mpu6050SetDMPEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_USER_CTRL, MPU6050_USERCTRL_DMP_EN_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_USER_CTRL, MPU6050_USERCTRL_DMP_EN_BIT, enabled); } void mpu6050ResetDMP() { - i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_USER_CTRL, MPU6050_USERCTRL_DMP_RESET_BIT, 1); + // i2cdevWriteBit(I2Cx, devAddr, MPU6050_RA_USER_CTRL, MPU6050_USERCTRL_DMP_RESET_BIT, 1); } // BANK_SEL register void mpu6050SetMemoryBank(uint8_t bank, bool prefetchEnabled, bool userBank) { - bank &= 0x1F; - if (userBank) - bank |= 0x20; - if (prefetchEnabled) - bank |= 0x40; - i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_BANK_SEL, bank); + // bank &= 0x1F; + // if (userBank) + // bank |= 0x20; + // if (prefetchEnabled) + // bank |= 0x40; + // i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_BANK_SEL, bank); } // MEM_START_ADDR register void mpu6050SetMemoryStartAddress(uint8_t address) { - i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_MEM_START_ADDR, address); + // i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_MEM_START_ADDR, address); } // MEM_R_W register uint8_t mpu6050ReadMemoryByte() { - i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_MEM_R_W, buffer); + // i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_MEM_R_W, buffer); return buffer[0]; } void mpu6050WriteMemoryByte(uint8_t data) { - i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_MEM_R_W, data); + // i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_MEM_R_W, data); } void mpu6050ReadMemoryBlock(uint8_t *data, uint16_t dataSize, uint8_t bank, uint8_t address) { - mpu6050SetMemoryBank(bank, true, true); - mpu6050SetMemoryStartAddress(address); - uint8_t chunkSize; - uint16_t i; + // mpu6050SetMemoryBank(bank, true, true); + // mpu6050SetMemoryStartAddress(address); + // uint8_t chunkSize; + // uint16_t i; - for (i = 0; i < dataSize;) - { - // determine correct chunk size according to bank position and data size - chunkSize = MPU6050_DMP_MEMORY_CHUNK_SIZE; + // for (i = 0; i < dataSize;) + // { + // // determine correct chunk size according to bank position and data size + // chunkSize = MPU6050_DMP_MEMORY_CHUNK_SIZE; - // make sure we don't go past the data size - if (i + chunkSize > dataSize) - chunkSize = dataSize - i; + // // make sure we don't go past the data size + // if (i + chunkSize > dataSize) + // chunkSize = dataSize - i; - // make sure this chunk doesn't go past the bank boundary (256 bytes) - if (chunkSize > 256 - address) - chunkSize = 256 - address; + // // make sure this chunk doesn't go past the bank boundary (256 bytes) + // if (chunkSize > 256 - address) + // chunkSize = 256 - address; - // read the chunk of data as specified - i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_MEM_R_W, chunkSize, data + i); + // // read the chunk of data as specified + // i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_MEM_R_W, chunkSize, data + i); - // increase byte index by [chunkSize] - i += chunkSize; + // // increase byte index by [chunkSize] + // i += chunkSize; - // uint8_t automatically wraps to 0 at 256 - address += chunkSize; + // // uint8_t automatically wraps to 0 at 256 + // address += chunkSize; - // if we aren't done, update bank (if necessary) and address - if (i < dataSize) - { - if (address == 0) - bank++; - mpu6050SetMemoryBank(bank, true, true); - mpu6050SetMemoryStartAddress(address); - } - } + // // if we aren't done, update bank (if necessary) and address + // if (i < dataSize) + // { + // if (address == 0) + // bank++; + // mpu6050SetMemoryBank(bank, true, true); + // mpu6050SetMemoryStartAddress(address); + // } + // } } bool mpu6050WriteMemoryBlock(const uint8_t *data, uint16_t dataSize, uint8_t bank, uint8_t address, bool verify) { - static uint8_t verifyBuffer[MPU6050_DMP_MEMORY_CHUNK_SIZE]; - uint8_t chunkSize; - uint8_t *progBuffer; - uint16_t i; - - mpu6050SetMemoryBank(bank, true, true); - mpu6050SetMemoryStartAddress(address); - - for (i = 0; i < dataSize;) - { - // determine correct chunk size according to bank position and data size - chunkSize = MPU6050_DMP_MEMORY_CHUNK_SIZE; - - // make sure we don't go past the data size - if (i + chunkSize > dataSize) - chunkSize = dataSize - i; - - // make sure this chunk doesn't go past the bank boundary (256 bytes) - if (chunkSize > 256 - address) - chunkSize = 256 - address; - - // write the chunk of data as specified - progBuffer = (uint8_t *) data + i; - - i2cdevWriteReg8(I2Cx, devAddr, MPU6050_RA_MEM_R_W, chunkSize, progBuffer); - - // verify data if needed - if (verify) - { - uint32_t j; - mpu6050SetMemoryBank(bank, true, true); - mpu6050SetMemoryStartAddress(address); - i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_MEM_R_W, chunkSize, verifyBuffer); - - for (j = 0; j < chunkSize; j++) - { - if (progBuffer[j] != verifyBuffer[j]) - { - /*Serial.print("Block write verification error, bank "); - Serial.print(bank, DEC); - Serial.print(", address "); - Serial.print(address, DEC); - Serial.print("!\nExpected:"); - for (j = 0; j < chunkSize; j++) { - Serial.print(" 0x"); - if (progBuffer[j] < 16) Serial.print("0"); - Serial.print(progBuffer[j], HEX); - } - Serial.print("\nReceived:"); - for (uint8_t j = 0; j < chunkSize; j++) { - Serial.print(" 0x"); - if (verifyBuffer[i + j] < 16) Serial.print("0"); - Serial.print(verifyBuffer[i + j], HEX); - } - Serial.print("\n");*/ - return false; - } - } - } - - // increase byte index by [chunkSize] - i += chunkSize; - - // uint8_t automatically wraps to 0 at 256 - address += chunkSize; - - // if we aren't done, update bank (if necessary) and address - if (i < dataSize) - { - if (address == 0) - bank++; - mpu6050SetMemoryBank(bank, true, true); - mpu6050SetMemoryStartAddress(address); - } - } + // static uint8_t verifyBuffer[MPU6050_DMP_MEMORY_CHUNK_SIZE]; + // uint8_t chunkSize; + // uint8_t *progBuffer; + // uint16_t i; + + // mpu6050SetMemoryBank(bank, true, true); + // mpu6050SetMemoryStartAddress(address); + + // for (i = 0; i < dataSize;) + // { + // // determine correct chunk size according to bank position and data size + // chunkSize = MPU6050_DMP_MEMORY_CHUNK_SIZE; + + // // make sure we don't go past the data size + // if (i + chunkSize > dataSize) + // chunkSize = dataSize - i; + + // // make sure this chunk doesn't go past the bank boundary (256 bytes) + // if (chunkSize > 256 - address) + // chunkSize = 256 - address; + + // // write the chunk of data as specified + // progBuffer = (uint8_t *) data + i; + + // i2cdevWriteReg8(I2Cx, devAddr, MPU6050_RA_MEM_R_W, chunkSize, progBuffer); + + // // verify data if needed + // if (verify) + // { + // uint32_t j; + // mpu6050SetMemoryBank(bank, true, true); + // mpu6050SetMemoryStartAddress(address); + // i2cdevReadReg8(I2Cx, devAddr, MPU6050_RA_MEM_R_W, chunkSize, verifyBuffer); + + // for (j = 0; j < chunkSize; j++) + // { + // if (progBuffer[j] != verifyBuffer[j]) + // { + // /*Serial.print("Block write verification error, bank "); + // Serial.print(bank, DEC); + // Serial.print(", address "); + // Serial.print(address, DEC); + // Serial.print("!\nExpected:"); + // for (j = 0; j < chunkSize; j++) { + // Serial.print(" 0x"); + // if (progBuffer[j] < 16) Serial.print("0"); + // Serial.print(progBuffer[j], HEX); + // } + // Serial.print("\nReceived:"); + // for (uint8_t j = 0; j < chunkSize; j++) { + // Serial.print(" 0x"); + // if (verifyBuffer[i + j] < 16) Serial.print("0"); + // Serial.print(verifyBuffer[i + j], HEX); + // } + // Serial.print("\n");*/ + // return false; + // } + // } + // } + + // // increase byte index by [chunkSize] + // i += chunkSize; + + // // uint8_t automatically wraps to 0 at 256 + // address += chunkSize; + + // // if we aren't done, update bank (if necessary) and address + // if (i < dataSize) + // { + // if (address == 0) + // bank++; + // mpu6050SetMemoryBank(bank, true, true); + // mpu6050SetMemoryStartAddress(address); + // } + // } return true; } bool mpu6050WriteProgMemoryBlock(const uint8_t *data, uint16_t dataSize, uint8_t bank, @@ -3582,66 +3619,66 @@ bool mpu6050WriteProgMemoryBlock(const uint8_t *data, uint16_t dataSize, uint8_t #define MPU6050_DMP_CONFIG_BLOCK_SIZE 6 bool mpu6050WriteDMPConfigurationSet(const uint8_t *data, uint16_t dataSize) { - uint8_t *progBuffer, success, special; - uint16_t i; - - // config set data is a long string of blocks with the following structure: - // [bank] [offset] [length] [byte[0], byte[1], ..., byte[length]] - uint8_t bank=0; - uint8_t offset=0; - uint8_t length=0; - for (i = 0; i < dataSize;) - { - bank = data[i++]; - offset = data[i++]; - length = data[i++]; - } - - // write data or perform special action - if (length > 0) - { - // regular block of data to write - /*Serial.print("Writing config block to bank "); - Serial.print(bank); - Serial.print(", offset "); - Serial.print(offset); - Serial.print(", length="); - Serial.println(length);*/ - progBuffer = (uint8_t *) data + i; - success = mpu6050WriteMemoryBlock(progBuffer, length, bank, offset, true); - i += length; - } - else - { - // special instruction - // NOTE: this kind of behavior (what and when to do certain things) - // is totally undocumented. This code is in here based on observed - // behavior only, and exactly why (or even whether) it has to be here - // is anybody's guess for now. - special = data[i++]; - /*Serial.print("Special command code "); - Serial.print(special, HEX); - Serial.println(" found...");*/ - if (special == 0x01) - { - // enable DMP-related interrupts - mpu6050SetIntZeroMotionEnabled(true); - mpu6050SetIntFIFOBufferOverflowEnabled(true); - mpu6050SetIntDMPEnabled(true); - //i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_INT_ENABLE, 0x32); - success = true; - } - else - { - // unknown special command - success = false; - } - } - - if (!success) - { - return false; // uh oh - } + // uint8_t *progBuffer, success, special; + // uint16_t i; + + // // config set data is a long string of blocks with the following structure: + // // [bank] [offset] [length] [byte[0], byte[1], ..., byte[length]] + // uint8_t bank=0; + // uint8_t offset=0; + // uint8_t length=0; + // for (i = 0; i < dataSize;) + // { + // bank = data[i++]; + // offset = data[i++]; + // length = data[i++]; + // } + + // // write data or perform special action + // if (length > 0) + // { + // // regular block of data to write + // /*Serial.print("Writing config block to bank "); + // Serial.print(bank); + // Serial.print(", offset "); + // Serial.print(offset); + // Serial.print(", length="); + // Serial.println(length);*/ + // progBuffer = (uint8_t *) data + i; + // success = mpu6050WriteMemoryBlock(progBuffer, length, bank, offset, true); + // i += length; + // } + // else + // { + // // special instruction + // // NOTE: this kind of behavior (what and when to do certain things) + // // is totally undocumented. This code is in here based on observed + // // behavior only, and exactly why (or even whether) it has to be here + // // is anybody's guess for now. + // special = data[i++]; + // /*Serial.print("Special command code "); + // Serial.print(special, HEX); + // Serial.println(" found...");*/ + // if (special == 0x01) + // { + // // enable DMP-related interrupts + // mpu6050SetIntZeroMotionEnabled(true); + // mpu6050SetIntFIFOBufferOverflowEnabled(true); + // mpu6050SetIntDMPEnabled(true); + // //i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_INT_ENABLE, 0x32); + // success = true; + // } + // else + // { + // // unknown special command + // success = false; + // } + // } + + // if (!success) + // { + // return false; // uh oh + // } return true; } @@ -3654,22 +3691,22 @@ bool mpu6050WriteProgDMPConfigurationSet(const uint8_t *data, uint16_t dataSize) uint8_t mpu6050GetDMPConfig1() { - i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_DMP_CFG_1, buffer); + // i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_DMP_CFG_1, buffer); return buffer[0]; } void mpu6050SetDMPConfig1(uint8_t config) { - i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_DMP_CFG_1, config); + // i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_DMP_CFG_1, config); } // DMP_CFG_2 register uint8_t mpu6050GetDMPConfig2() { - i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_DMP_CFG_2, buffer); + // i2cdevReadByte(I2Cx, devAddr, MPU6050_RA_DMP_CFG_2, buffer); return buffer[0]; } void mpu6050SetDMPConfig2(uint8_t config) { - i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_DMP_CFG_2, config); + // i2cdevWriteByte(I2Cx, devAddr, MPU6050_RA_DMP_CFG_2, config); } diff --git a/crazyflie_software/crazyflie-firmware-2021.06/src/drivers/src/mpu6500.c b/crazyflie_software/crazyflie-firmware-2021.06/src/drivers/src/mpu6500.c index e54b85c9597a84ac62e99cbb4d658f1e0f767421..9a29f793058d1f5e0bd07f289bdc43b2d6c5bbfe 100644 --- a/crazyflie_software/crazyflie-firmware-2021.06/src/drivers/src/mpu6500.c +++ b/crazyflie_software/crazyflie-firmware-2021.06/src/drivers/src/mpu6500.c @@ -121,129 +121,131 @@ bool mpu6500TestConnection() */ bool mpu6500SelfTest() { - uint8_t rawData[6] = {0, 0, 0, 0, 0, 0}; - uint8_t saveReg[5]; - uint8_t selfTest[6]; - int32_t gAvg[3]={0}, aAvg[3]={0}, aSTAvg[3]={0}, gSTAvg[3]={0}; - int32_t factoryTrim[6]; - float aDiff[3], gDiff[3]; - uint8_t FS = 0; - int i; - - // Save old configuration - i2cdevReadByte(I2Cx, devAddr, MPU6500_RA_SMPLRT_DIV, &saveReg[0]); - i2cdevReadByte(I2Cx, devAddr, MPU6500_RA_CONFIG, &saveReg[1]); - i2cdevReadByte(I2Cx, devAddr, MPU6500_RA_GYRO_CONFIG, &saveReg[2]); - i2cdevReadByte(I2Cx, devAddr, MPU6500_RA_ACCEL_CONFIG_2, &saveReg[3]); - i2cdevReadByte(I2Cx, devAddr, MPU6500_RA_ACCEL_CONFIG, &saveReg[4]); - // Write test configuration - i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_SMPLRT_DIV, 0x00); // Set gyro sample rate to 1 kHz - i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_CONFIG, 0x02); // Set gyro sample rate to 1 kHz and DLPF to 92 Hz - i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_GYRO_CONFIG, 1<<FS); // Set full scale range for the gyro to 250 dps - i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_ACCEL_CONFIG_2, 0x02); // Set accelerometer rate to 1 kHz and bandwidth to 92 Hz - i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_ACCEL_CONFIG, 1<<FS); // Set full scale range for the accelerometer to 2 g - - for(i = 0; i < 200; i++) - { - // get average current values of gyro and acclerometer - i2cdevReadReg8(I2Cx, devAddr, MPU6500_RA_ACCEL_XOUT_H, 6, &rawData[0]); // Read the six raw data registers into data array - aAvg[0] += (int16_t)(((int16_t)rawData[0] << 8) | rawData[1]) ; // Turn the MSB and LSB into a signed 16-bit value - aAvg[1] += (int16_t)(((int16_t)rawData[2] << 8) | rawData[3]) ; - aAvg[2] += (int16_t)(((int16_t)rawData[4] << 8) | rawData[5]) ; - - i2cdevReadReg8(I2Cx, devAddr, MPU6500_RA_GYRO_XOUT_H, 6, &rawData[0]); // Read the six raw data registers sequentially into data array - gAvg[0] += (int16_t)((int16_t)rawData[0] << 8) | rawData[1]; // Turn the MSB and LSB into a signed 16-bit value - gAvg[1] += (int16_t)((int16_t)rawData[2] << 8) | rawData[3]; - gAvg[2] += (int16_t)((int16_t)rawData[4] << 8) | rawData[5]; - } - - for (i = 0; i < 3; i++) - { // Get average of 200 values and store as average current readings - aAvg[i] /= 200; - gAvg[i] /= 200; - } - - // Configure the accelerometer for self-test - i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_ACCEL_CONFIG, 0xE0); // Enable self test on all three axes and set accelerometer range to +/- 2 g - i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_GYRO_CONFIG, 0xE0); // Enable self test on all three axes and set gyro range to +/- 250 degrees/s - vTaskDelay(M2T(25)); // Delay a while to let the device stabilize - - for(i = 0; i < 200; i++) - { - // get average self-test values of gyro and acclerometer - i2cdevReadReg8(I2Cx, devAddr, MPU6500_RA_ACCEL_XOUT_H, 6, &rawData[0]); // Read the six raw data registers into data array - aSTAvg[0] += (int16_t)(((int16_t)rawData[0] << 8) | rawData[1]) ; // Turn the MSB and LSB into a signed 16-bit value - aSTAvg[1] += (int16_t)(((int16_t)rawData[2] << 8) | rawData[3]) ; - aSTAvg[2] += (int16_t)(((int16_t)rawData[4] << 8) | rawData[5]) ; - - i2cdevReadReg8(I2Cx, devAddr, MPU6500_RA_GYRO_XOUT_H, 6, &rawData[0]); // Read the six raw data registers sequentially into data array - gSTAvg[0] += (int16_t)(((int16_t)rawData[0] << 8) | rawData[1]) ; // Turn the MSB and LSB into a signed 16-bit value - gSTAvg[1] += (int16_t)(((int16_t)rawData[2] << 8) | rawData[3]) ; - gSTAvg[2] += (int16_t)(((int16_t)rawData[4] << 8) | rawData[5]) ; - } - - for (i =0; i < 3; i++) - { // Get average of 200 values and store as average self-test readings - aSTAvg[i] /= 200; - gSTAvg[i] /= 200; - } - - // Configure the gyro and accelerometer for normal operation - i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_ACCEL_CONFIG, 0x00); - i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_GYRO_CONFIG, 0x00); - vTaskDelay(M2T(25)); // Delay a while to let the device stabilize - - // Retrieve accelerometer and gyro factory Self-Test Code from USR_Reg - i2cdevReadByte(I2Cx, devAddr, MPU6500_RA_ST_X_ACCEL, &selfTest[0]); // X-axis accel self-test results - i2cdevReadByte(I2Cx, devAddr, MPU6500_RA_ST_Y_ACCEL, &selfTest[1]); // Y-axis accel self-test results - i2cdevReadByte(I2Cx, devAddr, MPU6500_RA_ST_Z_ACCEL, &selfTest[2]); // Z-axis accel self-test results - i2cdevReadByte(I2Cx, devAddr, MPU6500_RA_ST_X_GYRO, &selfTest[3]); // X-axis gyro self-test results - i2cdevReadByte(I2Cx, devAddr, MPU6500_RA_ST_Y_GYRO, &selfTest[4]); // Y-axis gyro self-test results - i2cdevReadByte(I2Cx, devAddr, MPU6500_RA_ST_Z_GYRO, &selfTest[5]); // Z-axis gyro self-test results - - for (i = 0; i < 6; i++) - { - if (selfTest[i] != 0) - { - factoryTrim[i] = mpu6500StTb[selfTest[i] - 1]; - } - else - { - factoryTrim[i] = 0; - } - } - - // Report results as a ratio of (STR - FT)/FT; the change from Factory Trim of the Self-Test Response - // To get percent, must multiply by 100 - for (i = 0; i < 3; i++) - { - aDiff[i] = 100.0f*((float)((aSTAvg[i] - aAvg[i]) - factoryTrim[i]))/factoryTrim[i]; // Report percent differences - gDiff[i] = 100.0f*((float)((gSTAvg[i] - gAvg[i]) - factoryTrim[i+3]))/factoryTrim[i+3]; // Report percent differences -// DEBUG_PRINT("a[%d] Avg:%d, StAvg:%d, Shift:%d, FT:%d, Diff:%0.2f\n", i, aAvg[i], aSTAvg[i], aSTAvg[i] - aAvg[i], factoryTrim[i], aDiff[i]); -// DEBUG_PRINT("g[%d] Avg:%d, StAvg:%d, Shift:%d, FT:%d, Diff:%0.2f\n", i, gAvg[i], gSTAvg[i], gSTAvg[i] - gAvg[i], factoryTrim[i+3], gDiff[i]); - } - - // Restore old configuration - i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_SMPLRT_DIV, saveReg[0]); - i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_CONFIG, saveReg[1]); - i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_GYRO_CONFIG, saveReg[2]); - i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_ACCEL_CONFIG_2, saveReg[3]); - i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_ACCEL_CONFIG, saveReg[4]); - - // Check result - if (mpu6500EvaluateSelfTest(MPU6500_ST_GYRO_LOW, MPU6500_ST_GYRO_HIGH, gDiff[0], "gyro X") && - mpu6500EvaluateSelfTest(MPU6500_ST_GYRO_LOW, MPU6500_ST_GYRO_HIGH, gDiff[1], "gyro Y") && - mpu6500EvaluateSelfTest(MPU6500_ST_GYRO_LOW, MPU6500_ST_GYRO_HIGH, gDiff[2], "gyro Z") && - mpu6500EvaluateSelfTest(MPU6500_ST_ACCEL_LOW, MPU6500_ST_ACCEL_HIGH, aDiff[0], "acc X") && - mpu6500EvaluateSelfTest(MPU6500_ST_ACCEL_LOW, MPU6500_ST_ACCEL_HIGH, aDiff[1], "acc Y") && - mpu6500EvaluateSelfTest(MPU6500_ST_ACCEL_LOW, MPU6500_ST_ACCEL_HIGH, aDiff[2], "acc Z")) - { - return true; - } - else - { - return false; - } +// uint8_t rawData[6] = {0, 0, 0, 0, 0, 0}; +// uint8_t saveReg[5]; +// uint8_t selfTest[6]; +// int32_t gAvg[3]={0}, aAvg[3]={0}, aSTAvg[3]={0}, gSTAvg[3]={0}; +// int32_t factoryTrim[6]; +// float aDiff[3], gDiff[3]; +// uint8_t FS = 0; +// int i; + +// // Save old configuration +// i2cdevReadByte(I2Cx, devAddr, MPU6500_RA_SMPLRT_DIV, &saveReg[0]); +// i2cdevReadByte(I2Cx, devAddr, MPU6500_RA_CONFIG, &saveReg[1]); +// i2cdevReadByte(I2Cx, devAddr, MPU6500_RA_GYRO_CONFIG, &saveReg[2]); +// i2cdevReadByte(I2Cx, devAddr, MPU6500_RA_ACCEL_CONFIG_2, &saveReg[3]); +// i2cdevReadByte(I2Cx, devAddr, MPU6500_RA_ACCEL_CONFIG, &saveReg[4]); +// // Write test configuration +// i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_SMPLRT_DIV, 0x00); // Set gyro sample rate to 1 kHz +// i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_CONFIG, 0x02); // Set gyro sample rate to 1 kHz and DLPF to 92 Hz +// i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_GYRO_CONFIG, 1<<FS); // Set full scale range for the gyro to 250 dps +// i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_ACCEL_CONFIG_2, 0x02); // Set accelerometer rate to 1 kHz and bandwidth to 92 Hz +// i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_ACCEL_CONFIG, 1<<FS); // Set full scale range for the accelerometer to 2 g + +// for(i = 0; i < 200; i++) +// { +// // get average current values of gyro and acclerometer +// i2cdevReadReg8(I2Cx, devAddr, MPU6500_RA_ACCEL_XOUT_H, 6, &rawData[0]); // Read the six raw data registers into data array +// aAvg[0] += (int16_t)(((int16_t)rawData[0] << 8) | rawData[1]) ; // Turn the MSB and LSB into a signed 16-bit value +// aAvg[1] += (int16_t)(((int16_t)rawData[2] << 8) | rawData[3]) ; +// aAvg[2] += (int16_t)(((int16_t)rawData[4] << 8) | rawData[5]) ; + +// i2cdevReadReg8(I2Cx, devAddr, MPU6500_RA_GYRO_XOUT_H, 6, &rawData[0]); // Read the six raw data registers sequentially into data array +// gAvg[0] += (int16_t)((int16_t)rawData[0] << 8) | rawData[1]; // Turn the MSB and LSB into a signed 16-bit value +// gAvg[1] += (int16_t)((int16_t)rawData[2] << 8) | rawData[3]; +// gAvg[2] += (int16_t)((int16_t)rawData[4] << 8) | rawData[5]; +// } + +// for (i = 0; i < 3; i++) +// { // Get average of 200 values and store as average current readings +// aAvg[i] /= 200; +// gAvg[i] /= 200; +// } + +// // Configure the accelerometer for self-test +// i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_ACCEL_CONFIG, 0xE0); // Enable self test on all three axes and set accelerometer range to +/- 2 g +// i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_GYRO_CONFIG, 0xE0); // Enable self test on all three axes and set gyro range to +/- 250 degrees/s +// vTaskDelay(M2T(25)); // Delay a while to let the device stabilize + +// for(i = 0; i < 200; i++) +// { +// // get average self-test values of gyro and acclerometer +// i2cdevReadReg8(I2Cx, devAddr, MPU6500_RA_ACCEL_XOUT_H, 6, &rawData[0]); // Read the six raw data registers into data array +// aSTAvg[0] += (int16_t)(((int16_t)rawData[0] << 8) | rawData[1]) ; // Turn the MSB and LSB into a signed 16-bit value +// aSTAvg[1] += (int16_t)(((int16_t)rawData[2] << 8) | rawData[3]) ; +// aSTAvg[2] += (int16_t)(((int16_t)rawData[4] << 8) | rawData[5]) ; + +// i2cdevReadReg8(I2Cx, devAddr, MPU6500_RA_GYRO_XOUT_H, 6, &rawData[0]); // Read the six raw data registers sequentially into data array +// gSTAvg[0] += (int16_t)(((int16_t)rawData[0] << 8) | rawData[1]) ; // Turn the MSB and LSB into a signed 16-bit value +// gSTAvg[1] += (int16_t)(((int16_t)rawData[2] << 8) | rawData[3]) ; +// gSTAvg[2] += (int16_t)(((int16_t)rawData[4] << 8) | rawData[5]) ; +// } + +// for (i =0; i < 3; i++) +// { // Get average of 200 values and store as average self-test readings +// aSTAvg[i] /= 200; +// gSTAvg[i] /= 200; +// } + +// // Configure the gyro and accelerometer for normal operation +// i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_ACCEL_CONFIG, 0x00); +// i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_GYRO_CONFIG, 0x00); +// vTaskDelay(M2T(25)); // Delay a while to let the device stabilize + +// // Retrieve accelerometer and gyro factory Self-Test Code from USR_Reg +// i2cdevReadByte(I2Cx, devAddr, MPU6500_RA_ST_X_ACCEL, &selfTest[0]); // X-axis accel self-test results +// i2cdevReadByte(I2Cx, devAddr, MPU6500_RA_ST_Y_ACCEL, &selfTest[1]); // Y-axis accel self-test results +// i2cdevReadByte(I2Cx, devAddr, MPU6500_RA_ST_Z_ACCEL, &selfTest[2]); // Z-axis accel self-test results +// i2cdevReadByte(I2Cx, devAddr, MPU6500_RA_ST_X_GYRO, &selfTest[3]); // X-axis gyro self-test results +// i2cdevReadByte(I2Cx, devAddr, MPU6500_RA_ST_Y_GYRO, &selfTest[4]); // Y-axis gyro self-test results +// i2cdevReadByte(I2Cx, devAddr, MPU6500_RA_ST_Z_GYRO, &selfTest[5]); // Z-axis gyro self-test results + +// for (i = 0; i < 6; i++) +// { +// if (selfTest[i] != 0) +// { +// factoryTrim[i] = mpu6500StTb[selfTest[i] - 1]; +// } +// else +// { +// factoryTrim[i] = 0; +// } +// } + +// // Report results as a ratio of (STR - FT)/FT; the change from Factory Trim of the Self-Test Response +// // To get percent, must multiply by 100 +// for (i = 0; i < 3; i++) +// { +// aDiff[i] = 100.0f*((float)((aSTAvg[i] - aAvg[i]) - factoryTrim[i]))/factoryTrim[i]; // Report percent differences +// gDiff[i] = 100.0f*((float)((gSTAvg[i] - gAvg[i]) - factoryTrim[i+3]))/factoryTrim[i+3]; // Report percent differences +// // DEBUG_PRINT("a[%d] Avg:%d, StAvg:%d, Shift:%d, FT:%d, Diff:%0.2f\n", i, aAvg[i], aSTAvg[i], aSTAvg[i] - aAvg[i], factoryTrim[i], aDiff[i]); +// // DEBUG_PRINT("g[%d] Avg:%d, StAvg:%d, Shift:%d, FT:%d, Diff:%0.2f\n", i, gAvg[i], gSTAvg[i], gSTAvg[i] - gAvg[i], factoryTrim[i+3], gDiff[i]); +// } + +// // Restore old configuration +// i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_SMPLRT_DIV, saveReg[0]); +// i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_CONFIG, saveReg[1]); +// i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_GYRO_CONFIG, saveReg[2]); +// i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_ACCEL_CONFIG_2, saveReg[3]); +// i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_ACCEL_CONFIG, saveReg[4]); + +// // Check result +// if (mpu6500EvaluateSelfTest(MPU6500_ST_GYRO_LOW, MPU6500_ST_GYRO_HIGH, gDiff[0], "gyro X") && +// mpu6500EvaluateSelfTest(MPU6500_ST_GYRO_LOW, MPU6500_ST_GYRO_HIGH, gDiff[1], "gyro Y") && +// mpu6500EvaluateSelfTest(MPU6500_ST_GYRO_LOW, MPU6500_ST_GYRO_HIGH, gDiff[2], "gyro Z") && +// mpu6500EvaluateSelfTest(MPU6500_ST_ACCEL_LOW, MPU6500_ST_ACCEL_HIGH, aDiff[0], "acc X") && +// mpu6500EvaluateSelfTest(MPU6500_ST_ACCEL_LOW, MPU6500_ST_ACCEL_HIGH, aDiff[1], "acc Y") && +// mpu6500EvaluateSelfTest(MPU6500_ST_ACCEL_LOW, MPU6500_ST_ACCEL_HIGH, aDiff[2], "acc Z")) +// { +// return true; +// } +// else +// { +// return false; +// } + +return true; } /** Evaluate the values from a MPU6500 self test. @@ -255,12 +257,12 @@ bool mpu6500SelfTest() */ bool mpu6500EvaluateSelfTest(float low, float high, float value, char* string) { - if (value < low || value > high) - { - DEBUG_PRINT("Self test %s [FAIL]. low: %0.2f, high: %0.2f, measured: %0.2f\n", - string, (double)low, (double)high, (double)value); - return false; - } + // if (value < low || value > high) + // { + // DEBUG_PRINT("Self test %s [FAIL]. low: %0.2f, high: %0.2f, measured: %0.2f\n", + // string, (double)low, (double)high, (double)value); + // return false; + // } return true; } @@ -289,7 +291,7 @@ bool mpu6500EvaluateSelfTest(float low, float high, float value, char* string) */ uint8_t mpu6500GetRate() { - i2cdevReadByte(I2Cx, devAddr, MPU6500_RA_SMPLRT_DIV, buffer); + // i2cdevReadByte(I2Cx, devAddr, MPU6500_RA_SMPLRT_DIV, buffer); return buffer[0]; } /** Set gyroscope sample rate divider. @@ -299,7 +301,7 @@ uint8_t mpu6500GetRate() */ void mpu6500SetRate(uint8_t rate) { - i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_SMPLRT_DIV, rate); + // i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_SMPLRT_DIV, rate); } // CONFIG register @@ -333,8 +335,8 @@ void mpu6500SetRate(uint8_t rate) */ uint8_t mpu6500GetExternalFrameSync() { - i2cdevReadBits(I2Cx, devAddr, MPU6500_RA_CONFIG, MPU6500_CFG_EXT_SYNC_SET_BIT, - MPU6500_CFG_EXT_SYNC_SET_LENGTH, buffer); + // i2cdevReadBits(I2Cx, devAddr, MPU6500_RA_CONFIG, MPU6500_CFG_EXT_SYNC_SET_BIT, + // MPU6500_CFG_EXT_SYNC_SET_LENGTH, buffer); return buffer[0]; } /** Set external FSYNC configuration. @@ -344,8 +346,8 @@ uint8_t mpu6500GetExternalFrameSync() */ void mpu6500SetExternalFrameSync(uint8_t sync) { - i2cdevWriteBits(I2Cx, devAddr, MPU6500_RA_CONFIG, MPU6500_CFG_EXT_SYNC_SET_BIT, - MPU6500_CFG_EXT_SYNC_SET_LENGTH, sync); + // i2cdevWriteBits(I2Cx, devAddr, MPU6500_RA_CONFIG, MPU6500_CFG_EXT_SYNC_SET_BIT, + // MPU6500_CFG_EXT_SYNC_SET_LENGTH, sync); } /** Get digital low-pass filter configuration. * The DLPF_CFG parameter sets the digital low pass filter configuration. It @@ -377,8 +379,8 @@ void mpu6500SetExternalFrameSync(uint8_t sync) */ uint8_t mpu6500GetDLPFMode() { - i2cdevReadBits(I2Cx, devAddr, MPU6500_RA_CONFIG, MPU6500_CFG_DLPF_CFG_BIT, - MPU6500_CFG_DLPF_CFG_LENGTH, buffer); + // i2cdevReadBits(I2Cx, devAddr, MPU6500_RA_CONFIG, MPU6500_CFG_DLPF_CFG_BIT, + // MPU6500_CFG_DLPF_CFG_LENGTH, buffer); return buffer[0]; } /** Set digital low-pass filter configuration. @@ -391,8 +393,8 @@ uint8_t mpu6500GetDLPFMode() */ void mpu6500SetDLPFMode(uint8_t mode) { - i2cdevWriteBits(I2Cx, devAddr, MPU6500_RA_CONFIG, MPU6500_CFG_DLPF_CFG_BIT, - MPU6500_CFG_DLPF_CFG_LENGTH, mode); + // i2cdevWriteBits(I2Cx, devAddr, MPU6500_RA_CONFIG, MPU6500_CFG_DLPF_CFG_BIT, + // MPU6500_CFG_DLPF_CFG_LENGTH, mode); } // GYRO_CONFIG register @@ -416,8 +418,8 @@ void mpu6500SetDLPFMode(uint8_t mode) */ uint8_t mpu6500GetFullScaleGyroRangeId() { - i2cdevReadBits(I2Cx, devAddr, MPU6500_RA_GYRO_CONFIG, MPU6500_GCONFIG_FS_SEL_BIT, - MPU6500_GCONFIG_FS_SEL_LENGTH, buffer); + // i2cdevReadBits(I2Cx, devAddr, MPU6500_RA_GYRO_CONFIG, MPU6500_GCONFIG_FS_SEL_BIT, + // MPU6500_GCONFIG_FS_SEL_LENGTH, buffer); return buffer[0]; } @@ -434,25 +436,25 @@ float mpu6500GetFullScaleGyroDPL() int32_t rangeId; float range; - rangeId = mpu6500GetFullScaleGyroRangeId(); - switch (rangeId) - { - case MPU6500_GYRO_FS_250: - range = MPU6500_DEG_PER_LSB_250; - break; - case MPU6500_GYRO_FS_500: - range = MPU6500_DEG_PER_LSB_500; - break; - case MPU6500_GYRO_FS_1000: - range = MPU6500_DEG_PER_LSB_1000; - break; - case MPU6500_GYRO_FS_2000: - range = MPU6500_DEG_PER_LSB_2000; - break; - default: - range = MPU6500_DEG_PER_LSB_1000; - break; - } + // rangeId = mpu6500GetFullScaleGyroRangeId(); + // switch (rangeId) + // { + // case MPU6500_GYRO_FS_250: + // range = MPU6500_DEG_PER_LSB_250; + // break; + // case MPU6500_GYRO_FS_500: + // range = MPU6500_DEG_PER_LSB_500; + // break; + // case MPU6500_GYRO_FS_1000: + // range = MPU6500_DEG_PER_LSB_1000; + // break; + // case MPU6500_GYRO_FS_2000: + // range = MPU6500_DEG_PER_LSB_2000; + // break; + // default: + // range = MPU6500_DEG_PER_LSB_1000; + // break; + // } return range; } @@ -467,23 +469,23 @@ float mpu6500GetFullScaleGyroDPL() */ void mpu6500SetFullScaleGyroRange(uint8_t range) { - i2cdevWriteBits(I2Cx, devAddr, MPU6500_RA_GYRO_CONFIG, MPU6500_GCONFIG_FS_SEL_BIT, - MPU6500_GCONFIG_FS_SEL_LENGTH, range); + // i2cdevWriteBits(I2Cx, devAddr, MPU6500_RA_GYRO_CONFIG, MPU6500_GCONFIG_FS_SEL_BIT, + // MPU6500_GCONFIG_FS_SEL_LENGTH, range); } void mpu6500SetGyroXSelfTest(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_GYRO_CONFIG, MPU6500_GCONFIG_XG_ST_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_GYRO_CONFIG, MPU6500_GCONFIG_XG_ST_BIT, enabled); } void mpu6500SetGyroYSelfTest(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_GYRO_CONFIG, MPU6500_GCONFIG_YG_ST_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_GYRO_CONFIG, MPU6500_GCONFIG_YG_ST_BIT, enabled); } void mpu6500SetGyroZSelfTest(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_GYRO_CONFIG, MPU6500_GCONFIG_ZG_ST_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_GYRO_CONFIG, MPU6500_GCONFIG_ZG_ST_BIT, enabled); } // ACCEL_CONFIG register @@ -494,7 +496,7 @@ void mpu6500SetGyroZSelfTest(bool enabled) */ bool mpu6500GetAccelXSelfTest() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_ACCEL_CONFIG, MPU6500_ACONFIG_XA_ST_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_ACCEL_CONFIG, MPU6500_ACONFIG_XA_ST_BIT, buffer); return buffer[0]; } /** Get self-test enabled setting for accelerometer X axis. @@ -503,7 +505,7 @@ bool mpu6500GetAccelXSelfTest() */ void mpu6500SetAccelXSelfTest(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_ACCEL_CONFIG, MPU6500_ACONFIG_XA_ST_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_ACCEL_CONFIG, MPU6500_ACONFIG_XA_ST_BIT, enabled); } /** Get self-test enabled value for accelerometer Y axis. * @return Self-test enabled value @@ -511,7 +513,7 @@ void mpu6500SetAccelXSelfTest(bool enabled) */ bool mpu6500GetAccelYSelfTest() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_ACCEL_CONFIG, MPU6500_ACONFIG_YA_ST_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_ACCEL_CONFIG, MPU6500_ACONFIG_YA_ST_BIT, buffer); return buffer[0]; } /** Get self-test enabled value for accelerometer Y axis. @@ -520,7 +522,7 @@ bool mpu6500GetAccelYSelfTest() */ void mpu6500SetAccelYSelfTest(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_ACCEL_CONFIG, MPU6500_ACONFIG_YA_ST_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_ACCEL_CONFIG, MPU6500_ACONFIG_YA_ST_BIT, enabled); } /** Get self-test enabled value for accelerometer Z axis. * @return Self-test enabled value @@ -528,7 +530,7 @@ void mpu6500SetAccelYSelfTest(bool enabled) */ bool mpu6500GetAccelZSelfTest() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_ACCEL_CONFIG, MPU6500_ACONFIG_ZA_ST_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_ACCEL_CONFIG, MPU6500_ACONFIG_ZA_ST_BIT, buffer); return buffer[0]; } /** Set self-test enabled value for accelerometer Z axis. @@ -537,7 +539,7 @@ bool mpu6500GetAccelZSelfTest() */ void mpu6500SetAccelZSelfTest(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_ACCEL_CONFIG, MPU6500_ACONFIG_ZA_ST_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_ACCEL_CONFIG, MPU6500_ACONFIG_ZA_ST_BIT, enabled); } /** Get full-scale accelerometer range. * The FS_SEL parameter allows setting the full-scale range of the accelerometer @@ -558,8 +560,8 @@ void mpu6500SetAccelZSelfTest(bool enabled) */ uint8_t mpu6500GetFullScaleAccelRangeId() { - i2cdevReadBits(I2Cx, devAddr, MPU6500_RA_ACCEL_CONFIG, MPU6500_ACONFIG_AFS_SEL_BIT, - MPU6500_ACONFIG_AFS_SEL_LENGTH, buffer); + // i2cdevReadBits(I2Cx, devAddr, MPU6500_RA_ACCEL_CONFIG, MPU6500_ACONFIG_AFS_SEL_BIT, + // MPU6500_ACONFIG_AFS_SEL_LENGTH, buffer); return buffer[0]; } @@ -576,25 +578,25 @@ float mpu6500GetFullScaleAccelGPL() int32_t rangeId; float range; - rangeId = mpu6500GetFullScaleAccelRangeId(); - switch (rangeId) - { - case MPU6500_ACCEL_FS_2: - range = MPU6500_G_PER_LSB_2; - break; - case MPU6500_ACCEL_FS_4: - range = MPU6500_G_PER_LSB_4; - break; - case MPU6500_ACCEL_FS_8: - range = MPU6500_G_PER_LSB_8; - break; - case MPU6500_ACCEL_FS_16: - range = MPU6500_G_PER_LSB_16; - break; - default: - range = MPU6500_DEG_PER_LSB_1000; - break; - } + // rangeId = mpu6500GetFullScaleAccelRangeId(); + // switch (rangeId) + // { + // case MPU6500_ACCEL_FS_2: + // range = MPU6500_G_PER_LSB_2; + // break; + // case MPU6500_ACCEL_FS_4: + // range = MPU6500_G_PER_LSB_4; + // break; + // case MPU6500_ACCEL_FS_8: + // range = MPU6500_G_PER_LSB_8; + // break; + // case MPU6500_ACCEL_FS_16: + // range = MPU6500_G_PER_LSB_16; + // break; + // default: + // range = MPU6500_DEG_PER_LSB_1000; + // break; + // } return range; } @@ -605,8 +607,8 @@ float mpu6500GetFullScaleAccelGPL() */ void mpu6500SetFullScaleAccelRange(uint8_t range) { - i2cdevWriteBits(I2Cx, devAddr, MPU6500_RA_ACCEL_CONFIG, MPU6500_ACONFIG_AFS_SEL_BIT, - MPU6500_ACONFIG_AFS_SEL_LENGTH, range); + // i2cdevWriteBits(I2Cx, devAddr, MPU6500_RA_ACCEL_CONFIG, MPU6500_ACONFIG_AFS_SEL_BIT, + // MPU6500_ACONFIG_AFS_SEL_LENGTH, range); } /** Set accelerometer digital low pass filter. @@ -621,8 +623,8 @@ void mpu6500SetFullScaleAccelRange(uint8_t range) */ void mpu6500SetAccelDLPF(uint8_t range) { - i2cdevWriteBits(I2Cx, devAddr, MPU6500_RA_ACCEL_CONFIG_2, MPU6500_ACONFIG2_DLPF_BIT, - MPU6500_ACONFIG2_DLPF_LENGTH, range); + // i2cdevWriteBits(I2Cx, devAddr, MPU6500_RA_ACCEL_CONFIG_2, MPU6500_ACONFIG2_DLPF_BIT, + // MPU6500_ACONFIG2_DLPF_LENGTH, range); } /** Get the high-pass filter configuration. @@ -662,8 +664,8 @@ void mpu6500SetAccelDLPF(uint8_t range) */ uint8_t mpu6500GetDHPFMode() { - i2cdevReadBits(I2Cx, devAddr, MPU6500_RA_ACCEL_CONFIG, MPU6500_ACONFIG_ACCEL_HPF_BIT, - MPU6500_ACONFIG_ACCEL_HPF_LENGTH, buffer); + // i2cdevReadBits(I2Cx, devAddr, MPU6500_RA_ACCEL_CONFIG, MPU6500_ACONFIG_ACCEL_HPF_BIT, + // MPU6500_ACONFIG_ACCEL_HPF_LENGTH, buffer); return buffer[0]; } /** Set the high-pass filter configuration. @@ -674,8 +676,8 @@ uint8_t mpu6500GetDHPFMode() */ void mpu6500SetDHPFMode(uint8_t bandwidth) { - i2cdevWriteBits(I2Cx, devAddr, MPU6500_RA_ACCEL_CONFIG, MPU6500_ACONFIG_ACCEL_HPF_BIT, - MPU6500_ACONFIG_ACCEL_HPF_LENGTH, bandwidth); + // i2cdevWriteBits(I2Cx, devAddr, MPU6500_RA_ACCEL_CONFIG, MPU6500_ACONFIG_ACCEL_HPF_BIT, + // MPU6500_ACONFIG_ACCEL_HPF_LENGTH, bandwidth); } // FIFO_EN register @@ -688,7 +690,7 @@ void mpu6500SetDHPFMode(uint8_t bandwidth) */ bool mpu6500GetTempFIFOEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_FIFO_EN, MPU6500_TEMP_FIFO_EN_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_FIFO_EN, MPU6500_TEMP_FIFO_EN_BIT, buffer); return buffer[0]; } /** Set temperature FIFO enabled value. @@ -698,7 +700,7 @@ bool mpu6500GetTempFIFOEnabled() */ void mpu6500SetTempFIFOEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_FIFO_EN, MPU6500_TEMP_FIFO_EN_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_FIFO_EN, MPU6500_TEMP_FIFO_EN_BIT, enabled); } /** Get gyroscope X-axis FIFO enabled value. * When set to 1, this bit enables GYRO_XOUT_H and GYRO_XOUT_L (Registers 67 and @@ -708,7 +710,7 @@ void mpu6500SetTempFIFOEnabled(bool enabled) */ bool mpu6500GetXGyroFIFOEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_FIFO_EN, MPU6500_XG_FIFO_EN_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_FIFO_EN, MPU6500_XG_FIFO_EN_BIT, buffer); return buffer[0]; } /** Set gyroscope X-axis FIFO enabled value. @@ -718,7 +720,7 @@ bool mpu6500GetXGyroFIFOEnabled() */ void mpu6500SetXGyroFIFOEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_FIFO_EN, MPU6500_XG_FIFO_EN_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_FIFO_EN, MPU6500_XG_FIFO_EN_BIT, enabled); } /** Get gyroscope Y-axis FIFO enabled value. * When set to 1, this bit enables GYRO_YOUT_H and GYRO_YOUT_L (Registers 69 and @@ -728,7 +730,7 @@ void mpu6500SetXGyroFIFOEnabled(bool enabled) */ bool mpu6500GetYGyroFIFOEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_FIFO_EN, MPU6500_YG_FIFO_EN_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_FIFO_EN, MPU6500_YG_FIFO_EN_BIT, buffer); return buffer[0]; } /** Set gyroscope Y-axis FIFO enabled value. @@ -738,7 +740,7 @@ bool mpu6500GetYGyroFIFOEnabled() */ void mpu6500SetYGyroFIFOEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_FIFO_EN, MPU6500_YG_FIFO_EN_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_FIFO_EN, MPU6500_YG_FIFO_EN_BIT, enabled); } /** Get gyroscope Z-axis FIFO enabled value. * When set to 1, this bit enables GYRO_ZOUT_H and GYRO_ZOUT_L (Registers 71 and @@ -748,7 +750,7 @@ void mpu6500SetYGyroFIFOEnabled(bool enabled) */ bool mpu6500GetZGyroFIFOEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_FIFO_EN, MPU6500_ZG_FIFO_EN_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_FIFO_EN, MPU6500_ZG_FIFO_EN_BIT, buffer); return buffer[0]; } /** Set gyroscope Z-axis FIFO enabled value. @@ -758,7 +760,7 @@ bool mpu6500GetZGyroFIFOEnabled() */ void mpu6500SetZGyroFIFOEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_FIFO_EN, MPU6500_ZG_FIFO_EN_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_FIFO_EN, MPU6500_ZG_FIFO_EN_BIT, enabled); } /** Get accelerometer FIFO enabled value. * When set to 1, this bit enables ACCEL_XOUT_H, ACCEL_XOUT_L, ACCEL_YOUT_H, @@ -769,7 +771,7 @@ void mpu6500SetZGyroFIFOEnabled(bool enabled) */ bool mpu6500GetAccelFIFOEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_FIFO_EN, MPU6500_ACCEL_FIFO_EN_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_FIFO_EN, MPU6500_ACCEL_FIFO_EN_BIT, buffer); return buffer[0]; } /** Set accelerometer FIFO enabled value. @@ -779,7 +781,7 @@ bool mpu6500GetAccelFIFOEnabled() */ void mpu6500SetAccelFIFOEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_FIFO_EN, MPU6500_ACCEL_FIFO_EN_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_FIFO_EN, MPU6500_ACCEL_FIFO_EN_BIT, enabled); } /** Get Slave 2 FIFO enabled value. * When set to 1, this bit enables EXT_SENS_DATA registers (Registers 73 to 96) @@ -789,7 +791,7 @@ void mpu6500SetAccelFIFOEnabled(bool enabled) */ bool mpu6500GetSlave2FIFOEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_FIFO_EN, MPU6500_SLV2_FIFO_EN_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_FIFO_EN, MPU6500_SLV2_FIFO_EN_BIT, buffer); return buffer[0]; } /** Set Slave 2 FIFO enabled value. @@ -799,7 +801,7 @@ bool mpu6500GetSlave2FIFOEnabled() */ void mpu6500SetSlave2FIFOEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_FIFO_EN, MPU6500_SLV2_FIFO_EN_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_FIFO_EN, MPU6500_SLV2_FIFO_EN_BIT, enabled); } /** Get Slave 1 FIFO enabled value. * When set to 1, this bit enables EXT_SENS_DATA registers (Registers 73 to 96) @@ -809,7 +811,7 @@ void mpu6500SetSlave2FIFOEnabled(bool enabled) */ bool mpu6500GetSlave1FIFOEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_FIFO_EN, MPU6500_SLV1_FIFO_EN_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_FIFO_EN, MPU6500_SLV1_FIFO_EN_BIT, buffer); return buffer[0]; } /** Set Slave 1 FIFO enabled value. @@ -819,7 +821,7 @@ bool mpu6500GetSlave1FIFOEnabled() */ void mpu6500SetSlave1FIFOEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_FIFO_EN, MPU6500_SLV1_FIFO_EN_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_FIFO_EN, MPU6500_SLV1_FIFO_EN_BIT, enabled); } /** Get Slave 0 FIFO enabled value. * When set to 1, this bit enables EXT_SENS_DATA registers (Registers 73 to 96) @@ -829,7 +831,7 @@ void mpu6500SetSlave1FIFOEnabled(bool enabled) */ bool mpu6500GetSlave0FIFOEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_FIFO_EN, MPU6500_SLV0_FIFO_EN_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_FIFO_EN, MPU6500_SLV0_FIFO_EN_BIT, buffer); return buffer[0]; } /** Set Slave 0 FIFO enabled value. @@ -839,7 +841,7 @@ bool mpu6500GetSlave0FIFOEnabled() */ void mpu6500SetSlave0FIFOEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_FIFO_EN, MPU6500_SLV0_FIFO_EN_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_FIFO_EN, MPU6500_SLV0_FIFO_EN_BIT, enabled); } // I2C_MST_CTRL register @@ -861,7 +863,7 @@ void mpu6500SetSlave0FIFOEnabled(bool enabled) */ bool mpu6500GetMultiMasterEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_I2C_MST_CTRL, MPU6500_MULT_MST_EN_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_I2C_MST_CTRL, MPU6500_MULT_MST_EN_BIT, buffer); return buffer[0]; } /** Set multi-master enabled value. @@ -871,7 +873,7 @@ bool mpu6500GetMultiMasterEnabled() */ void mpu6500SetMultiMasterEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_I2C_MST_CTRL, MPU6500_MULT_MST_EN_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_I2C_MST_CTRL, MPU6500_MULT_MST_EN_BIT, enabled); } /** Get wait-for-external-sensor-data enabled value. * When the WAIT_FOR_ES bit is set to 1, the Data Ready interrupt will be @@ -886,7 +888,7 @@ void mpu6500SetMultiMasterEnabled(bool enabled) */ bool mpu6500GetWaitForExternalSensorEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_I2C_MST_CTRL, MPU6500_WAIT_FOR_ES_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_I2C_MST_CTRL, MPU6500_WAIT_FOR_ES_BIT, buffer); return buffer[0]; } /** Set wait-for-external-sensor-data enabled value. @@ -896,7 +898,7 @@ bool mpu6500GetWaitForExternalSensorEnabled() */ void mpu6500SetWaitForExternalSensorEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_I2C_MST_CTRL, MPU6500_WAIT_FOR_ES_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_I2C_MST_CTRL, MPU6500_WAIT_FOR_ES_BIT, enabled); } /** Get Slave 3 FIFO enabled value. * When set to 1, this bit enables EXT_SENS_DATA registers (Registers 73 to 96) @@ -906,7 +908,7 @@ void mpu6500SetWaitForExternalSensorEnabled(bool enabled) */ bool mpu6500GetSlave3FIFOEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_I2C_MST_CTRL, MPU6500_SLV_3_FIFO_EN_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_I2C_MST_CTRL, MPU6500_SLV_3_FIFO_EN_BIT, buffer); return buffer[0]; } /** Set Slave 3 FIFO enabled value. @@ -916,7 +918,7 @@ bool mpu6500GetSlave3FIFOEnabled() */ void mpu6500SetSlave3FIFOEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_I2C_MST_CTRL, MPU6500_SLV_3_FIFO_EN_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_I2C_MST_CTRL, MPU6500_SLV_3_FIFO_EN_BIT, enabled); } /** Get slave read/write transition enabled value. * The I2C_MST_P_NSR bit configures the I2C Master's transition from one slave @@ -930,7 +932,7 @@ void mpu6500SetSlave3FIFOEnabled(bool enabled) */ bool mpu6500GetSlaveReadWriteTransitionEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_I2C_MST_CTRL, MPU6500_I2C_MST_P_NSR_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_I2C_MST_CTRL, MPU6500_I2C_MST_P_NSR_BIT, buffer); return buffer[0]; } /** Set slave read/write transition enabled value. @@ -940,7 +942,7 @@ bool mpu6500GetSlaveReadWriteTransitionEnabled() */ void mpu6500SetSlaveReadWriteTransitionEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_I2C_MST_CTRL, MPU6500_I2C_MST_P_NSR_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_I2C_MST_CTRL, MPU6500_I2C_MST_P_NSR_BIT, enabled); } /** Get I2C master clock speed. * I2C_MST_CLK is a 4 bit unsigned value which configures a divider on the @@ -973,8 +975,8 @@ void mpu6500SetSlaveReadWriteTransitionEnabled(bool enabled) */ uint8_t mpu6500GetMasterClockSpeed() { - i2cdevReadBits(I2Cx, devAddr, MPU6500_RA_I2C_MST_CTRL, MPU6500_I2C_MST_CLK_BIT, - MPU6500_I2C_MST_CLK_LENGTH, buffer); + // i2cdevReadBits(I2Cx, devAddr, MPU6500_RA_I2C_MST_CTRL, MPU6500_I2C_MST_CLK_BIT, + // MPU6500_I2C_MST_CLK_LENGTH, buffer); return buffer[0]; } /** Set I2C master clock speed. @@ -983,8 +985,8 @@ uint8_t mpu6500GetMasterClockSpeed() */ void mpu6500SetMasterClockSpeed(uint8_t speed) { - i2cdevWriteBits(I2Cx, devAddr, MPU6500_RA_I2C_MST_CTRL, MPU6500_I2C_MST_CLK_BIT, - MPU6500_I2C_MST_CLK_LENGTH, speed); + // i2cdevWriteBits(I2Cx, devAddr, MPU6500_RA_I2C_MST_CTRL, MPU6500_I2C_MST_CLK_BIT, + // MPU6500_I2C_MST_CLK_LENGTH, speed); } // I2C_SLV* registers (Slave 0-3) @@ -1032,9 +1034,9 @@ void mpu6500SetMasterClockSpeed(uint8_t speed) */ uint8_t mpu6500GetSlaveAddress(uint8_t num) { - if (num > 3) - return 0; - i2cdevReadByte(I2Cx, devAddr, MPU6500_RA_I2C_SLV0_ADDR + num * 3, buffer); + // if (num > 3) + // return 0; + // i2cdevReadByte(I2Cx, devAddr, MPU6500_RA_I2C_SLV0_ADDR + num * 3, buffer); return buffer[0]; } /** Set the I2C address of the specified slave (0-3). @@ -1045,9 +1047,9 @@ uint8_t mpu6500GetSlaveAddress(uint8_t num) */ void mpu6500SetSlaveAddress(uint8_t num, uint8_t address) { - if (num > 3) - return; - i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_I2C_SLV0_ADDR + num * 3, address); + // if (num > 3) + // return; + // i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_I2C_SLV0_ADDR + num * 3, address); } /** Get the active internal register for the specified slave (0-3). * Read/write operations for this slave will be done to whatever internal @@ -1062,9 +1064,9 @@ void mpu6500SetSlaveAddress(uint8_t num, uint8_t address) */ uint8_t mpu6500GetSlaveRegister(uint8_t num) { - if (num > 3) - return 0; - i2cdevReadByte(I2Cx, devAddr, MPU6500_RA_I2C_SLV0_REG + num * 3, buffer); + // if (num > 3) + // return 0; + // i2cdevReadByte(I2Cx, devAddr, MPU6500_RA_I2C_SLV0_REG + num * 3, buffer); return buffer[0]; } /** Set the active internal register for the specified slave (0-3). @@ -1075,9 +1077,9 @@ uint8_t mpu6500GetSlaveRegister(uint8_t num) */ void mpu6500SetSlaveRegister(uint8_t num, uint8_t reg) { - if (num > 3) - return; - i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_I2C_SLV0_REG + num * 3, reg); + // if (num > 3) + // return; + // i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_I2C_SLV0_REG + num * 3, reg); } /** Get the enabled value for the specified slave (0-3). * When set to 1, this bit enables Slave 0 for data transfer operations. When @@ -1088,9 +1090,9 @@ void mpu6500SetSlaveRegister(uint8_t num, uint8_t reg) */ bool mpu6500GetSlaveEnabled(uint8_t num) { - if (num > 3) - return 0; - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_I2C_SLV0_CTRL + num * 3, MPU6500_I2C_SLV_EN_BIT, buffer); + // if (num > 3) + // return 0; + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_I2C_SLV0_CTRL + num * 3, MPU6500_I2C_SLV_EN_BIT, buffer); return buffer[0]; } /** Set the enabled value for the specified slave (0-3). @@ -1101,10 +1103,10 @@ bool mpu6500GetSlaveEnabled(uint8_t num) */ void mpu6500SetSlaveEnabled(uint8_t num, bool enabled) { - if (num > 3) - return; - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_I2C_SLV0_CTRL + num * 3, MPU6500_I2C_SLV_EN_BIT, - enabled); + // if (num > 3) + // return; + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_I2C_SLV0_CTRL + num * 3, MPU6500_I2C_SLV_EN_BIT, + // enabled); } /** Get word pair byte-swapping enabled for the specified slave (0-3). * When set to 1, this bit enables byte swapping. When byte swapping is enabled, @@ -1119,10 +1121,10 @@ void mpu6500SetSlaveEnabled(uint8_t num, bool enabled) */ bool mpu6500GetSlaveWordByteSwap(uint8_t num) { - if (num > 3) - return 0; - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_I2C_SLV0_CTRL + num * 3, MPU6500_I2C_SLV_BYTE_SW_BIT, - buffer); + // if (num > 3) + // return 0; + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_I2C_SLV0_CTRL + num * 3, MPU6500_I2C_SLV_BYTE_SW_BIT, + // buffer); return buffer[0]; } /** Set word pair byte-swapping enabled for the specified slave (0-3). @@ -1133,10 +1135,10 @@ bool mpu6500GetSlaveWordByteSwap(uint8_t num) */ void mpu6500SetSlaveWordByteSwap(uint8_t num, bool enabled) { - if (num > 3) - return; - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_I2C_SLV0_CTRL + num * 3, MPU6500_I2C_SLV_BYTE_SW_BIT, - enabled); + // if (num > 3) + // return; + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_I2C_SLV0_CTRL + num * 3, MPU6500_I2C_SLV_BYTE_SW_BIT, + // enabled); } /** Get write mode for the specified slave (0-3). * When set to 1, the transaction will read or write data only. When cleared to @@ -1150,10 +1152,10 @@ void mpu6500SetSlaveWordByteSwap(uint8_t num, bool enabled) */ bool mpu6500GetSlaveWriteMode(uint8_t num) { - if (num > 3) - return 0; - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_I2C_SLV0_CTRL + num * 3, MPU6500_I2C_SLV_REG_DIS_BIT, - buffer); + // if (num > 3) + // return 0; + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_I2C_SLV0_CTRL + num * 3, MPU6500_I2C_SLV_REG_DIS_BIT, + // buffer); return buffer[0]; } /** Set write mode for the specified slave (0-3). @@ -1164,10 +1166,10 @@ bool mpu6500GetSlaveWriteMode(uint8_t num) */ void mpu6500SetSlaveWriteMode(uint8_t num, bool mode) { - if (num > 3) - return; - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_I2C_SLV0_CTRL + num * 3, MPU6500_I2C_SLV_REG_DIS_BIT, - mode); + // if (num > 3) + // return; + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_I2C_SLV0_CTRL + num * 3, MPU6500_I2C_SLV_REG_DIS_BIT, + // mode); } /** Get word pair grouping order offset for the specified slave (0-3). * This sets specifies the grouping order of word pairs received from registers. @@ -1182,9 +1184,9 @@ void mpu6500SetSlaveWriteMode(uint8_t num, bool mode) */ bool mpu6500GetSlaveWordGroupOffset(uint8_t num) { - if (num > 3) - return 0; - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_I2C_SLV0_CTRL + num * 3, MPU6500_I2C_SLV_GRP_BIT, buffer); + // if (num > 3) + // return 0; + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_I2C_SLV0_CTRL + num * 3, MPU6500_I2C_SLV_GRP_BIT, buffer); return buffer[0]; } /** Set word pair grouping order offset for the specified slave (0-3). @@ -1195,10 +1197,10 @@ bool mpu6500GetSlaveWordGroupOffset(uint8_t num) */ void mpu6500SetSlaveWordGroupOffset(uint8_t num, bool enabled) { - if (num > 3) - return; - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_I2C_SLV0_CTRL + num * 3, MPU6500_I2C_SLV_GRP_BIT, - enabled); + // if (num > 3) + // return; + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_I2C_SLV0_CTRL + num * 3, MPU6500_I2C_SLV_GRP_BIT, + // enabled); } /** Get number of bytes to read for the specified slave (0-3). * Specifies the number of bytes transferred to and from Slave 0. Clearing this @@ -1209,10 +1211,10 @@ void mpu6500SetSlaveWordGroupOffset(uint8_t num, bool enabled) */ uint8_t mpu6500GetSlaveDataLength(uint8_t num) { - if (num > 3) - return 0; - i2cdevReadBits(I2Cx, devAddr, MPU6500_RA_I2C_SLV0_CTRL + num * 3, MPU6500_I2C_SLV_LEN_BIT, - MPU6500_I2C_SLV_LEN_LENGTH, buffer); + // if (num > 3) + // return 0; + // i2cdevReadBits(I2Cx, devAddr, MPU6500_RA_I2C_SLV0_CTRL + num * 3, MPU6500_I2C_SLV_LEN_BIT, + // MPU6500_I2C_SLV_LEN_LENGTH, buffer); return buffer[0]; } /** Set number of bytes to read for the specified slave (0-3). @@ -1223,10 +1225,10 @@ uint8_t mpu6500GetSlaveDataLength(uint8_t num) */ void mpu6500SetSlaveDataLength(uint8_t num, uint8_t length) { - if (num > 3) - return; - i2cdevWriteBits(I2Cx, devAddr, MPU6500_RA_I2C_SLV0_CTRL + num * 3, MPU6500_I2C_SLV_LEN_BIT, - MPU6500_I2C_SLV_LEN_LENGTH, length); + // if (num > 3) + // return; + // i2cdevWriteBits(I2Cx, devAddr, MPU6500_RA_I2C_SLV0_CTRL + num * 3, MPU6500_I2C_SLV_LEN_BIT, + // MPU6500_I2C_SLV_LEN_LENGTH, length); } // I2C_SLV* registers (Slave 4) @@ -1242,7 +1244,7 @@ void mpu6500SetSlaveDataLength(uint8_t num, uint8_t length) */ uint8_t mpu6500GetSlave4Address() { - i2cdevReadByte(I2Cx, devAddr, MPU6500_RA_I2C_SLV4_ADDR, buffer); + // i2cdevReadByte(I2Cx, devAddr, MPU6500_RA_I2C_SLV4_ADDR, buffer); return buffer[0]; } /** Set the I2C address of Slave 4. @@ -1252,7 +1254,7 @@ uint8_t mpu6500GetSlave4Address() */ void mpu6500SetSlave4Address(uint8_t address) { - i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_I2C_SLV4_ADDR, address); + // i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_I2C_SLV4_ADDR, address); } /** Get the active internal register for the Slave 4. * Read/write operations for this slave will be done to whatever internal @@ -1263,7 +1265,7 @@ void mpu6500SetSlave4Address(uint8_t address) */ uint8_t mpu6500GetSlave4Register() { - i2cdevReadByte(I2Cx, devAddr, MPU6500_RA_I2C_SLV4_REG, buffer); + // i2cdevReadByte(I2Cx, devAddr, MPU6500_RA_I2C_SLV4_REG, buffer); return buffer[0]; } /** Set the active internal register for Slave 4. @@ -1273,7 +1275,7 @@ uint8_t mpu6500GetSlave4Register() */ void mpu6500SetSlave4Register(uint8_t reg) { - i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_I2C_SLV4_REG, reg); + // i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_I2C_SLV4_REG, reg); } /** Set new byte to write to Slave 4. * This register stores the data to be written into the Slave 4. If I2C_SLV4_RW @@ -1283,7 +1285,7 @@ void mpu6500SetSlave4Register(uint8_t reg) */ void mpu6500SetSlave4OutputByte(uint8_t data) { - i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_I2C_SLV4_DO, data); + // i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_I2C_SLV4_DO, data); } /** Get the enabled value for the Slave 4. * When set to 1, this bit enables Slave 4 for data transfer operations. When @@ -1293,7 +1295,7 @@ void mpu6500SetSlave4OutputByte(uint8_t data) */ bool mpu6500GetSlave4Enabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_I2C_SLV4_CTRL, MPU6500_I2C_SLV4_EN_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_I2C_SLV4_CTRL, MPU6500_I2C_SLV4_EN_BIT, buffer); return buffer[0]; } /** Set the enabled value for Slave 4. @@ -1303,7 +1305,7 @@ bool mpu6500GetSlave4Enabled() */ void mpu6500SetSlave4Enabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_I2C_SLV4_CTRL, MPU6500_I2C_SLV4_EN_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_I2C_SLV4_CTRL, MPU6500_I2C_SLV4_EN_BIT, enabled); } /** Get the enabled value for Slave 4 transaction interrupts. * When set to 1, this bit enables the generation of an interrupt signal upon @@ -1316,7 +1318,7 @@ void mpu6500SetSlave4Enabled(bool enabled) */ bool mpu6500GetSlave4InterruptEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_I2C_SLV4_CTRL, MPU6500_I2C_SLV4_INT_EN_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_I2C_SLV4_CTRL, MPU6500_I2C_SLV4_INT_EN_BIT, buffer); return buffer[0]; } /** Set the enabled value for Slave 4 transaction interrupts. @@ -1326,7 +1328,7 @@ bool mpu6500GetSlave4InterruptEnabled() */ void mpu6500SetSlave4InterruptEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_I2C_SLV4_CTRL, MPU6500_I2C_SLV4_INT_EN_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_I2C_SLV4_CTRL, MPU6500_I2C_SLV4_INT_EN_BIT, enabled); } /** Get write mode for Slave 4. * When set to 1, the transaction will read or write data only. When cleared to @@ -1339,7 +1341,7 @@ void mpu6500SetSlave4InterruptEnabled(bool enabled) */ bool mpu6500GetSlave4WriteMode() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_I2C_SLV4_CTRL, MPU6500_I2C_SLV4_REG_DIS_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_I2C_SLV4_CTRL, MPU6500_I2C_SLV4_REG_DIS_BIT, buffer); return buffer[0]; } /** Set write mode for the Slave 4. @@ -1349,7 +1351,7 @@ bool mpu6500GetSlave4WriteMode() */ void mpu6500SetSlave4WriteMode(bool mode) { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_I2C_SLV4_CTRL, MPU6500_I2C_SLV4_REG_DIS_BIT, mode); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_I2C_SLV4_CTRL, MPU6500_I2C_SLV4_REG_DIS_BIT, mode); } /** Get Slave 4 master delay value. * This configures the reduced access rate of I2C slaves relative to the Sample @@ -1368,8 +1370,8 @@ void mpu6500SetSlave4WriteMode(bool mode) */ uint8_t mpu6500GetSlave4MasterDelay() { - i2cdevReadBits(I2Cx, devAddr, MPU6500_RA_I2C_SLV4_CTRL, MPU6500_I2C_SLV4_MST_DLY_BIT, - MPU6500_I2C_SLV4_MST_DLY_LENGTH, buffer); + // i2cdevReadBits(I2Cx, devAddr, MPU6500_RA_I2C_SLV4_CTRL, MPU6500_I2C_SLV4_MST_DLY_BIT, + // MPU6500_I2C_SLV4_MST_DLY_LENGTH, buffer); return buffer[0]; } /** Set Slave 4 master delay value. @@ -1379,8 +1381,8 @@ uint8_t mpu6500GetSlave4MasterDelay() */ void mpu6500SetSlave4MasterDelay(uint8_t delay) { - i2cdevWriteBits(I2Cx, devAddr, MPU6500_RA_I2C_SLV4_CTRL, MPU6500_I2C_SLV4_MST_DLY_BIT, - MPU6500_I2C_SLV4_MST_DLY_LENGTH, delay); + // i2cdevWriteBits(I2Cx, devAddr, MPU6500_RA_I2C_SLV4_CTRL, MPU6500_I2C_SLV4_MST_DLY_BIT, + // MPU6500_I2C_SLV4_MST_DLY_LENGTH, delay); } /** Get last available byte read from Slave 4. * This register stores the data read from Slave 4. This field is populated @@ -1390,7 +1392,7 @@ void mpu6500SetSlave4MasterDelay(uint8_t delay) */ uint8_t mpu6500GetSlate4InputByte() { - i2cdevReadByte(I2Cx, devAddr, MPU6500_RA_I2C_SLV4_DI, buffer); + // i2cdevReadByte(I2Cx, devAddr, MPU6500_RA_I2C_SLV4_DI, buffer); return buffer[0]; } @@ -1407,7 +1409,7 @@ uint8_t mpu6500GetSlate4InputByte() */ bool mpu6500GetPassthroughStatus() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_I2C_MST_STATUS, MPU6500_MST_PASS_THROUGH_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_I2C_MST_STATUS, MPU6500_MST_PASS_THROUGH_BIT, buffer); return buffer[0]; } /** Get Slave 4 transaction done status. @@ -1420,7 +1422,7 @@ bool mpu6500GetPassthroughStatus() */ bool mpu6500GetSlave4IsDone() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_I2C_MST_STATUS, MPU6500_MST_I2C_SLV4_DONE_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_I2C_MST_STATUS, MPU6500_MST_I2C_SLV4_DONE_BIT, buffer); return buffer[0]; } /** Get master arbitration lost status. @@ -1432,7 +1434,7 @@ bool mpu6500GetSlave4IsDone() */ bool mpu6500GetLostArbitration() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_I2C_MST_STATUS, MPU6500_MST_I2C_LOST_ARB_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_I2C_MST_STATUS, MPU6500_MST_I2C_LOST_ARB_BIT, buffer); return buffer[0]; } /** Get Slave 4 NACK status. @@ -1444,7 +1446,7 @@ bool mpu6500GetLostArbitration() */ bool mpu6500GetSlave4Nack() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_I2C_MST_STATUS, MPU6500_MST_I2C_SLV4_NACK_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_I2C_MST_STATUS, MPU6500_MST_I2C_SLV4_NACK_BIT, buffer); return buffer[0]; } /** Get Slave 3 NACK status. @@ -1456,7 +1458,7 @@ bool mpu6500GetSlave4Nack() */ bool mpu6500GetSlave3Nack() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_I2C_MST_STATUS, MPU6500_MST_I2C_SLV3_NACK_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_I2C_MST_STATUS, MPU6500_MST_I2C_SLV3_NACK_BIT, buffer); return buffer[0]; } /** Get Slave 2 NACK status. @@ -1468,7 +1470,7 @@ bool mpu6500GetSlave3Nack() */ bool mpu6500GetSlave2Nack() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_I2C_MST_STATUS, MPU6500_MST_I2C_SLV2_NACK_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_I2C_MST_STATUS, MPU6500_MST_I2C_SLV2_NACK_BIT, buffer); return buffer[0]; } /** Get Slave 1 NACK status. @@ -1480,7 +1482,7 @@ bool mpu6500GetSlave2Nack() */ bool mpu6500GetSlave1Nack() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_I2C_MST_STATUS, MPU6500_MST_I2C_SLV1_NACK_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_I2C_MST_STATUS, MPU6500_MST_I2C_SLV1_NACK_BIT, buffer); return buffer[0]; } /** Get Slave 0 NACK status. @@ -1492,7 +1494,7 @@ bool mpu6500GetSlave1Nack() */ bool mpu6500GetSlave0Nack() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_I2C_MST_STATUS, MPU6500_MST_I2C_SLV0_NACK_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_I2C_MST_STATUS, MPU6500_MST_I2C_SLV0_NACK_BIT, buffer); return buffer[0]; } @@ -1506,7 +1508,7 @@ bool mpu6500GetSlave0Nack() */ bool mpu6500GetInterruptMode() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_INT_PIN_CFG, MPU6500_INTCFG_INT_LEVEL_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_INT_PIN_CFG, MPU6500_INTCFG_INT_LEVEL_BIT, buffer); return buffer[0]; } /** Set interrupt logic level mode. @@ -1517,7 +1519,7 @@ bool mpu6500GetInterruptMode() */ void mpu6500SetInterruptMode(bool mode) { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_INT_PIN_CFG, MPU6500_INTCFG_INT_LEVEL_BIT, mode); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_INT_PIN_CFG, MPU6500_INTCFG_INT_LEVEL_BIT, mode); } /** Get interrupt drive mode. * Will be set 0 for push-pull, 1 for open-drain. @@ -1527,7 +1529,7 @@ void mpu6500SetInterruptMode(bool mode) */ bool mpu6500GetInterruptDrive() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_INT_PIN_CFG, MPU6500_INTCFG_INT_OPEN_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_INT_PIN_CFG, MPU6500_INTCFG_INT_OPEN_BIT, buffer); return buffer[0]; } /** Set interrupt drive mode. @@ -1538,7 +1540,7 @@ bool mpu6500GetInterruptDrive() */ void mpu6500SetInterruptDrive(bool drive) { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_INT_PIN_CFG, MPU6500_INTCFG_INT_OPEN_BIT, drive); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_INT_PIN_CFG, MPU6500_INTCFG_INT_OPEN_BIT, drive); } /** Get interrupt latch mode. * Will be set 0 for 50us-pulse, 1 for latch-until-int-cleared. @@ -1548,7 +1550,7 @@ void mpu6500SetInterruptDrive(bool drive) */ bool mpu6500GetInterruptLatch() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_INT_PIN_CFG, MPU6500_INTCFG_LATCH_INT_EN_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_INT_PIN_CFG, MPU6500_INTCFG_LATCH_INT_EN_BIT, buffer); return buffer[0]; } /** Set interrupt latch mode. @@ -1559,7 +1561,7 @@ bool mpu6500GetInterruptLatch() */ void mpu6500SetInterruptLatch(bool latch) { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_INT_PIN_CFG, MPU6500_INTCFG_LATCH_INT_EN_BIT, latch); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_INT_PIN_CFG, MPU6500_INTCFG_LATCH_INT_EN_BIT, latch); } /** Get interrupt latch clear mode. * Will be set 0 for status-read-only, 1 for any-register-read. @@ -1569,7 +1571,7 @@ void mpu6500SetInterruptLatch(bool latch) */ bool mpu6500GetInterruptLatchClear() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_INT_PIN_CFG, MPU6500_INTCFG_INT_RD_CLEAR_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_INT_PIN_CFG, MPU6500_INTCFG_INT_RD_CLEAR_BIT, buffer); return buffer[0]; } /** Set interrupt latch clear mode. @@ -1580,7 +1582,7 @@ bool mpu6500GetInterruptLatchClear() */ void mpu6500SetInterruptLatchClear(bool clear) { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_INT_PIN_CFG, MPU6500_INTCFG_INT_RD_CLEAR_BIT, clear); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_INT_PIN_CFG, MPU6500_INTCFG_INT_RD_CLEAR_BIT, clear); } /** Get FSYNC interrupt logic level mode. * @return Current FSYNC interrupt mode (0=active-high, 1=active-low) @@ -1590,7 +1592,7 @@ void mpu6500SetInterruptLatchClear(bool clear) */ bool mpu6500GetFSyncInterruptLevel() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_INT_PIN_CFG, MPU6500_INTCFG_FSYNC_INT_LEVEL_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_INT_PIN_CFG, MPU6500_INTCFG_FSYNC_INT_LEVEL_BIT, buffer); return buffer[0]; } /** Set FSYNC interrupt logic level mode. @@ -1601,7 +1603,7 @@ bool mpu6500GetFSyncInterruptLevel() */ void mpu6500SetFSyncInterruptLevel(bool level) { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_INT_PIN_CFG, MPU6500_INTCFG_FSYNC_INT_LEVEL_BIT, level); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_INT_PIN_CFG, MPU6500_INTCFG_FSYNC_INT_LEVEL_BIT, level); } /** Get FSYNC pin interrupt enabled setting. * Will be set 0 for disabled, 1 for enabled. @@ -1611,7 +1613,7 @@ void mpu6500SetFSyncInterruptLevel(bool level) */ bool mpu6500GetFSyncInterruptEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_INT_PIN_CFG, MPU6500_INTCFG_FSYNC_INT_EN_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_INT_PIN_CFG, MPU6500_INTCFG_FSYNC_INT_EN_BIT, buffer); return buffer[0]; } /** Set FSYNC pin interrupt enabled setting. @@ -1622,7 +1624,7 @@ bool mpu6500GetFSyncInterruptEnabled() */ void mpu6500SetFSyncInterruptEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_INT_PIN_CFG, MPU6500_INTCFG_FSYNC_INT_EN_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_INT_PIN_CFG, MPU6500_INTCFG_FSYNC_INT_EN_BIT, enabled); } /** Get I2C bypass enabled status. * When this bit is equal to 1 and I2C_MST_EN (Register 106 bit[5]) is equal to @@ -1637,7 +1639,7 @@ void mpu6500SetFSyncInterruptEnabled(bool enabled) */ bool mpu6500GetI2CBypassEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_INT_PIN_CFG, MPU6500_INTCFG_I2C_BYPASS_EN_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_INT_PIN_CFG, MPU6500_INTCFG_I2C_BYPASS_EN_BIT, buffer); return buffer[0]; } /** Set I2C bypass enabled status. @@ -1653,7 +1655,7 @@ bool mpu6500GetI2CBypassEnabled() */ void mpu6500SetI2CBypassEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_INT_PIN_CFG, MPU6500_INTCFG_I2C_BYPASS_EN_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_INT_PIN_CFG, MPU6500_INTCFG_I2C_BYPASS_EN_BIT, enabled); } /** Get reference clock output enabled status. * When this bit is equal to 1, a reference clock output is provided at the @@ -1666,7 +1668,7 @@ void mpu6500SetI2CBypassEnabled(bool enabled) */ bool mpu6500GetClockOutputEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_INT_PIN_CFG, MPU6500_INTCFG_CLKOUT_EN_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_INT_PIN_CFG, MPU6500_INTCFG_CLKOUT_EN_BIT, buffer); return buffer[0]; } /** Set reference clock output enabled status. @@ -1680,7 +1682,7 @@ bool mpu6500GetClockOutputEnabled() */ void mpu6500SetClockOutputEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_INT_PIN_CFG, MPU6500_INTCFG_CLKOUT_EN_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_INT_PIN_CFG, MPU6500_INTCFG_CLKOUT_EN_BIT, enabled); } // INT_ENABLE register @@ -1694,7 +1696,7 @@ void mpu6500SetClockOutputEnabled(bool enabled) **/ uint8_t mpu6500GetIntEnabled() { - i2cdevReadByte(I2Cx, devAddr, MPU6500_RA_INT_ENABLE, buffer); + // i2cdevReadByte(I2Cx, devAddr, MPU6500_RA_INT_ENABLE, buffer); return buffer[0]; } /** Set full interrupt enabled status. @@ -1707,7 +1709,7 @@ uint8_t mpu6500GetIntEnabled() **/ void mpu6500SetIntEnabled(uint8_t enabled) { - i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_INT_ENABLE, enabled); + // i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_INT_ENABLE, enabled); } /** Get Free Fall interrupt enabled status. * Will be set 0 for disabled, 1 for enabled. @@ -1717,7 +1719,7 @@ void mpu6500SetIntEnabled(uint8_t enabled) **/ bool mpu6500GetIntFreefallEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_INT_ENABLE, MPU6500_INTERRUPT_FF_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_INT_ENABLE, MPU6500_INTERRUPT_FF_BIT, buffer); return buffer[0]; } /** Set Free Fall interrupt enabled status. @@ -1738,7 +1740,7 @@ void mpu6500SetIntFreefallEnabled(bool enabled) **/ bool mpu6500GetIntMotionEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_INT_ENABLE, MPU6500_INTERRUPT_MOT_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_INT_ENABLE, MPU6500_INTERRUPT_MOT_BIT, buffer); return buffer[0]; } /** Set Motion Detection interrupt enabled status. @@ -1749,7 +1751,7 @@ bool mpu6500GetIntMotionEnabled() **/ void mpu6500SetIntMotionEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_INT_ENABLE, MPU6500_INTERRUPT_MOT_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_INT_ENABLE, MPU6500_INTERRUPT_MOT_BIT, enabled); } /** Get Zero Motion Detection interrupt enabled status. * Will be set 0 for disabled, 1 for enabled. @@ -1759,7 +1761,7 @@ void mpu6500SetIntMotionEnabled(bool enabled) **/ bool mpu6500GetIntZeroMotionEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_INT_ENABLE, MPU6500_INTERRUPT_ZMOT_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_INT_ENABLE, MPU6500_INTERRUPT_ZMOT_BIT, buffer); return buffer[0]; } /** Set Zero Motion Detection interrupt enabled status. @@ -1770,7 +1772,7 @@ bool mpu6500GetIntZeroMotionEnabled() **/ void mpu6500SetIntZeroMotionEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_INT_ENABLE, MPU6500_INTERRUPT_ZMOT_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_INT_ENABLE, MPU6500_INTERRUPT_ZMOT_BIT, enabled); } /** Get FIFO Buffer Overflow interrupt enabled status. * Will be set 0 for disabled, 1 for enabled. @@ -1780,7 +1782,7 @@ void mpu6500SetIntZeroMotionEnabled(bool enabled) **/ bool mpu6500GetIntFIFOBufferOverflowEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_INT_ENABLE, MPU6500_INTERRUPT_FIFO_OFLOW_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_INT_ENABLE, MPU6500_INTERRUPT_FIFO_OFLOW_BIT, buffer); return buffer[0]; } /** Set FIFO Buffer Overflow interrupt enabled status. @@ -1791,7 +1793,7 @@ bool mpu6500GetIntFIFOBufferOverflowEnabled() **/ void mpu6500SetIntFIFOBufferOverflowEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_INT_ENABLE, MPU6500_INTERRUPT_FIFO_OFLOW_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_INT_ENABLE, MPU6500_INTERRUPT_FIFO_OFLOW_BIT, enabled); } /** Get I2C Master interrupt enabled status. * This enables any of the I2C Master interrupt sources to generate an @@ -1802,7 +1804,7 @@ void mpu6500SetIntFIFOBufferOverflowEnabled(bool enabled) **/ bool mpu6500GetIntI2CMasterEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_INT_ENABLE, MPU6500_INTERRUPT_I2C_MST_INT_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_INT_ENABLE, MPU6500_INTERRUPT_I2C_MST_INT_BIT, buffer); return buffer[0]; } /** Set I2C Master interrupt enabled status. @@ -1813,7 +1815,7 @@ bool mpu6500GetIntI2CMasterEnabled() **/ void mpu6500SetIntI2CMasterEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_INT_ENABLE, MPU6500_INTERRUPT_I2C_MST_INT_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_INT_ENABLE, MPU6500_INTERRUPT_I2C_MST_INT_BIT, enabled); } /** Get Data Ready interrupt enabled setting. * This event occurs each time a write operation to all of the sensor registers @@ -1824,7 +1826,7 @@ void mpu6500SetIntI2CMasterEnabled(bool enabled) */ bool mpu6500GetIntDataReadyEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_INT_ENABLE, MPU6500_INTERRUPT_DATA_RDY_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_INT_ENABLE, MPU6500_INTERRUPT_DATA_RDY_BIT, buffer); return buffer[0]; } /** Set Data Ready interrupt enabled status. @@ -1835,7 +1837,7 @@ bool mpu6500GetIntDataReadyEnabled() */ void mpu6500SetIntDataReadyEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_INT_ENABLE, MPU6500_INTERRUPT_DATA_RDY_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_INT_ENABLE, MPU6500_INTERRUPT_DATA_RDY_BIT, enabled); } // INT_STATUS register @@ -1849,7 +1851,7 @@ void mpu6500SetIntDataReadyEnabled(bool enabled) */ uint8_t mpu6500GetIntStatus() { - i2cdevReadByte(I2Cx, devAddr, MPU6500_RA_INT_STATUS, buffer); + // i2cdevReadByte(I2Cx, devAddr, MPU6500_RA_INT_STATUS, buffer); return buffer[0]; } /** Get Free Fall interrupt status. @@ -1861,7 +1863,7 @@ uint8_t mpu6500GetIntStatus() */ bool mpu6500GetIntFreefallStatus() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_INT_STATUS, MPU6500_INTERRUPT_FF_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_INT_STATUS, MPU6500_INTERRUPT_FF_BIT, buffer); return buffer[0]; } /** Get Motion Detection interrupt status. @@ -1873,7 +1875,7 @@ bool mpu6500GetIntFreefallStatus() */ bool mpu6500GetIntMotionStatus() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_INT_STATUS, MPU6500_INTERRUPT_MOT_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_INT_STATUS, MPU6500_INTERRUPT_MOT_BIT, buffer); return buffer[0]; } /** Get Zero Motion Detection interrupt status. @@ -1885,7 +1887,7 @@ bool mpu6500GetIntMotionStatus() */ bool mpu6500GetIntZeroMotionStatus() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_INT_STATUS, MPU6500_INTERRUPT_ZMOT_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_INT_STATUS, MPU6500_INTERRUPT_ZMOT_BIT, buffer); return buffer[0]; } /** Get FIFO Buffer Overflow interrupt status. @@ -1897,7 +1899,7 @@ bool mpu6500GetIntZeroMotionStatus() */ bool mpu6500GetIntFIFOBufferOverflowStatus() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_INT_STATUS, MPU6500_INTERRUPT_FIFO_OFLOW_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_INT_STATUS, MPU6500_INTERRUPT_FIFO_OFLOW_BIT, buffer); return buffer[0]; } /** Get I2C Master interrupt status. @@ -1910,7 +1912,7 @@ bool mpu6500GetIntFIFOBufferOverflowStatus() */ bool mpu6500GetIntI2CMasterStatus() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_INT_STATUS, MPU6500_INTERRUPT_I2C_MST_INT_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_INT_STATUS, MPU6500_INTERRUPT_I2C_MST_INT_BIT, buffer); return buffer[0]; } /** Get Data Ready interrupt status. @@ -1922,7 +1924,7 @@ bool mpu6500GetIntI2CMasterStatus() */ bool mpu6500GetIntDataReadyStatus() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_INT_STATUS, MPU6500_INTERRUPT_DATA_RDY_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_INT_STATUS, MPU6500_INTERRUPT_DATA_RDY_BIT, buffer); return buffer[0]; } @@ -1964,13 +1966,13 @@ void mpu6500GetMotion9(int16_t* ax, int16_t* ay, int16_t* az, int16_t* gx, int16 */ void mpu6500GetMotion6(int16_t* ax, int16_t* ay, int16_t* az, int16_t* gx, int16_t* gy, int16_t* gz) { - i2cdevReadReg8(I2Cx, devAddr, MPU6500_RA_ACCEL_XOUT_H, 14, buffer); - *ax = (((int16_t) buffer[0]) << 8) | buffer[1]; - *ay = (((int16_t) buffer[2]) << 8) | buffer[3]; - *az = (((int16_t) buffer[4]) << 8) | buffer[5]; - *gx = (((int16_t) buffer[8]) << 8) | buffer[9]; - *gy = (((int16_t) buffer[10]) << 8) | buffer[11]; - *gz = (((int16_t) buffer[12]) << 8) | buffer[13]; + // i2cdevReadReg8(I2Cx, devAddr, MPU6500_RA_ACCEL_XOUT_H, 14, buffer); + // *ax = (((int16_t) buffer[0]) << 8) | buffer[1]; + // *ay = (((int16_t) buffer[2]) << 8) | buffer[3]; + // *az = (((int16_t) buffer[4]) << 8) | buffer[5]; + // *gx = (((int16_t) buffer[8]) << 8) | buffer[9]; + // *gy = (((int16_t) buffer[10]) << 8) | buffer[11]; + // *gz = (((int16_t) buffer[12]) << 8) | buffer[13]; } /** Get 3-axis accelerometer readings. * These registers store the most recent accelerometer measurements. @@ -2010,10 +2012,10 @@ void mpu6500GetMotion6(int16_t* ax, int16_t* ay, int16_t* az, int16_t* gx, int16 */ void mpu6500GetAcceleration(int16_t* x, int16_t* y, int16_t* z) { - i2cdevReadReg8(I2Cx, devAddr, MPU6500_RA_ACCEL_XOUT_H, 6, buffer); - *x = (((int16_t) buffer[0]) << 8) | buffer[1]; - *y = (((int16_t) buffer[2]) << 8) | buffer[3]; - *z = (((int16_t) buffer[4]) << 8) | buffer[5]; + // i2cdevReadReg8(I2Cx, devAddr, MPU6500_RA_ACCEL_XOUT_H, 6, buffer); + // *x = (((int16_t) buffer[0]) << 8) | buffer[1]; + // *y = (((int16_t) buffer[2]) << 8) | buffer[3]; + // *z = (((int16_t) buffer[4]) << 8) | buffer[5]; } /** Get X-axis accelerometer reading. * @return X-axis acceleration measurement in 16-bit 2's complement format @@ -2022,7 +2024,7 @@ void mpu6500GetAcceleration(int16_t* x, int16_t* y, int16_t* z) */ int16_t mpu6500GetAccelerationX() { - i2cdevReadReg8(I2Cx, devAddr, MPU6500_RA_ACCEL_XOUT_H, 2, buffer); + // i2cdevReadReg8(I2Cx, devAddr, MPU6500_RA_ACCEL_XOUT_H, 2, buffer); return (((int16_t) buffer[0]) << 8) | buffer[1]; } /** Get Y-axis accelerometer reading. @@ -2032,7 +2034,7 @@ int16_t mpu6500GetAccelerationX() */ int16_t mpu6500GetAccelerationY() { - i2cdevReadReg8(I2Cx, devAddr, MPU6500_RA_ACCEL_YOUT_H, 2, buffer); + // i2cdevReadReg8(I2Cx, devAddr, MPU6500_RA_ACCEL_YOUT_H, 2, buffer); return (((int16_t) buffer[0]) << 8) | buffer[1]; } /** Get Z-axis accelerometer reading. @@ -2042,7 +2044,7 @@ int16_t mpu6500GetAccelerationY() */ int16_t mpu6500GetAccelerationZ() { - i2cdevReadReg8(I2Cx, devAddr, MPU6500_RA_ACCEL_ZOUT_H, 2, buffer); + // i2cdevReadReg8(I2Cx, devAddr, MPU6500_RA_ACCEL_ZOUT_H, 2, buffer); return (((int16_t) buffer[0]) << 8) | buffer[1]; } @@ -2054,7 +2056,7 @@ int16_t mpu6500GetAccelerationZ() */ int16_t mpu6500GetTemperature() { - i2cdevReadReg8(I2Cx, devAddr, MPU6500_RA_TEMP_OUT_H, 2, buffer); + // i2cdevReadReg8(I2Cx, devAddr, MPU6500_RA_TEMP_OUT_H, 2, buffer); return (((int16_t) buffer[0]) << 8) | buffer[1]; } @@ -2094,10 +2096,10 @@ int16_t mpu6500GetTemperature() */ void mpu6500GetRotation(int16_t* x, int16_t* y, int16_t* z) { - i2cdevReadReg8(I2Cx, devAddr, MPU6500_RA_GYRO_XOUT_H, 6, buffer); - *x = (((int16_t) buffer[0]) << 8) | buffer[1]; - *y = (((int16_t) buffer[2]) << 8) | buffer[3]; - *z = (((int16_t) buffer[4]) << 8) | buffer[5]; + // i2cdevReadReg8(I2Cx, devAddr, MPU6500_RA_GYRO_XOUT_H, 6, buffer); + // *x = (((int16_t) buffer[0]) << 8) | buffer[1]; + // *y = (((int16_t) buffer[2]) << 8) | buffer[3]; + // *z = (((int16_t) buffer[4]) << 8) | buffer[5]; } /** Get X-axis gyroscope reading. * @return X-axis rotation measurement in 16-bit 2's complement format @@ -2106,7 +2108,7 @@ void mpu6500GetRotation(int16_t* x, int16_t* y, int16_t* z) */ int16_t mpu6500GetRotationX() { - i2cdevReadReg8(I2Cx, devAddr, MPU6500_RA_GYRO_XOUT_H, 2, buffer); + // i2cdevReadReg8(I2Cx, devAddr, MPU6500_RA_GYRO_XOUT_H, 2, buffer); return (((int16_t) buffer[0]) << 8) | buffer[1]; } /** Get Y-axis gyroscope reading. @@ -2116,7 +2118,7 @@ int16_t mpu6500GetRotationX() */ int16_t mpu6500GetRotationY() { - i2cdevReadReg8(I2Cx, devAddr, MPU6500_RA_GYRO_YOUT_H, 2, buffer); + // i2cdevReadReg8(I2Cx, devAddr, MPU6500_RA_GYRO_YOUT_H, 2, buffer); return (((int16_t) buffer[0]) << 8) | buffer[1]; } /** Get Z-axis gyroscope reading. @@ -2126,7 +2128,7 @@ int16_t mpu6500GetRotationY() */ int16_t mpu6500GetRotationZ() { - i2cdevReadReg8(I2Cx, devAddr, MPU6500_RA_GYRO_ZOUT_H, 2, buffer); + // i2cdevReadReg8(I2Cx, devAddr, MPU6500_RA_GYRO_ZOUT_H, 2, buffer); return (((int16_t) buffer[0]) << 8) | buffer[1]; } @@ -2208,7 +2210,7 @@ int16_t mpu6500GetRotationZ() */ uint8_t mpu6500GetExternalSensorByte(int position) { - i2cdevReadByte(I2Cx, devAddr, MPU6500_RA_EXT_SENS_DATA_00 + position, buffer); + // i2cdevReadByte(I2Cx, devAddr, MPU6500_RA_EXT_SENS_DATA_00 + position, buffer); return buffer[0]; } /** Read word (2 bytes) from external sensor data registers. @@ -2218,7 +2220,7 @@ uint8_t mpu6500GetExternalSensorByte(int position) */ uint16_t mpu6500GetExternalSensorWord(int position) { - i2cdevReadReg8(I2Cx, devAddr, MPU6500_RA_EXT_SENS_DATA_00 + position, 2, buffer); + // i2cdevReadReg8(I2Cx, devAddr, MPU6500_RA_EXT_SENS_DATA_00 + position, 2, buffer); return (((uint16_t) buffer[0]) << 8) | buffer[1]; } /** Read double word (4 bytes) from external sensor data registers. @@ -2228,7 +2230,7 @@ uint16_t mpu6500GetExternalSensorWord(int position) */ uint32_t mpu6500GetExternalSensorDWord(int position) { - i2cdevReadReg8(I2Cx, devAddr, MPU6500_RA_EXT_SENS_DATA_00 + position, 4, buffer); + // i2cdevReadReg8(I2Cx, devAddr, MPU6500_RA_EXT_SENS_DATA_00 + position, 4, buffer); return (((uint32_t) buffer[0]) << 24) | (((uint32_t) buffer[1]) << 16) | (((uint16_t) buffer[2]) << 8) | buffer[3]; } @@ -2242,7 +2244,7 @@ uint32_t mpu6500GetExternalSensorDWord(int position) */ bool mpu6500GetXNegMotionDetected() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_MOT_DETECT_STATUS, MPU6500_MOTION_MOT_XNEG_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_MOT_DETECT_STATUS, MPU6500_MOTION_MOT_XNEG_BIT, buffer); return buffer[0]; } /** Get X-axis positive motion detection interrupt status. @@ -2252,7 +2254,7 @@ bool mpu6500GetXNegMotionDetected() */ bool mpu6500GetXPosMotionDetected() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_MOT_DETECT_STATUS, MPU6500_MOTION_MOT_XPOS_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_MOT_DETECT_STATUS, MPU6500_MOTION_MOT_XPOS_BIT, buffer); return buffer[0]; } /** Get Y-axis negative motion detection interrupt status. @@ -2262,7 +2264,7 @@ bool mpu6500GetXPosMotionDetected() */ bool mpu6500GetYNegMotionDetected() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_MOT_DETECT_STATUS, MPU6500_MOTION_MOT_YNEG_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_MOT_DETECT_STATUS, MPU6500_MOTION_MOT_YNEG_BIT, buffer); return buffer[0]; } /** Get Y-axis positive motion detection interrupt status. @@ -2272,7 +2274,7 @@ bool mpu6500GetYNegMotionDetected() */ bool mpu6500GetYPosMotionDetected() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_MOT_DETECT_STATUS, MPU6500_MOTION_MOT_YPOS_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_MOT_DETECT_STATUS, MPU6500_MOTION_MOT_YPOS_BIT, buffer); return buffer[0]; } /** Get Z-axis negative motion detection interrupt status. @@ -2282,7 +2284,7 @@ bool mpu6500GetYPosMotionDetected() */ bool mpu6500GetZNegMotionDetected() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_MOT_DETECT_STATUS, MPU6500_MOTION_MOT_ZNEG_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_MOT_DETECT_STATUS, MPU6500_MOTION_MOT_ZNEG_BIT, buffer); return buffer[0]; } /** Get Z-axis positive motion detection interrupt status. @@ -2292,7 +2294,7 @@ bool mpu6500GetZNegMotionDetected() */ bool mpu6500GetZPosMotionDetected() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_MOT_DETECT_STATUS, MPU6500_MOTION_MOT_ZPOS_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_MOT_DETECT_STATUS, MPU6500_MOTION_MOT_ZPOS_BIT, buffer); return buffer[0]; } /** Get zero motion detection interrupt status. @@ -2302,7 +2304,7 @@ bool mpu6500GetZPosMotionDetected() */ bool mpu6500GetZeroMotionDetected() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_MOT_DETECT_STATUS, MPU6500_MOTION_MOT_ZRMOT_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_MOT_DETECT_STATUS, MPU6500_MOTION_MOT_ZRMOT_BIT, buffer); return buffer[0]; } @@ -2318,9 +2320,9 @@ bool mpu6500GetZeroMotionDetected() */ void mpu6500SetSlaveOutputByte(uint8_t num, uint8_t data) { - if (num > 3) - return; - i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_I2C_SLV0_DO + num, data); + // if (num > 3) + // return; + // i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_I2C_SLV0_DO + num, data); } // I2C_MST_DELAY_CTRL register @@ -2335,8 +2337,8 @@ void mpu6500SetSlaveOutputByte(uint8_t num, uint8_t data) */ bool mpu6500GetExternalShadowDelayEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_I2C_MST_DELAY_CTRL, MPU6500_DELAYCTRL_DELAY_ES_SHADOW_BIT, - buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_I2C_MST_DELAY_CTRL, MPU6500_DELAYCTRL_DELAY_ES_SHADOW_BIT, + // buffer); return buffer[0]; } /** Set external data shadow delay enabled status. @@ -2347,8 +2349,8 @@ bool mpu6500GetExternalShadowDelayEnabled() */ void mpu6500SetExternalShadowDelayEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_I2C_MST_DELAY_CTRL, - MPU6500_DELAYCTRL_DELAY_ES_SHADOW_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_I2C_MST_DELAY_CTRL, + // MPU6500_DELAYCTRL_DELAY_ES_SHADOW_BIT, enabled); } /** Get slave delay enabled status. * When a particular slave delay is enabled, the rate of access for the that @@ -2371,9 +2373,9 @@ void mpu6500SetExternalShadowDelayEnabled(bool enabled) bool mpu6500GetSlaveDelayEnabled(uint8_t num) { // MPU6500_DELAYCTRL_I2C_SLV4_DLY_EN_BIT is 4, SLV3 is 3, etc. - if (num > 4) - return 0; - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_I2C_MST_DELAY_CTRL, num, buffer); + // if (num > 4) + // return 0; + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_I2C_MST_DELAY_CTRL, num, buffer); return buffer[0]; } /** Set slave delay enabled status. @@ -2384,7 +2386,7 @@ bool mpu6500GetSlaveDelayEnabled(uint8_t num) */ void mpu6500SetSlaveDelayEnabled(uint8_t num, bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_I2C_MST_DELAY_CTRL, num, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_I2C_MST_DELAY_CTRL, num, enabled); } // SIGNAL_PATH_RESET register @@ -2397,7 +2399,7 @@ void mpu6500SetSlaveDelayEnabled(uint8_t num, bool enabled) */ void mpu6500ResetGyroscopePath() { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_SIGNAL_PATH_RESET, MPU6500_PATHRESET_GYRO_RESET_BIT, 1); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_SIGNAL_PATH_RESET, MPU6500_PATHRESET_GYRO_RESET_BIT, 1); } /** Reset accelerometer signal path. * The reset will revert the signal path analog to digital converters and @@ -2407,7 +2409,7 @@ void mpu6500ResetGyroscopePath() */ void mpu6500ResetAccelerometerPath() { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_SIGNAL_PATH_RESET, MPU6500_PATHRESET_ACCEL_RESET_BIT, 1); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_SIGNAL_PATH_RESET, MPU6500_PATHRESET_ACCEL_RESET_BIT, 1); } /** Reset temperature sensor signal path. * The reset will revert the signal path analog to digital converters and @@ -2417,7 +2419,7 @@ void mpu6500ResetAccelerometerPath() */ void mpu6500ResetTemperaturePath() { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_SIGNAL_PATH_RESET, MPU6500_PATHRESET_TEMP_RESET_BIT, 1); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_SIGNAL_PATH_RESET, MPU6500_PATHRESET_TEMP_RESET_BIT, 1); } // MOT_DETECT_CTRL register @@ -2438,8 +2440,8 @@ void mpu6500ResetTemperaturePath() */ uint8_t mpu6500GetAccelerometerPowerOnDelay() { - i2cdevReadBits(I2Cx, devAddr, MPU6500_RA_MOT_DETECT_CTRL, MPU6500_DETECT_ACCEL_ON_DELAY_BIT, - MPU6500_DETECT_ACCEL_ON_DELAY_LENGTH, buffer); + // i2cdevReadBits(I2Cx, devAddr, MPU6500_RA_MOT_DETECT_CTRL, MPU6500_DETECT_ACCEL_ON_DELAY_BIT, + // MPU6500_DETECT_ACCEL_ON_DELAY_LENGTH, buffer); return buffer[0]; } /** Set accelerometer power-on delay. @@ -2450,8 +2452,8 @@ uint8_t mpu6500GetAccelerometerPowerOnDelay() */ void mpu6500SetAccelerometerPowerOnDelay(uint8_t delay) { - i2cdevWriteBits(I2Cx, devAddr, MPU6500_RA_MOT_DETECT_CTRL, MPU6500_DETECT_ACCEL_ON_DELAY_BIT, - MPU6500_DETECT_ACCEL_ON_DELAY_LENGTH, delay); + // i2cdevWriteBits(I2Cx, devAddr, MPU6500_RA_MOT_DETECT_CTRL, MPU6500_DETECT_ACCEL_ON_DELAY_BIT, + // MPU6500_DETECT_ACCEL_ON_DELAY_LENGTH, delay); } /** Get Free Fall detection counter decrement configuration. * Detection is registered by the Free Fall detection module after accelerometer @@ -2481,8 +2483,8 @@ void mpu6500SetAccelerometerPowerOnDelay(uint8_t delay) */ uint8_t mpu6500GetFreefallDetectionCounterDecrement() { - i2cdevReadBits(I2Cx, devAddr, MPU6500_RA_MOT_DETECT_CTRL, MPU6500_DETECT_FF_COUNT_BIT, - MPU6500_DETECT_FF_COUNT_LENGTH, buffer); + // i2cdevReadBits(I2Cx, devAddr, MPU6500_RA_MOT_DETECT_CTRL, MPU6500_DETECT_FF_COUNT_BIT, + // MPU6500_DETECT_FF_COUNT_LENGTH, buffer); return buffer[0]; } /** Set Free Fall detection counter decrement configuration. @@ -2493,8 +2495,8 @@ uint8_t mpu6500GetFreefallDetectionCounterDecrement() */ void mpu6500SetFreefallDetectionCounterDecrement(uint8_t decrement) { - i2cdevWriteBits(I2Cx, devAddr, MPU6500_RA_MOT_DETECT_CTRL, MPU6500_DETECT_FF_COUNT_BIT, - MPU6500_DETECT_FF_COUNT_LENGTH, decrement); + // i2cdevWriteBits(I2Cx, devAddr, MPU6500_RA_MOT_DETECT_CTRL, MPU6500_DETECT_FF_COUNT_BIT, + // MPU6500_DETECT_FF_COUNT_LENGTH, decrement); } /** Get Motion detection counter decrement configuration. * Detection is registered by the Motion detection module after accelerometer @@ -2521,8 +2523,8 @@ void mpu6500SetFreefallDetectionCounterDecrement(uint8_t decrement) */ uint8_t mpu6500GetMotionDetectionCounterDecrement() { - i2cdevReadBits(I2Cx, devAddr, MPU6500_RA_MOT_DETECT_CTRL, MPU6500_DETECT_MOT_COUNT_BIT, - MPU6500_DETECT_MOT_COUNT_LENGTH, buffer); + // i2cdevReadBits(I2Cx, devAddr, MPU6500_RA_MOT_DETECT_CTRL, MPU6500_DETECT_MOT_COUNT_BIT, + // MPU6500_DETECT_MOT_COUNT_LENGTH, buffer); return buffer[0]; } /** Set Motion detection counter decrement configuration. @@ -2533,8 +2535,8 @@ uint8_t mpu6500GetMotionDetectionCounterDecrement() */ void mpu6500SetMotionDetectionCounterDecrement(uint8_t decrement) { - i2cdevWriteBits(I2Cx, devAddr, MPU6500_RA_MOT_DETECT_CTRL, MPU6500_DETECT_MOT_COUNT_BIT, - MPU6500_DETECT_MOT_COUNT_LENGTH, decrement); + // i2cdevWriteBits(I2Cx, devAddr, MPU6500_RA_MOT_DETECT_CTRL, MPU6500_DETECT_MOT_COUNT_BIT, + // MPU6500_DETECT_MOT_COUNT_LENGTH, decrement); } // USER_CTRL register @@ -2549,7 +2551,7 @@ void mpu6500SetMotionDetectionCounterDecrement(uint8_t decrement) */ bool mpu6500GetFIFOEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_USER_CTRL, MPU6500_USERCTRL_FIFO_EN_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_USER_CTRL, MPU6500_USERCTRL_FIFO_EN_BIT, buffer); return buffer[0]; } /** Set FIFO enabled status. @@ -2560,7 +2562,7 @@ bool mpu6500GetFIFOEnabled() */ void mpu6500SetFIFOEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_USER_CTRL, MPU6500_USERCTRL_FIFO_EN_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_USER_CTRL, MPU6500_USERCTRL_FIFO_EN_BIT, enabled); } /** Get I2C Master Mode enabled status. * When this mode is enabled, the MPU-60X0 acts as the I2C Master to the @@ -2575,7 +2577,7 @@ void mpu6500SetFIFOEnabled(bool enabled) */ bool mpu6500GetI2CMasterModeEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_USER_CTRL, MPU6500_USERCTRL_I2C_MST_EN_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_USER_CTRL, MPU6500_USERCTRL_I2C_MST_EN_BIT, buffer); return buffer[0]; } /** Set I2C Master Mode enabled status. @@ -2586,7 +2588,7 @@ bool mpu6500GetI2CMasterModeEnabled() */ void mpu6500SetI2CMasterModeEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_USER_CTRL, MPU6500_USERCTRL_I2C_MST_EN_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_USER_CTRL, MPU6500_USERCTRL_I2C_MST_EN_BIT, enabled); } /** Switch from I2C to SPI mode (MPU-6000 only) * If this is set, the primary SPI interface will be enabled in place of the @@ -2594,7 +2596,7 @@ void mpu6500SetI2CMasterModeEnabled(bool enabled) */ void mpu6500SwitchSPIEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_USER_CTRL, MPU6500_USERCTRL_I2C_IF_DIS_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_USER_CTRL, MPU6500_USERCTRL_I2C_IF_DIS_BIT, enabled); } /** Reset the FIFO. * This bit resets the FIFO buffer when set to 1 while FIFO_EN equals 0. This @@ -2604,7 +2606,7 @@ void mpu6500SwitchSPIEnabled(bool enabled) */ void mpu6500ResetFIFO() { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_USER_CTRL, MPU6500_USERCTRL_FIFO_RESET_BIT, 1); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_USER_CTRL, MPU6500_USERCTRL_FIFO_RESET_BIT, 1); } /** Reset the I2C Master. * This bit resets the I2C Master when set to 1 while I2C_MST_EN equals 0. @@ -2614,7 +2616,7 @@ void mpu6500ResetFIFO() */ void mpu6500ResetI2CMaster() { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_USER_CTRL, MPU6500_USERCTRL_I2C_MST_RESET_BIT, 1); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_USER_CTRL, MPU6500_USERCTRL_I2C_MST_RESET_BIT, 1); } /** Reset all sensor registers and signal paths. * When set to 1, this bit resets the signal paths for all sensors (gyroscopes, @@ -2630,7 +2632,7 @@ void mpu6500ResetI2CMaster() */ void mpu6500ResetSensors() { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_USER_CTRL, MPU6500_USERCTRL_SIG_COND_RESET_BIT, 1); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_USER_CTRL, MPU6500_USERCTRL_SIG_COND_RESET_BIT, 1); } // PWR_MGMT_1 register @@ -2642,7 +2644,7 @@ void mpu6500ResetSensors() */ void mpu6500Reset() { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_PWR_MGMT_1, MPU6500_PWR1_DEVICE_RESET_BIT, 1); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_PWR_MGMT_1, MPU6500_PWR1_DEVICE_RESET_BIT, 1); } /** Get sleep mode status. * Setting the SLEEP bit in the register puts the device into very low power @@ -2657,7 +2659,7 @@ void mpu6500Reset() */ bool mpu6500GetSleepEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_PWR_MGMT_1, MPU6500_PWR1_SLEEP_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_PWR_MGMT_1, MPU6500_PWR1_SLEEP_BIT, buffer); return buffer[0]; } /** Set sleep mode status. @@ -2668,7 +2670,7 @@ bool mpu6500GetSleepEnabled() */ void mpu6500SetSleepEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_PWR_MGMT_1, MPU6500_PWR1_SLEEP_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_PWR_MGMT_1, MPU6500_PWR1_SLEEP_BIT, enabled); } /** Get wake cycle enabled status. * When this bit is set to 1 and SLEEP is disabled, the MPU-60X0 will cycle @@ -2680,7 +2682,7 @@ void mpu6500SetSleepEnabled(bool enabled) */ bool mpu6500GetWakeCycleEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_PWR_MGMT_1, MPU6500_PWR1_CYCLE_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_PWR_MGMT_1, MPU6500_PWR1_CYCLE_BIT, buffer); return buffer[0]; } /** Set wake cycle enabled status. @@ -2691,7 +2693,7 @@ bool mpu6500GetWakeCycleEnabled() */ void mpu6500SetWakeCycleEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_PWR_MGMT_1, MPU6500_PWR1_CYCLE_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_PWR_MGMT_1, MPU6500_PWR1_CYCLE_BIT, enabled); } /** Get temperature sensor enabled status. * Control the usage of the internal temperature sensor. @@ -2706,7 +2708,7 @@ void mpu6500SetWakeCycleEnabled(bool enabled) */ bool mpu6500GetTempSensorEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_PWR_MGMT_1, MPU6500_PWR1_TEMP_DIS_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_PWR_MGMT_1, MPU6500_PWR1_TEMP_DIS_BIT, buffer); return buffer[0] == 0; // 1 is actually disabled here } /** Set temperature sensor enabled status. @@ -2722,7 +2724,7 @@ bool mpu6500GetTempSensorEnabled() void mpu6500SetTempSensorEnabled(bool enabled) { // 1 is actually disabled here - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_PWR_MGMT_1, MPU6500_PWR1_TEMP_DIS_BIT, !enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_PWR_MGMT_1, MPU6500_PWR1_TEMP_DIS_BIT, !enabled); } /** Get clock source setting. * @return Current clock source setting @@ -2732,8 +2734,8 @@ void mpu6500SetTempSensorEnabled(bool enabled) */ uint8_t mpu6500GetClockSource() { - i2cdevReadBits(I2Cx, devAddr, MPU6500_RA_PWR_MGMT_1, MPU6500_PWR1_CLKSEL_BIT, - MPU6500_PWR1_CLKSEL_LENGTH, buffer); + // i2cdevReadBits(I2Cx, devAddr, MPU6500_RA_PWR_MGMT_1, MPU6500_PWR1_CLKSEL_BIT, + // MPU6500_PWR1_CLKSEL_LENGTH, buffer); return buffer[0]; } /** Set clock source setting. @@ -2768,8 +2770,8 @@ uint8_t mpu6500GetClockSource() */ void mpu6500SetClockSource(uint8_t source) { - i2cdevWriteBits(I2Cx, devAddr, MPU6500_RA_PWR_MGMT_1, MPU6500_PWR1_CLKSEL_BIT, - MPU6500_PWR1_CLKSEL_LENGTH, source); + // i2cdevWriteBits(I2Cx, devAddr, MPU6500_RA_PWR_MGMT_1, MPU6500_PWR1_CLKSEL_BIT, + // MPU6500_PWR1_CLKSEL_LENGTH, source); } // PWR_MGMT_2 register @@ -2799,8 +2801,8 @@ void mpu6500SetClockSource(uint8_t source) */ uint8_t mpu6500GetWakeFrequency() { - i2cdevReadBits(I2Cx, devAddr, MPU6500_RA_PWR_MGMT_2, MPU6500_PWR2_LP_WAKE_CTRL_BIT, - MPU6500_PWR2_LP_WAKE_CTRL_LENGTH, buffer); + // i2cdevReadBits(I2Cx, devAddr, MPU6500_RA_PWR_MGMT_2, MPU6500_PWR2_LP_WAKE_CTRL_BIT, + // MPU6500_PWR2_LP_WAKE_CTRL_LENGTH, buffer); return buffer[0]; } /** Set wake frequency in Accel-Only Low Power Mode. @@ -2809,8 +2811,8 @@ uint8_t mpu6500GetWakeFrequency() */ void mpu6500SetWakeFrequency(uint8_t frequency) { - i2cdevWriteBits(I2Cx, devAddr, MPU6500_RA_PWR_MGMT_2, MPU6500_PWR2_LP_WAKE_CTRL_BIT, - MPU6500_PWR2_LP_WAKE_CTRL_LENGTH, frequency); + // i2cdevWriteBits(I2Cx, devAddr, MPU6500_RA_PWR_MGMT_2, MPU6500_PWR2_LP_WAKE_CTRL_BIT, + // MPU6500_PWR2_LP_WAKE_CTRL_LENGTH, frequency); } /** Get X-axis accelerometer standby enabled status. @@ -2821,7 +2823,7 @@ void mpu6500SetWakeFrequency(uint8_t frequency) */ bool mpu6500GetStandbyXAccelEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_PWR_MGMT_2, MPU6500_PWR2_STBY_XA_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_PWR_MGMT_2, MPU6500_PWR2_STBY_XA_BIT, buffer); return buffer[0]; } /** Set X-axis accelerometer standby enabled status. @@ -2832,7 +2834,7 @@ bool mpu6500GetStandbyXAccelEnabled() */ void mpu6500SetStandbyXAccelEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_PWR_MGMT_2, MPU6500_PWR2_STBY_XA_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_PWR_MGMT_2, MPU6500_PWR2_STBY_XA_BIT, enabled); } /** Get Y-axis accelerometer standby enabled status. * If enabled, the Y-axis will not gather or report data (or use power). @@ -2842,7 +2844,7 @@ void mpu6500SetStandbyXAccelEnabled(bool enabled) */ bool mpu6500GetStandbyYAccelEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_PWR_MGMT_2, MPU6500_PWR2_STBY_YA_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_PWR_MGMT_2, MPU6500_PWR2_STBY_YA_BIT, buffer); return buffer[0]; } /** Set Y-axis accelerometer standby enabled status. @@ -2853,7 +2855,7 @@ bool mpu6500GetStandbyYAccelEnabled() */ void mpu6500SetStandbyYAccelEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_PWR_MGMT_2, MPU6500_PWR2_STBY_YA_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_PWR_MGMT_2, MPU6500_PWR2_STBY_YA_BIT, enabled); } /** Get Z-axis accelerometer standby enabled status. * If enabled, the Z-axis will not gather or report data (or use power). @@ -2863,7 +2865,7 @@ void mpu6500SetStandbyYAccelEnabled(bool enabled) */ bool mpu6500GetStandbyZAccelEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_PWR_MGMT_2, MPU6500_PWR2_STBY_ZA_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_PWR_MGMT_2, MPU6500_PWR2_STBY_ZA_BIT, buffer); return buffer[0]; } /** Set Z-axis accelerometer standby enabled status. @@ -2874,7 +2876,7 @@ bool mpu6500GetStandbyZAccelEnabled() */ void mpu6500SetStandbyZAccelEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_PWR_MGMT_2, MPU6500_PWR2_STBY_ZA_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_PWR_MGMT_2, MPU6500_PWR2_STBY_ZA_BIT, enabled); } /** Get X-axis gyroscope standby enabled status. * If enabled, the X-axis will not gather or report data (or use power). @@ -2884,7 +2886,7 @@ void mpu6500SetStandbyZAccelEnabled(bool enabled) */ bool mpu6500GetStandbyXGyroEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_PWR_MGMT_2, MPU6500_PWR2_STBY_XG_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_PWR_MGMT_2, MPU6500_PWR2_STBY_XG_BIT, buffer); return buffer[0]; } /** Set X-axis gyroscope standby enabled status. @@ -2895,7 +2897,7 @@ bool mpu6500GetStandbyXGyroEnabled() */ void mpu6500SetStandbyXGyroEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_PWR_MGMT_2, MPU6500_PWR2_STBY_XG_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_PWR_MGMT_2, MPU6500_PWR2_STBY_XG_BIT, enabled); } /** Get Y-axis gyroscope standby enabled status. * If enabled, the Y-axis will not gather or report data (or use power). @@ -2905,7 +2907,7 @@ void mpu6500SetStandbyXGyroEnabled(bool enabled) */ bool mpu6500GetStandbyYGyroEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_PWR_MGMT_2, MPU6500_PWR2_STBY_YG_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_PWR_MGMT_2, MPU6500_PWR2_STBY_YG_BIT, buffer); return buffer[0]; } /** Set Y-axis gyroscope standby enabled status. @@ -2916,7 +2918,7 @@ bool mpu6500GetStandbyYGyroEnabled() */ void mpu6500SetStandbyYGyroEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_PWR_MGMT_2, MPU6500_PWR2_STBY_YG_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_PWR_MGMT_2, MPU6500_PWR2_STBY_YG_BIT, enabled); } /** Get Z-axis gyroscope standby enabled status. * If enabled, the Z-axis will not gather or report data (or use power). @@ -2926,7 +2928,7 @@ void mpu6500SetStandbyYGyroEnabled(bool enabled) */ bool mpu6500GetStandbyZGyroEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_PWR_MGMT_2, MPU6500_PWR2_STBY_ZG_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_PWR_MGMT_2, MPU6500_PWR2_STBY_ZG_BIT, buffer); return buffer[0]; } /** Set Z-axis gyroscope standby enabled status. @@ -2937,7 +2939,7 @@ bool mpu6500GetStandbyZGyroEnabled() */ void mpu6500SetStandbyZGyroEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_PWR_MGMT_2, MPU6500_PWR2_STBY_ZG_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_PWR_MGMT_2, MPU6500_PWR2_STBY_ZG_BIT, enabled); } // FIFO_COUNT* registers @@ -2951,7 +2953,7 @@ void mpu6500SetStandbyZGyroEnabled(bool enabled) */ uint16_t mpu6500GetFIFOCount() { - i2cdevReadReg8(I2Cx, devAddr, MPU6500_RA_FIFO_COUNTH, 2, buffer); + // i2cdevReadReg8(I2Cx, devAddr, MPU6500_RA_FIFO_COUNTH, 2, buffer); return (((uint16_t) buffer[0]) << 8) | buffer[1]; } @@ -2984,12 +2986,12 @@ uint16_t mpu6500GetFIFOCount() */ uint8_t mpu6500GetFIFOByte() { - i2cdevReadByte(I2Cx, devAddr, MPU6500_RA_FIFO_R_W, buffer); + // i2cdevReadByte(I2Cx, devAddr, MPU6500_RA_FIFO_R_W, buffer); return buffer[0]; } void mpu6500GetFIFOBytes(uint8_t *data, uint8_t length) { - i2cdevReadReg8(I2Cx, devAddr, MPU6500_RA_FIFO_R_W, length, data); + // i2cdevReadReg8(I2Cx, devAddr, MPU6500_RA_FIFO_R_W, length, data); } /** Write byte to FIFO buffer. * @see getFIFOByte() @@ -2997,7 +2999,7 @@ void mpu6500GetFIFOBytes(uint8_t *data, uint8_t length) */ void mpu6500SetFIFOByte(uint8_t data) { - i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_FIFO_R_W, data); + // i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_FIFO_R_W, data); } // WHO_AM_I register @@ -3011,8 +3013,8 @@ void mpu6500SetFIFOByte(uint8_t data) */ uint8_t mpu6500GetDeviceID() { - i2cdevReadBits(I2Cx, devAddr, MPU6500_RA_WHO_AM_I, MPU6500_WHO_AM_I_BIT, MPU6500_WHO_AM_I_LENGTH, - buffer); + // i2cdevReadBits(I2Cx, devAddr, MPU6500_RA_WHO_AM_I, MPU6500_WHO_AM_I_BIT, MPU6500_WHO_AM_I_LENGTH, + // buffer); return buffer[0]; } /** Set Device ID. @@ -3026,8 +3028,8 @@ uint8_t mpu6500GetDeviceID() */ void mpu6500SetDeviceID(uint8_t id) { - i2cdevWriteBits(I2Cx, devAddr, MPU6500_RA_WHO_AM_I, MPU6500_WHO_AM_I_BIT, MPU6500_WHO_AM_I_LENGTH, - id); + // i2cdevWriteBits(I2Cx, devAddr, MPU6500_RA_WHO_AM_I, MPU6500_WHO_AM_I_BIT, MPU6500_WHO_AM_I_LENGTH, + // id); } // ======== UNDOCUMENTED/DMP REGISTERS/METHODS ======== @@ -3038,53 +3040,53 @@ void mpu6500SetDeviceID(uint8_t id) bool mpu6500GetIntPLLReadyEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_INT_ENABLE, MPU6500_INTERRUPT_PLL_RDY_INT_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_INT_ENABLE, MPU6500_INTERRUPT_PLL_RDY_INT_BIT, buffer); return buffer[0]; } void mpu6500SetIntPLLReadyEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_INT_ENABLE, MPU6500_INTERRUPT_PLL_RDY_INT_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_INT_ENABLE, MPU6500_INTERRUPT_PLL_RDY_INT_BIT, enabled); } bool mpu6500GetIntDMPEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_INT_ENABLE, MPU6500_INTERRUPT_DMP_INT_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_INT_ENABLE, MPU6500_INTERRUPT_DMP_INT_BIT, buffer); return buffer[0]; } void mpu6500SetIntDMPEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_INT_ENABLE, MPU6500_INTERRUPT_DMP_INT_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_INT_ENABLE, MPU6500_INTERRUPT_DMP_INT_BIT, enabled); } // DMP_INT_STATUS bool mpu6500GetDMPInt5Status() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_DMP_INT_STATUS, MPU6500_DMPINT_5_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_DMP_INT_STATUS, MPU6500_DMPINT_5_BIT, buffer); return buffer[0]; } bool mpu6500GetDMPInt4Status() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_DMP_INT_STATUS, MPU6500_DMPINT_4_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_DMP_INT_STATUS, MPU6500_DMPINT_4_BIT, buffer); return buffer[0]; } bool mpu6500GetDMPInt3Status() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_DMP_INT_STATUS, MPU6500_DMPINT_3_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_DMP_INT_STATUS, MPU6500_DMPINT_3_BIT, buffer); return buffer[0]; } bool mpu6500GetDMPInt2Status() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_DMP_INT_STATUS, MPU6500_DMPINT_2_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_DMP_INT_STATUS, MPU6500_DMPINT_2_BIT, buffer); return buffer[0]; } bool mpu6500GetDMPInt1Status() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_DMP_INT_STATUS, MPU6500_DMPINT_1_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_DMP_INT_STATUS, MPU6500_DMPINT_1_BIT, buffer); return buffer[0]; } bool mpu6500GetDMPInt0Status() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_DMP_INT_STATUS, MPU6500_DMPINT_0_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_DMP_INT_STATUS, MPU6500_DMPINT_0_BIT, buffer); return buffer[0]; } @@ -3092,12 +3094,12 @@ bool mpu6500GetDMPInt0Status() bool mpu6500GetIntPLLReadyStatus() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_INT_STATUS, MPU6500_INTERRUPT_PLL_RDY_INT_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_INT_STATUS, MPU6500_INTERRUPT_PLL_RDY_INT_BIT, buffer); return buffer[0]; } bool mpu6500GetIntDMPStatus() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_INT_STATUS, MPU6500_INTERRUPT_DMP_INT_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_INT_STATUS, MPU6500_INTERRUPT_DMP_INT_BIT, buffer); return buffer[0]; } @@ -3105,47 +3107,47 @@ bool mpu6500GetIntDMPStatus() bool mpu6500GetDMPEnabled() { - i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_USER_CTRL, MPU6500_USERCTRL_DMP_EN_BIT, buffer); + // i2cdevReadBit(I2Cx, devAddr, MPU6500_RA_USER_CTRL, MPU6500_USERCTRL_DMP_EN_BIT, buffer); return buffer[0]; } void mpu6500SetDMPEnabled(bool enabled) { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_USER_CTRL, MPU6500_USERCTRL_DMP_EN_BIT, enabled); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_USER_CTRL, MPU6500_USERCTRL_DMP_EN_BIT, enabled); } void mpu6500ResetDMP() { - i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_USER_CTRL, MPU6500_USERCTRL_DMP_RESET_BIT, 1); + // i2cdevWriteBit(I2Cx, devAddr, MPU6500_RA_USER_CTRL, MPU6500_USERCTRL_DMP_RESET_BIT, 1); } // BANK_SEL register void mpu6500SetMemoryBank(uint8_t bank, bool prefetchEnabled, bool userBank) { - bank &= 0x1F; - if (userBank) - bank |= 0x20; - if (prefetchEnabled) - bank |= 0x40; - i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_BANK_SEL, bank); + // bank &= 0x1F; + // if (userBank) + // bank |= 0x20; + // if (prefetchEnabled) + // bank |= 0x40; + // i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_BANK_SEL, bank); } // MEM_START_ADDR register void mpu6500SetMemoryStartAddress(uint8_t address) { - i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_MEM_START_ADDR, address); + // i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_MEM_START_ADDR, address); } // MEM_R_W register uint8_t mpu6500ReadMemoryByte() { - i2cdevReadByte(I2Cx, devAddr, MPU6500_RA_MEM_R_W, buffer); + // i2cdevReadByte(I2Cx, devAddr, MPU6500_RA_MEM_R_W, buffer); return buffer[0]; } void mpu6500WriteMemoryByte(uint8_t data) { - i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_MEM_R_W, data); + // i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_MEM_R_W, data); } void mpu6500ReadMemoryBlock(uint8_t *data, uint16_t dataSize, uint8_t bank, uint8_t address) { @@ -3154,37 +3156,37 @@ void mpu6500ReadMemoryBlock(uint8_t *data, uint16_t dataSize, uint8_t bank, uint uint8_t chunkSize; uint16_t i; - for (i = 0; i < dataSize;) - { - // determine correct chunk size according to bank position and data size - chunkSize = MPU6500_DMP_MEMORY_CHUNK_SIZE; + // for (i = 0; i < dataSize;) + // { + // // determine correct chunk size according to bank position and data size + // chunkSize = MPU6500_DMP_MEMORY_CHUNK_SIZE; - // make sure we don't go past the data size - if (i + chunkSize > dataSize) - chunkSize = dataSize - i; + // // make sure we don't go past the data size + // if (i + chunkSize > dataSize) + // chunkSize = dataSize - i; - // make sure this chunk doesn't go past the bank boundary (256 bytes) - if (chunkSize > 256 - address) - chunkSize = 256 - address; + // // make sure this chunk doesn't go past the bank boundary (256 bytes) + // if (chunkSize > 256 - address) + // chunkSize = 256 - address; - // read the chunk of data as specified - i2cdevReadReg8(I2Cx, devAddr, MPU6500_RA_MEM_R_W, chunkSize, data + i); + // // read the chunk of data as specified + // i2cdevReadReg8(I2Cx, devAddr, MPU6500_RA_MEM_R_W, chunkSize, data + i); - // increase byte index by [chunkSize] - i += chunkSize; + // // increase byte index by [chunkSize] + // i += chunkSize; - // uint8_t automatically wraps to 0 at 256 - address += chunkSize; + // // uint8_t automatically wraps to 0 at 256 + // address += chunkSize; - // if we aren't done, update bank (if necessary) and address - if (i < dataSize) - { - if (address == 0) - bank++; - mpu6500SetMemoryBank(bank, true, true); - mpu6500SetMemoryStartAddress(address); - } - } + // // if we aren't done, update bank (if necessary) and address + // if (i < dataSize) + // { + // if (address == 0) + // bank++; + // mpu6500SetMemoryBank(bank, true, true); + // mpu6500SetMemoryStartAddress(address); + // } + // } } bool mpu6500WriteMemoryBlock(const uint8_t *data, uint16_t dataSize, uint8_t bank, uint8_t address, bool verify) @@ -3194,76 +3196,76 @@ bool mpu6500WriteMemoryBlock(const uint8_t *data, uint16_t dataSize, uint8_t ban uint8_t *progBuffer; uint16_t i; - mpu6500SetMemoryBank(bank, true, true); - mpu6500SetMemoryStartAddress(address); - - for (i = 0; i < dataSize;) - { - // determine correct chunk size according to bank position and data size - chunkSize = MPU6500_DMP_MEMORY_CHUNK_SIZE; - - // make sure we don't go past the data size - if (i + chunkSize > dataSize) - chunkSize = dataSize - i; - - // make sure this chunk doesn't go past the bank boundary (256 bytes) - if (chunkSize > 256 - address) - chunkSize = 256 - address; - - // write the chunk of data as specified - progBuffer = (uint8_t *) data + i; - - i2cdevWriteReg8(I2Cx, devAddr, MPU6500_RA_MEM_R_W, chunkSize, progBuffer); - - // verify data if needed - if (verify) - { - uint32_t j; - mpu6500SetMemoryBank(bank, true, true); - mpu6500SetMemoryStartAddress(address); - i2cdevReadReg8(I2Cx, devAddr, MPU6500_RA_MEM_R_W, chunkSize, verifyBuffer); - - for (j = 0; j < chunkSize; j++) - { - if (progBuffer[j] != verifyBuffer[j]) - { - /*Serial.print("Block write verification error, bank "); - Serial.print(bank, DEC); - Serial.print(", address "); - Serial.print(address, DEC); - Serial.print("!\nExpected:"); - for (j = 0; j < chunkSize; j++) { - Serial.print(" 0x"); - if (progBuffer[j] < 16) Serial.print("0"); - Serial.print(progBuffer[j], HEX); - } - Serial.print("\nReceived:"); - for (uint8_t j = 0; j < chunkSize; j++) { - Serial.print(" 0x"); - if (verifyBuffer[i + j] < 16) Serial.print("0"); - Serial.print(verifyBuffer[i + j], HEX); - } - Serial.print("\n");*/ - return false; - } - } - } - - // increase byte index by [chunkSize] - i += chunkSize; - - // uint8_t automatically wraps to 0 at 256 - address += chunkSize; - - // if we aren't done, update bank (if necessary) and address - if (i < dataSize) - { - if (address == 0) - bank++; - mpu6500SetMemoryBank(bank, true, true); - mpu6500SetMemoryStartAddress(address); - } - } + // mpu6500SetMemoryBank(bank, true, true); + // mpu6500SetMemoryStartAddress(address); + + // for (i = 0; i < dataSize;) + // { + // // determine correct chunk size according to bank position and data size + // chunkSize = MPU6500_DMP_MEMORY_CHUNK_SIZE; + + // // make sure we don't go past the data size + // if (i + chunkSize > dataSize) + // chunkSize = dataSize - i; + + // // make sure this chunk doesn't go past the bank boundary (256 bytes) + // if (chunkSize > 256 - address) + // chunkSize = 256 - address; + + // // write the chunk of data as specified + // progBuffer = (uint8_t *) data + i; + + // i2cdevWriteReg8(I2Cx, devAddr, MPU6500_RA_MEM_R_W, chunkSize, progBuffer); + + // // verify data if needed + // if (verify) + // { + // uint32_t j; + // mpu6500SetMemoryBank(bank, true, true); + // mpu6500SetMemoryStartAddress(address); + // i2cdevReadReg8(I2Cx, devAddr, MPU6500_RA_MEM_R_W, chunkSize, verifyBuffer); + + // for (j = 0; j < chunkSize; j++) + // { + // if (progBuffer[j] != verifyBuffer[j]) + // { + // /*Serial.print("Block write verification error, bank "); + // Serial.print(bank, DEC); + // Serial.print(", address "); + // Serial.print(address, DEC); + // Serial.print("!\nExpected:"); + // for (j = 0; j < chunkSize; j++) { + // Serial.print(" 0x"); + // if (progBuffer[j] < 16) Serial.print("0"); + // Serial.print(progBuffer[j], HEX); + // } + // Serial.print("\nReceived:"); + // for (uint8_t j = 0; j < chunkSize; j++) { + // Serial.print(" 0x"); + // if (verifyBuffer[i + j] < 16) Serial.print("0"); + // Serial.print(verifyBuffer[i + j], HEX); + // } + // Serial.print("\n");*/ + // return false; + // } + // } + // } + + // // increase byte index by [chunkSize] + // i += chunkSize; + + // // uint8_t automatically wraps to 0 at 256 + // address += chunkSize; + + // // if we aren't done, update bank (if necessary) and address + // if (i < dataSize) + // { + // if (address == 0) + // bank++; + // mpu6500SetMemoryBank(bank, true, true); + // mpu6500SetMemoryStartAddress(address); + // } + // } return true; } bool mpu6500WriteProgMemoryBlock(const uint8_t *data, uint16_t dataSize, uint8_t bank, @@ -3274,66 +3276,66 @@ bool mpu6500WriteProgMemoryBlock(const uint8_t *data, uint16_t dataSize, uint8_t #define MPU6500_DMP_CONFIG_BLOCK_SIZE 6 bool mpu6500WriteDMPConfigurationSet(const uint8_t *data, uint16_t dataSize) { - uint8_t *progBuffer, success, special; - uint16_t i; - - // config set data is a long string of blocks with the following structure: - // [bank] [offset] [length] [byte[0], byte[1], ..., byte[length]] - uint8_t bank=0; - uint8_t offset=0; - uint8_t length=0; - for (i = 0; i < dataSize;) - { - bank = data[i++]; - offset = data[i++]; - length = data[i++]; - } - - // write data or perform special action - if (length > 0) - { - // regular block of data to write - /*Serial.print("Writing config block to bank "); - Serial.print(bank); - Serial.print(", offset "); - Serial.print(offset); - Serial.print(", length="); - Serial.println(length);*/ - progBuffer = (uint8_t *) data + i; - success = mpu6500WriteMemoryBlock(progBuffer, length, bank, offset, true); - i += length; - } - else - { - // special instruction - // NOTE: this kind of behavior (what and when to do certain things) - // is totally undocumented. This code is in here based on observed - // behavior only, and exactly why (or even whether) it has to be here - // is anybody's guess for now. - special = data[i++]; - /*Serial.print("Special command code "); - Serial.print(special, HEX); - Serial.println(" found...");*/ - if (special == 0x01) - { - // enable DMP-related interrupts - mpu6500SetIntZeroMotionEnabled(true); - mpu6500SetIntFIFOBufferOverflowEnabled(true); - mpu6500SetIntDMPEnabled(true); - //i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_INT_ENABLE, 0x32); - success = true; - } - else - { - // unknown special command - success = false; - } - } - - if (!success) - { - return false; // uh oh - } + // uint8_t *progBuffer, success, special; + // uint16_t i; + + // // config set data is a long string of blocks with the following structure: + // // [bank] [offset] [length] [byte[0], byte[1], ..., byte[length]] + // uint8_t bank=0; + // uint8_t offset=0; + // uint8_t length=0; + // for (i = 0; i < dataSize;) + // { + // bank = data[i++]; + // offset = data[i++]; + // length = data[i++]; + // } + + // // write data or perform special action + // if (length > 0) + // { + // // regular block of data to write + // /*Serial.print("Writing config block to bank "); + // Serial.print(bank); + // Serial.print(", offset "); + // Serial.print(offset); + // Serial.print(", length="); + // Serial.println(length);*/ + // progBuffer = (uint8_t *) data + i; + // success = mpu6500WriteMemoryBlock(progBuffer, length, bank, offset, true); + // i += length; + // } + // else + // { + // // special instruction + // // NOTE: this kind of behavior (what and when to do certain things) + // // is totally undocumented. This code is in here based on observed + // // behavior only, and exactly why (or even whether) it has to be here + // // is anybody's guess for now. + // special = data[i++]; + // /*Serial.print("Special command code "); + // Serial.print(special, HEX); + // Serial.println(" found...");*/ + // if (special == 0x01) + // { + // // enable DMP-related interrupts + // mpu6500SetIntZeroMotionEnabled(true); + // mpu6500SetIntFIFOBufferOverflowEnabled(true); + // mpu6500SetIntDMPEnabled(true); + // //i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_INT_ENABLE, 0x32); + // success = true; + // } + // else + // { + // // unknown special command + // success = false; + // } + // } + + // if (!success) + // { + // return false; // uh oh + // } return true; } @@ -3346,22 +3348,22 @@ bool mpu6500WriteProgDMPConfigurationSet(const uint8_t *data, uint16_t dataSize) uint8_t mpu6500GetDMPConfig1() { - i2cdevReadByte(I2Cx, devAddr, MPU6500_RA_DMP_CFG_1, buffer); + // i2cdevReadByte(I2Cx, devAddr, MPU6500_RA_DMP_CFG_1, buffer); return buffer[0]; } void mpu6500SetDMPConfig1(uint8_t config) { - i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_DMP_CFG_1, config); + // i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_DMP_CFG_1, config); } // DMP_CFG_2 register uint8_t mpu6500GetDMPConfig2() { - i2cdevReadByte(I2Cx, devAddr, MPU6500_RA_DMP_CFG_2, buffer); + // i2cdevReadByte(I2Cx, devAddr, MPU6500_RA_DMP_CFG_2, buffer); return buffer[0]; } void mpu6500SetDMPConfig2(uint8_t config) { - i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_DMP_CFG_2, config); + // i2cdevWriteByte(I2Cx, devAddr, MPU6500_RA_DMP_CFG_2, config); } diff --git a/crazyflie_software/crazyflie-firmware-2021.06/src/drivers/src/ms5611.c b/crazyflie_software/crazyflie-firmware-2021.06/src/drivers/src/ms5611.c index 33dabcffea2b1be7321361e17744f65a929601b1..129c1b0560171d12e55bbbb15467deb9a3d595c3 100644 --- a/crazyflie_software/crazyflie-firmware-2021.06/src/drivers/src/ms5611.c +++ b/crazyflie_software/crazyflie-firmware-2021.06/src/drivers/src/ms5611.c @@ -70,106 +70,109 @@ static int32_t tempDeltaT; bool ms5611Init(I2C_Dev *i2cPort) { - if (isInit) - return true; + // if (isInit) + // return true; - I2Cx = i2cPort; - devAddr = MS5611_ADDR_CSB_LOW; + // I2Cx = i2cPort; + // devAddr = MS5611_ADDR_CSB_LOW; - ms5611Reset(); // reset the device to populate its internal PROM registers - vTaskDelay(M2T(5)); - if (ms5611ReadPROM() == false) // reads the PROM into object variables for later use - { - return false; - } + // ms5611Reset(); // reset the device to populate its internal PROM registers + // vTaskDelay(M2T(5)); + // if (ms5611ReadPROM() == false) // reads the PROM into object variables for later use + // { + // return false; + // } - isInit = true; + // isInit = true; return true; } bool ms5611SelfTest(void) { - bool testStatus = true; - int32_t rawPress; - int32_t rawTemp; - int32_t deltaT; - float pressure; - float temperature; - - if (!isInit) - return false; - - ms5611StartConversion(MS5611_D1 + MS5611_OSR_4096); - vTaskDelay(M2T(CONVERSION_TIME_MS)); - rawPress = ms5611GetConversion(MS5611_D1 + MS5611_OSR_4096); - - ms5611StartConversion(MS5611_D2 + MS5611_OSR_4096); - vTaskDelay(M2T(CONVERSION_TIME_MS)); - rawTemp = ms5611GetConversion(MS5611_D2 + MS5611_OSR_4096); - - deltaT = ms5611CalcDeltaTemp(rawTemp); - temperature = ms5611CalcTemp(deltaT); - pressure = ms5611CalcPressure(rawPress, deltaT); - - if (ms5611EvaluateSelfTest(MS5611_ST_PRESS_MIN, MS5611_ST_PRESS_MAX, pressure, "pressure") && - ms5611EvaluateSelfTest(MS5611_ST_TEMP_MIN, MS5611_ST_TEMP_MAX, temperature, "temperature")) - { - DEBUG_PRINT("Self test [OK].\n"); - } - else - { - testStatus = false; - } - - return testStatus; + // bool testStatus = true; + // int32_t rawPress; + // int32_t rawTemp; + // int32_t deltaT; + // float pressure; + // float temperature; + + // if (!isInit) + // return false; + + // ms5611StartConversion(MS5611_D1 + MS5611_OSR_4096); + // vTaskDelay(M2T(CONVERSION_TIME_MS)); + // rawPress = ms5611GetConversion(MS5611_D1 + MS5611_OSR_4096); + + // ms5611StartConversion(MS5611_D2 + MS5611_OSR_4096); + // vTaskDelay(M2T(CONVERSION_TIME_MS)); + // rawTemp = ms5611GetConversion(MS5611_D2 + MS5611_OSR_4096); + + // deltaT = ms5611CalcDeltaTemp(rawTemp); + // temperature = ms5611CalcTemp(deltaT); + // pressure = ms5611CalcPressure(rawPress, deltaT); + + // if (ms5611EvaluateSelfTest(MS5611_ST_PRESS_MIN, MS5611_ST_PRESS_MAX, pressure, "pressure") && + // ms5611EvaluateSelfTest(MS5611_ST_TEMP_MIN, MS5611_ST_TEMP_MAX, temperature, "temperature")) + // { + // DEBUG_PRINT("Self test [OK].\n"); + // } + // else + // { + // testStatus = false; + // } + + // return testStatus; + return true; } bool ms5611EvaluateSelfTest(float min, float max, float value, char* string) { - if (value < min || value > max) - { - DEBUG_PRINT("Self test %s [FAIL]. low: %0.2f, high: %0.2f, measured: %0.2f\n", - string, (double)min, (double)max, (double)value); - return false; - } + // if (value < min || value > max) + // { + // DEBUG_PRINT("Self test %s [FAIL]. low: %0.2f, high: %0.2f, measured: %0.2f\n", + // string, (double)min, (double)max, (double)value); + // return false; + // } return true; } float ms5611GetPressure(uint8_t osr) { - // see datasheet page 7 for formulas - int32_t rawPress = ms5611RawPressure(osr); - int64_t dT = (int64_t)ms5611GetDeltaTemp(osr); - if (dT == 0) - { - return 0; - } - int64_t off = (((int64_t)calReg.off) << 16) + ((calReg.tco * dT) >> 7); - int64_t sens = (((int64_t)calReg.psens) << 15) + ((calReg.tcs * dT) >> 8); - if (rawPress != 0) - { - return ((((rawPress * sens) >> 21) - off) >> (15 - EXTRA_PRECISION)) - / ((1 << EXTRA_PRECISION) * 100.0); - } - else - { - return 0; - } + // // see datasheet page 7 for formulas + // int32_t rawPress = ms5611RawPressure(osr); + // int64_t dT = (int64_t)ms5611GetDeltaTemp(osr); + // if (dT == 0) + // { + // return 0; + // } + // int64_t off = (((int64_t)calReg.off) << 16) + ((calReg.tco * dT) >> 7); + // int64_t sens = (((int64_t)calReg.psens) << 15) + ((calReg.tcs * dT) >> 8); + // if (rawPress != 0) + // { + // return ((((rawPress * sens) >> 21) - off) >> (15 - EXTRA_PRECISION)) + // / ((1 << EXTRA_PRECISION) * 100.0); + // } + // else + // { + // return 0; + // } + + return 1.0; } float ms5611CalcPressure(int32_t rawPress, int32_t dT) { - int64_t off; - int64_t sens; + // int64_t off; + // int64_t sens; - if (rawPress == 0 || dT == 0) - { - return 0; - } + // if (rawPress == 0 || dT == 0) + // { + // return 0; + // } - off = (((int64_t)calReg.off) << 16) + ((calReg.tco * (int64_t)dT) >> 7); - sens = (((int64_t)calReg.psens) << 15) + ((calReg.tcs * (int64_t)dT) >> 8); + // off = (((int64_t)calReg.off) << 16) + ((calReg.tco * (int64_t)dT) >> 7); + // sens = (((int64_t)calReg.psens) << 15) + ((calReg.tcs * (int64_t)dT) >> 8); return ((((rawPress * sens) >> 21) - off) >> (15 - EXTRA_PRECISION)) / ((1 << EXTRA_PRECISION) * 100.0); @@ -177,10 +180,10 @@ float ms5611CalcPressure(int32_t rawPress, int32_t dT) float ms5611GetTemperature(uint8_t osr) { - // see datasheet page 7 for formulas - int32_t dT; + // // see datasheet page 7 for formulas + // int32_t dT; - dT = ms5611GetDeltaTemp(osr); + // dT = ms5611GetDeltaTemp(osr); if (dT != 0) { return ms5611CalcTemp(dT); @@ -193,7 +196,7 @@ float ms5611GetTemperature(uint8_t osr) int32_t ms5611GetDeltaTemp(uint8_t osr) { - int32_t rawTemp = ms5611RawTemperature(osr); + // int32_t rawTemp = ms5611RawTemperature(osr); if (rawTemp != 0) { return ms5611CalcDeltaTemp(rawTemp); @@ -206,87 +209,92 @@ int32_t ms5611GetDeltaTemp(uint8_t osr) float ms5611CalcTemp(int32_t deltaT) { - if (deltaT == 0) - { - return 0; - } - else - { - return (float)(((1 << EXTRA_PRECISION) * 2000) - + (((int64_t)deltaT * calReg.tsens) >> (23 - EXTRA_PRECISION))) - / ((1 << EXTRA_PRECISION)* 100.0f); - } + // if (deltaT == 0) + // { + // return 0; + // } + // else + // { + // return (float)(((1 << EXTRA_PRECISION) * 2000) + // + (((int64_t)deltaT * calReg.tsens) >> (23 - EXTRA_PRECISION))) + // / ((1 << EXTRA_PRECISION)* 100.0f); + // } + return 1.0; } int32_t ms5611CalcDeltaTemp(int32_t rawTemp) { - if (rawTemp == 0) - { - return 0; - } - else - { - return rawTemp - (((int32_t)calReg.tref) << 8); - } + // if (rawTemp == 0) + // { + // return 0; + // } + // else + // { + // return rawTemp - (((int32_t)calReg.tref) << 8); + // } + return 1.0; } int32_t ms5611RawPressure(uint8_t osr) { - uint32_t now = xTaskGetTickCount(); - if (lastPresConv != 0 && (now - lastPresConv) >= CONVERSION_TIME_MS) - { - lastPresConv = 0; - return ms5611GetConversion(MS5611_D1 + osr); - } - else - { - if (lastPresConv == 0 && lastTempConv == 0) - { - ms5611StartConversion(MS5611_D1 + osr); - lastPresConv = now; - } - return 0; - } + // uint32_t now = xTaskGetTickCount(); + // if (lastPresConv != 0 && (now - lastPresConv) >= CONVERSION_TIME_MS) + // { + // lastPresConv = 0; + // return ms5611GetConversion(MS5611_D1 + osr); + // } + // else + // { + // if (lastPresConv == 0 && lastTempConv == 0) + // { + // ms5611StartConversion(MS5611_D1 + osr); + // lastPresConv = now; + // } + // return 0; + // } + return 1.0; } int32_t ms5611RawTemperature(uint8_t osr) { - uint32_t now = xTaskGetTickCount(); - if (lastTempConv != 0 && (now - lastTempConv) >= CONVERSION_TIME_MS) - { - lastTempConv = 0; - tempCache = ms5611GetConversion(MS5611_D2 + osr); - return tempCache; - } - else - { - if (lastTempConv == 0 && lastPresConv == 0) - { - ms5611StartConversion(MS5611_D2 + osr); - lastTempConv = now; - } - return tempCache; - } + // uint32_t now = xTaskGetTickCount(); + // if (lastTempConv != 0 && (now - lastTempConv) >= CONVERSION_TIME_MS) + // { + // lastTempConv = 0; + // tempCache = ms5611GetConversion(MS5611_D2 + osr); + // return tempCache; + // } + // else + // { + // if (lastTempConv == 0 && lastPresConv == 0) + // { + // ms5611StartConversion(MS5611_D2 + osr); + // lastTempConv = now; + // } + // return tempCache; + // } + return 1; + } // see page 11 of the datasheet void ms5611StartConversion(uint8_t command) { // initialize pressure conversion - i2cdevWriteByte(I2Cx, devAddr, I2CDEV_NO_MEM_ADDR, command); + // i2cdevWriteByte(I2Cx, devAddr, I2CDEV_NO_MEM_ADDR, command); } int32_t ms5611GetConversion(uint8_t command) { - int32_t conversion = 0; - uint8_t buffer[MS5611_D1D2_SIZE]; + // int32_t conversion = 0; + // uint8_t buffer[MS5611_D1D2_SIZE]; - // start read sequence - i2cdevWriteByte(I2Cx, devAddr, I2CDEV_NO_MEM_ADDR, 0); - // Read conversion - i2cdevRead(I2Cx, devAddr, MS5611_D1D2_SIZE, buffer); - conversion = ((int32_t)buffer[0] << 16) | - ((int32_t)buffer[1] << 8) | buffer[2]; + // // start read sequence + // i2cdevWriteByte(I2Cx, devAddr, I2CDEV_NO_MEM_ADDR, 0); + // // Read conversion + // i2cdevRead(I2Cx, devAddr, MS5611_D1D2_SIZE, buffer); + // conversion = ((int32_t)buffer[0] << 16) | + // ((int32_t)buffer[1] << 8) | buffer[2]; return conversion; } @@ -296,23 +304,23 @@ int32_t ms5611GetConversion(uint8_t command) */ bool ms5611ReadPROM() { - uint8_t buffer[MS5611_PROM_REG_SIZE]; - uint16_t* pCalRegU16 = (uint16_t*)&calReg; - int32_t i = 0; - bool status = false; - - for (i = 0; i < MS5611_PROM_REG_COUNT; i++) - { - // start read sequence - status = i2cdevWriteByte(I2Cx, devAddr, I2CDEV_NO_MEM_ADDR, - MS5611_PROM_BASE_ADDR + (i * MS5611_PROM_REG_SIZE)); - // Read conversion - if (status) - { - status = i2cdevRead(I2Cx, devAddr, MS5611_PROM_REG_SIZE, buffer); - pCalRegU16[i] = ((uint16_t)buffer[0] << 8) | buffer[1]; - } - } + // uint8_t buffer[MS5611_PROM_REG_SIZE]; + // uint16_t* pCalRegU16 = (uint16_t*)&calReg; + // int32_t i = 0; + // bool status = false; + + // for (i = 0; i < MS5611_PROM_REG_COUNT; i++) + // { + // // start read sequence + // status = i2cdevWriteByte(I2Cx, devAddr, I2CDEV_NO_MEM_ADDR, + // MS5611_PROM_BASE_ADDR + (i * MS5611_PROM_REG_SIZE)); + // // Read conversion + // if (status) + // { + // status = i2cdevRead(I2Cx, devAddr, MS5611_PROM_REG_SIZE, buffer); + // pCalRegU16[i] = ((uint16_t)buffer[0] << 8) | buffer[1]; + // } + // } return status; } @@ -323,7 +331,7 @@ bool ms5611ReadPROM() */ void ms5611Reset() { - i2cdevWriteByte(I2Cx, devAddr, I2CDEV_NO_MEM_ADDR, MS5611_RESET); + // i2cdevWriteByte(I2Cx, devAddr, I2CDEV_NO_MEM_ADDR, MS5611_RESET); } @@ -336,51 +344,51 @@ void ms5611Reset() */ void ms5611GetData(float* pressure, float* temperature, float* asl) { - int32_t tempPressureRaw, tempTemperatureRaw; - static float savedPress, savedTemp; - - // Dont reader faster than we can - uint32_t now = xTaskGetTickCount(); - if ((now - lastConv) < CONVERSION_TIME_MS) - { - *pressure = savedPress; - *temperature = savedTemp; - return; - } - lastConv = now; - - if (readState == 0) - { - // read temp - ++readState; - tempTemperatureRaw = ms5611GetConversion(MS5611_D2 + MS5611_OSR_DEFAULT); - tempDeltaT = ms5611CalcDeltaTemp(tempTemperatureRaw); - *temperature = ms5611CalcTemp(tempDeltaT); - savedTemp = *temperature; - *pressure = savedPress; - // cmd to read pressure - ms5611StartConversion(MS5611_D1 + MS5611_OSR_DEFAULT); - } - else - { - // read pressure - ++readState; - tempPressureRaw = ms5611GetConversion(MS5611_D1 + MS5611_OSR_DEFAULT); - *pressure = ms5611CalcPressure(tempPressureRaw, tempDeltaT); - savedPress = *pressure; - *asl = ms5611PressureToAltitude(pressure); - *temperature = savedTemp; - if (readState == PRESSURE_PER_TEMP){ - // cmd to read temp - ms5611StartConversion(MS5611_D2 + MS5611_OSR_DEFAULT); - readState = 0; - } - else - { - // cmd to read pressure - ms5611StartConversion(MS5611_D1 + MS5611_OSR_DEFAULT); - } - } + // int32_t tempPressureRaw, tempTemperatureRaw; + // static float savedPress, savedTemp; + + // // Dont reader faster than we can + // uint32_t now = xTaskGetTickCount(); + // if ((now - lastConv) < CONVERSION_TIME_MS) + // { + // *pressure = savedPress; + // *temperature = savedTemp; + // return; + // } + // lastConv = now; + + // if (readState == 0) + // { + // // read temp + // ++readState; + // tempTemperatureRaw = ms5611GetConversion(MS5611_D2 + MS5611_OSR_DEFAULT); + // tempDeltaT = ms5611CalcDeltaTemp(tempTemperatureRaw); + // *temperature = ms5611CalcTemp(tempDeltaT); + // savedTemp = *temperature; + // *pressure = savedPress; + // // cmd to read pressure + // ms5611StartConversion(MS5611_D1 + MS5611_OSR_DEFAULT); + // } + // else + // { + // // read pressure + // ++readState; + // tempPressureRaw = ms5611GetConversion(MS5611_D1 + MS5611_OSR_DEFAULT); + // *pressure = ms5611CalcPressure(tempPressureRaw, tempDeltaT); + // savedPress = *pressure; + // *asl = ms5611PressureToAltitude(pressure); + // *temperature = savedTemp; + // if (readState == PRESSURE_PER_TEMP){ + // // cmd to read temp + // ms5611StartConversion(MS5611_D2 + MS5611_OSR_DEFAULT); + // readState = 0; + // } + // else + // { + // // cmd to read pressure + // ms5611StartConversion(MS5611_D1 + MS5611_OSR_DEFAULT); + // } + // } } //TODO: pretty expensive function. Rather smooth the pressure estimates and only call this when needed @@ -390,14 +398,15 @@ void ms5611GetData(float* pressure, float* temperature, float* asl) */ float ms5611PressureToAltitude(float* pressure/*, float* ground_pressure, float* ground_temp*/) { - if (*pressure > 0) - { - //return (1.f - powf(*pressure / CONST_SEA_PRESSURE, CONST_PF)) * CONST_PF2; - //return ((powf((1015.7f / *pressure), CONST_PF) - 1.0f) * (25.f + 273.15f)) / 0.0065f; - return ((powf((1015.7f / *pressure), CONST_PF) - 1.0f) * (FIX_TEMP + 273.15f)) / 0.0065f; - } - else - { - return 0; - } + // if (*pressure > 0) + // { + // //return (1.f - powf(*pressure / CONST_SEA_PRESSURE, CONST_PF)) * CONST_PF2; + // //return ((powf((1015.7f / *pressure), CONST_PF) - 1.0f) * (25.f + 273.15f)) / 0.0065f; + // return ((powf((1015.7f / *pressure), CONST_PF) - 1.0f) * (FIX_TEMP + 273.15f)) / 0.0065f; + // } + // else + // { + // return 0; + // } + return 1.0; } diff --git a/crazyflie_software/crazyflie-firmware-2021.06/src/drivers/src/nrf24l01.c b/crazyflie_software/crazyflie-firmware-2021.06/src/drivers/src/nrf24l01.c index c50d3fa5c30fa6b3ed9381c92fd961da2b3ccb21..eb6cec301ad055809006b14caf916d64bab40c9d 100644 --- a/crazyflie_software/crazyflie-firmware-2021.06/src/drivers/src/nrf24l01.c +++ b/crazyflie_software/crazyflie-firmware-2021.06/src/drivers/src/nrf24l01.c @@ -105,14 +105,14 @@ static void (*interruptCb)(void) = NULL; ***********************/ static char spiSendByte(char byte) { - /* Loop while DR register in not emplty */ - while (SPI_I2S_GetFlagStatus(RADIO_SPI, SPI_I2S_FLAG_TXE) == RESET); + // /* Loop while DR register in not emplty */ + // while (SPI_I2S_GetFlagStatus(RADIO_SPI, SPI_I2S_FLAG_TXE) == RESET); - /* Send byte through the SPI1 peripheral */ - SPI_I2S_SendData(RADIO_SPI, byte); + // /* Send byte through the SPI1 peripheral */ + // SPI_I2S_SendData(RADIO_SPI, byte); - /* Wait to receive a byte */ - while (SPI_I2S_GetFlagStatus(RADIO_SPI, SPI_I2S_FLAG_RXNE) == RESET); + // /* Wait to receive a byte */ + // while (SPI_I2S_GetFlagStatus(RADIO_SPI, SPI_I2S_FLAG_RXNE) == RESET); /* Return the byte read from the SPI bus */ return SPI_I2S_ReceiveData(RADIO_SPI); @@ -130,18 +130,18 @@ static char spiReceiveByte() /* Read len bytes from a nRF24L register. 5 Bytes max */ unsigned char nrfReadReg(unsigned char address, char *buffer, int len) { - unsigned char status; - int i; + // unsigned char status; + // int i; - RADIO_EN_CS(); + // RADIO_EN_CS(); - /* Send the read command with the address */ - status = spiSendByte( CMD_R_REG | (address&0x1F) ); - /* Read LEN bytes */ - for(i=0; i<len; i++) - buffer[i]=spiReceiveByte(); + // /* Send the read command with the address */ + // status = spiSendByte( CMD_R_REG | (address&0x1F) ); + // /* Read LEN bytes */ + // for(i=0; i<len; i++) + // buffer[i]=spiReceiveByte(); - RADIO_DIS_CS(); + // RADIO_DIS_CS(); return status; } @@ -149,18 +149,18 @@ unsigned char nrfReadReg(unsigned char address, char *buffer, int len) /* Write len bytes a nRF24L register. 5 Bytes max */ unsigned char nrfWriteReg(unsigned char address, char *buffer, int len) { - unsigned char status; - int i; + // unsigned char status; + // int i; - RADIO_EN_CS(); + // RADIO_EN_CS(); - /* Send the write command with the address */ - status = spiSendByte( CMD_W_REG | (address&0x1F) ); - /* Write LEN bytes */ - for(i=0; i<len; i++) - spiSendByte(buffer[i]); + // /* Send the write command with the address */ + // status = spiSendByte( CMD_W_REG | (address&0x1F) ); + // /* Write LEN bytes */ + // for(i=0; i<len; i++) + // spiSendByte(buffer[i]); - RADIO_DIS_CS(); + // RADIO_DIS_CS(); return status; } @@ -173,9 +173,9 @@ unsigned char nrfWrite1Reg(unsigned char address, char byte) /* Read only one byte (useful for most of the reg.) */ unsigned char nrfRead1Reg(unsigned char address) { - char byte; + // char byte; - nrfReadReg(address, &byte, 1); + // nrfReadReg(address, &byte, 1); return byte; } @@ -183,33 +183,33 @@ unsigned char nrfRead1Reg(unsigned char address) { /* Sent the NOP command. Used to get the status byte */ unsigned char nrfNop() { - unsigned char status; + // unsigned char status; - RADIO_EN_CS(); - status = spiSendByte(CMD_NOP); - RADIO_DIS_CS(); + // RADIO_EN_CS(); + // status = spiSendByte(CMD_NOP); + // RADIO_DIS_CS(); return status; } unsigned char nrfFlushRx() { - unsigned char status; + // unsigned char status; - RADIO_EN_CS(); - status = spiSendByte(CMD_FLUSH_RX); - RADIO_DIS_CS(); + // RADIO_EN_CS(); + // status = spiSendByte(CMD_FLUSH_RX); + // RADIO_DIS_CS(); return status; } unsigned char nrfFlushTx() { - unsigned char status; + // unsigned char status; - RADIO_EN_CS(); - status = spiSendByte(CMD_FLUSH_TX); - RADIO_DIS_CS(); + // RADIO_EN_CS(); + // status = spiSendByte(CMD_FLUSH_TX); + // RADIO_DIS_CS(); return status; } @@ -217,24 +217,24 @@ unsigned char nrfFlushTx() // Return the payload length unsigned char nrfRxLength(unsigned int pipe) { - unsigned char length; + // unsigned char length; - RADIO_EN_CS(); - spiSendByte(CMD_RX_PL_WID); - length = spiReceiveByte(); - RADIO_DIS_CS(); + // RADIO_EN_CS(); + // spiSendByte(CMD_RX_PL_WID); + // length = spiReceiveByte(); + // RADIO_DIS_CS(); return length; } unsigned char nrfActivate() { - unsigned char status; + // unsigned char status; - RADIO_EN_CS(); - status = spiSendByte(CMD_ACTIVATE); - spiSendByte(ACTIVATE_DATA); - RADIO_DIS_CS(); + // RADIO_EN_CS(); + // status = spiSendByte(CMD_ACTIVATE); + // spiSendByte(ACTIVATE_DATA); + // RADIO_DIS_CS(); return status; } @@ -242,20 +242,20 @@ unsigned char nrfActivate() // Write the ack payload of the pipe 0 unsigned char nrfWriteAck(unsigned int pipe, char *buffer, int len) { - unsigned char status; - int i; + // unsigned char status; + // int i; - ASSERT(pipe<6); + // ASSERT(pipe<6); - RADIO_EN_CS(); + // RADIO_EN_CS(); - /* Send the read command with the address */ - status = spiSendByte(CMD_W_ACK_PAYLOAD(pipe)); - /* Read LEN bytes */ - for(i=0; i<len; i++) - spiSendByte(buffer[i]); + // /* Send the read command with the address */ + // status = spiSendByte(CMD_W_ACK_PAYLOAD(pipe)); + // /* Read LEN bytes */ + // for(i=0; i<len; i++) + // spiSendByte(buffer[i]); - RADIO_DIS_CS(); + // RADIO_DIS_CS(); return status; } @@ -263,18 +263,18 @@ unsigned char nrfWriteAck(unsigned int pipe, char *buffer, int len) // Read the RX payload unsigned char nrfReadRX(char *buffer, int len) { - unsigned char status; - int i; + // unsigned char status; + // int i; - RADIO_EN_CS(); + // RADIO_EN_CS(); - /* Send the read command with the address */ - status = spiSendByte(CMD_R_RX_PAYLOAD); - /* Read LEN bytes */ - for(i=0; i<len; i++) - buffer[i]=spiReceiveByte(); + // /* Send the read command with the address */ + // status = spiSendByte(CMD_R_RX_PAYLOAD); + // /* Read LEN bytes */ + // for(i=0; i<len; i++) + // buffer[i]=spiReceiveByte(); - RADIO_DIS_CS(); + // RADIO_DIS_CS(); return status; } @@ -282,150 +282,150 @@ unsigned char nrfReadRX(char *buffer, int len) /* Interrupt service routine, call the interrupt callback */ void __attribute__((used)) EXTI9_Callback(void) { - if (interruptCb) - { - interruptCb(); - } + // if (interruptCb) + // { + // interruptCb(); + // } } void nrfSetInterruptCallback(void (*cb)(void)) { - interruptCb = cb; + // interruptCb = cb; } void nrfSetChannel(unsigned int channel) { - if (channel<126) - nrfWrite1Reg(REG_RF_CH, channel); + // if (channel<126) + // nrfWrite1Reg(REG_RF_CH, channel); } void nrfSetDatarate(int datarate) { - switch(datarate) - { - case RADIO_RATE_250K: - nrfWrite1Reg(REG_RF_SETUP, VAL_RF_SETUP_250K); - break; - case RADIO_RATE_1M: - nrfWrite1Reg(REG_RF_SETUP, VAL_RF_SETUP_1M); - break; - case RADIO_RATE_2M: - nrfWrite1Reg(REG_RF_SETUP, VAL_RF_SETUP_2M); - break; - } + // switch(datarate) + // { + // case RADIO_RATE_250K: + // nrfWrite1Reg(REG_RF_SETUP, VAL_RF_SETUP_250K); + // break; + // case RADIO_RATE_1M: + // nrfWrite1Reg(REG_RF_SETUP, VAL_RF_SETUP_1M); + // break; + // case RADIO_RATE_2M: + // nrfWrite1Reg(REG_RF_SETUP, VAL_RF_SETUP_2M); + // break; + // } } void nrfSetAddress(unsigned int pipe, char* address) { - int len = 5; + // int len = 5; - ASSERT(pipe<6); + // ASSERT(pipe<6); - if (pipe > 1) - len = 1; + // if (pipe > 1) + // len = 1; - nrfWriteReg(REG_RX_ADDR_P0 + pipe, address, len); + // nrfWriteReg(REG_RX_ADDR_P0 + pipe, address, len); } void nrfSetEnable(bool enable) { - if (enable) - { - RADIO_EN_CE(); - } - else - { - RADIO_DIS_CE(); - } + // if (enable) + // { + // RADIO_EN_CE(); + // } + // else + // { + // RADIO_DIS_CE(); + // } } unsigned char nrfGetStatus() { - return nrfNop(); + // return nrfNop(); } /* Initialisation */ void nrfInit(void) { - SPI_InitTypeDef SPI_InitStructure; - EXTI_InitTypeDef EXTI_InitStructure; - GPIO_InitTypeDef GPIO_InitStructure; - - if (isInit) - return; - - /* Enable SPI and GPIO clocks */ - RCC_APB2PeriphClockCmd(RADIO_GPIO_SPI_CLK | RADIO_GPIO_CS_PERIF | - RADIO_GPIO_CE_PERIF | RADIO_GPIO_IRQ_PERIF, ENABLE); - - /* Enable SPI and GPIO clocks */ - RCC_APB1PeriphClockCmd(RADIO_SPI_CLK, ENABLE); - - /* Configure main clock */ - GPIO_InitStructure.GPIO_Pin = RADIO_GPIO_CLK; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; - GPIO_Init(RADIO_GPIO_CLK_PORT, &GPIO_InitStructure); - - /* Configure SPI pins: SCK, MISO and MOSI */ - GPIO_InitStructure.GPIO_Pin = RADIO_GPIO_SPI_SCK | RADIO_GPIO_SPI_MOSI; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; - GPIO_Init(RADIO_GPIO_SPI_PORT, &GPIO_InitStructure); - - //* Configure MISO */ - GPIO_InitStructure.GPIO_Pin = RADIO_GPIO_SPI_MISO; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; - GPIO_Init(RADIO_GPIO_SPI_PORT, &GPIO_InitStructure); - - /* Configure I/O for the Chip select */ - GPIO_InitStructure.GPIO_Pin = RADIO_GPIO_CS; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; - GPIO_Init(RADIO_GPIO_CS_PORT, &GPIO_InitStructure); - - /* Configure the interruption (EXTI Source) */ - GPIO_InitStructure.GPIO_Pin = RADIO_GPIO_IRQ; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; - GPIO_Init(RADIO_GPIO_IRQ_PORT, &GPIO_InitStructure); - - GPIO_EXTILineConfig(RADIO_GPIO_IRQ_SRC_PORT, RADIO_GPIO_IRQ_SRC); - EXTI_InitStructure.EXTI_Line = RADIO_GPIO_IRQ_LINE; - EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; - EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling; - EXTI_InitStructure.EXTI_LineCmd = ENABLE; - EXTI_Init(&EXTI_InitStructure); - - // Clock the radio with 16MHz - RCC_MCOConfig(RCC_MCO_HSE); - - /* disable the chip select */ - RADIO_DIS_CS(); - - /* Configure I/O for the Chip Enable */ - GPIO_InitStructure.GPIO_Pin = RADIO_GPIO_CE; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; - GPIO_Init(RADIO_GPIO_CE_PORT, &GPIO_InitStructure); - - /* disable the chip enable */ - RADIO_DIS_CE(); - - /* SPI configuration */ - SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex; - SPI_InitStructure.SPI_Mode = SPI_Mode_Master; - SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b; - SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low; - SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge; - SPI_InitStructure.SPI_NSS = SPI_NSS_Soft; - SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_8; - SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB; - SPI_InitStructure.SPI_CRCPolynomial = 7; - SPI_Init(RADIO_SPI, &SPI_InitStructure); - - /* Enable the SPI */ - SPI_Cmd(RADIO_SPI, ENABLE); + // SPI_InitTypeDef SPI_InitStructure; + // EXTI_InitTypeDef EXTI_InitStructure; + // GPIO_InitTypeDef GPIO_InitStructure; + + // if (isInit) + // return; + + // /* Enable SPI and GPIO clocks */ + // RCC_APB2PeriphClockCmd(RADIO_GPIO_SPI_CLK | RADIO_GPIO_CS_PERIF | + // RADIO_GPIO_CE_PERIF | RADIO_GPIO_IRQ_PERIF, ENABLE); + + // /* Enable SPI and GPIO clocks */ + // RCC_APB1PeriphClockCmd(RADIO_SPI_CLK, ENABLE); + + // /* Configure main clock */ + // GPIO_InitStructure.GPIO_Pin = RADIO_GPIO_CLK; + // GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; + // GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + // GPIO_Init(RADIO_GPIO_CLK_PORT, &GPIO_InitStructure); + + // /* Configure SPI pins: SCK, MISO and MOSI */ + // GPIO_InitStructure.GPIO_Pin = RADIO_GPIO_SPI_SCK | RADIO_GPIO_SPI_MOSI; + // GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; + // GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + // GPIO_Init(RADIO_GPIO_SPI_PORT, &GPIO_InitStructure); + + // //* Configure MISO */ + // GPIO_InitStructure.GPIO_Pin = RADIO_GPIO_SPI_MISO; + // GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; + // GPIO_Init(RADIO_GPIO_SPI_PORT, &GPIO_InitStructure); + + // /* Configure I/O for the Chip select */ + // GPIO_InitStructure.GPIO_Pin = RADIO_GPIO_CS; + // GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; + // GPIO_Init(RADIO_GPIO_CS_PORT, &GPIO_InitStructure); + + // /* Configure the interruption (EXTI Source) */ + // GPIO_InitStructure.GPIO_Pin = RADIO_GPIO_IRQ; + // GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + // GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; + // GPIO_Init(RADIO_GPIO_IRQ_PORT, &GPIO_InitStructure); + + // GPIO_EXTILineConfig(RADIO_GPIO_IRQ_SRC_PORT, RADIO_GPIO_IRQ_SRC); + // EXTI_InitStructure.EXTI_Line = RADIO_GPIO_IRQ_LINE; + // EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; + // EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling; + // EXTI_InitStructure.EXTI_LineCmd = ENABLE; + // EXTI_Init(&EXTI_InitStructure); + + // // Clock the radio with 16MHz + // RCC_MCOConfig(RCC_MCO_HSE); + + // /* disable the chip select */ + // RADIO_DIS_CS(); + + // /* Configure I/O for the Chip Enable */ + // GPIO_InitStructure.GPIO_Pin = RADIO_GPIO_CE; + // GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; + // GPIO_Init(RADIO_GPIO_CE_PORT, &GPIO_InitStructure); + + // /* disable the chip enable */ + // RADIO_DIS_CE(); + + // /* SPI configuration */ + // SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex; + // SPI_InitStructure.SPI_Mode = SPI_Mode_Master; + // SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b; + // SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low; + // SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge; + // SPI_InitStructure.SPI_NSS = SPI_NSS_Soft; + // SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_8; + // SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB; + // SPI_InitStructure.SPI_CRCPolynomial = 7; + // SPI_Init(RADIO_SPI, &SPI_InitStructure); + + // /* Enable the SPI */ + // SPI_Cmd(RADIO_SPI, ENABLE); - isInit = true; + // isInit = true; } bool nrfTest(void)