Mistake on this page?
Report an issue in GitHub or email us
SPIMasterTester.h
1 /*
2  * Copyright (c) 2019, Arm Limited and affiliates.
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef SPI_MASTER_TESTER_H
19 #define SPI_MASTER_TESTER_H
20 
21 #include "SPITester.h"
22 
23 class SPIMasterTester: public SPITester {
24 public:
25 
26  SPIMasterTester(const PinList *form_factor, const PinList *exclude_pins)
27  : SPITester(form_factor, exclude_pins)
28  {
29 
30  }
31 
32  /**
33  * Read the number of transfers which have occurred
34  *
35  * @return The number of SPI transfers that have completed since
36  * spi was reset.
37  */
38  uint16_t get_transfer_count();
39 
40  /**
41  * Read a checksum of data send to the tester
42  *
43  * @return The sum of all bytes sent to the tester since reset.
44  */
45  uint32_t get_receive_checksum();
46 
47  /**
48  * Set the clock mode of the spi_slave module.
49  *
50  * @param mode Spi clock mode
51  */
52  void set_mode(SpiMode mode);
53 
54  /**
55  * Set bit order durring transmission of the spi_slave module.
56  *
57  * @param mode Spi clock mode
58  */
59  void set_bit_order(SpiBitOrder bit_order);
60 
61  /**
62  * Set symbol size used durring transmission of the spi_slave module.
63  *
64  * @param mode Spi clock mode
65  */
66  void set_sym_size(uint32_t sym_size);
67 
68  /**
69  * Set full-duplex/half-duplex transmission mode of the spi_slave module.
70  *
71  * @param duplex duplex mode used for the transmission
72  */
73  void set_duplex_mode(SpiDuplex duplex);
74 
75  /**
76  * Set tx/rx symbol count.
77  *
78  * @tx_cnt TX symbol count
79  * @rx_cnt RX symbol count
80  *
81  * @note Required only in Half-Duplex mode.
82  */
83  void set_hd_tx_rx_cnt(uint16_t tx_cnt, uint16_t rx_cnt);
84 
85  /**
86  * Get nano seconds between chip select assertion and the first spi clock edge.
87  *
88  * @return nano seconds between chip select assertion and the first spi clock edge.
89  *
90  * @note Number of nano seconds is calculated based of number of counted clk changes and
91  * clk frequency (100 MHz => 1 clk tick corresponds to 10 ns).
92  * Accuracy of the returned value is +/- 10 ns.
93  */
94  uint32_t get_cs_to_first_clk_edge_ns();
95 
96  /**
97  * Get nano seconds between last spi clock edge and chip select de-assertion.
98  *
99  * @return nano seconds between last spi clock edge and chip select de-assertion.
100  *
101  * @note Number of nano seconds is calculated based of number of counted clk changes and
102  * clk frequency (100 MHz => 1 clk tick corresponds to 10 ns).
103  * Accuracy of the returned value is +/- 10 ns.
104  */
105  uint32_t get_last_clk_edge_to_cs_ns();
106 
107  /**
108  * Get SCLK and SIN states on transmission start and stop.
109  *
110  * @return latched SCLK and SIN states on transmission start and stop.
111  *
112  * @note Stats are encoded as fallows (bit 0 - LSB):
113  * - bit 0: start SCLK
114  * - bit 1: start SIN
115  * - bit 2: stop SCLK,
116  * - bit 3: stop SIN,
117  * - other: unused
118  */
119  uint8_t get_start_stop_stats();
120 
121 };
122 
123 #endif
void set_mode(SpiMode mode)
Set the clock mode of the spi_slave module.
void set_sym_size(uint32_t sym_size)
Set symbol size used durring transmission of the spi_slave module.
uint8_t get_start_stop_stats()
Get SCLK and SIN states on transmission start and stop.
void set_bit_order(SpiBitOrder bit_order)
Set bit order durring transmission of the spi_slave module.
void set_duplex_mode(SpiDuplex duplex)
Set full-duplex/half-duplex transmission mode of the spi_slave module.
uint16_t get_transfer_count()
Read the number of transfers which have occurred.
Definition: pinmap.h:36
uint32_t get_receive_checksum()
Read a checksum of data send to the tester.
void set_hd_tx_rx_cnt(uint16_t tx_cnt, uint16_t rx_cnt)
Set tx/rx symbol count.
uint32_t get_last_clk_edge_to_cs_ns()
Get nano seconds between last spi clock edge and chip select de-assertion.
uint32_t get_cs_to_first_clk_edge_ns()
Get nano seconds between chip select assertion and the first spi clock edge.
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.