47 #ifndef __FLASHSAFE_H__
48 #define __FLASHSAFE_H__
63 #include <inc/hw_types.h>
64 #include <inc/hw_flash.h>
65 #include <inc/hw_memmap.h>
66 #include <inc/hw_ints.h>
67 #include <inc/hw_fcfg1.h>
89 #ifndef DRIVERLIB_GENERATE_ROM
90 #define FlashsafeSizeGet NOROM_FlashsafeSizeGet
91 #define FlashsafeSectorSizeGet NOROM_FlashsafeSectorSizeGet
92 #define FlashsafePowerModeSet NOROM_FlashsafePowerModeSet
93 #define FlashsafePowerModeGet NOROM_FlashsafePowerModeGet
94 #define FlashsafeProtectionSet NOROM_FlashsafeProtectionSet
95 #define FlashsafeProtectionGet NOROM_FlashsafeProtectionGet
96 #define FlashsafeProtectionSave NOROM_FlashsafeProtectionSave
97 #define FlashsafeCheckFsmForError NOROM_FlashsafeCheckFsmForError
98 #define FlashsafeCheckFsmForReady NOROM_FlashsafeCheckFsmForReady
99 #define FlashsafeIntRegister NOROM_FlashsafeIntRegister
100 #define FlashsafeIntUnregister NOROM_FlashsafeIntUnregister
101 #define FlashsafeIntEnable NOROM_FlashsafeIntEnable
102 #define FlashsafeIntDisable NOROM_FlashsafeIntDisable
103 #define FlashsafeIntStatus NOROM_FlashsafeIntStatus
104 #define FlashsafeIntClear NOROM_FlashsafeIntClear
105 #define FlashsafeSectorErase NOROM_FlashsafeSectorErase
106 #define FlashsafeProgram NOROM_FlashsafeProgram
107 #define FlashsafeProgramNowait NOROM_FlashsafeProgramNowait
108 #define FlashsafeProgramNowaitRelease NOROM_FlashsafeProgramNowaitRelease
109 #define FlashsafeDisableSectorsForWrite NOROM_FlashsafeDisableSectorsForWrite
118 #define FLASHSAFE_ACCESS_DENIED 0x000000ff
119 #define FLASHSAFE_ACCESS_OK 0x000000ee
120 #define SMPH_ALLOC_FLASH 1
127 #define FAPI_STATUS_SUCCESS 0x00000000 // Function completed successfully
128 #define FAPI_STATUS_FSM_BUSY 0x00000001 // FSM is Busy
129 #define FAPI_STATUS_FSM_READY 0x00000002 // FSM is Ready
130 #define FAPI_STATUS_INCORRECT_DATABUFFER_LENGTH \
131 0x00000003 // Incorrect parameter value
132 #define FAPI_STATUS_FSM_ERROR 0x00000004 // Operation failed
140 #define FLASH_INT_FSM_DONE 0x00400000 // FSM Done Interrupt Mask
141 #define FLASH_INT_RV 0x00010000 // Read Verify error Interrupt Mask
148 #define FLASH_PWR_ACTIVE_MODE 0x00000000
149 #define FLASH_PWR_OFF_MODE 0x00000001
150 #define FLASH_PWR_DEEP_STDBY_MODE \
158 #define FLASH_NO_PROTECT 0x00000000 // Sector not protected
159 #define FLASH_WRITE_PROTECT 0x00000001 // Sector erase and program
167 #define FSM_REG_WRT_ENABLE 5
168 #define FSM_REG_WRT_DISABLE 2
268 uint32_t ui32BankGracePeriode,
269 uint32_t ui32PumpGracePeriode);
311 uint32_t ui32ProtectMode);
558 extern uint32_t
FlashsafeProgram(uint8_t *pui8DataBuffer, uint32_t ui32Address,
583 #ifndef DRIVERLIB_NOROM
585 #ifdef ROM_FlashsafeSizeGet
586 #undef FlashsafeSizeGet
587 #define FlashsafeSizeGet ROM_FlashsafeSizeGet
589 #ifdef ROM_FlashsafeSectorSizeGet
590 #undef FlashsafeSectorSizeGet
591 #define FlashsafeSectorSizeGet ROM_FlashsafeSectorSizeGet
593 #ifdef ROM_FlashsafePowerModeSet
594 #undef FlashsafePowerModeSet
595 #define FlashsafePowerModeSet ROM_FlashsafePowerModeSet
597 #ifdef ROM_FlashsafePowerModeGet
598 #undef FlashsafePowerModeGet
599 #define FlashsafePowerModeGet ROM_FlashsafePowerModeGet
601 #ifdef ROM_FlashsafeProtectionSet
602 #undef FlashsafeProtectionSet
603 #define FlashsafeProtectionSet ROM_FlashsafeProtectionSet
605 #ifdef ROM_FlashsafeProtectionGet
606 #undef FlashsafeProtectionGet
607 #define FlashsafeProtectionGet ROM_FlashsafeProtectionGet
609 #ifdef ROM_FlashsafeProtectionSave
610 #undef FlashsafeProtectionSave
611 #define FlashsafeProtectionSave ROM_FlashsafeProtectionSave
613 #ifdef ROM_FlashsafeCheckFsmForError
614 #undef FlashsafeCheckFsmForError
615 #define FlashsafeCheckFsmForError ROM_FlashsafeCheckFsmForError
617 #ifdef ROM_FlashsafeCheckFsmForReady
618 #undef FlashsafeCheckFsmForReady
619 #define FlashsafeCheckFsmForReady ROM_FlashsafeCheckFsmForReady
621 #ifdef ROM_FlashsafeIntRegister
622 #undef FlashsafeIntRegister
623 #define FlashsafeIntRegister ROM_FlashsafeIntRegister
625 #ifdef ROM_FlashsafeIntUnregister
626 #undef FlashsafeIntUnregister
627 #define FlashsafeIntUnregister ROM_FlashsafeIntUnregister
629 #ifdef ROM_FlashsafeIntEnable
630 #undef FlashsafeIntEnable
631 #define FlashsafeIntEnable ROM_FlashsafeIntEnable
633 #ifdef ROM_FlashsafeIntDisable
634 #undef FlashsafeIntDisable
635 #define FlashsafeIntDisable ROM_FlashsafeIntDisable
637 #ifdef ROM_FlashsafeIntStatus
638 #undef FlashsafeIntStatus
639 #define FlashsafeIntStatus ROM_FlashsafeIntStatus
641 #ifdef ROM_FlashsafeIntClear
642 #undef FlashsafeIntClear
643 #define FlashsafeIntClear ROM_FlashsafeIntClear
645 #ifdef ROM_FlashsafeSectorErase
646 #undef FlashsafeSectorErase
647 #define FlashsafeSectorErase ROM_FlashsafeSectorErase
649 #ifdef ROM_FlashsafeProgram
650 #undef FlashsafeProgram
651 #define FlashsafeProgram ROM_FlashsafeProgram
653 #ifdef ROM_FlashsafeProgramNowait
654 #undef FlashsafeProgramNowait
655 #define FlashsafeProgramNowait ROM_FlashsafeProgramNowait
657 #ifdef ROM_FlashsafeProgramNowaitRelease
658 #undef FlashsafeProgramNowaitRelease
659 #define FlashsafeProgramNowaitRelease ROM_FlashsafeProgramNowaitRelease
661 #ifdef ROM_FlashsafeDisableSectorsForWrite
662 #undef FlashsafeDisableSectorsForWrite
663 #define FlashsafeDisableSectorsForWrite ROM_FlashsafeDisableSectorsForWrite
676 #endif // __FLASHSAFE_H__
__STATIC_INLINE bool FlashsafeSMPHTryAcquire(void)
Aquire the flash semaphore.
uint32_t FlashsafeSectorSizeGet(void)
Get size of a flash sector in no of bytes.
__STATIC_INLINE void FlashsafeSMPHRelease(void)
Release the flash semaphore.
uint32_t FlashsafeSectorErase(uint32_t ui32SectorAddress)
Erase a flash sector.
uint32_t FlashsafeIntEnable(uint32_t ui32IntFlags)
Enables flash controller interrupt sources.
uint32_t FlashsafeCheckFsmForError(void)
Checks if the Flashsafe state machine has detected an error.
uint32_t FlashsafePowerModeGet(void)
Get current configured power mode.
uint32_t FlashsafeProgram(uint8_t *pui8DataBuffer, uint32_t ui32Address, uint32_t ui32Count)
Programs unprotected main bank flash sectors.
uint32_t FlashsafeIntClear(uint32_t ui32IntFlags)
Clears flash controller interrupt source.
__STATIC_INLINE void SMPHRelease(uint32_t ui32Semaphore)
Release a semaphore.
uint32_t FlashsafeIntDisable(uint32_t ui32IntFlags)
Disables individual flash controller interrupt sources.
uint32_t FlashsafeCheckFsmForReady(void)
Checks if the Flash state machine is ready.
uint32_t FlashsafeProtectionSet(uint32_t ui32SectorAddress, uint32_t ui32ProtectMode)
Set sector protection.
uint32_t FlashsafePowerModeSet(uint32_t ui32PowerMode, uint32_t ui32BankGracePeriode, uint32_t ui32PumpGracePeriode)
Set power mode.
uint32_t FlashsafeDisableSectorsForWrite(void)
Disables all sectors for erase and programming on the active bank.
uint32_t FlashsafeProtectionGet(uint32_t ui32SectorAddress)
Get sector protection.
uint32_t FlashsafeProtectionSave(uint32_t ui32SectorAddress)
Save sector protection to make it permanent.
uint32_t FlashsafeIntStatus(void)
Gets the current interrupt status.
__STATIC_INLINE bool SMPHTryAcquire(uint32_t ui32Semaphore)
Try to Acquire a semaphore.
uint32_t FlashsafeSizeGet(void)
Get the size of the flash.
uint32_t FlashsafeIntUnregister(void)
Unregisters the interrupt handler for the flash interrupt.
uint32_t FlashsafeIntRegister(void(*pfnHandler)(void))
Registers an interrupt handler for the flash interrupt.