NEORV32 Software Framework Documentation
The NEORV32 RISC-V Processor
Loading...
Searching...
No Matches
neorv32_onewire.h
Go to the documentation of this file.
1// ================================================================================ //
2// The NEORV32 RISC-V Processor - https://github.com/stnolting/neorv32 //
3// Copyright (c) NEORV32 contributors. //
4// Copyright (c) 2020 - 2024 Stephan Nolting. All rights reserved. //
5// Licensed under the BSD-3-Clause license, see LICENSE for details. //
6// SPDX-License-Identifier: BSD-3-Clause //
7// ================================================================================ //
8
18#ifndef neorv32_onewire_h
19#define neorv32_onewire_h
20
21#include <stdint.h>
22
23
24/**********************************************************************/
29typedef volatile struct __attribute__((packed,aligned(4))) {
30 uint32_t CTRL;
31 uint32_t DCMD;
33
35#define NEORV32_ONEWIRE ((neorv32_onewire_t*) (NEORV32_ONEWIRE_BASE))
36
54
66/**********************************************************************/
70#define ONEWIRE_CMD_NOP (0b00) // no operation
71#define ONEWIRE_CMD_BIT (0b01) // read/write single bit
72#define ONEWIRE_CMD_BYTE (0b10) // read/write full byte
73#define ONEWIRE_CMD_RESET (0b11) // generate reset pulse and check for presence
77/**********************************************************************/
83int neorv32_onewire_setup(uint32_t t_base);
84void neorv32_onewire_enable(void);
86void neorv32_onewire_flush(void);
87int neorv32_onewire_sense(void);
88
89int neorv32_onewire_busy(void);
90void neorv32_onewire_reset(void);
94void neorv32_onewire_write_bit(uint8_t bit);
97void neorv32_onewire_write_byte(uint8_t byte);
98
101void neorv32_onewire_write_bit_blocking(uint8_t bit);
103void neorv32_onewire_write_byte_blocking(uint8_t byte);
107#endif // neorv32_onewire_h
int neorv32_onewire_busy(void)
Definition neorv32_onewire.c:142
void neorv32_onewire_read_byte(void)
Definition neorv32_onewire.c:245
void neorv32_onewire_flush(void)
Definition neorv32_onewire.c:116
int neorv32_onewire_sense(void)
Definition neorv32_onewire.c:127
int neorv32_onewire_setup(uint32_t t_base)
Definition neorv32_onewire.c:55
void neorv32_onewire_write_byte(uint8_t byte)
Definition neorv32_onewire.c:273
void neorv32_onewire_reset(void)
Definition neorv32_onewire.c:164
int neorv32_onewire_get_fifo_depth(void)
Definition neorv32_onewire.c:42
int neorv32_onewire_reset_get_presence(void)
Definition neorv32_onewire.c:178
void neorv32_onewire_write_bit(uint8_t bit)
Definition neorv32_onewire.c:228
uint8_t neorv32_onewire_read_byte_get(void)
Definition neorv32_onewire.c:259
void neorv32_onewire_write_bit_blocking(uint8_t bit)
Definition neorv32_onewire.c:332
uint8_t neorv32_onewire_read_byte_blocking(void)
Definition neorv32_onewire.c:352
void neorv32_onewire_disable(void)
Definition neorv32_onewire.c:107
int neorv32_onewire_available(void)
Definition neorv32_onewire.c:26
uint8_t neorv32_onewire_read_bit_get(void)
Definition neorv32_onewire.c:209
void neorv32_onewire_read_bit(void)
Definition neorv32_onewire.c:195
NEORV32_ONEWIRE_DCMD_enum
Definition neorv32_onewire.h:56
@ ONEWIRE_DCMD_DATA_LSB
Definition neorv32_onewire.h:57
@ ONEWIRE_DCMD_DATA_MSB
Definition neorv32_onewire.h:58
@ ONEWIRE_DCMD_PRESENCE
Definition neorv32_onewire.h:61
@ ONEWIRE_DCMD_CMD_LO
Definition neorv32_onewire.h:59
@ ONEWIRE_DCMD_CMD_HI
Definition neorv32_onewire.h:60
void neorv32_onewire_write_byte_blocking(uint8_t byte)
Definition neorv32_onewire.c:372
uint8_t neorv32_onewire_read_bit_blocking(void)
Definition neorv32_onewire.c:312
NEORV32_ONEWIRE_CTRL_enum
Definition neorv32_onewire.h:38
@ ONEWIRE_CTRL_FIFO_MSB
Definition neorv32_onewire.h:47
@ ONEWIRE_CTRL_FIFO_LSB
Definition neorv32_onewire.h:46
@ ONEWIRE_CTRL_TX_FULL
Definition neorv32_onewire.h:49
@ ONEWIRE_CTRL_RX_AVAIL
Definition neorv32_onewire.h:50
@ ONEWIRE_CTRL_CLKDIV7
Definition neorv32_onewire.h:44
@ ONEWIRE_CTRL_BUSY
Definition neorv32_onewire.h:52
@ ONEWIRE_CTRL_EN
Definition neorv32_onewire.h:39
@ ONEWIRE_CTRL_PRSC0
Definition neorv32_onewire.h:41
@ ONEWIRE_CTRL_CLKDIV0
Definition neorv32_onewire.h:43
@ ONEWIRE_CTRL_CLEAR
Definition neorv32_onewire.h:40
@ ONEWIRE_CTRL_PRSC1
Definition neorv32_onewire.h:42
@ ONEWIRE_CTRL_SENSE
Definition neorv32_onewire.h:51
void neorv32_onewire_enable(void)
Definition neorv32_onewire.c:98
int neorv32_onewire_reset_blocking(void)
Definition neorv32_onewire.c:292
Definition neorv32_onewire.h:29
uint32_t CTRL
Definition neorv32_onewire.h:30
uint32_t DCMD
Definition neorv32_onewire.h:31