diff --git a/.vscode/settings.json b/.vscode/settings.json index 08b16d9..5dfc5cb 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -30,6 +30,8 @@ "sys.h": "c", "nrf_log.h": "c", "version.h": "c", - "zble_service.h": "c" + "zble_service.h": "c", + "pca10112.h": "c", + "pca10100.h": "c" } } \ No newline at end of file diff --git a/README.md b/README.md index edf0914..631dd68 100644 --- a/README.md +++ b/README.md @@ -5,4 +5,25 @@ ``` https://iflytop1.feishu.cn/wiki/Fp0fwciUEibtm4kaUeXcraOCneg +``` + +``` +开发板IO资源说明: + +#define BSP_LED_0 13 +#define BSP_LED_1 14 +#define BSP_LED_2 15 +#define BSP_LED_3 16 + +#define BUTTONS_NUMBER 4 + +#define BUTTON_1 11 +#define BUTTON_2 12 +#define BUTTON_3 24 +#define BUTTON_4 25 +#define BUTTON_PULL NRF_GPIO_PIN_PULLUP + + +sdk\components\boards\pca10100.h + ``` \ No newline at end of file diff --git a/app/app.uvoptx b/app/app.uvoptx index 58fd267..ed3dfe2 100644 --- a/app/app.uvoptx +++ b/app/app.uvoptx @@ -403,6 +403,18 @@ 0 0 + + 1 + 4 + 1 + 0 + 0 + 0 + .\src\board.c + board.c + 0 + 0 + @@ -413,7 +425,7 @@ 0 2 - 4 + 5 1 0 0 @@ -433,7 +445,7 @@ 0 3 - 5 + 6 1 0 0 @@ -445,7 +457,7 @@ 3 - 6 + 7 1 0 0 @@ -465,7 +477,7 @@ 0 4 - 7 + 8 1 0 0 @@ -485,7 +497,7 @@ 0 5 - 8 + 9 1 0 0 @@ -497,7 +509,7 @@ 5 - 9 + 10 1 0 0 @@ -509,7 +521,7 @@ 5 - 10 + 11 1 0 0 @@ -521,7 +533,7 @@ 5 - 11 + 12 1 0 0 @@ -533,7 +545,7 @@ 5 - 12 + 13 1 0 0 @@ -545,7 +557,7 @@ 5 - 13 + 14 1 0 0 @@ -557,7 +569,7 @@ 5 - 14 + 15 1 0 0 @@ -569,7 +581,7 @@ 5 - 15 + 16 1 0 0 @@ -589,7 +601,7 @@ 0 6 - 16 + 17 1 0 0 @@ -609,7 +621,7 @@ 0 7 - 17 + 18 1 0 0 @@ -621,7 +633,7 @@ 7 - 18 + 19 1 0 0 @@ -633,7 +645,7 @@ 7 - 19 + 20 1 0 0 @@ -645,7 +657,7 @@ 7 - 20 + 21 1 0 0 @@ -657,7 +669,7 @@ 7 - 21 + 22 1 0 0 @@ -669,7 +681,7 @@ 7 - 22 + 23 1 0 0 @@ -681,7 +693,7 @@ 7 - 23 + 24 1 0 0 @@ -693,7 +705,7 @@ 7 - 24 + 25 1 0 0 @@ -713,7 +725,7 @@ 0 8 - 25 + 26 1 0 0 @@ -725,7 +737,7 @@ 8 - 26 + 27 1 0 0 @@ -737,7 +749,7 @@ 8 - 27 + 28 1 0 0 @@ -749,7 +761,7 @@ 8 - 28 + 29 1 0 0 @@ -761,7 +773,7 @@ 8 - 29 + 30 1 0 0 @@ -773,7 +785,7 @@ 8 - 30 + 31 1 0 0 @@ -785,7 +797,7 @@ 8 - 31 + 32 1 0 0 @@ -797,7 +809,7 @@ 8 - 32 + 33 1 0 0 @@ -809,7 +821,7 @@ 8 - 33 + 34 1 0 0 @@ -821,7 +833,7 @@ 8 - 34 + 35 1 0 0 @@ -833,7 +845,7 @@ 8 - 35 + 36 1 0 0 @@ -845,7 +857,7 @@ 8 - 36 + 37 1 0 0 @@ -857,7 +869,7 @@ 8 - 37 + 38 1 0 0 @@ -869,7 +881,7 @@ 8 - 38 + 39 1 0 0 @@ -881,7 +893,7 @@ 8 - 39 + 40 1 0 0 @@ -893,7 +905,7 @@ 8 - 40 + 41 1 0 0 @@ -905,7 +917,7 @@ 8 - 41 + 42 1 0 0 @@ -917,7 +929,7 @@ 8 - 42 + 43 1 0 0 @@ -929,7 +941,7 @@ 8 - 43 + 44 1 0 0 @@ -941,7 +953,7 @@ 8 - 44 + 45 1 0 0 @@ -953,7 +965,7 @@ 8 - 45 + 46 1 0 0 @@ -965,7 +977,7 @@ 8 - 46 + 47 1 0 0 @@ -977,7 +989,7 @@ 8 - 47 + 48 1 0 0 @@ -989,7 +1001,7 @@ 8 - 48 + 49 1 0 0 @@ -1001,7 +1013,7 @@ 8 - 49 + 50 1 0 0 @@ -1021,7 +1033,7 @@ 0 9 - 50 + 51 1 0 0 @@ -1033,7 +1045,7 @@ 9 - 51 + 52 1 0 0 @@ -1045,7 +1057,7 @@ 9 - 52 + 53 1 0 0 @@ -1057,7 +1069,7 @@ 9 - 53 + 54 1 0 0 @@ -1069,7 +1081,7 @@ 9 - 54 + 55 1 0 0 @@ -1089,7 +1101,7 @@ 0 10 - 55 + 56 1 0 0 @@ -1101,7 +1113,7 @@ 10 - 56 + 57 1 0 0 @@ -1113,7 +1125,7 @@ 10 - 57 + 58 1 0 0 @@ -1133,7 +1145,7 @@ 0 11 - 58 + 59 1 0 0 @@ -1145,7 +1157,7 @@ 11 - 59 + 60 1 0 0 @@ -1157,7 +1169,7 @@ 11 - 60 + 61 1 0 0 @@ -1177,7 +1189,7 @@ 0 12 - 61 + 62 1 0 0 diff --git a/app/app.uvprojx b/app/app.uvprojx index 135b2c0..7138442 100644 --- a/app/app.uvprojx +++ b/app/app.uvprojx @@ -398,6 +398,11 @@ 1 .\src\zble_service.c + + board.c + 1 + .\src\board.c + @@ -4052,6 +4057,11 @@ 1 .\src\zble_service.c + + board.c + 1 + .\src\board.c + diff --git a/app/main.c b/app/main.c index f0c4dc1..299ee10 100644 --- a/app/main.c +++ b/app/main.c @@ -1,3 +1,5 @@ +#include "board.h" +#include "project_cfg.h" #include "sys.h" #include "version.h" #include "zble_service.h" @@ -7,10 +9,12 @@ zble_service_cfg_t cfg = {.deviceName = "iflytop"}; int main(void) { zsys_init(); + debug_light_init(DEBUG_LIGHT_IO_INDEX); // + NRF_LOG_INFO("compile time :%s", __TIME__); NRF_LOG_INFO("Version :%d", VERSION); NRF_LOG_INFO("Manufacturer :%s", MANUFACTURER_NAME); - + zble_service_init(&cfg); zsys_loop(); } diff --git a/app/src/board.c b/app/src/board.c new file mode 100644 index 0000000..621ccd7 --- /dev/null +++ b/app/src/board.c @@ -0,0 +1,41 @@ +#include "board.h" + +#include "app_timer.h" +#include "nrf_gpio.h" + +/******************************************************************************* + * DEBUG_LIGHT * + *******************************************************************************/ + +APP_TIMER_DEF(m_debug_light_tmr_cb); +static int32_t m_debug_light_io_index; +static void debug_light_tmr_cb_handler(void* p_context) { + static bool inited = false; + if (!inited) { + inited = true; + nrf_gpio_cfg(m_debug_light_io_index, // + NRF_GPIO_PIN_DIR_OUTPUT, // + NRF_GPIO_PIN_INPUT_DISCONNECT, // + NRF_GPIO_PIN_NOPULL, // + NRF_GPIO_PIN_S0S1, // + NRF_GPIO_PIN_NOSENSE); + } + static bool state = false; + if (state) { + nrf_gpio_pin_set(m_debug_light_io_index); + } else { + nrf_gpio_pin_clear(m_debug_light_io_index); + } + state = !state; +} + +void debug_light_init(int io_index) { + m_debug_light_io_index = io_index; + ret_code_t err_code; + err_code = app_timer_create(&m_debug_light_tmr_cb, APP_TIMER_MODE_REPEATED, debug_light_tmr_cb_handler); + APP_ERROR_CHECK(err_code); + + app_timer_start(m_debug_light_tmr_cb, APP_TIMER_TICKS(100), NULL); +} + +void board_init() {} diff --git a/app/src/board.h b/app/src/board.h new file mode 100644 index 0000000..3703645 --- /dev/null +++ b/app/src/board.h @@ -0,0 +1,11 @@ +#pragma once + +/******************************************************************************* + * DEBUG_LIGHT * + *******************************************************************************/ +void debug_light_init(int io_index); + +/******************************************************************************* + * BOARD * + *******************************************************************************/ +void board_init(); diff --git a/app/src/project_cfg.h b/app/src/project_cfg.h new file mode 100644 index 0000000..a0ece75 --- /dev/null +++ b/app/src/project_cfg.h @@ -0,0 +1,3 @@ +#pragma once + +#define DEBUG_LIGHT_IO_INDEX 13 \ No newline at end of file