Čeština / English
Login

SVN Repository / Prohlížení

Aktuální adresář: FITkit / trunk / mcu / libfitkit /

flash.h

   1  /*******************************************************************************
   2     flash.h:
   3     Copyright (C) 2009 Brno University of Technology,
   4                        Faculty of Information Technology
   5  
   6     LICENSE TERMS
   7  
   8     Redistribution and use in source and binary forms, with or without
   9     modification, are permitted provided that the following conditions
  10     are met:
  11     1. Redistributions of source code must retain the above copyright
  12        notice, this list of conditions and the following disclaimer.
  13     2. Redistributions in binary form must reproduce the above copyright
  14        notice, this list of conditions and the following disclaimer in
  15        the documentation and/or other materials provided with the
  16        distribution.
  17     3. All advertising materials mentioning features or use of this software
  18        or firmware must display the following acknowledgement:
  19  
  20          This product includes software developed by the University of
  21          Technology, Faculty of Information Technology, Brno and its
  22          contributors.
  23  
  24     4. Neither the name of the Company nor the names of its contributors
  25        may be used to endorse or promote products derived from this
  26        software without specific prior written permission.
  27  
  28     This software or firmware is provided ``as is'', and any express or implied
  29     warranties, including, but not limited to, the implied warranties of
  30     merchantability and fitness for a particular purpose are disclaimed.
  31     In no event shall the company or contributors be liable for any
  32     direct, indirect, incidental, special, exemplary, or consequential
  33     damages (including, but not limited to, procurement of substitute
  34     goods or services; loss of use, data, or profits; or business
  35     interruption) however caused and on any theory of liability, whether
  36     in contract, strict liability, or tort (including negligence or
  37     otherwise) arising in any way out of the use of this software, even
  38     if advised of the possibility of such damage.
  39  
  40     $Id$
  41  
  42     Popis:
  43       Nizko-urovnove fce pro praci z flash.
  44  *******************************************************************************/
  45  
  46  #ifndef _FLASH_H_
  47  #define _FLASH_H_
  48  
  49  /******************************************************************************/
  50  /* operacni kody pro flash */
  51  
  52  
  53  
  54  
  55  
  56  
  57  
  58  
  59  
  60  
  61  
  62  
  63  
  64  
  65  
  66  
  67  #define OPCODE_PAGE_READ              0x52    ///< cteni stranky
  68  
  69  
  70  
  71  
  72  /**
  73   \brief Prevod z cisla stranky na adresu
  74   \return adresa zacatku stranky ve FLASH
  75   **/
  76  unsigned int FLASH_PageToAddr(unsigned short page);
  77  
  78  /**
  79  
  80   \return 0 - chyba
  81  
  82   **/
  83  unsigned char flash_init(char show_info);
  84  
  85  /**
  86  
  87   \return Status flash
  88   */
  89  unsigned char FLASH_ReadStatus(void);
  90  
  91  /**
  92  
  93  
  94  
  95   **/
  96  unsigned char FLASH_IsReady(void);
  97  
  98  /**
  99  
 100   */
 101  void FLASH_print_status(void);
 102  
 103  /**
 104  
 105   \param buf - ukazatel na data
 106   \param bufsz - velikost dat
 107   **/
 108  void FLASH_WriteToBuffer(unsigned char *buf, unsigned long bufsz);
 109  
 110  /**
 111  
 112   \param TypeBuffer - 0 nebo 1, TypeBuffer = 0, tak buffer = 1, jinak buffer = 2
 113   \param Buf - ukazatel na data
 114   \param Bufsz - velikost dat
 115   \param AdrBuffer - adresa v bufferu flash, od 0 do PAGE_SIZE-1
 116   **/
 117  void FLASH_WriteDataBuffer(unsigned char TypeBuffer, unsigned char *Buf,
 118                             unsigned int  Bufsz, unsigned int AdrBuffer);
 119  
 120  /**
 121  
 122   \param TypeBuffer - 0 nebo 1, TypeBuffer = 0, tak buffer = 1, jinak buffer = 2
 123   \param Buf - ukazatel na data
 124   \param Bufsz - velikost dat
 125   \param AdrBuffer - adresa v bufferu ve Flash, od 0 do PAGE_SIZE-1
 126   **/
 127  void FLASH_ReadDataBuffer(unsigned char TypeBuffer, unsigned char *Buf,
 128                            unsigned int  Bufsz,      unsigned int AdrBuffer);
 129  
 130  
 131  /**
 132  
 133   \param Buf - ukazatel na data
 134   \param Bufsz - velikost dat
 135  
 136  
 137   **/
 138  void FLASH_ReadData(unsigned char *Buf, unsigned int Bufsz,
 139                      unsigned int Page,  unsigned int AdrInPage);
 140  
 141  /**
 142  
 143   \param buf - ukazatel na data
 144   \param bufsz - velikost dat
 145  
 146   **/
 147  void FLASH_ReadDataA(unsigned char *Buf, unsigned int Bufsz, long int Adr);
 148  
 149  /**
 150  
 151   \param TypeBuffer: 0 nebo 1, TypeBuffer = 1, tak buffer = 1, jinak buffer = 2
 152  
 153   **/
 154  void FLASH_WriteBufferMemory(unsigned char TypeBuffer, unsigned int Page);
 155  
 156  /**
 157  
 158   \param TypeBuffer: 0 nebo 1, TypeBuffer = 1, tak buffer = 1, jinak buffer = 2
 159  
 160   **/
 161  void FLASH_ReadMemoryBuffer(unsigned char TypeBuffer, unsigned int Page);
 162  
 163  /**
 164  
 165  
 166  
 167   \return 0 - chyba
 168  
 169   **/
 170  char FLASH_ProgFPGA(unsigned long Adr, unsigned long Length);
 171  
 172  /**
 173  
 174   \param Adr - adresa
 175   \param uChar - znak
 176   **/
 177  void FLASH_WriteByte(unsigned long Adr, unsigned char uChar);
 178  
 179  /**
 180  
 181   \param Adr - adresa
 182   **/
 183  void FLASH_EraseByte(unsigned long Adr);
 184  
 185  /**
 186  
 187  
 188   **/
 189  void FLASH_ErasePage(unsigned int Page);
 190  
 191  /**
 192  
 193   \param block - blok flash
 194   **/
 195  void FLASH_EraseBlock(unsigned int block);
 196  
 197  /**
 198  
 199  **/
 200  void FLASH_EraseAll(void);
 201  
 202  /**
 203  
 204  **/
 205  void FLASH_Dump_All(void);
 206  
 207  /**
 208  
 209  
 210   **/
 211  void FLASH_Dump_Block(long int block);
 212  
 213  /**
 214  
 215  
 216  **/
 217  void FLASH_Dump_Page(long int page);
 218  
 219  /**
 220  
 221    \param adr - adresa (0..)
 222  
 223   **/
 224  void FLASH_Dump_Adr(long int adr, long int len);
 225  
 226  /**
 227   \brief Test, zda-li je dana stranka prazdna (obsahuje same 0x00 nebo 0xFF)
 228  
 229   \return 0 - stranka obsahuje data, 1 stranka je prazdna
 230   **/
 231  char FLASH_isPageBlank(unsigned short page);
 232  
 233  /**
 234   \brief Vraci pocet dostupnych stranek FLASH pameti, ktera mohou byt pouzita pro uzivatelska data
 235   \return pocet stranek
 236   **/
 237  unsigned long FLASH_availablepages(void);
 238  
 239  #endif
 240  
Zobrazeno: 731723x Naposledy: 29.11.2022 04:42:34