CuVoodoo STM32F1 firmware template
Macros | Functions
onewire_master.h File Reference

library for 1-wire protocol as master More...

Go to the source code of this file.

Macros

#define ONEWIRE_MASTER_PORT   C
 GPIO port.
 
#define ONEWIRE_MASTER_PIN   9
 GPIO pin.
 

Functions

void onewire_master_setup (void)
 setup 1-wire peripheral
 
void onewire_master_release (void)
 release 1-wire peripheral
 
bool onewire_master_reset (void)
 send reset pulse More...
 
uint8_t onewire_master_crc (uint8_t *data, uint32_t length)
 compute CRC for 1-Wire More...
 
uint64_t onewire_master_rom_read (void)
 send READ ROM command and read ROM code response More...
 
bool onewire_master_rom_search (uint64_t *code, bool alarm)
 send SEARCH ROM command More...
 
bool onewire_master_rom_skip (void)
 send SKIP ROM command (all slaves on the bus will be selected) More...
 
bool onewire_master_rom_match (uint64_t code)
 send MATCH ROM command to select a specific slave More...
 
bool onewire_master_read_byte (uint8_t *data)
 read data byte More...
 
bool onewire_master_write_byte (uint8_t data)
 write data byte More...
 
bool onewire_master_function_read (uint8_t function, uint8_t *data, uint32_t bits)
 issue function and read data More...
 
bool onewire_master_function_write (uint8_t function, uint8_t *data, uint32_t bits)
 issue function and write data More...
 

Detailed Description

library for 1-wire protocol as master

Author
King Kévin kingk.nosp@m.evin.nosp@m.@cuvo.nosp@m.odoo.nosp@m..info
Date
2017-2018
Note
peripherals used: timer timer used to measure 1-wire signal timing, GPIO GPIO used for 1-wire signal
overdrive mode is not provided

Definition in file onewire_master.h.

Function Documentation

◆ onewire_master_crc()

uint8_t onewire_master_crc ( uint8_t *  data,
uint32_t  length 
)

compute CRC for 1-Wire

Note
this CRC-8 uses normal polynomial 0x31, reverse polynomial 0x8C, start value 0x00
Parameters
[in]databytes on which to calculate CRC checksum on
[in]lengthnumber of bytes in data
Returns
computed CRC checksum

Definition at line 318 of file onewire_master.c.

◆ onewire_master_function_read()

bool onewire_master_function_read ( uint8_t  function,
uint8_t *  data,
uint32_t  bits 
)

issue function and read data

Note
user needs to send a ROM command before
Parameters
[in]functionfunction command to send
[out]databuffer to save read bits (NULL if only the function command should be sent)
[in]bitsnumber of bits to read (0 if only the function command should be sent)
Returns
if operation succeeded

Definition at line 364 of file onewire_master.c.

◆ onewire_master_function_write()

bool onewire_master_function_write ( uint8_t  function,
uint8_t *  data,
uint32_t  bits 
)

issue function and write data

Note
user needs to send a ROM command before
Parameters
[in]functionfunction command to send
[out]datadata to write (NULL if only the function command should be sent)
[in]bitsnumber of bits to write (0 if only the function command should be sent)
Returns
if operation succeeded

Definition at line 385 of file onewire_master.c.

◆ onewire_master_read_byte()

bool onewire_master_read_byte ( uint8_t *  data)

read data byte

Note
it is up to the user to send the reset pulse
Parameters
[out]databuffer to save data read
Returns
if operation succeeded

Definition at line 338 of file onewire_master.c.

◆ onewire_master_reset()

bool onewire_master_reset ( void  )

send reset pulse

Returns
if slaves have indicated their presence

Definition at line 227 of file onewire_master.c.

◆ onewire_master_rom_match()

bool onewire_master_rom_match ( uint64_t  code)

send MATCH ROM command to select a specific slave

Note
user needs to send reset pulse before
Parameters
[in]codeROM code of slave to select
Returns
if operation succeeded

Definition at line 502 of file onewire_master.c.

◆ onewire_master_rom_read()

uint64_t onewire_master_rom_read ( void  )

send READ ROM command and read ROM code response

Note
user needs to send reset pulse before
Returns
ROM code read

Definition at line 407 of file onewire_master.c.

◆ onewire_master_rom_search()

bool onewire_master_rom_search ( uint64_t *  code,
bool  alarm 
)

send SEARCH ROM command

Note
user needs to send reset pulse before
Warning
undefined behaviour if a ROM code different than the last found is provided
Parameters
[in,out]codeuse 0 to start search ROM code from scratch, or last know value to search next; writes back next ROM code found, or 0 if error occurred
[in]alarmsearch only for ROM codes for slaves with an alarm flag set
Returns
if an additional slave has been detected
Warning
when the code found is 0 it very probably means that the 1-wire line is not pulled up instead of actually having found a slave with ROM code 0

Definition at line 426 of file onewire_master.c.

◆ onewire_master_rom_skip()

bool onewire_master_rom_skip ( void  )

send SKIP ROM command (all slaves on the bus will be selected)

Note
user needs to send reset pulse before
Returns
if operation succeeded

Definition at line 494 of file onewire_master.c.

◆ onewire_master_write_byte()

bool onewire_master_write_byte ( uint8_t  data)

write data byte

Note
it is up to the user to send the reset pulse
Parameters
[in]databyte to write
Returns
if operation succeeded

Definition at line 353 of file onewire_master.c.