changing circuitry to disable RTC, update initialization to match
[fw/openalt] / i2c / i2c.c
1 #include "FreeRTOS.h"
2
3 #include "i2c.h"
4
5 //
6 //
7 //
8 typedef struct i2cErrnoStr_s
9 {
10   int errno;
11   const char *text;
12 }
13 i2cErrnoStr_t;
14
15 static i2cErrnoStr_t i2cErrnoStr [] =
16 {
17   { I2CERR_NONE,              "I2CERR_NONE" },
18   { I2CERR_BUSY,              "I2CERR_BUSY" },
19   { I2CERR_EMPTY,             "I2CERR_EMPTY" },
20   { I2CERR_TIMEOUT,           "I2CERR_TIMEOUT" },
21   { I2CERR_TIMEOUTWC,         "I2CERR_TIMEOUTWC" },
22   { I2CERR_TIMEOUTACKPOLL,    "I2CERR_TIMEOUTACKPOLL" },
23   { I2CERR_NOTIMPLEMENTED,    "I2CERR_NOTIMPLEMENTED" },
24   { I2CERR_OTHER,             "I2CERR_OTHER" },
25   { I2CERR_BUSERROR,          "I2CERR_BUSERROR" },
26   { I2CERR_BUSERRORx,         "I2CERR_BUSERRORx" },
27   { I2CERR_STARTTX,           "I2CERR_STARTTX" },
28   { I2CERR_REPEATEDSTARTTX,   "I2CERR_REPEATEDSTARTTX" },
29   { I2CERR_SLAWTX_ACKRX,      "I2CERR_SLAWTX_ACKRX" },
30   { I2CERR_SLAWTX_NACKRX,     "I2CERR_SLAWTX_NACKRX" },
31   { I2CERR_DATTX_ACKRX,       "I2CERR_DATTX_ACKRX" },
32   { I2CERR_DATTX_NACKRX,      "I2CERR_DATTX_NACKRX" },
33   { I2CERR_ARBLOST,           "I2CERR_ARBLOST" },
34   { I2CERR_SLARTX_ACKRX,      "I2CERR_SLARTX_ACKRX" },
35   { I2CERR_SLARTX_NACKRX,     "I2CERR_SLARTX_NACKRX" },
36   { I2CERR_DATRX_ACKTX,       "I2CERR_DATRX_ACKTX" },
37   { I2CERR_DATRX_NACKTX,      "I2CERR_DATRX_NACKTX" },
38   { I2CERR_NOINFO,            "I2CERR_NOINFO" },
39 };
40
41 i2cErr_e i2cErrno = I2CERR_NONE;
42
43 //
44 //
45 //
46 int i2cGetErrno (void)
47 {
48   return i2cErrno;
49 }
50
51 const char *i2cStrerror (int err)
52 {
53   unsigned int i;
54
55   for (i = 0; i < arrsizeof (i2cErrnoStr); i++)
56     if (i2cErrnoStr [i].errno == err)
57       return i2cErrnoStr [i].text;
58
59   return NULL;
60 }