Example #1
0
// reads to end of page and discards extra
// uses CRC8
static GOOD_OR_BAD OW_r_page(BYTE * data, size_t size, off_t offset, struct parsedname *pn)
{
	BYTE p[4] = { _1W_READ_DATA_CRC8, LOW_HIGH_ADDRESS(offset), };
	BYTE q[33];
	int rest = 33 - (offset & 0x1F);
	struct transaction_log t[] = {
		TRXN_START,
		TRXN_WRITE3(p),
		TRXN_READ1(&p[3]),
		TRXN_CRC8(p, 4),
		TRXN_READ(q, rest),
		TRXN_CRC8(q, rest),
		TRXN_END,
	};
	RETURN_BAD_IF_BAD(BUS_transaction(t, pn)) ;

	memcpy(data, q, size);
	return gbGOOD;
}
Example #2
0
// use new read_all command
static GOOD_OR_BAD OW_r_all(BYTE * data, size_t size, off_t offset, struct parsedname *pn)
{
	BYTE p[4] = { _1W_READ_ALL, LOW_HIGH_ADDRESS(offset), };
	struct transaction_log t[] = {
		TRXN_START,
		TRXN_WRITE3(p),
		TRXN_READ1(&p[3]),
		TRXN_CRC8(p, 4),
		TRXN_READ(data, size),
	};
	RETURN_BAD_IF_BAD(BUS_transaction(t, pn)) ;

	return gbGOOD;
}
Example #3
0
static GOOD_OR_BAD OW_w_byte(BYTE data, off_t offset, struct parsedname *pn)
{
	BYTE p[5] = { _1W_WRITE_MEMORY, LOW_HIGH_ADDRESS(offset), data, 0xFF };
	BYTE q[1];
	struct transaction_log t[] = {
		TRXN_START,
		TRXN_WRITE(p,4),
		TRXN_READ1(&p[4]),
		TRXN_CRC8(p, 4+1),
		TRXN_PROGRAM,
		TRXN_READ1(q),
		TRXN_COMPARE(q,&data,1) ,
		TRXN_END,
	};

	return BUS_transaction(t, pn) ;
}
Example #4
0
// uses CRC8
static GOOD_OR_BAD OW_reading(BYTE * data, struct parsedname *pn)
{
	BYTE p[1] = { _1W_READ_SCRATCHPAD, };
	BYTE q[3];
	struct transaction_log t[] = {
		TRXN_START,
		TRXN_WRITE1(p),
		TRXN_WRITE2(q),
		TRXN_READ1(&q[2]),
		TRXN_CRC8(q,3),
		TRXN_END,
	};
	RETURN_BAD_IF_BAD(BUS_transaction(t, pn)) ;

	memcpy(data, q, 2);
	return gbGOOD;
}