// File: /workspace/github_c_makefile_star2_O0/ZombiesYard[P]MPU6050-DMP-raspberry-pi/MotionSensor/inv_mpu_lib/inv_mpu.c
// Function: mpu_lp_accel_mode(unsigned char)
uint8_t mpu_lp_accel_mode(uint8_t rate)
{
	uint8_t tmp[2];

	if (rate > 40)
		return 1;

	if (!rate)
	{
		mpu_set_int_latched(0);
		tmp[0] = 0;
		tmp[1] = BIT_STBY_XYZG;
		if (i2c_write(st.hw->addr, st.reg->pwr_mgmt_1, 2, tmp))
			return 1;
		st.chip_cfg.lp_accel_mode = 0;
		return 0;
	}
	/* For LP accel, we automatically configure the hardware to produce latched
	 * interrupts. In LP accel mode, the hardware cycles into sleep mode before
	 * it gets a chance to deassert the interrupt pin; therefore, we shift this
	 * responsibility over to the MCU.
	 *
	 * Any register read will clear the interrupt.
	 */
	mpu_set_int_latched(1);
#if defined MPU6050
	tmp[0] = BIT_LPA_CYCLE;
	if (rate == 1)
	{
		tmp[1] = INV_LPA_1_25HZ;
		mpu_set_lpf(5);
	}
	else if (rate <= 5)
	{
		tmp[1] = INV_LPA_5HZ;
		mpu_set_lpf(5);
	}
	else if (rate <= 20)
	{
		tmp[1] = INV_LPA_20HZ;
		mpu_set_lpf(10);
	}
	else
	{
		tmp[1] = INV_LPA_40HZ;
		mpu_set_lpf(20);
	}
	tmp[1] = (tmp[1] << 6) | BIT_STBY_XYZG;
	if (i2c_write(st.hw->addr, st.reg->pwr_mgmt_1, 2, tmp))
		return 1;
#elif defined MPU6500
	/* Set wake frequency. */
	if (rate == 1)
		tmp[0] = INV_LPA_1_25HZ;
	else if (rate == 2)
		tmp[0] = INV_LPA_2_5HZ;
	else if (rate <= 5)
		tmp[0] = INV_LPA_5HZ;
	else if (rate <= 10)
		tmp[0] = INV_LPA_10HZ;
	else if (rate <= 20)
		tmp[0] = INV_LPA_20HZ;
	else if (rate <= 40)
		tmp[0] = INV_LPA_40HZ;
	else if (rate <= 80)
		tmp[0] = INV_LPA_80HZ;
	else if (rate <= 160)
		tmp[0] = INV_LPA_160HZ;
	else if (rate <= 320)
		tmp[0] = INV_LPA_320HZ;
	else
		tmp[0] = INV_LPA_640HZ;
	if (i2c_write(st.hw->addr, st.reg->lp_accel_odr, 1, tmp))
		return 1;
	tmp[0] = BIT_LPA_CYCLE;
	if (i2c_write(st.hw->addr, st.reg->pwr_mgmt_1, 1, tmp))
		return 1;
#endif
	st.chip_cfg.sensors = INV_XYZ_ACCEL;
	st.chip_cfg.clk_src = 0;
	st.chip_cfg.lp_accel_mode = 1;
	mpu_configure_fifo(0);

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movb %dil, %al
movb %al, -0x2(%rbp)
movzbl -0x2(%rbp), %eax
cmpl $0x28, %eax
jle 0x2c10
movb $0x1, -0x1(%rbp)
jmp 0x2d38
cmpb $0x0, -0x2(%rbp)
jne 0x2c6c
xorl %edi, %edi
callq 0x2d50
movb $0x0, -0x4(%rbp)
movb $0x7, -0x3(%rbp)
movq 0x95ec(%rip), %rax      # 0xc218
movb (%rax), %sil
movq 0x95da(%rip), %rax      # 0xc210
movb 0x15(%rax), %al
leaq -0x4(%rbp), %rcx
movl $0x2, %edx
movzbl %sil, %edi
movzbl %al, %esi
callq 0x7360
cmpl $0x0, %eax
je 0x2c5c
movb $0x1, -0x1(%rbp)
jmp 0x2d38
movb $0x0, 0x95d1(%rip)      # 0xc234
movb $0x0, -0x1(%rbp)
jmp 0x2d38
movl $0x1, %edi
callq 0x2d50
movb $0x20, -0x4(%rbp)
movzbl -0x2(%rbp), %eax
cmpl $0x1, %eax
jne 0x2c93
movb $0x0, -0x3(%rbp)
movl $0x5, %edi
callq 0x2590
jmp 0x2cd7
movzbl -0x2(%rbp), %eax
cmpl $0x5, %eax
jg 0x2cac
movb $0x1, -0x3(%rbp)
movl $0x5, %edi
callq 0x2590
jmp 0x2cd5
movzbl -0x2(%rbp), %eax
cmpl $0x14, %eax
jg 0x2cc5
movb $0x2, -0x3(%rbp)
movl $0xa, %edi
callq 0x2590
jmp 0x2cd3
movb $0x3, -0x3(%rbp)
movl $0x14, %edi
callq 0x2590
jmp 0x2cd5
jmp 0x2cd7
movzbl -0x3(%rbp), %eax
shll $0x6, %eax
orl $0x7, %eax
movb %al, -0x3(%rbp)
movq 0x952d(%rip), %rax      # 0xc218
movb (%rax), %sil
movq 0x951b(%rip), %rax      # 0xc210
movb 0x15(%rax), %al
leaq -0x4(%rbp), %rcx
movl $0x2, %edx
movzbl %sil, %edi
movzbl %al, %esi
callq 0x7360
cmpl $0x0, %eax
je 0x2d18
movb $0x1, -0x1(%rbp)
jmp 0x2d38
movb $0x8, 0x950b(%rip)      # 0xc22a
movb $0x0, 0x9506(%rip)      # 0xc22c
movb $0x1, 0x9507(%rip)      # 0xc234
xorl %edi, %edi
callq 0x2780
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)