mirror of
https://github.com/RfidResearchGroup/ChameleonUltra.git
synced 2026-05-12 11:22:59 -07:00
Use common resources to provide hardware-related interfaces and functions.
This commit is contained in:
@@ -5,6 +5,8 @@ OUTPUT_DIRECTORY := out
|
||||
SDK_ROOT := ../../resource/nrf52_sdk
|
||||
PROJ_DIR := ./src/
|
||||
LD_DIR := ../../resource/link_script/
|
||||
SRC_PUBLIC := ../../resource/public_src/
|
||||
|
||||
|
||||
$(OUTPUT_DIRECTORY)/application.out: \
|
||||
LINKER_SCRIPT := ${LD_DIR}/application.ld
|
||||
@@ -18,7 +20,7 @@ CURRENT_DEVICE_TYPE := ${CHAMELEON_LITE}
|
||||
|
||||
# Source files common to all targets
|
||||
SRC_FILES += \
|
||||
$(PROJ_DIR)/hw_connect.c \
|
||||
$(SRC_PUBLIC)/hw_connect.c \
|
||||
$(PROJ_DIR)/app_main.c \
|
||||
$(PROJ_DIR)/app_cmd.c \
|
||||
$(PROJ_DIR)/ble_main.c \
|
||||
@@ -123,6 +125,7 @@ SRC_FILES += \
|
||||
# Include folders common to all targets
|
||||
INC_FOLDERS += \
|
||||
${PROJ_DIR} \
|
||||
${SRC_PUBLIC} \
|
||||
${PROJ_DIR}/bsp/ \
|
||||
${PROJ_DIR}/utils/ \
|
||||
${PROJ_DIR}/rfid/ \
|
||||
@@ -264,11 +267,6 @@ INC_FOLDERS += \
|
||||
# Libraries common to all targets
|
||||
LIB_FILES += \
|
||||
|
||||
# Optimization flags
|
||||
OPT = -O3 -g3
|
||||
# Uncomment the line below to enable link time optimization
|
||||
#OPT += -flto
|
||||
|
||||
|
||||
ifeq (${CURRENT_DEVICE_TYPE}, ${CHAMELEON_ULTRA})
|
||||
# Append reader module source code to compile list.
|
||||
@@ -289,16 +287,22 @@ ifeq (${CURRENT_DEVICE_TYPE}, ${CHAMELEON_ULTRA})
|
||||
|
||||
CFLAGS += -DPROJECT_CHAMELEON_ULTRA
|
||||
|
||||
$(info Chameleon Ultra: reader and tag emulation module enable.)
|
||||
$(info Chameleon Ultra <Application>: reader and tag emulation module enable.)
|
||||
else ifeq (${CURRENT_DEVICE_TYPE}, ${CHAMELEON_LITE})
|
||||
|
||||
CFLAGS += -DPROJECT_CHAMELEON_LITE
|
||||
|
||||
$(info Chameleon Lite: tag emulation module enable.)
|
||||
$(info Chameleon Lite <Application>: tag emulation module enable.)
|
||||
else
|
||||
$(error Chameleon: No device type define.)
|
||||
$(error Chameleon <Application>: No device type define.)
|
||||
endif
|
||||
|
||||
|
||||
# Optimization flags
|
||||
OPT = -O3 -g3
|
||||
# Uncomment the line below to enable link time optimization
|
||||
#OPT += -flto
|
||||
|
||||
# C flags common to all targets
|
||||
CFLAGS += $(OPT)
|
||||
CFLAGS += -DAPP_TIMER_V2
|
||||
@@ -375,7 +379,7 @@ include $(TEMPLATE_PATH)/Makefile.common
|
||||
|
||||
$(foreach target, $(TARGETS), $(call define_target, $(target)))
|
||||
|
||||
.PHONY: flash flash_softdevice erase
|
||||
.PHONY: flash flash_softdevice erase config
|
||||
|
||||
# Flash the program
|
||||
flash: default
|
||||
@@ -395,4 +399,4 @@ erase:
|
||||
SDK_CONFIG_FILE := ./${PROJ_DIR}/sdk_config.h
|
||||
CMSIS_CONFIG_TOOL := $(SDK_ROOT)/external_tools/cmsisconfig/CMSIS_Configuration_Wizard.jar
|
||||
config:
|
||||
java -jar $(CMSIS_CONFIG_TOOL) $(SDK_CONFIG_FILE)
|
||||
java -jar $(CMSIS_CONFIG_TOOL) $(SDK_CONFIG_FILE)
|
||||
@@ -61,28 +61,6 @@ void tag_mode_enter(void) {
|
||||
}
|
||||
}
|
||||
|
||||
// 初始化设备的LED灯珠
|
||||
void init_leds(void) {
|
||||
uint32_t* led_pins = hw_get_led_array();
|
||||
uint32_t* led_rgb_pins = hw_get_rgb_array();
|
||||
|
||||
// 初始化卡槽那几颗LED灯的GPIO(其他的LED由其他的模块控制)
|
||||
for (uint8_t i = 0; i < RGB_LIST_NUM; i++) {
|
||||
nrf_gpio_cfg_output(led_pins[i]);
|
||||
nrf_gpio_pin_clear(led_pins[i]);
|
||||
}
|
||||
|
||||
// 初始化RGB脚
|
||||
for (uint8_t i = 0; i < RGB_CTRL_NUM; i++) {
|
||||
nrf_gpio_cfg_output(led_rgb_pins[i]);
|
||||
nrf_gpio_pin_set(led_rgb_pins[i]);
|
||||
}
|
||||
|
||||
// 设置FIELD LED脚为输出且灭掉场灯
|
||||
nrf_gpio_cfg_output(LED_FIELD);
|
||||
TAG_FIELD_LED_OFF()
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Function for light up led by slot index
|
||||
*/
|
||||
@@ -99,28 +77,6 @@ void light_up_by_slot(void) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Function for enter tag emulation mode
|
||||
* @param color: 0 表示r, 1表示g, 2表示b
|
||||
*/
|
||||
void set_slot_light_color(uint8_t color) {
|
||||
nrf_gpio_pin_set(LED_R);
|
||||
nrf_gpio_pin_set(LED_G);
|
||||
nrf_gpio_pin_set(LED_B);
|
||||
switch(color) {
|
||||
case 0:
|
||||
nrf_gpio_pin_clear(LED_R);
|
||||
break;
|
||||
case 1:
|
||||
nrf_gpio_pin_clear(LED_G);
|
||||
break;
|
||||
case 2:
|
||||
nrf_gpio_pin_clear(LED_B);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Function for get current device mode
|
||||
*/
|
||||
|
||||
@@ -32,7 +32,6 @@ void init_leds(void);
|
||||
void light_up_by_slot(void);
|
||||
void reader_mode_enter(void);
|
||||
void tag_mode_enter(void);
|
||||
void set_slot_light_color(uint8_t color);
|
||||
device_mode_t get_device_mode(void);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -6,14 +6,23 @@ SDK_ROOT := ../../resource/nrf52_sdk
|
||||
PROJ_DIR := ./src/
|
||||
DFU_DIR := ../../resource/dfu_key/
|
||||
LD_DIR := ../../resource/link_script/
|
||||
SRC_PUBLIC := ../../resource/public_src/
|
||||
|
||||
|
||||
$(OUTPUT_DIRECTORY)/bootloader.out: \
|
||||
LINKER_SCRIPT := ${LD_DIR}/bootloader.ld
|
||||
|
||||
|
||||
CHAMELEON_ULTRA := ultra
|
||||
CHAMELEON_LITE := lite
|
||||
# What device is it?
|
||||
CURRENT_DEVICE_TYPE := ${CHAMELEON_LITE}
|
||||
|
||||
|
||||
# Source files common to all targets
|
||||
SRC_FILES += \
|
||||
$(PROJ_DIR)/main.c \
|
||||
$(SRC_PUBLIC)/hw_connect.c \
|
||||
$(DFU_DIR)/dfu_public_key.c \
|
||||
$(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_clock.c \
|
||||
$(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_power.c \
|
||||
@@ -60,7 +69,6 @@ SRC_FILES += \
|
||||
$(SDK_ROOT)/components/libraries/crypto/backend/cc310_bl/cc310_bl_backend_hash.c \
|
||||
$(SDK_ROOT)/components/libraries/crypto/backend/cc310_bl/cc310_bl_backend_init.c \
|
||||
$(SDK_ROOT)/components/libraries/crypto/backend/cc310_bl/cc310_bl_backend_shared.c \
|
||||
$(SDK_ROOT)/components/boards/boards.c \
|
||||
$(SDK_ROOT)/components/softdevice/common/nrf_sdh.c \
|
||||
$(SDK_ROOT)/components/softdevice/common/nrf_sdh_ble.c \
|
||||
$(SDK_ROOT)/components/softdevice/common/nrf_sdh_soc.c \
|
||||
@@ -106,6 +114,7 @@ SRC_FILES += \
|
||||
# Include folders common to all targets
|
||||
INC_FOLDERS += \
|
||||
$(PROJ_DIR) \
|
||||
${SRC_PUBLIC} \
|
||||
$(SDK_ROOT)/modules/nrfx/drivers/include \
|
||||
$(SDK_ROOT)/components/libraries/crypto/backend/micro_ecc \
|
||||
$(SDK_ROOT)/components/libraries/memobj \
|
||||
@@ -139,7 +148,6 @@ INC_FOLDERS += \
|
||||
$(SDK_ROOT)/external/nrf_oberon \
|
||||
$(SDK_ROOT)/components/libraries/strerror \
|
||||
$(SDK_ROOT)/components/libraries/crypto/backend/mbedtls \
|
||||
$(SDK_ROOT)/components/boards \
|
||||
$(SDK_ROOT)/components/libraries/crypto/backend/cc310 \
|
||||
$(SDK_ROOT)/components/libraries/bootloader \
|
||||
$(SDK_ROOT)/components/softdevice/s140/headers \
|
||||
@@ -167,6 +175,18 @@ LIB_FILES += \
|
||||
$(SDK_ROOT)/external/nrf_oberon/lib/cortex-m4/hard-float/liboberon_3.0.8.a \
|
||||
$(SDK_ROOT)/external/nrf_cc310_bl/lib/cortex-m4/hard-float/libnrf_cc310_bl_0.9.13.a \
|
||||
|
||||
|
||||
ifeq (${CURRENT_DEVICE_TYPE}, ${CHAMELEON_ULTRA})
|
||||
CFLAGS += -DPROJECT_CHAMELEON_ULTRA
|
||||
$(info Chameleon Ultra <Bootloader>: zZZZZZ.)
|
||||
else ifeq (${CURRENT_DEVICE_TYPE}, ${CHAMELEON_LITE})
|
||||
CFLAGS += -DPROJECT_CHAMELEON_LITE
|
||||
$(info Chameleon Lite <Bootloader>: zZZZZZ.)
|
||||
else
|
||||
$(error Chameleon <Bootloader>: No device type define.)
|
||||
endif
|
||||
|
||||
|
||||
# Optimization flags
|
||||
OPT = -Os -g3
|
||||
# Uncomment the line below to enable link time optimization
|
||||
@@ -175,7 +195,6 @@ OPT = -Os -g3
|
||||
# C flags common to all targets
|
||||
CFLAGS += $(OPT)
|
||||
CFLAGS += -DBLE_STACK_SUPPORT_REQD
|
||||
CFLAGS += -DBOARD_CHAMELEON
|
||||
# CFLAGS += -DCONFIG_GPIO_AS_PINRESET
|
||||
CFLAGS += -DFLOAT_ABI_HARD
|
||||
CFLAGS += -DNRF52840_XXAA
|
||||
@@ -201,7 +220,6 @@ ASMFLAGS += -mcpu=cortex-m4
|
||||
ASMFLAGS += -mthumb -mabi=aapcs
|
||||
ASMFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
|
||||
ASMFLAGS += -DBLE_STACK_SUPPORT_REQD
|
||||
ASMFLAGS += -DBOARD_CHAMELEON
|
||||
ASMFLAGS += -DCONFIG_GPIO_AS_PINRESET
|
||||
ASMFLAGS += -DFLOAT_ABI_HARD
|
||||
ASMFLAGS += -DNRF52840_XXAA
|
||||
|
||||
@@ -52,10 +52,6 @@ static const uint8_t m_board_led_list[LEDS_NUMBER] = LEDS_LIST;
|
||||
static const uint8_t m_board_btn_list[BUTTONS_NUMBER] = BUTTONS_LIST;
|
||||
#endif
|
||||
|
||||
#if RGB_NUMBER > 0
|
||||
static const uint8_t m_board_rgb_list[RGB_NUMBER] = RGB_LIST;
|
||||
#endif
|
||||
|
||||
#if LEDS_NUMBER > 0
|
||||
bool bsp_board_led_state_get(uint32_t led_idx)
|
||||
{
|
||||
@@ -140,22 +136,12 @@ static void bsp_board_leds_init(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(RGB_NUMBER) && defined(LEDS_NUMBER)
|
||||
// Led for rgb init
|
||||
uint32_t i;
|
||||
for (i = 0; i < RGB_NUMBER; ++i)
|
||||
{
|
||||
nrf_gpio_cfg_output(m_board_rgb_list[i]);
|
||||
nrf_gpio_pin_set(m_board_rgb_list[i]);
|
||||
}
|
||||
nrf_gpio_pin_clear(LED_R);
|
||||
|
||||
for (i = 0; i < LEDS_NUMBER; ++i)
|
||||
{
|
||||
nrf_gpio_cfg_output(m_board_led_list[i]);
|
||||
}
|
||||
bsp_board_leds_off();
|
||||
#endif
|
||||
}
|
||||
|
||||
uint32_t bsp_board_led_idx_to_pin(uint32_t led_idx)
|
||||
@@ -219,30 +205,6 @@ uint32_t bsp_board_button_idx_to_pin(uint32_t button_idx)
|
||||
}
|
||||
#endif //BUTTONS_NUMBER > 0
|
||||
|
||||
#if RGB_NUMBER > 0
|
||||
/**
|
||||
* @brief Function for enter tag emulation mode
|
||||
* @param color: 0 -> r, 1 -> g, 2 -> b
|
||||
*/
|
||||
void bsp_set_led_color(uint8_t color) {
|
||||
nrf_gpio_pin_set(LED_R);
|
||||
nrf_gpio_pin_set(LED_G);
|
||||
nrf_gpio_pin_set(LED_B);
|
||||
uint32_t pin = LED_R;
|
||||
switch(color) {
|
||||
case 0:
|
||||
pin = LED_R;
|
||||
break;
|
||||
case 1:
|
||||
pin = LED_G;
|
||||
break;
|
||||
case 2:
|
||||
pin = LED_B;
|
||||
break;
|
||||
}
|
||||
nrf_gpio_pin_clear(pin);
|
||||
}
|
||||
#endif
|
||||
|
||||
void bsp_board_init(uint32_t init_flags)
|
||||
{
|
||||
|
||||
@@ -85,8 +85,6 @@
|
||||
#include STRINGIFY(CUSTOM_BOARD_INC.h)
|
||||
#elif defined(BOARD_CUSTOM)
|
||||
#include "custom_board.h"
|
||||
#elif defined(BOARD_CHAMELEON)
|
||||
#include "chameleon_nrf52.h"
|
||||
#else
|
||||
#error "Board is not defined"
|
||||
|
||||
@@ -116,13 +114,6 @@ extern "C" {
|
||||
*/
|
||||
bool bsp_board_led_state_get(uint32_t led_idx);
|
||||
|
||||
/**
|
||||
* @brief Fcuntion for led color change
|
||||
*
|
||||
* @param color 0 -> r, 1 -> g, 2 -> b
|
||||
*/
|
||||
void bsp_set_led_color(uint8_t color);
|
||||
|
||||
/**
|
||||
* Function for turning on an LED.
|
||||
*
|
||||
|
||||
@@ -1,137 +0,0 @@
|
||||
#ifndef CHAMALEON_NRF52_H
|
||||
#define CHAMALEON_NRF52_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "nrf_gpio.h"
|
||||
|
||||
// LEDs definitions for CHAMELEON
|
||||
#define LEDS_NUMBER 8
|
||||
#define RGB_NUMBER 3
|
||||
#define LED_R (NRF_GPIO_PIN_MAP(0, 24))
|
||||
#define LED_G (NRF_GPIO_PIN_MAP(0, 22))
|
||||
#define LED_B (NRF_GPIO_PIN_MAP(1, 0))
|
||||
#define LED_8 (NRF_GPIO_PIN_MAP(0, 20))
|
||||
#define LED_7 (NRF_GPIO_PIN_MAP(0, 17))
|
||||
#define LED_6 (NRF_GPIO_PIN_MAP(0, 15))
|
||||
#define LED_5 (NRF_GPIO_PIN_MAP(0, 13))
|
||||
#define LED_4 (NRF_GPIO_PIN_MAP(0, 12))
|
||||
#define LED_3 (NRF_GPIO_PIN_MAP(1, 9))
|
||||
#define LED_2 (NRF_GPIO_PIN_MAP(0, 8))
|
||||
#define LED_1 (NRF_GPIO_PIN_MAP(0, 6))
|
||||
#define LED_START LED_1
|
||||
#define LED_STOP LED_8
|
||||
|
||||
#define LEDS_ACTIVE_STATE 1
|
||||
|
||||
#define LEDS_LIST { LED_1, LED_2, LED_3, LED_4, LED_5, LED_6, LED_7, LED_8 }
|
||||
|
||||
#define RGB_LIST { LED_R, LED_G, LED_B }
|
||||
|
||||
#define LEDS_INV_MASK LEDS_MASK
|
||||
|
||||
#define BSP_LED_0 LED_1
|
||||
#define BSP_LED_1 LED_2
|
||||
#define BSP_LED_2 LED_3
|
||||
#define BSP_LED_3 LED_4
|
||||
|
||||
#define BUTTONS_NUMBER 4
|
||||
|
||||
#define BUTTON_1 11
|
||||
#define BUTTON_2 12
|
||||
#define BUTTON_3 24
|
||||
#define BUTTON_4 25
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLDOWN
|
||||
|
||||
#define BUTTONS_ACTIVE_STATE 0
|
||||
|
||||
#define BUTTONS_LIST { BUTTON_1, BUTTON_2, BUTTON_3, BUTTON_4 }
|
||||
|
||||
#define BSP_BUTTON_0 BUTTON_1
|
||||
#define BSP_BUTTON_1 BUTTON_2
|
||||
#define BSP_BUTTON_2 BUTTON_3
|
||||
#define BSP_BUTTON_3 BUTTON_4
|
||||
|
||||
|
||||
/////////////////////// 下面的内容用不上
|
||||
|
||||
|
||||
#define RX_PIN_NUMBER 8
|
||||
#define TX_PIN_NUMBER 6
|
||||
#define CTS_PIN_NUMBER 7
|
||||
#define RTS_PIN_NUMBER 5
|
||||
#define HWFC true
|
||||
|
||||
#define BSP_QSPI_SCK_PIN 19
|
||||
#define BSP_QSPI_CSN_PIN 17
|
||||
#define BSP_QSPI_IO0_PIN 20
|
||||
#define BSP_QSPI_IO1_PIN 21
|
||||
#define BSP_QSPI_IO2_PIN 22
|
||||
#define BSP_QSPI_IO3_PIN 23
|
||||
|
||||
|
||||
// serialization APPLICATION board - temp. setup for running serialized MEMU tests
|
||||
#define SER_APP_RX_PIN NRF_GPIO_PIN_MAP(1,13) // UART RX pin number.
|
||||
#define SER_APP_TX_PIN NRF_GPIO_PIN_MAP(1,14) // UART TX pin number.
|
||||
#define SER_APP_CTS_PIN NRF_GPIO_PIN_MAP(0,2) // UART Clear To Send pin number.
|
||||
#define SER_APP_RTS_PIN NRF_GPIO_PIN_MAP(1,15) // UART Request To Send pin number.
|
||||
|
||||
#define SER_APP_SPIM0_SCK_PIN NRF_GPIO_PIN_MAP(0,27) // SPI clock GPIO pin number.
|
||||
#define SER_APP_SPIM0_MOSI_PIN NRF_GPIO_PIN_MAP(0,2) // SPI Master Out Slave In GPIO pin number
|
||||
#define SER_APP_SPIM0_MISO_PIN NRF_GPIO_PIN_MAP(0,26) // SPI Master In Slave Out GPIO pin number
|
||||
#define SER_APP_SPIM0_SS_PIN NRF_GPIO_PIN_MAP(1,13) // SPI Slave Select GPIO pin number
|
||||
#define SER_APP_SPIM0_RDY_PIN NRF_GPIO_PIN_MAP(1,15) // SPI READY GPIO pin number
|
||||
#define SER_APP_SPIM0_REQ_PIN NRF_GPIO_PIN_MAP(1,14) // SPI REQUEST GPIO pin number
|
||||
|
||||
// serialization CONNECTIVITY board
|
||||
#define SER_CON_RX_PIN NRF_GPIO_PIN_MAP(1,14) // UART RX pin number.
|
||||
#define SER_CON_TX_PIN NRF_GPIO_PIN_MAP(1,13) // UART TX pin number.
|
||||
#define SER_CON_CTS_PIN NRF_GPIO_PIN_MAP(1,15) // UART Clear To Send pin number. Not used if HWFC is set to false.
|
||||
#define SER_CON_RTS_PIN NRF_GPIO_PIN_MAP(0,2) // UART Request To Send pin number. Not used if HWFC is set to false.
|
||||
|
||||
|
||||
#define SER_CON_SPIS_SCK_PIN NRF_GPIO_PIN_MAP(0,27) // SPI SCK signal.
|
||||
#define SER_CON_SPIS_MOSI_PIN NRF_GPIO_PIN_MAP(0,2) // SPI MOSI signal.
|
||||
#define SER_CON_SPIS_MISO_PIN NRF_GPIO_PIN_MAP(0,26) // SPI MISO signal.
|
||||
#define SER_CON_SPIS_CSN_PIN NRF_GPIO_PIN_MAP(1,13) // SPI CSN signal.
|
||||
#define SER_CON_SPIS_RDY_PIN NRF_GPIO_PIN_MAP(1,15) // SPI READY GPIO pin number.
|
||||
#define SER_CON_SPIS_REQ_PIN NRF_GPIO_PIN_MAP(1,14) // SPI REQUEST GPIO pin number.
|
||||
|
||||
#define SER_CONN_CHIP_RESET_PIN NRF_GPIO_PIN_MAP(1,1) // Pin used to reset connectivity chip
|
||||
|
||||
// Arduino board mappings
|
||||
#define ARDUINO_SCL_PIN 27 // SCL signal pin
|
||||
#define ARDUINO_SDA_PIN 26 // SDA signal pin
|
||||
#define ARDUINO_AREF_PIN 2 // Aref pin
|
||||
|
||||
#define ARDUINO_13_PIN NRF_GPIO_PIN_MAP(1, 15) // Digital pin 13
|
||||
#define ARDUINO_12_PIN NRF_GPIO_PIN_MAP(1, 14) // Digital pin 12
|
||||
#define ARDUINO_11_PIN NRF_GPIO_PIN_MAP(1, 13) // Digital pin 11
|
||||
#define ARDUINO_10_PIN NRF_GPIO_PIN_MAP(1, 12) // Digital pin 10
|
||||
#define ARDUINO_9_PIN NRF_GPIO_PIN_MAP(1, 11) // Digital pin 9
|
||||
#define ARDUINO_8_PIN NRF_GPIO_PIN_MAP(1, 10) // Digital pin 8
|
||||
|
||||
#define ARDUINO_7_PIN NRF_GPIO_PIN_MAP(1, 8) // Digital pin 7
|
||||
#define ARDUINO_6_PIN NRF_GPIO_PIN_MAP(1, 7) // Digital pin 6
|
||||
#define ARDUINO_5_PIN NRF_GPIO_PIN_MAP(1, 6) // Digital pin 5
|
||||
#define ARDUINO_4_PIN NRF_GPIO_PIN_MAP(1, 5) // Digital pin 4
|
||||
#define ARDUINO_3_PIN NRF_GPIO_PIN_MAP(1, 4) // Digital pin 3
|
||||
#define ARDUINO_2_PIN NRF_GPIO_PIN_MAP(1, 3) // Digital pin 2
|
||||
#define ARDUINO_1_PIN NRF_GPIO_PIN_MAP(1, 2) // Digital pin 1
|
||||
#define ARDUINO_0_PIN NRF_GPIO_PIN_MAP(1, 1) // Digital pin 0
|
||||
|
||||
#define ARDUINO_A0_PIN 3 // Analog channel 0
|
||||
#define ARDUINO_A1_PIN 4 // Analog channel 1
|
||||
#define ARDUINO_A2_PIN 28 // Analog channel 2
|
||||
#define ARDUINO_A3_PIN 29 // Analog channel 3
|
||||
#define ARDUINO_A4_PIN 30 // Analog channel 4
|
||||
#define ARDUINO_A5_PIN 31 // Analog channel 5
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // PCA10056_H
|
||||
@@ -0,0 +1,23 @@
|
||||
#ifndef DEVICE_INFO_H
|
||||
#define DEVICE_INFO_H
|
||||
|
||||
// Default name
|
||||
#if defined(PROJECT_CHAMELEON_ULTRA)
|
||||
#define DEVICE_NAME_STR "ChameleonUltra"
|
||||
#define DEVICE_NAME_STR_SHORT "CU"
|
||||
#elif defined(PROJECT_CHAMELEON_LITE)
|
||||
#define DEVICE_NAME_STR "ChameleonLite"
|
||||
#define DEVICE_NAME_STR_SHORT "CL"
|
||||
#else
|
||||
#error "Unknown device name?"
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* From 2byte version code merge to a U16 value,
|
||||
* like: 1(byte).0(byte) -> 1.0
|
||||
*/
|
||||
#define VER_CODE_TO_NUM(major, minor) (((major << 8) & 0xFFFF) | (minor & 0xFF))
|
||||
|
||||
|
||||
#endif
|
||||
@@ -12,6 +12,8 @@ const static chameleon_device_type_t m_device_type =
|
||||
"No device define before project build.";
|
||||
#endif
|
||||
|
||||
char g_extern_product_str[sizeof(DEVICE_NAME_STR) + sizeof(": hw_v255, fw_v65535") + 1];
|
||||
|
||||
|
||||
uint32_t g_led_field;
|
||||
uint32_t g_led_1;
|
||||
@@ -63,7 +65,36 @@ uint32_t m_rgb_array[MAX_RGB_NUM];
|
||||
static uint8_t m_hw_ver;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Function for chameleon lite power set
|
||||
*/
|
||||
void board_lite_high_voltage_set(void) {
|
||||
#ifdef SOFTDEVICE_PRESENT
|
||||
sd_power_dcdc_mode_set(NRF_POWER_DCDC_DISABLE);
|
||||
sd_power_dcdc0_mode_set(NRF_POWER_DCDC_DISABLE);
|
||||
#else
|
||||
NRF_POWER->DCDCEN = 0;
|
||||
NRF_POWER->DCDCEN0 = 0;
|
||||
#endif
|
||||
// if the chameleon lite is powered from USB (high voltage mode), GPIO output voltage is set to 1.8 volts by
|
||||
// default and that is not enough to turn the green and blue LEDs on. Increase GPIO voltage to 3.0 volts.
|
||||
if (((NRF_UICR->REGOUT0 & UICR_REGOUT0_VOUT_Msk) == (UICR_REGOUT0_VOUT_DEFAULT << UICR_REGOUT0_VOUT_Pos))) {
|
||||
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos;
|
||||
while (NRF_NVMC->READY == NVMC_READY_READY_Busy);
|
||||
NRF_UICR->REGOUT0 = (NRF_UICR->REGOUT0 & ~((uint32_t)UICR_REGOUT0_VOUT_Msk)) | (UICR_REGOUT0_VOUT_3V3 << UICR_REGOUT0_VOUT_Pos);
|
||||
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos;
|
||||
while (NRF_NVMC->READY == NVMC_READY_READY_Busy);
|
||||
// a reset is required for changes to take effect
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
}
|
||||
|
||||
void hw_connect_init(void) {
|
||||
#if defined(PROJECT_CHAMELEON_LITE)
|
||||
board_lite_high_voltage_set(); // lite需要关闭dcdc并且抬高内核电压
|
||||
#endif
|
||||
|
||||
// TODO 请实现此处,实现硬件版本号的读取
|
||||
// 测试的时候可以直接改写此版本号
|
||||
m_hw_ver = 1;
|
||||
@@ -180,6 +211,9 @@ void hw_connect_init(void) {
|
||||
INIT_RGB_ARRAY(1, LED_R);
|
||||
INIT_RGB_ARRAY(2, LED_G);
|
||||
INIT_RGB_ARRAY(3, LED_B);
|
||||
|
||||
// Generates a description string of detailed device information.
|
||||
sprintf(g_extern_product_str, "%s: hw_v%d, fw_v%d", DEVICE_NAME_STR, m_hw_ver, FW_VER_NUM);
|
||||
}
|
||||
|
||||
uint32_t* hw_get_led_array(void) {
|
||||
@@ -197,3 +231,47 @@ chameleon_device_type_t hw_get_device_type(void) {
|
||||
uint8_t hw_get_version_code(void) {
|
||||
return m_hw_ver;
|
||||
}
|
||||
|
||||
// 初始化设备的LED灯珠
|
||||
void init_leds(void) {
|
||||
uint32_t* led_pins = hw_get_led_array();
|
||||
uint32_t* led_rgb_pins = hw_get_rgb_array();
|
||||
|
||||
// 初始化卡槽那几颗LED灯的GPIO(其他的LED由其他的模块控制)
|
||||
for (uint8_t i = 0; i < RGB_LIST_NUM; i++) {
|
||||
nrf_gpio_cfg_output(led_pins[i]);
|
||||
nrf_gpio_pin_clear(led_pins[i]);
|
||||
}
|
||||
|
||||
// 初始化RGB脚
|
||||
for (uint8_t i = 0; i < RGB_CTRL_NUM; i++) {
|
||||
nrf_gpio_cfg_output(led_rgb_pins[i]);
|
||||
nrf_gpio_pin_set(led_rgb_pins[i]);
|
||||
}
|
||||
|
||||
// 设置FIELD LED脚为输出且灭掉场灯
|
||||
nrf_gpio_cfg_output(LED_FIELD);
|
||||
TAG_FIELD_LED_OFF()
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Function for enter tag emulation mode
|
||||
* @param color: 0 表示r, 1表示g, 2表示b
|
||||
*/
|
||||
void set_slot_light_color(uint8_t color) {
|
||||
nrf_gpio_pin_set(LED_R);
|
||||
nrf_gpio_pin_set(LED_G);
|
||||
nrf_gpio_pin_set(LED_B);
|
||||
switch(color) {
|
||||
case 0:
|
||||
nrf_gpio_pin_clear(LED_R);
|
||||
break;
|
||||
case 1:
|
||||
nrf_gpio_pin_clear(LED_G);
|
||||
break;
|
||||
case 2:
|
||||
nrf_gpio_pin_clear(LED_B);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,11 @@
|
||||
/*
|
||||
* hardware io connection map.
|
||||
*/
|
||||
#ifndef HW_CONNECT_H_
|
||||
#define HW_CONNECT_H_
|
||||
|
||||
#include "nrf_lpcomp.h"
|
||||
#include "device_info.h"
|
||||
|
||||
|
||||
typedef enum {
|
||||
@@ -52,6 +56,7 @@ extern uint32_t g_bat_sense;
|
||||
#define RGB_CTRL_NUM g_rgb_num
|
||||
#define BUTTON_1 g_button1
|
||||
#define BUTTON_2 g_button2
|
||||
#define BUTTON_PULL NRF_GPIO_PIN_PULLDOWN
|
||||
#define LF_MOD g_lf_mod
|
||||
#define LF_RSSI_PIN g_lf_rssi_pin
|
||||
#define LF_RSSI g_lf_rssi
|
||||
@@ -85,7 +90,12 @@ extern uint32_t g_reader_power;
|
||||
|
||||
|
||||
void hw_connect_init(void);
|
||||
void init_leds(void);
|
||||
uint32_t* hw_get_led_array(void);
|
||||
uint32_t* hw_get_rgb_array(void);
|
||||
chameleon_device_type_t hw_get_device_type(void);
|
||||
uint8_t hw_get_version_code(void);
|
||||
void set_slot_light_color(uint8_t color);
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user