From 809810048360f991faa351f4eca13da0c770feb0 Mon Sep 17 00:00:00 2001 From: skarg Date: Thu, 23 Sep 2010 00:52:41 +0000 Subject: [PATCH] removed timeout code --- bacnet-stack/ports/bdk-atxx4-mstp/seeprom.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/bacnet-stack/ports/bdk-atxx4-mstp/seeprom.c b/bacnet-stack/ports/bdk-atxx4-mstp/seeprom.c index e623f035..a2619441 100644 --- a/bacnet-stack/ports/bdk-atxx4-mstp/seeprom.c +++ b/bacnet-stack/ports/bdk-atxx4-mstp/seeprom.c @@ -1,6 +1,7 @@ /************************************************************************** * * Copyright (C) 2009 Steve Karg +* Used algorithm and code from Joerg Wunsch and Ruwan Jayanetti. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -25,6 +26,7 @@ #include #include #include "hardware.h" +/* me */ #include "seeprom.h" /* the SEEPROM chip select bits A2, A1, and A0 are grounded */ @@ -88,7 +90,7 @@ * complete, but low enough to properly abort an infinite loop in case * a slave is broken or not present at all. With 100 kHz TWI clock, * transfering the start condition and SLA+R/W packet takes about 10 - * µs. The longest write period is supposed to not exceed ~ 10 ms. + * s. The longest write period is supposed to not exceed ~ 10 ms. * Thus, normal operation should not require more than 100 iterations * to get the device to respond to a selection. */ @@ -276,7 +278,7 @@ int seeprom_bytes_read( * RETURN: number of bytes written, or -1 on error * NOTES: only writes from offset to end of page. **************************************************************************/ -int seeprom_bytes_write_page( +static int seeprom_bytes_write_page( uint16_t eeaddr, /* SEEPROM starting memory address */ uint8_t * buf, /* data to send */ int len) @@ -413,14 +415,14 @@ int seeprom_bytes_write_page( /************************************************************************* * DESCRIPTION: Write some data and wait until it is sent * RETURN: number of bytes written, or -1 on error -* NOTES: -* When the word address, internally generated, +* NOTES: +* When the word address, internally generated, * reaches the page boundary, the following -* byte is placed at the beginning of the same +* byte is placed at the beginning of the same * page. If more than 64 data words are -* transmitted to the EEPROM, the data word -* address will “roll over” and previous data will be -* overwritten. The address “roll over” during write +* transmitted to the EEPROM, the data word +* address will "roll over" and previous data will be +* overwritten. The address "roll over" during write * is from the last byte of the current page to the * first byte of the same page. **************************************************************************/ @@ -461,6 +463,8 @@ void seeprom_init( TWSR = 0; TWCR = _BV(TWEN) | _BV(TWEA); /* bit rate */ + /* SCL freq = F_CPU/(16+2*TWBR*4^TWPS) */ + /* since TWPS in TWSR is set to zero, 4^TWPS resolves to 1 */ TWBR = (F_CPU / SEEPROM_I2C_CLOCK - 16) / 2; /* my address */ TWAR = 0;