#ifndef NRF_PWR_MGMT_ENABLED
#define NRF_PWR_MGMT_ENABLED 1
#endif
#ifndef APP_SHUTDOWN_HANDLER_PRIORITY
#define APP_SHUTDOWN_HANDLER_PRIORITY 1
#endif
#ifdef NRF_PWR_MGMT_ENABLED
#ifndef NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED
#define NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED 0
#endif
#ifndef NRF_PWR_MGMT_SLEEP_DEBUG_PIN
#define NRF_PWR_MGMT_SLEEP_DEBUG_PIN 31
#endif
#ifndef NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED
#define NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED 1
#endif
#ifndef NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED
#define NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED 1
#endif
#ifndef NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S
#define NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S 3
#endif
#ifndef NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED
#define NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED 1
#endif
#ifndef NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY
#define NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY 0
#endif
#ifndef NRF_PWR_MGMT_CONFIG_USE_SCHEDULER
#define NRF_PWR_MGMT_CONFIG_USE_SCHEDULER 0
#endif
#ifndef NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT
#define NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT 3
#endif
#endif
void task(void *p_context)
{
printf("\n\r");
NRF_LOG_INFO("Task");
while(true)
{
// NRF_LOG_INFO("Reset");
task_yield();
// spi_send("ABCDEFG HIJKLMN",15);
nrf_pwr_mgmt_run();
#ifndef S140
// uart_send("ble go",6);
#endif
// NRF_LOG_INFO("MAIN Task");
}
}
void pwr_mgmt_init()
{
ret_code_t err_code;
err_code = nrf_pwr_mgmt_init();
APP_ERROR_CHECK(err_code);
}
static bool shutdown_handler(nrf_pwr_mgmt_evt_t event)
{
ret_code_t err_code;
switch(event)
{
case NRF_PWR_MGMT_EVT_PREPARE_WAKEUP :
nrf_gpio_cfg_sense_set(12, NRF_GPIO_PIN_SENSE_LOW);
NRF_LOG_INFO( " Power management Evt : NRF_PWR_MGMT_EVT_PREPARE_WAKEUP" );
break;
case NRF_PWR_MGMT_EVT_PREPARE_SYSOFF :
NRF_LOG_INFO( " Power management Evt : NRF_PWR_MGMT_EVT_PREPARE_SYSOFF" );
break;
case NRF_PWR_MGMT_EVT_PREPARE_DFU :
NRF_LOG_INFO( " Power management Evt : NRF_PWR_MGMT_EVT_PREPARE_DFU" );
break;
case NRF_PWR_MGMT_EVT_PREPARE_RESET :
NRF_LOG_INFO( " Power management Evt : NRF_PWR_MGMT_EVT_PREPARE_RESET" );
break;
}
printf("\n\r");
err_code = app_timer_stop_all();
APP_ERROR_CHECK(err_code);
return true;
}
NRF_PWR_MGMT_HANDLER_REGISTER(shutdown_handler, APP_SHUTDOWN_HANDLER_PRIORITY);
void main(void)
{
int i;
ret_code_t err;
log_init();
clock_init();
timer_init();
flash_init();
list_init();
main_init();
tcp_init();
spi_init();
uart_init();
pwr_mgmt_init();
ble_init();
led_init();
err = app_timer_start( m_timer, MAIN_TIMER_CYCLE, NULL );
APP_ERROR_CHECK(err);
// uart_send("ble go",6);
printf("\n\r");
do {
if (NRF_LOG_PROCESS() == false)
{
// nrf_pwr_mgmt_run();
// NRF_LOG_INFO("PWR MGMT RUN");
}
task_manager_start(task, NULL);
} while (1);
}