Choco OS  V.0.16.9.0
Join to the chocolate world
oc_fmc_lld.h
Go to the documentation of this file.
1 
32 #ifndef _OC_FMC_LLD_H
33 #define _OC_FMC_LLD_H
34 
35 #include <oc_machine.h>
36 #include <oc_errors.h>
37 #include <oc_frequency.h>
38 #include <oc_memory.h>
39 #include <oc_time.h>
40 
41 #if oC_Channel_IsModuleDefined(FMC) && oC_ModulePinFunctions_IsModuleDefined(FMC) && oC_ModulePin_IsModuleDefined(FMC)
42 
43 #define oC_FMC_LLD_AVAILABLE
44 
50 #define _________________________________________TYPES_SECTION______________________________________________________________________________
51 #define MODULE_NAME FMC
54 
55 //==========================================================================================================================================
62 //==========================================================================================================================================
63 oC_ModulePinFunction_DefineType;
64 
65 //==========================================================================================================================================
72 //==========================================================================================================================================
73 oC_ModulePin_DefineType;
74 
75 //==========================================================================================================================================
82 //==========================================================================================================================================
83 typedef enum
84 {
85  oC_FMC_LLD_MemoryType_RAM = (1<<6) ,
86  oC_FMC_LLD_MemoryType_Flash = (1<<7) ,
87  oC_FMC_LLD_MemoryType_SDRAM = (0x1) | oC_FMC_LLD_MemoryType_RAM ,
88  oC_FMC_LLD_MemoryType_PSRAM = (0x2) | oC_FMC_LLD_MemoryType_RAM ,
89  oC_FMC_LLD_MemoryType_NAND_Flash = (0x3) | oC_FMC_LLD_MemoryType_Flash ,
90  oC_FMC_LLD_MemoryType_NOR_Flash = (0x4) | oC_FMC_LLD_MemoryType_Flash ,
91 } oC_FMC_LLD_MemoryType_t;
92 
93 //==========================================================================================================================================
99 //==========================================================================================================================================
100 typedef enum
101 {
102  oC_FMC_LLD_DataBusWidth_8Bits = 1,
103  oC_FMC_LLD_DataBusWidth_16Bits = 2,
104  oC_FMC_LLD_DataBusWidth_32Bits = 4,
105  oC_FMC_LLD_DataBusWidth_64Bits = 8,
106 } oC_FMC_LLD_DataBusWidth_t;
107 
108 //==========================================================================================================================================
114 //==========================================================================================================================================
115 typedef enum
116 {
117  oC_FMC_LLD_Protection_Default = 0 ,
118  oC_FMC_LLD_Protection_AllowWrite = (1<<0) ,
119  oC_FMC_LLD_Protection_AllowRead = (1<<1) ,
120  oC_FMC_LLD_Protection_AllowExecute = (1<<2) ,
121 } oC_FMC_LLD_Protection_t;
122 
123 //==========================================================================================================================================
129 //==========================================================================================================================================
130 typedef enum
131 {
132  oC_FMC_LLD_SDRAM_CasLatency_0 = (1<<0) ,
133  oC_FMC_LLD_SDRAM_CasLatency_1 = (1<<1) ,
134  oC_FMC_LLD_SDRAM_CasLatency_2 = (1<<2) ,
135  oC_FMC_LLD_SDRAM_CasLatency_3 = (1<<3) ,
136  oC_FMC_LLD_SDRAM_CasLatency_4 = (1<<4) ,
137  oC_FMC_LLD_SDRAM_CasLatency_5 = (1<<5) ,
138  oC_FMC_LLD_SDRAM_CasLatency_6 = (1<<6) ,
139  oC_FMC_LLD_SDRAM_CasLatency_7 = (1<<7) ,
140 } oC_FMC_LLD_SDRAM_CasLatency_t;
141 
142 //==========================================================================================================================================
148 //==========================================================================================================================================
149 typedef enum
150 {
151  oC_FMC_LLD_SDRAM_BurstLength_1 = (1<<0),
152  oC_FMC_LLD_SDRAM_BurstLength_2 = (1<<1),
153  oC_FMC_LLD_SDRAM_BurstLength_4 = (1<<2),
154  oC_FMC_LLD_SDRAM_BurstLength_8 = (1<<3),
155  oC_FMC_LLD_SDRAM_BurstLength_FullPage = (1<<4),
156 } oC_FMC_LLD_SDRAM_BurstLength_t;
157 
158 //==========================================================================================================================================
162 //==========================================================================================================================================
163 typedef enum
164 {
165  oC_FMC_LLD_PinUsage_NotUsed ,
166  oC_FMC_LLD_PinUsage_Optional ,
167  oC_FMC_LLD_PinUsage_Required ,
168  oC_FMC_LLD_PinUsage_Used
169 } oC_FMC_LLD_PinUsage_t;
170 
171 //==========================================================================================================================================
175 //==========================================================================================================================================
176 typedef struct
177 {
178 
179 } oC_FMC_LLD_NANDFlash_Pins_t;
180 
181 //==========================================================================================================================================
185 //==========================================================================================================================================
186 typedef struct
187 {
188 
189 } oC_FMC_LLD_NORFlash_Pins_t;
190 
191 //==========================================================================================================================================
197 //==========================================================================================================================================
198 typedef struct
199 {
200  union
201  {
202  oC_Pin_t PinsArray[1];
203  struct
204  {
205  oC_Pin_t SDCLK;
206  oC_Pin_t SDCKE[2];
207  oC_Pin_t SDNE[2];
208  oC_Pin_t A[13];
209  oC_Pin_t D[32];
210  oC_Pin_t BA[4];
211  oC_Pin_t NRAS;
212  oC_Pin_t NCAS;
213  oC_Pin_t SDNWE;
214  oC_Pin_t NBL[4];
215  };
216  };
217 } oC_FMC_LLD_SDRAM_Pins_t;
218 
219 //==========================================================================================================================================
223 //==========================================================================================================================================
224 typedef struct
225 {
226 
227 } oC_FMC_LLD_PSRAM_Pins_t;
228 
229 //==========================================================================================================================================
233 //==========================================================================================================================================
234 typedef struct
235 {
236 
237 } oC_FMC_LLD_NANDFlash_ChipParameters_t;
238 
239 //==========================================================================================================================================
243 //==========================================================================================================================================
244 typedef struct
245 {
246 
247 } oC_FMC_LLD_NORFlash_ChipParameters_t;
248 
249 //==========================================================================================================================================
259 //==========================================================================================================================================
260 typedef struct
261 {
262  oC_MemorySize_t Size;
263  oC_MemorySize_t BankSize;
264  uint32_t NumberOfBanks;
265  oC_FMC_LLD_DataBusWidth_t DataBusWidth;
266  oC_FMC_LLD_SDRAM_CasLatency_t CasLatencyMask;
267  oC_Time_t CasLatency;
268  oC_FMC_LLD_SDRAM_BurstLength_t BurstLengthMask;
269  bool AutoPrechargePossible;
270  bool AutoRefreshPossible;
271  bool SelfPrechargePossible;
272  oC_Time_t AutoRefreshPeriod;
273  oC_Frequency_t MaximumClockFrequency;
274  uint8_t NumberOfRowAddressBits;
275  uint8_t NumberOfColumnAddressBits;
276  oC_Time_t ActiveToReadWriteDelay;
277  oC_Time_t PrechargeDelay;
278  oC_Time_t WriteRecoveryDelay;
279  oC_Time_t RefreshToActivateDelay;
280  oC_Time_t MinimumSelfRefreshPeriod;
281  oC_Time_t ExitSelfRefreshDelay;
282  uint32_t CyclesToDelayAfterLoadMode;
283  struct
284  {
285  oC_Time_t ReadPipeDelay;
286  bool UseBurstRead;
287  } Advanced;
288 } oC_FMC_LLD_SDRAM_ChipParameters_t;
289 
290 
291 //==========================================================================================================================================
295 //==========================================================================================================================================
296 typedef struct
297 {
298 
299 } oC_FMC_LLD_PSRAM_ChipParameters_t;
300 
301 //==========================================================================================================================================
308 //==========================================================================================================================================
309 typedef struct
310 {
311  oC_FMC_LLD_MemoryType_t MemoryType;
312  const char * Name;
313  union
314  {
315  oC_FMC_LLD_SDRAM_ChipParameters_t SDRAM;
316  };
317 } oC_FMC_LLD_ChipParameters_t;
318 
319 
320 //==========================================================================================================================================
324 //==========================================================================================================================================
325 typedef struct
326 {
327 
328 } oC_FMC_LLD_NANDFlash_Config_t;
329 
330 //==========================================================================================================================================
334 //==========================================================================================================================================
335 typedef struct
336 {
337 
338 } oC_FMC_LLD_NORFlash_Config_t;
339 
340 //==========================================================================================================================================
346 //==========================================================================================================================================
347 typedef struct
348 {
349  oC_FMC_LLD_DataBusWidth_t DataBusWidth;
350  oC_FMC_LLD_Protection_t Protection;
351  oC_FMC_LLD_SDRAM_Pins_t Pins;
352  oC_Time_t Timeout;
353 } oC_FMC_LLD_SDRAM_Config_t;
354 
355 //==========================================================================================================================================
361 //==========================================================================================================================================
362 typedef struct
363 {
364 
365 } oC_FMC_LLD_PSRAM_Config_t;
366 
367 typedef uint32_t oC_FMC_LLD_Bank_t;
368 
369 //==========================================================================================================================================
375 //==========================================================================================================================================
376 typedef struct
377 {
378  union
379  {
380  oC_FMC_LLD_PinUsage_t PinsUsage[1];
381  // //////////////////////////////////////////////////////////////////////////
382  // SDRAM
383  // //////////////////////////////////////////////////////////////////////////
384  struct
385  {
386  /* IMPORTANT!!!! */
387  /* */
388  /* Pins usage must be at the start */
389  /* of the structure and order must */
390  /* be the same like in the SDRAM */
391  /* pins structure!!! */
392  oC_FMC_LLD_PinUsage_t SDCLK;
393  oC_FMC_LLD_PinUsage_t SDCKE[2];
394  oC_FMC_LLD_PinUsage_t SDNE[2];
395  oC_FMC_LLD_PinUsage_t A[13];
396  oC_FMC_LLD_PinUsage_t D[32];
397  oC_FMC_LLD_PinUsage_t BA[4];
398  oC_FMC_LLD_PinUsage_t NRAS;
399  oC_FMC_LLD_PinUsage_t NCAS;
400  oC_FMC_LLD_PinUsage_t SDNWE;
401  oC_FMC_LLD_PinUsage_t NBL[4];
402  };
403  };
404  oC_Frequency_t ConfiguredFrequency;
405  uint8_t * MemoryStart;
406  oC_MemorySize_t MemorySize;
407  oC_FMC_LLD_Bank_t ConfiguredBanks;
408  oC_FMC_LLD_Protection_t DirectAccessProtection;
409  oC_FMC_LLD_DataBusWidth_t DataBusWidth;
410 } oC_FMC_LLD_Result_t;
411 
412 //==========================================================================================================================================
419 //==========================================================================================================================================
420 typedef enum
421 {
422  oC_FMC_LLD_SDRAM_Command_EnableClock ,
423  oC_FMC_LLD_SDRAM_Command_Inhibit ,
424  oC_FMC_LLD_SDRAM_Command_Nop ,
425  oC_FMC_LLD_SDRAM_Command_LoadModeRegister ,
426  oC_FMC_LLD_SDRAM_Command_Active ,
427  oC_FMC_LLD_SDRAM_Command_Read ,
428  oC_FMC_LLD_SDRAM_Command_Write ,
429  oC_FMC_LLD_SDRAM_Command_Precharge ,
430  oC_FMC_LLD_SDRAM_Command_BurstTerminate ,
431  oC_FMC_LLD_SDRAM_Command_AutoRefresh ,
432  oC_FMC_LLD_SDRAM_Command_SelfRefresh ,
433 } oC_FMC_LLD_SDRAM_Command_t;
434 
435 //==========================================================================================================================================
439 //==========================================================================================================================================
440 typedef uint64_t oC_FMC_LLD_Address_t;
441 
442 //==========================================================================================================================================
446 //==========================================================================================================================================
447 typedef union
448 {
449  struct
450  {
451  oC_FMC_LLD_Address_t RowAddress;
452  oC_FMC_LLD_Address_t BankAddress;
453  bool Reserved;
454  } Active;
455 
456  struct
457  {
458  oC_FMC_LLD_Address_t ColumnAddress;
459  oC_FMC_LLD_Address_t BankAddress;
460  bool EnableAutoPrecharge;
461  } Read;
462 
463  struct
464  {
465  oC_FMC_LLD_Address_t ColumnAddress;
466  oC_FMC_LLD_Address_t BankAddress;
467  bool EnableAutoPrecharge;
468  } Write;
469 
470  struct
471  {
472  oC_FMC_LLD_Address_t Reserved;
473  oC_FMC_LLD_Address_t BankAddress;
474  bool AllBanks;
475  } Precharge;
476 
477  struct
478  {
479  union
480  {
481  oC_FMC_LLD_Address_t MRD;
482  struct
483  {
484 #ifdef LITTLE_ENDIAN
485  oC_FMC_LLD_Address_t BurstLength:3;
486  oC_FMC_LLD_Address_t BurstType:1;
487  oC_FMC_LLD_Address_t CasLatency:3;
488  oC_FMC_LLD_Address_t OperatingMode:2;
489  oC_FMC_LLD_Address_t WriteBurstMode:1;
490  oC_FMC_LLD_Address_t Reserved:55;
491 #else
492 # error LoadModeRegister is not defined for BIG_ENDIAN
493 #endif
494  };
495  };
496  oC_FMC_LLD_Address_t BankAddress;
497  bool AllBanks;
498  } LoadModeRegister;
499 
500  struct
501  {
502  oC_FMC_LLD_Address_t NumberOfAutoRefresh;
503  oC_FMC_LLD_Address_t Reserved;
504  bool Reserved2;
505  } AutoRefresh;
506 
507  struct
508  {
509  oC_FMC_LLD_Address_t Address;
510  oC_FMC_LLD_Address_t BankAddress;
511  bool A10;
512  } Common;
513 } oC_FMC_LLD_SDRAM_CommandData_t;
514 
515 #undef MODULE_NAME
516 #undef _________________________________________TYPES_SECTION______________________________________________________________________________
517 
524 #define _________________________________________MACROS_SECTION_____________________________________________________________________________
525 
526 #undef _________________________________________MACROS_SECTION_____________________________________________________________________________
527 
528 
534 #define _________________________________________FUNCTIONS_SECTION__________________________________________________________________________
535 
538 
539 //==========================================================================================================================================
557 //==========================================================================================================================================
558 extern oC_ErrorCode_t oC_FMC_LLD_TurnOnDriver( void );
559 //==========================================================================================================================================
578 //==========================================================================================================================================
579 extern oC_ErrorCode_t oC_FMC_LLD_TurnOffDriver( void );
580 //==========================================================================================================================================
588 //==========================================================================================================================================
589 extern oC_ErrorCode_t oC_FMC_LLD_ConfigureSDRAM( const oC_FMC_LLD_SDRAM_Config_t * Config , const oC_FMC_LLD_ChipParameters_t * ChipInfo , oC_FMC_LLD_Result_t * outResult );
590 extern oC_ErrorCode_t oC_FMC_LLD_ConfigureNORFlash( const oC_FMC_LLD_NORFlash_Config_t * Config , const oC_FMC_LLD_ChipParameters_t * ChipInfo , oC_FMC_LLD_Result_t * outResult );
591 extern oC_ErrorCode_t oC_FMC_LLD_ConfigureNANDFlash(const oC_FMC_LLD_NANDFlash_Config_t * Config , const oC_FMC_LLD_ChipParameters_t * ChipInfo , oC_FMC_LLD_Result_t * outResult );
592 extern oC_ErrorCode_t oC_FMC_LLD_ConfigurePSRAM( const oC_FMC_LLD_PSRAM_Config_t * Config , const oC_FMC_LLD_ChipParameters_t * ChipInfo , oC_FMC_LLD_Result_t * outResult );
593 extern oC_ErrorCode_t oC_FMC_LLD_UnconfigureSDRAM( const oC_FMC_LLD_SDRAM_Config_t * Config , const oC_FMC_LLD_ChipParameters_t * ChipInfo , oC_FMC_LLD_Result_t * outResult );
594 extern oC_ErrorCode_t oC_FMC_LLD_UnconfigureNORFlash( const oC_FMC_LLD_NORFlash_Config_t * Config , const oC_FMC_LLD_ChipParameters_t * ChipInfo , oC_FMC_LLD_Result_t * outResult );
595 extern oC_ErrorCode_t oC_FMC_LLD_UnconfigureNANDFlash(const oC_FMC_LLD_NANDFlash_Config_t * Config , const oC_FMC_LLD_ChipParameters_t * ChipInfo , oC_FMC_LLD_Result_t * outResult );
596 extern oC_ErrorCode_t oC_FMC_LLD_UnconfigurePSRAM( const oC_FMC_LLD_PSRAM_Config_t * Config , const oC_FMC_LLD_ChipParameters_t * ChipInfo , oC_FMC_LLD_Result_t * outResult );
597 extern oC_ErrorCode_t oC_FMC_LLD_SendSDRAMCommand( oC_FMC_LLD_Result_t * Result , oC_Time_t * Timeout , oC_FMC_LLD_SDRAM_Command_t Command , const oC_FMC_LLD_SDRAM_CommandData_t * Data );
598 extern oC_ErrorCode_t oC_FMC_LLD_FinishSDRAMInitialization( const oC_FMC_LLD_SDRAM_Config_t * Config , const oC_FMC_LLD_ChipParameters_t * ChipInfo , oC_FMC_LLD_Result_t * Result );
599 extern oC_ErrorCode_t oC_FMC_LLD_FinishNORFlashInitialization( const oC_FMC_LLD_NORFlash_Config_t * Config , const oC_FMC_LLD_ChipParameters_t * ChipInfo , oC_FMC_LLD_Result_t * Result );
600 extern oC_ErrorCode_t oC_FMC_LLD_FinishNANDFlashInitialization( const oC_FMC_LLD_NANDFlash_Config_t * Config , const oC_FMC_LLD_ChipParameters_t * ChipInfo , oC_FMC_LLD_Result_t * Result );
601 extern oC_ErrorCode_t oC_FMC_LLD_FinishPSRAMInitialization( const oC_FMC_LLD_PSRAM_Config_t * Config , const oC_FMC_LLD_ChipParameters_t * ChipInfo , oC_FMC_LLD_Result_t * Result );
602 
603 #undef _________________________________________FUNCTIONS_SECTION__________________________________________________________________________
604 
606 
607 #endif /* _OC_FMC_LLD_H */
608 #endif
The file with interface for the GPIO driver.
The file with frequency definitions.
double oC_Frequency_t
type to store frequency
Definition: oc_frequency.h:76
The library with time definitions.
static oC_ErrorCode_t Write(ConnectionContext_t Context, const char *Buffer, uint32_t *Size, oC_Time_t Timeout)
function called when process want to write data on STDOUT stream
Definition: oc_telnet.c:694
static oC_ErrorCode_t Read(ConnectionContext_t Context, char *outBuffer, uint32_t *Size, oC_Time_t Timeout)
function called when process want to read data from STDIN stream
Definition: oc_telnet.c:749
The file with interface for the machine module.