summaryrefslogtreecommitdiffhomepage
path: root/source/spi.h
blob: 100a73cfd94897c3bbd4ef3a5cf8b15d93a3ff86 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
 *       spi.h
 *
 *       Copyright (C) 2018, 2019 Mind Chasers Inc.
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 *
 */

#ifndef SPI_H_
#define SPI_H_

/*******************************************************************************
* SPI Definitions
******************************************************************************/
#define DSPI_MASTER_BASEADDR SPI0
#define DSPI_MASTER_CLK_SRC DSPI0_CLK_SRC
#define DSPI_MASTER_CLK_FREQ CLOCK_GetFreq(DSPI0_CLK_SRC)
#define DSPI_TRANSFER_BAUDRATE 1000000U /*! Transfer baudrate - 1M */

/* Memory Address Map
 * 9-bit words are transferred
 * DEV_AD, RWN
 * MEM_AD
 */

#define SPI_READ 1
#define SPI_WRITE 0

#define SPI_DEV_AD_SCI_SEL_CH_0		0x00
#define SPI_DEV_AD_SCI_SEL_CH_1		0x01
#define SPI_DEV_AD_DUAL_0			0x02
#define SPI_DEV_AD_SCI_SEL_CH_2		0x04
#define SPI_DEV_AD_SCI_SEL_CH_3		0x05
#define SPI_DEV_AD_DUAL_1			0x06
#define SPI_DEV_AD_DPRAM_RX			0x08
#define SPI_DEV_AD_DPRAM_TX			0x0c
#define SPI_DEV_AD_DPRAM_PTRS		0x10
#define SPI_DEV_AD_INT_SEL			0X11
#define SPI_DEV_AD_PARAM_0			0x20
#define SPI_DEV_AD_PARAM_1			0x24
#define SPI_DEV_AD_PARAM_2			0x28
#define SPI_DEV_AD_PARAM_2			0x2C
#define SPI_DEV_AD_PKT_FILTER_01	0X41
#define SPI_DEV_AD_PKT_FILTER_02	0X42
#define SPI_DEV_AD_PKT_FILTER_03	0X43
#define SPI_DEV_AD_PKT_FILTER_10	0X48
#define SPI_DEV_AD_PKT_FILTER_12	0X4a
#define SPI_DEV_AD_PKT_FILTER_13	0X4b
#define SPI_DEV_AD_PKT_FILTER_20	0x50
#define SPI_DEV_AD_PKT_FILTER_21	0X51
#define SPI_DEV_AD_PKT_FILTER_23	0X53



int spi_init(dspi_master_config_t);
int test_spi(uint8_t, uint8_t);
int write_spi(uint8_t, uint8_t, uint8_t*, uint8_t);
int read_spi(uint8_t, uint8_t, uint8_t*, uint8_t);

#endif /* SPI_H_ */