static int fsi2pib_putscom(struct pib *pib, uint64_t addr, uint64_t value) { usleep(FSI2PIB_RELAX); CHECK_ERR(fsi_write(&pib->target, FSI_DATA0_REG, (value >> 32) & 0xffffffff)); CHECK_ERR(fsi_write(&pib->target, FSI_DATA1_REG, value & 0xffffffff)); CHECK_ERR(fsi_write(&pib->target, FSI_CMD_REG, FSI_CMD_REG_WRITE | addr)); return 0; }
static int cfam_hmfsi_probe(struct pdbg_target *target) { struct fsi *fsi = target_to_fsi(target); struct pdbg_target *fsi_parent = target->parent; uint32_t value, port; int rc; /* Enable the port in the upstream control register */ port = dt_prop_get_u32(target, "port"); fsi_read(fsi_parent, 0x3404, &value); value |= 1 << (31 - port); if ((rc = fsi_write(fsi_parent, 0x3404, value))) { PR_ERROR("Unable to enable HMFSI port %d\n", port); return rc; } if ((rc = fsi_read(&fsi->target, 0xc09, &value))) return rc; fsi->chip_type = get_chip_type(value); PR_DEBUG("Found chip type %x\n", fsi->chip_type); if (fsi->chip_type == CHIP_UNKNOWN) return -1; return 0; }
static int cfam_hmfsi_write(struct fsi *fsi, uint32_t addr, uint32_t data) { struct pdbg_target *parent_fsi = pdbg_target_require_parent("fsi", &fsi->target); addr += dt_get_address(&fsi->target, 0, NULL); return fsi_write(parent_fsi, addr, data); }
static int fsi2pib_reset(struct pdbg_target *target) { /* Reset the PIB master interface. We used to reset the entire FSI2PIB * engine but that had the unfortunate side effect of clearing existing * settings such as the true mask register (0xd) */ CHECK_ERR(fsi_write(target, FSI_SET_PIB_RESET_REG, FSI_SET_PIB_RESET)); return 0; }
static int fsi2pib_getscom(struct pib *pib, uint64_t addr, uint64_t *value) { uint32_t result; usleep(FSI2PIB_RELAX); /* Get scom works by putting the address in FSI_CMD_REG and * reading the result from FST_DATA[01]_REG. */ CHECK_ERR(fsi_write(&pib->target, FSI_CMD_REG, addr)); CHECK_ERR(fsi_read(&pib->target, FSI_DATA0_REG, &result)); *value = ((uint64_t) result) << 32; CHECK_ERR(fsi_read(&pib->target, FSI_DATA1_REG, &result)); *value |= result; return 0; }
static error_t tscalib_WndMsgHandler(t_HWindow handle, t_WidgetEvent evt, t_sparam sparam, t_lparam lparam) { t_TSCalibData *glob=(t_TSCalibData*)app_get_data(); error_t ret = NOT_HANDLED; switch(evt){ case WINDOW_OnOpen: g_printf("WINDOW_OnOpen\r\n"); //wgt_enable_attr(handle, WND_ATTR_FULLSCREEN); break; case WINDOW_OnClose: g_printf("WINDOW_OnClose\r\n"); ret = SUCCESS; break; case WINDOW_OnDraw: { coord_t x = gs_calib_const.x[glob->points.n]; coord_t y = gs_calib_const.y[glob->points.n]; gdi_clear(glob->gdi, 0, 0, -1, -1, guiNoCorner); gdi_set_color(glob->gdi, RGB_RED); gdi_line(glob->gdi, x-5, y, x+5, y); gdi_line(glob->gdi, x, y-5, x, y+5); } ret = SUCCESS; break; case WIDGET_OnKeyEvent: if(lparam == MVK_END && sparam == MMI_KEY_PRESS){ task_exit(0); } ret = SUCCESS; break; case WIDGET_OnPenEvent: if(PEN_TYPE(lparam) == MMI_PEN_DOWN){ PEN_XY(lparam, glob->points.x[glob->points.n], glob->points.y[glob->points.n]); glob->points.n++; if(glob->points.n == gs_calib_const.n-1){ if(!glob->vtbl->StartCalib(&gs_calib_const, &glob->points)){ //2 校准失败,重新校准 glob->points.n = 0; } //2 校准成功,等待用户输入最后一点来做验证 }else if(glob->points.n == gs_calib_const.n){ //2 校准成功后,还须用最后一点来做验证 int i = glob->points.n-1; if(ABS(glob->points.x[i] - gs_calib_const.x[i]) <= 5 && ABS(glob->points.y[i] - gs_calib_const.y[i]) <= 5){ //2 校准成功且最后一点验证ok, 保存校准数据 int fd = fsi_open(TS_CALIB_FILE, _O_RDWR | _O_CREAT, _S_IREAD | _S_IWRITE); if(fd >= 0){ fsi_write(fd, &glob->points, sizeof(glob->points)); fsi_close(fd); } task_exit(0); break; }else{ //2 最后一点验证失败,重新校准 glob->points.n = 0; } } wnd_redraw(handle, NULL); } ret = SUCCESS; break; } return ret; }