while(1)
{
- i2c_master_read(UZUME_AD7999_I2C_PORT, UZUME_AD7999_I2C_ADRS, adcbuf, 2);
+ i2ccall(i2c_master_read(UZUME_AD7999_I2C_PORT, UZUME_AD7999_I2C_ADRS, adcbuf, 2));
/* 上位バイトのbit 5:4 をチャンネル番号として受け取る */
ch = ( adcbuf[0] & 0x30 ) >> 4;
- /*上位バイトのbit 3;0と買いバイトから12bitのADCデータを作る。そのデータを32bitに左詰めする */
+ /*上位バイトのbit 3;0と下位バイトから12bitのADCデータを作る。そのデータを32bitに左詰めする */
/* 排他区間開始 */
wai_sem(AD7999_SEM);
*/
static struct I2C_MASTER_CONTROL_TYPE i2c_control[I2CNUM];
+static char * i2c_strerror( ER ercd )
+{
+ ercd &= 0xFFFF0000;
+ switch (ercd)
+ {
+ case I2C_ERR_WRONGPARAM :
+ return("I2C_ERR_WRONGPARAM");
+ case I2C_ERR_TOOLONGBUFFER :
+ return("I2C_ERR_TOOLONGBUFFER");
+ case I2C_ERR_TIMEOUT :
+ return ("I2C_ERR_TIMEOUT");
+ }
+ return ("I2C_ERR_UNKNOWN");
+}
+
+
+void
+i2c_perror(UINT prio, const char *file, int line, const char *expr, ER ercd)
+{
+ syslog_5(prio, "%s reported by `%s' in line %d of `%s'. Interrupt Status = %04x",
+ i2c_strerror(ercd), expr, line, file, ercd & 0xFFFF);
+}
+
int i2c_master_write( int peripheral, int slave, unsigned char write_data[], int write_count )
{
/**
* \brief TWIデバイス制御関数への引き数値が間違っている。
*/
-#define I2C_ERR_WRONGPARAM 0x4000
+#define I2C_ERR_WRONGPARAM 0x40000
/**
* \brief TWIデバイス制御関数へ指定した送受信データ長が長すぎる。
*/
-#define I2C_ERR_TOOLONGBUFFER 0x2000
+#define I2C_ERR_TOOLONGBUFFER 0x20000
/**
* \brief TWIデバイスがタイムアウトした。
*/
-#define I2C_ERR_TIMEOUT 0x1000
+#define I2C_ERR_TIMEOUT 0x10000
+
+extern void i2c_perror(UINT prio, const char *file, int line,
+ const char *expr, ER ercd) throw();
+
+Inline ER
+_i2c_perror(const char *file, int line, const char *expr, ER ercd)
+{
+ if (ercd < 0) {
+ i2c_perror(LOG_ERROR, file, line, expr, ercd);
+ }
+ return(ercd);
+}
+
+#define i2ccall(s) _t_perror(__FILE__, __LINE__, #s, (s))
+
/**
* \brief i2cマスターモードの割り込みサービスルーチン
/* TLV320AIC23Bに初期化データを送信する */
for ( i=0; i< CODECINITDATALEN; i++){
- i2c_master_write( UZUME_SSM2603_I2C_PORT, UZUME_SSM2603_I2C_ADRS, tlv320aic23init[i], 2 );
+ i2ccall(i2c_master_write( UZUME_SSM2603_I2C_PORT, UZUME_SSM2603_I2C_ADRS, tlv320aic23init[i], 2 ));
}
}