Compare commits

...

57 Commits

Author SHA1 Message Date
Roy_01 f4972e21f9 Merge branch 'dev/PELv2.0' into vscode 2025-08-29 17:25:17 +08:00
Roy_01 1bc166c936 config: switch project configuration to DEF_ELITE_DEV 2025-08-29 17:25:09 +08:00
Roy_01 6c323cb927 feat: PELv2.0 notify 120 bytes 2025-08-29 17:24:33 +08:00
Roy_01 116ec28fad config: switch project configuration to PEL v2.0 2025-08-29 13:57:05 +08:00
Roy_01 a8caa10431 Merge branch 'dev/PELv3.0' into vscode 2025-08-29 10:10:08 +08:00
Roy_01 a6f3ed642e config: switch project configuration to DEF_ELITE_DEV 2025-08-29 10:09:56 +08:00
Roy_01 f2da6d2624 feat: update PELv3.0 5-channel data(120 bytes) 2025-08-28 17:46:11 +08:00
Roy_01 74b967b5ab style: add Black formatter for Python 2025-08-25 14:33:50 +08:00
Roy_01 cf99f4a2a2 fix: rename DEF_UART_ENABLED to DEF_UARTE_ENABLED 2025-08-20 16:35:18 +08:00
Roy_01 f1d30e5ab7 config: switch project configuration to PEL v3.0 2025-08-20 14:42:36 +08:00
Roy_01 a8f4f331d6 Merge branch 'dev/PELv3.0' into vscode 2025-08-13 17:35:03 +08:00
Roy_01 ecfaeec09a config: switch project configuration to DEF_ELITE_DEV 2025-08-13 17:34:53 +08:00
Roy_01 7d5900b58b fix: ADC pulse config 2025-08-12 15:44:20 +08:00
Roy_01 3603861e0e feat: add INA_HI_PIN to ADC pulse process 2025-08-12 10:40:07 +08:00
Roy_01 e7cbc16a7b config: switch project configuration to PEL v3.0 2025-08-12 09:38:57 +08:00
Roy_01 0f8b8b8454 Merge branch 'dev/PELv3.0' into vscode 2025-08-06 15:39:13 +08:00
Roy_01 0941c9b815 config: switch project configuration to DEF_ELITE_DEV 2025-08-06 15:39:00 +08:00
Roy_01 0f29e19c44 feat:
1. add GPIO feature in dev mode
2. update the dev_mode_input_resistor command
2025-08-06 15:38:23 +08:00
Roy_01 2c5c7e8a62 feat: rename file name and format code 2025-07-30 17:45:25 +08:00
Roy_01 26a02b23ec feat: remove unused function and format code 2025-07-30 16:52:35 +08:00
Roy_01 271257f9bc feat: update PELv3.0 LED and format code 2025-07-30 13:41:21 +08:00
Roy_01 18b07d05e6 fix: rename function and format code 2025-07-29 11:36:48 +08:00
Roy_01 097d589e09 config: switch project configuration to PEL v3.0 2025-07-28 16:21:24 +08:00
charles 2cb1f12c71 Merge branch 'cmake' into vscode 2025-07-23 22:28:11 +08:00
charles 07f80cdaf4 feat: integrate SPIM/TWI drivers and link math/standard libraries 2025-07-23 22:24:26 +08:00
Roy_01 b9cf000fe0 fix: renamed led_rgb.h and updated SDK file references 2025-07-23 16:03:28 +08:00
charles 100a4f5f91 Merge commit '7627b53a93b021b225cf1ee0350465407765accb' into vscode 2025-07-22 23:58:26 +08:00
charles 7627b53a93 feat: export OTA files to output folder after build 2025-07-22 23:58:15 +08:00
charles 6b3b2f0d10 Merge commit '0877359ecc027561f6ce37fddf3678f01e709b21' into vscode 2025-07-22 23:06:11 +08:00
charles 0877359ecc feat: add CMake automation for OTA zip generation 2025-07-22 23:03:59 +08:00
Roy_01 f016799774 Merge branch 'develop/PELv3.0' into vscode 2025-07-17 16:29:57 +08:00
Roy_01 012e1458e1 config: switch project configuration to DEF_ELITE_DEV 2025-07-17 16:29:43 +08:00
Roy_01 fe5c814405 feat: updated dev_identify 2025-07-17 16:29:00 +08:00
Roy_01 7cf17ad98d style: update LED macro 2025-07-17 16:27:23 +08:00
Roy_01 e6091b811e feat: remove led_mode function 2025-07-17 16:25:57 +08:00
Roy_01 67ab93677a feat: new RGB LED function 2025-07-17 16:24:26 +08:00
Roy_01 f1b34e1095 feat: updated load value 2025-07-17 16:20:05 +08:00
Roy_01 9e83dc9184 fix:
1.correct anode/sample_I/sample_V timing
2.include pel_v3_0.h for PELv3.0
2025-07-17 16:19:31 +08:00
Roy_01 73368f35a4 fix: fix memory leak by adjusting stack size from 256 to 320 (256 + 256/4) 2025-07-17 16:18:49 +08:00
Roy_01 b22c53e894 feat: new hot_swap_monitor 2025-07-17 16:18:21 +08:00
Roy_01 b725af593b feat: updated RESET_PIN & CATHODE_PIN & HOT_SWAP_SIGNAL_PIN config 2025-07-17 16:17:43 +08:00
Roy_01 30a543f46a feat: add and modify PEL v3.0 GPIO configuration 2025-07-17 16:16:42 +08:00
Roy_01 3c06aa717b feat: new PEL v3.0 device code 2025-07-17 16:15:15 +08:00
Roy_01 f93ac23469 config: switch project configuration to PEL v3.0 2025-07-17 16:06:58 +08:00
Roy_01 492772a893 config: new DEF_ELITE_PEL_V3_0 config 2025-07-17 15:59:19 +08:00
chain40 ea69255b68 feat: porting for cmake prj 2025-07-16 01:03:40 +08:00
chang.chihchien 7512f2a002 feat: creat vscode workspace 2025-07-06 09:54:16 +08:00
Roy_01 13a3bc2bac config: let each device decide DEF_UARTE_ENABLED 2025-06-12 10:08:27 +08:00
Roy_01 057cd37031 Merge branch 'dev/MMMv1.0' into develp 2025-06-12 10:07:46 +08:00
Roy_01 2fe3c96281 config: switch project configuration to DEF_ELITE_DEV 2025-06-11 16:35:03 +08:00
chain40 8c90802ce3 Merge branch 'ble_uart' into develop 2025-06-10 22:08:42 +08:00
chain40 0cd2355014 fix: Replace custom UUID with BLE UUID for ble uart 2025-06-10 22:08:30 +08:00
Roy_01 41decad72e feat: new MMMv1.0 device 2025-06-04 16:44:38 +08:00
Roy_01 57e6ab5af2 config: new DEF_ELITE_MMM_V1_0 config 2025-06-04 16:20:09 +08:00
chain40 453278fa33 Merge branch 'ble_uart' into develop 2025-05-26 21:00:51 +08:00
chain40 b94ad89af7 fix: use one stop bit 2025-05-26 20:52:01 +08:00
chain40 41227c9877 Merge branch 'ble_uart' into develop 2025-05-21 20:56:22 +08:00
114 changed files with 4025 additions and 4503 deletions
-3
View File
@@ -29,7 +29,6 @@ BinPackParameters: false
BreakBeforeBinaryOperators: None
BreakBeforeTernaryOperators: false
BreakAfterJavaFieldAnnotations: true
AlignConsecutiveAssignments: true
AlignTrailingComments: true
BreakConstructorInitializers: AfterColon
AlignConsecutiveMacros:
@@ -50,6 +49,4 @@ AlignConsecutiveBitFields:
AlignCompound: true
PadOperators: true
AlignEscapedNewlines: Right
BinPackArguments: false
BinPackParameters: false
...
+1
View File
@@ -4,3 +4,4 @@
*.vgdbsettings.*.user
*.zip
/build/
/output/
+74
View File
@@ -0,0 +1,74 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"cwd": "${workspaceRoot}",
"executable": "${command:cmake.launchTargetPath}",
"name": "(Ubuntu) launch & debug",
"request": "launch",
"type": "cortex-debug",
"servertype": "jlink",
"serverpath": "/opt/SEGGER/JLink/JLinkGDBServerCLExe",
"serverArgs": [
"-halt",
"-ir",
"-vd",
"-strict",
],
"rttConfig": {
"enabled": true,
"address": "auto",
"decoders": [
{
"label": "",
"port": 0,
"type": "console"
}
],
},
"armToolchainPath": "/opt/arm-none-eabi/bin",
"device": "NRF52840_XXAA",
"interface": "swd",
"rtos": "FreeRTOS",
"svdFile": "${workspaceRoot}/../bmd380_sdk/modules/nrfx/mdk/nrf52840.svd",
"runToEntryPoint": "main",
"preLaunchTask": "CMake: build"
},
{
"cwd": "${workspaceRoot}",
"executable": "${command:cmake.launchTargetPath}",
"name": "(Windows) launch & debug",
"request": "launch",
"type": "cortex-debug",
"servertype": "jlink",
"serverpath": "C:/Program Files/SEGGER/JLink/JLinkGDBServerCL.exe",
"serverArgs": [
"-halt",
"-ir",
"-vd",
"-strict",
],
"rttConfig": {
"enabled": true,
"address": "auto",
"decoders": [
{
"label": "",
"port": 0,
"type": "console"
}
],
},
"armToolchainPath": "C:/sysgcc/arm-eabi/bin",
"device": "NRF52840_XXAA",
"interface": "swd",
"rtos": "FreeRTOS",
"svdFile": "${workspaceRoot}/../bmd380_sdk/modules/nrfx/mdk/nrf52840.svd",
"runToEntryPoint": "main",
"preLaunchTask": "CMake: build"
},
]
}
+15
View File
@@ -0,0 +1,15 @@
{
"editor.formatOnSave": false,
"[c]": {
"editor.defaultFormatter": "xaver.clang-format",
"editor.formatOnSave": true
},
"[cpp]": {
"editor.defaultFormatter": "xaver.clang-format",
"editor.formatOnSave": true
},
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.formatOnSave": true
}
}
+29
View File
@@ -0,0 +1,29 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "cmake",
"label": "CMake: build",
"command": "build",
"targets": [
"all"
],
"preset": "Debug",
"group": "build",
"problemMatcher": [],
"detail": "CMake template build task"
},
{
"type": "cmake",
"label": "CMake: clean rebuild",
"command": "cleanRebuild",
"targets": [
"all"
],
"preset": "Debug",
"group": "build",
"problemMatcher": [],
"detail": "CMake template clean rebuild task"
}
]
}
+261
View File
@@ -0,0 +1,261 @@
cmake_minimum_required(VERSION 3.10.0)
# ==========================
# Toolchain Setup
# ==========================
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/arm-none-eabi-gcc.cmake)
# ==========================
# Project Setup
# ==========================
project(elite VERSION 0.1.0 LANGUAGES C ASM)
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS ON)
set(EXECUTABLE ${PROJECT_NAME}.elf)
set(NRF_SDK_DIR ${CMAKE_SOURCE_DIR}/../bmd380_sdk)
set(NRF_SDK_LINKER_DIR ${NRF_SDK_DIR}/modules/nrfx/mdk)
set(SD_LINKER_DIR ${CMAKE_SOURCE_DIR}/SoftdeviceLibraries/hard)
set(LINKER_DIR ${CMAKE_SOURCE_DIR}/linkscripts)
set(LINKER_FILE ${LINKER_DIR}/nRF52840_XXAA_S140_reserve.lds)
# ==========================
# Compiler Flags and Defines
# ==========================
set(COMMON_COMPILE_OPT
-mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb
-fdata-sections -ffunction-sections -Wall -Os -g3 -std=gnu99
-Wno-unused-variable -Wno-pointer-sign -Wno-array-bounds
)
set(COMMON_COMPILE_DEF
-DDEBUG=1 -DNRF52840_XXAA -DS140_reserve -DCONFIG_GPIO_AS_PIN
-DRESETHNRF_DFU_SETTINGS_VERSION=2 -DNRF_SD_BLE_API_VERSION=7
-D__STACK_SIZE=1024 -D__HEAP_SIZE=1024 -DARM_MATH_CM4
-DSOFTDEVICE_PRESENT -DUSE_APP_CONFIG
)
set(COMMON_COMPILE_INC
${ARM_TOOLCHAIN_DIR}/../arm-none-eabi/include
${CMAKE_SOURCE_DIR}/app/inc
${NRF_SDK_DIR}/components/ble/ble_db_discovery
${NRF_SDK_DIR}/components/ble/ble_services/ble_dis
${NRF_SDK_DIR}/components/ble/ble_services/ble_dis_c
${NRF_SDK_DIR}/components/ble/common/
${NRF_SDK_DIR}/components/ble/nrf_ble_gatt
${NRF_SDK_DIR}/components/ble/nrf_ble_gq
${NRF_SDK_DIR}/components/ble/nrf_ble_scan
${NRF_SDK_DIR}/components/ble/ble_services/ble_dfu
${NRF_SDK_DIR}/components/ble/ble_advertising
${NRF_SDK_DIR}/components/ble/peer_manager
${NRF_SDK_DIR}/components/libraries/atomic
${NRF_SDK_DIR}/components/libraries/atomic_flags
${NRF_SDK_DIR}/components/libraries/balloc
${NRF_SDK_DIR}/components/libraries/delay
${NRF_SDK_DIR}/components/libraries/experimental_section_vars
${NRF_SDK_DIR}/components/libraries/memobj
${NRF_SDK_DIR}/components/libraries/queue
${NRF_SDK_DIR}/components/libraries/ringbuf
${NRF_SDK_DIR}/components/libraries/strerror
${NRF_SDK_DIR}/components/libraries/util
${NRF_SDK_DIR}/components/libraries/block_dev
${NRF_SDK_DIR}/components/libraries/bootloader
${NRF_SDK_DIR}/components/libraries/bootloader/ble_dfu
${NRF_SDK_DIR}/components/libraries/bootloader/dfu
${NRF_SDK_DIR}/components/libraries/pwr_mgmt
${NRF_SDK_DIR}/components/libraries/usbd
${NRF_SDK_DIR}/components/libraries/usbd/class/cdc
${NRF_SDK_DIR}/components/libraries/usbd/class/cdc/acm
${NRF_SDK_DIR}/components/libraries/usbd/class/nrf_dfu_trigger
${NRF_SDK_DIR}/components/libraries/atomic_fifo
${NRF_SDK_DIR}/components/libraries/svc
${NRF_SDK_DIR}/components/libraries/mutex
${NRF_SDK_DIR}/components/softdevice/common
${NRF_SDK_DIR}/components/softdevice/mbr/headers
${NRF_SDK_DIR}/components/softdevice/s140/headers
${NRF_SDK_DIR}/components/toolchain/cmsis/include
${NRF_SDK_DIR}/modules/nrfx
${NRF_SDK_DIR}/modules/nrfx/hal
${NRF_SDK_DIR}/modules/nrfx/mdk
${NRF_SDK_DIR}/modules/nrfx/drivers/include
${NRF_SDK_DIR}/external/fprintf
${NRF_SDK_DIR}/external/segger_rtt
${NRF_SDK_DIR}/external/utf_converter
${NRF_SDK_DIR}/integration/nrfx
${NRF_SDK_DIR}/integration/nrfx/legacy
)
# ==========================
# Configuration Interface
# ==========================
add_library(prj_config INTERFACE)
target_include_directories(prj_config INTERFACE ${COMMON_COMPILE_INC})
target_compile_definitions(prj_config INTERFACE ${COMMON_COMPILE_DEF})
target_compile_options(prj_config INTERFACE ${COMMON_COMPILE_OPT})
# ==========================
# Subdirectories
# ==========================
include(cmake/littlefs.cmake)
include(cmake/freertos.cmake)
include(cmake/nrf_log.cmake)
# ==========================
# Source Files
# ==========================
set(STARTUP_SRC
${NRF_SDK_DIR}/modules/nrfx/mdk/gcc_startup_nrf52840.S
${NRF_SDK_DIR}/modules/nrfx/mdk/system_nrf52.c
)
set(UTILS_SRC
${NRF_SDK_DIR}/components/libraries/util/nrf_assert.c
${NRF_SDK_DIR}/components/libraries/util/app_error.c
${NRF_SDK_DIR}/components/libraries/util/app_error_handler_gcc.c
${NRF_SDK_DIR}/components/libraries/util/app_error_weak.c
${NRF_SDK_DIR}/components/libraries/util/app_util_platform.c
${NRF_SDK_DIR}/components/libraries/strerror/nrf_strerror.c
${NRF_SDK_DIR}/components/libraries/pwr_mgmt/nrf_pwr_mgmt.c
)
set(ATOMIC_SRC
${NRF_SDK_DIR}/components/libraries/atomic/nrf_atomic.c
${NRF_SDK_DIR}/components/libraries/atomic_fifo/nrf_atfifo.c
${NRF_SDK_DIR}/components/libraries/atomic_flags/nrf_atflags.c
${NRF_SDK_DIR}/components/libraries/memobj/nrf_memobj.c
${NRF_SDK_DIR}/components/libraries/balloc/nrf_balloc.c
${NRF_SDK_DIR}/components/libraries/ringbuf/nrf_ringbuf.c
)
set(USBD_SRC
${NRF_SDK_DIR}/components/libraries/usbd/app_usbd.c
${NRF_SDK_DIR}/components/libraries/usbd/app_usbd_core.c
${NRF_SDK_DIR}/components/libraries/usbd/app_usbd_serial_num.c
${NRF_SDK_DIR}/components/libraries/usbd/app_usbd_string_desc.c
${NRF_SDK_DIR}/components/libraries/usbd/class/cdc/acm/app_usbd_cdc_acm.c
${NRF_SDK_DIR}/components/libraries/usbd/class/nrf_dfu_trigger/app_usbd_nrf_dfu_trigger.c
)
set(SOFTDEVICE_SRC
${NRF_SDK_DIR}/components/softdevice/common/nrf_sdh.c
${NRF_SDK_DIR}/components/softdevice/common/nrf_sdh_freertos.c
${NRF_SDK_DIR}/components/softdevice/common/nrf_sdh_ble.c
)
set(BLE_SRC
${NRF_SDK_DIR}/components/ble/common/ble_advdata.c
${NRF_SDK_DIR}/components/ble/common/ble_conn_state.c
${NRF_SDK_DIR}/components/ble/common/ble_srv_common.c
${NRF_SDK_DIR}/components/ble/ble_advertising/ble_advertising.c
${NRF_SDK_DIR}/components/ble/ble_services/ble_dis/ble_dis.c
${NRF_SDK_DIR}/components/ble/ble_services/ble_dfu/ble_dfu.c
${NRF_SDK_DIR}/components/ble/ble_services/ble_dfu/ble_dfu_unbonded.c
${NRF_SDK_DIR}/components/ble/nrf_ble_gatt/nrf_ble_gatt.c
)
set(PRINTF_SRC
${NRF_SDK_DIR}/external/fprintf/nrf_fprintf.c
${NRF_SDK_DIR}/external/fprintf/nrf_fprintf_format.c
${NRF_SDK_DIR}/external/segger_rtt/SEGGER_RTT.c
${NRF_SDK_DIR}/external/segger_rtt/SEGGER_RTT_printf.c
)
set(NRFX_DRIVERS_SRC
${NRF_SDK_DIR}/modules/nrfx/drivers/src/nrfx_clock.c
${NRF_SDK_DIR}/modules/nrfx/drivers/src/nrfx_power.c
${NRF_SDK_DIR}/modules/nrfx/drivers/src/nrfx_usbd.c
${NRF_SDK_DIR}/modules/nrfx/drivers/src/nrfx_gpiote.c
${NRF_SDK_DIR}/modules/nrfx/soc/nrfx_atomic.c
${NRF_SDK_DIR}/modules/nrfx/drivers/src/nrfx_spim.c
${NRF_SDK_DIR}/modules/nrfx/drivers/src/nrfx_twim.c
)
set(NRFX_LEGACY_SRC
${NRF_SDK_DIR}/integration/nrfx/legacy/nrf_drv_clock.c
${NRF_SDK_DIR}/integration/nrfx/legacy/nrf_drv_power.c
${NRF_SDK_DIR}/integration/nrfx/legacy/nrf_drv_spi.c
${NRF_SDK_DIR}/integration/nrfx/legacy/nrf_drv_twi.c
)
set(EXPERIMENTAL_SRC
${NRF_SDK_DIR}/components/libraries/experimental_section_vars/nrf_section_iter.c
)
file(GLOB_RECURSE APP_SOURCES "app/*.c")
# ==========================
# Executable and Linker
# ==========================
add_executable(${EXECUTABLE}
$<TARGET_OBJECTS:lfs>
$<TARGET_OBJECTS:freertos>
$<TARGET_OBJECTS:nrf_log>
${APP_SOURCES}
${STARTUP_SRC}
${UTILS_SRC}
${ATOMIC_SRC}
${USBD_SRC}
${SOFTDEVICE_SRC}
${BLE_SRC}
${PRINTF_SRC}
${NRFX_DRIVERS_SRC}
${NRFX_LEGACY_SRC}
${EXPERIMENTAL_SRC}
${NRF_SDK_DIR}/components/libraries/pwr_mgmt/nrf_pwr_mgmt.c
)
target_link_options(${EXECUTABLE} PRIVATE
-T${LINKER_FILE}
-L${LINKER_DIR}
-L${SD_LINKER_DIR}
-L${NRF_SDK_LINKER_DIR}
-mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb
--specs=nano.specs --specs=nosys.specs -u _printf_float
-lc -lm
-Wl,-Map=${PROJECT_NAME}.map,--cref
-Wl,--gc-sections
-Xlinker -print-memory-usage -Xlinker
)
target_link_libraries(${EXECUTABLE} PRIVATE
prj_config
lfs
freertos
nrf_log
m
c
)
# Optional: Print executable size as part of the post build process
add_custom_command(TARGET ${EXECUTABLE}
POST_BUILD
COMMAND ${CMAKE_SIZE} ${EXECUTABLE})
string(TIMESTAMP BUILD_TIMESTAMP "%Y%m%d%H%M")
set(OTA_ZIP_NAME "ota_${PROJECT_NAME}_${BUILD_TIMESTAMP}.zip")
# Optional: Create hex, bin and S-Record files after the build
add_custom_command(TARGET ${EXECUTABLE}
POST_BUILD
COMMAND ${CMAKE_OBJCOPY} -O srec --srec-len=64 ${EXECUTABLE} ${PROJECT_NAME}.s19
COMMAND ${CMAKE_OBJCOPY} -O ihex ${EXECUTABLE} ${PROJECT_NAME}.hex
COMMAND ${CMAKE_OBJCOPY} -O binary ${EXECUTABLE} ${PROJECT_NAME}.bin
COMMAND nrfutil nrf5sdk-tools pkg generate
--hw-version 52
--sd-req 0x100
--application-version 0
--application ${PROJECT_NAME}.hex
--key-file ${CMAKE_SOURCE_DIR}/private.pem
${OTA_ZIP_NAME}
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_SOURCE_DIR}/output"
COMMAND ${CMAKE_COMMAND} -E rename "${OTA_ZIP_NAME}" "${CMAKE_SOURCE_DIR}/output/${OTA_ZIP_NAME}"
)
+59
View File
@@ -0,0 +1,59 @@
{
"version": 3,
"configurePresets": [
{
"name": "default",
"hidden": true,
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/${presetName}",
"cacheVariables": {
}
},
{
"name": "Debug",
"inherits": "default",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "RelWithDebInfo",
"inherits": "default",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
}
},
{
"name": "Release",
"inherits": "default",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "MinSizeRel",
"inherits": "default",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "MinSizeRel"
}
}
],
"buildPresets": [
{
"name": "Debug",
"configurePreset": "Debug"
},
{
"name": "RelWithDebInfo",
"configurePreset": "RelWithDebInfo"
},
{
"name": "Release",
"configurePreset": "Release"
},
{
"name": "MinSizeRel",
"configurePreset": "MinSizeRel"
}
]
}
-49
View File
@@ -1,49 +0,0 @@
#ifndef __ADC_DRV_H__
#define __ADC_DRV_H__
#ifdef __cplusplus
extern "C" {
#endif
#include "app_config.h"
#include "adc_drv_if.h"
#define ADC_DRV_ERROR (-1)
#define ADC_DRV_SUCCESS (0)
#define AIN0 0
#define AIN1 1
#define AIN2 2
#define AIN3 3
#define AIN4 4
#define AIN5 5
#define AIN6 6
#define AIN7 7
#if (DEF_ADC_DRV_ENABLED)
int adc_init(void);
int adc_reset(void);
int adc_gain(adc_gain_t gain);
int adc_read(uint32_t channel, int32_t *adc_val);
int adc_read_milivolt(uint32_t channel, float *mv);
int adc_read_mutiple_channels(uint32_t *p_channel, int32_t *p_adc_val, uint32_t cnt);
int adc_read_mutiple_channels_ex(uint32_t *p_channel, int32_t *p_adc_val, uint32_t cnt, void (*preliminary_action)(void));
int adc_read_multiple_milivolt_ex(uint32_t *p_channel, float *p_val, uint32_t cnt, void (*preliminary_action)(void));
int adc_read_mutiple_channels_convert_milivolt(int32_t *p_val_14bit, float *p_val_f, uint32_t count);
#else
#define adc_init()
#define adc_reset()
#define adc_gain(x)
#define adc_read(x, y)
#define adc_read_milivolt(x, y)
#define adc_read_mutiple_channels(x, y, z)
#define adc_read_mutiple_channels_ex(x, y, z, a)
#define adc_read_multiple_milivolt_ex(x, y, z, a)
#define adc_read_mutiple_channels_convert_milivolt(x, y, z)
#endif /* ! DEF_ADC_DRV_ENABLED */
#ifdef __cplusplus
}
#endif
#endif /* ! __ADC_DRV_H__ */
-48
View File
@@ -1,48 +0,0 @@
#ifndef __ADC_DRV_IF_H__
#define __ADC_DRV_IF_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stdlib.h>
#define ADC0 (0x01 << 0)
#define ADC1 (0x01 << 1)
#define ADC2 (0x01 << 2)
#define ADC3 (0x01 << 3)
typedef enum
{
GAIN_0P625,
GAIN_1P000,
GAIN_1P200,
GAIN_1P250,
GAIN_1P500,
GAIN_2P000,
GAIN_2P500,
GAIN_3P000,
GAIN_6P000,
GAIN_12P000,
GAIN_24P000,
} adc_gain_t;
typedef struct
{
int (*init)(void);
int (*reset)(void);
int (*read)(uint32_t channel, int32_t *adc_val);
int (*read_milivolt)(uint32_t channel, float *p_val);
int (*read_multiple_milivolt_ex)(uint32_t *p_channels, float *p_val, uint32_t count, void (*preliminary_action));
int (*read_multiple_channels)(uint32_t *p_channels, int32_t *adc_val, uint32_t count);
int (*read_multiple_channels_ex)(uint32_t *p_channels, int32_t *adc_val, uint32_t count, void (*preliminary_action)(void));
int (*gain)(adc_gain_t gain);
int (*adc_convert_multiple_milivolt)(int32_t *p_val_14bit, float *p_val_f, uint32_t count);
} adc_drv_if_t;
#ifdef __cplusplus
}
#endif
#endif /* ! __ADC_DRV_IF_H__ */
+39
View File
@@ -0,0 +1,39 @@
#ifndef __ADC_DRV_H__
#define __ADC_DRV_H__
#ifdef __cplusplus
extern "C"
{
#endif
#include "app_config.h"
#include "adc_drv_if.h"
#if (DEF_ADC_DRV_ENABLED)
int adc_init(void);
int adc_reset(void);
int adc_gain(adc_gain_t gain);
int adc_read(uint32_t channel, int32_t *adc_val);
int adc_read_milivolt(uint32_t channel, float *mv);
int adc_read_mutiple_channels(uint32_t *p_channel, int32_t *p_adc_val, uint32_t cnt);
int adc_read_mutiple_channels_ex(uint32_t *p_channel, int32_t *p_adc_val, uint32_t cnt, void (*preliminary_action)(void));
int adc_read_multiple_milivolt_ex(uint32_t *p_channel, float *p_val, uint32_t cnt, void (*preliminary_action)(void));
int adc_read_mutiple_channels_convert_milivolt(int32_t *p_val_14bit, float *p_val_f, uint32_t count);
#else
#define adc_init()
#define adc_reset()
#define adc_gain(x)
#define adc_read(x, y)
#define adc_read_milivolt(x, y)
#define adc_read_mutiple_channels(x, y, z)
#define adc_read_mutiple_channels_ex(x, y, z, a)
#define adc_read_multiple_milivolt_ex(x, y, z, a)
#define adc_read_mutiple_channels_convert_milivolt(x, y, z)
#endif /* ! DEF_ADC_DRV_ENABLED */
#ifdef __cplusplus
}
#endif
#endif /* ! __ADC_DRV_H__ */
+46
View File
@@ -0,0 +1,46 @@
#ifndef __ADC_DRV_IF_H__
#define __ADC_DRV_IF_H__
#ifdef __cplusplus
extern "C"
{
#endif
#include <stdint.h>
#define ADC_DRV_ERROR (-1)
#define ADC_DRV_SUCCESS (0)
typedef enum
{
GAIN_0P625,
GAIN_1P000,
GAIN_1P200,
GAIN_1P250,
GAIN_1P500,
GAIN_2P000,
GAIN_2P500,
GAIN_3P000,
GAIN_6P000,
GAIN_12P000,
GAIN_24P000,
} adc_gain_t;
typedef struct
{
int (*init)(void);
int (*reset)(void);
int (*read)(uint32_t channel, int32_t *adc_val);
int (*read_milivolt)(uint32_t channel, float *p_val);
int (*read_multiple_milivolt_ex)(uint32_t *p_channels, float *p_val, uint32_t count, void(*preliminary_action));
int (*read_multiple_channels)(uint32_t *p_channels, int32_t *adc_val, uint32_t count);
int (*read_multiple_channels_ex)(uint32_t *p_channels, int32_t *adc_val, uint32_t count, void (*preliminary_action)(void));
int (*gain)(adc_gain_t gain);
int (*adc_convert_multiple_milivolt)(int32_t *p_val_14bit, float *p_val_f, uint32_t count);
} adc_drv_if_t;
#ifdef __cplusplus
}
#endif
#endif /* ! __ADC_DRV_IF_H__ */
View File
View File
+5 -4
View File
@@ -2,16 +2,17 @@
#define __APA102_2020_H__
#ifdef __cplusplus
extern "C" {
extern "C"
{
#endif
#include "app_config.h"
#include "elite_board.h"
#include "led_drv_if.h"
#if (DEF_APA102_2020_ENABLED)
extern const led_drv_if_t apa102_drv;
#include "led_drv_if.h"
extern const led_drv_if_t apa102_drv;
#endif /* ! DEF_APA102_2020_ENABLED */
+98 -5
View File
@@ -108,7 +108,9 @@ extern "C"
#define DEF_ELITE_DEV 0x00000000
#define DEF_ELITE_EDC_V2_0 0x00020109
#define DEF_ELITE_PEL_V2_0 0x00070001
#define DEF_ELITE_PEL_V3_0 0x00070002
#define DEF_ELITE_CPG_V1_1 0x00080001
#define DEF_ELITE_MMM_V1_0 0x00090001
#define DEF_ELITE_MODEL DEF_ELITE_DEV
#define DEF_ELITE_DEMO_W_SOFTDEVICE 0
@@ -123,9 +125,10 @@ extern "C"
#define DEF_TW1508_ENABLED 0
#define DEF_LED_COUNT 0
#define DEF_LED_DRV_ENABLED 0
#define DEF_LED_COUNT 0
#define DEF_APA102_2020_ENABLED 0
#define DEF_RGB_ENABLED 0
#define DEF_ADC_DRV_ENABLED 0
#define DEF_ADS8691_ENABLED 0
@@ -148,6 +151,8 @@ extern "C"
#define DEF_USBD_ENABLED 1
#define DEF_UARTE_ENABLED 0
#elif (DEF_ELITE_MODEL == DEF_ELITE_EDC_V2_0)
#define ELITE_DEVICE_NAME "Elite-EDC"
#define ELITE_HW_NAME "Elite-EDCv2.0"
@@ -158,9 +163,10 @@ extern "C"
#define DEF_TW1508_ENABLED 0
#define DEF_LED_COUNT 12
#define DEF_LED_DRV_ENABLED 1
#define DEF_LED_COUNT 12
#define DEF_APA102_2020_ENABLED 1
#define DEF_RGB_ENABLED 0
#define DEF_ADC_DRV_ENABLED 1
#define DEF_ADS8691_ENABLED 1
@@ -183,6 +189,8 @@ extern "C"
#define DEF_USBD_ENABLED 1
#define DEF_UARTE_ENABLED 0
#elif (DEF_ELITE_MODEL == DEF_ELITE_PEL_V2_0)
#define BOARD_IOPH 1
#define BOARD_IOPL 0
@@ -197,9 +205,10 @@ extern "C"
#define DEF_TW1508_ENABLED 0
#define DEF_LED_COUNT 0
#define DEF_LED_DRV_ENABLED 0
#define DEF_LED_COUNT 0
#define DEF_APA102_2020_ENABLED 0
#define DEF_RGB_ENABLED 0
#define DEF_ADC_DRV_ENABLED 1
#define DEF_ADS8691_ENABLED 0
@@ -222,6 +231,50 @@ extern "C"
#define DEF_USBD_ENABLED 1
#define DEF_UARTE_ENABLED 0
#elif (DEF_ELITE_MODEL == DEF_ELITE_PEL_V3_0)
#define BOARD_IOPH 1
#define BOARD_IOPL 0
#define ELITE_DEVICE_NAME "Elite-PEL"
#define ELITE_HW_NAME "Elite-PELv3.0"
#define BOARD_IOPx BOARD_IOPH
#define MAJOR_PRODUCT_NUMBER 0
#define MINOR_PRODUCT_NUMBER 7
#define MAJOR_VERSION_NUMBER 0
#define MINOR_VERSION_NUMBER 2
#define DEF_TW1508_ENABLED 0
#define DEF_LED_DRV_ENABLED 1
#define DEF_LED_COUNT 1
#define DEF_APA102_2020_ENABLED 0
#define DEF_RGB_ENABLED 1
#define DEF_ADC_DRV_ENABLED 1
#define DEF_ADS8691_ENABLED 0
#define DEF_BULTIN_ADC_ENABED 1
#define DEF_DAC_DRV_ENABLED 0
#define DEF_MAX5136_ENABLED 0
#define DEF_SW_DRV_ENABLED 0
#define DEF_MAX14802_ENABLED 0
#define DEF_ADGS1412_ENABLED 0
#define DEF_FS_ENABLED 0
#define DEF_FS_RTT_DIR 0
#define DEF_GD25D10C_ENABLED 0
#define DEF_BTN_ENABLED 0
#define DEF_RTT_JSCOP_ENABLED 0
#define DEF_USBD_ENABLED 1
#define DEF_UARTE_ENABLED 0
#elif (DEF_ELITE_MODEL == DEF_ELITE_CPG_V1_1)
#define ELITE_DEVICE_NAME "Elite-CPG"
#define ELITE_HW_NAME "Elite-CPGv1.1"
@@ -232,9 +285,10 @@ extern "C"
#define DEF_TW1508_ENABLED 1
#define DEF_LED_COUNT 0
#define DEF_LED_DRV_ENABLED 0
#define DEF_LED_COUNT 0
#define DEF_APA102_2020_ENABLED 0
#define DEF_RGB_ENABLED 0
#define DEF_ADC_DRV_ENABLED 0
#define DEF_ADS8691_ENABLED 0
@@ -257,6 +311,46 @@ extern "C"
#define DEF_USBD_ENABLED 1
#define DEF_UARTE_ENABLED 0
#elif (DEF_ELITE_MODEL == DEF_ELITE_MMM_V1_0)
#define ELITE_DEVICE_NAME "Elite-MMM"
#define ELITE_HW_NAME "Elite-MMM"
#define MAJOR_PRODUCT_NUMBER 0
#define MINOR_PRODUCT_NUMBER 9
#define MAJOR_VERSION_NUMBER 0
#define MINOR_VERSION_NUMBER 1
#define DEF_TW1508_ENABLED 0
#define DEF_LED_DRV_ENABLED 0
#define DEF_LED_COUNT 0
#define DEF_APA102_2020_ENABLED 0
#define DEF_RGB_ENABLED 0
#define DEF_ADC_DRV_ENABLED 0
#define DEF_ADS8691_ENABLED 0
#define DEF_BULTIN_ADC_ENABED 0
#define DEF_DAC_DRV_ENABLED 0
#define DEF_MAX5136_ENABLED 0
#define DEF_SW_DRV_ENABLED 0
#define DEF_MAX14802_ENABLED 0
#define DEF_ADGS1412_ENABLED 0
#define DEF_FS_ENABLED 0
#define DEF_FS_RTT_DIR 0
#define DEF_GD25D10C_ENABLED 0
#define DEF_BTN_ENABLED 0
#define DEF_RTT_JSCOP_ENABLED 0
#define DEF_USBD_ENABLED 1
#define DEF_UARTE_ENABLED 1
#endif
#define BLE_ELITE_SRV_ENABLED 1
@@ -294,7 +388,6 @@ extern "C"
#define BLE_UART_SRV_ENABLED 1
#define BLE_UART_OBSERVER_PRIO 3
#define NRF_UARTE_ENABLED 1
#define DEF_UARTE_ENABLED 1
// DFU
#define NRF_DFU_TRANSPORT_BLE 1
View File
View File
+10 -2
View File
@@ -7,9 +7,10 @@ extern "C"
#endif
#include "app_config.h"
#include "app_error.h"
#include "elite_def.h"
#include "elite.h"
#include "app_error.h"
void elite_init(void);
void elite_instr_send(void *p, size_t size);
@@ -17,6 +18,13 @@ extern "C"
ret_code_t le_event_notify(uint8_t *p_value, uint16_t len);
ret_code_t le_event_async_notify(uint8_t *p_value, uint16_t len, uint32_t ms_to_wait);
typedef struct
{
void (*cis_func[256])(uint8_t *ins, uint16_t size);
void (*vis_func[256])(uint8_t *ins, uint16_t size);
void (*ris_func[256])(uint8_t *ins, uint16_t size);
} elite_instance_t;
#ifdef __cplusplus
}
#endif
+6 -3
View File
@@ -18,11 +18,14 @@ extern "C"
#if (DEF_ELITE_MODEL == DEF_ELITE_DEV)
#elif (DEF_ELITE_MODEL == DEF_ELITE_EDC_V2_0)
#include "edc20_io.h"
#include "elite_edc_v2_0_io.h"
#elif (DEF_ELITE_MODEL == DEF_ELITE_PEL_V2_0)
#include "pel20_io.h"
#include "elite_pel_v2_0_io.h"
#elif (DEF_ELITE_MODEL == DEF_ELITE_PEL_V3_0)
#include "elite_pel_v3_0_io.h"
#elif (DEF_ELITE_MODEL == DEF_ELITE_CPG_V1_1)
#include "cpg11_io.h"
#include "elite_cpg_v1_1_io.h"
#elif (DEF_ELITE_MODEL == DEF_ELITE_MMM_V1_0)
#else
#error "Not implemented xxx_io.h"
#endif
View File
+3 -2
View File
@@ -2,13 +2,14 @@
#define __ELITE_DEV_H__
#ifdef __cplusplus
extern "C" {
extern "C"
{
#endif
#include "app_config.h"
#include "elite.h"
const elite_instance_t *dev_init(void);
const elite_instance_t *dev_init(void);
#ifdef __cplusplus
}
+48
View File
@@ -0,0 +1,48 @@
#ifndef __EDC_H__
#define __EDC_H__
#ifdef __cplusplus
extern "C"
{
#endif
#include "app_config.h"
#if (DEF_ELITE_MODEL == DEF_ELITE_EDC_V2_0)
#include "dac_drv.h"
#include "elite.h"
#include <stdbool.h>
#include <stdint.h>
typedef struct
{
void (*init)(void);
elite_instance_t *p_elite_instance;
} edc20_t;
typedef struct
{
struct
{
float coeff;
float offset;
} dac_c;
struct
{
float coeff;
float offset;
float Voffset;
} dac_f[3];
} edc20_dac_cal_data_t;
extern edc20_t edc;
#endif
#ifdef __cplusplus
}
#endif
#endif /* ! __EDC_H__ */
+43 -41
View File
@@ -2,12 +2,14 @@
#define __EDC20_IO_H__
#ifdef __cplusplus
extern "C" {
extern "C"
{
#endif
#include <stdint.h>
#include "nrf_drv_spi.h"
#include "nrf_gpio.h"
#include <stdint.h>
#define ADCA2_PIN NRF_GPIO_PIN_MAP(0, 25)
#define ADCA1_PIN NRF_GPIO_PIN_MAP(0, 19)
@@ -45,51 +47,51 @@ extern "C" {
#define SPIM_MOSI_PIN NRF_GPIO_PIN_MAP(0, 7)
#define SPIM_MISO_PIN NRF_GPIO_PIN_MAP(1, 9)
typedef struct
{
float mV_start;
float mV_stop;
float mV_step;
uint32_t uS_step;
uint32_t cycles;
bool hi_z_en;
} elite_dac_config_t;
typedef struct
{
float mV_start;
float mV_stop;
float mV_step;
uint32_t uS_step;
uint32_t cycles;
bool hi_z_en;
} elite_dac_config_t;
void gpio_init(void);
void circuit_selection_vin_0(void);
void circuit_selection_vin_1(void);
void circuit_selection_vin_2(void);
void circuit_selection_Iin_0(void);
void circuit_selection_Iin_1(void);
void circuit_selection_Iin_2(void);
void circuit_selection_Iin_3(void);
void circuit_selection_Iin_4(void);
void circuit_selection_dac_coarse_tune_c(void);
void circuit_selection_dac_fine_tune_f0(void);
void circuit_selection_dac_fine_tune_f1(void);
void circuit_selection_dac_fine_tune_f2(void);
void circuit_selection_cv3_config(void);
void circuit_selection_cc_config(void);
void circuit_selection_dac_circuit_open(void);
void gpio_init(void);
void circuit_selection_vin_0(void);
void circuit_selection_vin_1(void);
void circuit_selection_vin_2(void);
void circuit_selection_Iin_0(void);
void circuit_selection_Iin_1(void);
void circuit_selection_Iin_2(void);
void circuit_selection_Iin_3(void);
void circuit_selection_Iin_4(void);
void circuit_selection_dac_coarse_tune_c(void);
void circuit_selection_dac_fine_tune_f0(void);
void circuit_selection_dac_fine_tune_f1(void);
void circuit_selection_dac_fine_tune_f2(void);
void circuit_selection_cv3_config(void);
void circuit_selection_cc_config(void);
void circuit_selection_dac_circuit_open(void);
void twi_init(void);
void twi0_write_reg(uint8_t slave_addr, uint8_t reg_addr, uint8_t *data, uint8_t data_len);
void twi0_read_reg(uint8_t slave_addr, uint8_t reg_addr, uint8_t *p_rx_buf, uint8_t rx_buffer_length);
void twi_init(void);
void twi0_write_reg(uint8_t slave_addr, uint8_t reg_addr, uint8_t *data, uint8_t data_len);
void twi0_read_reg(uint8_t slave_addr, uint8_t reg_addr, uint8_t *p_rx_buf, uint8_t rx_buffer_length);
void spi_init(void);
void spi1_write(uint8_t *p_tx_buffer, uint16_t tx_buffer_length);
void spim_xfer(uint32_t cs_pin, nrf_spim_mode_t mode, uint8_t *p_tx_buffer, uint16_t tx_buffer_length, uint8_t *p_rx_buf, uint16_t rx_buffer_length);
void spi2_set_mode(nrf_drv_spi_mode_t mode);
void spi_init(void);
void spi1_write(uint8_t *p_tx_buffer, uint16_t tx_buffer_length);
void spim_xfer(uint32_t cs_pin, nrf_spim_mode_t mode, uint8_t *p_tx_buffer, uint16_t tx_buffer_length, uint8_t *p_rx_buf, uint16_t rx_buffer_length);
void spi2_set_mode(nrf_drv_spi_mode_t mode);
void edc20_io_init(void);
void edc20_io_power_off(void);
void edc20_io_power_on(void);
void edc20_io_init(void);
void edc20_io_power_off(void);
void edc20_io_power_on(void);
void edc20_dac_tim_start(uint32_t period, void (*callback)(void *p_arg), void *p_arg);
void edc20_dac_tim_stop(void);
void edc20_dac_tim_start(uint32_t period, void (*callback)(void *p_arg), void *p_arg);
void edc20_dac_tim_stop(void);
void edc20_adc_tim_start(elite_dac_config_t *p_config);
void edc20_adc_tim_stop(void);
void edc20_adc_tim_start(elite_dac_config_t *p_config);
void edc20_adc_tim_stop(void);
#ifdef __cplusplus
}
+18
View File
@@ -0,0 +1,18 @@
#ifndef __ELITE_MMM_H__
#define __ELITE_MMM_H__
#ifdef __cplusplus
extern "C"
{
#endif
#include "app_config.h"
#include "elite.h"
const elite_instance_t *mmm_init(void);
#ifdef __cplusplus
}
#endif
#endif /* ! __ELITE_MMM_H__ */
+29 -18
View File
@@ -1,5 +1,5 @@
#ifndef __PEL_H__
#define __PEL_H__
#ifndef __ELITE_PEL_V2_0_H__
#define __ELITE_PEL_V2_0_H__
#ifdef __cplusplus
extern "C"
@@ -11,10 +11,10 @@ extern "C"
#include "elite_board.h"
#define VERSION_DATE_YEAR 25
#define VERSION_DATE_MONTH 3
#define VERSION_DATE_DAY 31
#define VERSION_DATE_HOUR 10
#define VERSION_DATE_MINUTE 45
#define VERSION_DATE_MONTH 8
#define VERSION_DATE_DAY 29
#define VERSION_DATE_HOUR 17
#define VERSION_DATE_MINUTE 24
#define PEL_0P5R_MASK (0x01 << 0)
#define PEL_1P0R_MASK (0x01 << 1)
@@ -31,23 +31,34 @@ extern "C"
typedef struct __PACKED
{
uint16_t mem_board_id : 8;
uint16_t packet_seq : 8;
uint16_t mem_board_id;
uint16_t packet_seq;
uint32_t notify_time;
int32_t output_vo_raw;
int32_t output_vc_raw;
int32_t output_ve_raw;
float hold_OUT_v;
float hold_VCC_v;
float hold_VEE_v;
int32_t raw_output_r1;
int32_t raw_output_r2;
int32_t raw_output_vo;
int32_t raw_output_vc;
int32_t raw_output_ve;
float output_r1_mv;
float output_r2_mv;
float output_vo_mv;
float output_vc_mv;
float output_ve_mv;
float hold_r1_v;
float hold_r2_v;
float hold_out_v;
float hold_vcc_v;
float hold_vee_v;
float current;
uint16_t resis_pattern_id;
uint16_t resis_bitsmask;
float resis_g_value;
uint32_t mode_complete : 4;
uint32_t rsvd : 28;
uint32_t val_1;
uint32_t val_2;
uint16_t val_3;
uint32_t payload[9];
} scan_mode_notify_packet_t;
const elite_instance_t *pel_init(void);
@@ -56,4 +67,4 @@ extern "C"
}
#endif
#endif /* ! __PEL_H__ */
#endif /* ! __ELITE_PEL_V2_0_H__ */
+69
View File
@@ -0,0 +1,69 @@
#ifndef __PEL_V3_0_H__
#define __PEL_V3_0_H__
#ifdef __cplusplus
extern "C"
{
#endif
#include "app_config.h"
#include "elite.h"
#include "elite_board.h"
#define VERSION_DATE_YEAR 25
#define VERSION_DATE_MONTH 8
#define VERSION_DATE_DAY 28
#define VERSION_DATE_HOUR 17
#define VERSION_DATE_MINUTE 46
#define PEL_0P5R_MASK (0x01 << 0)
#define PEL_1P0R_MASK (0x01 << 1)
#define PEL_2P0R_MASK (0x01 << 2)
#define PEL_4P0R_MASK (0x01 << 3)
#define PEL_8P0R_MASK (0x01 << 4)
#define PEL_16P2R_MASK (0x01 << 5)
#define PEL_32P4R_MASK (0x01 << 6)
#define PEL_63P4R_MASK (0x01 << 7)
#define PEL_127R_MASK (0x01 << 8)
#define PEL_255R_MASK (0x01 << 9)
#define PEL_511R_MASK (0x01 << 10)
#define PEL_1000R_MASK (0x01 << 11)
typedef struct __PACKED
{
uint16_t mem_board_id;
uint16_t packet_seq;
uint32_t notify_time;
int32_t raw_acs37030_vref;
int32_t raw_i_out;
int32_t raw_output_vo;
int32_t raw_output_vc;
int32_t raw_output_ve;
float acs37030_vref_mv;
float i_out_mv;
float output_vo_mv;
float output_vc_mv;
float output_ve_mv;
float acs37030_vref_v;
float hold_acs37030_out_v;
float hold_out_v;
float hold_vcc_v;
float hold_vee_v;
float acs37030_current_a;
uint16_t resis_pattern_id;
uint16_t resis_bitsmask;
float resis_g_value;
uint32_t mode_complete : 4;
uint32_t rsvd : 28;
uint32_t payload[9];
} scan_mode_notify_packet_t;
const elite_instance_t *pel_init(void);
#ifdef __cplusplus
}
#endif
#endif /* ! __PEL_V3_0_H__ */
+129
View File
@@ -0,0 +1,129 @@
#ifndef __PEL_V3_0_IO_H__
#define __PEL_V3_0_IO_H__
#ifdef __cplusplus
extern "C"
{
#endif
#include "app_config.h"
#include "elite_board.h"
#include "nrf_gpio.h"
#include "nrf_saadc.h"
#include "nrf_spim.h"
#if (DEF_ELITE_MODEL == DEF_ELITE_PEL_V3_0)
#define INPUT_1_PIN NRF_GPIO_PIN_MAP(0, 15)
#define INPUT_2_PIN NRF_GPIO_PIN_MAP(0, 13)
#define INPUT_3_PIN NRF_GPIO_PIN_MAP(0, 20)
#define INPUT_4_PIN NRF_GPIO_PIN_MAP(1, 0)
#define INPUT_5_PIN NRF_GPIO_PIN_MAP(0, 25)
#define INPUT_6_PIN NRF_GPIO_PIN_MAP(0, 11)
#define INPUT_7_PIN NRF_GPIO_PIN_MAP(0, 14)
#define INPUT_8_PIN NRF_GPIO_PIN_MAP(0, 17)
#define INPUT_9_PIN NRF_GPIO_PIN_MAP(1, 8)
#define INPUT_10_PIN NRF_GPIO_PIN_MAP(0, 21)
#define INPUT_11_PIN NRF_GPIO_PIN_MAP(0, 19)
#define INPUT_12_PIN NRF_GPIO_PIN_MAP(0, 22)
#define RESET_PIN NRF_GPIO_PIN_MAP(0, 18)
#define TP1_PIN NRF_GPIO_PIN_MAP(0, 5)
#define TP2_PIN NRF_GPIO_PIN_MAP(0, 26)
#define SAMPLE_I_PIN NRF_GPIO_PIN_MAP(1, 11)
#define SAMPLE_V_PIN NRF_GPIO_PIN_MAP(1, 6)
#define ANODE_PIN NRF_GPIO_PIN_MAP(0, 7)
#define CATHODE_PIN NRF_GPIO_PIN_MAP(0, 8)
#define HOT_SWAP_1_PIN NRF_GPIO_PIN_MAP(0, 1)
#define HOT_SWAP_SIGNAL_PIN NRF_GPIO_PIN_MAP(0, 0)
#define INA_HI_PIN NRF_GPIO_PIN_MAP(1, 12)
#define WP_MEM_PIN NRF_GPIO_PIN_MAP(0, 12)
#define CS_MEM_PIN NRF_GPIO_PIN_MAP(0, 6)
#define SPIM_MOSI_PIN NRF_GPIO_PIN_MAP(0, 27)
#define SPIM_CLK_PIN NRF_GPIO_PIN_MAP(0, 4)
#define SPIM_MISO_PIN NRF_GPIO_PIN_MAP(1, 9)
#define LED_IOPL_PIN NRF_GPIO_PIN_MAP(0, 24) // pin60
#define LED_IOPH_PIN NRF_GPIO_PIN_MAP(0, 16) // pin62
#define LED_R_PINS \
{ \
NRF_GPIO_PIN_MAP(1, 13) \
}
#define LED_G_PINS \
{ \
NRF_GPIO_PIN_MAP(1, 3) \
}
#define LED_B_PINS \
{ \
NRF_GPIO_PIN_MAP(1, 10) \
}
#define OUTPUT_ACS37030_VREF_CHANNEL 7
#define OUTPUT_I_OUT_CHANNEL 4
#define OUTPUT_VO_CHANNEL 5
#define OUTPUT_VC_CHANNEL 0
#define OUTPUT_VE_CHANNEL 1
#define OUTPUT_ACS37030_REF_IDX 0
#define OUTPUT_I_OUT_IDX 1
#define OUTPUT_VO_IDX 2
#define OUTPUT_VC_IDX 3
#define OUTPUT_VE_IDX 4
typedef struct
{
uint32_t anode_pin;
uint32_t ina_hi_pin;
uint32_t smaple_i_pin;
uint32_t sample_v_pin;
uint32_t test_pin;
uint32_t point_us[5]; // toggle point timestamp
uint32_t pulse_cnt; // min: 1, max: 0xFFFFFFFF
uint32_t mode; // 0: IOPL mode, 1: IOPH mode
nrf_saadc_gain_t gain;
nrf_saadc_acqtime_t smaple_time;
int32_t adc_timing_shift;
void (*convt_new_arrival_cb)(void);
} pel_config_t;
typedef struct
{
nrf_saadc_gain_t gain;
nrf_saadc_acqtime_t smaple_time;
uint32_t channels[5];
int16_t results[5];
float results_f[5];
void (*convt_new_arrival_cb)(void);
} pel_adc_t;
typedef struct
{
NRF_TIMER_Type *pulse_tmr;
uint32_t pulse_irq_n;
uint32_t pulse_cnt;
uint32_t pulse_is_running;
pel_adc_t adc;
} pel_hw_t;
extern pel_hw_t pel_hw;
void spim_xfer(uint32_t cs_pin,
nrf_spim_mode_t spi_mode,
uint8_t *p_tx_buffer,
uint16_t tx_buffer_length,
uint8_t *p_rx_buf,
uint16_t rx_buffer_length);
void pel30_io_init(void);
void pel_pulse_gen_init(pel_config_t cfg);
void pel_pulse_gen_start(void);
void pel_pulse_gen_stop(void);
#endif /* ! DEF_ELITE_MODEL */
#ifdef __cplusplus
}
#endif
#endif /* ! __PEL_V3_0_IO_H__ */
View File
View File
+33 -27
View File
@@ -2,7 +2,8 @@
#define __LED_DRV_H__
#ifdef __cplusplus
extern "C" {
extern "C"
{
#endif
#include "app_config.h"
@@ -11,6 +12,7 @@ extern "C" {
#define LED_DRV_ERROR (-1)
#define LED_DRV_SUCCESS (0)
#if (DEF_APA102_2020_ENABLED)
#define LED_NONE \
(struct led_color) \
{ \
@@ -51,41 +53,45 @@ extern "C" {
{ \
.R = 0xFF, .G = 0x00, .B = 0xFF \
}
#define LED_ORANGE \
(struct led_color) \
{ \
.R = 0xFF, .G = 0x58, .B = 0x09 \
}
#define LED_OFF LED_NONE
#define LED_ON LED_GREEN
#define LED_ERROR LED_RED
#define LED_IDEL_DISCONNECT LED_YELLOW
#define LED_IDEL_CONNECTED LED_GREEN
#define LED_REC LED_CYAN
#define LED_IDENTICY_DEV LED_PURPLE
#define LED_BUTTON_PRESS LED_YELLOW
#elif (DEF_RGB_ENABLED)
#define LED_NONE \
(struct led_color) { .R = 0, .G = 0, .B = 0 }
#define LED_RED \
(struct led_color) { .R = 1, .G = 0, .B = 0 }
#define LED_YELLOW \
(struct led_color) { .R = 1, .G = 1, .B = 0 }
#define LED_WHITE \
(struct led_color) { .R = 1, .G = 1, .B = 1 }
#define LED_GREEN \
(struct led_color) { .R = 0, .G = 1, .B = 0 }
#define LED_CYAN \
(struct led_color) { .R = 0, .G = 1, .B = 1 }
#define LED_BLUE \
(struct led_color) { .R = 0, .G = 0, .B = 1 }
#define LED_PURPLE \
(struct led_color) { .R = 1, .G = 0, .B = 1 }
#endif
#define BT_WAIT 0x01
#define NO_EVENT 0x02
#define PRE_WORK 0x03
#define WORKING 0x04
#define POST_WORK 0x05
#define LED_OFF LED_NONE
#define LED_ON LED_GREEN
#define LED_ERROR LED_RED
#define LED_IDLE_DISCONNECTED LED_YELLOW
#define LED_IDLE_CONNECTED LED_GREEN
#define LED_REC LED_CYAN
#define LED_IDENTIFY_DEV LED_PURPLE
#define LED_BUTTON_PRESS LED_YELLOW
#if (DEF_LED_DRV_ENABLED)
int32_t
led_init(void);
int32_t led_set(struct led_color color);
int32_t led_single_led_set(uint32_t idx, struct led_color color, uint8_t brightness);
int32_t led_mode(uint16_t mode_status);
int32_t led_as_rainbow(void);
int32_t led_init(void);
int32_t led_set(struct led_color color);
int32_t led_single_led_set(uint32_t idx, struct led_color color, uint8_t brightness);
int32_t led_as_rainbow(void);
#else
#define led_init()
#define led_set(x)
#define led_single_led_set(x, y, z)
#define led_mode(x)
#define led_as_rainbow(x)
#endif /* ! DEF_LED_DRV_ENABLED */
+26
View File
@@ -0,0 +1,26 @@
#ifndef __LED_RGB_H__
#define __LED_RGB_H__
#ifdef __cplusplus
extern "C"
{
#endif
#include "app_config.h"
#include "elite_board.h"
#include "led_drv_if.h"
#if (DEF_RGB_ENABLED)
#if !(defined(LED_R_PINS) && defined(LED_G_PINS) && defined(LED_B_PINS))
#error "LED_R_PINS, LED_G_PINS and LED_B_PINS must all be defined"
#endif
extern const led_drv_if_t led_rgb_drv;
#endif /* ! DEF_RGB_ENABLED */
#ifdef __cplusplus
}
#endif
#endif /* ! __LED_RGB_H__ */
View File
View File
View File
View File
View File
+4 -3
View File
@@ -16,9 +16,10 @@ extern "C"
int uart_recv(void *p_data, uint32_t max_size);
ret_code_t uart_set_baud(uint32_t baudrate);
#else
#define uart_init()
#define uart_send(...) ;
#define uart_recv(...) ;
#define uart_init()
#define uart_send(...) ;
#define uart_recv(...) ;
#define uart_set_baud(...)
#endif /* ! DEF_UARTE_ENABLED */
#ifdef __cplusplus
View File
+4 -3
View File
@@ -1,16 +1,17 @@
#include "adc_drv.h"
#if (DEF_ADS8691_ENABLED)
#if (DEF_ADC_DRV_ENABLED && DEF_ADS8691_ENABLED)
#include "ads8691.h"
extern const adc_drv_if_t ads8691;
static const adc_drv_if_t *p_inst = &ads8691;
#else
#elif (DEF_ADC_DRV_ENABLED && DEF_BULTIN_ADC_ENABED)
#include "builtin_saadc.h"
static const adc_drv_if_t *p_inst = &builtin_saadc;
#endif
#if (DEF_ADC_DRV_ENABLED)
#include <stdlib.h>
int adc_init(void)
{
if (p_inst == NULL)
View File
+15 -12
View File
@@ -1,4 +1,9 @@
#include "app_config.h"
#include "ads8691.h"
#if (DEF_ADS8691_ENABLED)
#include "elite_board.h"
#include "nrf_delay.h"
@@ -8,8 +13,6 @@
#include <string.h>
#if (DEF_ADS8691_ENABLED)
/*
* ADS8691
* Features:
@@ -164,11 +167,11 @@ uint32_t read_dev_id(void)
return read_hword();
}
static int write_dataout_ctrl(dataout_ctl_t *dataout_ctl)
{
write_cmd(ADS8691_CMD_WRITE, DATAOUT_CTL_REG, dataout_ctl->val);
return 0;
}
// static int write_dataout_ctrl(dataout_ctl_t *dataout_ctl)
// {
// write_cmd(ADS8691_CMD_WRITE, DATAOUT_CTL_REG, dataout_ctl->val);
// return 0;
// }
static int read_dataout_ctrl(dataout_ctl_t *dataout_ctl)
{
@@ -214,7 +217,7 @@ static double adc_convert_volt(uint16_t range_sel, int32_t val_18bit)
#define FSR_VREF_P_1P500 6.144
#define FSR_VREF_P_1P250 5.12
double volt;
double volt = 0;
if (range_sel == VREF_NP_3P000)
volt = (double)val_18bit * LSB_VREF_NP_3P000 / 1000000 - FSR_VREF_NP_3P000 / 2;
@@ -326,10 +329,10 @@ static int ads8691_init(void)
}
const adc_drv_if_t ads8691 = {
.init = ads8691_init,
.reset = ads8691_reset,
.read = ads8691_read,
.gain = ads8691_gain,
.init = ads8691_init,
.reset = ads8691_reset,
.read = ads8691_read,
.gain = ads8691_gain,
.read_milivolt = ads8691_read_milivolt,
};
+4 -7
View File
@@ -1,16 +1,13 @@
#include "nrf_gpio.h"
#include "nrf_log.h"
#include "nrf_spim.h"
#include "app_config.h"
#if (DEF_APA102_2020_ENABLED)
#include "apa102_2020.h"
#include "elite_board.h"
#include "FreeRTOS.h"
#include "task.h"
#if (DEF_APA102_2020_ENABLED)
#define DISP_LED_COLOR 0
typedef struct
{
uint8_t brightness : 5;
+13 -7
View File
@@ -104,8 +104,12 @@ static BtnEvent_t btn_event(void)
static void btn_event_shortx1_cb(void)
{
NRF_LOG_INFO("BTN_EVENT_SHORTx1");
#if (DEF_APA102_2020_ENABLED)
const struct led_color color[6] = { LED_RED, LED_ORANGE, LED_YELLOW, LED_GREEN, LED_BLUE, LED_PURPLE };
static int idx = 0;
#elif (DEF_RGB_ENABLED)
const struct led_color color[6] = { LED_RED, LED_YELLOW, LED_GREEN, LED_CYAN, LED_BLUE, LED_PURPLE };
#endif
static int idx = 0;
led_set(color[idx++ % COUNTOF(color)]);
}
@@ -119,7 +123,7 @@ static void btn_event_shortx2_cb(void)
led_set(LED_BLUE);
vTaskDelay(pdMS_TO_TICKS(250));
}
led_set(LED_IDEL_DISCONNECT);
led_set(LED_IDLE_DISCONNECTED);
}
static void btn_event_shortx3_cb(void)
@@ -131,21 +135,25 @@ static void btn_event_shortx3_cb(void)
vTaskDelay(pdMS_TO_TICKS(250));
led_set(LED_CYAN);
vTaskDelay(pdMS_TO_TICKS(250));
led_set(LED_IDEL_DISCONNECT);
led_set(LED_IDLE_DISCONNECTED);
}
led_set(LED_IDEL_DISCONNECT);
led_set(LED_IDLE_DISCONNECTED);
}
static void btn_event_long(void)
{
NRF_LOG_INFO("BTN_EVENT_LONG");
#if (DEF_APA102_2020_ENABLED)
led_set(LED_ORANGE);
#elif (DEF_RGB_ENABLED)
led_set(LED_YELLOW);
#endif
if (!wait_released(TIME_PRESS_LONG))
{
led_set(LED_OFF);
elite_board_power_off();
}
led_set(LED_IDEL_DISCONNECT);
led_set(LED_IDLE_DISCONNECTED);
}
static void btn_task(void *pvArg)
@@ -190,5 +198,3 @@ void btn_init(void)
}
#endif /* ! DEF_BTN_ENABLED */
+1 -1
View File
@@ -41,7 +41,7 @@ static int reset(void)
static float adc_convert_milivolt(uint16_t range_sel, int32_t val_14bit, bool is_diff)
{
float volt;
float gain;
float gain = 1.0 / 6.0;
float vref;
uint32_t m = is_diff ? 1 : 0;
View File
+20 -5
View File
@@ -1,13 +1,19 @@
#include "app_config.h"
#include "elite.h"
#if (DEF_ELITE_MODEL == DEF_ELITE_DEV)
#include "elite_dev.h"
#include "elite_dev_v1_0.h"
#elif (DEF_ELITE_MODEL == DEF_ELITE_EDC_V2_0)
#include "edc.h"
#include "elite_edc_v2_0.h"
#elif (DEF_ELITE_MODEL == DEF_ELITE_PEL_V2_0)
#include "pel.h"
#include "elite_pel_v2_0.h"
#elif (DEF_ELITE_MODEL == DEF_ELITE_PEL_V3_0)
#include "elite_pel_v3_0.h"
#elif (DEF_ELITE_MODEL == DEF_ELITE_CPG_V1_1)
#include "cpg.h"
#include "elite_cpg_v1_1.h"
#elif (DEF_ELITE_MODEL == DEF_ELITE_MMM_V1_0)
#include "elite_mmm_v1_0.h"
#else
#error "Unknown DEF_ELITE_MODEL"
#endif
@@ -67,6 +73,11 @@ static void decode_cis_ins(uint8_t *ins, uint16_t size)
}
}
// define BT instruction
#define INS_TYPE_RIS 0x30
#define INS_TYPE_VIS 0xC0
#define INS_TYPE_CIS 0x70
static void elite_instr_task(void *p_arg)
{
static size_t instr_size = 0;
@@ -107,8 +118,12 @@ void elite_init(void)
p_instance = edc.p_elite_instance;
#elif (DEF_ELITE_MODEL == DEF_ELITE_PEL_V2_0)
p_instance = pel_init();
#elif (DEF_ELITE_MODEL == DEF_ELITE_PEL_V3_0)
p_instance = pel_init();
#elif (DEF_ELITE_MODEL == DEF_ELITE_CPG_V1_1)
p_instance = cpg_init();
#elif (DEF_ELITE_MODEL == DEF_ELITE_MMM_V1_0)
p_instance = mmm_init();
#else
#error "Unknown DEF_ELITE_MODEL"
#endif
@@ -120,7 +135,7 @@ void elite_init(void)
void elite_instr_send(void *p, size_t size)
{
/* reply the instruction */
extern ret_code_t le_data_update(uint8_t * p_value, uint16_t len);
extern ret_code_t le_data_update(uint8_t *p_value, uint16_t len);
le_data_update(p, size);
xMessageBufferSend(instr_msg, p, size, portMAX_DELAY);
+7 -1
View File
@@ -6,6 +6,8 @@ void elite_board_init(void)
edc20_io_init();
#elif (DEF_ELITE_MODEL == DEF_ELITE_PEL_V2_0)
pel20_io_init();
#elif (DEF_ELITE_MODEL == DEF_ELITE_PEL_V3_0)
pel30_io_init();
#elif (DEF_ELITE_MODEL == DEF_ELITE_CPG_V1_1)
cpg11_io_init();
#endif
@@ -20,6 +22,9 @@ void elite_board_demo(void)
#elif (DEF_ELITE_MODEL == DEF_ELITE_PEL_V2_0)
extern void pel_pulse_gen_demo(void);
pel_pulse_gen_demo();
#elif (DEF_ELITE_MODEL == DEF_ELITE_PEL_V3_0)
extern void pel_pulse_gen_demo(void);
pel_pulse_gen_demo();
#elif (DEF_ELITE_MODEL == DEF_ELITE_CPG_V1_1)
cpg_pulse_default_demo_ext();
#endif
@@ -32,6 +37,7 @@ void elite_board_power_off(void)
#if (DEF_ELITE_MODEL == DEF_ELITE_EDC_V2_0)
edc20_io_power_off();
#elif (DEF_ELITE_MODEL == DEF_ELITE_PEL_V2_0)
#elif (DEF_ELITE_MODEL == DEF_ELITE_PEL_V3_0)
#elif (DEF_ELITE_MODEL == DEF_ELITE_CPG_V1_1)
#endif
}
@@ -40,7 +46,7 @@ void elite_drv_init(void)
{
btn_init();
led_init();
led_set(LED_IDEL_DISCONNECT);
led_set(LED_IDLE_DISCONNECTED);
sw_init();
adc_init();
dac_init();
+22 -8
View File
@@ -1,7 +1,11 @@
#include "cpg.h"
#include "elite_board.h"
#include "app_config.h"
#include "elite_def.h"
#include "elite_cpg_v1_1.h"
#if (DEF_ELITE_MODEL == DEF_ELITE_CPG_V1_1)
#include "elite.h"
#include "elite_board.h"
#include "nrf_delay.h"
#include "nrf_gpio.h"
@@ -9,7 +13,17 @@
#include "tw1508.h"
#if (DEF_ELITE_MODEL == DEF_ELITE_CPG_V1_1)
// RIS (real instruction)
#define DEV_MODE 0xFF // Develop Mode
// VIS (virtual instruction)
#define VIS_RST 0xF0
#define VIS_DEVICE_SHINY 0x10
// CIS (control instruction)
#define CIS_VERSION 0x40
#define CIS_VOLT 0x10
#define CIS_TEMPERATURE 0x80
// ExN: electrode x negative
// ExP: electrode x positive
@@ -155,8 +169,8 @@ static uint16_t current_mA_convert_tw1508_value(float current_mA)
uint16_t tw1508_value;
uint8_t dac_7bit;
uint8_t dac_3bit;
float rext;
uint8_t dac_3bit = 0b000;
float rext = 0.0;
if (current_mA > TW1508_BOUNDARY_GAIN7)
{
@@ -205,7 +219,7 @@ static uint16_t current_mA_convert_tw1508_value(float current_mA)
rext = TW1508_REXR;
}
dac_7bit = current_mA * 8 * TW1508_REXR / 1.25 / (dac_3bit + 1);
dac_7bit = current_mA * 8 * rext / 1.25 / (dac_3bit + 1);
tw1508_value = dac_3bit << 7 | dac_7bit;
return tw1508_value;
@@ -773,7 +787,7 @@ static void cis_version(uint8_t *ins, uint16_t size)
VERSION_DATE_HOUR,
VERSION_DATE_MINUTE,
};
extern ret_code_t le_data_update(uint8_t * p_value, uint16_t len);
extern ret_code_t le_data_update(uint8_t *p_value, uint16_t len);
le_data_update((void *)cis_ver, sizeof(cis_ver));
}
+4 -4
View File
@@ -31,20 +31,20 @@ typedef struct
} pulse_gen_hw_t;
pulse_gen_hw_t pulse_gen_hw[] = {
{.gpiote_idx = { 0, 1, 2, 3 },
{ .gpiote_idx = { 0, 1, 2, 3 },
.TMR_A = NRF_TIMER1,
.TMR_B = NRF_TIMER3,
.TMR_A_IRQn = TIMER1_IRQn,
.TMR_B_IRQn = TIMER3_IRQn,
.p_pulse_gen = NULL,
.private = { NULL, 0, 0 }},
{.gpiote_idx = { 4, 5, 6, 7 },
.private = { NULL, 0, 0 } },
{ .gpiote_idx = { 4, 5, 6, 7 },
.TMR_A = NRF_TIMER2,
.TMR_B = NRF_TIMER4,
.TMR_A_IRQn = TIMER2_IRQn,
.TMR_B_IRQn = TIMER4_IRQn,
.p_pulse_gen = NULL,
.private = { NULL, 0, 0 }},
.private = { NULL, 0, 0 } },
};
__STATIC_INLINE void config_tmrB(uint32_t hw_idx, pulse_gen_t *p_pulse_gen)
+21 -3
View File
@@ -1,9 +1,27 @@
#include "elite_dev.h"
#include "app_config.h"
#include "elite_dev_v1_0.h"
#if (DEF_ELITE_MODEL == DEF_ELITE_DEV)
#include "app_error.h"
#include "nrf_gpio.h"
#include "nrf_log.h"
#if (DEF_ELITE_MODEL == DEF_ELITE_DEV)
#include <stdint.h>
// RIS (real instruction)
#define DEV_MODE 0xFF // Develop Mode
// VIS (virtual instruction)
#define VIS_RST 0xF0
#define VIS_DEVICE_SHINY 0x10
// CIS (control instruction)
#define CIS_VERSION 0x40
#define CIS_VOLT 0x10
#define CIS_TEMPERATURE 0x80
#define CIS_CALI 0x30
#define VERSION_DATE_YEAR 24
#define VERSION_DATE_MONTH 7
@@ -21,7 +39,7 @@ static void cis_version(uint8_t *ins, uint16_t size)
VERSION_DATE_HOUR,
VERSION_DATE_MINUTE,
};
extern ret_code_t le_data_update(uint8_t * p_value, uint16_t len);
extern ret_code_t le_data_update(uint8_t *p_value, uint16_t len);
le_data_update((void *)cis_ver, sizeof(cis_ver));
}
+112 -46
View File
@@ -1,28 +1,73 @@
#include "app_config.h"
#include "elite_board.h"
#include "edc.h"
#include "elite.h"
#include "elite_adc.h"
#include "elite_correction.h"
#include "elite_dac.h"
#include "elite_edc_v2_0.h"
#if (DEF_ELITE_MODEL == DEF_ELITE_EDC_V2_0)
#include "adc_drv.h"
#include "dac_drv.h"
#include "elite.h"
#include "elite_board.h"
#include "led_drv.h"
#include "sw_drv.h"
#include "nrf_log.h"
#if (DEF_ELITE_MODEL == DEF_ELITE_EDC_V2_0)
#include "timers.h"
// RIS (real instruction)
#define DEV_MODE 0xFF // Develop Mode
#define CURVE_IV 0x01 // I-V Curve
#define CURVE_IV_CY 0x02 // Cycle I-V
#define CURVE_VO 0x03 // Function Generator
#define CURVE_RT 0x04 // R-T Graph
#define CURVE_VT 0x05 // V-T Graph
#define CURVE_IT 0x06 // I-T Graph
#define CURVE_CC 0x07 // Constant Current (CC)
#define CURVE_OCP 0x08 // Open Circuit Potential (OCP)
#define CURVE_CV 0x09 // Cyclic Voltammetry (CV)
#define CURVE_LSV 0x0A // Linear Sweep Voltammetry (LSV)
#define CURVE_CA 0x0B // Chronoamperometric Graph (CA)
#define CURVE_CP 0x0C // Chronopotentiometry (CP)
#define CURVE_UNI_PULSE 0x0D // Pulse Sensing (universal pulse)
#define CURVE_DPV 0x0E // Differential Pulse Voltammetry (DPV)
#define CURVE_DPV_ADVANCE 0x0F
#define CURVE_DPV_SMPRATE 0x10
#define CURVE_DPV_ADVANCE_SMPRATE 0x11
#define CURVE_EIS 0x12
#define CURVE_CF 0x13 // Constant Frequency(CF)
#define CURVE_CALI 0xF1
#define SET_SAMPLE_RATE 0xE0
// VIS (virtual instruction)
#define VIS_RST 0xF0
#define VIS_DEVICE_SHINY 0x10
// CIS (control instruction)
#define CIS_VERSION 0x40
#define CIS_VOLT 0x10
#define CIS_TEMPERATURE 0x80
#define CIS_CALI 0x30
// ADC Iin gain level !!! move to ADC.h in future
#define I_GAIN_3M 0x00 // lv0,largest gain
#define I_GAIN_100K 0x01 // lv1
#define I_GAIN_3K 0x02 // lv2
#define I_GAIN_100R 0x03 // lv3,the least gain
#define I_GAIN_AUTO 0x04
// ADC Vin gain level !!! move to ADC.h in future
#define VIN_GAIN_1M 0x00
#define VIN_GAIN_30K 0x01
#define VIN_GAIN_1K 0x02
#define VIN_GAIN_AUTO 0x03
#define DEV_SHINY_DELAY_MS 3000
static TimerHandle_t dev_shiny_timer_handle = NULL;
extern ret_code_t le_event_update(uint8_t *p_value, uint16_t len);
static void dummy(uint8_t *ins, uint16_t size)
{
NRF_LOG_INFO("%s", __FUNCTION__);
}
/*
dev_mode_set_led
(1)0x3000FF0400
@@ -395,6 +440,7 @@ static void dev_mode_read_output_pin(void)
output.cs_mem = nrf_gpio_pin_out_read(CS_MEM_PIN);
output.cs_adc = nrf_gpio_pin_out_read(CS_ADC_PIN);
output.cs_dac = nrf_gpio_pin_out_read(CS_DAC_PIN);
output.resvd = 0;
pin_out_status = (output.resvd << 21) |
(output.power_5v_en << 20) |
@@ -461,6 +507,7 @@ static void dev_mode_read_input_pin(void)
input.vbat = nrf_gpio_pin_read(VBAT_PIN);
input.shut_down = nrf_gpio_pin_read(SHUT_DOWN_PIN);
input.int9466 = nrf_gpio_pin_read(INT9466_PIN);
input.resvd = 0;
pin_input_status = (input.resvd << 3) |
(input.vbat << 2) |
@@ -845,7 +892,7 @@ static void cis_version(uint8_t *ins, uint16_t size)
.hh = 22,
.mm = 40,
};
extern ret_code_t le_data_update(uint8_t * p_value, uint16_t len);
extern ret_code_t le_data_update(uint8_t *p_value, uint16_t len);
le_data_update((void *)&cis_ver, sizeof(cis_ver));
}
@@ -867,7 +914,7 @@ static void cis_volt(uint8_t *ins, uint16_t size)
.opcode = CIS_VOLT,
.volt = bat_volt_read(),
};
extern ret_code_t le_data_update(uint8_t * p_value, uint16_t len);
extern ret_code_t le_data_update(uint8_t *p_value, uint16_t len);
le_data_update((void *)&cis_volt, sizeof(cis_volt));
}
@@ -890,52 +937,74 @@ static void cis_temperature(uint8_t *ins, uint16_t size)
.opcode = CIS_TEMPERATURE,
.temperature = __REV(temperature_read()),
};
extern ret_code_t le_data_update(uint8_t * p_value, uint16_t len);
extern ret_code_t le_data_update(uint8_t *p_value, uint16_t len);
le_data_update((void *)&cis_temperature, sizeof(cis_temperature));
}
static void cis_cali(uint8_t *ins, uint16_t size) { NRF_LOG_INFO("%s", __FUNCTION__); }
static bool DACReset;
static void vis_rst(uint8_t *ins, uint16_t size)
{
NRF_LOG_INFO("%s", __FUNCTION__);
edc.instru.eliteFxn = VIS_RST;
edc.instru.VinADCGainLv = VIN_GAIN_1K;
VinADCGainCtrl(edc.instru.VinADCGainLv);
edc.instru.IinADCGainLv = I_GAIN_100R;
IinADCGainCtrl(edc.instru.IinADCGainLv);
edc.instru.VoutGainLv = VOUT_GAIN_15K;
VoutGainControl(edc.instru.VoutGainLv);
uint16_t volt = Usercode_Correction_to_DAC(edc.instru.VoutGainLv, 25000);
dac_write_through(DAC0, volt);
led_mode(NO_EVENT);
}
static void vis_sti(uint8_t *ins, uint16_t size) { NRF_LOG_INFO("%s", __FUNCTION__); }
static void vis_int(uint8_t *ins, uint16_t size) { NRF_LOG_INFO("%s", __FUNCTION__); }
static void vis_device_shiny(uint8_t *ins, uint16_t size)
{
NRF_LOG_INFO("%s", __FUNCTION__);
led_set(LED_IDENTICY_DEV);
}
static void vis_shiny_dis(uint8_t *ins, uint16_t size)
static void dev_shiny_callback(TimerHandle_t xTimer)
{
extern bool is_ble_connected(void);
if (!is_ble_connected())
{
led_set(LED_IDLE_DISCONNECTED);
return;
}
extern bool is_mode_running(void);
if (is_mode_running())
{
led_set(LED_REC);
}
else
{
led_set(LED_IDLE_CONNECTED);
}
}
void start_dev_shiny_timer(void)
{
if (dev_shiny_timer_handle == NULL)
{
dev_shiny_timer_handle = xTimerCreate("dev_shiny_timer",
pdMS_TO_TICKS(DEV_SHINY_DELAY_MS),
pdFALSE,
NULL,
dev_shiny_callback);
if (dev_shiny_timer_handle == NULL)
{
NRF_LOG_ERROR("dev_shiny_timer creation failed");
return;
}
}
if (xTimerStart(dev_shiny_timer_handle, 0) != pdPASS)
{
NRF_LOG_ERROR("dev_shiny_timer start failed");
}
}
static void vis_dev_shiny(uint8_t *ins, uint16_t size)
{
NRF_LOG_INFO("%s", __FUNCTION__);
led_set(LED_IDEL_CONNECTED);
led_set(LED_IDENTIFY_DEV);
start_dev_shiny_timer();
}
static void curve_iv(uint8_t *ins, uint16_t size) { NRF_LOG_INFO("%s", __FUNCTION__); }
static void curve_iv_cy(uint8_t *ins, uint16_t size)
{
NRF_LOG_INFO("%s", __FUNCTION__);
extern void edc20_cycle_iv_mode_start(uint8_t * ins, uint16_t size);
extern void edc20_cycle_iv_mode_start(uint8_t *ins, uint16_t size);
edc20_cycle_iv_mode_start(ins, size);
}
@@ -968,10 +1037,7 @@ elite_instance_t edc20_elite_instance = {
},
.vis_func = {
[VIS_RST] = vis_rst,
[VIS_STI] = vis_sti,
[VIS_INT] = vis_int,
[VIS_DEVICE_SHINY] = vis_device_shiny,
[VIS_SHINY_DIS] = vis_shiny_dis,
[VIS_DEVICE_SHINY] = vis_dev_shiny,
},
.ris_func = {
[CURVE_IV] = curve_iv,
@@ -1,7 +1,12 @@
#include "edc.h"
#include "elite_board.h"
#include "app_config.h"
#include "elite_edc_v2_0.h"
#if (DEF_ELITE_MODEL == DEF_ELITE_EDC_V2_0)
#include "dac_drv.h"
#include "elite.h"
#include "elite_board.h"
#include "nrf.h"
#include "nrf_log.h"
@@ -16,8 +21,6 @@
#include <stdlib.h>
#include <string.h>
#if (DEF_ELITE_MODEL == DEF_ELITE_EDC_V2_0)
#define OUT_0 DAC0
#define OUT_1 DAC1
@@ -311,6 +314,7 @@ static void edc20_cycle_iv_mode_task(void *p_arg)
NRF_LOG_INFO("%s", info);
}
led_set(LED_REC);
dac_write_through(OUT_0, mV_out_0(&dac_param));
dac_param.mV_output = dac_param.mV_start;
@@ -350,6 +354,7 @@ static void edc20_cycle_iv_mode_task(void *p_arg)
edc20_dac_tim_stop();
edc20_adc_tim_stop();
dac_init();
led_set(LED_IDLE_CONNECTED);
if (1)
{
@@ -361,70 +366,9 @@ static void edc20_cycle_iv_mode_task(void *p_arg)
vTaskDelete(NULL);
}
void edc20_cycle_iv_mode_init(void)
{
}
#define VDIRECTION(v1, v2) ((v1 > v2) ? 0 : 1)
// Step time macro
#define STEPTIME_HALF_SEC 5000
#define STEPTIME_ONE_SEC 10000
#define STEPTIME_TWO_SEC 20000
static uint32_t step2VsetRate(uint32_t step)
{
/*step = 100 mv, index = 0, n = 2
10 mv, index = 1, n = 10
1 mv, index = 2, n = 100
0.1 mv, index = 3, n = 1000
0.01mv, index = 4, n = 10000 */
if (step >= 10000)
{
return 0;
}
else if (step >= 1000)
{
return 1;
}
else if (step >= 100)
{
return 2;
}
else if (step >= 10)
{
return 3;
}
else if (step >= 1)
{
return 4;
}
else
{
return 5;
}
}
static uint32_t get_step_time(uint8_t StepTime)
{
switch (StepTime)
{
case 0: { // 0.5 sec
return STEPTIME_HALF_SEC;
}
case 1: { // 1 sec
return STEPTIME_ONE_SEC;
}
case 2: { // 2 sec
return STEPTIME_TWO_SEC;
}
default: { // 1 sec
return STEPTIME_ONE_SEC;
}
}
}
#define STEP_TO_VSETRATE(step) step2VsetRate(step)
const uint32_t VsetRateTable[5] = { 2, 10, 100, 1000, 10000 };
#define VMAX(v1, v2) ((v1 >= v2) ? v1 : v2)
#define VMIN(v1, v2) ((v1 < v2) ? v1 : v2)
static uint32_t convt_uS_step(uint32_t idx)
{
@@ -445,38 +389,24 @@ static uint32_t convt_uS_step(uint32_t idx)
}
}
bool is_mode_running(void)
{
return running;
}
void edc20_cycle_iv_mode_start(uint8_t *ins, uint16_t size)
{
/*
instru.eliteFxn = CURVE_IV_CY;
instru.Ve1 = ((uint16_t)(ins[3]) << 8) | (uint16_t)(ins[4]);
instru.Ve2 = ((uint16_t)(ins[5]) << 8) | (uint16_t)(ins[6]);
instru.Vinit = (int32_t)instru.Ve1;
instru.Vmax = (int32_t)VMAX(instru.Ve1,instru.Ve2);
instru.Vmin = (int32_t)VMIN(instru.Ve1,instru.Ve2);
instru.directionInit = VDIRECTION(instru.Ve1,instru.Ve2);
instru.steptime = get_step_time(ins[9]); //5000;10000;20000;
instru.step = ((uint32_t)(ins[7]) << 8) | (uint32_t)(ins[8]);//1~1000 = 0.1mv ~ 100mv
instru.step = instru.step * 100000 / instru.steptime;
STEP_TO_VSETRATE(instru.step);
instru.VsetRate = VsetRateTable[instru.VsetRateIndex];//N
instru.cycleNumber = ((uint16_t)(ins[10]) << 8) | (uint16_t)(ins[11]);
instru.hign_z_en = ins[13] & 0x0F;
instru.notifyRate = ((uint32_t)ins[14] << 8) | (uint32_t)ins[15];
instru.notifyRate = 10000 / instru.notifyRate * 10;
*/
struct __PACKED
{
uint8_t id : 4;
uint8_t : 4;
uint8_t : 8;
uint8_t : 8;
uint16_t volt_start; // unit: 100uV, -5V = 0, 0V = 25000, 5V = 50000
uint16_t volt_stop; // unit: 100uV, -5V = 0, 0V = 25000, 5V = 50000
uint16_t step; // unit: 100uV
uint8_t step_time; // enum: 0 = 5000us, 1 = 10000us, 2 = 20000us
uint16_t cycles; // 0 ~ 500000
uint16_t volt_start; // unit: 100uV, -5V = 0, 0V = 25000, 5V = 50000
uint16_t volt_stop; // unit: 100uV, -5V = 0, 0V = 25000, 5V = 50000
uint16_t step; // unit: 100uV
uint8_t step_time; // enum: 0 = 5000us, 1 = 10000us, 2 = 20000us
uint16_t cycles; // 0 ~ 500000
uint8_t : 8;
uint8_t hi_z_en; // lower nibble
uint16_t sample_rate; // unit: 0.1Hz
+271
View File
@@ -0,0 +1,271 @@
#include "app_config.h"
#include "elite_mmm_v1_0.h"
#if (DEF_ELITE_MODEL == DEF_ELITE_MMM_V1_0)
#include "nrf_gpio.h"
#include "nrf_log.h"
// RIS (real instruction)
#define DEV_MODE 0xFF // Develop Mode
// VIS (virtual instruction)
#define VIS_RST 0xF0
#define VIS_DEVICE_SHINY 0x10
// CIS (control instruction)
#define CIS_VERSION 0x40
#define CIS_VOLT 0x10
#define CIS_TEMPERATURE 0x80
#define CIS_CALI 0x30
#define VERSION_DATE_YEAR 25
#define VERSION_DATE_MONTH 6
#define VERSION_DATE_DAY 4
#define VERSION_DATE_HOUR 16
#define VERSION_DATE_MINUTE 44
static void cis_version(uint8_t *ins, uint16_t size)
{
NRF_LOG_INFO("%s", __FUNCTION__);
uint8_t cis_ver[] = {
CIS_VERSION,
VERSION_DATE_YEAR,
VERSION_DATE_MONTH,
VERSION_DATE_DAY,
VERSION_DATE_HOUR,
VERSION_DATE_MINUTE,
};
extern ret_code_t le_data_update(uint8_t *p_value, uint16_t len);
le_data_update((void *)cis_ver, sizeof(cis_ver));
}
static void vis_rst(uint8_t *ins, uint16_t size)
{
NRF_LOG_INFO("%s", __FUNCTION__);
}
#define UNDEF_GPIO 0xFFFFFFFF
// The GPIO corresponding to the pin
const uint32_t pin_to_gpio_table[] = {
[6] = NRF_GPIO_PIN_MAP(0, 22),
[8] = NRF_GPIO_PIN_MAP(0, 25),
[9] = NRF_GPIO_PIN_MAP(0, 19),
[10] = NRF_GPIO_PIN_MAP(0, 21),
[11] = NRF_GPIO_PIN_MAP(1, 00),
[12] = NRF_GPIO_PIN_MAP(0, 18),
[13] = NRF_GPIO_PIN_MAP(0, 17),
[14] = NRF_GPIO_PIN_MAP(0, 20),
[16] = NRF_GPIO_PIN_MAP(0, 14),
[17] = NRF_GPIO_PIN_MAP(0, 13),
[18] = NRF_GPIO_PIN_MAP(0, 11),
[20] = NRF_GPIO_PIN_MAP(0, 15),
[25] = NRF_GPIO_PIN_MAP(1, 8),
[26] = NRF_GPIO_PIN_MAP(0, 12),
[27] = NRF_GPIO_PIN_MAP(0, 7),
[28] = NRF_GPIO_PIN_MAP(1, 9),
[29] = NRF_GPIO_PIN_MAP(0, 8),
[30] = NRF_GPIO_PIN_MAP(0, 6),
[31] = NRF_GPIO_PIN_MAP(0, 5),
[32] = NRF_GPIO_PIN_MAP(0, 27),
[33] = NRF_GPIO_PIN_MAP(0, 26),
[34] = NRF_GPIO_PIN_MAP(0, 4),
[36] = NRF_GPIO_PIN_MAP(0, 1),
[37] = NRF_GPIO_PIN_MAP(0, 29),
[38] = NRF_GPIO_PIN_MAP(0, 0),
[39] = NRF_GPIO_PIN_MAP(0, 31),
[40] = NRF_GPIO_PIN_MAP(1, 15),
[41] = NRF_GPIO_PIN_MAP(0, 2),
[42] = NRF_GPIO_PIN_MAP(0, 30),
[43] = NRF_GPIO_PIN_MAP(0, 28),
[44] = NRF_GPIO_PIN_MAP(1, 12),
[45] = NRF_GPIO_PIN_MAP(1, 14),
[46] = NRF_GPIO_PIN_MAP(0, 3),
[47] = NRF_GPIO_PIN_MAP(1, 13),
[48] = NRF_GPIO_PIN_MAP(1, 3),
[49] = NRF_GPIO_PIN_MAP(1, 10),
[50] = NRF_GPIO_PIN_MAP(1, 6),
[51] = NRF_GPIO_PIN_MAP(1, 11),
[52] = NRF_GPIO_PIN_MAP(0, 10),
[53] = NRF_GPIO_PIN_MAP(0, 9),
[59] = NRF_GPIO_PIN_MAP(1, 2),
[60] = NRF_GPIO_PIN_MAP(0, 24),
[61] = NRF_GPIO_PIN_MAP(0, 23),
[62] = NRF_GPIO_PIN_MAP(0, 16),
};
static uint32_t bmd380pins_convert_to_gpio(uint32_t pin)
{
uint32_t gpio;
switch (pin)
{
case 6:
case 8:
case 9:
case 10:
case 11:
case 12:
case 13:
case 14:
case 16:
case 17:
case 18:
case 20:
case 25:
case 26:
case 27:
case 28:
case 29:
case 30:
case 31:
case 32:
case 33:
case 34:
case 36:
case 37:
case 38:
case 39:
case 40:
case 41:
case 42:
case 43:
case 44:
case 45:
case 46:
case 47:
case 48:
case 49:
case 50:
case 51:
case 52:
case 53:
case 59:
case 60:
case 61:
case 62:
gpio = pin_to_gpio_table[pin];
break;
default:
gpio = UNDEF_GPIO;
NRF_LOG_INFO("UNDEF_GPIO: pin %d can't convert to gpio number", pin);
break;
}
return gpio;
}
static void set_bmd380_pin_signal(uint32_t pin, uint32_t high_low)
{
uint32_t gpio = bmd380pins_convert_to_gpio(pin);
if (gpio != UNDEF_GPIO)
{
nrf_gpio_cfg_output(gpio);
nrf_gpio_pin_write(gpio, high_low);
NRF_LOG_INFO("set pin %d (gpio %d) = %d", pin, gpio, high_low);
}
}
/*
dev_mode_gpio_function
(1)0x3000FFA000ppss
-func: set_bmd380_pin_signal
-pp: pin number 06h-3Fh
06h: P0.22_GPIO
08h: P0.25_GPIO
......
3Eh: P0.16_GPIO
-ss: signal 00h-01h
00h: low
01h: high
(2)0x3000FFA001ss
-func: set_bmd380 all pin signal high/low
-ss: signal 00h-01h
00h: low
01h: high
*/
void dev_mode_gpio_function(uint8_t *ins)
{
struct __PACKED
{
uint8_t id : 4;
uint8_t : 4;
uint16_t magic : 16;
uint8_t dev_opcode;
uint8_t gpio_function_opcode;
uint8_t param[];
} *p_ins = (void *)ins;
switch (p_ins->gpio_function_opcode)
{
case 0x00: {
uint32_t pin = p_ins->param[0];
uint32_t high_low = p_ins->param[1];
set_bmd380_pin_signal(pin, high_low);
break;
}
case 0x01: {
uint32_t high_low = p_ins->param[0];
uint32_t set_pin[44] = { 6, 8, 9, 10, 11, 12, 13, 14, 16, 17, 18, 20, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 59, 60, 61, 62 };
for (int i = 0; i < sizeof(set_pin) / sizeof(set_pin[0]); i++)
{
set_bmd380_pin_signal(set_pin[i], high_low);
}
break;
}
}
}
#define MAGIC_NUM 0xFF00
static void dev_mode(uint8_t *ins, uint16_t size)
{
NRF_LOG_INFO("%s", __FUNCTION__);
struct __PACKED
{
uint8_t id : 4;
uint8_t : 4;
uint16_t magic : 16;
uint8_t opcode;
uint8_t param[];
} *p_ins = (void *)ins;
if (p_ins->magic != MAGIC_NUM)
{
return;
}
// TODO...
switch (p_ins->opcode)
{
case 0xA0:
dev_mode_gpio_function(ins);
break;
default:
break;
}
}
const elite_instance_t mmm_elite_instance = {
.cis_func = {
[CIS_VERSION] = cis_version,
},
.vis_func = {
[VIS_RST] = vis_rst,
},
.ris_func = {
[DEV_MODE] = dev_mode,
}
};
const elite_instance_t *mmm_init(void)
{
return &mmm_elite_instance;
}
#endif /* !DEF_ELITE_MODEL */
+330 -182
View File
@@ -1,26 +1,42 @@
#include "app_config.h"
#include "app_error.h"
#include "elite_board.h"
#include "pel.h"
#include "elite_def.h"
#include "nrf_delay.h"
#include "nrf_gpio.h"
#include "nrf_log.h"
#include "adc_drv.h"
#include "FreeRTOS.h"
#include "message_buffer.h"
#include "queue.h"
#include "semphr.h"
#include "stream_buffer.h"
#include "task.h"
#if (DEF_ELITE_MODEL == DEF_ELITE_PEL_V2_0)
#include "adc_drv.h"
#include "elite.h"
#include "elite_board.h"
#include "elite_pel_v2_0.h"
#include "message_buffer.h"
#include "semphr.h"
#include "task.h"
#include "nrf_log.h"
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
// RIS (real instruction)
#define MANUAL_SCAN_MODE 0x01
#define AUTO_SCAN_MODE 0x02
#define R_EXTERNAL_CALIBRATION_MODE 0x03
#define DEV_MODE 0xFF
// VIS (virtual instruction)
#define VIS_RST 0xF0
#define VIS_DEVICE_SHINY 0x10
// CIS (control instruction)
#define CIS_VERSION 0x40
#define CIS_VOLT 0x10
#define CIS_TEMPERATURE 0x80
#define CIS_CALI 0x30
#define DUMP_DATA 0
static bool running = false;
typedef struct
{
uint32_t pattern_index;
@@ -46,18 +62,18 @@ static float _load_set(uint32_t mask)
} input_pin_t;
const input_pin_t input_pin_tab[] = {
{ 0.5, INPUT_1_PIN, PEL_0P5R_MASK},
{ 1.0, INPUT_2_PIN, PEL_1P0R_MASK},
{ 2.0, INPUT_3_PIN, PEL_2P0R_MASK},
{ 4.0, INPUT_4_PIN, PEL_4P0R_MASK},
{ 8.3, INPUT_5_PIN, PEL_8P0R_MASK},
{ 16.2, INPUT_6_PIN, PEL_16P2R_MASK},
{ 32.4, INPUT_7_PIN, PEL_32P4R_MASK},
{ 62.5, INPUT_8_PIN, PEL_63P4R_MASK},
{ 130.0, INPUT_9_PIN, PEL_127R_MASK},
{ 270.0, INPUT_10_PIN, PEL_255R_MASK},
{ 510.0, INPUT_11_PIN, PEL_511R_MASK},
{1000.0, INPUT_12_PIN, PEL_1000R_MASK},
{ 0.5, INPUT_1_PIN, PEL_0P5R_MASK },
{ 1.0, INPUT_2_PIN, PEL_1P0R_MASK },
{ 2.0, INPUT_3_PIN, PEL_2P0R_MASK },
{ 4.0, INPUT_4_PIN, PEL_4P0R_MASK },
{ 8.3, INPUT_5_PIN, PEL_8P0R_MASK },
{ 16.2, INPUT_6_PIN, PEL_16P2R_MASK },
{ 32.4, INPUT_7_PIN, PEL_32P4R_MASK },
{ 62.5, INPUT_8_PIN, PEL_63P4R_MASK },
{ 130.0, INPUT_9_PIN, PEL_127R_MASK },
{ 270.0, INPUT_10_PIN, PEL_255R_MASK },
{ 510.0, INPUT_11_PIN, PEL_511R_MASK },
{ 1000.0, INPUT_12_PIN, PEL_1000R_MASK },
};
float ohms = 0;
@@ -77,6 +93,11 @@ static float _load_set(uint32_t mask)
nrf_gpio_pin_set(input_pin_tab[i].pin);
}
}
if (mask == 0)
{
NRF_LOG_INFO("disable R1~R12");
}
return sum_of_conductances;
}
@@ -91,49 +112,49 @@ static void set_resistor_load_bits(uint32_t mask)
static void set_resistor_load_pattern(uint32_t index)
{
const resistor_t pattern_tab[] = {
{ 1, 0b0000000000000111},
{ 2, 0b0000000000000011},
{ 3, 0b0000000000000101},
{ 4, 0b0000000000000001},
{ 5, 0b0000000000001110},
{ 6, 0b0000000000000110},
{ 7, 0b0000000000001010},
{ 8, 0b0000000000000010},
{ 9, 0b0000000000011100},
{10, 0b0000000000001100},
{11, 0b0000000000010100},
{12, 0b0000000000000100},
{13, 0b0000000000111000},
{14, 0b0000000000011000},
{15, 0b0000000000101000},
{16, 0b0000000000001000},
{17, 0b0000000001110000},
{18, 0b0000000000110000},
{19, 0b0000000001010000},
{20, 0b0000000000010000},
{21, 0b0000000011100000},
{22, 0b0000000001100000},
{23, 0b0000000010100000},
{24, 0b0000000000100000},
{25, 0b0000000111000000},
{26, 0b0000000011000000},
{27, 0b0000000101000000},
{28, 0b0000000001000000},
{29, 0b0000001110000000},
{30, 0b0000000110000000},
{31, 0b0000001010000000},
{32, 0b0000000010000000},
{33, 0b0000011100000000},
{34, 0b0000001100000000},
{35, 0b0000010100000000},
{36, 0b0000000100000000},
{37, 0b0000111000000000},
{38, 0b0000011000000000},
{39, 0b0000101000000000},
{40, 0b0000001000000000},
{41, 0b0000110000000000},
{42, 0b0000010000000000},
{43, 0b0000100000000000},
{ 1, 0b0000000000000111 },
{ 2, 0b0000000000000011 },
{ 3, 0b0000000000000101 },
{ 4, 0b0000000000000001 },
{ 5, 0b0000000000001110 },
{ 6, 0b0000000000000110 },
{ 7, 0b0000000000001010 },
{ 8, 0b0000000000000010 },
{ 9, 0b0000000000011100 },
{ 10, 0b0000000000001100 },
{ 11, 0b0000000000010100 },
{ 12, 0b0000000000000100 },
{ 13, 0b0000000000111000 },
{ 14, 0b0000000000011000 },
{ 15, 0b0000000000101000 },
{ 16, 0b0000000000001000 },
{ 17, 0b0000000001110000 },
{ 18, 0b0000000000110000 },
{ 19, 0b0000000001010000 },
{ 20, 0b0000000000010000 },
{ 21, 0b0000000011100000 },
{ 22, 0b0000000001100000 },
{ 23, 0b0000000010100000 },
{ 24, 0b0000000000100000 },
{ 25, 0b0000000111000000 },
{ 26, 0b0000000011000000 },
{ 27, 0b0000000101000000 },
{ 28, 0b0000000001000000 },
{ 29, 0b0000001110000000 },
{ 30, 0b0000000110000000 },
{ 31, 0b0000001010000000 },
{ 32, 0b0000000010000000 },
{ 33, 0b0000011100000000 },
{ 34, 0b0000001100000000 },
{ 35, 0b0000010100000000 },
{ 36, 0b0000000100000000 },
{ 37, 0b0000111000000000 },
{ 38, 0b0000011000000000 },
{ 39, 0b0000101000000000 },
{ 40, 0b0000001000000000 },
{ 41, 0b0000110000000000 },
{ 42, 0b0000010000000000 },
{ 43, 0b0000100000000000 },
};
for (int32_t i = 0; i < ARRAY_SIZE(pattern_tab); i++)
@@ -206,32 +227,35 @@ static void cis_version(uint8_t *ins, uint16_t size)
{
NRF_LOG_INFO("%s", __FUNCTION__);
uint8_t cis_ver[] = {
CIS_VERSION,
ins[1],
VERSION_DATE_YEAR,
VERSION_DATE_MONTH,
VERSION_DATE_DAY,
VERSION_DATE_HOUR,
VERSION_DATE_MINUTE,
};
extern ret_code_t le_data_update(uint8_t * p_value, uint16_t len);
extern ret_code_t le_data_update(uint8_t *p_value, uint16_t len);
le_data_update((void *)cis_ver, sizeof(cis_ver));
}
static void send_start_package(void *packet_buf, uint32_t packet_len)
{
NRF_LOG_INFO(__FUNCTION__);
for (uint32_t i = 0; i < 4; i++)
{
ret_code_t le_event_notify(uint8_t * p_value, uint16_t len);
ret_code_t le_event_notify(uint8_t *p_value, uint16_t len);
nrf_gpio_pin_set(TP2_PIN);
ret_code_t ret = le_event_notify(packet_buf, packet_len);
nrf_gpio_pin_clear(TP2_PIN);
if (DUMP_DATA)
{
for (uint32_t i = 0; i < packet_len; i++)
{
NRF_LOG_RAW_INFO("%02X ", ((uint8_t *)packet_buf)[i]);
}
NRF_LOG_RAW_INFO("\r\n");
}
vTaskDelay(pdMS_TO_TICKS(10));
NRF_LOG_HEXDUMP_INFO(packet_buf, packet_len);
NRF_LOG_INFO("\n");
}
}
@@ -248,97 +272,60 @@ static void pel_scan_mode_notify(scan_mode_notify_packet_t *packet_buf, uint32_t
packet_buf->mem_board_id = global_memoryboard_id;
packet_buf->packet_seq++;
packet_buf->notify_time = xTaskGetTickCount();
packet_buf->output_vo_raw = pel_hw.adc.results[2];
packet_buf->output_vc_raw = pel_hw.adc.results[3];
packet_buf->output_ve_raw = pel_hw.adc.results[4];
packet_buf->hold_OUT_v = pel_hw.adc.results_f[2] * 10 / 1000;
packet_buf->hold_VCC_v = pel_hw.adc.results_f[3] * 10 / 1000;
packet_buf->hold_VEE_v = pel_hw.adc.results_f[4] * 10 / 1000;
packet_buf->notify_time = xTaskGetTickCount();
packet_buf->raw_output_r1 = pel_hw.adc.results[0];
packet_buf->raw_output_r2 = pel_hw.adc.results[1];
packet_buf->raw_output_vo = pel_hw.adc.results[2];
packet_buf->raw_output_vc = pel_hw.adc.results[3];
packet_buf->raw_output_ve = pel_hw.adc.results[4];
packet_buf->output_r1_mv = pel_hw.adc.results_f[0];
packet_buf->output_r2_mv = pel_hw.adc.results_f[1];
packet_buf->output_vo_mv = pel_hw.adc.results_f[2];
packet_buf->output_vc_mv = pel_hw.adc.results_f[3];
packet_buf->output_ve_mv = pel_hw.adc.results_f[4];
packet_buf->hold_r1_v = pel_hw.adc.results_f[0] * 10 / 1000;
packet_buf->hold_r2_v = pel_hw.adc.results_f[1] * 10 / 1000;
packet_buf->hold_out_v = pel_hw.adc.results_f[2] * 10 / 1000;
packet_buf->hold_vcc_v = pel_hw.adc.results_f[3] * 10 / 1000;
packet_buf->hold_vee_v = pel_hw.adc.results_f[4] * 10 / 1000;
packet_buf->current = 0;
packet_buf->resis_pattern_id = load_config.resistor.pattern_index;
packet_buf->resis_bitsmask = load_config.resistor.resistor_mask;
packet_buf->resis_g_value = load_config.resistor.resistor_conductance;
packet_buf->val_1 = 0xFFFFFFFF;
packet_buf->val_2 = 0xFFFFFFFF;
packet_buf->val_3 = 0xFFFF;
ret_code_t ret = le_event_async_notify((void *)packet_buf, packet_len, pdMS_TO_TICKS(5));
// NRF_LOG_HEXDUMP_INFO(packet_buf,packet_len);
for (int i = 0; i < ARRAY_SIZE(packet_buf->payload); i++)
{
char str[128];
snprintf(str, sizeof(str), "{%3d, %3d, %10lu, %10lu, %10lu, %10lu, %2.7f, %2.7f, %2.7f, %5d, 0x%04X, %.7f, %d}", packet_buf->mem_board_id, packet_buf->packet_seq, packet_buf->notify_time, packet_buf->output_vo_raw, packet_buf->output_vc_raw, packet_buf->output_ve_raw, packet_buf->hold_OUT_v, packet_buf->hold_VCC_v, packet_buf->hold_VEE_v, packet_buf->resis_pattern_id, packet_buf->resis_bitsmask, packet_buf->resis_g_value, packet_buf->mode_complete);
NRF_LOG_INFO("%s", str);
packet_buf->payload[i] = 0xFFFFFFFF;
}
}
void test_gpio_task(void *pArg)
{
const uint32_t pel_pins[] = {
INPUT_1_PIN,
INPUT_2_PIN,
INPUT_3_PIN,
INPUT_4_PIN,
INPUT_5_PIN,
INPUT_6_PIN,
INPUT_7_PIN,
INPUT_8_PIN,
INPUT_9_PIN,
INPUT_10_PIN,
INPUT_11_PIN,
INPUT_12_PIN,
ANODE_PIN,
CATHODE_PIN,
SAMPLE_R_PIN,
SAMPLE_V_PIN
};
ret_code_t ret = le_event_async_notify((void *)packet_buf, packet_len, pdMS_TO_TICKS(5));
for (;;)
if (DUMP_DATA)
{
for (uint32_t i = 0; i < packet_len; i++)
{
NRF_LOG_RAW_INFO("%02X ", ((uint8_t *)packet_buf)[i]);
}
NRF_LOG_RAW_INFO("\r\n");
NRF_LOG_INFO("[test] all output pin set low");
for (int i = 0; i < COUNTOF(pel_pins); i++)
{
nrf_gpio_pin_clear(pel_pins[i]);
}
vTaskDelay(1000);
char str[128];
snprintf(str, sizeof(str), "{%10d, %10d, %10lu,", packet_buf->mem_board_id, packet_buf->packet_seq, packet_buf->notify_time);
NRF_LOG_INFO("%s", str);
NRF_LOG_INFO("[test] all output pin set high");
for (int i = 0; i < COUNTOF(pel_pins); i++)
{
nrf_gpio_pin_set(pel_pins[i]);
}
vTaskDelay(1000);
snprintf(str, sizeof(str), " %10lu, %10lu, %10lu, %10lu, %10lu, %7.3f, %7.3f, %7.3f, %7.3f, %7.3f,", packet_buf->raw_output_r1, packet_buf->raw_output_r2, packet_buf->raw_output_vo, packet_buf->raw_output_vc, packet_buf->raw_output_ve, packet_buf->output_r1_mv, packet_buf->output_r2_mv, packet_buf->output_vo_mv, packet_buf->output_vc_mv, packet_buf->output_ve_mv);
NRF_LOG_INFO("%s", str);
NRF_LOG_INFO("[test] alternating high and low signals on all output pins");
for (int i = 0; i < COUNTOF(pel_pins); i++)
{
nrf_gpio_pin_clear(pel_pins[i]);
snprintf(str, sizeof(str), " %4.6f, %4.6f, %4.6f, %4.6f, %4.6f, %4.6f,", packet_buf->hold_r1_v, packet_buf->hold_r2_v, packet_buf->hold_out_v, packet_buf->hold_vcc_v, packet_buf->hold_vee_v, packet_buf->current);
NRF_LOG_INFO("%s", str);
snprintf(str, sizeof(str), " %10d, 0x%04X, %3.7f, %d}", packet_buf->resis_pattern_id, packet_buf->resis_bitsmask, packet_buf->resis_g_value, packet_buf->mode_complete);
NRF_LOG_INFO("%s", str);
}
vTaskDelay(1000);
for (int i = 0; i < COUNTOF(pel_pins); i++)
{
nrf_gpio_pin_set(pel_pins[i]);
vTaskDelay(100);
nrf_gpio_pin_clear(pel_pins[i]);
}
vTaskDelay(1000);
}
}
static void decode_and_set_resistor_pattern(uint8_t *param)
{
uint16_t pattern_id = u8_to_u16(param[0], param[1]);
set_resistor_load_pattern(pattern_id);
}
static void decode_and_set_manual_resistor(uint8_t *param)
{
uint16_t manual_val = u8_to_u16(param[0], param[1]);
set_resistor_load_bits(manual_val);
}
static void dev_mode_input_resistor(uint8_t *ins)
{
NRF_LOG_INFO("[DEV MODE] %s", __FUNCTION__);
@@ -349,30 +336,182 @@ static void dev_mode_input_resistor(uint8_t *ins)
uint8_t ins_type : 4;
uint8_t pkg_size;
uint8_t mode;
uint8_t func_id;
uint8_t opcode;
uint8_t mode_opcode; // dev mode could ignore
uint8_t dev_feat;
uint8_t dev_feat_opcode;
uint8_t param[];
} *p_ins = (void *)ins;
switch (p_ins->opcode)
switch (u8_to_u16(p_ins->dev_feat, p_ins->dev_feat_opcode))
{
case 0x00:
case 0x0100:
// 3000FFFF 0100
set_resistor_to_high_z();
break;
case 0x01:
decode_and_set_resistor_pattern(p_ins->param);
case 0x0101: {
// 3000FFFF 0101 0001
uint16_t pattern_id = u8_to_u16(p_ins->param[0], p_ins->param[1]);
set_resistor_load_pattern(pattern_id);
break;
}
case 0x02:
decode_and_set_manual_resistor(p_ins->param);
case 0x0102: {
// 3000FFFF 0102 000F
uint16_t manual_val = u8_to_u16(p_ins->param[0], p_ins->param[1]);
set_resistor_load_bits(manual_val);
break;
}
default:
break;
}
}
typedef struct
{
uint32_t gpio;
const char *gpio_desc;
} pin_map_entry_t;
#define UNDEF_GPIO 0xFFFFFFFF
static const pin_map_entry_t pin_to_gpio_table[64] = {
[1] = { UNDEF_GPIO, "UNDEF_GPIO" },
[2] = { UNDEF_GPIO, "UNDEF_GPIO" },
[3] = { UNDEF_GPIO, "UNDEF_GPIO" },
[4] = { UNDEF_GPIO, "UNDEF_GPIO" },
[5] = { UNDEF_GPIO, "UNDEF_GPIO" },
[6] = { NRF_GPIO_PIN_MAP(0, 22), "GPIO(0, 22)" },
[7] = { UNDEF_GPIO, "UNDEF_GPIO" },
[8] = { NRF_GPIO_PIN_MAP(0, 25), "GPIO(0, 25)" },
[9] = { NRF_GPIO_PIN_MAP(0, 19), "GPIO(0, 19)" },
[10] = { NRF_GPIO_PIN_MAP(0, 21), "GPIO(0, 21)" },
[11] = { NRF_GPIO_PIN_MAP(1, 0), "GPIO(1, 0)" },
[12] = { NRF_GPIO_PIN_MAP(0, 18), "GPIO(0, 18)" },
[13] = { NRF_GPIO_PIN_MAP(0, 17), "GPIO(0, 17)" },
[14] = { NRF_GPIO_PIN_MAP(0, 20), "GPIO(0, 20)" },
[15] = { UNDEF_GPIO, "UNDEF_GPIO" },
[16] = { NRF_GPIO_PIN_MAP(0, 14), "GPIO(0, 14)" },
[17] = { NRF_GPIO_PIN_MAP(0, 13), "GPIO(0, 13)" },
[18] = { NRF_GPIO_PIN_MAP(0, 11), "GPIO(0, 11)" },
[19] = { UNDEF_GPIO, "UNDEF_GPIO" },
[20] = { NRF_GPIO_PIN_MAP(0, 15), "GPIO(0, 15)" },
[21] = { UNDEF_GPIO, "UNDEF_GPIO" },
[22] = { UNDEF_GPIO, "UNDEF_GPIO" },
[23] = { UNDEF_GPIO, "UNDEF_GPIO" },
[24] = { UNDEF_GPIO, "UNDEF_GPIO" },
[25] = { NRF_GPIO_PIN_MAP(1, 8), "GPIO(1, 8)" },
[26] = { NRF_GPIO_PIN_MAP(0, 12), "GPIO(0, 12)" },
[27] = { NRF_GPIO_PIN_MAP(0, 7), "GPIO(0, 7)" },
[28] = { NRF_GPIO_PIN_MAP(1, 9), "GPIO(1, 9)" },
[29] = { NRF_GPIO_PIN_MAP(0, 8), "GPIO(0, 8)" },
[30] = { NRF_GPIO_PIN_MAP(0, 6), "GPIO(0, 6)" },
[31] = { NRF_GPIO_PIN_MAP(0, 5), "GPIO(0, 5)" },
[32] = { NRF_GPIO_PIN_MAP(0, 27), "GPIO(0, 27)" },
[33] = { NRF_GPIO_PIN_MAP(0, 26), "GPIO(0, 26)" },
[34] = { NRF_GPIO_PIN_MAP(0, 4), "GPIO(0, 4)" },
[35] = { UNDEF_GPIO, "UNDEF_GPIO" },
[36] = { NRF_GPIO_PIN_MAP(0, 1), "GPIO(0, 1)" },
[37] = { NRF_GPIO_PIN_MAP(0, 29), "GPIO(0, 29)" },
[38] = { NRF_GPIO_PIN_MAP(0, 0), "GPIO(0, 0)" },
[39] = { NRF_GPIO_PIN_MAP(0, 31), "GPIO(0, 31)" },
[40] = { NRF_GPIO_PIN_MAP(1, 15), "GPIO(1, 15)" },
[41] = { NRF_GPIO_PIN_MAP(0, 2), "GPIO(0, 2)" },
[42] = { NRF_GPIO_PIN_MAP(0, 30), "GPIO(0, 30)" },
[43] = { NRF_GPIO_PIN_MAP(0, 28), "GPIO(0, 28)" },
[44] = { NRF_GPIO_PIN_MAP(1, 12), "GPIO(1, 12)" },
[45] = { NRF_GPIO_PIN_MAP(1, 14), "GPIO(1, 14)" },
[46] = { NRF_GPIO_PIN_MAP(0, 3), "GPIO(0, 3)" },
[47] = { NRF_GPIO_PIN_MAP(1, 13), "GPIO(1, 13)" },
[48] = { NRF_GPIO_PIN_MAP(1, 3), "GPIO(1, 3)" },
[49] = { NRF_GPIO_PIN_MAP(1, 10), "GPIO(1, 10)" },
[50] = { NRF_GPIO_PIN_MAP(1, 6), "GPIO(1, 6)" },
[51] = { NRF_GPIO_PIN_MAP(1, 11), "GPIO(1, 11)" },
[52] = { NRF_GPIO_PIN_MAP(0, 10), "GPIO(0, 10)" },
[53] = { NRF_GPIO_PIN_MAP(0, 9), "GPIO(0, 9)" },
[54] = { UNDEF_GPIO, "UNDEF_GPIO" },
[55] = { UNDEF_GPIO, "UNDEF_GPIO" },
[56] = { UNDEF_GPIO, "UNDEF_GPIO" },
[57] = { UNDEF_GPIO, "UNDEF_GPIO" },
[58] = { UNDEF_GPIO, "UNDEF_GPIO" },
[59] = { NRF_GPIO_PIN_MAP(1, 2), "GPIO(1, 2)" },
[60] = { NRF_GPIO_PIN_MAP(0, 24), "GPIO(0, 24)" },
[61] = { NRF_GPIO_PIN_MAP(0, 23), "GPIO(0, 23)" },
[62] = { NRF_GPIO_PIN_MAP(0, 16), "GPIO(0, 16)" },
[63] = { UNDEF_GPIO, "UNDEF_GPIO" },
};
static void set_single_pin_as_output(uint16_t pin_number, uint16_t high_low)
{
const pin_map_entry_t *pin_entry = &pin_to_gpio_table[pin_number];
if (pin_entry->gpio == UNDEF_GPIO)
{
NRF_LOG_INFO("pin_number(%d) is not used", pin_number);
return;
}
if (high_low > 1) high_low = 1;
nrf_gpio_cfg_output(pin_entry->gpio);
nrf_gpio_pin_write(pin_entry->gpio, high_low);
NRF_LOG_INFO("pin_number(%d) = %d // pin_function_name: %s",
pin_number,
high_low,
pin_entry->gpio_desc);
}
static void set_all_pins_as_output(uint16_t high_low)
{
if (high_low > 1) high_low = 1;
for (uint16_t i = 1; i < ARRAY_SIZE(pin_to_gpio_table); i++)
{
if (pin_to_gpio_table[i].gpio != UNDEF_GPIO)
{
set_single_pin_as_output(i, high_low);
}
}
}
static void dev_mode_gpio(uint8_t *ins)
{
struct __PACKED
{
uint8_t id : 4;
uint8_t ins_type : 4;
uint8_t pkg_size;
uint8_t mode;
uint8_t mode_opcode; // dev mode could ignore
uint8_t dev_feat;
uint8_t dev_feat_opcode;
uint8_t param[];
} *p_ins = (void *)ins;
switch (u8_to_u16(p_ins->dev_feat, p_ins->dev_feat_opcode))
{
case 0xA000: {
// 3000FFFF A000
// pelv30_default_gpio();
break;
}
case 0xA001: {
// 3000FFFF A001 0008 0001
uint16_t pin_number = uint16_big_decode(&p_ins->param[0]);
uint16_t high_low = uint16_big_decode(&p_ins->param[2]);
set_single_pin_as_output(pin_number, high_low);
break;
}
case 0xA002: {
// 3000FFFF A002 0001
uint16_t high_low = uint16_big_decode(&p_ins->param[0]);
set_all_pins_as_output(high_low);
break;
}
}
}
static void start_adc_pulse(uint32_t pusle_cnt, void (*convt_done_cb)(void))
{
pel_config_t pel_cfg = {
@@ -424,20 +563,14 @@ static void pel_pulse_start(void *p_arg)
if (p_setting->is_pattern == true)
{
nrf_gpio_pin_set(RELAY1_PIN);
set_resistor_load_pattern(p_setting->pattern);
nrf_gpio_pin_clear(RELAY1_PIN);
}
else
{
nrf_gpio_pin_set(RELAY1_PIN);
set_resistor_load_bits(p_setting->bitmask);
nrf_gpio_pin_clear(RELAY1_PIN);
}
nrf_gpio_pin_set(TP2_PIN); // For testing
start_adc_pulse(0xFFFFFFFF, adc_event_end_cb);
nrf_gpio_pin_clear(TP2_PIN); // For testing
}
static void pel_pulse_stop(void *p_arg)
@@ -528,25 +661,29 @@ static void pel_scan_mode_task(void *pvArg)
static void dev_mode(uint8_t *ins, uint16_t size)
{
NRF_LOG_INFO("%s", __FUNCTION__);
struct __PACKED
{
uint8_t id : 4;
uint8_t ins_type : 4;
uint8_t pkg_size;
uint8_t mode;
uint8_t func_id;
uint8_t opcode;
uint8_t mode_opcode; // dev mode could ignore
uint8_t dev_feat;
uint8_t dev_feat_opcode;
uint8_t param[];
} *p_ins = (void *)ins;
global_memoryboard_id = p_ins->id;
switch (p_ins->func_id)
switch (p_ins->dev_feat)
{
case 0x01:
dev_mode_input_resistor(ins);
break;
case 0xA0:
dev_mode_gpio(ins);
break;
default:
break;
}
@@ -554,6 +691,7 @@ static void dev_mode(uint8_t *ins, uint16_t size)
static void manual_scan_mode(uint8_t *ins, uint16_t size)
{
NRF_LOG_INFO("%s", __FUNCTION__);
struct __PACKED
{
uint8_t id : 4;
@@ -576,6 +714,7 @@ static void manual_scan_mode(uint8_t *ins, uint16_t size)
// 30 00 01 00
pel_scan_msg.opcode = PEL_STOP;
ASSERT(xMessageBufferSend(pel_scan_msqQ, &pel_scan_msg, sizeof(pel_scan_msg.opcode), pdMS_TO_TICKS(500)));
running = false;
break;
}
@@ -593,6 +732,7 @@ static void manual_scan_mode(uint8_t *ins, uint16_t size)
pel_scan_msg.notify_setting.drop = u8_to_u16(p_ins->param[4], p_ins->param[5]);
pel_scan_msg.notify_setting.count = u8_to_u16(p_ins->param[6], p_ins->param[7]);
ASSERT(xMessageBufferSend(pel_scan_msqQ, &pel_scan_msg, sizeof(pel_scan_msg.opcode) + sizeof(pel_scan_msg.notify_setting), pdMS_TO_TICKS(500)));
running = true;
break;
}
@@ -685,11 +825,14 @@ static void auto_scan_start_task(void *p_arg)
auto_scan_start_handle = NULL;
running = false;
vTaskDelete(NULL);
}
static void auto_scan_mode(uint8_t *ins, uint16_t size)
{
NRF_LOG_INFO("%s", __FUNCTION__);
struct __PACKED
{
uint8_t id : 4;
@@ -720,6 +863,7 @@ static void auto_scan_mode(uint8_t *ins, uint16_t size)
vTaskDelete(auto_scan_start_handle);
auto_scan_start_handle = NULL;
}
running = false;
taskEXIT_CRITICAL();
break;
}
@@ -735,11 +879,18 @@ static void auto_scan_mode(uint8_t *ins, uint16_t size)
uint8_t payload[256];
} param;
param.size = MIN(size, sizeof(param.payload)),
param.size = MIN(size, sizeof(param.payload));
memcpy(param.payload, ins, param.size);
ASSERT(xTaskCreate(auto_scan_start_task, "auto_start", 256, &param, 4, &auto_scan_start_handle));
BaseType_t ret = xTaskCreate(auto_scan_start_task, "auto_start", 320, &param, 4, &auto_scan_start_handle);
if (ret != pdPASS)
{
NRF_LOG_ERROR("auto_scan_start_task task not created.");
}
// using a 100ms delay to ensure the parameter is copied to to auto_scan_start_task()
vTaskDelay(pdMS_TO_TICKS(100));
running = true;
}
break;
}
@@ -751,6 +902,7 @@ static void auto_scan_mode(uint8_t *ins, uint16_t size)
static void R_external_calibration_mode(uint8_t *ins, uint16_t size)
{
NRF_LOG_INFO("%s", __FUNCTION__);
#define R1 PEL_0P5R_MASK
#define R2 PEL_1P0R_MASK
#define R3 PEL_2P0R_MASK
@@ -842,10 +994,6 @@ static void R_external_calibration_mode(uint8_t *ins, uint16_t size)
}
}
#define MANUAL_SCAN_MODE 0x01
#define AUTO_SCAN_MODE 0x02
#define R_EXTERNAL_CALIBRATION_MODE 0x03
const elite_instance_t pel_elite_instance = {
.cis_func = {
[CIS_VERSION] = cis_version,
+397
View File
@@ -0,0 +1,397 @@
#include "elite_board.h"
#include "nrf_gpio.h"
#include "nrf_gpiote.h"
#include "nrf_spim.h"
#include "nrf_timer.h"
#include "FreeRTOS.h"
#include "semphr.h"
#include "task.h"
#include "SEGGER_RTT.h"
#if (DEF_ELITE_MODEL == DEF_ELITE_PEL_V2_0)
pel_hw_t pel_hw = {
.pulse_tmr = NRF_TIMER3,
.pulse_irq_n = TIMER3_IRQn,
.pulse_cnt = 0,
.adc.channels = {
[OUTPUT_R1_IDX] = OUTPUT_R1_CHANNEL,
[OUTPUT_R2_IDX] = OUTPUT_R2_CHANNEL,
[OUTPUT_VO_IDX] = OUTPUT_VO_CHANNEL,
[OUTPUT_VC_IDX] = OUTPUT_VC_CHANNEL,
[OUTPUT_VE_IDX] = OUTPUT_VE_CHANNEL },
.adc.gain = NRF_SAADC_GAIN1_6,
.adc.smaple_time = NRF_SAADC_ACQTIME_3US
};
void spim_xfer(uint32_t cs_pin,
nrf_spim_mode_t spi_mode,
uint8_t *p_tx_buffer,
uint16_t tx_buffer_length,
uint8_t *p_rx_buf,
uint16_t rx_buffer_length)
{
__disable_irq();
NRF_SPIM3->ENABLE = SPIM_ENABLE_ENABLE_Disabled << SPIM_ENABLE_ENABLE_Pos;
switch (spi_mode)
{
default:
case NRF_SPIM_MODE_0:
NRF_SPIM3->CONFIG = (SPIM_CONFIG_ORDER_MsbFirst << SPIM_CONFIG_ORDER_Pos) |
(SPIM_CONFIG_CPOL_ActiveHigh << SPIM_CONFIG_CPOL_Pos) |
(SPIM_CONFIG_CPHA_Leading << SPIM_CONFIG_CPHA_Pos);
break;
case NRF_SPIM_MODE_1:
NRF_SPIM3->CONFIG = (SPIM_CONFIG_ORDER_MsbFirst << SPIM_CONFIG_ORDER_Pos) |
(SPIM_CONFIG_CPOL_ActiveHigh << SPIM_CONFIG_CPOL_Pos) |
(SPIM_CONFIG_CPHA_Trailing << SPIM_CONFIG_CPHA_Pos);
break;
case NRF_SPIM_MODE_2:
NRF_SPIM3->CONFIG = (SPIM_CONFIG_ORDER_MsbFirst << SPIM_CONFIG_ORDER_Pos) |
(SPIM_CONFIG_CPOL_ActiveLow << SPIM_CONFIG_CPOL_Pos) |
(SPIM_CONFIG_CPHA_Leading << SPIM_CONFIG_CPHA_Pos);
break;
case NRF_SPIM_MODE_3:
NRF_SPIM3->CONFIG = (SPIM_CONFIG_ORDER_MsbFirst << SPIM_CONFIG_ORDER_Pos) |
(SPIM_CONFIG_CPOL_ActiveLow << SPIM_CONFIG_CPOL_Pos) |
(SPIM_CONFIG_CPHA_Trailing << SPIM_CONFIG_CPHA_Pos);
break;
}
NRF_SPIM3->ENABLE = SPIM_ENABLE_ENABLE_Enabled << SPIM_ENABLE_ENABLE_Pos;
NRF_SPIM3->TXD.MAXCNT = tx_buffer_length;
NRF_SPIM3->TXD.PTR = (uint32_t)p_tx_buffer;
NRF_SPIM3->RXD.MAXCNT = rx_buffer_length;
NRF_SPIM3->RXD.PTR = (uint32_t)p_rx_buf;
nrf_gpio_pin_clear(cs_pin);
NRF_SPIM3->EVENTS_END = 0;
NRF_SPIM3->TASKS_START = 1;
do {
} while (NRF_SPIM3->EVENTS_END == 0);
nrf_gpio_pin_set(cs_pin);
__enable_irq();
}
#define MIN_PULSE_WIDTH 2
#define MIN_PULSE_IDLE 2
#define MAX_PULSE_WIDTH INT16_MAX
#define MAX_PULSE_IDLE INT16_MAX
static void pel_saadc_init(pel_adc_t *p_adc)
{
/* stop ssadc */
NRF_SAADC->EVENTS_STOPPED = 0;
NRF_SAADC->TASKS_STOP = 1;
do {
} while (NRF_SAADC->EVENTS_STOPPED == 0);
/* disable ssadc */
NRF_SAADC->ENABLE = 0;
/*
ref: p.381, nrf52840_PS_v1.1.pdf
Note: Oversampling should only be used when a single input channel is enabled, as averaging is
performed over all enabled channels.
*/
NRF_SAADC->OVERSAMPLE = SAADC_OVERSAMPLE_OVERSAMPLE_Bypass;
NRF_SAADC->RESOLUTION = SAADC_RESOLUTION_VAL_14bit;
/* config analog inputs */
for (uint32_t i = 0; i < COUNTOF(NRF_SAADC->CH); i++)
{
if (i < COUNTOF(p_adc->channels))
{
NRF_SAADC->CH[i].PSELP = NRF_SAADC_INPUT_AIN0 + p_adc->channels[i];
NRF_SAADC->CH[i].PSELN = NRF_SAADC_INPUT_DISABLED;
NRF_SAADC->CH[i].CONFIG =
(NRF_SAADC_RESISTOR_DISABLED << SAADC_CH_CONFIG_RESP_Pos) |
(NRF_SAADC_RESISTOR_DISABLED << SAADC_CH_CONFIG_RESN_Pos) |
(p_adc->gain << SAADC_CH_CONFIG_GAIN_Pos) |
(NRF_SAADC_REFERENCE_INTERNAL << SAADC_CH_CONFIG_REFSEL_Pos) |
(p_adc->smaple_time << SAADC_CH_CONFIG_TACQ_Pos) |
(NRF_SAADC_MODE_SINGLE_ENDED << SAADC_CH_CONFIG_MODE_Pos) |
(NRF_SAADC_BURST_DISABLED << SAADC_CH_CONFIG_BURST_Pos);
}
else
{
NRF_SAADC->CH[i].PSELP = NRF_SAADC_INPUT_DISABLED;
NRF_SAADC->CH[i].PSELN = NRF_SAADC_INPUT_DISABLED;
NRF_SAADC->CH[i].CONFIG = 0;
}
}
/* enable ssadc */
NRF_SAADC->INTENSET = NRF_SAADC_INT_STARTED | NRF_SAADC_INT_END;
NRF_SAADC->ENABLE = 1;
NRF_SAADC->RESULT.PTR = (uint32_t)p_adc->results;
NRF_SAADC->RESULT.MAXCNT = COUNTOF(p_adc->results);
}
void TIMER3_IRQHandler(void)
{
if (pel_hw.pulse_tmr->EVENTS_COMPARE[0])
{
pel_hw.pulse_tmr->EVENTS_COMPARE[0] = 0;
pel_hw.pulse_is_running = 1;
if (pel_hw.pulse_cnt)
{
pel_hw.pulse_cnt--;
}
}
}
void SAADC_IRQHandler(void)
{
if (NRF_SAADC->EVENTS_STARTED)
{
NRF_SAADC->EVENTS_STARTED = 0;
if (pel_hw.pulse_cnt == 0)
{
pel_hw.pulse_tmr->TASKS_STOP = 1;
}
return;
}
if (NRF_SAADC->EVENTS_END)
{
NRF_SAADC->EVENTS_END = 0;
NRF_SAADC->RESULT.PTR = (uint32_t)pel_hw.adc.results;
NRF_SAADC->RESULT.MAXCNT = COUNTOF(pel_hw.adc.results);
pel_hw.pulse_is_running = 0;
if (pel_hw.adc.convt_new_arrival_cb)
{
pel_hw.adc.convt_new_arrival_cb();
}
}
}
void pel_pulse_gen_init(pel_config_t cfg)
{
pel_hw.pulse_tmr->TASKS_STOP = 1;
sd_nvic_DisableIRQ(pel_hw.pulse_irq_n);
sd_nvic_ClearPendingIRQ(pel_hw.pulse_irq_n);
sd_nvic_DisableIRQ(SAADC_IRQn);
sd_nvic_ClearPendingIRQ(SAADC_IRQn);
pel_hw.pulse_cnt = cfg.pulse_cnt;
pel_hw.adc.gain = cfg.gain;
pel_hw.adc.smaple_time = cfg.smaple_time;
pel_hw.adc.convt_new_arrival_cb = cfg.convt_new_arrival_cb;
pel_saadc_init(&pel_hw.adc);
// disable gpio task
for (int i = 0; i < 4; i++)
{
nrf_gpiote_task_disable(i);
}
// config gpiote task
nrf_gpiote_task_configure(0, cfg.anode_pin, NRF_GPIOTE_POLARITY_TOGGLE, (cfg.mode == 0) ? NRF_GPIOTE_INITIAL_VALUE_HIGH : NRF_GPIOTE_INITIAL_VALUE_LOW);
nrf_gpiote_task_configure(1, cfg.smaple_r_pin, NRF_GPIOTE_POLARITY_TOGGLE, NRF_GPIOTE_INITIAL_VALUE_LOW);
nrf_gpiote_task_configure(2, cfg.sample_v_pin, NRF_GPIOTE_POLARITY_TOGGLE, NRF_GPIOTE_INITIAL_VALUE_LOW);
NRF_PPI->CH[0].EEP = (uint32_t)&pel_hw.pulse_tmr->EVENTS_COMPARE[0];
NRF_PPI->CH[0].TEP = (uint32_t)&NRF_GPIOTE->TASKS_OUT[0]; // anode_pin
NRF_PPI->CHENSET = (1 << (0));
NRF_PPI->CH[1].EEP = (uint32_t)&pel_hw.pulse_tmr->EVENTS_COMPARE[1];
NRF_PPI->CH[1].TEP = (uint32_t)&NRF_GPIOTE->TASKS_OUT[1]; // smaple_r_pin
NRF_PPI->FORK[1].TEP = (uint32_t)&NRF_GPIOTE->TASKS_OUT[2]; // sample_v_pin
NRF_PPI->CHENSET = (1 << (1));
NRF_PPI->CH[2].EEP = (uint32_t)&pel_hw.pulse_tmr->EVENTS_COMPARE[2];
NRF_PPI->CH[2].TEP = (uint32_t)&NRF_GPIOTE->TASKS_OUT[1];
NRF_PPI->FORK[2].TEP = (uint32_t)&NRF_GPIOTE->TASKS_OUT[2];
NRF_PPI->CHENSET = (1 << (2));
NRF_PPI->CH[3].EEP = (uint32_t)&pel_hw.pulse_tmr->EVENTS_COMPARE[3];
NRF_PPI->CH[3].TEP = (uint32_t)&NRF_GPIOTE->TASKS_OUT[0];
NRF_PPI->CHENSET = (1 << (3));
NRF_PPI->CH[4].EEP = (uint32_t)&pel_hw.pulse_tmr->EVENTS_COMPARE[4];
NRF_PPI->CH[4].TEP = (uint32_t)&NRF_SAADC->TASKS_START;
NRF_PPI->CHENSET = (1 << (4));
NRF_PPI->CH[5].EEP = (uint32_t)&NRF_SAADC->EVENTS_STARTED;
NRF_PPI->CH[5].TEP = (uint32_t)&NRF_SAADC->TASKS_SAMPLE;
NRF_PPI->CHENSET = (1 << (5));
NRF_PPI->CH[6].EEP = (uint32_t)&NRF_SAADC->EVENTS_END;
NRF_PPI->CHENSET = (1 << (6));
// enable gpio task
for (int i = 0; i < 3; i++)
{
nrf_gpiote_task_enable(i);
}
if (cfg.test_pin != 0xFFFFFFFF)
{
nrf_gpiote_task_configure(3, cfg.test_pin, NRF_GPIOTE_POLARITY_TOGGLE, NRF_GPIOTE_INITIAL_VALUE_LOW);
NRF_PPI->FORK[5].TEP = (uint32_t)&NRF_GPIOTE->TASKS_OUT[3]; // test_pin
NRF_PPI->CH[6].TEP = (uint32_t)&NRF_GPIOTE->TASKS_OUT[3];
nrf_gpiote_task_enable(3);
}
pel_hw.pulse_tmr->PRESCALER = NRF_TIMER_FREQ_16MHz;
pel_hw.pulse_tmr->MODE = NRF_TIMER_MODE_TIMER;
pel_hw.pulse_tmr->BITMODE = NRF_TIMER_BIT_WIDTH_32;
pel_hw.pulse_tmr->CC[0] = cfg.point_us[0] * 16;
pel_hw.pulse_tmr->CC[1] = pel_hw.pulse_tmr->CC[0] + cfg.point_us[1] * 16;
pel_hw.pulse_tmr->CC[2] = pel_hw.pulse_tmr->CC[1] + cfg.point_us[2] * 16;
pel_hw.pulse_tmr->CC[3] = pel_hw.pulse_tmr->CC[2] + cfg.point_us[3] * 16;
pel_hw.pulse_tmr->CC[4] = pel_hw.pulse_tmr->CC[3] + cfg.point_us[4] * 16 + cfg.adc_timing_shift;
pel_hw.pulse_tmr->CC[5] = pel_hw.pulse_tmr->CC[4];
pel_hw.pulse_tmr->SHORTS = NRF_TIMER_SHORT_COMPARE5_CLEAR_MASK;
pel_hw.pulse_tmr->INTENSET = NRF_TIMER_INT_COMPARE0_MASK;
sd_nvic_SetPriority(SAADC_IRQn, _PRIO_APP_HIGH);
sd_nvic_EnableIRQ(SAADC_IRQn);
sd_nvic_SetPriority(pel_hw.pulse_irq_n, _PRIO_APP_HIGH);
sd_nvic_EnableIRQ(pel_hw.pulse_irq_n);
}
void pel_pulse_gen_start(void)
{
pel_hw.pulse_tmr->TASKS_START = 1;
}
void pel_pulse_gen_stop(void)
{
pel_hw.pulse_cnt = 0;
do {
} while (pel_hw.pulse_is_running == 1);
pel_hw.adc.convt_new_arrival_cb = NULL;
}
#if (DEF_ELITE_DEMO_W_SOFTDEVICE == 1) || (DEF_ELITE_DEMO_WO_SOFTDEVICE == 1)
static void pel_pulse_gen_demo_task(void *p_arg)
{
pel_config_t pel_cfg = {
.anode_pin = ANODE_PIN,
.cathode_pin = CATHODE_PIN,
.smaple_r_pin = SAMPLE_R_PIN,
.sample_v_pin = SAMPLE_V_PIN,
.test_pin = TP1_PIN,
.mode = BOARD_IOPx,
.point_us = {
10000,
3,
5,
2,
0,
},
.pulse_cnt = 0xFFFFFFFF,
.gain = NRF_SAADC_GAIN1_6,
.smaple_time = NRF_SAADC_ACQTIME_10US,
.adc_timing_shift = 0,
};
pel_pulse_gen_init(pel_cfg);
pel_pulse_gen_start();
for (;;)
{
static uint32_t i = 0;
vTaskDelay(pdMS_TO_TICKS(pel_cfg.point_us[0] / 1000));
SEGGER_RTT_printf(0, "%d, %d, %d, %d, %d, %d\r\n", i++, pel_hw.adc.results[0], pel_hw.adc.results[1], pel_hw.adc.results[2], pel_hw.adc.results[3], pel_hw.adc.results[4]);
}
}
void pel_pulse_gen_demo(void)
{
}
#endif
void pel20_io_init(void)
{
// common gpio
const uint32_t config_output_and_set[] = {
INPUT_1_PIN,
INPUT_2_PIN,
INPUT_3_PIN,
INPUT_4_PIN,
INPUT_5_PIN,
INPUT_6_PIN,
INPUT_7_PIN,
INPUT_8_PIN,
INPUT_9_PIN,
INPUT_10_PIN,
INPUT_11_PIN,
INPUT_12_PIN
};
const uint32_t config_output_and_clear[] = {
TP1_PIN,
TP2_PIN,
SAMPLE_R_PIN,
SAMPLE_V_PIN,
};
for (int i = 0; i < ARRAY_SIZE(config_output_and_set); i++)
{
nrf_gpio_pin_set(config_output_and_set[i]);
nrf_gpio_cfg_output(config_output_and_set[i]);
}
for (int i = 0; i < ARRAY_SIZE(config_output_and_clear); i++)
{
nrf_gpio_pin_clear(config_output_and_clear[i]);
nrf_gpio_cfg_output(config_output_and_clear[i]);
}
nrf_gpio_cfg_input(CATHODE_PIN, NRF_GPIO_PIN_NOPULL);
// specific gpio
if (BOARD_IOPx == BOARD_IOPH)
{
nrf_gpio_pin_clear(ANODE_PIN);
nrf_gpio_cfg_output(ANODE_PIN);
}
else if (BOARD_IOPx == BOARD_IOPL)
{
nrf_gpio_pin_set(ANODE_PIN);
nrf_gpio_cfg_output(ANODE_PIN);
}
// Config spi module
nrf_gpio_pin_set(WP_MEM_PIN);
nrf_gpio_pin_set(CS_MEM_PIN);
nrf_gpio_pin_clear(SPIM_MOSI_PIN);
nrf_gpio_pin_clear(SPIM_CLK_PIN);
nrf_gpio_cfg_output(WP_MEM_PIN);
nrf_gpio_cfg_output(CS_MEM_PIN);
nrf_gpio_cfg_output(SPIM_MOSI_PIN);
nrf_gpio_cfg_output(SPIM_CLK_PIN);
nrf_gpio_cfg_input(SPIM_MISO_PIN, NRF_GPIO_PIN_NOPULL);
NRF_SPIM3->ENABLE = SPIM_ENABLE_ENABLE_Disabled << SPIM_ENABLE_ENABLE_Pos;
NRF_SPIM3->ORC = 0x00000000;
NRF_SPIM3->FREQUENCY = SPIM_FREQUENCY_FREQUENCY_M32;
NRF_SPIM3->CSNPOL = SPIM_CSNPOL_CSNPOL_LOW;
NRF_SPIM3->IFTIMING.CSNDUR = 8;
NRF_SPIM3->PSEL.CSN = CS_MEM_PIN;
NRF_SPIM3->PSEL.SCK = SPIM_CLK_PIN;
NRF_SPIM3->PSEL.MOSI = SPIM_MOSI_PIN;
NRF_SPIM3->PSEL.MISO = SPIM_MISO_PIN;
NRF_SPIM3->ENABLE = SPIM_ENABLE_ENABLE_Enabled << SPIM_ENABLE_ENABLE_Pos;
}
#endif
File diff suppressed because it is too large Load Diff
+77 -89
View File
@@ -1,3 +1,4 @@
#include "app_config.h"
#include "elite_board.h"
#include "nrf_gpio.h"
@@ -12,18 +13,18 @@
#include "SEGGER_RTT.h"
#if (DEF_ELITE_MODEL == DEF_ELITE_PEL_V2_0)
#if (DEF_ELITE_MODEL == DEF_ELITE_PEL_V3_0)
pel_hw_t pel_hw = {
.pulse_tmr = NRF_TIMER3,
.pulse_irq_n = TIMER3_IRQn,
.pulse_cnt = 0,
.adc.channels = {
[OUTPUT_R1_IDX] = OUTPUT_R1_CHANNEL,
[OUTPUT_R2_IDX] = OUTPUT_R2_CHANNEL,
[OUTPUT_VO_IDX] = OUTPUT_VO_CHANNEL,
[OUTPUT_VC_IDX] = OUTPUT_VC_CHANNEL,
[OUTPUT_VE_IDX] = OUTPUT_VE_CHANNEL},
[OUTPUT_ACS37030_REF_IDX] = OUTPUT_ACS37030_VREF_CHANNEL,
[OUTPUT_I_OUT_IDX] = OUTPUT_I_OUT_CHANNEL,
[OUTPUT_VO_IDX] = OUTPUT_VO_CHANNEL,
[OUTPUT_VC_IDX] = OUTPUT_VC_CHANNEL,
[OUTPUT_VE_IDX] = OUTPUT_VE_CHANNEL },
.adc.gain = NRF_SAADC_GAIN1_6,
.adc.smaple_time = NRF_SAADC_ACQTIME_3US
};
@@ -92,30 +93,6 @@ void spim_xfer(uint32_t cs_pin,
#define MAX_PULSE_WIDTH INT16_MAX
#define MAX_PULSE_IDLE INT16_MAX
void set_anode_cathode_to_default(void)
{
if (BOARD_IOPx == BOARD_IOPL)
{
nrf_gpio_pin_set(ANODE_PIN);
nrf_gpio_pin_clear(CATHODE_PIN);
nrf_gpio_pin_clear(SAMPLE_R_PIN);
nrf_gpio_pin_clear(SAMPLE_V_PIN);
nrf_gpio_pin_clear(TP1_PIN);
nrf_gpio_pin_clear(TP2_PIN);
nrf_gpio_pin_clear(RELAY1_PIN);
}
else if (BOARD_IOPx == BOARD_IOPH)
{
nrf_gpio_pin_clear(ANODE_PIN);
nrf_gpio_pin_set(CATHODE_PIN);
nrf_gpio_pin_clear(SAMPLE_R_PIN);
nrf_gpio_pin_clear(SAMPLE_V_PIN);
nrf_gpio_pin_clear(TP1_PIN);
nrf_gpio_pin_clear(TP2_PIN);
nrf_gpio_pin_clear(RELAY1_PIN);
}
}
static void pel_saadc_init(pel_adc_t *p_adc)
{
/* stop ssadc */
@@ -207,10 +184,8 @@ void SAADC_IRQHandler(void)
void pel_pulse_gen_init(pel_config_t cfg)
{
pel_hw.pulse_tmr->TASKS_STOP = 1;
sd_nvic_DisableIRQ(pel_hw.pulse_irq_n);
sd_nvic_ClearPendingIRQ(pel_hw.pulse_irq_n);
sd_nvic_DisableIRQ(SAADC_IRQn);
sd_nvic_ClearPendingIRQ(SAADC_IRQn);
@@ -218,7 +193,6 @@ void pel_pulse_gen_init(pel_config_t cfg)
pel_hw.adc.gain = cfg.gain;
pel_hw.adc.smaple_time = cfg.smaple_time;
pel_hw.adc.convt_new_arrival_cb = cfg.convt_new_arrival_cb;
pel_saadc_init(&pel_hw.adc);
// disable gpio task
@@ -227,44 +201,20 @@ void pel_pulse_gen_init(pel_config_t cfg)
nrf_gpiote_task_disable(i);
}
set_anode_cathode_to_default();
// config gpiote task
switch (cfg.mode)
{
default:
case 1:
nrf_gpiote_task_configure(0, cfg.anode_pin, NRF_GPIOTE_POLARITY_TOGGLE, NRF_GPIOTE_INITIAL_VALUE_LOW);
nrf_gpiote_task_configure(1, cfg.cathode_pin, NRF_GPIOTE_POLARITY_TOGGLE, NRF_GPIOTE_INITIAL_VALUE_HIGH);
break;
case 0:
nrf_gpiote_task_configure(0, cfg.anode_pin, NRF_GPIOTE_POLARITY_TOGGLE, NRF_GPIOTE_INITIAL_VALUE_HIGH);
nrf_gpiote_task_configure(1, cfg.cathode_pin, NRF_GPIOTE_POLARITY_TOGGLE, NRF_GPIOTE_INITIAL_VALUE_LOW);
break;
}
nrf_gpiote_task_configure(2, cfg.smaple_r_pin, NRF_GPIOTE_POLARITY_TOGGLE, NRF_GPIOTE_INITIAL_VALUE_LOW);
nrf_gpiote_task_configure(0, cfg.anode_pin, NRF_GPIOTE_POLARITY_TOGGLE, (cfg.mode == 0) ? NRF_GPIOTE_INITIAL_VALUE_HIGH : NRF_GPIOTE_INITIAL_VALUE_LOW);
nrf_gpiote_task_configure(1, cfg.ina_hi_pin, NRF_GPIOTE_POLARITY_TOGGLE, (cfg.mode == 0) ? NRF_GPIOTE_INITIAL_VALUE_HIGH : NRF_GPIOTE_INITIAL_VALUE_LOW);
nrf_gpiote_task_configure(2, cfg.smaple_i_pin, NRF_GPIOTE_POLARITY_TOGGLE, NRF_GPIOTE_INITIAL_VALUE_LOW);
nrf_gpiote_task_configure(3, cfg.sample_v_pin, NRF_GPIOTE_POLARITY_TOGGLE, NRF_GPIOTE_INITIAL_VALUE_LOW);
if (cfg.test_pin != 0xFFFFFFFF)
{
nrf_gpiote_task_configure(4, cfg.test_pin, NRF_GPIOTE_POLARITY_TOGGLE, NRF_GPIOTE_INITIAL_VALUE_LOW);
}
// enable gpio task
for (int i = 0; i < 5; i++)
{
nrf_gpiote_task_enable(i);
}
NRF_PPI->CH[0].EEP = (uint32_t)&pel_hw.pulse_tmr->EVENTS_COMPARE[0];
NRF_PPI->CH[0].TEP = (uint32_t)&NRF_GPIOTE->TASKS_OUT[0];
NRF_PPI->FORK[0].TEP = (uint32_t)&NRF_GPIOTE->TASKS_OUT[1];
NRF_PPI->CH[0].TEP = (uint32_t)&NRF_GPIOTE->TASKS_OUT[0]; // anode_pin
NRF_PPI->FORK[0].TEP = (uint32_t)&NRF_GPIOTE->TASKS_OUT[1]; // ina_hi_pin
NRF_PPI->CHENSET = (1 << (0));
NRF_PPI->CH[1].EEP = (uint32_t)&pel_hw.pulse_tmr->EVENTS_COMPARE[1];
NRF_PPI->CH[1].TEP = (uint32_t)&NRF_GPIOTE->TASKS_OUT[2];
NRF_PPI->FORK[1].TEP = (uint32_t)&NRF_GPIOTE->TASKS_OUT[3];
NRF_PPI->CH[1].TEP = (uint32_t)&NRF_GPIOTE->TASKS_OUT[2]; // smaple_i_pin
NRF_PPI->FORK[1].TEP = (uint32_t)&NRF_GPIOTE->TASKS_OUT[3]; // sample_v_pin
NRF_PPI->CHENSET = (1 << (1));
NRF_PPI->CH[2].EEP = (uint32_t)&pel_hw.pulse_tmr->EVENTS_COMPARE[2];
@@ -281,15 +231,25 @@ void pel_pulse_gen_init(pel_config_t cfg)
NRF_PPI->CH[4].TEP = (uint32_t)&NRF_SAADC->TASKS_START;
NRF_PPI->CHENSET = (1 << (4));
NRF_PPI->CH[5].EEP = (uint32_t)&NRF_SAADC->EVENTS_STARTED;
NRF_PPI->CH[5].TEP = (uint32_t)&NRF_SAADC->TASKS_SAMPLE;
NRF_PPI->CHENSET = (1 << (5));
NRF_PPI->CH[6].EEP = (uint32_t)&NRF_SAADC->EVENTS_END;
NRF_PPI->CHENSET = (1 << (6));
// enable gpio task
for (int i = 0; i < 4; i++)
{
nrf_gpiote_task_enable(i);
}
if (cfg.test_pin != 0xFFFFFFFF)
{
NRF_PPI->CH[6].EEP = (uint32_t)&NRF_SAADC->EVENTS_STARTED;
NRF_PPI->CH[6].TEP = (uint32_t)&NRF_SAADC->TASKS_SAMPLE;
NRF_PPI->FORK[6].TEP = (uint32_t)&NRF_GPIOTE->TASKS_OUT[4];
NRF_PPI->CHENSET = (1 << (6));
NRF_PPI->CH[7].EEP = (uint32_t)&NRF_SAADC->EVENTS_END;
NRF_PPI->CH[7].TEP = (uint32_t)&NRF_GPIOTE->TASKS_OUT[4];
NRF_PPI->CHENSET = (1 << (7));
nrf_gpiote_task_configure(4, cfg.test_pin, NRF_GPIOTE_POLARITY_TOGGLE, NRF_GPIOTE_INITIAL_VALUE_LOW);
NRF_PPI->FORK[5].TEP = (uint32_t)&NRF_GPIOTE->TASKS_OUT[4]; // test_pin
NRF_PPI->CH[6].TEP = (uint32_t)&NRF_GPIOTE->TASKS_OUT[4];
nrf_gpiote_task_enable(4);
}
pel_hw.pulse_tmr->PRESCALER = NRF_TIMER_FREQ_16MHz;
@@ -329,8 +289,8 @@ static void pel_pulse_gen_demo_task(void *p_arg)
{
pel_config_t pel_cfg = {
.anode_pin = ANODE_PIN,
.cathode_pin = CATHODE_PIN,
.smaple_r_pin = SAMPLE_R_PIN,
.ina_hi_pin = INA_HI_PIN,
.smaple_i_pin = SAMPLE_I_PIN,
.sample_v_pin = SAMPLE_V_PIN,
.test_pin = TP1_PIN,
.mode = BOARD_IOPx,
@@ -364,9 +324,9 @@ void pel_pulse_gen_demo(void)
}
#endif
void pel20_io_init(void)
void pel30_io_init(void)
{
const uint32_t pel_pins_default_high[] = {
const uint32_t config_output_and_set[] = {
INPUT_1_PIN,
INPUT_2_PIN,
INPUT_3_PIN,
@@ -381,30 +341,58 @@ void pel20_io_init(void)
INPUT_12_PIN
};
for (int i = 0; i < COUNTOF(pel_pins_default_high); i++)
const uint32_t config_output_and_clear[] = {
TP1_PIN,
TP2_PIN,
SAMPLE_I_PIN,
SAMPLE_V_PIN,
HOT_SWAP_1_PIN
};
for (int i = 0; i < ARRAY_SIZE(config_output_and_set); i++)
{
nrf_gpio_pin_set(pel_pins_default_high[i]);
nrf_gpio_cfg_output(pel_pins_default_high[i]);
nrf_gpio_pin_set(config_output_and_set[i]);
nrf_gpio_cfg_output(config_output_and_set[i]);
}
for (int i = 0; i < ARRAY_SIZE(config_output_and_clear); i++)
{
nrf_gpio_pin_clear(config_output_and_clear[i]);
nrf_gpio_cfg_output(config_output_and_clear[i]);
}
nrf_gpio_cfg_input(RESET_PIN, NRF_GPIO_PIN_NOPULL);
nrf_gpio_cfg_input(CATHODE_PIN, NRF_GPIO_PIN_NOPULL);
nrf_gpio_cfg_input(HOT_SWAP_SIGNAL_PIN, NRF_GPIO_PIN_PULLUP);
if (BOARD_IOPx == BOARD_IOPH)
{
nrf_gpio_pin_clear(ANODE_PIN);
nrf_gpio_pin_clear(INA_HI_PIN);
nrf_gpio_pin_set(LED_IOPL_PIN);
nrf_gpio_pin_clear(LED_IOPH_PIN);
}
else if (BOARD_IOPx == BOARD_IOPL)
{
nrf_gpio_pin_set(ANODE_PIN);
nrf_gpio_pin_set(INA_HI_PIN);
nrf_gpio_pin_clear(LED_IOPL_PIN);
nrf_gpio_pin_set(LED_IOPH_PIN);
}
set_anode_cathode_to_default();
nrf_gpio_cfg_output(ANODE_PIN);
nrf_gpio_cfg_output(CATHODE_PIN);
nrf_gpio_cfg_output(SAMPLE_R_PIN);
nrf_gpio_cfg_output(SAMPLE_V_PIN);
nrf_gpio_cfg_output(TP1_PIN);
nrf_gpio_cfg_output(TP2_PIN);
nrf_gpio_cfg_output(RELAY1_PIN);
nrf_gpio_cfg_output(INA_HI_PIN);
nrf_gpio_cfg_output(LED_IOPL_PIN);
nrf_gpio_cfg_output(LED_IOPH_PIN);
// Config spi module
nrf_gpio_pin_set(WP_MEM_PIN);
nrf_gpio_cfg_output(WP_MEM_PIN);
nrf_gpio_pin_set(CS_MEM_PIN);
nrf_gpio_cfg_output(CS_MEM_PIN);
nrf_gpio_pin_clear(SPIM_MOSI_PIN);
nrf_gpio_cfg_output(SPIM_MOSI_PIN);
nrf_gpio_pin_clear(SPIM_CLK_PIN);
nrf_gpio_cfg_output(WP_MEM_PIN);
nrf_gpio_cfg_output(CS_MEM_PIN);
nrf_gpio_cfg_output(SPIM_MOSI_PIN);
nrf_gpio_cfg_output(SPIM_CLK_PIN);
nrf_gpio_cfg_input(SPIM_MISO_PIN, NRF_GPIO_PIN_NOPULL);
View File
View File
View File
View File
View File
@@ -337,4 +337,9 @@ ret_code_t le_event_async_notify(uint8_t *p_value, uint16_t len, uint32_t ms_to_
return ret;
}
bool is_ble_connected(void)
{
return (elite_context.conn_handle != BLE_CONN_HANDLE_INVALID);
}
#endif // NRF_MODULE_ENABLED(BLE_ELITE)
View File
View File
View File
+10 -13
View File
@@ -27,10 +27,10 @@ extern "C"
#if NRF_MODULE_ENABLED(BLE_UART_SRV)
#define BLE_UUID_UART_SERVICE 0x0001 /**< The UUID of the Service. */
#define BLE_UUID_UART_RX_CHAR 0x0002 /**< The UUID of the RX Characteristic. */
#define BLE_UUID_UART_TX_CHAR 0x0003 /**< The UUID of the TX Characteristic. */
#define BLE_UUID_UART_BAUD_CHAR 0x0004 /**< The UUID of the Baud Characteristic. */
#define BLE_UUID_UART_SERVICE 0xFFF8 /**< The UUID of the Service. */
#define BLE_UUID_UART_RX_CHAR 0xFFF9 /**< The UUID of the RX Characteristic. */
#define BLE_UUID_UART_TX_CHAR 0xFFFA /**< The UUID of the TX Characteristic. */
#define BLE_UUID_UART_BAUD_CHAR 0xFFFB /**< The UUID of the Baud Characteristic. */
#define BLE_UART_BASE_UUID \
{ \
@@ -197,20 +197,17 @@ static ret_code_t add_baud_characteristic(uint16_t uuid, uint8_t uuid_type, ble_
void le_uart_srv_init(void)
{
ret_code_t err_code;
ble_uuid128_t nus_base_uuid = BLE_UART_BASE_UUID;
uint8_t uuid_type = 0;
ble_uuid_t ble_uuid;
uint8_t uuid_type = 0;
/**@snippet [Adding proprietary Service to the SoftDevice] */
// Add a custom base UUID.
err_code = sd_ble_uuid_vs_add(&nus_base_uuid, &uuid_type);
APP_ERROR_CHECK(err_code);
ble_uuid_t ble_uuid = {
.type = BLE_UUID_TYPE_BLE,
.uuid = BLE_UUID_UART_SERVICE,
};
// Add the service.
ble_uuid.type = uuid_type;
ble_uuid.uuid = BLE_UUID_UART_SERVICE;
err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY,
err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY,
&ble_uuid,
&ble_uart_context.service_handle);
APP_ERROR_CHECK(err_code);
+14 -50
View File
@@ -1,3 +1,5 @@
#include "app_config.h"
#if (DEF_LED_DRV_ENABLED)
#include "led_drv.h"
#include "nrf_log.h"
@@ -9,60 +11,15 @@
#if (DEF_APA102_2020_ENABLED)
#include "apa102_2020.h"
static const led_drv_if_t *p_inst = &apa102_drv;
#elif (DEF_RGB_ENABLED)
#include "led_rgb.h"
static const led_drv_if_t *p_inst = &led_rgb_drv;
#else
static led_drv_if_t *p_inst = NULL;
#endif
#if (DEF_LED_DRV_ENABLED)
static bool btWaitLedFlag = 0;
static bool noEventLedFlag = 0;
static bool preWorkLedFlag = 0;
static bool workingLedFlag = 0;
static bool postWorkLedFlag = 0;
int32_t led_mode(uint16_t mode_status)
{
btWaitLedFlag = 0;
noEventLedFlag = 0;
preWorkLedFlag = 0;
workingLedFlag = 0;
postWorkLedFlag = 0;
switch (mode_status)
{
case BT_WAIT:
btWaitLedFlag = 1;
NRF_LOG_INFO("%s(BT_WAIT) is unimplemented.", __FUNCTION__);
break;
case NO_EVENT:
noEventLedFlag = 1;
NRF_LOG_INFO("%s(NO_EVENT) is unimplemented.", __FUNCTION__);
break;
case PRE_WORK:
preWorkLedFlag = 1;
NRF_LOG_INFO("%s(PRE_WORK) is unimplemented.", __FUNCTION__);
break;
case WORKING:
workingLedFlag = 1;
NRF_LOG_INFO("%s(WORKING) is unimplemented.", __FUNCTION__);
break;
case POST_WORK:
postWorkLedFlag = 1;
NRF_LOG_INFO("%s(POST_WORK) is unimplemented.", __FUNCTION__);
break;
default:
NRF_LOG_INFO("%s(default) is unimplemented.", __FUNCTION__);
break;
}
return 0;
}
int32_t led_set(struct led_color color)
{
if (p_inst == NULL)
@@ -111,7 +68,14 @@ int32_t led_init(void)
int32_t led_as_rainbow(void)
{
uint8_t color_idx;
#if (DEF_APA102_2020_ENABLED)
struct led_color color[6] = { LED_RED, LED_ORANGE, LED_YELLOW, LED_GREEN, LED_BLUE, LED_PURPLE };
#endif
#if (DEF_RGB_ENABLED)
struct led_color color[6] = { LED_RED, LED_YELLOW, LED_GREEN, LED_CYAN, LED_BLUE, LED_PURPLE };
#endif
for (int i = 0; i < DEF_LED_COUNT; i++)
{
+47
View File
@@ -0,0 +1,47 @@
#include "app_config.h"
#if (DEF_RGB_ENABLED)
#include "led_rgb.h"
#include "elite_board.h"
#include "nrf_gpio.h"
static const uint32_t r_pins[DEF_LED_COUNT] = LED_R_PINS;
static const uint32_t g_pins[DEF_LED_COUNT] = LED_G_PINS;
static const uint32_t b_pins[DEF_LED_COUNT] = LED_B_PINS;
static uint32_t led_count = 0;
int32_t rgb_led_set(uint32_t idx, struct led_color color, uint8_t brightness)
{
if (idx >= led_count) return 1;
nrf_gpio_pin_write(r_pins[idx], color.R ? 0 : 1);
nrf_gpio_pin_write(g_pins[idx], color.G ? 0 : 1);
nrf_gpio_pin_write(b_pins[idx], color.B ? 0 : 1);
return 0;
}
int32_t rgb_init(uint32_t cnt)
{
led_count = cnt;
for (uint8_t i = 0; i < led_count; i++)
{
nrf_gpio_cfg_output(r_pins[i]);
nrf_gpio_cfg_output(g_pins[i]);
nrf_gpio_cfg_output(b_pins[i]);
/* all dark */
nrf_gpio_pin_set(r_pins[i]);
nrf_gpio_pin_set(g_pins[i]);
nrf_gpio_pin_set(b_pins[i]);
}
return 0;
}
const led_drv_if_t led_rgb_drv = {
.init = rgb_init,
.set = rgb_led_set,
};
#endif /* ! DEF_RGB_ENABLED */
+2 -2
View File
@@ -42,13 +42,13 @@ static void le_evt_handler(ble_evt_t const *p_ble_evt, void *p_context)
NRF_LOG_INFO("Connect to peer.");
err_code = sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_CONN, p_ble_evt->evt.gap_evt.conn_handle, 8);
APP_ERROR_CHECK(err_code);
led_set(LED_IDEL_CONNECTED);
led_set(LED_IDLE_CONNECTED);
break;
case BLE_GAP_EVT_DISCONNECTED:
NRF_LOG_INFO("Disconnect from peer.");
err_code = sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_ADV, p_ble_evt->evt.gap_evt.conn_handle, 0);
APP_ERROR_CHECK(err_code);
led_set(LED_IDEL_DISCONNECT);
led_set(LED_IDLE_DISCONNECTED);
break;
case BLE_GAP_EVT_PHY_UPDATE_REQUEST: {
NRF_LOG_INFO("PHY update response. (AUTO)");
View File
View File
View File
View File
View File
+5
View File
@@ -0,0 +1,5 @@
-----BEGIN EC PRIVATE KEY-----
MHcCAQEEIEM6TVi/ofxCYEb2O9OYK4sNHlpwd0ZrW3yFOIeRJKqKoAoGCCqGSM49
AwEHoUQDQgAEYUIRVGOQwmOEfsuYSufu4hHxRsQSUzh9lMBkvc3ewrPkpbfiXfa/
vGyIM8HAY2Jemux9+FyFERXRjgj5RxOJAA==
-----END EC PRIVATE KEY-----
View File
View File
View File
+1 -1
View File
@@ -207,7 +207,7 @@ void uart_init(void)
NRF_UARTE0->PSEL.RXD = UART_RX_PIN | (UARTE_PSEL_RXD_CONNECT_Connected << UARTE_PSEL_RXD_CONNECT_Pos);
NRF_UARTE0->PSEL.CTS = 0;
NRF_UARTE0->PSEL.RTS = 0;
NRF_UARTE0->CONFIG = UARTE_CONFIG_STOP_Msk;
NRF_UARTE0->CONFIG = 0;
NRF_UARTE0->BAUDRATE = UARTE_BAUDRATE_BAUDRATE_Baud115200;
NRF_UARTE0->ENABLE = UARTE_ENABLE_ENABLE_Enabled;
View File
+11
View File
@@ -0,0 +1,11 @@
{
"folders": [
{
"path": "."
},
{
"path": "../bmd380_sdk"
}
],
"settings": {}
}
+2
View File
@@ -205,6 +205,7 @@
<ClCompile Include="dac_drv.c" />
<ClCompile Include="elite_dev.c" />
<ClCompile Include="edc20_cycle_iv_mode.c" />
<ClCompile Include="elite_mmm.c" />
<ClCompile Include="fs.c" />
<ClCompile Include="gd25d10c.c" />
<ClCompile Include="le_uart_srv.c" />
@@ -233,6 +234,7 @@
<ClCompile Include="uart.drv.c" />
<ClCompile Include="usbd.c" />
<ClCompile Include="usbd_dfu_trigger.c" />
<ClInclude Include="elite_mmm.h" />
<ClInclude Include="le_uart_srv.h" />
<ClInclude Include="max14802.h" />
<ClInclude Include="pel20_io.h" />
+47
View File
@@ -0,0 +1,47 @@
# Call Cmake from the 'build' subfolder with the command below.
# For using Make:
# cmake -DCMAKE_MAKE_PROGRAM=make.exe -DCMAKE_TOOLCHAIN_FILE="arm-none-eabi-gcc.cmake" -G "Unix Makefiles" ..
# followed by
# 'make' or 'cmake --build .' to build it
#
# For using Ninja:
# cmake -DCMAKE_MAKE_PROGRAM=ninja.exe -DCMAKE_TOOLCHAIN_FILE="arm-none-eabi-gcc.cmake" -G "Ninja" ..
# followed by
# 'ninja' or 'cmake --build .' to build it
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR arm)
if(CMAKE_HOST_WIN32)
set(EXECUTESUFFIX ".exe")
set(ARM_TOOLCHAIN_DIR "C:/SysGCC/arm-eabi/bin")
elseif(CMAKE_HOST_UNIX)
set(EXECUTESUFFIX "")
if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Darwin")
message(STATUS "Running on macOS")
set(ARM_TOOLCHAIN_DIR "/opt/homebrew/bin")
elseif(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Linux")
message(STATUS "Running on Linux (likely Ubuntu)")
set(ARM_TOOLCHAIN_DIR "/opt/arm-none-eabi/bin")
endif()
else()
message(WARNING "Unknown host OS: ${CMAKE_HOST_SYSTEM_NAME}")
endif()
set(BINUTILS_PATH ${ARM_TOOLCHAIN_DIR})
set(TOOLCHAIN_PREFIX arm-none-eabi-)
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
set(CMAKE_C_COMPILER ${ARM_TOOLCHAIN_DIR}/${TOOLCHAIN_PREFIX}gcc${EXECUTESUFFIX})
set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER})
set(CMAKE_CXX_COMPILER ${ARM_TOOLCHAIN_DIR}/${TOOLCHAIN_PREFIX}g++${EXECUTESUFFIX})
set(CMAKE_LINKER ${ARM_TOOLCHAIN_DIR}/${TOOLCHAIN_PREFIX}ld${EXECUTESUFFIX})
set(CMAKE_OBJCOPY ${ARM_TOOLCHAIN_DIR}/${TOOLCHAIN_PREFIX}objcopy${EXECUTESUFFIX} CACHE INTERNAL "objcopy tool")
set(CMAKE_SIZE ${ARM_TOOLCHAIN_DIR}/${TOOLCHAIN_PREFIX}size${EXECUTESUFFIX} CACHE INTERNAL "size tool")
set(CMAKE_FIND_ROOT_PATH ${BINUTILS_PATH})
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
+21
View File
@@ -0,0 +1,21 @@
cmake_minimum_required(VERSION 3.15.3)
file(GLOB FREERTO_KERNEL_SOURCES "${NRF_SDK_DIR}/external/freertos/source/*.c")
add_library(freertos OBJECT
${NRF_SDK_DIR}/external/freertos/portable/GCC/nrf52/port.c
${NRF_SDK_DIR}/external/freertos/portable/CMSIS/nrf52/port_cmsis.c
${NRF_SDK_DIR}/external/freertos/portable/CMSIS/nrf52/port_cmsis_systick.c
${NRF_SDK_DIR}/external/freertos/source/portable/MemMang/heap_4.c
${FREERTO_KERNEL_SOURCES}
)
target_include_directories(freertos PUBLIC
${NRF_SDK_DIR}/external/freertos/portable/CMSIS/nrf52
${NRF_SDK_DIR}/external/freertos/portable/GCC/nrf52
${NRF_SDK_DIR}/external/freertos/source/include
)
target_link_libraries(freertos PRIVATE
prj_config
)
+14
View File
@@ -0,0 +1,14 @@
cmake_minimum_required(VERSION 3.15.3)
file(GLOB_RECURSE LFS_SOURCES "littlefs/*.c")
add_library(lfs OBJECT ${LFS_SOURCES})
target_include_directories(lfs PUBLIC
${CMAKE_SOURCE_DIR}/littlefs
)
target_link_libraries(lfs PRIVATE
prj_config
freertos
)

Some files were not shown because too many files have changed in this diff Show More