| NANO100_BSP V3.05.000 The Board Support Package for Nano100BN Series

ebi.c
Go to the documentation of this file.
1/****************************************************************************/
12#include "Nano100Series.h"
13#include "ebi.h"
14
15
47 void EBI_Open(uint32_t u32Bank, uint32_t u32DataWidth, uint32_t u32TimingClass, uint32_t u32BusMode, uint32_t u32CSActiveLevel)
48{
49 EBI->EBICON = 0;
50
51 if (u32DataWidth == EBI_BUSWIDTH_8BIT)
52 EBI->EBICON &= ~EBI_EBICON_ExtBW16_Msk;
53 else
54 EBI->EBICON |= EBI_EBICON_ExtBW16_Msk;
55
56 EBI->EBICON &= ~(EBI_EBICON_ExttALE_Msk | EBI_EBICON_MCLKDIV_Msk);
57 switch (u32TimingClass)
58 {
59 case EBI_TIMING_FASTEST:
60 EBI->EBICON |= (0 << EBI_EBICON_ExttALE_Pos);
61 EBI->EBICON |= (EBI_MCLKDIV_1 << EBI_EBICON_MCLKDIV_Pos);
62 EBI->EXTIME = 0;
63 break;
64
65 case EBI_TIMING_VERYFAST:
66 EBI->EBICON |= (1 << EBI_EBICON_ExttALE_Pos);
67 EBI->EBICON |= (EBI_MCLKDIV_2 << EBI_EBICON_MCLKDIV_Pos);
68 EBI->EXTIME = (4 << EBI_EXTIME_ExttACC_Pos) | (1 << EBI_EXTIME_ExttAHD_Pos) |
69 (2 << EBI_EXTIME_ExtIW2X_Pos) | (2 << EBI_EXTIME_ExtIR2W_Pos) |
70 (2 << EBI_EXTIME_ExtIR2R_Pos);
71 break;
72
73 case EBI_TIMING_FAST:
74 EBI->EBICON |= (2 << EBI_EBICON_ExttALE_Pos);
75 EBI->EBICON |= (EBI_MCLKDIV_4 << EBI_EBICON_MCLKDIV_Pos);
76 EBI->EXTIME = (8 << EBI_EXTIME_ExttACC_Pos) | (2 << EBI_EXTIME_ExttAHD_Pos) |
77 (4 << EBI_EXTIME_ExtIW2X_Pos) | (4 << EBI_EXTIME_ExtIR2W_Pos) |
78 (4 << EBI_EXTIME_ExtIR2R_Pos);
79 break;
80
81 case EBI_TIMING_NORMAL:
82 EBI->EBICON |= (3 << EBI_EBICON_ExttALE_Pos);
83 EBI->EBICON |= (EBI_MCLKDIV_8 << EBI_EBICON_MCLKDIV_Pos);
84 EBI->EXTIME = (16 << EBI_EXTIME_ExttACC_Pos) | (3 << EBI_EXTIME_ExttAHD_Pos) |
85 (8 << EBI_EXTIME_ExtIW2X_Pos) | (8 << EBI_EXTIME_ExtIR2W_Pos) |
86 (8 << EBI_EXTIME_ExtIR2R_Pos);
87 break;
88
89 case EBI_TIMING_SLOW:
90 EBI->EBICON |= (4 << EBI_EBICON_ExttALE_Pos);
91 EBI->EBICON |= (EBI_MCLKDIV_16 << EBI_EBICON_MCLKDIV_Pos);
92 EBI->EXTIME = (20 << EBI_EXTIME_ExttACC_Pos) | (4 << EBI_EXTIME_ExttAHD_Pos) |
93 (12 << EBI_EXTIME_ExtIW2X_Pos) | (12 << EBI_EXTIME_ExtIR2W_Pos) |
94 (12 << EBI_EXTIME_ExtIR2R_Pos);
95 break;
96
97 case EBI_TIMING_VERYSLOW:
98 EBI->EBICON |= (5 << EBI_EBICON_ExttALE_Pos);
99 EBI->EBICON |= (EBI_MCLKDIV_32 << EBI_EBICON_MCLKDIV_Pos);
100 EBI->EXTIME = (26 << EBI_EXTIME_ExttACC_Pos) | (5 << EBI_EXTIME_ExttAHD_Pos) |
101 (14 << EBI_EXTIME_ExtIW2X_Pos) | (14 << EBI_EXTIME_ExtIR2W_Pos) |
102 (14 << EBI_EXTIME_ExtIR2R_Pos);
103 break;
104
105 case EBI_TIMING_SLOWEST:
106 EBI->EBICON |= (6 << EBI_EBICON_ExttALE_Pos);
107 EBI->EBICON |= (EBI_MCLKDIV_32 << EBI_EBICON_MCLKDIV_Pos);
108 EBI->EXTIME = (31 << EBI_EXTIME_ExttACC_Pos) | (7 << EBI_EXTIME_ExttAHD_Pos) |
109 (15 << EBI_EXTIME_ExtIW2X_Pos) | (15 << EBI_EXTIME_ExtIR2W_Pos) |
110 (15 << EBI_EXTIME_ExtIR2R_Pos);
111 break;
112 }
113
114 EBI->EBICON |= EBI_EBICON_MCLKEN_Msk | EBI_EBICON_ExtEN_Msk;
115}
116
122 void EBI_Close(uint8_t u32Bank)
123{
124 EBI->EBICON = 0;
125 EBI->EXTIME = 0;
126}
127
141 void EBI_SetBusTiming(uint32_t u32Bank, uint32_t u32TimingConfig, uint32_t u32MclkDiv)
142{
143 EBI->EXTIME = u32TimingConfig;
144 EBI->EBICON = (EBI->EBICON & ~EBI_EBICON_MCLKDIV_Msk) | (u32MclkDiv << EBI_EBICON_MCLKDIV_Pos);
145}
146
147 /* end of group NANO100_EBI_EXPORTED_FUNCTIONS */
149 /* end of group NANO100_EBI_Driver */
151 /* end of group NANO100_Device_Driver */
153
154/*** (C) COPYRIGHT 2014 Nuvoton Technology Corp. ***/
Nano100Series.h
Nano100 series peripheral access layer header file. This file contains all the peripheral register's ...
EBI_EBICON_ExttALE_Msk
#define EBI_EBICON_ExttALE_Msk
Definition: Nano100Series.h:1765
EBI_EXTIME_ExtIR2W_Pos
#define EBI_EXTIME_ExtIR2W_Pos
Definition: Nano100Series.h:1776
EBI_EBICON_MCLKDIV_Msk
#define EBI_EBICON_MCLKDIV_Msk
Definition: Nano100Series.h:1759
EBI_EXTIME_ExttAHD_Pos
#define EBI_EXTIME_ExttAHD_Pos
Definition: Nano100Series.h:1770
EBI_EXTIME_ExttACC_Pos
#define EBI_EXTIME_ExttACC_Pos
Definition: Nano100Series.h:1767
EBI_EBICON_MCLKEN_Msk
#define EBI_EBICON_MCLKEN_Msk
Definition: Nano100Series.h:1762
EBI_EXTIME_ExtIR2R_Pos
#define EBI_EXTIME_ExtIR2R_Pos
Definition: Nano100Series.h:1779
EBI_EXTIME_ExtIW2X_Pos
#define EBI_EXTIME_ExtIW2X_Pos
Definition: Nano100Series.h:1773
EBI_EBICON_ExtBW16_Msk
#define EBI_EBICON_ExtBW16_Msk
Definition: Nano100Series.h:1756
EBI_EBICON_ExttALE_Pos
#define EBI_EBICON_ExttALE_Pos
Definition: Nano100Series.h:1764
EBI_EBICON_MCLKDIV_Pos
#define EBI_EBICON_MCLKDIV_Pos
Definition: Nano100Series.h:1758
EBI_EBICON_ExtEN_Msk
#define EBI_EBICON_ExtEN_Msk
Definition: Nano100Series.h:1753
ebi.h
Nano100 Series Flash Memory Controller Driver Header File.
EBI_TIMING_VERYFAST
#define EBI_TIMING_VERYFAST
Definition: ebi.h:60
EBI_MCLKDIV_4
#define EBI_MCLKDIV_4
Definition: ebi.h:51
EBI_MCLKDIV_1
#define EBI_MCLKDIV_1
Definition: ebi.h:49
EBI_MCLKDIV_8
#define EBI_MCLKDIV_8
Definition: ebi.h:52
EBI_MCLKDIV_16
#define EBI_MCLKDIV_16
Definition: ebi.h:53
EBI_MCLKDIV_2
#define EBI_MCLKDIV_2
Definition: ebi.h:50
EBI_MCLKDIV_32
#define EBI_MCLKDIV_32
Definition: ebi.h:54
EBI_TIMING_FASTEST
#define EBI_TIMING_FASTEST
Definition: ebi.h:59
EBI_TIMING_FAST
#define EBI_TIMING_FAST
Definition: ebi.h:61
EBI_BUSWIDTH_8BIT
#define EBI_BUSWIDTH_8BIT
Definition: ebi.h:43
EBI_TIMING_VERYSLOW
#define EBI_TIMING_VERYSLOW
Definition: ebi.h:64
EBI_TIMING_NORMAL
#define EBI_TIMING_NORMAL
Definition: ebi.h:62
EBI_TIMING_SLOW
#define EBI_TIMING_SLOW
Definition: ebi.h:63
EBI_TIMING_SLOWEST
#define EBI_TIMING_SLOWEST
Definition: ebi.h:65
EBI_Open
void EBI_Open(uint32_t u32Bank, uint32_t u32DataWidth, uint32_t u32TimingClass, uint32_t u32BusMode, uint32_t u32CSActiveLevel)
Initialize and enable EBI.
Definition: ebi.c:47
EBI_Close
void EBI_Close(uint8_t u32Bank)
Disable EBI.
Definition: ebi.c:122
EBI_SetBusTiming
void EBI_SetBusTiming(uint32_t u32Bank, uint32_t u32TimingConfig, uint32_t u32MclkDiv)
Set EBI bus timings.
Definition: ebi.c:141
EBI
#define EBI
Pointer to EBI register structure.
Definition: Nano100Series.h:11712