NEORV32 Software Framework Documentation
The NEORV32 RISC-V Processor
Loading...
Searching...
No Matches
neorv32_spi.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_spi_h
19#define neorv32_spi_h
20
21#include <stdint.h>
22
23
24/**********************************************************************/
29typedef volatile struct __attribute__((packed,aligned(4))) {
30 uint32_t CTRL;
31 uint32_t DATA;
33
35#define NEORV32_SPI ((neorv32_spi_t*) (NEORV32_SPI_BASE))
36
67
78/**********************************************************************/
82int neorv32_spi_available(void);
83void neorv32_spi_setup(int prsc, int cdiv, int clk_phase, int clk_polarity, uint32_t irq_mask);
86uint32_t neorv32_spi_get_clock_speed(void);
87void neorv32_spi_disable(void);
88void neorv32_spi_enable(void);
90void neorv32_spi_cs_en(int cs);
91void neorv32_spi_cs_dis(void);
92uint8_t neorv32_spi_trans(uint8_t tx_data);
93void neorv32_spi_put_nonblocking(uint8_t tx_data);
94uint8_t neorv32_spi_get_nonblocking(void);
97int neorv32_spi_check_cs(void);
98int neorv32_spi_busy(void);
101#endif // neorv32_spi_h
uint32_t neorv32_spi_get_clock_speed(void)
Definition neorv32_spi.c:85
int neorv32_spi_busy(void)
Definition neorv32_spi.c:247
void neorv32_spi_highspeed_disable(void)
Definition neorv32_spi.c:74
int neorv32_spi_available(void)
Definition neorv32_spi.c:26
void neorv32_spi_cs_en(int cs)
Definition neorv32_spi.c:144
uint8_t neorv32_spi_trans(uint8_t tx_data)
Definition neorv32_spi.c:172
void neorv32_spi_setup(int prsc, int cdiv, int clk_phase, int clk_polarity, uint32_t irq_mask)
Definition neorv32_spi.c:46
void neorv32_spi_disable(void)
Definition neorv32_spi.c:109
int neorv32_spi_check_cs(void)
Definition neorv32_spi.c:231
void neorv32_spi_enable(void)
Definition neorv32_spi.c:118
void neorv32_spi_cs_en_nonblocking(int cs)
Definition neorv32_spi.c:209
void neorv32_spi_cs_dis(void)
Definition neorv32_spi.c:157
NEORV32_SPI_DATA_enum
Definition neorv32_spi.h:69
@ SPI_DATA_MSB
Definition neorv32_spi.h:71
@ SPI_DATA_CSEN
Definition neorv32_spi.h:72
@ SPI_DATA_CMD
Definition neorv32_spi.h:73
@ SPI_DATA_LSB
Definition neorv32_spi.h:70
uint8_t neorv32_spi_get_nonblocking(void)
Definition neorv32_spi.c:196
void neorv32_spi_highspeed_enable(void)
Definition neorv32_spi.c:65
void neorv32_spi_cs_dis_nonblocking(void)
Definition neorv32_spi.c:220
int neorv32_spi_get_fifo_depth(void)
Definition neorv32_spi.c:129
NEORV32_SPI_CTRL_enum
Definition neorv32_spi.h:38
@ SPI_CTRL_CDIV1
Definition neorv32_spi.h:46
@ SPI_CTRL_RX_AVAIL
Definition neorv32_spi.h:51
@ SPI_CTRL_FIFO_LSB
Definition neorv32_spi.h:61
@ SPI_CTRL_IRQ_RX_AVAIL
Definition neorv32_spi.h:56
@ SPI_CTRL_IRQ_IDLE
Definition neorv32_spi.h:59
@ SPI_CTRL_TX_EMPTY
Definition neorv32_spi.h:52
@ SPI_CTRL_PRSC1
Definition neorv32_spi.h:43
@ SPI_CTRL_CPHA
Definition neorv32_spi.h:40
@ SPI_CS_ACTIVE
Definition neorv32_spi.h:64
@ SPI_CTRL_TX_NHALF
Definition neorv32_spi.h:53
@ SPI_CTRL_EN
Definition neorv32_spi.h:39
@ SPI_CTRL_CPOL
Definition neorv32_spi.h:41
@ SPI_CTRL_BUSY
Definition neorv32_spi.h:65
@ SPI_CTRL_PRSC2
Definition neorv32_spi.h:44
@ SPI_CTRL_CDIV3
Definition neorv32_spi.h:48
@ SPI_CTRL_FIFO_MSB
Definition neorv32_spi.h:62
@ SPI_CTRL_IRQ_TX_HALF
Definition neorv32_spi.h:58
@ SPI_CTRL_TX_FULL
Definition neorv32_spi.h:54
@ SPI_CTRL_CDIV2
Definition neorv32_spi.h:47
@ SPI_CTRL_PRSC0
Definition neorv32_spi.h:42
@ SPI_CTRL_HIGHSPEED
Definition neorv32_spi.h:49
@ SPI_CTRL_CDIV0
Definition neorv32_spi.h:45
@ SPI_CTRL_IRQ_TX_EMPTY
Definition neorv32_spi.h:57
void neorv32_spi_put_nonblocking(uint8_t tx_data)
Definition neorv32_spi.c:185
Definition neorv32_spi.h:29
uint32_t CTRL
Definition neorv32_spi.h:30
uint32_t DATA
Definition neorv32_spi.h:31