NEORV32 Software Framework Documentation
The NEORV32 RISC-V Processor
Loading...
Searching...
No Matches
neorv32_onewire.h File Reference

1-Wire Interface Controller (ONEWIRE) HW driver header file. More...

#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  neorv32_onewire_t
 

Functions

Prototypes
int neorv32_onewire_available (void)
 
int neorv32_onewire_setup (uint32_t t_base)
 
void neorv32_onewire_enable (void)
 
void neorv32_onewire_disable (void)
 
int neorv32_onewire_sense (void)
 
int neorv32_onewire_busy (void)
 
void neorv32_onewire_reset (void)
 
int neorv32_onewire_reset_get_presence (void)
 
void neorv32_onewire_read_bit (void)
 
uint8_t neorv32_onewire_read_bit_get (void)
 
void neorv32_onewire_write_bit (uint8_t bit)
 
void neorv32_onewire_read_byte (void)
 
uint8_t neorv32_onewire_read_byte_get (void)
 
void neorv32_onewire_write_byte (uint8_t byte)
 
int neorv32_onewire_reset_blocking (void)
 
uint8_t neorv32_onewire_read_bit_blocking (void)
 
void neorv32_onewire_write_bit_blocking (uint8_t bit)
 
uint8_t neorv32_onewire_read_byte_blocking (void)
 
void neorv32_onewire_write_byte_blocking (uint8_t byte)
 

IO Device: 1-Wire Interface Controller (ONEWIRE)

#define NEORV32_ONEWIRE   ((neorv32_onewire_t*) (NEORV32_ONEWIRE_BASE))
 
enum  NEORV32_ONEWIRE_CTRL_enum {
  ONEWIRE_CTRL_EN = 0 , ONEWIRE_CTRL_PRSC0 = 1 , ONEWIRE_CTRL_PRSC1 = 2 , ONEWIRE_CTRL_CLKDIV0 = 3 ,
  ONEWIRE_CTRL_CLKDIV1 = 4 , ONEWIRE_CTRL_CLKDIV2 = 5 , ONEWIRE_CTRL_CLKDIV3 = 6 , ONEWIRE_CTRL_CLKDIV4 = 7 ,
  ONEWIRE_CTRL_CLKDIV5 = 8 , ONEWIRE_CTRL_CLKDIV6 = 9 , ONEWIRE_CTRL_CLKDIV7 = 10 , ONEWIRE_CTRL_TRIG_RST = 11 ,
  ONEWIRE_CTRL_TRIG_BIT = 12 , ONEWIRE_CTRL_TRIG_BYTE = 13 , ONEWIRE_CTRL_SENSE = 29 , ONEWIRE_CTRL_PRESENCE = 30 ,
  ONEWIRE_CTRL_BUSY = 31
}
 
enum  NEORV32_ONEWIRE_DATA_enum { ONEWIRE_DATA_LSB = 0 , ONEWIRE_DATA_MSB = 7 }
 

Detailed Description

1-Wire Interface Controller (ONEWIRE) HW driver header file.

Note
These functions should only be used if the ONEWIRE unit was synthesized (IO_ONEWIRE_EN = true).
See also
https://stnolting.github.io/neorv32/sw/files.html

Macro Definition Documentation

◆ NEORV32_ONEWIRE

#define NEORV32_ONEWIRE   ((neorv32_onewire_t*) (NEORV32_ONEWIRE_BASE))

ONEWIRE module hardware access (neorv32_onewire_t)

Enumeration Type Documentation

◆ NEORV32_ONEWIRE_CTRL_enum

ONEWIRE control register bits

Enumerator
ONEWIRE_CTRL_EN 

ONEWIRE control register(0) (r/w): ONEWIRE controller enable

ONEWIRE_CTRL_PRSC0 

ONEWIRE control register(1) (r/w): Clock prescaler select bit 0

ONEWIRE_CTRL_PRSC1 

ONEWIRE control register(2) (r/w): Clock prescaler select bit 1

ONEWIRE_CTRL_CLKDIV0 

ONEWIRE control register(3) (r/w): Clock divider bit 0

ONEWIRE_CTRL_CLKDIV1 

ONEWIRE control register(4) (r/w): Clock divider bit 1

ONEWIRE_CTRL_CLKDIV2 

ONEWIRE control register(5) (r/w): Clock divider bit 2

ONEWIRE_CTRL_CLKDIV3 

ONEWIRE control register(6) (r/w): Clock divider bit 3

ONEWIRE_CTRL_CLKDIV4 

ONEWIRE control register(7) (r/w): Clock divider bit 4

ONEWIRE_CTRL_CLKDIV5 

ONEWIRE control register(8) (r/w): Clock divider bit 5

ONEWIRE_CTRL_CLKDIV6 

ONEWIRE control register(9) (r/w): Clock divider bit 6

ONEWIRE_CTRL_CLKDIV7 

ONEWIRE control register(10) (r/w): Clock divider bit 7

ONEWIRE_CTRL_TRIG_RST 

ONEWIRE control register(11) (-/w): Trigger reset pulse, auto-clears

ONEWIRE_CTRL_TRIG_BIT 

ONEWIRE control register(12) (-/w): Trigger single-bit transmission, auto-clears

ONEWIRE_CTRL_TRIG_BYTE 

ONEWIRE control register(13) (-/w): Trigger full-byte transmission, auto-clears

ONEWIRE_CTRL_SENSE 

ONEWIRE control register(29) (r/-): Current state of the bus line

ONEWIRE_CTRL_PRESENCE 

ONEWIRE control register(30) (r/-): Bus presence detected

ONEWIRE_CTRL_BUSY 

ONEWIRE control register(31) (r/-): Operation in progress when set

◆ NEORV32_ONEWIRE_DATA_enum

ONEWIRE receive/transmit data register bits

Enumerator
ONEWIRE_DATA_LSB 

ONEWIRE data register(0) (r/w): Receive/transmit data (8-bit) LSB

ONEWIRE_DATA_MSB 

ONEWIRE data register(7) (r/w): Receive/transmit data (8-bit) MSB

Function Documentation

◆ neorv32_onewire_available()

int neorv32_onewire_available ( void )

Check if ONEWIRE controller was synthesized.

Returns
0 if ONEWIRE was not synthesized, 1 if ONEWIRE is available.

◆ neorv32_onewire_busy()

int neorv32_onewire_busy ( void )

Check if ONEWIRE module is busy.

Note
This function is non-blocking.
Returns
0 if not busy, 1 if busy.

◆ neorv32_onewire_disable()

void neorv32_onewire_disable ( void )

Disable ONEWIRE controller.

◆ neorv32_onewire_enable()

void neorv32_onewire_enable ( void )

Enable ONEWIRE controller.

◆ neorv32_onewire_read_bit()

void neorv32_onewire_read_bit ( void )

Initiate single-bit read.

Note
This function is non-blocking.

◆ neorv32_onewire_read_bit_blocking()

uint8_t neorv32_onewire_read_bit_blocking ( void )

Read single bit.

Warning
This function is blocking!
Returns
Read bit in bit 0.

◆ neorv32_onewire_read_bit_get()

uint8_t neorv32_onewire_read_bit_get ( void )

Get bit from previous single-bit read operation

Note
This function is non-blocking.
Returns
Read bit in bit 0.

◆ neorv32_onewire_read_byte()

void neorv32_onewire_read_byte ( void )

Initiate read byte.

Note
This function is non-blocking.

◆ neorv32_onewire_read_byte_blocking()

uint8_t neorv32_onewire_read_byte_blocking ( void )

Read byte.

Warning
This function is blocking!
Returns
Read byte.

◆ neorv32_onewire_read_byte_get()

uint8_t neorv32_onewire_read_byte_get ( void )

Get data from previous read byte operation.

Note
This function is non-blocking.
Returns
Read byte.

◆ neorv32_onewire_reset()

void neorv32_onewire_reset ( void )

Initiate reset pulse.

Note
This function is non-blocking.

◆ neorv32_onewire_reset_blocking()

int neorv32_onewire_reset_blocking ( void )

Generate reset pulse and check if any bus device is present.

Warning
This function is blocking!
Returns
0 if at lest one device is present, -1 otherwise

◆ neorv32_onewire_reset_get_presence()

int neorv32_onewire_reset_get_presence ( void )

Get bus presence (after RESET).

Note
This function is non-blocking.
Returns
0 if at lest one device is present, -1 otherwise

◆ neorv32_onewire_sense()

int neorv32_onewire_sense ( void )

Get current bus state.

Returns
1 if bus is high, 0 if bus is low.

◆ neorv32_onewire_setup()

int neorv32_onewire_setup ( uint32_t t_base)

Reset, configure and enable ONEWIRE interface controller.

Parameters
[in]t_baseBase tick time in ns.
Returns
0 if configuration failed, otherwise the actual t_base time in ns is returned.

◆ neorv32_onewire_write_bit()

void neorv32_onewire_write_bit ( uint8_t bit)

Initiate single-bit write.

Note
This function is non-blocking.
Parameters
[in]bitBit to be send.

◆ neorv32_onewire_write_bit_blocking()

void neorv32_onewire_write_bit_blocking ( uint8_t bit)

Write single bit.

Warning
This function is blocking!
Parameters
[in]bitBit to be send.

◆ neorv32_onewire_write_byte()

void neorv32_onewire_write_byte ( uint8_t byte)

Initiate write byte.

Note
This function is non-blocking.
Parameters
[in]byteByte to be send.

◆ neorv32_onewire_write_byte_blocking()

void neorv32_onewire_write_byte_blocking ( uint8_t byte)

Write byte.

Warning
This function is blocking!
Parameters
[in]byteByte to be send.