uint8_t HMC5883L_GetXYZ(HMC5883L *hmc, int_fp *x, int_fp *y, int_fp *z) { uint8_t data_buffer[6], cmd, ret; int_fp divider_fp; int16_t x_raw, y_raw, z_raw; if (!hmc->connected) return 0; cmd = HMC5883L_REG_X_MSB; ret = MoonLander_I2C_Transaction(hmc->i2c, HMC5883L_I2C_ADDR, &cmd, 1, data_buffer, 6); if (!ret) return 0; x_raw = (data_buffer[0]<<8) | data_buffer[1]; z_raw = (data_buffer[2]<<8) | data_buffer[3]; y_raw = (data_buffer[4]<<8) | data_buffer[5]; divider_fp = FP_INT(hmc->divider); if (x_raw == -4096) (*x) = FP_INT(9000); else { (*x) = FP_INT((int32_t) x_raw); (*x) = int_fp_div((*x), divider_fp); // In Gauss (*x) = int_fp_mul((*x), FP_INT(100)); // In uTesla } if (y_raw == -4096) (*y) = FP_INT(9000); else { (*y) = FP_INT((int32_t) y_raw); (*y) = int_fp_div((*y), divider_fp); // In Gauss (*y) = int_fp_mul((*y), FP_INT(100)); // In uTesla } if (z_raw == -4096) (*z) = FP_INT(9000); else { (*z) = FP_INT((int32_t) z_raw); (*z) = int_fp_div((*z), divider_fp); // In Gauss (*z) = int_fp_mul((*z), FP_INT(100)); // In uTesla } return 1; }
.orig = "int_value", \ .type = FPARAM_INT, \ .v = { \ .i = val \ },\ }; #define FP_STRING(val) { \ .orig = val, \ .type = FPARAM_STR, \ .v = { \ .str = STR_STATIC_INIT(val) \ },\ }; static fparam_t fp_503 = FP_INT(503); static fparam_t fp_server_busy = FP_STRING("Server Unavailable"); static int rl_drop(struct sip_msg * msg, int low, int high) { str hdr = {pkg_malloc(64), 0}; int ret; LOG(L_DBG, "rl_drop(%d, %d sl_reply = %p)\n", low, high, sl_reply); if (! hdr.s) { LOG(L_ERR, "rl_drop: no memory for hdr\n"); return 0; } hdr.len = snprintf(hdr.s, 63, "Retry-After: %d\r\n",