PropWare  3.0.0.229
C++ objects and CMake build system for Parallax Propeller
peb_ee_readShort.c
1 /*
2  ee_readShort.c
3 
4  Copyright (c) 2015 Parallax Inc., all rights MIT licensed,
5  see end of file.
6 */
7 
8 #include "simpletools.h"
9 #include "badgetools.h"
10 
11 volatile int eei2cLock;
12 
13 short ee_readShort(int addr)
14 {
15  while(lockset(eei2cLock));
16  int value;
17  i2c_in(st_eeprom, 0x50, addr, 2, (unsigned char*) &value, 2);
18  lockclr(eei2cLock);
19  return value;
20 }
21 
22 /*
23  TERMS OF USE: MIT License
24 
25  Permission is hereby granted, free of charge, to any person obtaining a
26  copy of this software and associated documentation files (the "Software"),
27  to deal in the Software without restriction, including without limitation
28  the rights to use, copy, modify, merge, publish, distribute, sublicense,
29  and/or sell copies of the Software, and to permit persons to whom the
30  Software is furnished to do so, subject to the following conditions:
31 
32  The above copyright notice and this permission notice shall be included in
33  all copies or substantial portions of the Software.
34 
35  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
36  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
37  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
38  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
39  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
40  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
41  DEALINGS IN THE SOFTWARE.
42 */
43 
ee_readShort
short ee_readShort(int addr)
Get a short value from a certain address in the Propeller Chip's dedicated EEPROM....
Definition: peb_ee_readShort.c:13
i2c_in
HUBTEXT int i2c_in(i2c *busID, int i2cAddr, int memAddr, int memAddrCount, unsigned char *data, int dataCount)
Receive data from device using I2C protocol.
Definition: i2c_in.c:20
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,...
lockset
#define lockset(lockid)
Set a lock.
Definition: propeller.h:163
lockclr
#define lockclr(lockid)
Clear lock.
Definition: propeller.h:170
badgetools.h
This library provides convenient functions for a variety of Parallax eBadge operations.