summaryrefslogtreecommitdiff
path: root/bsp/nuvoton/libraries/m460/rtt_port/drv_ebi.c
blob: 3d9362f49c6e6ad3c84d9579e82560c385992a92 (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
/**************************************************************************//**
*
* @copyright (C) 2020 Nuvoton Technology Corp. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date            Author           Notes
* 2022-3-15       Wayne            First version
*
******************************************************************************/
#include <drv_ebi.h>

#ifdef  BSP_USING_EBI
#define MAX_BANK    EBI_BANK2

/* Private variables ------------------------------------------------------------*/
static uint8_t nu_ebi_bank_mask = 0;

/* Public functions -------------------------------------------------------------*/
rt_err_t nu_ebi_init(uint32_t u32Bank, uint32_t u32DataWidth, uint32_t u32TimingClass, uint32_t u32BusMode, uint32_t u32CSActiveLevel)
{
    if (u32Bank > MAX_BANK)
        return -(RT_ERROR);

    /* Check this bank is not used */
    if ((1 << u32Bank) & nu_ebi_bank_mask)
        return -(RT_ERROR);

    /* Initialize EBI */
    EBI_Open(u32Bank, u32DataWidth, u32TimingClass, u32BusMode, u32CSActiveLevel);

    nu_ebi_bank_mask |= (1 << u32Bank);

    return RT_EOK;
}

#endif //BSP_USING_EBI