User Manual
Version 1.1
2011-07-15
 
  deRFnode and deRFgateway
 
 
 
 
dresden elektronik
ingenieurtechnik gmbh
Enno-Heidebroek-Str. 12
12 7 Dr
n
rm  n
Tel.: +49 351  31 85 00
Fax: +49 351  3 18 50 10
wireless@dresden-elektronik.de
www. r
n- l k r nik.
Page 43 of 56
 
Assumed that you use an ARM MCU, the initialization might look like:
#define PINS_TWI           { ((1<<10) | (1<<11)), AT91C_BASE_PIOA,  
  AT91C_ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT }
static Twid twid;                           // managing datastructure 
const Pin pins[] = { PINS_TWI };            // SDA/SCL pins (PA10, PA11) 
PIO_Configure(pins, PIO_LISTSIZE(pins)); 
PMC_EnablePeripheral( AT91C_ID_TWI);        // enable twi peripheral 
TWI_ConfigureMaster(AT91C_BASE_TWI, 100000, BOARD_MCK); // 100kHz 
TWID_Initialize(&twid, AT91C_BASE_TWI);     // initialize datastructure 
AIC_ConfigureIT(AT91C_ID_TWI, 0, ISR_Twi);  // configure and 
AIC_EnableIT(AT91C_ID_TWI);                 // enable twi interrupt 
During the next step the devices are configured. This includes activity intervals, resolution/
sensitivity, triggers when exceeding/falling below given limits, etc. Usually the sensors power
up idle and must be explicitly started. Additionally the acceleration sensor includes a configu-
ration EEPROM in which an overriding startup-configuration may be saved. Configuration is
usually done by writing to device registers and incorporates:
(1) initiate a TWI start condition,
(2) write the configuration register address,
(3) write the configuration register value,
(4) send a TWI stop condition.
So if you i.e. want to activate the TMP102 temperature sensor measuring temperatures only
upon request, select the configuration register MSB (0x01) and write in 0x80 to shut down
the device. Here TWID_Write() encapsulates all the required steps in one function:
#define BOARD_SENS_ADDR_TEMP     (0x48)  // sensor address, 1bit shifted 
unsigned char ucBuf[2];                  // buffer for twi transmissions 
ucBuf[0] = 0x01; // configuration register, MSB
ucBuf[1] = 0x80; // shutdown-mode
TWID_Write(&twid, BOARD_SENS_ADDR_TEMP, 0x00, 0x00, ucBuf, 0x02, NULL);
As like as configuration is performed, sensor values are read from device registers. Depend-
ing on the device, you may either read the current register value directly or must send a start
command first and wait a certain time until measurement is available (otherwise you would
read outdated values). To continue with the temperature sensor, a code snippet looks like:
ucBuf[0] = 0x01; // configuration register, MSB 
ucBuf[1] = 0x81; // shutdown mode | one-shot 
TWID_Write(&twid, BOARD_SENS_ADDR_TEMP, 0x00, 0x00, ucBuf, 0x02, NULL); 
// wait at least 26 ms (depends on selected resolution), then
// select temperature register (MSB) and read 2 bytes from it 
ucBuf[0] = 0x00;
TWID_Write(&twid, BOARD_SENS_ADDR_TEMP, 0x00, 0x00, ucBuf, 0x01, NULL); 
TWID_Read(&twid, BOARD_SENS_ADDR_TEMP, 0x00, 0x00, ucBuf, 0x02, NULL); 
 
// convert value to a human-readable format ... 
Besides the I
2
C communication lines, the acceleration sensor includes an interrupt line which
may trigger under certain circumstances, i.e. acceleration increases above/decreases be-
low/changes relatively to a configured threshold. These features might be used to detect the
device falling or its motion at all. For all these cases, the sensor might drive its INT line high,
as long as the condition is met. For detailed information, please refer to the BMA150
datasheet. Using this feature requires JP1 to shortcut pins 2-3 and configuration of an inter-
rupt trigger on the MCU side.
相关PDF资料
3700BL15B100E BALUN CERAMIC CHIP WIMAX 3.7GHZ
4000BL14U100T BALUN CERAMIC CHIP UWB 4GHZ
4391-93 ATTENUATOR BNC MALE/FMALE 93 OHM
4432-T-B1 B 915 KIT DEV TEST EZRADIOPRO SI4432
5250AT43A200E ANTENNA CHIP 5.25GHZ WIFI
5250BL14B100T BALUN CERAMIC CHIP WIFI 5250MHZ
5250BL15B100E BALUN CERAMIC CHIP WIFI 5250MHZ
5325BL15B050E BALUN CERAMIC CHIP WIFI 5325MHZ
相关代理商/技术参数
3077-0-00-01-00-00-33-0 制造商:Mill-Max Mfg Corp 功能描述:
30770001 制造商: 功能描述: 制造商:undefined 功能描述:
3077-0-00-15-00-00030 制造商:Mill-Max Mfg Corp 功能描述:3077 DOUBLE TAIL HEADER PIN
307706 制造商:Weidmuller 功能描述:WBP-1/2IN NPT,STOPPING PLUG, -EA - Bulk
307707 制造商:Weidmuller 功能描述:WBP-3/4IN NPT,STOPPING PLUG, -EA - Bulk
307708 制造商:Weidmuller 功能描述:WBP-1IN NPT,STOPNG PLUG,BR -EA - Bulk
307709 制造商:Weidmuller 功能描述:WBP-1X1/4IN NPT,STOPNG PLUG, -EA - Bulk
30771 制造商:Alpha Wire 功能描述:Roll 制造商:Vicor Corporation 功能描述:HEATSINK VI-J00 TRANSVERSE 0.9" 制造商:Vicor Corporation 功能描述:VI-J00 heat sink 5 V output