Hello,
I’m trying to set up I2C on my device (SL8080T), but I’m having issues. I’ve followed the sample code in the ADL user guide (§3.13.18), and came up with the following test program, intended to subscribe to the I2C service, and write a buffer to it every second:
#include "adl_global.h"
#include "adl_bus.h"
#include "generated.h"
// Temporary global values
u8 buffer[] = {0xAA, 0x0F, 0x0F, 0xAA};
adl_busAccess_t AccessConfig = {0,0};
s32 MyI2CHandle;
adl_busI2CSettings_t MyI2CConfig = {
0x20, // Chip address is 0x20
ADL_BUS_I2C_CLK_STD, // Chip uses the I2C standard clock speed
ADL_BUS_I2C_ADDR_7_BITS, // 7 bits address length
ADL_BUS_I2C_MASTER_MODE // Master mode
};
// Timer handler
void write_test() {
s32 ret = adl_busWrite( MyI2CHandle, &AccessConfig, sizeof(u8) * 4, buffer );
switch( ret ) {
default:
case OK:
TRACE(( 1, "OK" ));
break;
case ERROR:
TRACE(( 1, "ERROR" ));
break;
case ADL_RET_ERR_UNKNOWN_HDL:
TRACE(( 1, "ADL_RET_ERR_UNKNOWN_HDL" ));
break;
case ADL_RET_ERR_PARAM:
TRACE(( 1, "ADL_RET_ERR_PARAM" ));
break;
case ADL_RET_ERR_SERVICE_LOCKED:
TRACE(( 1, "ADL_RET_ERR_SERVICE_LOCKED" ));
break;
}
}
// Entry point for ADL user application
void main_task()
{
TRACE(( 1, "main_task" ));
MyI2CHandle = adl_busSubscribe( ADL_BUS_ID_I2C, 1, &MyI2CConfig );
switch( MyI2CHandle ) {
case ADL_RET_ERR_PARAM:
TRACE(( 1, "ADL_RET_ERR_PARAM" ));
break;
case ADL_RET_ERR_ALREADY_SUBSCRIBED:
TRACE(( 1, "ADL_RET_ERR_ALREADY_SUBSCRIBED" ));
break;
case ADL_RET_ERR_BAD_HDL:
TRACE(( 1, "ADL_RET_ERR_BAD_HDL" ));
break;
case ADL_RET_ERR_NOT_SUPPORTED:
TRACE(( 1, "ADL_RET_ERR_NOT_SUPPORTED" ));
break;
case ADL_RET_ERR_SERVICE_LOCKED:
TRACE(( 1, "ADL_RET_ERR_SERVICE_LOCKED" ));
break;
default:
TRACE(( 1, "MyI2CHandle == 0x%.8x", MyI2CHandle ));
adl_tmrSubscribe( TRUE, 10, ADL_TMR_TYPE_100MS, (adl_tmrHandler_t) write_test );
break;
}
}
The adl_busSubscribe function is successful, but each call to adl_busWrite returns the value ADL_RET_ERR_PARAM. I can’t seem to figure out, however, where the issue lies. Is there something I’m doing wrong?
Here’s some additional diagnostic information, including the device number and firmware version:
ati9
"DWL"," B04.05.18.00.SL8RDBT R2509 CNSHZ-ED-XP0029 2015/04/23 15:10:23","","Sierra Wireless",0,"","00000000","00000000"
"FW","FW_753_1_A1_4.SL808FAx","B7.53.1.A1.201411071126.SL8080T","Sierra Wireless",1943676,"110714 11:26","4380cd1b","10002020"
"MODEM 3G+","Revision: B04.05.05.00.SL8RDAP R2339 CNSHZ-ED-XP0029 2014/11/07 15:28:21"
"OAT","1.0.0.20150630145156","MyApplication","Minium LLC",215176,"063015 14:51","5962f825","10700000"
-"Developer Studio","3.4.0.201506101227"
-"Open AT Application Framework package","2.53.1.A1.201411071700"
-"Open AT OS Package","6.53.1.A1.201410271301"
-"Firmware Package","7.53.1.A1.201411071126"
-"ExtendedATApplication Library Package","2.1.0.A1.201411071534"
-"eCall Library Package","1.3.3.201411071021"
-"Local Trace Session Library Package","1.1.0.201410231018"
-"Location Library Package","1.4.6.201310160912"
-"Security Library Package","2.2.0.201306261000"
-"Internet Library Package","5.57.1.A1.201410101134"
"ROM","8400000"
"RAM","4000000"
"OATRAM","b00000"
"DWLNAME","SL808xA"
OK