|
SmartSnippets DA1459x SDK
|
Go to the documentation of this file.
45 #if dg_configUSE_HW_FCU
55 #define HW_FCU_FLASH_PAGE_SIZE_IN_BYTES (2048)
56 #define HW_FCU_FLASH_PAGE_SIZE_IN_WORDS (HW_FCU_FLASH_PAGE_SIZE_IN_BYTES / 4)
58 #define HW_FCU_ERASE_FLASH_PAGE_MIN_TIME (0x13880)
63 #define HW_FCU_ERASE_FLASH_PAGE_MAX_TIME (0x3FFFF)
65 #define HW_FCU_ERASE_FLASH_BLOCK_MIN_TIME (0x13880)
70 #define HW_FCU_ERASE_FLASH_BLOCK_MAX_TIME (0x3FFFF)
72 #define HW_FCU_ERASE_FLASH_PAGE_SEGMENT_MIN_TIME (0x3E8)
77 #define HW_FCU_ERASE_FLASH_PAGE_SEGMENT_MAX_TIME (0x3FFFF)
83 HW_FCU_ERROR_ERASE_IN_PROGRESS = -5,
84 HW_FCU_ERROR_WRITE_IN_PROGRESS = -4,
85 HW_FCU_ERROR_PROTECTED_AGAINST_ACTION = -3,
86 HW_FCU_ERROR_INVALID_ADDRESS = -2,
87 HW_FCU_ERROR_INVALID_FUNCTION_INPUT = -1,
125 HW_FCU_WAIT_CYCLES_0,
126 HW_FCU_WAIT_CYCLES_1,
127 HW_FCU_WAIT_CYCLES_2,
128 HW_FCU_WAIT_CYCLES_3,
129 HW_FCU_WAIT_CYCLES_4,
130 HW_FCU_WAIT_CYCLES_5,
131 HW_FCU_WAIT_CYCLES_6,
132 HW_FCU_WAIT_CYCLES_7,
133 HW_FCU_WAIT_CYCLES_MAX
157 #if dg_configUSE_HW_DMA
174 REG_SETF(FCU, FLASH_CTRL_REG, VDD_LEVEL_VALUE, value);
189 return REG_GETF(FCU, FLASH_CTRL_REG, VDD_LEVEL_VALUE);
231 return REG_GETF(FCU, FLASH_CTRL_REG, FLASH_PROT) == 1;
245 return REG_GETF(FCU, FLASH_CTRL_REG, ERASE_SUSPEND_STAT) == 1;
257 REG_SETF(FCU, FLASH_CTRL_REG, ERASE_SUSPEND_MODE,
mode);
269 return REG_GETF(FCU, FLASH_CTRL_REG, ERASE_SUSPEND_MODE);
280 REG_SET_BIT(FCU, FLASH_CTRL_REG, ERASE_SUSPEND_EN);
288 REG_CLR_BIT(FCU, FLASH_CTRL_REG, ERASE_SUSPEND_EN);
298 return REG_GETF(FCU, FLASH_CTRL_REG, ERASE_SUSPEND_EN) == 1;
309 return REG_GETF(FCU, FLASH_CTRL_REG, SLEEP) == 1;
339 return REG_GETF(FCU, FLASH_CTRL_REG, DMA_EN) == 1;
360 return REG_GETF(FCU, FLASH_CTRL_REG, BUS_ERROR_EN) == 1;
372 return REG_GETF(FCU, FLASH_CTRL_REG, BUS_ERROR) == 1;
392 return REG_GETF(FCU, FLASH_CTRL_REG, WAIT_CYCLES);
413 ASSERT_WARNING(wait_cycles < HW_FCU_WAIT_CYCLES_MAX);
415 REG_SETF(FCU, FLASH_CTRL_REG, WAIT_CYCLES, wait_cycles);
435 return ((FCU->FLASH_CTRL_REG & mask) != 0);
455 return REG_GETF(FCU, FLASH_CTRL_REG, FLASH_RPROT) == 1;
475 return REG_GETF(FCU, FLASH_CTRL_REG, FLASH_WPROT) == 1;
485 return REG_GETF(FCU, FLASH_CTRL_REG, PROG_RMIN) == 1;
496 return REG_GETF(FCU, FLASH_CTRL_REG, PROG_ERS) == 1;
507 uint32_t reg_val = FCU->FLASH_CTRL_REG;
508 uint32_t mask =
REG_MSK(FCU, FLASH_CTRL_REG, ERASE_SUSPEND_EN) |
509 REG_MSK(FCU, FLASH_CTRL_REG, ERASE_SUSPEND_STAT);
511 if (mask == (reg_val & mask)) {
525 return REG_GETF(FCU, FLASH_CTRL_REG, PROG_WRS) == 1;
549 return REG_GETF(FCU, FLASH_CTRL_REG, PROG_SEL);
573 return REG_GETF(FCU, FLASH_CTRL_REG, PROG_MODE);
594 ASSERT_WARNING(hold_time >= 100);
595 REG_SETF(FCU, FLASH_PTNVH1_REG, PTNVH1, hold_time);
605 return REG_GETF(FCU, FLASH_PTNVH1_REG, PTNVH1);
616 ASSERT_WARNING(prog_time >= 8);
617 REG_SETF(FCU, FLASH_PTPROG_REG, PTPROG, prog_time);
627 return REG_GETF(FCU, FLASH_PTPROG_REG, PTPROG);
638 ASSERT_WARNING(erase_time >= HW_FCU_ERASE_FLASH_PAGE_MIN_TIME &&
639 erase_time < HW_FCU_ERASE_FLASH_PAGE_MAX_TIME + 1);
640 REG_SETF(FCU, FLASH_PTERASE_REG, PTERASE, erase_time);
650 return REG_GETF(FCU, FLASH_PTERASE_REG, PTERASE);
661 ASSERT_WARNING(erase_time >= HW_FCU_ERASE_FLASH_BLOCK_MIN_TIME &&
662 erase_time < HW_FCU_ERASE_FLASH_BLOCK_MAX_TIME + 1);
663 REG_SETF(FCU, FLASH_PTME_REG, PTME, erase_time);
673 return REG_GETF(FCU, FLASH_PTME_REG, PTME);
683 ASSERT_WARNING(wakeup_time >= 3);
684 REG_SETF(FCU, FLASH_PTWK_SP_REG, PTWK_SP, wakeup_time);
694 return REG_GETF(FCU, FLASH_PTWK_SP_REG, PTWK_SP);
704 ASSERT_WARNING(erase_time >= HW_FCU_ERASE_FLASH_PAGE_SEGMENT_MIN_TIME &&
705 erase_time < HW_FCU_ERASE_FLASH_PAGE_SEGMENT_MAX_TIME + 1);
706 REG_SETF(FCU, FLASH_PTERASE_SEG_REG, PTERASE_SEG, erase_time);
716 return REG_GETF(FCU, FLASH_PTERASE_SEG_REG, PTERASE_SEG);
726 return REG_GETF(FCU, FLASH_RTERASE_TOT_CNT_REG, RTERASE_TOT_CNT);
736 return REG_GETF(FCU, FLASH_RTERASE_SEG_CNT_REG, RTERASE_SEG_CNT);
744 REG_SET_BIT(CRG_TOP, RST_CTRL_REG, GATE_RST_WITH_FCU);
752 REG_CLR_BIT(CRG_TOP, RST_CTRL_REG, GATE_RST_WITH_FCU);
800 uint32_t page_erase_time,
801 uint32_t segment_erase_time);
__STATIC_FORCEINLINE void hw_fcu_enable_bus_error(void)
Enable bus error response.
Definition: hw_fcu.h:348
Definition of API for the DMA Low Level Driver.
#define REG_SETF(base, reg, field, new_val)
Set the value of a register field.
Definition: sdk_defs.h:738
__STATIC_FORCEINLINE void hw_fcu_enable_erase_suspend(void)
Enable erase/suspend functionality.
Definition: hw_fcu.h:278
__ALWAYS_RETAINED_CODE void hw_fcu_enable_read(void)
Put FCU in read mode.
#define REG_CLR_BIT(base, reg, field)
Clear a bit of a register.
Definition: sdk_defs.h:781
__STATIC_FORCEINLINE HW_FCU_FLASH_ACCESS_MODE hw_fcu_get_flash_access_mode(void)
Get flash read/write/erase mode.
Definition: hw_fcu.h:547
#define REG_SET_BIT(base, reg, field)
Set a bit of a register.
Definition: sdk_defs.h:766
__STATIC_FORCEINLINE uint32_t hw_fcu_get_total_erase_counter(void)
Get total erase time counter value.
Definition: hw_fcu.h:724
__STATIC_FORCEINLINE void hw_fcu_disable_reset_delay(void)
Disables reset delay when FCU write/erase has finished.
Definition: hw_fcu.h:750
__STATIC_FORCEINLINE uint32_t hw_fcu_get_flash_page_erase_time(void)
Get program flash page erase time.
Definition: hw_fcu.h:648
__STATIC_FORCEINLINE bool hw_fcu_is_bus_error_enabled(void)
Check if bus error response is enabled.
Definition: hw_fcu.h:358
__ALWAYS_RETAINED_CODE void hw_fcu_wakeup(void)
Wakeup FCU.
__STATIC_FORCEINLINE HW_FCU_FLASH_PROG_MODE hw_fcu_get_flash_programming_mode(void)
Get program flash mode.
Definition: hw_fcu.h:571
__STATIC_FORCEINLINE void hw_fcu_set_erase_suspend_mode(HW_FCU_ERASE_SUSPEND_MODE mode)
Set erase/suspend mode.
Definition: hw_fcu.h:255
__STATIC_FORCEINLINE HW_FCU_VDD_LEVEL_VALUE hw_fcu_get_vdd_level_value(void)
Get VDD level value.
Definition: hw_fcu.h:187
__STATIC_FORCEINLINE bool hw_fcu_is_asleep(void)
Check if fcu is in sleeping mode.
Definition: hw_fcu.h:307
__STATIC_FORCEINLINE void hw_fcu_prohibit_flash_operations(void)
Prohibit flash operations.
Definition: hw_fcu.h:211
__STATIC_FORCEINLINE uint32_t hw_fcu_get_flash_mass_erase_time(void)
Get program flash mass erase time.
Definition: hw_fcu.h:671
__STATIC_FORCEINLINE uint16_t hw_fcu_get_flash_hold_time(void)
Get program flash NVSTR1 hold time.
Definition: hw_fcu.h:603
Central include header file with platform definitions.
__STATIC_FORCEINLINE bool hw_fcu_get_bus_error_status(void)
Get bus error status.
Definition: hw_fcu.h:370
HW_FCU_FLASH_ACCESS_MODE
FCU flash read/write/erase mode.
Definition: hw_fcu.h:106
__STATIC_FORCEINLINE void hw_fcu_enable_reset_delay(void)
Enables reset delay when FCU write/erase begins.
Definition: hw_fcu.h:742
__STATIC_FORCEINLINE uint32_t hw_fcu_get_flash_page_segment_erase_time(void)
Get program flash page segment erase time for suspend erase.
Definition: hw_fcu.h:714
__STATIC_FORCEINLINE void hw_fcu_set_flash_hold_time(uint16_t hold_time)
Set program flash NVSTR1 hold time.
Definition: hw_fcu.h:592
__STATIC_FORCEINLINE void hw_fcu_enable_flash_read_protection(void)
Enable program flash read protection.
Definition: hw_fcu.h:443
__STATIC_FORCEINLINE void hw_fcu_set_sleep_mode(void)
Puts FCU (eFlash) in sleep mode for lower leakage current.
Definition: hw_fcu.h:581
__STATIC_FORCEINLINE void hw_fcu_resume_erase(void)
Resume erase.
Definition: hw_fcu.h:505
__ALWAYS_RETAINED_CODE HW_FCU_ERROR hw_fcu_write(uint32_t *src, uint32_t address, uint32_t len, struct hw_fcu_operation_params_t *params)
Write a buffer to flash address (first flash page should be erased)
HW_DMA_CHANNEL
DMA channel number.
Definition: hw_dma.h:62
__STATIC_FORCEINLINE uint32_t hw_fcu_get_segment_erase_counter(void)
Get segment erase time counter value.
Definition: hw_fcu.h:734
__ALWAYS_RETAINED_CODE void hw_fcu_enable_write(void)
Put FCU in write mode.
HW_DMA_CHANNEL dma_channel
Definition: hw_fcu.h:158
__STATIC_FORCEINLINE void hw_fcu_set_flash_sleep_to_standby_time(uint8_t wakeup_time)
Set program flash sleep to standby wake-up time.
Definition: hw_fcu.h:681
__STATIC_FORCEINLINE void hw_fcu_set_vdd_level_value(HW_FCU_VDD_LEVEL_VALUE value)
Set VDD level value.
Definition: hw_fcu.h:172
__STATIC_FORCEINLINE void hw_fcu_set_flash_page_erase_time(uint32_t erase_time)
Set program flash page erase time.
Definition: hw_fcu.h:636
__ALWAYS_RETAINED_CODE void hw_fcu_enable_erase(HW_FCU_FLASH_PROG_MODE mode)
Put FCU in erase mode.
__ALWAYS_RETAINED_CODE bool hw_fcu_is_available(void)
Check if FCU is not busy or in sleeping mode.
__ALWAYS_RETAINED_CODE HW_FCU_ERROR hw_fcu_configure_erase_page_suspend(HW_FCU_ERASE_SUSPEND_MODE mode, uint32_t page_erase_time, uint32_t segment_erase_time)
Configure page erase suspend/resume.
__ALWAYS_RETAINED_CODE HW_FCU_ERROR hw_fcu_erase_block(uint32_t address, struct hw_fcu_operation_params_t *params)
Erase flash block.
__STATIC_FORCEINLINE bool hw_fcu_is_flash_write_protection_enabled(void)
Check program flash write protection.
Definition: hw_fcu.h:473
__STATIC_FORCEINLINE bool hw_fcu_is_flash_erase_suspended(void)
Check if flash erase is suspended.
Definition: hw_fcu.h:243
__ALWAYS_RETAINED_CODE HW_FCU_ERROR hw_fcu_read(uint32_t address, uint32_t *dst, uint32_t len, struct hw_fcu_operation_params_t *params)
Read from flash address to buffer.
#define REG_MSK(base, reg, field)
Access register field mask.
Definition: sdk_defs.h:583
HW_GPIO_MODE mode
Definition: hw_gpio.h:211
__STATIC_FORCEINLINE void hw_fcu_clear_interrupt(void)
Clear FCU interrupt.
Definition: hw_fcu.h:378
__STATIC_FORCEINLINE bool hw_fcu_is_flash_read_mode_inhibited(void)
Check if program flash read mode is inhibited.
Definition: hw_fcu.h:483
__STATIC_FORCEINLINE void hw_fcu_permit_flash_operations(void)
Permit flash operations.
Definition: hw_fcu.h:219
__STATIC_FORCEINLINE void hw_fcu_enable_flash_write_protection(void)
Enable program flash write protection.
Definition: hw_fcu.h:463
__STATIC_FORCEINLINE void hw_fcu_set_flash_access_mode(HW_FCU_FLASH_ACCESS_MODE mode)
Set flash read or write/erase mode.
Definition: hw_fcu.h:535
__ALWAYS_RETAINED_CODE HW_FCU_ERROR hw_fcu_erase_page(uint32_t address, struct hw_fcu_operation_params_t *params)
Erase flash block's page.
void(* hw_fcu_operation_completed_cb)(void *user_data)
Callback called upon completion of erase or write (interrupt or DMA)
Definition: hw_fcu.h:149
__STATIC_FORCEINLINE uint8_t hw_fcu_get_flash_sleep_to_standby_time(void)
Get program flash sleep to standby wake-up time.
Definition: hw_fcu.h:692
__STATIC_FORCEINLINE HW_FCU_WAIT_CYCLES hw_fcu_get_wait_cycles(void)
Get wait cycles.
Definition: hw_fcu.h:390
__STATIC_FORCEINLINE bool hw_fcu_is_erase_suspend_enabled(void)
Check if erase/suspend functionality is enabled.
Definition: hw_fcu.h:296
HW_FCU_VDD_LEVEL_VALUE
FCU VDD level value.
Definition: hw_fcu.h:139
#define REG_GETF(base, reg, field)
Return the value of a register field.
Definition: sdk_defs.h:711
HW_FCU_WAIT_CYCLES
FCU wait cycles.
Definition: hw_fcu.h:124
__STATIC_FORCEINLINE void hw_fcu_disable_vdd_level_overriding(void)
Disable overriding of VDD level FCU input signal.
Definition: hw_fcu.h:203
__STATIC_FORCEINLINE void hw_fcu_set_wait_cycles(HW_FCU_WAIT_CYCLES wait_cycles)
Set wait cycles.
Definition: hw_fcu.h:411
HW_FCU_FLASH_PROG_MODE
FCU program flash mode.
Definition: hw_fcu.h:114
__STATIC_FORCEINLINE void hw_fcu_set_flash_page_segment_erase_time(uint32_t erase_time)
Set program flash page segment erase time for suspend erase.
Definition: hw_fcu.h:702
__ALWAYS_RETAINED_CODE void hw_fcu_sleep(void)
Set FCU to sleep mode.
__STATIC_FORCEINLINE bool hw_fcu_is_protected_against_actions(uint32_t mask)
Definition: hw_fcu.h:433
__STATIC_FORCEINLINE bool hw_fcu_is_erase_in_progress(void)
Check if flash erase is in progress.
Definition: hw_fcu.h:494
Operation parameters structure.
Definition: hw_fcu.h:154
__STATIC_FORCEINLINE void hw_fcu_enable_vdd_level_overriding(void)
Enable overriding of VDD level FCU input signal.
Definition: hw_fcu.h:195
__STATIC_FORCEINLINE void hw_fcu_disable_erase_suspend(void)
Disable erase/suspend functionality.
Definition: hw_fcu.h:286
__STATIC_FORCEINLINE void hw_fcu_disable_dma(void)
Disable DMA handshake when writing to the FCU.
Definition: hw_fcu.h:327
__STATIC_FORCEINLINE bool hw_fcu_is_flash_read_protection_enabled(void)
Check program flash read protection.
Definition: hw_fcu.h:453
__STATIC_FORCEINLINE bool hw_fcu_is_write_in_progress(void)
Check if flash write is in progress.
Definition: hw_fcu.h:523
__STATIC_FORCEINLINE void hw_fcu_set_flash_program_time(uint16_t prog_time)
Set program flash programming time.
Definition: hw_fcu.h:614
void * user_data
Definition: hw_fcu.h:156
__STATIC_FORCEINLINE void hw_fcu_enable_dma(void)
Enable DMA handshake when writing to the FCU.
Definition: hw_fcu.h:317
__STATIC_FORCEINLINE bool hw_fcu_are_flash_operations_prohibited(void)
Check if flash operations are prohibited.
Definition: hw_fcu.h:229
__STATIC_FORCEINLINE uint16_t hw_fcu_get_flash_program_time(void)
Get program flash programming time.
Definition: hw_fcu.h:625
__STATIC_FORCEINLINE bool hw_fcu_is_dma_enabled(void)
Check if DMA handshake when writing to the FCU is enabled.
Definition: hw_fcu.h:337
__STATIC_FORCEINLINE void hw_fcu_set_flash_programming_mode(HW_FCU_FLASH_PROG_MODE mode)
Set program flash mode.
Definition: hw_fcu.h:559
__STATIC_FORCEINLINE void hw_fcu_set_flash_mass_erase_time(uint32_t erase_time)
Set program flash mass erase time.
Definition: hw_fcu.h:659
__STATIC_FORCEINLINE HW_FCU_ERASE_SUSPEND_MODE hw_fcu_get_erase_suspend_mode(void)
Get erase/suspend mode.
Definition: hw_fcu.h:267
HW_FCU_ERASE_SUSPEND_MODE
FCU erase/suspend modes.
Definition: hw_fcu.h:94
HW_FCU_ERROR
FCU error codes.
Definition: hw_fcu.h:82
hw_fcu_operation_completed_cb cb
Definition: hw_fcu.h:155