User manual

JM3 Engineering Inh. J. Maisel Dobelweg 18, D-85567 Grafing / Munich
Email: JHM@JM3-Engineering.de
Version: 2.30 Oct 21, 2013 page: 3
2. RP6ControlLib.ccp
/******************************************************************/
// SPI ACC Sensor LIS302DLH
uint8_t cSPI::ACCSENS_ReadByte(uint8_t regAddr)
{
regAddr |= 0x80;
uint8_t data;
PORTB &= ~ACC_CS;
writeSPI(regAddr);
data = readSPI();
PORTB |= ACC_CS;
return data;
}
// Reads "length" Bytes into the Buffer "buffer" from startAdr2 on
void cSPI::ACCSENS_ReadBytes(uint8_t startAddr, uint8_t* buffer, uint8_t length)
{
startAddr |= 0xC0;
PORTB &= ~ACC_CS;
writeSPI(startAddr);
readBufferSPI(buffer, length);
PORTB |= ACC_CS;
}
// Write a single data byte to the specified sensor address
void cSPI::ACCSENS_WriteByte(uint8_t regAddr, uint8_t data)
{
PORTB &= ~ACC_CS;
writeSPI(regAddr);
writeSPI(data);
PORTB |= ACC_CS;
}
// Returns Sensor Status register - for checking if sensor is busy
uint8_t cSPI::ACCSENS_GetStatus()
{
uint8_t status;
PORTB &= ~ACC_CS;
writeSPI(0x27);
status = readSPI();
PORTB |= ACC_CS;
return status;
}
This SW example demonstrates the access to the module your SW need to handle to
output to a display or the terminal via RS 232. The part is much more capable as shown here
- read data sheet for more information.