major refactoring/simplifying
This commit is contained in:
@@ -11,8 +11,14 @@ $(OUTPUT_DIRECTORY)/nrf52840_xxaa.out: \
|
||||
# Source files common to all targets
|
||||
SRC_FILES += \
|
||||
$(SDK_ROOT)/modules/nrfx/mdk/gcc_startup_nrf52840.S \
|
||||
$(PROJ_DIR)/main.c \
|
||||
$(PROJ_DIR)/../main.c \
|
||||
$(PROJ_DIR)/usb.c \
|
||||
$(PROJ_DIR)/retarget.c \
|
||||
$(PROJ_DIR)/device.c \
|
||||
$(PROJ_DIR)/../util.c \
|
||||
$(PROJ_DIR)/../log.c \
|
||||
$(PROJ_DIR)/../stubs.c \
|
||||
$(PROJ_DIR)/../ctaphid.c \
|
||||
$(SDK_ROOT)/components/boards/boards.c \
|
||||
$(SDK_ROOT)/components/libraries/util/app_error.c \
|
||||
$(SDK_ROOT)/components/libraries/util/app_error_handler_gcc.c \
|
||||
@@ -82,6 +88,8 @@ INC_FOLDERS += \
|
||||
$(SDK_ROOT)/modules/nrfx \
|
||||
$(SDK_ROOT)/external/segger_rtt \
|
||||
$(PROJ_DIR) \
|
||||
$(PROJ_DIR)/.. \
|
||||
$(PROJ_DIR)/../tinycbor/src \
|
||||
$(SDK_ROOT)/components/libraries/util \
|
||||
$(SDK_ROOT)/integration/nrfx/legacy \
|
||||
$(SDK_ROOT)/modules/nrfx/drivers/include \
|
||||
@@ -138,13 +146,16 @@ OPT = -O3 -g3
|
||||
# C flags common to all targets
|
||||
CFLAGS += $(OPT)
|
||||
CFLAGS += -DBOARD_PCA10056
|
||||
CFLAGS += -DNRF52
|
||||
#CFLAGS += -DBSP_DEFINES_ONLY
|
||||
CFLAGS += -DCONFIG_GPIO_AS_PINRESET
|
||||
CFLAGS += -DFLOAT_ABI_HARD
|
||||
CFLAGS += -DNRF52840_XXAA
|
||||
#CFLAGS += -DSTUB_CTAPHID
|
||||
CFLAGS += -DSTUB_CTAP
|
||||
CFLAGS += -mcpu=cortex-m4
|
||||
CFLAGS += -mthumb -mabi=aapcs
|
||||
CFLAGS += -Wall
|
||||
CFLAGS += -Wall -Wno-format
|
||||
CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
|
||||
# keep every function in a separate section, this allows linker to discard unused ones
|
||||
CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing
|
||||
|
@@ -37,6 +37,9 @@
|
||||
|
||||
#ifndef SEGGER_RTT_CONFIG_DEFAULT_MODE
|
||||
#define SEGGER_RTT_CONFIG_DEFAULT_MODE 2
|
||||
|
||||
#define APP_FIFO_ENABLED 1
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
259
nrf52840/device.c
Normal file
259
nrf52840/device.c
Normal file
@@ -0,0 +1,259 @@
|
||||
/*
|
||||
* Device specific functionality here
|
||||
* */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "nrf.h"
|
||||
#include "nrf_error.h"
|
||||
#include "nrf_drv_power.h"
|
||||
#include "nrf_strerror.h"
|
||||
#include "nrf_drv_rtc.h"
|
||||
#include "nrf_drv_clock.h"
|
||||
#include "nrf_drv_usbd.h"
|
||||
#include "nrf_gpio.h"
|
||||
#include "bsp.h"
|
||||
|
||||
#include "app_error.h"
|
||||
#include "app_fifo.h"
|
||||
|
||||
#include "util.h"
|
||||
#include "usb.h"
|
||||
#include "device.h"
|
||||
#include "cbor.h"
|
||||
#include "log.h"
|
||||
|
||||
|
||||
|
||||
extern int _SEGGER_TERM;
|
||||
|
||||
|
||||
void set_output_terminal(uint32_t term)
|
||||
{
|
||||
_SEGGER_TERM = term;
|
||||
}
|
||||
|
||||
void app_error_fault_handler(uint32_t id, uint32_t pc, uint32_t info)
|
||||
{
|
||||
error_info_t * e = (error_info_t *)info;
|
||||
printf("Error: %d: %s at %d:%s\n",e->err_code, nrf_strerror_get(e->err_code), e->line_num, e->p_file_name);
|
||||
while(1)
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
void log_resetreason(void)
|
||||
{
|
||||
/* Reset reason */
|
||||
uint32_t rr = nrf_power_resetreas_get();
|
||||
printf("Reset reasons:\n");
|
||||
if (0 == rr)
|
||||
{
|
||||
printf("- NONE\n");
|
||||
}
|
||||
if (0 != (rr & NRF_POWER_RESETREAS_RESETPIN_MASK))
|
||||
{
|
||||
printf("- RESETPIN\n");
|
||||
}
|
||||
if (0 != (rr & NRF_POWER_RESETREAS_DOG_MASK ))
|
||||
{
|
||||
printf("- DOG\n");
|
||||
}
|
||||
if (0 != (rr & NRF_POWER_RESETREAS_SREQ_MASK ))
|
||||
{
|
||||
printf("- SREQ\n");
|
||||
}
|
||||
if (0 != (rr & NRF_POWER_RESETREAS_LOCKUP_MASK ))
|
||||
{
|
||||
printf("- LOCKUP\n");
|
||||
}
|
||||
if (0 != (rr & NRF_POWER_RESETREAS_OFF_MASK ))
|
||||
{
|
||||
printf("- OFF\n");
|
||||
}
|
||||
if (0 != (rr & NRF_POWER_RESETREAS_LPCOMP_MASK ))
|
||||
{
|
||||
printf("- LPCOMP\n");
|
||||
}
|
||||
if (0 != (rr & NRF_POWER_RESETREAS_DIF_MASK ))
|
||||
{
|
||||
printf("- DIF\n");
|
||||
}
|
||||
if (0 != (rr & NRF_POWER_RESETREAS_NFC_MASK ))
|
||||
{
|
||||
printf("- NFC\n");
|
||||
}
|
||||
if (0 != (rr & NRF_POWER_RESETREAS_VBUS_MASK ))
|
||||
{
|
||||
printf("- VBUS\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static const nrf_drv_rtc_t rtc = NRF_DRV_RTC_INSTANCE(0); /**< Declaring an instance of nrf_drv_rtc for RTC0. */
|
||||
uint64_t millis()
|
||||
{
|
||||
return (uint64_t)nrf_drv_rtc_counter_get(&rtc);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void rtc_config(void)
|
||||
{
|
||||
uint32_t err_code;
|
||||
|
||||
//Initialize RTC instance
|
||||
nrf_drv_rtc_config_t config = NRF_DRV_RTC_DEFAULT_CONFIG;
|
||||
config.prescaler = 32;
|
||||
err_code = nrf_drv_rtc_init(&rtc, &config, NULL);
|
||||
APP_ERROR_CHECK(err_code);
|
||||
|
||||
//Power on RTC instance
|
||||
nrf_drv_rtc_enable(&rtc);
|
||||
}
|
||||
|
||||
static void init_power_clock(void)
|
||||
{
|
||||
ret_code_t ret;
|
||||
/* Initializing power and clock */
|
||||
ret = nrf_drv_clock_init();
|
||||
APP_ERROR_CHECK(ret);
|
||||
ret = nrf_drv_power_init(NULL);
|
||||
APP_ERROR_CHECK(ret);
|
||||
nrf_drv_clock_hfclk_request(NULL);
|
||||
nrf_drv_clock_lfclk_request(NULL);
|
||||
while (!(nrf_drv_clock_hfclk_is_running() &&
|
||||
nrf_drv_clock_lfclk_is_running()))
|
||||
{
|
||||
/* Just waiting */
|
||||
}
|
||||
}
|
||||
|
||||
void device_init()
|
||||
{
|
||||
if ((nrf_power_resetreas_get() & NRF_POWER_RESETREAS_RESETPIN_MASK) == 0)
|
||||
{
|
||||
// Hard reset. this is for engineering A sample to work for USB ...
|
||||
nrf_power_resetreas_clear(nrf_power_resetreas_get());
|
||||
nrf_gpio_cfg_output(NRF_GPIO_PIN_MAP(0,31));
|
||||
nrf_gpio_pin_clear(NRF_GPIO_PIN_MAP(0,31));
|
||||
while (1)
|
||||
;
|
||||
}
|
||||
nrf_power_resetreas_clear(nrf_power_resetreas_get());
|
||||
|
||||
set_output_terminal(0);
|
||||
init_power_clock();
|
||||
rtc_config();
|
||||
usbhid_init();
|
||||
|
||||
srand(millis());
|
||||
|
||||
nrf_gpio_cfg_output(LED_1);
|
||||
nrf_gpio_cfg_output(LED_2);
|
||||
nrf_gpio_cfg_output(LED_3);
|
||||
nrf_gpio_cfg_output(LED_4);
|
||||
|
||||
nrf_gpio_pin_toggle(LED_2);
|
||||
nrf_gpio_pin_toggle(LED_3);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static uint8_t fifo_buf[1024];
|
||||
app_fifo_t USBHID_RECV_FIFO;
|
||||
|
||||
void usbhid_init()
|
||||
{
|
||||
app_fifo_init(&USBHID_RECV_FIFO, fifo_buf, sizeof(fifo_buf));
|
||||
usb_init();
|
||||
}
|
||||
|
||||
// Receive 64 byte USB HID message, don't block, return size of packet, return 0 if nothing
|
||||
int usbhid_recv(uint8_t * msg)
|
||||
{
|
||||
uint32_t size = 64;
|
||||
app_fifo_read(&USBHID_RECV_FIFO, msg, &size);
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
// Send 64 byte USB HID message
|
||||
void usbhid_send(uint8_t * msg)
|
||||
{
|
||||
static nrf_drv_usbd_transfer_t transfer;
|
||||
transfer.p_data.tx = msg;
|
||||
transfer.size = 64;
|
||||
|
||||
nrf_drv_usbd_ep_transfer(
|
||||
NRF_DRV_USBD_EPIN1,
|
||||
&transfer);
|
||||
}
|
||||
|
||||
void usbhid_close()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void main_loop_delay()
|
||||
{
|
||||
// no delay on embedded system
|
||||
}
|
||||
|
||||
void heartbeat()
|
||||
{
|
||||
nrf_gpio_pin_toggle(LED_1);
|
||||
nrf_gpio_pin_toggle(LED_2);
|
||||
nrf_gpio_pin_toggle(LED_3);
|
||||
nrf_gpio_pin_toggle(LED_4);
|
||||
}
|
||||
|
||||
|
||||
void ctaphid_write_block(uint8_t * data)
|
||||
{
|
||||
printf("<< "); dump_hex(data, 64);
|
||||
usbhid_send(data);
|
||||
}
|
||||
|
||||
|
||||
int ctap_user_presence_test()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ctap_user_verification(uint8_t arg)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
uint32_t ctap_atomic_count(int sel)
|
||||
{
|
||||
static uint32_t counter1 = 25;
|
||||
static uint32_t counter2 = 25;
|
||||
/*return 713;*/
|
||||
if (sel == 0)
|
||||
{
|
||||
printf1(TAG_RED,"counter1: %d\n", counter1);
|
||||
return counter1++;
|
||||
}
|
||||
else
|
||||
{
|
||||
return counter2++;
|
||||
}
|
||||
}
|
||||
|
||||
int ctap_generate_rng(uint8_t * dst, size_t num)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
*dst++ = (uint8_t)rand();
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
140
nrf52840/main.c
140
nrf52840/main.c
@@ -50,140 +50,52 @@
|
||||
#define DEBUG
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "nrf.h"
|
||||
#include "nrf_gpio.h"
|
||||
#include "nrf_delay.h"
|
||||
#include "nrf_drv_clock.h"
|
||||
#include "nrf_drv_power.h"
|
||||
#include "nrf_strerror.h"
|
||||
#include "nrf_drv_rtc.h"
|
||||
#include "nrf_drv_clock.h"
|
||||
|
||||
#include "SEGGER_RTT.h"
|
||||
#include "boards.h"
|
||||
|
||||
#include "usb.h"
|
||||
|
||||
|
||||
#define COMPARE_COUNTERTIME (3UL) /**< Get Compare event COMPARE_TIME seconds after the counter starts from 0. */
|
||||
|
||||
#ifdef BSP_LED_0
|
||||
#define TICK_EVENT_OUTPUT BSP_LED_0 /**< Pin number for indicating tick event. */
|
||||
#endif
|
||||
#ifndef TICK_EVENT_OUTPUT
|
||||
#error "Please indicate output pin"
|
||||
#endif
|
||||
#ifdef BSP_LED_1
|
||||
#define COMPARE_EVENT_OUTPUT BSP_LED_1 /**< Pin number for indicating compare event. */
|
||||
#endif
|
||||
#ifndef COMPARE_EVENT_OUTPUT
|
||||
#error "Please indicate output pin"
|
||||
#endif
|
||||
|
||||
const nrf_drv_rtc_t rtc = NRF_DRV_RTC_INSTANCE(0); /**< Declaring an instance of nrf_drv_rtc for RTC0. */
|
||||
|
||||
#define printf(fmt,...) SEGGER_RTT_printf(0, fmt, ##__VA_ARGS__);
|
||||
|
||||
|
||||
/*lint -save -e14 */
|
||||
void app_error_fault_handler(uint32_t id, uint32_t pc, uint32_t info)
|
||||
{
|
||||
error_info_t * e = (error_info_t *)info;
|
||||
SEGGER_RTT_printf(0, "Error: %d: %s at %d:%s\n",e->err_code, nrf_strerror_get(e->err_code), e->line_num, e->p_file_name);
|
||||
while(1)
|
||||
;
|
||||
}
|
||||
|
||||
void log_resetreason(void);
|
||||
|
||||
|
||||
|
||||
static void init_power_clock(void)
|
||||
{
|
||||
ret_code_t ret;
|
||||
/* Initializing power and clock */
|
||||
ret = nrf_drv_clock_init();
|
||||
APP_ERROR_CHECK(ret);
|
||||
ret = nrf_drv_power_init(NULL);
|
||||
APP_ERROR_CHECK(ret);
|
||||
nrf_drv_clock_hfclk_request(NULL);
|
||||
nrf_drv_clock_lfclk_request(NULL);
|
||||
while (!(nrf_drv_clock_hfclk_is_running() &&
|
||||
nrf_drv_clock_lfclk_is_running()))
|
||||
{
|
||||
/* Just waiting */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void rtc_config(void)
|
||||
{
|
||||
uint32_t err_code;
|
||||
|
||||
//Initialize RTC instance
|
||||
nrf_drv_rtc_config_t config = NRF_DRV_RTC_DEFAULT_CONFIG;
|
||||
config.prescaler = 32;
|
||||
err_code = nrf_drv_rtc_init(&rtc, &config, NULL);
|
||||
APP_ERROR_CHECK(err_code);
|
||||
|
||||
//Enable tick event & interrupt
|
||||
/*nrf_drv_rtc_tick_enable(&rtc,true);*/
|
||||
|
||||
/*//Set compare channel to trigger interrupt after COMPARE_COUNTERTIME seconds*/
|
||||
/*err_code = nrf_drv_rtc_cc_set(&rtc,0,COMPARE_COUNTERTIME * 8,true);*/
|
||||
/*APP_ERROR_CHECK(err_code);*/
|
||||
|
||||
//Power on RTC instance
|
||||
nrf_drv_rtc_enable(&rtc);
|
||||
}
|
||||
#include "device.h"
|
||||
#include "time.h"
|
||||
#include "util.h"
|
||||
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
/* Configure board. */
|
||||
/*bsp_board_init(BSP_INIT_LEDS);*/
|
||||
/*lfclk_config();*/
|
||||
/*SEGGER_RTT_printf(0, "Hello FIDO2\n");*/
|
||||
uint8_t hidmsg[64];
|
||||
uint32_t count = 0;
|
||||
uint32_t beat = 0;
|
||||
uint32_t t1 = 0;
|
||||
|
||||
uint32_t count;
|
||||
int i = 0;
|
||||
|
||||
printf("hello FIDO2\r\n");
|
||||
log_resetreason();
|
||||
if ((nrf_power_resetreas_get() & NRF_POWER_RESETREAS_RESETPIN_MASK) == 0)
|
||||
device_init();
|
||||
|
||||
while(1)
|
||||
{
|
||||
// Hard reset. this is for engineering A sample to work for USB ...
|
||||
nrf_power_resetreas_clear(nrf_power_resetreas_get());
|
||||
nrf_gpio_cfg_output(NRF_GPIO_PIN_MAP(0,31));
|
||||
nrf_gpio_pin_clear(NRF_GPIO_PIN_MAP(0,31));
|
||||
while (1)
|
||||
;
|
||||
}
|
||||
nrf_power_resetreas_clear(nrf_power_resetreas_get());
|
||||
|
||||
|
||||
init_power_clock();
|
||||
rtc_config();
|
||||
usb_init();
|
||||
|
||||
while (1)
|
||||
{
|
||||
i++;
|
||||
for (int i = 0; i < LEDS_NUMBER; i++)
|
||||
if (millis() - t1 > 1000)
|
||||
{
|
||||
bsp_board_led_invert(i);
|
||||
nrf_delay_ms(25);
|
||||
printf("heartbeat %ld\n", beat++);
|
||||
t1 = millis();
|
||||
}
|
||||
count = nrf_drv_rtc_counter_get(&rtc);
|
||||
|
||||
printf("toggle\r\n");
|
||||
SEGGER_RTT_SetTerminal(0);
|
||||
SEGGER_RTT_printf(0, "Hello World %d!\n", count);
|
||||
SEGGER_RTT_SetTerminal(1);
|
||||
SEGGER_RTT_printf(0, "Hello World %d!\n", i);
|
||||
if (usbhid_recv(hidmsg) > 0)
|
||||
{
|
||||
printf("%d>> ",count++); dump_hex(hidmsg,sizeof(hidmsg));
|
||||
|
||||
/*ctaphid_handle_packet(hidmsg);*/
|
||||
memset(hidmsg, 0, sizeof(hidmsg));
|
||||
}
|
||||
|
||||
/*u2f_hid_check_timeouts();*/
|
||||
|
||||
main_loop_delay();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
73
nrf52840/retarget.c
Normal file
73
nrf52840/retarget.c
Normal file
@@ -0,0 +1,73 @@
|
||||
#include "nrf.h"
|
||||
#include "SEGGER_RTT.h"
|
||||
|
||||
int _SEGGER_TERM = 0;
|
||||
|
||||
void set_logging_tag(uint32_t tag)
|
||||
{
|
||||
int term = 0;
|
||||
while (tag)
|
||||
{
|
||||
if (tag & 1)
|
||||
break;
|
||||
term++;
|
||||
tag = tag >> 1;
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(__CC_ARM)
|
||||
int fgetc(FILE * p_file)
|
||||
{
|
||||
return '0';
|
||||
}
|
||||
|
||||
int fputc(int ch, FILE * p_file)
|
||||
{
|
||||
SEGGER_RTT_PutChar(_SEGGER_TERM, ch);
|
||||
return ch;
|
||||
}
|
||||
|
||||
#elif defined(__GNUC__) && defined(__SES_ARM)
|
||||
|
||||
int __getchar(FILE * p_file)
|
||||
{
|
||||
return '0';
|
||||
}
|
||||
|
||||
int __putchar(int ch, FILE * p_file)
|
||||
{
|
||||
SEGGER_RTT_PutChar(_SEGGER_TERM, ch);
|
||||
return ch;
|
||||
}
|
||||
#elif defined(__GNUC__) && !defined(__SES_ARM)
|
||||
|
||||
int _write(int file, const char * p_char, int len)
|
||||
{
|
||||
int i;
|
||||
|
||||
UNUSED_PARAMETER(file);
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
SEGGER_RTT_PutChar(_SEGGER_TERM, *p_char++);
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
int _read(int file, char * p_char, int len)
|
||||
{
|
||||
*p_char = '0';
|
||||
/*UNUSED_PARAMETER(file);*/
|
||||
/*while (app_uart_get((uint8_t *)p_char) == NRF_ERROR_NOT_FOUND)*/
|
||||
/*{*/
|
||||
/*// No implementation needed.*/
|
||||
/*}*/
|
||||
return 1;
|
||||
}
|
||||
|
||||
#else
|
||||
/*#elif defined(__ICCARM__)*/
|
||||
#error "No read/write for printing implemented for compiler"
|
||||
#endif
|
||||
|
@@ -6844,7 +6844,7 @@
|
||||
// <e> NRF_QUEUE_ENABLED - nrf_queue - Queue module
|
||||
//==========================================================
|
||||
#ifndef NRF_QUEUE_ENABLED
|
||||
#define NRF_QUEUE_ENABLED 1
|
||||
#define NRF_QUEUE_ENABLED 0
|
||||
#endif
|
||||
// <q> NRF_QUEUE_CLI_CMDS - Enable CLI commands specific to the module
|
||||
|
||||
|
@@ -52,12 +52,13 @@
|
||||
#include "nrf_log_default_backends.h"
|
||||
#include "app_timer.h"
|
||||
#include "app_error.h"
|
||||
#include "app_fifo.h"
|
||||
#include "bsp.h"
|
||||
#include "bsp_cli.h"
|
||||
#include "nrf_cli.h"
|
||||
|
||||
#include "SEGGER_RTT.h"
|
||||
#define printf(fmt,...) SEGGER_RTT_printf(0, fmt, ##__VA_ARGS__);
|
||||
#include "util.h"
|
||||
#include "usb.h"
|
||||
|
||||
#define BTN_DATA_SEND 0
|
||||
#define BTN_DATA_KEY_RELEASE (bsp_event_t)(BSP_EVENT_KEY_LAST + 1)
|
||||
@@ -805,20 +806,12 @@ static void usbd_setup_SetProtocol(
|
||||
|
||||
/** @} */ /* End of processing setup requests functions */
|
||||
|
||||
void dump_hex(uint8_t * buf, int size)
|
||||
{
|
||||
while(size--)
|
||||
{
|
||||
printf("%02x ", *buf++);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void usbd_event_handler(nrf_drv_usbd_evt_t const * const p_event)
|
||||
{
|
||||
static uint8_t buf[64];
|
||||
uint32_t size;
|
||||
nrf_drv_usbd_transfer_t transfer;
|
||||
memset(&transfer, 0, sizeof(nrf_drv_usbd_transfer_t));
|
||||
|
||||
@@ -861,7 +854,14 @@ static void usbd_event_handler(nrf_drv_usbd_evt_t const * const p_event)
|
||||
{
|
||||
case NRF_USBD_EP_OK:
|
||||
/*printf("NRF_USBD_EP_OK\n");*/
|
||||
printf(">> ");dump_hex(buf,64);
|
||||
/*printf(">> "); dump_hex(buf,64);*/
|
||||
size = 64;
|
||||
app_fifo_write(&USBHID_RECV_FIFO, buf, &size);
|
||||
if (size != 64)
|
||||
{
|
||||
printf("Error, USB FIFO is full\n");
|
||||
APP_ERROR_CHECK(NRF_ERROR_NO_MEM);
|
||||
}
|
||||
break;
|
||||
case NRF_USBD_EP_WAITING:
|
||||
/*printf("NRF_USBD_EP_WAITING\n");*/
|
||||
@@ -1038,54 +1038,6 @@ static void power_usb_event_handler(nrf_drv_power_usb_evt_t event)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void log_resetreason(void)
|
||||
{
|
||||
/* Reset reason */
|
||||
uint32_t rr = nrf_power_resetreas_get();
|
||||
printf("Reset reasons:\n");
|
||||
if (0 == rr)
|
||||
{
|
||||
printf("- NONE\n");
|
||||
}
|
||||
if (0 != (rr & NRF_POWER_RESETREAS_RESETPIN_MASK))
|
||||
{
|
||||
printf("- RESETPIN\n");
|
||||
}
|
||||
if (0 != (rr & NRF_POWER_RESETREAS_DOG_MASK ))
|
||||
{
|
||||
printf("- DOG\n");
|
||||
}
|
||||
if (0 != (rr & NRF_POWER_RESETREAS_SREQ_MASK ))
|
||||
{
|
||||
printf("- SREQ\n");
|
||||
}
|
||||
if (0 != (rr & NRF_POWER_RESETREAS_LOCKUP_MASK ))
|
||||
{
|
||||
printf("- LOCKUP\n");
|
||||
}
|
||||
if (0 != (rr & NRF_POWER_RESETREAS_OFF_MASK ))
|
||||
{
|
||||
printf("- OFF\n");
|
||||
}
|
||||
if (0 != (rr & NRF_POWER_RESETREAS_LPCOMP_MASK ))
|
||||
{
|
||||
printf("- LPCOMP\n");
|
||||
}
|
||||
if (0 != (rr & NRF_POWER_RESETREAS_DIF_MASK ))
|
||||
{
|
||||
printf("- DIF\n");
|
||||
}
|
||||
if (0 != (rr & NRF_POWER_RESETREAS_NFC_MASK ))
|
||||
{
|
||||
printf("- NFC\n");
|
||||
}
|
||||
if (0 != (rr & NRF_POWER_RESETREAS_VBUS_MASK ))
|
||||
{
|
||||
printf("- VBUS\n");
|
||||
}
|
||||
}
|
||||
|
||||
void usb_init(void)
|
||||
{
|
||||
ret_code_t ret;
|
||||
|
@@ -1,6 +1,10 @@
|
||||
#ifndef _USB_H
|
||||
#define _USB_H
|
||||
|
||||
#include "app_fifo.h"
|
||||
|
||||
void usb_init(void);
|
||||
|
||||
extern app_fifo_t USBHID_RECV_FIFO;
|
||||
|
||||
#endif
|
||||
|
1
nrf52840/usbhid.c
Normal file
1
nrf52840/usbhid.c
Normal file
@@ -0,0 +1 @@
|
||||
|
Reference in New Issue
Block a user