NEORV32 Software Framework Documentation
The NEORV32 RISC-V Processor
Loading...
Searching...
No Matches
neorv32_twi.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_twi_h
19#define neorv32_twi_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_TWI ((neorv32_twi_t*) (NEORV32_TWI_BASE))
36
58
70/**********************************************************************/
74#define TWI_CMD_NOP (0b00) // no operation
75#define TWI_CMD_START (0b01) // generate start condition
76#define TWI_CMD_STOP (0b10) // generate stop condition
77#define TWI_CMD_RTX (0b11) // transmit+receive data byte
81/**********************************************************************/
85int neorv32_twi_available(void);
86void neorv32_twi_setup(int prsc, int cdiv, int clkstr);
88void neorv32_twi_disable(void);
89void neorv32_twi_enable(void);
90
91int neorv32_twi_sense_scl(void);
92int neorv32_twi_sense_sda(void);
93
94int neorv32_twi_busy(void);
95int neorv32_twi_get(uint8_t *data);
96
97int neorv32_twi_trans(uint8_t *data, int mack);
100
101void neorv32_twi_send_nonblocking(uint8_t data, int mack);
107#endif // neorv32_twi_h
void neorv32_twi_enable(void)
Definition neorv32_twi.c:81
void neorv32_twi_send_nonblocking(uint8_t data, int mack)
Definition neorv32_twi.c:214
int neorv32_twi_get_fifo_depth(void)
Definition neorv32_twi.c:62
NEORV32_TWI_DCMD_enum
Definition neorv32_twi.h:60
@ TWI_DCMD_CMD_LO
Definition neorv32_twi.h:64
@ TWI_DCMD_MSB
Definition neorv32_twi.h:62
@ TWI_DCMD_CMD_HI
Definition neorv32_twi.h:65
@ TWI_DCMD_LSB
Definition neorv32_twi.h:61
@ TWI_DCMD_ACK
Definition neorv32_twi.h:63
int neorv32_twi_busy(void)
Definition neorv32_twi.c:124
void neorv32_twi_generate_start(void)
Definition neorv32_twi.c:198
int neorv32_twi_sense_scl(void)
Definition neorv32_twi.c:92
NEORV32_TWI_CTRL_enum
Definition neorv32_twi.h:38
@ TWI_CTRL_FIFO_MSB
Definition neorv32_twi.h:50
@ TWI_CTRL_EN
Definition neorv32_twi.h:39
@ TWI_CTRL_BUSY
Definition neorv32_twi.h:56
@ TWI_CTRL_CDIV1
Definition neorv32_twi.h:44
@ TWI_CTRL_PRSC2
Definition neorv32_twi.h:42
@ TWI_CTRL_SENSE_SCL
Definition neorv32_twi.h:52
@ TWI_CTRL_FIFO_LSB
Definition neorv32_twi.h:49
@ TWI_CTRL_CDIV0
Definition neorv32_twi.h:43
@ TWI_CTRL_PRSC1
Definition neorv32_twi.h:41
@ TWI_CTRL_PRSC0
Definition neorv32_twi.h:40
@ TWI_CTRL_CDIV3
Definition neorv32_twi.h:46
@ TWI_CTRL_TX_FULL
Definition neorv32_twi.h:54
@ TWI_CTRL_CDIV2
Definition neorv32_twi.h:45
@ TWI_CTRL_CLKSTR
Definition neorv32_twi.h:47
@ TWI_CTRL_RX_AVAIL
Definition neorv32_twi.h:55
@ TWI_CTRL_SENSE_SDA
Definition neorv32_twi.h:53
int neorv32_twi_sense_sda(void)
Definition neorv32_twi.c:108
int neorv32_twi_get(uint8_t *data)
Definition neorv32_twi.c:141
void neorv32_twi_setup(int prsc, int cdiv, int clkstr)
Definition neorv32_twi.c:44
void neorv32_twi_generate_stop_nonblocking(void)
Definition neorv32_twi.c:228
int neorv32_twi_available(void)
Definition neorv32_twi.c:26
int neorv32_twi_trans(uint8_t *data, int mack)
Definition neorv32_twi.c:162
void neorv32_twi_generate_stop(void)
Definition neorv32_twi.c:185
void neorv32_twi_generate_start_nonblocking(void)
Definition neorv32_twi.c:239
void neorv32_twi_disable(void)
Definition neorv32_twi.c:72
Definition neorv32_twi.h:29
uint32_t CTRL
Definition neorv32_twi.h:30
uint32_t DCMD
Definition neorv32_twi.h:31