1-Wire and ENS210 driver stack
|
General library for the DS28E18. More...
Go to the source code of this file.
Classes | |
struct | DS28E18_sequence_T |
Enumerations | |
enum | DS28E18_device_function_commands_T { COMMAND_START = 0x66, WRITE_SEQUENCER = 0x11, READ_SEQUENCER = 0x22, RUN_SEQUENCER = 0x33, WRITE_CONFIGURATION = 0x55, READ_CONFIGURATION = 0x6A, WRITE_GPIO_CONFIGURATION = 0x83, READ_GPIO_CONFIGURATION = 0x7C, DEVICE_STATUS = 0x7A } |
enum | DS28E18_one_wire_rom_commands_T { READ_ROM = 0x33, MATCH_ROM = 0x55, SEARCH_ROM = 0xF0, SKIP_ROM = 0xCC, RESUME = 0xA5, OVERDRIVE_SKIP = 0x3C, OVERDRIVE_MATCH = 0x69 } |
enum | DS28E18_sequencer_commands_T { I2C_START = 0x02, I2C_STOP = 0x03, I2C_WRITE_DATA = 0xE3, I2C_READ_DATA = 0xD4, I2C_READ_DATA_W_NACK_END = 0xD3, SPI_WRITE_READ_BYTE = 0xC0, SPI_WRITE_READ_BIT = 0xB0, SPI_SS_HIGH = 0x01, SPI_SS_LOW = 0x80, UTILITY_DELAY = 0xDD, UTILITY_SENS_VDD_ON = 0xCC, UTILITY_SENS_VDD_OFF = 0xBB, UTILITY_GPIO_BUF_WRITE = 0xD1, UTILITY_GPIO_BUF_READ = 0x1D, UTILITY_GPIO_CNTL_WRITE = 0xE2, UTILITY_GPIO_CNTL_READ = 0x2E } |
enum | DS28E18_result_byte_T { POR_OCCURRED = 0x44, EXECUTION_ERROR = 0x55, INVALID_PARAMETER = 0x77, NACK_OCCURED = 0x88, SUCCESS = 0xAA } |
enum | DS28E18_protocol_speed_T { KHZ_100, KHZ_400, KHZ_1000, KHZ_2300 } |
enum | DS28E18_ignore_nack_T { DONT_IGNORE, IGNORE } |
enum | DS28E18_protocol_T { I2C, SPI } |
enum | DS28E18_spi_mode_T { MODE_0 = 0x00, MODE_3 = 0x03 } |
enum | DS28E18_target_configuration_register_T { CONTROL = 0x0B, BUFFER = 0x0C } |
enum | DS28E18_utility_delay_T { DELAY_1msec = 0, DELAY_2msec = 1, DELAY_4msec = 2, DELAY_8msec = 3, DELAY_16msec = 4, DELAY_32msec = 5, DELAY_64msec = 6, DELAY_128msec = 7, DELAY_256msec = 8, DELAY_512msec = 9, DELAY_1024msec = 10, DELAY_2048msec = 11, DELAY_4096msec = 12, DELAY_8192msec = 13, DELAY_16384msec = 14, DELAY_32768msec = 15 } |
Functions | |
int | DS28E18_Init (void) |
int | DS28E18_SetOnewireSpeed (one_wire_speeds spd) |
void | DS28E18_SetRomCommand (DS28E18_one_wire_rom_commands_T rom_cmd) |
DS28E18_one_wire_rom_commands_T | DS28E18_GetRomCommand (void) |
Return the value of 'current_ROM_command'. | |
bool | DS28E18_WriteSequencer (unsigned short nineBitStartingAddress, const uint8_t *txData, int txDataSize) |
bool | DS28E18_ReadSequencer (unsigned short nineBitStartingAddress, uint8_t *rxData, unsigned short readLength) |
bool | DS28E18_RunSequencer (unsigned short nineBitStartingAddress, unsigned short runLength) |
bool | DS28E18_WriteConfiguration (DS28E18_protocol_speed_T SPD, DS28E18_ignore_nack_T INACK, DS28E18_protocol_T PROT, DS28E18_spi_mode_T SPI_MODE) |
bool | DS28E18_ReadConfiguration (uint8_t *rxData) |
bool | DS28E18_WriteGpioConfiguration (DS28E18_target_configuration_register_T CFG_REG_TARGET, uint8_t GPIO_HI, uint8_t GPIO_LO) |
bool | DS28E18_ReadGpioConfiguration (uint8_t CFG_REG_TARGET, uint8_t *rxData) |
bool | DS28E18_DeviceStatus (uint8_t *rxData) |
void | DS28E18_BuildPacket_ClearSequencerPacket (void) |
Reset local command sequencer packet under construction. | |
uint8_t * | DS28E18_BuildPacket_GetSequencerPacket (void) |
Get address of locally constructed command sequencer packet's data. | |
int | DS28E18_BuildPacket_GetSequencerPacketSize (void) |
Get length of locally constructed command sequencer packet. | |
void | DS28E18_BuildPacket_I2C_Start (void) |
void | DS28E18_BuildPacket_I2C_Stop (void) |
void | DS28E18_BuildPacket_I2C_WriteData (const uint8_t *i2cData, uint8_t i2cDataSize) |
unsigned short | DS28E18_BuildPacket_I2C_ReadData (int readBytes) |
unsigned short | DS28E18_BuildPacket_I2C_ReadDataWithNackEnd (int readBytes) |
unsigned short | DS28E18_BuildPacket_SPI_WriteReadByte (const uint8_t *spiWriteData, uint8_t spiWriteDataSize, int readBytes, bool fullDuplex) |
unsigned short | DS28E18_BuildPacket_SPI_WriteReadBit (const uint8_t *spiWriteData, uint8_t spiWriteDataSize, int writeBits, int readBits) |
void | DS28E18_BuildPacket_SPI_SlaveSelectHigh (void) |
void | DS28E18_BuildPacket_SPI_SlaveSelectLow (void) |
void | DS28E18_BuildPacket_Utility_Delay (DS28E18_utility_delay_T delayTimeInMsExponent) |
void | DS28E18_BuildPacket_Utility_SensVddOn (void) |
void | DS28E18_BuildPacket_Utility_SensVddOff (void) |
void | DS28E18_BuildPacket_Utility_GpioBufferWrite (uint8_t GPIO_BUF) |
unsigned short | DS28E18_BuildPacket_Utility_GpioBufferRead (void) |
void | DS28E18_BuildPacket_Utility_GpioControlWrite (uint8_t GPIO_CRTL_HI, uint8_t GPIO_CRTL_LO) |
unsigned short | DS28E18_BuildPacket_Utility_GpioControlRead (void) |
void | DS28E18_BuildPacket_Append (const uint8_t *sequencerCmds, size_t length) |
Append commands to locally constructed command sequencer packet. | |
bool | DS28E18_BuildPacket_WriteAndRun (void) |
Variables | |
OneWire_ROM_ID_T | current_DS28E18_ROM_ID |
DS28E18 device addressed for current operations (may be one of many on 1-Wire bus) | |
General library for the DS28E18.
DS28E18 delay command argument is an exponent: Delay is 2^arg in msec. The actual delay time is from 1ms to 32s respectively Code relies on enum defined as the exponent as below.
unsigned short DS28E18_BuildPacket_I2C_ReadData | ( | int | readBytes | ) |
Sequencer Command: Read Data (D4h).
Append an I2C Read Data command to the locally constructed command sequencer packet.
readBytes | Number of bytes to read from the I2C bus |
unsigned short DS28E18_BuildPacket_I2C_ReadDataWithNackEnd | ( | int | readBytes | ) |
Sequencer Command: Read Data w/NACK end (D3h).
Append an I2C Read Data w/NACK end command to the locally constructed command sequencer packet.
readBytes | Number of bytes to read from the I2C bus |
void DS28E18_BuildPacket_I2C_Start | ( | void | ) |
Sequencer Command: Start (02h).
Append an I2C Start command to the locally constructed command sequencer packet.
void DS28E18_BuildPacket_I2C_Stop | ( | void | ) |
Sequencer Command: Stop (03h).
Append an I2C Stop command to the locally constructed command sequencer packet.
void DS28E18_BuildPacket_I2C_WriteData | ( | const uint8_t * | i2cData, |
uint8_t | i2cDataSize | ||
) |
Sequencer Command: Write Data (E3h).
Append an I2C Write Data command to the locally constructed command sequencer packet.
i2cData | Array with data to be transmitted over the I2C bus |
i2cDataSize | Number of elements found in i2cData array |
void DS28E18_BuildPacket_SPI_SlaveSelectHigh | ( | void | ) |
Sequencer Command: SPI SS_High (01h).
Append an SPI SS_High command to the locally constructed command sequencer packet.
void DS28E18_BuildPacket_SPI_SlaveSelectLow | ( | void | ) |
Sequencer Command: SPI SS_Low (80h).
Append an SPI SS_Low command to the locally constructed command sequencer packet.
unsigned short DS28E18_BuildPacket_SPI_WriteReadBit | ( | const uint8_t * | spiWriteData, |
uint8_t | spiWriteDataSize, | ||
int | writeBits, | ||
int | readBits | ||
) |
Sequencer Command: SPI Write/Read Bit (B0h).
Append an SPI Write/Read Bit command to the locally constructed command sequencer packet.
spiWriteData | Array with data to be transmitted over the SPI bus. Data not important if only reading. |
spiWriteDataSize | Number of elements found in spiWriteData array. Set to 0 if only reading. |
writeBits | Number of bits to write to SPI bus. Set to 0 if only reading. |
readBits | Number of bits to read from SPI bus. Set to 0 if only writting. |
unsigned short DS28E18_BuildPacket_SPI_WriteReadByte | ( | const uint8_t * | spiWriteData, |
uint8_t | spiWriteDataSize, | ||
int | readBytes, | ||
bool | fullDuplex | ||
) |
Sequencer Command: SPI Write/Read Byte (C0h).
Append an SPI Write/Read Byte command to the locally constructed command sequencer packet.
spiWriteData | Array with data to be transmitted over the SPI bus. Data not important if only reading. |
spiWriteDataSize | Number of elements found in spiWriteData array. Set to 0 if only reading. |
readBytes | Number of bytes to read from SPI bus. Set to 0 if only writting. |
fullDuplex | Set 'true' when interfacing with a full duplex SPI slave. Otherwise, set 'false' |
void DS28E18_BuildPacket_Utility_Delay | ( | DS28E18_utility_delay_T | delayTimeInMsExponent | ) |
Sequencer Command: Delay (DDh).
Append a Delay command to the locally constructed command sequencer packet.
unsigned short DS28E18_BuildPacket_Utility_GpioBufferRead | ( | void | ) |
Sequencer Command: GPIO_BUF Read (1Dh).
Append a GPIO_BUF Read command to the locally constructed command sequencer packet.
void DS28E18_BuildPacket_Utility_GpioBufferWrite | ( | uint8_t | GPIO_BUF | ) |
Sequencer Command: GPIO_BUF Write (D1h).
Append a GPIO_BUF Write command to the locally constructed command sequencer packet.
GPIO_BUF | Buffer register high byte. |
unsigned short DS28E18_BuildPacket_Utility_GpioControlRead | ( | void | ) |
Sequencer Command: GPIO_CNTL Read (2Eh).
Append a GPIO_CNTL Read command to the locally constructed command sequencer packet.
void DS28E18_BuildPacket_Utility_GpioControlWrite | ( | uint8_t | GPIO_CRTL_HI, |
uint8_t | GPIO_CRTL_LO | ||
) |
Sequencer Command: GPIO_CNTL Write (E2h).
Append a GPIO_CNTL Write command to the locally constructed command sequencer packet.
GPIO_CRTL_HI | Control register high byte. |
GPIO_CRTL_LO | Control register low byte. |
void DS28E18_BuildPacket_Utility_SensVddOff | ( | void | ) |
Sequencer Command: SENS_VDD Off (BBh).
Append a 'SENS_VDD Off' command to the locally constructed command sequencer packet.
void DS28E18_BuildPacket_Utility_SensVddOn | ( | void | ) |
Sequencer Command: SENS_VDD On (CCh).
Append a 'SENS_VDD On' command to the locally constructed command sequencer packet.
bool DS28E18_BuildPacket_WriteAndRun | ( | void | ) |
Write locally constructed command sequencer packet into DS28E18's sequence memory over 1wire, run it, and wait long enough for completion. Does NOT fetch any response; use DS28E18_ReadSequencer for that.
bool DS28E18_DeviceStatus | ( | uint8_t * | rxData | ) |
Device Function Command: Device Status (7Ah)
rxData[out] | Array of 4 bytes to receive DS28E18's status information |
int DS28E18_Init | ( | void | ) |
Initialize all DS28E18 on the 1-Wire bus.
bool DS28E18_ReadConfiguration | ( | uint8_t * | rxData | ) |
Device Function Command: Read Configuration (6Ah)
rxData[out] | Array of 2 bytes to be updated with devices' configuration information |
bool DS28E18_ReadGpioConfiguration | ( | uint8_t | CFG_REG_TARGET, |
uint8_t * | rxData | ||
) |
Device Function Command: Read GPIO Configuration (7Ch)
CFG_REG_TARGET | Desired GPIO Configuration Register from macros to read from |
rxData[out] | Array of 2 bytes to be updated with device current GPIO configuration for GPIO_HI and GPIO_LO |
bool DS28E18_ReadSequencer | ( | unsigned short | nineBitStartingAddress, |
uint8_t * | rxData, | ||
unsigned short | readLength | ||
) |
Device Function Command: Read Sequencer (22h)
nineBitStartingAddress | Target read address | |
readLength | Number of data bytes to be read from the sequencer memory starting from the target read address | |
[out] | rxData | Array of data returned from specified memory address |
bool DS28E18_RunSequencer | ( | unsigned short | nineBitStartingAddress, |
unsigned short | runLength | ||
) |
Device Function Command: Run Sequencer (33h) - Command DS28E18 over 1wire to run a command sequence already placed in DS28E18 sequence memory
nineBitStartingAddress | Target run address |
runLength | Number of data bytes to run from the sequencer memory starting from the target run address |
int DS28E18_SetOnewireSpeed | ( | one_wire_speeds | spd | ) |
Set desired 1-Wire speed between Standard and Overdrive for both, 1-Wire master and slave.
void DS28E18_SetRomCommand | ( | DS28E18_one_wire_rom_commands_T | rom_cmd | ) |
Set 1-Wire 'current_ROM_command' (normally MATCH_ROM, SKIP_ROM during device search). Does not send anything to lower-level code; just sets the operating mode for this DS28E18 layer.
bool DS28E18_WriteConfiguration | ( | DS28E18_protocol_speed_T | SPD, |
DS28E18_ignore_nack_T | INACK, | ||
DS28E18_protocol_T | PROT, | ||
DS28E18_spi_mode_T | SPI_MODE | ||
) |
Device Function Command: Write Configuration (55h)
SPD | Desired protocol speed from macros |
INACK | Desired INACK configuration from macros |
PROT | Desired protocol from macros |
SPI_MODE | Desired SPI Mode from macros |
bool DS28E18_WriteGpioConfiguration | ( | DS28E18_target_configuration_register_T | CFG_REG_TARGET, |
uint8_t | GPIO_HI, | ||
uint8_t | GPIO_LO | ||
) |
Device Function Command: Write GPIO Configuration (83h)
CFG_REG_TARGET | Desired GPIO Configuration Register to write to |
GPIO_HI | Control/Buffer register high byte |
GPIO_LO | Control/Buffer register low byte |
bool DS28E18_WriteSequencer | ( | unsigned short | nineBitStartingAddress, |
const uint8_t * | txData, | ||
int | txDataSize | ||
) |
Device Function Command: Write Sequencer (11h) - Write command sequence into DS28E28 sequencer memory over 1Wire
nineBitStartingAddress | Target write address |
txData | Array of data to be written into the sequencer memory starting from the target write address |
txDataSize | Number of elements found in txData array |