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
 

Macros

ONEWIRE DCMD commands
#define ONEWIRE_CMD_NOP   (0b00)
 
#define ONEWIRE_CMD_BIT   (0b01)
 
#define ONEWIRE_CMD_BYTE   (0b10)
 
#define ONEWIRE_CMD_RESET   (0b11)
 

Functions

Prototypes
int neorv32_onewire_available (void)
 
int neorv32_onewire_get_fifo_depth (void)
 
int neorv32_onewire_setup (uint32_t t_base)
 
void neorv32_onewire_enable (void)
 
void neorv32_onewire_disable (void)
 
void neorv32_onewire_flush (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_CLEAR = 1 , ONEWIRE_CTRL_PRSC0 = 2 , ONEWIRE_CTRL_PRSC1 = 3 ,
  ONEWIRE_CTRL_CLKDIV0 = 4 , ONEWIRE_CTRL_CLKDIV7 = 11 , ONEWIRE_CTRL_FIFO_LSB = 15 , ONEWIRE_CTRL_FIFO_MSB = 18 ,
  ONEWIRE_CTRL_TX_FULL = 28 , ONEWIRE_CTRL_RX_AVAIL = 29 , ONEWIRE_CTRL_SENSE = 30 , ONEWIRE_CTRL_BUSY = 31
}
 
enum  NEORV32_ONEWIRE_DCMD_enum {
  ONEWIRE_DCMD_DATA_LSB = 0 , ONEWIRE_DCMD_DATA_MSB = 7 , ONEWIRE_DCMD_CMD_LO = 8 , ONEWIRE_DCMD_CMD_HI = 9 ,
  ONEWIRE_DCMD_PRESENCE = 10
}
 

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_CLEAR 

ONEWIRE control register(1) (-/w): Clear RXT FIFO, auto-clears

ONEWIRE_CTRL_PRSC0 

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

ONEWIRE_CTRL_PRSC1 

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

ONEWIRE_CTRL_CLKDIV0 

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

ONEWIRE_CTRL_CLKDIV7 

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

ONEWIRE_CTRL_FIFO_LSB 

ONEWIRE control register(15) (r/-): log2(FIFO size), LSB

ONEWIRE_CTRL_FIFO_MSB 

ONEWIRE control register(18) (r/-): log2(FIFO size), MSB

ONEWIRE_CTRL_TX_FULL 

ONEWIRE control register(28) (r/-): TX FIFO full

ONEWIRE_CTRL_RX_AVAIL 

ONEWIRE control register(29) (r/-): RX FIFO data available

ONEWIRE_CTRL_SENSE 

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

ONEWIRE_CTRL_BUSY 

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

◆ NEORV32_ONEWIRE_DCMD_enum

ONEWIRE command and data register bits

Enumerator
ONEWIRE_DCMD_DATA_LSB 

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

ONEWIRE_DCMD_DATA_MSB 

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

ONEWIRE_DCMD_CMD_LO 

ONEWIRE data/data register(8) (-/w): Operation command LSB

ONEWIRE_DCMD_CMD_HI 

ONEWIRE data/data register(9) (-/w): Operation command MSB

ONEWIRE_DCMD_PRESENCE 

ONEWIRE data/data register(10) (r/-): Bus presence detected

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.

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_flush()

void neorv32_onewire_flush ( void )

Clear RTX FIFO.

◆ neorv32_onewire_get_fifo_depth()

int neorv32_onewire_get_fifo_depth ( void )

Get ONEWIRE FIFO depth.

Returns
FIFO depth (number of entries), zero if no FIFO implemented

◆ 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.