OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [sw/] [drivers/] [simple-spi/] [include/] [simple-spi.h] - Blame information for rev 393

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 374 julius
/*
2
 * Defines and prototypes for Simple SPI module driver
3
 *
4
 * Julius Baxter, julius.baxter@orsoc.se
5
 *
6
 */
7
 
8
#ifndef _SIMPLE_SPI_H_
9
#define _SIMPLE_SPI_H_
10
 
11
#define SIMPLESPI_SPCR 0x00 // Control register
12
#define SIMPLESPI_SPSR 0x01 // Status register
13
#define SIMPLESPI_SPDR 0x02 // Data register
14
#define SIMPLESPI_SPER 0x03 // Extensions Register
15
#define SIMPLESPI_SSPU 0x04 // Slave select pickups
16
 
17
//
18
// Bit masks for each register //
19
//
20
 
21
// Control Register
22
#define SIMPLESPI_SPCR_SPR  0x03 // Clock rate select
23
#define SIMPLESPI_SPCR_CPHA 0x04 // Clock phase
24
#define SIMPLESPI_SPCR_CPOL 0x08 // Clock polarity
25
#define SIMPLESPI_SPCR_MSTR 0x10 // Master mode select
26
#define SIMPLESPI_SPCR_SPE  0x40 // Serial peripheral enable (core enable)
27
#define SIMPLESPI_SPCR_SPIE 0x80 // Interrupt enable
28
 
29
// Status Register
30
#define SIMPLESPI_SPSR_RFEMPTY 0x01 // Read FIFO buffer empty
31
#define SIMPLESPI_SPSR_RFFULL  0x02 // Read FIFO buffer full
32
#define SIMPLESPI_SPSR_WFEMPTY 0x04 // Write FIFO buffer empty
33
#define SIMPLESPI_SPSR_WFFULL  0x08 // Write FIFO buffer full
34
#define SIMPLESPI_SPSR_WCOL    0x40 // Write collision
35
#define SIMPLESPI_SPSR_SPIF    0x80 // Interrupt flag
36
 
37
// Extensions register
38
#define SIMPLESPI_SPER_ESPR    0x03 // Extended clock rate select
39
#define SIMPLESPI_SPER_ICNT    0xc0 // Interrupt count (IRQ set after no. xfer)
40
 
41
// Pass these to the spi_core_set_int_count() function
42
#define SIMPLESPI_SPER_ICNT_EVERY 0x00
43
#define SIMPLESPI_SPER_ICNT_TWO   0x40
44
#define SIMPLESPI_SPER_ICNT_THREE 0x80
45
#define SIMPLESPI_SPER_ICNT_FOUR  0xC0
46
 
47
 
48
void spi_core_enable(int core);
49
void spi_core_disable(int core);
50
void spi_core_interrupt_enable(int core);
51
void spi_core_interrupt_disable(int core);
52
void spi_core_interrupt_flag_clear(int core);
53
void spi_core_clock_setup(int core, char polarity, char phase, char rate,char ext_rate);
54
void spi_core_set_int_count(int core, char cnt);
55
void spi_core_slave_select(int core, char slave_sel_dec);
56
void spi_core_write_data(int core, char data);
57
int spi_core_data_avail(int core);
58
int spi_core_write_avail(int core);
59
char spi_core_read_data(int core);
60
 
61
 
62
 
63
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.