Skip to content

Commit 118d966

Browse files
kl-cruzadbridge
authored andcommitted
nRF52840: Added checking if sd is enabled in flashapi
1 parent e9c59b3 commit 118d966

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

targets/TARGET_NORDIC/TARGET_NRF5_SDK13/flash_api.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,27 @@
3838

3939
#include "flash_api.h"
4040
#include "nrf_nvmc.h"
41+
#include "nrf_soc.h"
42+
#include "nrf_sdm.h"
4143

4244
#if DEVICE_FLASH
4345

46+
/*
47+
uint8_t sd_enabled;
48+
if ((sd_softdevice_is_enabled(&sd_enabled) == NRF_SUCCESS) && sd_enabled == 1)
49+
{
50+
return -1;
51+
}
52+
*/
53+
4454
int32_t flash_init(flash_t *obj)
4555
{
4656
(void)(obj);
57+
uint8_t sd_enabled;
58+
if ((sd_softdevice_is_enabled(&sd_enabled) == NRF_SUCCESS) && sd_enabled == 1)
59+
{
60+
return -1;
61+
}
4762
return 0;
4863
}
4964

@@ -56,12 +71,22 @@ int32_t flash_free(flash_t *obj)
5671
int32_t flash_erase_sector(flash_t *obj, uint32_t address)
5772
{
5873
(void)(obj);
74+
uint8_t sd_enabled;
75+
if ((sd_softdevice_is_enabled(&sd_enabled) == NRF_SUCCESS) && sd_enabled == 1)
76+
{
77+
return -1;
78+
}
5979
nrf_nvmc_page_erase(address);
6080
return 0;
6181
}
6282

6383
int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data, uint32_t size)
6484
{
85+
uint8_t sd_enabled;
86+
if ((sd_softdevice_is_enabled(&sd_enabled) == NRF_SUCCESS) && sd_enabled == 1)
87+
{
88+
return -1;
89+
}
6590
/* We will use *_words function to speed up flashing code. Word means 32bit -> 4B
6691
* or sizeof(uint32_t). */
6792
nrf_nvmc_write_words(address, data, (size / sizeof(uint32_t)));

0 commit comments

Comments
 (0)