nrfx power

This commit is contained in:
hathach 2018-08-07 13:33:44 +07:00
parent 2847b319f2
commit c1c43b3c83
3 changed files with 13 additions and 20 deletions

View File

@ -113,6 +113,10 @@ endif
C_SOURCE_FILES += $(SRC_PATH)/main.c C_SOURCE_FILES += $(SRC_PATH)/main.c
C_SOURCE_FILES += $(SRC_PATH)/dfu_ble_svc.c C_SOURCE_FILES += $(SRC_PATH)/dfu_ble_svc.c
# nrfx
C_SOURCE_FILES += $(NRFX_PATH)/drivers/src/nrfx_power.c
# SDK 11 files # SDK 11 files
C_SOURCE_FILES += $(SDK11_PATH)/libraries/bootloader_dfu/bootloader.c C_SOURCE_FILES += $(SDK11_PATH)/libraries/bootloader_dfu/bootloader.c
C_SOURCE_FILES += $(SDK11_PATH)/libraries/bootloader_dfu/bootloader_settings.c C_SOURCE_FILES += $(SDK11_PATH)/libraries/bootloader_dfu/bootloader_settings.c
@ -189,15 +193,16 @@ endif
#****************************************************************************** #******************************************************************************
# src # src
IPATH += $(SRC_PATH)/ IPATH += $(SRC_PATH)
IPATH += $(SRC_PATH)/cmsis/include IPATH += $(SRC_PATH)/cmsis/include
IPATH += $(SRC_PATH)/usb IPATH += $(SRC_PATH)/usb
IPATH += $(TUSB_PATH)/ IPATH += $(TUSB_PATH)
# nrfx # nrfx
IPATH += $(NRFX_PATH) IPATH += $(NRFX_PATH)
IPATH += $(NRFX_PATH)/mdk IPATH += $(NRFX_PATH)/mdk
IPATH += $(NRFX_PATH)/hal IPATH += $(NRFX_PATH)/hal
IPATH += $(NRFX_PATH)/drivers/include
IPATH += $(SDK11_PATH)/libraries/bootloader_dfu/hci_transport IPATH += $(SDK11_PATH)/libraries/bootloader_dfu/hci_transport
IPATH += $(SDK11_PATH)/libraries/bootloader_dfu IPATH += $(SDK11_PATH)/libraries/bootloader_dfu
@ -221,8 +226,6 @@ IPATH += $(SDK_PATH)/libraries/hci
IPATH += $(SDK_PATH)/drivers_nrf/delay IPATH += $(SDK_PATH)/drivers_nrf/delay
#IPATH += $(SDK_PATH)/drivers_nrf/uart #IPATH += $(SDK_PATH)/drivers_nrf/uart
#IPATH += $(SDK_PATH)/drivers_nrf/power #IPATH += $(SDK_PATH)/drivers_nrf/power
#IPATH += $(SDK_PATH)/drivers_nrf/usbd
#IPATH += $(SDK_PATH)/device
# Softdevice # Softdevice
IPATH += $(SD_PATH)/headers IPATH += $(SD_PATH)/headers

View File

@ -31,6 +31,8 @@
#include <stdbool.h> #include <stdbool.h>
#include <string.h> #include <string.h>
#include <stddef.h> #include <stddef.h>
#include "nrfx.h"
#include "nrfx_power.h"
#include "nordic_common.h" #include "nordic_common.h"
#include "sdk_common.h" #include "sdk_common.h"
@ -38,6 +40,7 @@
#include "bootloader.h" #include "bootloader.h"
#include "bootloader_util.h" #include "bootloader_util.h"
#include "nrf.h" #include "nrf.h"
#include "nrf_soc.h" #include "nrf_soc.h"
#include "nrf_nvic.h" #include "nrf_nvic.h"
@ -69,13 +72,6 @@ void usb_teardown(void);
* We must call it within SD's SOC event handler, or set it as power event handler if SD is not enabled. */ * We must call it within SD's SOC event handler, or set it as power event handler if SD is not enabled. */
extern void tusb_hal_nrf_power_event(uint32_t event); extern void tusb_hal_nrf_power_event(uint32_t event);
// TODO fully move to nrfx
enum {
NRFX_POWER_USB_EVT_DETECTED, /**< USB power detected on the connector (plugged in). */
NRFX_POWER_USB_EVT_REMOVED, /**< USB power removed from the connector. */
NRFX_POWER_USB_EVT_READY /**< USB power regulator ready. */
};
#else #else
#define usb_init() #define usb_init()

View File

@ -34,6 +34,9 @@
*/ */
/**************************************************************************/ /**************************************************************************/
#include "nrfx.h"
#include "nrfx_power.h"
#ifdef SOFTDEVICE_PRESENT #ifdef SOFTDEVICE_PRESENT
#include "nrf_sdm.h" #include "nrf_sdm.h"
#include "nrf_soc.h" #include "nrf_soc.h"
@ -42,13 +45,6 @@
#include "nrf_usbd.h" #include "nrf_usbd.h"
#include "tusb.h" #include "tusb.h"
// TODO fully move to nrfx
enum {
NRFX_POWER_USB_EVT_DETECTED, /**< USB power detected on the connector (plugged in). */
NRFX_POWER_USB_EVT_REMOVED, /**< USB power removed from the connector. */
NRFX_POWER_USB_EVT_READY /**< USB power regulator ready. */
};
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// MACRO TYPEDEF CONSTANT ENUM DECLARATION // MACRO TYPEDEF CONSTANT ENUM DECLARATION
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
@ -78,7 +74,6 @@ void usb_init(void)
}else }else
#endif #endif
{ {
#if 0 // TODO enable
// Power module init // Power module init
const nrfx_power_config_t pwr_cfg = { 0 }; const nrfx_power_config_t pwr_cfg = { 0 };
nrfx_power_init(&pwr_cfg); nrfx_power_init(&pwr_cfg);
@ -90,7 +85,6 @@ void usb_init(void)
nrfx_power_usbevt_enable(); nrfx_power_usbevt_enable();
usb_reg = NRF_POWER->USBREGSTATUS; usb_reg = NRF_POWER->USBREGSTATUS;
#endif
} }
if ( usb_reg & POWER_USBREGSTATUS_VBUSDETECT_Msk ) { if ( usb_reg & POWER_USBREGSTATUS_VBUSDETECT_Msk ) {