ConOpSys V2970  P004.07
ANVILEX control operating system
S25FL512.h
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 //! @file S25FL512.h
3 //! @brief SPI NAND FLASH memory chip S25FL512 hardware driver class header file.
4 //! @attention No special attention requered.
5 //! @copyright (C) 2015-2020 ANVILEX LLC
6 //! $HeadURL: https://192.168.3.4:8443/svn/P004_07/ConOpSys/Peripherals/SPI_Memory/S25FL512.h $
7 //! $Revision: 2765 $
8 //! $Date: 2021-07-04 04:32:25 +0500 (So, 04 Jul 2021) $
9 //! $Author: minch $
10 //------------------------------------------------------------------------------
11 //
12 // Redistribution and use in source and binary forms, with or without
13 // modification, are permitted provided that the following conditions are met:
14 //
15 // 1. Redistributions of source code must retain the above copyright notice,
16 // this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright notice,
19 // this list of conditions and the following disclaimer in the documentation
20 // and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of ANVILEX nor the names of its contributors may be
23 // used to endorse or promote products derived from this software without
24 // specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
30 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 // POSSIBILITY OF SUCH DAMAGE.
37 //
38 //------------------------------------------------------------------------------
39 
40 //------------------------------------------------------------------------------
41 // Protecting header files from mutual, recursive inclusion.
42 //------------------------------------------------------------------------------
43 
44 #pragma once
45 
46 //------------------------------------------------------------------------------
47 // Include project files
48 //------------------------------------------------------------------------------
49 
50 #include "SPI_Memory_Base.h"
51 
52 //------------------------------------------------------------------------------
53 // Defines
54 //------------------------------------------------------------------------------
55 
56 //------------------------------------------------------------------------------
57 // Class
58 //------------------------------------------------------------------------------
59 
60 //! @brief NAND memory hardware driver
62 {
63 
64  //----------------------------------------------------------------------------
65  // Public defines, methods and variables
66  //----------------------------------------------------------------------------
67 
68  public:
69 
70  //--------------------------------------------------------------------------
71  // Constructor and destructor methods
72  //--------------------------------------------------------------------------
73 
74  //!-------------------------------------------------------------------------
75  //! @brief Class constructor method.
76  //! @note None
77  //! \par Override
78  //! Not allowed
79  //! @attention Don't call this method directly.
80  //--------------------------------------------------------------------------
81 
82 // TS25FL512();
83 
84  //!-------------------------------------------------------------------------
85  //! @brief Class destructor method.
86  //! @note None
87  //! \par Override
88  //! Not allowed
89  //! @attention Don't call this method directly.
90  //--------------------------------------------------------------------------
91 
92 // virtual ~TS25FL512();
93 
94  //!-------------------------------------------------------------------------
95  //! @brief Driver initialisation method.
96  //! @note By calling this method driver make internal initialisation and prepering for operation.
97  //! @return None
98  //! \par Override
99  //! Not allowed
100  //! @attention None
101  //--------------------------------------------------------------------------
102 
103  VOID Init();
104 
105  //!-------------------------------------------------------------------------
106  //! @brief Driver start operation method.
107  //! @note By calling this method driver starts opration.
108  //! @return None
109  //! \par Override
110  //! Not allowed
111  //! @attention None
112  //--------------------------------------------------------------------------
113 
114  virtual VOID Start();
115 
116  //!-------------------------------------------------------------------------
117  //! @brief Background execute method.
118  //! @note None.
119  //! @return None
120  //! \par Override
121  //! Not allowed
122  //! @attention None
123  //--------------------------------------------------------------------------
124 
125  VOID Execute();
126 
127  //!-------------------------------------------------------------------------
128  //! @brief Read data from memory into buffer.
129  //! @note None
130  //! @param [in] u32_Linear_Address - Linear address of the data in memory
131  //! @param [in] u32_Size - Size of the data to read
132  //! @param [out] *u8_Data_Buffer - Pointer to the data buffer
133  //! @return BOOL - Data read operation status
134  //! @retval false - Read operation failed
135  //! @retval true - Read operation successed
136  //! \par Override
137  //! Not requered
138  //! @attention None
139  //--------------------------------------------------------------------------
140 
141  virtual BOOL Read_Buffer( U32 u32_Linear_Address, U32 u32_Size, U8 *u8_Data_Buffer );
142 
143  //!-------------------------------------------------------------------------
144  //! @brief Read data from memory into buffer.
145  //! @note None
146  //! @param [in] u32_Linear_Address - Linear address of the data in memory
147  //! @param [in] u32_Size - Size of the data to read
148  //! @param [out] *u8_Data_Buffer - Pointer to the data buffer
149  //! @return BOOL - Data read operation status
150  //! @retval false - Read operation failed
151  //! @retval true - Read operation successed
152  //! \par Override
153  //! Not requered
154  //! @attention None
155  //--------------------------------------------------------------------------
156 
157  BOOL Read_Extended_Buffer( U32 u32_Linear_Address, U32 u32_Size, U8 *u8_Data_Buffer );
158 
159  //!-------------------------------------------------------------------------
160  //! @brief Read data from memory into buffer.
161  //! @note None
162  //! @param [in] u32_Page_Index - Page index
163  //! @param [in] u16_Offset - Offset inside page
164  //! @param [in] u32_Size - Size of the data to read
165  //! @param [out] *u8_Data_Buffer - Pointer to the data buffer
166  //! @return BOOL - Data read operation status
167  //! @retval false - Read operation failed
168  //! @retval true - Read operation successed
169  //! \par Override
170  //! Not requered
171  //! @attention None
172  //--------------------------------------------------------------------------
173 
174  BOOL Read_Buffer_By_Page_Index( U32 u32_Page_Index, U16 u16_Offset, U32 u32_Size, U8 *u8_Data_Buffer );
175 
176  //!-------------------------------------------------------------------------
177  //! @brief Write data from buffer into memory.
178  //! @note None
179  //! @param [in] u32_Linear_Address - Linear address of the data in memory
180  //! @param [in] u32_Size - Size of the data to write
181  //! @param [out] *u8_Data_Buffer - Pointer to the data buffer
182  //! @return BOOL - Data write operation status
183  //! @retval false - Write operation failed
184  //! @retval true - Write operation successed
185  //! \par Override
186  //! Not requered
187  //! @attention None
188  //--------------------------------------------------------------------------
189 
190  virtual BOOL Write_Buffer( U32 u32_Linear_Address, U32 u32_Size, U8 *u8_Data_Buffer );
191 
192  //!-------------------------------------------------------------------------
193  //! @brief Write data from buffer into memory.
194  //! @note None
195  //! @param [in] u32_Page_Index - Page index
196  //! @param [in] u16_Offset - Offset into page
197  //! @param [in] u32_Size - Size of the data to write
198  //! @param [out] *u8_Data_Buffer - Pointer to the data buffer
199  //! @return BOOL - Data write operation status
200  //! @retval false - Write operation failed
201  //! @retval true - Write operation successed
202  //! \par Override
203  //! Not requered
204  //! @attention None
205  //--------------------------------------------------------------------------
206 
207  BOOL Write_Buffer_By_Page_Index( U32 u32_Page_Index, U16 u16_Offset, U32 u32_Size, U8 *u8_Data_Buffer );
208 
209  //!-------------------------------------------------------------------------
210  //! @brief Erase block referenced by block index.
211  //! @note None
212  //! @param [in] u16_Block_Index - Block index to erase
213  //! @return BOOL - Erase operation status
214  //! @retval false - Erase operation failed
215  //! @retval true - Erase operation successed
216  //! \par Override
217  //! Not requered
218  //! @attention None
219  //--------------------------------------------------------------------------
220 
221  BOOL Erase_Block_By_Index( U16 u16_Block_Index );
222 
223  //!-------------------------------------------------------------------------
224  //! @brief Erase all blocks of the chip.
225  //! @note None
226  //! @param [in] bool_Force_Bad_Block_Erase - Force bad block erase
227  //! @return BOOL - Erase operation status
228  //! @retval false - Erase operation failed
229  //! @retval true - Erase operation successed
230  //! \par Override
231  //! Not requered
232  //! @attention Erase operation not applied to the bad blocks.
233  //--------------------------------------------------------------------------
234 
235  virtual BOOL Erase_Chip( BOOL bool_Force_Bad_Block_Erase );
236 
237  //!-------------------------------------------------------------------------
238  //! @brief Test for specified block is bad and can not be utilised.
239  //! @note None
240  //! @param [in] u32_Block_Index - Block index to erase
241  //! @param [out] bool_Bad_Block_Status - Bad block status value
242  //! @return BOOL - Operation status
243  //! @retval false - Block is good
244  //! @retval true - Block is bad
245  //! \par Override
246  //! Not requered
247  //! @attention None
248  //--------------------------------------------------------------------------
249 
250  BOOL Get_Bad_Block_Status( U32 u32_Block_Index, BOOL *bool_Bad_Block_Status );
251 
252  //!-------------------------------------------------------------------------
253  //! @brief Test for specified block is empty and be utilised for write operation.
254  //! @note None
255  //! @param [in] u16_Block_Index - Block index to be test
256  //! @return BOOL - Operation status
257  //! @retval false - Block is not empty
258  //! @retval true - Block is empty
259  //! \par Override
260  //! Not requered
261  //! @attention None
262  //--------------------------------------------------------------------------
263 
264  BOOL Is_Block_Empty( U16 u16_Block_Index );
265 
266  //!-------------------------------------------------------------------------
267  //! @brief Test for specified page is empty and be utilised for write operation.
268  //! @note None
269  //! @return BOOL - Operation status
270  //! @retval false - Page is not empty
271  //! @retval true - Page is empty
272  //! \par Override
273  //! Not requered
274  //! @attention None
275  //--------------------------------------------------------------------------
276 
278 
279  //!-------------------------------------------------------------------------
280  //! @brief Method sends actual driver information over specified communication link protocol.
281  //! @note None
282  //! @param [in] *object_Protocol - Pointer to the connunication link protocol
283  //! @return None
284  //! \par Override
285  //! Not allowed
286  //! @attention None
287  //--------------------------------------------------------------------------
288 
289  virtual VOID Send_Information( TProtocol_Base *object_Protocol );
290 
291  //---------------------------------------------------------------------------
292  // Protected defines, methods and variables
293  //---------------------------------------------------------------------------
294 
295  protected:
296 
297  //---------------------------------------------------------------------------
298  // Private defines, methods and variables
299  //---------------------------------------------------------------------------
300 
301  private:
302 
303  //--------------------------------------------------------------------------
304  // Private defines
305  //--------------------------------------------------------------------------
306 
307  //! @brief Define chip types
308  typedef enum
309  {
310 
311  //! @brief No chip
313 
314  //! @brief Unknown chip
316 
317  //! @brief 1 GBit, NAND, ISSI, IS37SML01G1
319 
320  //! @brief 4 GBit, NAND, GigaDevice, GD5F4GQ4UAYIG
322 
323  //! @brief 512 MBit, NOR, SPANSION, S25FL512S
325 
327 
328  //! @brief Define NVRAM commands
329  typedef enum
330  {
331 
332  //! @brief Reset chip command
333  commandRES = (U8)0xFF,
334 
335  //! @brief Block erase command
336  commandBE = (U8)0xD8,
337 
338  //! @brief Get feature command
339  commandGF = (U8)0x0F,
340 
341  //! @brief Set feature command
342  commandSF = (U8)0x1F,
343 
344  //! @brief Write disable command
345  commandWRDI = (U8)0x04,
346 
347  //! @brief Write enable command
348  commandWREN = (U8)0x06,
349 
350  //! @brief Page program command
351  commandPP = (U8)0x02,
352 
353  //! @brief Random page program command
354  commandRPP = (U8)0x84,
355 
356  //! @brief Program execute command
357  commandPE = (U8)0x10,
358 
359  //! @brief Read page command
360  commandREAD = (U8)0x13,
361 
362  //! @brief Read from cache (or 0x0B) command
363  commandRFC = (U8)0x03,
364 
365  //! @brief Read manufacture ID, memory type ID, capacity ID command
366  commandRDID = (U8)0x9F,
367 
368  //! @brief Read from cache x2 command
369  command2RFC = (U8)0x3B,
370 
371  //! @brief Random page program x4 command
372  command4RPP = (U8)0x34,
373 
374  //! @brief Read from cache x4 command
375  command4RFC = (U8)0x6B,
376 
378 
379  //! @brief Feature address list
380  typedef enum TS25FL512SAdress
381  {
382 
383  //! @brief Block lock register address
384  address_BL = (U8)0xA0,
385 
386  //! @brief OTP register address
387  address_OTP = (U8)0xB0,
388 
389  //! @brief Status register address
390  address_SR = (U8)0xC0,
391 
392  //! @brief Output data register address
393  address_OD = (U8)0xD0
394 
396 
397  //! @brief Status register structure
398  typedef union
399  {
400 
401  //! @brief Raw data
403 
404  //! @brief Bitfield structure
405  struct
406  {
407 
408  //! @brief Bit 0 : Operation in progress bit
410 
411  //! @brief Bit 1 :Write enable latch bit
413 
414  //! @brief Bit 2 : Erase fail bit
416 
417  //! @brief Bit 3 Program fail bit
419 
420  //! @brief Bit 4 and 5 :ECC status bits
422 
423  //! @brief Bit 6 : Not in use
424  U8 :1;
425 
426  //! @brief Bit 7 : Not in use
427  U8 :1;
428 
429  };
430 
431  } TStatus_Register;
432 
433  //! @brief Block lock register structure
434  typedef union
435  {
436 
437  //! @brief Raw data
439 
440  //! @brief Bitfield structure
441  struct
442  {
443 
444  //! @brief Bit 0 : Not in use
445  U8 :1;
446 
447  //! @brief Bit 1 : Not in use
448  U8 :1;
449 
450  //! @brief Bit 2 : Not in use
451  U8 :1;
452 
453  //! @brief Bit 3 Not in use
454  U8 :1;
455 
456  //! @brief Bit 4 : BP1
457  U8 BP1:1;
458 
459  //! @brief Bit 5 : BP2
460  U8 BP2:1;
461 
462  //! @brief Bit 6 : Not in use
463  U8 :1;
464 
465  //! @brief Bit 7 : BRWD
466  U8 BRWD:1;
467 
468  };
469 
470  } TBlock_Register;
471 
472  //--------------------------------------------------------------------------
473  // Private methods
474  //--------------------------------------------------------------------------
475 
476  //!-------------------------------------------------------------------------
477  //! @brief Enable write operation into memory.
478  //! @note None
479  //! @return BOOL - Operation status
480  //! @retval false - Operation successed
481  //! @retval true - Operation failed
482  //! \par Override
483  //! Not allowed
484  //! @attention None
485  //--------------------------------------------------------------------------
486 
487  virtual BOOL Write_Enable();
488 
489  //!-------------------------------------------------------------------------
490  //! @brief Disable write operation into memory.
491  //! @note None
492  //! @return BOOL - Operation status
493  //! @retval false - Operation successed
494  //! @retval true - Operation failed
495  //! \par Override
496  //! Not allowed
497  //! @attention None
498  //--------------------------------------------------------------------------
499 
500  virtual BOOL Write_Disable();
501 
502  //!-------------------------------------------------------------------------
503  //! @brief Read memory device status register method.
504  //! @note None
505  //! @param [out] *u8_Status_Register - Pointer to status register value
506  //! @return BOOL - Read operation status
507  //! @retval false - Read operation failed
508  //! @retval true - Read operation successed
509  //! \par Override
510  //! Requered
511  //! @attention None
512  //--------------------------------------------------------------------------
513 
514  virtual BOOL Read_Status_Register( U8 *u8_Status_Register );
515 
516  //!-------------------------------------------------------------------------
517  //! @brief Get flash memory feature method.
518  //! @note None
519  //! @param [in] enum_Feature_Adress - Chip feature address
520  //! @param [out] u8_Data - Chip feature value
521  //! @return BOOL - Get operation status
522  //! @retval false - Get operation successed
523  //! @retval true - Get operation failed
524  //! \par Override
525  //! Not allowed
526  //! @attention None
527  //--------------------------------------------------------------------------
528 
529  BOOL Get_Feature( TS25FL512SAdress enum_Feature_Adress, U8 *u8_Data );
530 
531  //!-------------------------------------------------------------------------
532  //! @brief Set flash memory feature method.
533  //! @note None
534  //! @param [in] enum_Feature_Adress - Chip feature address
535  //! @param [in] u8_Data - Chip feature value
536  //! @return BOOL - Set operation status
537  //! @retval false - Set operation successed
538  //! @retval true - Set operation failed
539  //! \par Override
540  //! Not allowed
541  //! @attention None
542  //--------------------------------------------------------------------------
543 
544  BOOL Set_Feature( TS25FL512SAdress enum_Feature_Adress, U8 u8_Data );
545 
546  //!-------------------------------------------------------------------------
547  //! @brief Read memory device identification information method.
548  //! @note None
549  //! @return BOOL - Read operation status
550  //! @retval false - Read operation successed
551  //! @retval true - Read operation failed
552  //! \par Override
553  //! Requered
554  //! @attention None
555  //--------------------------------------------------------------------------
556 
557  virtual BOOL Read_Identification();
558 
559  //!-------------------------------------------------------------------------
560  //! @brief Software reset memory chip method.
561  //! @note None
562  //! @return None
563  //! \par Override
564  //! Requered
565  //! @attention None
566  //--------------------------------------------------------------------------
567 
568  VOID Reset();
569 
570  //!-------------------------------------------------------------------------
571  //! @brief Read multiple byte from chip cache method.
572  //! @note None
573  //! @param [in] u32_Address - Start address in cache
574  //! @param [in] u32_Length - Amount of the byte to read
575  //! @param [in] u8_Data_Buffer - Pointer to the data buffer
576  //! @return BOOL - Read operation status
577  //! @retval false - Read operation successed
578  //! @retval true - Read operation failed
579  //! \par Override
580  //! Not allowed
581  //! @attention None
582  //--------------------------------------------------------------------------
583 
584  BOOL Read_Page_From_Cache_By_Leniar_Address( U32 u32_Address, U32 u32_Length, U8 *u8_Data_Buffer );
585 
586  //!-------------------------------------------------------------------------
587  //! @brief Read multiple byte from chip cache method.
588  //! @note None
589  //! @param [in] u16_Offset - Address offset in cache
590  //! @param [in] u32_Length - Amount of the byte to read
591  //! @param [in] u8_Data_Buffer - Pointer to the data buffer
592  //! @return BOOL - Read operation status
593  //! @retval false - Read operation successed
594  //! @retval true - Read operation failed
595  //! \par Override
596  //! Not allowed
597  //! @attention None
598  //--------------------------------------------------------------------------
599 
600  BOOL Read_Page_From_Cache( U16 u16_Offset, U32 u32_Length, U8 *u8_Data_Buffer );
601 
602  //!-------------------------------------------------------------------------
603  //! @brief Write multiple byte into chip cache method.
604  //! @note None
605  //! @param [in] u32_Address - Start address in cache
606  //! @param [in] u32_Length - Amount of the byte to write
607  //! @param [in] u8_Data_Buffer - Pointer to the data buffer
608  //! @return BOOL - Write operation status
609  //! @retval false - Write operation successed
610  //! @retval true - Write operation failed
611  //! \par Override
612  //! Not allowed
613  //! @attention None
614  //--------------------------------------------------------------------------
615 
616  BOOL Write_Page_To_Cache_By_Leniar_Address( U32 u32_Address, U32 u32_Length, U8 *u8_Data_Buffer );
617 
618  //!-------------------------------------------------------------------------
619  //! @brief Write multiple byte into chip cache method.
620  //! @note None
621  //! @param [in] u16_Offset - Address offset in cache
622  //! @param [in] u32_Length - Amount of the byte to write
623  //! @param [in] u8_Data_Buffer - Pointer to the data buffer
624  //! @return BOOL - Write operation status
625  //! @retval false - Write operation successed
626  //! @retval true - Write operation failed
627  //! \par Override
628  //! Not allowed
629  //! @attention None
630  //--------------------------------------------------------------------------
631 
632  BOOL Write_Page_To_Cache( U16 u16_Offset, U32 u32_Length, U8 *u8_Data_Buffer );
633 
634  //!-------------------------------------------------------------------------
635  //! @brief Read page from chip cells into the cache method.
636  //! @note None
637  //! @param [in] u32_Linear_Address - Linear address of the page to read
638  //! @return BOOL - Read operation status
639  //! @retval false - Read operation successed
640  //! @retval true - Read operation failed
641  //! \par Override
642  //! Not allowed
643  //! @attention None
644  //--------------------------------------------------------------------------
645 
646  BOOL Read_Page_From_Cells_To_Cache( U32 u32_Linear_Address );
647 
648  //!-------------------------------------------------------------------------
649  //! @brief Read page from chip cells into the cache method. Page referenced by absolute page index within memory chip.
650  //! @note None
651  //! @param [in] u32_Page_Index - Absolute index of the page to read
652  //! @return BOOL - Read operation status
653  //! @retval false - Read operation successed
654  //! @retval true - Read operation failed
655  //! \par Override
656  //! Not allowed
657  //! @attention None
658  //--------------------------------------------------------------------------
659 
661 
662  //!-------------------------------------------------------------------------
663  //! @brief Write page from cache into chip cells method.
664  //! @note None
665  //! @param [in] u32_Linear_Address - Linear address of the page to write
666  //! @return BOOL - Write operation status
667  //! @retval false - Write operation successed
668  //! @retval true - Write operation failed
669  //! \par Override
670  //! Not allowed
671  //! @attention None
672  //--------------------------------------------------------------------------
673 
674  BOOL Write_Page_From_Cache_To_Cells( U32 u32_Linear_Address );
675 
676  //!-------------------------------------------------------------------------
677  //! @brief Write page from cache into chip cells method.
678  //! @note None
679  //! @param [in] u32_Page_Index - Absolute indes og the page to write
680  //! @return BOOL - Write operation status
681  //! @retval false - Write operation successed
682  //! @retval true - Write operation failed
683  //! \par Override
684  //! Not allowed
685  //! @attention None
686  //--------------------------------------------------------------------------
687 
689 
690  //!-------------------------------------------------------------------------
691  //! @brief Get write protection bits.
692  //! @note None
693  //! @return BOOL - Operation status
694  //! @retval false - Operation successed
695  //! @retval true - Operation failed
696  //! \par Override
697  //! Not allowed
698  //! @attention None
699  //--------------------------------------------------------------------------
700 
702 
703  //!-------------------------------------------------------------------------
704  //! @brief Wait specified time for hardware controller operation done method.
705  //! @note None
706  //! @param [in] f32_Timeout - Timeout in seconds
707  //! @return BOOL - Operation status
708  //! @retval false - Hardware controller perform operation in specified time
709  //! @retval true - Hardware controller not perform operation in specified time
710  //! \par Override
711  //! Not allowed
712  //! @attention None
713  //--------------------------------------------------------------------------
714 
715  BOOL Wait_For_Operation_Done( F32 f32_Timeout );
716 
717  //!-------------------------------------------------------------------------
718  //! @brief Get operation status method.
719  //! @note None
720  //! @return BOOL - Operation status
721  //! @retval false - Operation completed
722  //! @retval true - Operation in progress
723  //! \par Override
724  //! Not allowed
725  //! @attention None
726  //--------------------------------------------------------------------------
727 
729 
730  //!-------------------------------------------------------------------------
731  //! @brief Get read operation status method.
732  //! @note None
733  //! @return BOOL - Read operation status
734  //! @retval false - Read operation successed without any errors
735  //! @retval true - Read oparation failed
736  //! \par Override
737  //! Not allowed
738  //! @attention None
739  //--------------------------------------------------------------------------
740 
742 
743  //!-------------------------------------------------------------------------
744  //! @brief Get erase operation status method.
745  //! @note None
746  //! @return BOOL - Erase operation status
747  //! @retval false - Erase operation successed without any errors
748  //! @retval true - Erase oparation failed
749  //! \par Override
750  //! Not allowed
751  //! @attention None
752  //--------------------------------------------------------------------------
753 
755 
756  //!-------------------------------------------------------------------------
757  //! @brief Get program operation status method.
758  //! @note None
759  //! @return BOOL - Program operation status
760  //! @retval false - Program operation successed without any errors
761  //! @retval true - Program oparation failed
762  //! \par Override
763  //! Not allowed
764  //! @attention None
765  //--------------------------------------------------------------------------
766 
768 
769  //!-------------------------------------------------------------------------
770  //! @brief Increment block erase request counter method.
771  //! @note None
772  //! @return None
773  //! \par Override
774  //! Not allowed
775  //! @attention None
776  //--------------------------------------------------------------------------
777 
779 
780  //!-------------------------------------------------------------------------
781  //! @brief Increment block erase error counter method.
782  //! @note None
783  //! @return None
784  //! \par Override
785  //! Not allowed
786  //! @attention None
787  //--------------------------------------------------------------------------
788 
790 
791  //!-------------------------------------------------------------------------
792  //! @brief Increment page read request counter method.
793  //! @note None
794  //! @return None
795  //! \par Override
796  //! Not allowed
797  //! @attention None
798  //--------------------------------------------------------------------------
799 
801 
802  //!-------------------------------------------------------------------------
803  //! @brief Increment page read error counter method.
804  //! @note None
805  //! @return None
806  //! \par Override
807  //! Not allowed
808  //! @attention None
809  //--------------------------------------------------------------------------
810 
812 
813  //!-------------------------------------------------------------------------
814  //! @brief Increment page write request counter method.
815  //! @note None
816  //! @return None
817  //! \par Override
818  //! Not allowed
819  //! @attention None
820  //--------------------------------------------------------------------------
821 
823 
824  //!-------------------------------------------------------------------------
825  //! @brief Increment page write error counter method.
826  //! @note None
827  //! @return None
828  //! \par Override
829  //! Not allowed
830  //! @attention None
831  //--------------------------------------------------------------------------
832 
834 
835  //-------------------------------------------------------------------------
836  // Test functionality
837  //-------------------------------------------------------------------------
838 
839  //!-------------------------------------------------------------------------
840  //! @brief Erase block test method.
841  //! @note None
842  //! @return TReturn_Test_Code - Detail test status
843  //! \par Override
844  //! Not allowed
845  //! @attention None
846  //--------------------------------------------------------------------------
847 
848 public: TReturn_Test_Code QA_Erase_Block_Test(); // Temp ver (public)
849 
850  //!-------------------------------------------------------------------------
851  //! @brief Write page test method.
852  //! @note None
853  //! @return TReturn_Test_Code - Detail test status
854  //! \par Override
855  //! Not allowed
856  //! @attention None
857  //--------------------------------------------------------------------------
858 
860 
861  //!-------------------------------------------------------------------------
862  //! @brief Read page test method.
863  //! @note None
864  //! @return TReturn_Test_Code - Detail test status
865  //! \par Override
866  //! Not allowed
867  //! @attention None
868  //--------------------------------------------------------------------------
869 
871 
872 
873  //!-------------------------------------------------------------------------
874  //! @brief Single block erase test method.
875  //! @note None
876  //! @return TReturn_Test_Code - Detail test status
877  //! \par Override
878  //! Not allowed
879  //! @attention None
880  //--------------------------------------------------------------------------
881 
883 
884  //!-------------------------------------------------------------------------
885  //! @brief Method for starting the main test sequence.
886  //! @note None
887  //! @return TReturn_Test_Code - Detail test status
888  //! \par Override
889  //! Not allowed
890  //! @attention None
891  //--------------------------------------------------------------------------
892 
894 
895  //-------------------------------------------------------------------------
896  // Private variables
897  //-------------------------------------------------------------------------
898 
899  //! @brief Flash chip type storage
901 
902  //! @brief Manufacturer number storage
904 
905  //! @brief Serial number storage
906  U8 u8_Device_ID = (U8)0xFF;
907 
908  //! @brief JEDEC code storage
909  volatile U8 u8_JEDEC_ID[ 3 ] = { (U8)0xFF, (U8)0xFF, (U8)0xFF };
910 
911  //! @brief Read identifier dummy byte counter
912  //! @note ANVILEX KM: u32_Identifier_Dummy_Byte_Counter is used only for debug purpouse, and can optimised.
914 
915  //! @brief BP1 bit in BL register
916  U8 u8_BP1 = (U8)0x00;
917 
918  //! @brief BP2 bit in BL register
919  U8 u8_BP2 = (U8)0x00;
920 
921  //! @brief BRWD bit in BL register
922  U8 u8_BRWD = (U8)0x00;
923 
924  //! @brief Block erase request counter
926 
927  //! @brief Block read error counter
929 
930  //! @brief Page read request counter
932 
933  //! @brief Page read error counter
935 
936  //! @brief Page write request counter
938 
939  //! @brief Page write error counter
941 
942  //! @brief Bad block search counter
944 
945  //! @brief Bad block count
947 
948  //! @brief Actual block index of the search bad block count process
950 
951  //! @brief Actual block index of the search bad block count process
952  //! @todo ANVILEX KM: Investigate of this buffer purpoise
954 
955 };
956 
957 //------------------------------------------------------------------------------
958 // End of file
959 //------------------------------------------------------------------------------
int BOOL
Boolean datatype definition.
Definition: Defines.h:124
unsigned char U8
Binary 8-Bit unsigned integer datatype defenition.
Definition: Defines.h:183
TReturn_Test_Code
Global test status.
Definition: Defines.h:663
void VOID
Datatypesess datatype definition.
Definition: Defines.h:105
unsigned long U32
Binary 32-Bit unsigned integer datatype defenition.
Definition: Defines.h:203
float F32
IEEE-754 32-Bit single presession floating point numbers datatype defenition.
Definition: Defines.h:324
unsigned short U16
Binary 16-Bit unsigned integer datatype defenition.
Definition: Defines.h:193
SPI connected memory base class header file.
Definition: Protocol_Base.h:57
NAND memory hardware driver.
Definition: S25FL512.h:62
BOOL Read_Page_From_Cells_To_Cache(U32 u32_Linear_Address)
Read page from chip cells into the cache method.
Definition: S25FL512.cpp:1802
BOOL Erase_Block_By_Index(U16 u16_Block_Index)
Erase block referenced by block index.
Definition: S25FL512.cpp:959
VOID Increment_Block_Erase_Request_Counter()
Increment block erase request counter method.
Definition: S25FL512.cpp:2827
TChip_Type enum_Flash_Chip_Type
Flash chip type storage.
Definition: S25FL512.h:900
virtual BOOL Erase_Chip(BOOL bool_Force_Bad_Block_Erase)
Erase all blocks of the chip.
Definition: S25FL512.cpp:824
BOOL Is_Block_Empty(U16 u16_Block_Index)
Test for specified block is empty and be utilised for write operation.
Definition: S25FL512.cpp:2438
U32 u32_Page_Read_Error_Counter
Page read error counter.
Definition: S25FL512.h:934
VOID Increment_Page_Read_Request_Counter()
Increment page read request counter method.
Definition: S25FL512.cpp:2851
BOOL Get_Bad_Block_Status(U32 u32_Block_Index, BOOL *bool_Bad_Block_Status)
Test for specified block is bad and can not be utilised.
Definition: S25FL512.cpp:2273
U32 u32_Block_Erase_Error_Counter
Block read error counter.
Definition: S25FL512.h:928
U8 u8_Test_Buffer[2048]
Actual block index of the search bad block count process.
Definition: S25FL512.h:953
BOOL Get_Feature(TS25FL512SAdress enum_Feature_Adress, U8 *u8_Data)
Get flash memory feature method.
Definition: S25FL512.cpp:2739
BOOL Read_Page_From_Cache(U16 u16_Offset, U32 u32_Length, U8 *u8_Data_Buffer)
Read multiple byte from chip cache method.
Definition: S25FL512.cpp:1589
TReturn_Test_Code QA_Flash_Driver_Main_Test()
Method for starting the main test sequence.
Definition: S25FL512.cpp:3773
virtual BOOL Read_Identification()
Read memory device identification information method.
Definition: S25FL512.cpp:1180
U8 u8_BP2
BP2 bit in BL register.
Definition: S25FL512.h:919
VOID Execute()
Background execute method.
Definition: S25FL512.cpp:166
BOOL Is_Operation_In_Progress()
Get operation status method.
Definition: S25FL512.cpp:2132
BOOL Get_Write_Protection_Bits()
Get write protection bits.
Definition: S25FL512.cpp:2803
BOOL Is_Read_Failure()
Get read operation status method.
Definition: S25FL512.cpp:2167
TReturn_Test_Code QA_Single_Block_Erase_Test()
Single block erase test method.
Definition: S25FL512.cpp:3620
virtual BOOL Read_Buffer(U32 u32_Linear_Address, U32 u32_Size, U8 *u8_Data_Buffer)
Read data from memory into buffer.
Definition: S25FL512.cpp:230
BOOL Write_Page_To_Cache(U16 u16_Offset, U32 u32_Length, U8 *u8_Data_Buffer)
Write multiple byte into chip cache method.
Definition: S25FL512.cpp:1727
BOOL Write_Buffer_By_Page_Index(U32 u32_Page_Index, U16 u16_Offset, U32 u32_Size, U8 *u8_Data_Buffer)
Write data from buffer into memory.
Definition: S25FL512.cpp:618
U8 u8_BP1
BP1 bit in BL register.
Definition: S25FL512.h:916
U8 u8_BRWD
BRWD bit in BL register.
Definition: S25FL512.h:922
TReturn_Test_Code QA_Erase_Block_Test()
Erase block test method.
Definition: S25FL512.cpp:2898
BOOL Read_Buffer_By_Page_Index(U32 u32_Page_Index, U16 u16_Offset, U32 u32_Size, U8 *u8_Data_Buffer)
Read data from memory into buffer.
Definition: S25FL512.cpp:311
U32 u32_Page_Write_Error_Counter
Page write error counter.
Definition: S25FL512.h:940
virtual VOID Start()
Driver start operation method.
Definition: S25FL512.cpp:139
U16 u16_Bad_Block_Count
Bad block count.
Definition: S25FL512.h:946
virtual BOOL Read_Status_Register(U8 *u8_Status_Register)
Read memory device status register method.
Definition: S25FL512.cpp:1147
virtual VOID Send_Information(TProtocol_Base *object_Protocol)
Method sends actual driver information over specified communication link protocol.
Definition: S25FL512.cpp:2621
BOOL Write_Page_From_Cache_To_Cells_By_Page_Index(U32 u32_Page_Index)
Write page from cache into chip cells method.
Definition: S25FL512.cpp:1992
volatile U8 u8_JEDEC_ID[3]
JEDEC code storage.
Definition: S25FL512.h:909
virtual BOOL Write_Buffer(U32 u32_Linear_Address, U32 u32_Size, U8 *u8_Data_Buffer)
Write data from buffer into memory.
Definition: S25FL512.cpp:492
BOOL Write_Page_From_Cache_To_Cells(U32 u32_Linear_Address)
Write page from cache into chip cells method.
Definition: S25FL512.cpp:1908
BOOL Wait_For_Operation_Done(F32 f32_Timeout)
Wait specified time for hardware controller operation done method.
Definition: S25FL512.cpp:2075
U8 u8_Device_ID
Serial number storage.
Definition: S25FL512.h:906
U32 u32_Block_Erase_Request_Counter
Block erase request counter.
Definition: S25FL512.h:925
U16 u16_Bad_Block_Counter
Bad block search counter.
Definition: S25FL512.h:943
virtual BOOL Write_Disable()
Disable write operation into memory.
Definition: S25FL512.cpp:1126
BOOL Read_Page_From_Cache_By_Leniar_Address(U32 u32_Address, U32 u32_Length, U8 *u8_Data_Buffer)
Read multiple byte from chip cache method.
Definition: S25FL512.cpp:1518
U16 u16_Execute_Bad_Block_Count_Index
Actual block index of the search bad block count process.
Definition: S25FL512.h:949
BOOL Set_Feature(TS25FL512SAdress enum_Feature_Adress, U8 u8_Data)
Set flash memory feature method.
Definition: S25FL512.cpp:2773
U8 u8_Manufacturer_ID
Manufacturer number storage.
Definition: S25FL512.h:903
BOOL Is_Program_Failure()
Get program operation status method.
Definition: S25FL512.cpp:2237
BOOL Read_Extended_Buffer(U32 u32_Linear_Address, U32 u32_Size, U8 *u8_Data_Buffer)
Read data from memory into buffer.
Definition: S25FL512.cpp:393
virtual BOOL Write_Enable()
Enable write operation into memory.
Definition: S25FL512.cpp:1105
BOOL Read_Page_From_Cells_To_Cache_By_Index(U32 u32_Page_Index)
Read page from chip cells into the cache method. Page referenced by absolute page index within memory...
Definition: S25FL512.cpp:1825
TS25FL512SCommand
Define NVRAM commands.
Definition: S25FL512.h:330
@ command4RFC
Read from cache x4 command.
Definition: S25FL512.h:375
@ command2RFC
Read from cache x2 command.
Definition: S25FL512.h:369
@ commandPE
Program execute command.
Definition: S25FL512.h:357
@ commandRES
Reset chip command.
Definition: S25FL512.h:333
@ commandRDID
Read manufacture ID, memory type ID, capacity ID command.
Definition: S25FL512.h:366
@ commandSF
Set feature command.
Definition: S25FL512.h:342
@ commandWREN
Write enable command.
Definition: S25FL512.h:348
@ commandBE
Block erase command.
Definition: S25FL512.h:336
@ commandRFC
Read from cache (or 0x0B) command.
Definition: S25FL512.h:363
@ commandREAD
Read page command.
Definition: S25FL512.h:360
@ commandGF
Get feature command.
Definition: S25FL512.h:339
@ command4RPP
Random page program x4 command.
Definition: S25FL512.h:372
@ commandRPP
Random page program command.
Definition: S25FL512.h:354
@ commandPP
Page program command.
Definition: S25FL512.h:351
@ commandWRDI
Write disable command.
Definition: S25FL512.h:345
VOID Increment_Page_Read_Error_Counter()
Increment page read error counter method.
Definition: S25FL512.cpp:2862
BOOL Write_Page_To_Cache_By_Leniar_Address(U32 u32_Address, U32 u32_Length, U8 *u8_Data_Buffer)
Write multiple byte into chip cache method.
Definition: S25FL512.cpp:1640
TReturn_Test_Code QA_Write_Page_Test()
Write page test method.
Definition: S25FL512.cpp:3051
U32 u32_Identifier_Dummy_Byte_Counter
Read identifier dummy byte counter.
Definition: S25FL512.h:913
VOID Increment_Page_Write_Request_Counter()
Increment page write request counter method.
Definition: S25FL512.cpp:2874
VOID Reset()
Software reset memory chip method.
Definition: S25FL512.cpp:1497
TReturn_Test_Code QA_Read_Page_Test()
Read page test method.
Definition: S25FL512.cpp:3307
VOID Increment_Page_Write_Error_Counter()
Increment page write error counter method.
Definition: S25FL512.cpp:2886
VOID Increment_Block_Erase_Error_Counter()
Increment block erase error counter method.
Definition: S25FL512.cpp:2839
BOOL Is_Page_In_Cache_Empty()
Test for specified page is empty and be utilised for write operation.
Definition: S25FL512.cpp:2546
TChip_Type
Define chip types.
Definition: S25FL512.h:309
@ chip_type_Unknown
Unknown chip.
Definition: S25FL512.h:315
@ chip_type_S25FL512S
512 MBit, NOR, SPANSION, S25FL512S
Definition: S25FL512.h:324
@ chip_type_None
No chip.
Definition: S25FL512.h:312
@ chip_type_IS37SML01G1
1 GBit, NAND, ISSI, IS37SML01G1
Definition: S25FL512.h:318
@ chip_type_GD5F4GQ4UAYIG
4 GBit, NAND, GigaDevice, GD5F4GQ4UAYIG
Definition: S25FL512.h:321
VOID Init()
Class constructor method.
Definition: S25FL512.cpp:127
BOOL Is_Erase_Failure()
Get erase operation status method.
Definition: S25FL512.cpp:2202
U32 u32_Page_Read_Request_Counter
Page read request counter.
Definition: S25FL512.h:931
U32 u32_Page_Write_Request_Counter
Page write request counter.
Definition: S25FL512.h:937
TS25FL512SAdress
Feature address list.
Definition: S25FL512.h:381
@ address_BL
Block lock register address.
Definition: S25FL512.h:384
@ address_SR
Status register address.
Definition: S25FL512.h:390
@ address_OTP
OTP register address.
Definition: S25FL512.h:387
@ address_OD
Output data register address.
Definition: S25FL512.h:393
SPI memory base class.
Definition: SPI_Memory_Base.h:55
U8 BP1
Bit 4 : BP1.
Definition: S25FL512.h:457
U8 u8_Raw_Data
Raw data.
Definition: S25FL512.h:438
U8 BP2
Bit 5 : BP2.
Definition: S25FL512.h:460
U8 BRWD
Bit 7 : BRWD.
Definition: S25FL512.h:466
U8 bit_Write_Enable_Latch
Bit 1 :Write enable latch bit.
Definition: S25FL512.h:412
U8 u8_Raw_Data
Raw data.
Definition: S25FL512.h:402
U8 bits_ECC_Status
Bit 4 and 5 :ECC status bits.
Definition: S25FL512.h:421
U8 bit_Erase_Fail
Bit 2 : Erase fail bit.
Definition: S25FL512.h:415
U8 bit_Program_Fail
Bit 3 Program fail bit.
Definition: S25FL512.h:418
U8 bit_Operation_In_Progress
Bit 0 : Operation in progress bit.
Definition: S25FL512.h:409