File tree Expand file tree Collapse file tree 3 files changed +107
-279
lines changed
source/hic_hal/nordic/nrf52820 Expand file tree Collapse file tree 3 files changed +107
-279
lines changed Original file line number Diff line number Diff line change 20
20
*/
21
21
22
22
#include "target_config.h"
23
-
24
23
#include "nrf_nvmc.h"
25
24
26
25
uint32_t Init (uint32_t adr , uint32_t clk , uint32_t fnc )
@@ -40,12 +39,26 @@ uint32_t EraseChip(void)
40
39
41
40
uint32_t EraseSector (uint32_t adr )
42
41
{
43
- nrf_nvmc_page_erase (adr );
42
+ nrf_nvmc_mode_set (NRF_NVMC , NRF_NVMC_MODE_ERASE );
43
+ nrf_nvmc_page_erase_start (NRF_NVMC , adr );
44
+ while (!nrf_nvmc_ready_check (NRF_NVMC )) {
45
+ // Wait for controller to be ready
46
+ }
47
+ nrf_nvmc_mode_set (NRF_NVMC , NRF_NVMC_MODE_READONLY );
48
+
44
49
return 0 ;
45
50
}
46
51
47
52
uint32_t ProgramPage (uint32_t adr , uint32_t sz , uint32_t * buf )
48
53
{
49
- nrf_nvmc_write_words (adr , buf , sz / 4 );
54
+ nrf_nvmc_mode_set (NRF_NVMC , NRF_NVMC_MODE_WRITE );
55
+ for (uint32_t i = 0 ; i < sz / 4 ; i ++ ) {
56
+ ((volatile uint32_t * )adr )[i ] = buf [i ];
57
+ while (!nrf_nvmc_ready_check (NRF_NVMC )) {
58
+ // Wait for controller to be ready
59
+ }
60
+ }
61
+ nrf_nvmc_mode_set (NRF_NVMC , NRF_NVMC_MODE_READONLY );
62
+
50
63
return 0 ;
51
64
}
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments