• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (C) 2022 Beken Corporation
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #pragma once
16 
17 #include <components/log.h>
18 #include <driver/hal/hal_spi_types.h>
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 typedef struct {
25 	uint32_t spi_isr_cnt;
26 	uint32_t tx_fifo_isr_cnt;
27 	uint32_t rx_fifo_isr_cnt;
28 	uint32_t tx_finish_isr_cnt;
29 	uint32_t rx_finish_isr_cnt;
30 	uint32_t tx_underflow_isr_cnt;
31 	uint32_t rx_overflow_isr_cnt;
32 	uint32_t slave_release_isr_cnt;
33 } spi_statis_t;
34 
35 #if CONFIG_SPI_STATIS
36 
37 #define SPI_STATIS_DEC() spi_statis_t * spi_statis = NULL
38 #define SPI_STATIS_GET(_statis, _id) (_statis) = spi_statis_get_statis(_id)
39 #define SPI_STATIS_SET(_statis, _v) (_statis) = (_v)
40 #define SPI_STATIS_ADD(_statis, _v) (_statis) += (_v);
41 #define SPI_STATIS_INC(_statis) SPI_STATIS_ADD((_statis), 1)
42 bk_err_t spi_statis_init(void);
43 spi_statis_t* spi_statis_get_statis(spi_id_t id);
44 void spi_statis_dump(spi_id_t id);
45 
46 #else
47 
48 #define SPI_STATIS_DEC()
49 #define SPI_STATIS_GET(_statis, _id)
50 #define SPI_STATIS_SET(_id, _v)
51 #define SPI_STATIS_ADD(_statis, _v)
52 #define SPI_STATIS_INC(_statis)
53 #define spi_statis_init()
54 #define spi_statis_dump(id)
55 
56 #endif
57 
58 #ifdef __cplusplus
59 }
60 #endif
61 
62