// Switch to overdrive speed -- 3 tries static GOOD_OR_BAD DS9490_overdrive(const struct parsedname *pn) { BYTE sp = _1W_OVERDRIVE_SKIP_ROM; BYTE resp; int i; // we need to change speed to overdrive for (i = 0; i < 3; i++) { LEVEL_DATA("set overdrive speed. Attempt %d",i); if ( BAD( gbRESET(BUS_reset(pn)) ) ) { continue; } if ( BAD( DS9490_sendback_data(&sp, &resp, 1, pn) ) || (_1W_OVERDRIVE_SKIP_ROM != resp) ) { LEVEL_DEBUG("error setting overdrive %.2X/0x%02X", _1W_OVERDRIVE_SKIP_ROM, resp); continue; } if ( GOOD( USB_Control_Msg(MODE_CMD, MOD_1WIRE_SPEED, ONEWIREBUSSPEED_OVERDRIVE, pn)) ) { LEVEL_DEBUG("speed is now set to overdrive"); return gbGOOD; } } LEVEL_DEBUG("Error setting overdrive after 3 retries"); return gbBAD; }
// do the configuration stuff static GOOD_OR_BAD DS2480_big_configuration(struct connection_in * in) { BYTE single_bit = CMD_COMM | BITPOL_ONE | DS2480b_speed_byte(in) ; BYTE single_bit_response ; // Now set desired baud and polarity // BUS_reset will do the actual changes in->changed_bus_settings = 1 ; // Force a mode change // Send a reset again DS2480_reset_in(in) ; // delay to let line settle UT_delay(4); // default W1LT = 10us (write-1 low time) RETURN_BAD_IF_BAD(DS2480_configuration_write(PARMSEL_WRITE1LOW, PARMSET_Write10us, in)) ; // default DSO/WORT = 8us (data sample offset / write 0 recovery time ) RETURN_BAD_IF_BAD(DS2480_configuration_write(PARMSEL_SAMPLEOFFSET, PARMSET_SampOff8us, in)) ; // Strong pullup duration = infinite RETURN_BAD_IF_BAD(DS2480_configuration_write(PARMSEL_5VPULSE, PARMSET_infinite, in)) ; // Program pulse duration = 512usec RETURN_BAD_IF_BAD(DS2480_configuration_write(PARMSEL_12VPULSE, PARMSET_512us, in)) ; // Send a single bit // The datasheet wants this RETURN_BAD_IF_BAD(DS2480_sendback_cmd(&single_bit, &single_bit_response, 1, in)) ; /* Apparently need to reset again to get the version number properly */ return gbRESET( DS2480_reset_in(in) ) ; }