forked from RfidResearchGroup/ChameleonUltra
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
323 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include "nrf_drv_wdt.h" | ||
#include "hw_connect.h" | ||
#include "nrf_gpio.h" | ||
|
||
static nrf_drv_wdt_channel_id m_channel_id; | ||
|
||
static void wdt_event_handler(void) | ||
{ | ||
//NOTE: The max amount of time we can spend in WDT interrupt is two cycles of 32768[Hz] clock - after that, reset occurs | ||
uint32_t* p_led_array = hw_get_led_array(); | ||
for (uint8_t i = 0; i < RGB_LIST_NUM; i++) { | ||
nrf_gpio_pin_clear(p_led_array[i]); | ||
} | ||
} | ||
|
||
void bsp_wdt_init(void) { | ||
ret_code_t err_code; | ||
// err_code = nrf_drv_clock_init(); // already done by usb_cdc_init() -> app_usbd_init() | ||
// APP_ERROR_CHECK(err_code); | ||
nrf_drv_wdt_config_t config = NRF_DRV_WDT_DEAFULT_CONFIG; // typo is in the SDK... | ||
err_code = nrf_drv_wdt_init(&config, wdt_event_handler); | ||
APP_ERROR_CHECK(err_code); | ||
err_code = nrf_drv_wdt_channel_alloc(&m_channel_id); | ||
APP_ERROR_CHECK(err_code); | ||
nrf_drv_wdt_enable(); | ||
} | ||
|
||
void bsp_wdt_feed(void) { | ||
nrf_drv_wdt_channel_feed(m_channel_id); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#ifndef __BSP_WDT_H__ | ||
#define __BSP_WDT_H__ | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
void bsp_wdt_init(void); | ||
void bsp_wdt_feed(void); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif // __BSP_WDT_H__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include "app_timer.h" | ||
#include "delayed_reset.h" | ||
|
||
#include "nrf_log.h" | ||
#include "nrf_log_ctrl.h" | ||
#include "nrf_log_default_backends.h" | ||
|
||
APP_TIMER_DEF(m_reset_timer); | ||
|
||
static void delayed_reset_event_handler(void* ctx) { | ||
while (NRF_LOG_PROCESS()); | ||
ret_code_t ret = sd_nvic_SystemReset(); | ||
APP_ERROR_CHECK(ret); | ||
while (1) { | ||
__NOP(); | ||
} | ||
} | ||
|
||
void delayed_reset(uint32_t delay) { | ||
NRF_LOG_INFO("Resetting in %d ms...", delay); | ||
ret_code_t ret; | ||
ret = app_timer_create(&m_reset_timer, APP_TIMER_MODE_SINGLE_SHOT, delayed_reset_event_handler); | ||
APP_ERROR_CHECK(ret); | ||
ret = app_timer_start(m_reset_timer, APP_TIMER_TICKS(delay), NULL); | ||
APP_ERROR_CHECK(ret); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#pragma once | ||
|
||
void delayed_reset(uint32_t delay); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.