|
| 1 | + |
| 2 | +/** |
| 3 | + * FLASH Generated Driver Header File |
| 4 | + * |
| 5 | + * @file flash.h |
| 6 | + * |
| 7 | + * @ingroup Flash Driver |
| 8 | + * |
| 9 | + * @brief This is the generated driver header file for the FLASH driver |
| 10 | + * |
| 11 | + * @skipline @version Firmware Driver Version 1.1.0 |
| 12 | + * |
| 13 | + * @skipline @version PLIB Version 3.2.1 |
| 14 | + * |
| 15 | + * @skipline Device : dsPIC33CK1024MP710 |
| 16 | +*/ |
| 17 | + |
| 18 | +/* |
| 19 | +© [2024] Microchip Technology Inc. and its subsidiaries. |
| 20 | +
|
| 21 | + Subject to your compliance with these terms, you may use Microchip |
| 22 | + software and any derivatives exclusively with Microchip products. |
| 23 | + You are responsible for complying with 3rd party license terms |
| 24 | + applicable to your use of 3rd party software (including open source |
| 25 | + software) that may accompany Microchip software. SOFTWARE IS ?AS IS.? |
| 26 | + NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS |
| 27 | + SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, |
| 28 | + MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT |
| 29 | + WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, |
| 30 | + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY |
| 31 | + KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF |
| 32 | + MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE |
| 33 | + FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S |
| 34 | + TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT |
| 35 | + EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR |
| 36 | + THIS SOFTWARE. |
| 37 | +*/ |
| 38 | + |
| 39 | +#ifndef FLASH_HARDWARE_H |
| 40 | +#define FLASH_HARDWARE_H |
| 41 | + |
| 42 | +#include <xc.h> |
| 43 | +#include <stdint.h> |
| 44 | +#include <stdbool.h> |
| 45 | +#include "flash_types.h" |
| 46 | + |
| 47 | +/** |
| 48 | + @ingroup flashdriver |
| 49 | + @brief Defines FLASH Flash PC unit size |
| 50 | +*/ |
| 51 | +#define FLASH_PC_UNIT_SIZE 2U |
| 52 | +/** |
| 53 | + @ingroup flashdriver |
| 54 | + @brief Defines FLASH unlock key value |
| 55 | +*/ |
| 56 | +#define FLASH_UNLOCK_KEY 0x00AA0055 |
| 57 | +/** |
| 58 | + @ingroup flashdriver |
| 59 | + @brief Defines FLASH write row size in instruction counts |
| 60 | +*/ |
| 61 | +#define FLASH_WRITE_ROW_SIZE_IN_INSTRUCTIONS 128U |
| 62 | +/** |
| 63 | + @ingroup flashdriver |
| 64 | + @brief Defines FLASH write row size in PC counts |
| 65 | +*/ |
| 66 | +#define FLASH_WRITE_ROW_SIZE_IN_PC_UNITS (FLASH_WRITE_ROW_SIZE_IN_INSTRUCTIONS * FLASH_PC_UNIT_SIZE) |
| 67 | +/** |
| 68 | + @ingroup flashdriver |
| 69 | + @brief Defines FLASH erase page size in instruction counts |
| 70 | +*/ |
| 71 | +#define FLASH_ERASE_PAGE_SIZE_IN_INSTRUCTIONS 1024U |
| 72 | +/** |
| 73 | + @ingroup flashdriver |
| 74 | + @brief Defines FLASH erase page size in PC counts |
| 75 | +*/ |
| 76 | +#define FLASH_ERASE_PAGE_SIZE_IN_PC_UNITS (FLASH_ERASE_PAGE_SIZE_IN_INSTRUCTIONS * FLASH_PC_UNIT_SIZE) |
| 77 | +/** |
| 78 | + @ingroup flashdriver |
| 79 | + @brief Defines if FLASH has ECC |
| 80 | +*/ |
| 81 | +#define FLASH_HAS_ECC 1 |
| 82 | +/** |
| 83 | + @ingroup flashdriver |
| 84 | + @brief Defines FLASH erase page mask value |
| 85 | +*/ |
| 86 | +#define FLASH_ERASE_PAGE_MASK (~(FLASH_ERASE_PAGE_SIZE_IN_PC_UNITS - 1U)) |
| 87 | +/** |
| 88 | + @ingroup flashdriver |
| 89 | + @brief Defines FLASH odd address mask value |
| 90 | +*/ |
| 91 | +#define FLASH_ODD_ADDRESS_MASK 1U |
| 92 | +/** |
| 93 | + @ingroup flashdriver |
| 94 | + @brief Defines FLASH error mask value |
| 95 | +*/ |
| 96 | +#define FLASH_ERROR_MASK 0x2100 |
| 97 | + |
| 98 | +/** |
| 99 | + * @ingroup flashdriver |
| 100 | + * @brief This routine erases a page indicated by the page aligned address. |
| 101 | + * @param[in] address - Flash page aligned address. |
| 102 | + * @return bool - Returns True if operation successful else returns false. |
| 103 | + */ |
| 104 | +bool FLASH_ErasePage(flash_adr_t address, flash_key_t unlockKey); |
| 105 | + |
| 106 | +/* The address in the Read and Write word functions below must be even */ |
| 107 | + |
| 108 | +/** |
| 109 | + * @ingroup flashdriver |
| 110 | + * @brief This routine reads a 24 bit instruction from the indicated address in flash. |
| 111 | + * @param[in] address - Flash address. |
| 112 | + * @return uint32_t - 24 bit data. |
| 113 | + */ |
| 114 | +uint32_t FLASH_ReadWord24(flash_adr_t address); |
| 115 | + |
| 116 | + |
| 117 | +/** |
| 118 | + * @ingroup flashdriver |
| 119 | + * @brief This routine reads a 16 bit instruction from the indicated address in flash. |
| 120 | + * @param[in] address - Flash address. |
| 121 | + * @return uint16_t - 16 bit data. |
| 122 | + */ |
| 123 | +uint16_t FLASH_ReadWord16(flash_adr_t address); |
| 124 | + |
| 125 | + |
| 126 | +/** |
| 127 | + * @ingroup flashdriver |
| 128 | + * @brief This routine writes two 24 bit instructions to the indicated address in flash. |
| 129 | + * @param[in] address - Flash address. |
| 130 | + * @param[in] data1 - First 24 bit data to be written(First word). |
| 131 | + * @param[in] data2 - Second 24 bit data to be written(Second word). |
| 132 | + * @return bool - Returns true if operation is successful else returns false. |
| 133 | + */ |
| 134 | +bool FLASH_WriteDoubleWord24(flash_adr_t address, flash_data_t Data0, flash_data_t Data1, flash_key_t unlockKey); |
| 135 | + |
| 136 | + |
| 137 | +/** |
| 138 | + * @ingroup flashdriver |
| 139 | + * @brief This routine writes two ,16 bit instructions to the indicated address in flash. |
| 140 | + * @param[in] address - Flash address. |
| 141 | + * @param[in] data1 - First 16 bit data to be written(First word). |
| 142 | + * @param[in] data2 - Second 16 bit data to be written(Second word). |
| 143 | + * @return bool - Returns true if operation is successful else returns false. |
| 144 | + */ |
| 145 | +bool FLASH_WriteDoubleWord16(flash_adr_t flashAddress, uint16_t Data0, uint16_t Data1, flash_key_t unlockKey); |
| 146 | + |
| 147 | + |
| 148 | +/* Program the flash one row at a time. */ |
| 149 | + |
| 150 | + |
| 151 | +/** |
| 152 | + * @ingroup flashdriver |
| 153 | + * @brief |
| 154 | + * This routine writes a single row of data from the location given in *data to the flash location in address. |
| 155 | + * Since the flash is only 24 bits wide all data in the upper 8 bits of the source will be lost.The address in |
| 156 | + * *data must be row aligned. |
| 157 | + * @param[in] address - Flash address. |
| 158 | + * @param[in] *data - Address of the data to be written. |
| 159 | + * @return bool - Returns true if operation is successful else returns false. |
| 160 | + */ |
| 161 | +bool FLASH_WriteRow24(flash_adr_t flashAddress, flash_data_t *data, flash_key_t unlockKey); |
| 162 | + |
| 163 | + |
| 164 | +/** |
| 165 | + * @ingroup flashdriver |
| 166 | + * @brief |
| 167 | + * This routine writes a single row of data from the location given in *data to the flash location in address. |
| 168 | + * Each 16 bit source data word is stored in the lower 16 bits of each flash entry and the upper 8 bits of the |
| 169 | + * flash is not programmed.The address in *data must be row aligned. |
| 170 | + * @param[in] address - Flash address. |
| 171 | + * @param[in] *data - Address of the data to be written. |
| 172 | + * @return bool - Returns true if operation is successful else returns false. |
| 173 | + */ |
| 174 | +bool FLASH_WriteRow16(flash_adr_t address, uint16_t *data, flash_key_t unlockKey); |
| 175 | + |
| 176 | + |
| 177 | +/** |
| 178 | + * @ingroup flashdriver |
| 179 | + * @brief This routiner returns the page offset the given flash address. |
| 180 | + * @param[in] address - Flash address. |
| 181 | + * @return uint32_t - returns offset. |
| 182 | + */ |
| 183 | +uint16_t FLASH_ErasePageOffsetGet(flash_adr_t address); |
| 184 | + |
| 185 | + |
| 186 | +/** |
| 187 | + * @ingroup flashdriver |
| 188 | + * @brief This routine returns the page aligned address for a given flash address.. |
| 189 | + * @param[in] address - Flash address. |
| 190 | + * @return uint32_t - Returns page aligned flash address. |
| 191 | + */ |
| 192 | +uint32_t FLASH_ErasePageAddressGet(flash_adr_t address); |
| 193 | + |
| 194 | +#endif /* FLASH_HARDWARE_H */ |
0 commit comments