gh_adc.h 10.4 KB
Newer Older
G
gokemicro 已提交
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 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243
/*!
*******************************************************************************
**
** \file      gh_adc.h
**
** \brief     ADC.
**
**            Copyright:   2012 - 2016 (C) GoKe Microelectronics
**
** \attention THIS SAMPLE CODE IS PROVIDED AS IS. GOKE MICROELECTRONICS
**            ACCEPTS NO RESPONSIBILITY OR LIABILITY FOR ANY ERRORS OR
**            OMMISSIONS.
**
** \note      Do not modify this file as it is generated automatically.
**
******************************************************************************/
#ifndef _GH_ADC_H
#define _GH_ADC_H

#ifdef __LINUX__
#include "reg4linux.h"
#else
#define FIO_ADDRESS(block,address) (address)
#define FIO_MOFFSET(block,moffset) (moffset)
#endif

#ifndef __LINUX__
#include "gtypes.h" /* global type definitions */
#include "gh_lib_cfg.h" /* configuration */
#endif

#define GH_ADC_ENABLE_DEBUG_PRINT   0
#ifdef __LINUX__
#define GH_ADC_DEBUG_PRINT_FUNCTION printk
#else
#define GH_ADC_DEBUG_PRINT_FUNCTION printf
#endif
#ifndef __LINUX__
#if GH_ADC_ENABLE_DEBUG_PRINT
#include <stdio.h>
#endif
#endif

/*----------------------------------------------------------------------------*/
/* registers                                                                  */
/*----------------------------------------------------------------------------*/
#define REG_ADC_AUX_ATOP                                    FIO_ADDRESS(ADC,0x90020A00) /* read/write */
#define REG_ADC_GPIO                                        FIO_ADDRESS(ADC,0x90020A04) /* read/write */
#define REG_ADC_CONTROL                                     FIO_ADDRESS(ADC,0xa000D000) /* read/write */
#define REG_ADC_READDATA                                    FIO_ADDRESS(ADC,0xa000D004) /* read */
#define REG_ADC_ENABLE                                      FIO_ADDRESS(ADC,0xa000D018) /* read/write */
#define REG_ADC_INTCONTROL                                  FIO_ADDRESS(ADC,0xa000D044) /* read/write */

/*----------------------------------------------------------------------------*/
/* bit group structures                                                       */
/*----------------------------------------------------------------------------*/
typedef union { /* ADC_AUX_ATOP */
    U32 all;
    struct {
        U32 sar_pd                      : 1;
        U32 sar_maxnsel                 : 3;
        U32 sar_maxsel                  : 4;
        U32 sar_oneshot                 : 1;
        U32 sar_freerun                 : 1;
        U32 sar_refnsel                 : 2;
        U32 sar_refsel                  : 3;
        U32                             : 17;
    } bitc;
} GH_ADC_AUX_ATOP_S;

typedef union { /* ADC_GPIO */
    U32 all;
    struct {
        U32 sar_test                    : 4;
        U32 sar_key_pge                 : 4;
        U32                             : 24;
    } bitc;
} GH_ADC_GPIO_S;

typedef union { /* ADC_Control */
    U32 all;
    struct {
        U32 status                      : 1;
        U32 start                       : 1;
        U32                             : 1;
        U32 channel                     : 3;
        U32                             : 26;
    } bitc;
} GH_ADC_CONTROL_S;

typedef union { /* ADC_IntControl */
    U32 all;
    struct {
        U32 val_lo                      : 10;
        U32                             : 5;
        U32 val_hi                      : 10;
        U32                             : 5;
        U32 en_lo                       : 1;
        U32 en_hi                       : 1;
    } bitc;
} GH_ADC_INTCONTROL_S;


/*----------------------------------------------------------------------------*/
/* mirror variables                                                           */
/*----------------------------------------------------------------------------*/

#ifdef __cplusplus
extern "C" {
#endif

/*----------------------------------------------------------------------------*/
/* register ADC_AUX_ATOP (read/write)                                         */
/*----------------------------------------------------------------------------*/
/*! \brief Writes the register 'ADC_AUX_ATOP'. */
void GH_ADC_set_AUX_ATOP(U32 data);
/*! \brief Reads the register 'ADC_AUX_ATOP'. */
U32  GH_ADC_get_AUX_ATOP(void);
/*! \brief Writes the bit group 'sar_pd' of register 'ADC_AUX_ATOP'. */
void GH_ADC_set_AUX_ATOP_sar_pd(U8 data);
/*! \brief Reads the bit group 'sar_pd' of register 'ADC_AUX_ATOP'. */
U8   GH_ADC_get_AUX_ATOP_sar_pd(void);
/*! \brief Writes the bit group 'sar_maxnsel' of register 'ADC_AUX_ATOP'. */
void GH_ADC_set_AUX_ATOP_sar_maxnsel(U8 data);
/*! \brief Reads the bit group 'sar_maxnsel' of register 'ADC_AUX_ATOP'. */
U8   GH_ADC_get_AUX_ATOP_sar_maxnsel(void);
/*! \brief Writes the bit group 'sar_maxsel' of register 'ADC_AUX_ATOP'. */
void GH_ADC_set_AUX_ATOP_sar_maxsel(U8 data);
/*! \brief Reads the bit group 'sar_maxsel' of register 'ADC_AUX_ATOP'. */
U8   GH_ADC_get_AUX_ATOP_sar_maxsel(void);
/*! \brief Writes the bit group 'sar_oneshot' of register 'ADC_AUX_ATOP'. */
void GH_ADC_set_AUX_ATOP_sar_oneshot(U8 data);
/*! \brief Reads the bit group 'sar_oneshot' of register 'ADC_AUX_ATOP'. */
U8   GH_ADC_get_AUX_ATOP_sar_oneshot(void);
/*! \brief Writes the bit group 'sar_freerun' of register 'ADC_AUX_ATOP'. */
void GH_ADC_set_AUX_ATOP_sar_freerun(U8 data);
/*! \brief Reads the bit group 'sar_freerun' of register 'ADC_AUX_ATOP'. */
U8   GH_ADC_get_AUX_ATOP_sar_freerun(void);
/*! \brief Writes the bit group 'sar_refnsel' of register 'ADC_AUX_ATOP'. */
void GH_ADC_set_AUX_ATOP_sar_refnsel(U8 data);
/*! \brief Reads the bit group 'sar_refnsel' of register 'ADC_AUX_ATOP'. */
U8   GH_ADC_get_AUX_ATOP_sar_refnsel(void);
/*! \brief Writes the bit group 'sar_refsel' of register 'ADC_AUX_ATOP'. */
void GH_ADC_set_AUX_ATOP_sar_refsel(U8 data);
/*! \brief Reads the bit group 'sar_refsel' of register 'ADC_AUX_ATOP'. */
U8   GH_ADC_get_AUX_ATOP_sar_refsel(void);

/*----------------------------------------------------------------------------*/
/* register ADC_GPIO (read/write)                                             */
/*----------------------------------------------------------------------------*/
/*! \brief Writes the register 'ADC_GPIO'. */
void GH_ADC_set_GPIO(U32 data);
/*! \brief Reads the register 'ADC_GPIO'. */
U32  GH_ADC_get_GPIO(void);
/*! \brief Writes the bit group 'sar_test' of register 'ADC_GPIO'. */
void GH_ADC_set_GPIO_sar_test(U8 data);
/*! \brief Reads the bit group 'sar_test' of register 'ADC_GPIO'. */
U8   GH_ADC_get_GPIO_sar_test(void);
/*! \brief Writes the bit group 'sar_key_pge' of register 'ADC_GPIO'. */
void GH_ADC_set_GPIO_sar_key_pge(U8 data);
/*! \brief Reads the bit group 'sar_key_pge' of register 'ADC_GPIO'. */
U8   GH_ADC_get_GPIO_sar_key_pge(void);

/*----------------------------------------------------------------------------*/
/* register ADC_Control (read/write)                                          */
/*----------------------------------------------------------------------------*/
/*! \brief Writes the register 'ADC_Control'. */
void GH_ADC_set_Control(U32 data);
/*! \brief Reads the register 'ADC_Control'. */
U32  GH_ADC_get_Control(void);
/*! \brief Writes the bit group 'status' of register 'ADC_Control'. */
void GH_ADC_set_Control_status(U8 data);
/*! \brief Reads the bit group 'status' of register 'ADC_Control'. */
U8   GH_ADC_get_Control_status(void);
/*! \brief Writes the bit group 'start' of register 'ADC_Control'. */
void GH_ADC_set_Control_start(U8 data);
/*! \brief Reads the bit group 'start' of register 'ADC_Control'. */
U8   GH_ADC_get_Control_start(void);
/*! \brief Writes the bit group 'channel' of register 'ADC_Control'. */
void GH_ADC_set_Control_channel(U8 data);
/*! \brief Reads the bit group 'channel' of register 'ADC_Control'. */
U8   GH_ADC_get_Control_channel(void);

/*----------------------------------------------------------------------------*/
/* register ADC_ReadData (read)                                               */
/*----------------------------------------------------------------------------*/
/*! \brief Reads the register 'ADC_ReadData'. */
U32  GH_ADC_get_ReadData(U8 index);

/*----------------------------------------------------------------------------*/
/* register ADC_Enable (read/write)                                           */
/*----------------------------------------------------------------------------*/
/*! \brief Writes the register 'ADC_Enable'. */
void GH_ADC_set_Enable(U32 data);
/*! \brief Reads the register 'ADC_Enable'. */
U32  GH_ADC_get_Enable(void);

/*----------------------------------------------------------------------------*/
/* register ADC_IntControl (read/write)                                       */
/*----------------------------------------------------------------------------*/
/*! \brief Writes the register 'ADC_IntControl'. */
void GH_ADC_set_IntControl(U8 index, U32 data);
/*! \brief Reads the register 'ADC_IntControl'. */
U32  GH_ADC_get_IntControl(U8 index);
/*! \brief Writes the bit group 'val_lo' of register 'ADC_IntControl'. */
void GH_ADC_set_IntControl_val_lo(U8 index, U16 data);
/*! \brief Reads the bit group 'val_lo' of register 'ADC_IntControl'. */
U16  GH_ADC_get_IntControl_val_lo(U8 index);
/*! \brief Writes the bit group 'val_hi' of register 'ADC_IntControl'. */
void GH_ADC_set_IntControl_val_hi(U8 index, U16 data);
/*! \brief Reads the bit group 'val_hi' of register 'ADC_IntControl'. */
U16  GH_ADC_get_IntControl_val_hi(U8 index);
/*! \brief Writes the bit group 'en_lo' of register 'ADC_IntControl'. */
void GH_ADC_set_IntControl_en_lo(U8 index, U8 data);
/*! \brief Reads the bit group 'en_lo' of register 'ADC_IntControl'. */
U8   GH_ADC_get_IntControl_en_lo(U8 index);
/*! \brief Writes the bit group 'en_hi' of register 'ADC_IntControl'. */
void GH_ADC_set_IntControl_en_hi(U8 index, U8 data);
/*! \brief Reads the bit group 'en_hi' of register 'ADC_IntControl'. */
U8   GH_ADC_get_IntControl_en_hi(U8 index);

/*----------------------------------------------------------------------------*/
/* init function                                                              */
/*----------------------------------------------------------------------------*/
/*! \brief Initialises the registers and mirror variables. */
void GH_ADC_init(void);

#ifdef SRC_INLINE
#define SRC_INC 1
#include "gh_adc.c"
#undef SRC_INC
#endif

#ifdef __cplusplus
}
#endif

#endif /* _GH_ADC_H */

/*----------------------------------------------------------------------------*/
/* end of file                                                                */
/*----------------------------------------------------------------------------*/