TM STM32Fxxx HAL Libraries  v1.0.0
Libraries for STM32Fxxx (F0, F4 and F7 series) devices based on HAL drivers from ST from Tilen Majerle
TM_ONEWIRE_Functions

Library Functions. More...

Functions

void TM_OneWire_Init (TM_OneWire_t *OneWireStruct, GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin)
 Initializes OneWire bus. More...
 
uint8_t TM_OneWire_Reset (TM_OneWire_t *OneWireStruct)
 Resets OneWire bus. More...
 
uint8_t TM_OneWire_ReadByte (TM_OneWire_t *OneWireStruct)
 Reads byte from one wire bus. More...
 
void TM_OneWire_WriteByte (TM_OneWire_t *OneWireStruct, uint8_t byte)
 Writes byte to bus. More...
 
void TM_OneWire_WriteBit (TM_OneWire_t *OneWireStruct, uint8_t bit)
 Writes single bit to onewire bus. More...
 
uint8_t TM_OneWire_ReadBit (TM_OneWire_t *OneWireStruct)
 Reads single bit from one wire bus. More...
 
uint8_t TM_OneWire_Search (TM_OneWire_t *OneWireStruct, uint8_t command)
 Searches for OneWire devices on specific Onewire port. More...
 
void TM_OneWire_ResetSearch (TM_OneWire_t *OneWireStruct)
 Resets search states. More...
 
uint8_t TM_OneWire_First (TM_OneWire_t *OneWireStruct)
 Starts search, reset states first. More...
 
uint8_t TM_OneWire_Next (TM_OneWire_t *OneWireStruct)
 Reads next device. More...
 
uint8_t TM_OneWire_GetROM (TM_OneWire_t *OneWireStruct, uint8_t index)
 Gets ROM number from device from search. More...
 
void TM_OneWire_GetFullROM (TM_OneWire_t *OneWireStruct, uint8_t *firstIndex)
 Gets all 8 bytes ROM value from device from search. More...
 
void TM_OneWire_Select (TM_OneWire_t *OneWireStruct, uint8_t *addr)
 Selects specific slave on bus. More...
 
void TM_OneWire_SelectWithPointer (TM_OneWire_t *OneWireStruct, uint8_t *ROM)
 Selects specific slave on bus with pointer address. More...
 
uint8_t TM_OneWire_CRC8 (uint8_t *addr, uint8_t len)
 Calculates 8-bit CRC for 1-wire devices. More...
 

Detailed Description

Library Functions.

Function Documentation

uint8_t TM_OneWire_CRC8 ( uint8_t *  addr,
uint8_t  len 
)

Calculates 8-bit CRC for 1-wire devices.

Parameters
*addrPointer to 8-bit array of data to calculate CRC
lenNumber of bytes to check
Return values
CalculatedCRC from input data
uint8_t TM_OneWire_First ( TM_OneWire_t OneWireStruct)

Starts search, reset states first.

Note
When you want to search for ALL devices on one onewire port, you should first use this function.
1 //...Initialization before
2 status = TM_OneWire_First(&OneWireStruct);
3 while (status) {
4  //Save ROM number from device
5  TM_OneWire_GetFullROM(ROM_Array_Pointer);
6  //Check for new device
7  status = TM_OneWire_Next(&OneWireStruct);
8 }
Parameters
*OneWireStructPointer to TM_OneWire_t working onewire where to reset search values
Devicestatus:
  • 0: No devices detected
  • > 0: Device detected
void TM_OneWire_GetFullROM ( TM_OneWire_t OneWireStruct,
uint8_t *  firstIndex 
)

Gets all 8 bytes ROM value from device from search.

Parameters
*OneWireStructPointer to TM_OneWire_t working onewire
*firstIndexPointer to first location for first byte, other bytes are automatically incremented
Return values
None
uint8_t TM_OneWire_GetROM ( TM_OneWire_t OneWireStruct,
uint8_t  index 
)

Gets ROM number from device from search.

Parameters
*OneWireStructPointer to TM_OneWire_t working onewire
indexBecause each device has 8-bytes long ROm address, you have to call this 8 times, to get ROM bytes from 0 to 7 ROM byte for index (0 to 7) at current found device
void TM_OneWire_Init ( TM_OneWire_t OneWireStruct,
GPIO_TypeDef *  GPIOx,
uint16_t  GPIO_Pin 
)

Initializes OneWire bus.

Parameters
*OneWireStructPointer to TM_OneWire_t empty working onewire structure
*Pointerto GPIO port used for onewire channel
GPIO_PinGPIO Pin on specific GPIOx to be used for onewire channel
Return values
None
uint8_t TM_OneWire_Next ( TM_OneWire_t OneWireStruct)

Reads next device.

Note
Use TM_OneWire_First to start searching
Parameters
*OneWireStructPointer to TM_OneWire_t working onewire
Devicestatus:
  • 0: No devices detected any more
  • > 0: New device detected
uint8_t TM_OneWire_ReadBit ( TM_OneWire_t OneWireStruct)

Reads single bit from one wire bus.

Parameters
*OneWireStructPointer to TM_OneWire_t working onewire structure
Return values
Bitvalue:
  • 0: Bit is low (zero)
  • > 0: Bit is high (one)
uint8_t TM_OneWire_ReadByte ( TM_OneWire_t OneWireStruct)

Reads byte from one wire bus.

Parameters
*OneWireStructPointer to TM_OneWire_t working onewire structure
Return values
Bytefrom read operation
uint8_t TM_OneWire_Reset ( TM_OneWire_t OneWireStruct)

Resets OneWire bus.

Note
Sends reset command for OneWire
Parameters
*OneWireStructPointer to TM_OneWire_t working onewire structure
Return values
None
void TM_OneWire_ResetSearch ( TM_OneWire_t OneWireStruct)

Resets search states.

Parameters
*OneWireStructPointer to TM_OneWire_t working onewire where to reset search values
Return values
None
uint8_t TM_OneWire_Search ( TM_OneWire_t OneWireStruct,
uint8_t  command 
)

Searches for OneWire devices on specific Onewire port.

Note
Not meant for public use. Use TM_OneWire_First and TM_OneWire_Next for this.
Parameters
*OneWireStructPointer to TM_OneWire_t working onewire structure where to search
Devicestatus:
  • 0: No devices detected
  • > 0: Device detected
void TM_OneWire_Select ( TM_OneWire_t OneWireStruct,
uint8_t *  addr 
)

Selects specific slave on bus.

Parameters
*OneWireStructPointer to TM_OneWire_t working onewire
*addrPointer to first location of 8-bytes long ROM address
Return values
None
void TM_OneWire_SelectWithPointer ( TM_OneWire_t OneWireStruct,
uint8_t *  ROM 
)

Selects specific slave on bus with pointer address.

Parameters
*OneWireStructPointer to TM_OneWire_t working onewire
*ROMPointer to first byte of ROM address
Return values
None
void TM_OneWire_WriteBit ( TM_OneWire_t OneWireStruct,
uint8_t  bit 
)

Writes single bit to onewire bus.

Parameters
*OneWireStructPointer to TM_OneWire_t working onewire structure
bitBit value to send, 1 or 0
Return values
None
void TM_OneWire_WriteByte ( TM_OneWire_t OneWireStruct,
uint8_t  byte 
)

Writes byte to bus.

Parameters
*OneWireStructPointer to TM_OneWire_t working onewire structure
byte8-bit value to write over OneWire protocol
Return values
None