summaryrefslogtreecommitdiff
path: root/bsp/phytium/libraries/standalone/drivers/mio/fmio/fmio.h
blob: 5343130addfe2533dc254d7a9088aedc4da74c54 (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
72
73
74
75
76
77
78
79
80
81
82
/*
 * Copyright : (C) 2022 Phytium Information Technology, Inc.
 * All Rights Reserved.
 *
 * This program is OPEN SOURCE software: you can redistribute it and/or modify it
 * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
 * either version 1.0 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the Phytium Public License for more details.
 *
 *
 * FilePath: fmio.h
 * Date: 2022-06-21 15:40:06
 * LastEditTime: 2022-06-21 15:40:06
 * Description:  This file is for
 *
 * Modify History:
 *  Ver   Who        Date         Changes
 * ----- ------     --------    --------------------------------------
 */

#ifndef DRIVERS_MIO_FMIO_H
#define DRIVERS_MIO_FMIO_H

#ifdef __cplusplus
extern "C"
{
#endif

/***************************** Include Files *********************************/

#include "ftypes.h"
#include "ferror_code.h"
#include "fassert.h"

/************************** Constant Definitions *****************************/
#define FMIO_SUCCESS          FT_SUCCESS
#define FMIO_ERR_INVAL_PARM   FT_MAKE_ERRCODE(ErrModBsp, ErrBspMio, 1)
#define FMIO_ERR_NOT_READY    FT_MAKE_ERRCODE(ErrModBsp, ErrBspMio, 2)
#define FMIO_ERR_TIMEOUT      FT_MAKE_ERRCODE(ErrModBsp, ErrBspMio, 3)
#define FMIO_ERR_NOT_SUPPORT  FT_MAKE_ERRCODE(ErrModBsp, ErrBspMio, 4)
#define FMIO_ERR_INVAL_STATE  FT_MAKE_ERRCODE(ErrModBsp, ErrBspMio, 5)

/**************************** Type Definitions *******************************/

typedef struct
{
    u32     instance_id;        /*mio id*/
    uintptr func_base_addr; /*I2C or UART function address*/
    u32     irq_num;     /* Device intrrupt id */
    uintptr mio_base_addr;  /*MIO control address*/
} FMioConfig;               /*mio configs*/

typedef struct
{
    FMioConfig config;  /* mio config */
    u32 is_ready;   /* mio initialize the complete flag */
} FMioCtrl;

/************************** Function Prototypes ******************************/
/*获取MIO的配置信息*/
const FMioConfig *FMioLookupConfig(u32 instance_id);

/*初始化MIO的功能*/
FError FMioFuncInit(FMioCtrl *instance_p, u32 mio_type);

/*去初始化*/
FError FMioFuncDeinit(FMioCtrl *instance_p);

/*获取功能配置的基地址*/
uintptr FMioFuncGetAddress(FMioCtrl *instance_p, u32 mio_type);

/*获取功能的中断号*/
u32 FMioFuncGetIrqNum(FMioCtrl *instance_p, u32 mio_type);

#ifdef __cplusplus
}
#endif

#endif