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 #include <os/mem.h>
16 #include "spi_hw.h"
17 #include "spi_statis.h"
18
19 #if CONFIG_SPI_STATIS
20
21 #define TAG "spi_statis"
22
23 static spi_statis_t s_spi_statis[SOC_SPI_UNIT_NUM] = {0};
24
spi_statis_init(void)25 bk_err_t spi_statis_init(void)
26 {
27 os_memset(&s_spi_statis, 0, sizeof(s_spi_statis));
28 return BK_OK;
29 }
30
spi_statis_get_statis(spi_id_t id)31 spi_statis_t* spi_statis_get_statis(spi_id_t id)
32 {
33 return &(s_spi_statis[id]);
34 }
35
spi_statis_dump(spi_id_t id)36 void spi_statis_dump(spi_id_t id)
37 {
38 BK_LOGI(TAG, "dump spi statis:\r\n");
39 BK_LOGI(TAG, "spi_isr_cnt: %d\r\n", s_spi_statis[id].spi_isr_cnt);
40 BK_LOGI(TAG, "tx_fifo_isr_cnt: %d\r\n", s_spi_statis[id].tx_fifo_isr_cnt);
41 BK_LOGI(TAG, "rx_fifo_isr_cnt: %d\r\n", s_spi_statis[id].rx_fifo_isr_cnt);
42 BK_LOGI(TAG, "tx_finish_isr_cnt: %d\r\n", s_spi_statis[id].tx_finish_isr_cnt);
43 BK_LOGI(TAG, "rx_finish_isr_cnt: %d\r\n", s_spi_statis[id].rx_finish_isr_cnt);
44 BK_LOGI(TAG, "tx_underflow_isr_cnt: %d\r\n", s_spi_statis[id].tx_underflow_isr_cnt);
45 BK_LOGI(TAG, "rx_overflow_isr_cnt: %d\r\n", s_spi_statis[id].rx_overflow_isr_cnt);
46 BK_LOGI(TAG, "slave_release_isr_cnt: %d\r\n", s_spi_statis[id].slave_release_isr_cnt);
47 }
48
49 #endif
50