Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds support for nrf5340-DK board (application and networking core) #302

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -108,21 +108,28 @@ BIN = _bin/$(BOARD)
# Board specific
-include src/boards/$(BOARD)/board.mk

CFLAGS += -DNRF_REGULATORS_HAS_POFCON=0
CFLAGS += -DNRF_REGULATORS_HAS_POFCON_VDDH=0
CFLAGS += -DNRF_REGULATORS_HAS_DCDCEN_VDDH=0

# MCU_SUB_VARIANT can be nrf52 (nrf52832), nrf52833, nrf52840
ifeq ($(MCU_SUB_VARIANT),nrf52)
SD_NAME = s132
DFU_DEV_REV = 0xADAF
CFLAGS += -DNRF52 -DNRF52832_XXAA -DS132
CFLAGS += -DIS_NRF52840=0 -DIS_NRF52832=1 -DIS_NRF52833=0 -DIS_NRF52805=0 -DIS_NRF52810=0 -DIS_NRF52811=0 -DIS_NRF52820=0
DFU_APP_DATA_RESERVED=7*4096
else ifeq ($(MCU_SUB_VARIANT),nrf52833)
SD_NAME = s140
DFU_DEV_REV = 52833
CFLAGS += -DNRF52833_XXAA -DS140
CFLAGS += -DIS_NRF52840=0 -DIS_NRF52832=0 -DIS_NRF52833=1 -DIS_NRF52805=0 -DIS_NRF52810=0 -DIS_NRF52811=0 -DIS_NRF52820=0
DFU_APP_DATA_RESERVED=7*4096
else ifeq ($(MCU_SUB_VARIANT),nrf52840)
SD_NAME = s140
DFU_DEV_REV = 52840
CFLAGS += -DNRF52840_XXAA -DS140
CFLAGS += -DIS_NRF52840=1 -DIS_NRF52832=0 -DIS_NRF52833=0 -DIS_NRF52805=0 -DIS_NRF52810=0 -DIS_NRF52811=0 -DIS_NRF52820=0
DFU_APP_DATA_RESERVED=10*4096
else
$(error Sub Variant $(MCU_SUB_VARIANT) is unknown)
Expand Down
2 changes: 1 addition & 1 deletion lib/nrfx
Submodule nrfx updated 608 files
55 changes: 30 additions & 25 deletions lib/sdk/components/libraries/timer/app_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,6 @@ STATIC_ASSERT(RTC1_IRQ_PRI == SWI_IRQ_PRI);

#define MAX_RTC_TASKS_DELAY 47 /**< Maximum delay until an RTC task is executed. */

#if (APP_TIMER_CONFIG_SWI_NUMBER == 0)
#define SWI_IRQn SWI0_IRQn
#define SWI_IRQHandler SWI0_IRQHandler
#elif (APP_TIMER_CONFIG_SWI_NUMBER == 1)
#define SWI_IRQn SWI1_IRQn
#define SWI_IRQHandler SWI1_IRQHandler
#else
#error "Unsupported SWI number."
#endif

#define MODULE_INITIALIZED (m_op_queue.size != 0) /**< Macro designating whether the module has been initialized properly. */

/**@brief Timer node type. The nodes will be used form a linked list of running timers. */
Expand Down Expand Up @@ -151,6 +141,10 @@ static bool m_rtc1_reset;
static uint8_t m_max_user_op_queue_utilization; /**< Maximum observed timer user operations queue utilization. */
#endif

/**@brief Function for handling changes to the timer list.
*/
static void timer_list_handler(void);

/**@brief Function for initializing the RTC1 counter.
*
* @param[in] prescaler Value of the RTC1 PRESCALER register. Set to 0 for no prescaling.
Expand Down Expand Up @@ -198,6 +192,25 @@ static void rtc1_stop(void)
m_rtc1_running = false;
}

/**@brief Function suspends RTC1 timer.
*/
static void rtc1_suspend(void)
{
if(m_rtc1_running == true)
{
NRF_RTC1->TASKS_STOP = 1;
}
}

/**@brief Function resumes RTC1 timer.
*/
static void rtc1_resume(void)
{
if(m_rtc1_running == true)
{
NRF_RTC1->TASKS_START = 1;
}
}

/**@brief Function for returning the current value of the RTC1 counter.
*
Expand Down Expand Up @@ -352,14 +365,6 @@ static void timer_timeouts_check_sched(void)
NVIC_SetPendingIRQ(RTC1_IRQn);
}


/**@brief Function for scheduling a timer list update by generating a SWI interrupt.
*/
static void timer_list_handler_sched(void)
{
NVIC_SetPendingIRQ(SWI_IRQn);
}

#if APP_TIMER_CONFIG_USE_SCHEDULER
static void timeout_handler_scheduled_exec(void * p_event_data, uint16_t event_size)
{
Expand Down Expand Up @@ -455,7 +460,7 @@ static void timer_timeouts_check(void)
// Queue the ticks expired.
m_ticks_elapsed[m_ticks_elapsed_q_write_ind] = ticks_expired;

timer_list_handler_sched();
timer_list_handler();
}
}

Expand Down Expand Up @@ -727,6 +732,8 @@ static void timer_list_handler(void)
bool compare_update = false;
timer_node_t * p_timer_id_head_old;

rtc1_suspend();

#if APP_TIMER_WITH_PROFILER
{
uint8_t size = m_op_queue.size;
Expand Down Expand Up @@ -768,6 +775,8 @@ static void timer_list_handler(void)
compare_reg_update(p_timer_id_head_old);
}
m_rtc1_reset = false;

rtc1_resume();
}


Expand Down Expand Up @@ -850,7 +859,7 @@ static uint32_t timer_start_op_schedule(timer_node_t * p_node,

if (err_code == NRF_SUCCESS)
{
timer_list_handler_sched();
timer_list_handler();
}

return err_code;
Expand Down Expand Up @@ -888,7 +897,7 @@ static uint32_t timer_stop_op_schedule(timer_node_t * p_node,

if (err_code == NRF_SUCCESS)
{
timer_list_handler_sched();
timer_list_handler();
}

return err_code;
Expand Down Expand Up @@ -941,10 +950,6 @@ ret_code_t app_timer_init(void)
m_max_user_op_queue_utilization = 0;
#endif

NVIC_ClearPendingIRQ(SWI_IRQn);
NVIC_SetPriority(SWI_IRQn, SWI_IRQ_PRI);
NVIC_EnableIRQ(SWI_IRQn);

rtc1_init(APP_TIMER_CONFIG_RTC_FREQUENCY);

m_ticks_latest = rtc1_counter_get();
Expand Down
10 changes: 10 additions & 0 deletions lib/sdk/components/libraries/util/app_util_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@ extern "C" {
#define _PRIO_APP_LOW 6
#define _PRIO_APP_LOWEST 7
#define _PRIO_THREAD 15
#elif __CORTEX_M == (33U)
#define _PRIO_SD_HIGH 0
#define _PRIO_SD_MID 1
#define _PRIO_APP_HIGH 2
#define _PRIO_APP_MID 3
#define _PRIO_SD_LOW 4
#define _PRIO_SD_LOWEST 5
#define _PRIO_APP_LOW 6
#define _PRIO_APP_LOWEST 7
#define _PRIO_THREAD 15
#else
#error "No platform defined"
#endif
Expand Down
4 changes: 4 additions & 0 deletions lib/sdk11/components/drivers_nrf/pstorage/pstorage_raw.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@
#define SOC_MAX_WRITE_SIZE 1024 /**< Maximum write size allowed for a single call to \ref sd_flash_write as specified in the SoC API on the nRF51. */
#elif defined(NRF52_SERIES)
#define SOC_MAX_WRITE_SIZE 4096 /**< Maximum write size allowed for a single call to \ref sd_flash_write as specified in the SoC API on the nRF52. */
#elif defined(NRF5340_XXAA_APPLICATION)
#define SOC_MAX_WRITE_SIZE 4096 /**< Maximum write size allowed for a single call to \ref sd_flash_write as specified in the SoC API on the nRF53. */
#elif defined(NRF5340_XXAA_NETWORK)
#define SOC_MAX_WRITE_SIZE 2048 /**< Maximum write size allowed for a single call to \ref sd_flash_write as specified in the SoC API on the nRF53. */
#else
#error No target defined
#endif
Expand Down
6 changes: 5 additions & 1 deletion lib/sdk11/components/libraries/bootloader_dfu/bootloader.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,12 @@ void bootloader_app_start(void)
{
PRINTF("SoftDevice not exist\r\n");

// App starts right after MBR
// App starts right after MBR (except for networking core)
#if !defined(NRF5340_XXAA_NETWORK)
app_addr = MBR_SIZE;
#else
app_addr = APP_START_ADDRESS;
#endif
sd_mbr_command_t command =
{
.command = SD_MBR_COMMAND_IRQ_FORWARD_ADDRESS_SET,
Expand Down
13 changes: 12 additions & 1 deletion lib/sdk11/components/libraries/bootloader_dfu/dfu_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,18 @@ static inline bool is_sd_existed(void)
#endif
#define BOOTLOADER_MBR_PARAMS_PAGE_ADDRESS 0x000FE000 /**< The field specifies the page location of the mbr params page address. */
#define BOOTLOADER_SETTINGS_ADDRESS 0x000FF000 /**< The field specifies the page location of the bootloader settings address. */

#elif defined(NRF5340_XXAA_APPLICATION)
#ifndef BOOTLOADER_REGION_START
#define BOOTLOADER_REGION_START 0x000EE000
#endif
#define BOOTLOADER_MBR_PARAMS_PAGE_ADDRESS 0x000FE000
#define BOOTLOADER_SETTINGS_ADDRESS 0x000FF000
#elif defined(NRF5340_XXAA_NETWORK)
#ifndef BOOTLOADER_REGION_START
#define BOOTLOADER_REGION_START 0x01000000
#endif
#define BOOTLOADER_MBR_PARAMS_PAGE_ADDRESS 0x0103F000
#define BOOTLOADER_SETTINGS_ADDRESS 0x0103F800
#else
#error No target defined
#endif
Expand Down
Loading