removed timeout code
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
*
|
*
|
||||||
* Copyright (C) 2009 Steve Karg <skarg@users.sourceforge.net>
|
* Copyright (C) 2009 Steve Karg <skarg@users.sourceforge.net>
|
||||||
|
* Used algorithm and code from Joerg Wunsch and Ruwan Jayanetti.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
* a copy of this software and associated documentation files (the
|
* a copy of this software and associated documentation files (the
|
||||||
@@ -25,6 +26,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "hardware.h"
|
#include "hardware.h"
|
||||||
|
/* me */
|
||||||
#include "seeprom.h"
|
#include "seeprom.h"
|
||||||
|
|
||||||
/* the SEEPROM chip select bits A2, A1, and A0 are grounded */
|
/* 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
|
* 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,
|
* 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
|
* 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
|
* Thus, normal operation should not require more than 100 iterations
|
||||||
* to get the device to respond to a selection.
|
* 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
|
* RETURN: number of bytes written, or -1 on error
|
||||||
* NOTES: only writes from offset to end of page.
|
* 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 */
|
uint16_t eeaddr, /* SEEPROM starting memory address */
|
||||||
uint8_t * buf, /* data to send */
|
uint8_t * buf, /* data to send */
|
||||||
int len)
|
int len)
|
||||||
@@ -419,8 +421,8 @@ int seeprom_bytes_write_page(
|
|||||||
* 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
|
* page. If more than 64 data words are
|
||||||
* transmitted to the EEPROM, the data word
|
* transmitted to the EEPROM, the data word
|
||||||
* address will “roll over” and previous data will be
|
* address will "roll over" and previous data will be
|
||||||
* overwritten. The address “roll over” during write
|
* overwritten. The address "roll over" during write
|
||||||
* is from the last byte of the current page to the
|
* is from the last byte of the current page to the
|
||||||
* first byte of the same page.
|
* first byte of the same page.
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
@@ -461,6 +463,8 @@ void seeprom_init(
|
|||||||
TWSR = 0;
|
TWSR = 0;
|
||||||
TWCR = _BV(TWEN) | _BV(TWEA);
|
TWCR = _BV(TWEN) | _BV(TWEA);
|
||||||
/* bit rate */
|
/* 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;
|
TWBR = (F_CPU / SEEPROM_I2C_CLOCK - 16) / 2;
|
||||||
/* my address */
|
/* my address */
|
||||||
TWAR = 0;
|
TWAR = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user