PropWare  3.0.0.229
C++ objects and CMake build system for Parallax Propeller
eeprom_putStr.c
1 /*
2  * @file eeprom.c
3  *
4  * @author Andy Lindsay
5  *
6  * @version 0.87
7  *
8  * @copyright Copyright (C) Parallax, Inc. 2013. See end of file for
9  * terms of use (MIT License).
10  *
11  * @brief eeprom functions source, see simpletools.h for documentation.
12  *
13  * @detail Please submit bug reports, suggestions, and improvements to
14  * this code to editor@parallax.com.
15  */
16 
17 #include "simpletools.h" // simpletools function prototypes
18 
19 i2c *st_eeprom;
20 int st_eeInitFlag;
21 
22 void ee_init();
23 
24 
25 void ee_putStr(unsigned char *s, int n, int addr)
26 {
27  //unsigned char addrArray[2];
28  if(!st_eeInitFlag) ee_init();
29 
30  while(n > 0)
31  {
32  //addrArray[0] = (char)(addr >> 8);
33  //addrArray[1] = (char)(addr&0xFF);
34 
35  int pageAddr = addr % 128;
36  int byteCnt = 128 - pageAddr;
37  if(byteCnt > n) byteCnt = n;
38 
39  //i2c_out(st_eeprom, 0xA0, addrArray, 2, s, byteCnt);
40  i2c_out(st_eeprom, 0x50, addr, 2, s, byteCnt);
41  while(i2c_poll(st_eeprom, 0xA0));
42 
43  n -= byteCnt;
44  addr += byteCnt;
45  s += byteCnt;
46  }
47  return;
48 }
49 
st_eeprom
i2c * st_eeprom
The busID for the Propeller Activity Board's EEPROM bus.
Definition: accel_shaken.c:9
simpletools.h
This library provides convenient functions for a variety of microcontroller I/O, timing,...
ee_putStr
void ee_putStr(unsigned char *s, int n, int addr)
Store a string of byte values starting at a certain address in the Propeller Chip's dedicated EEPROM.
Definition: eeprom_putStr.c:25
i2c_poll
HUBTEXT int i2c_poll(i2c *bus, int devaddr)
Send i2c start and addr byte. Looks for ACK (0) or NACK (1). This is useful for checking if a device ...
Definition: simplei2c.c:227
i2c_st
Definition: simplei2c.h:25
st_eeInitFlag
int st_eeInitFlag
Initialization flag used by ee_ functions.
Definition: accel_shaken.c:10
i2c_out
HUBTEXT int i2c_out(i2c *busID, int i2cAddr, int memAddr, int memAddrCount, const unsigned char *data, int dataCount)
Send data to device using I2C protocol.
Definition: i2c_out.c:20