diff --git a/.vscode/settings.json b/.vscode/settings.json
index 876ea80..a0adfb0 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -46,6 +46,8 @@
"project_cfg.h": "c",
"nrf_block_dev_sdc.h": "c",
"nrf_drv_pwm.h": "c",
- "nrfx_config.h": "c"
+ "nrfx_config.h": "c",
+ "nrf_drv_wdt.h": "c",
+ "app_sdcard.h": "c"
}
}
\ No newline at end of file
diff --git a/app/app.uvoptx b/app/app.uvoptx
index ce98612..43be657 100644
--- a/app/app.uvoptx
+++ b/app/app.uvoptx
@@ -148,7 +148,56 @@
UL2CM3(-S0 -C0 -P0 -FD20000000 -FC4000 -FN2 -FF0nrf52xxx -FS00 -FL0200000 -FF1nrf52xxx_uicr -FS110001000 -FL11000 -FP0($$Device:nRF52833_xxAA$Flash\nrf52xxx.flm) -FP1($$Device:nRF52833_xxAA$Flash\nrf52xxx_uicr.flm))
-
+
+
+ 0
+ 0
+ 84
+ 1
+ 191842
+ 0
+ 0
+ 0
+ 0
+ 0
+ 1
+ main.c
+
+ \\nrf52833_xxaa\main.c\84
+
+
+ 1
+ 0
+ 275
+ 1
+ 173498
+ 0
+ 0
+ 0
+ 0
+ 0
+ 1
+ .\src\board.c
+
+ \\nrf52833_xxaa\src/board.c\275
+
+
+ 2
+ 0
+ 279
+ 1
+ 173540
+ 0
+ 0
+ 0
+ 0
+ 0
+ 1
+ .\src\board.c
+
+ \\nrf52833_xxaa\src/board.c\279
+
+
0
diff --git a/app/main.c b/app/main.c
index 411910d..e0180cd 100644
--- a/app/main.c
+++ b/app/main.c
@@ -9,6 +9,7 @@
#include "version.h"
#include "zble_module.h"
#include "zdatachannel_service.h"
+#include "diskio_blkdev.h"
#if 0
void qingfengboard_test(void) {
@@ -76,10 +77,12 @@ static void test_tx_timer_cb(void* p_context) {
// zdatachannel_data_send((uint8_t*)&data, &txlen);
// ZLOGI("adc channel %d %d", adc_module_heart_elect_channel_read_val(), adc_module_battery_channel_read_val());
- ZLOGI("test_tx_timer_cb")
+ ZLOGI("test_tx_timer_cb");
+ NVIC_SystemReset();
// board_spi_transfer_test();
- uint8_t data[] = {0xAA, 0xBB};
- board_i2c_write(0x3C, data, 2);
+ // uint8_t data[] = {0xAA, 0xBB};
+ // board_i2c_write(0x3C, data, 2);
+ // fatfs_test_write();
}
static void board_init() {
@@ -104,15 +107,15 @@ int main(void) {
};
zble_module_init(&cfg);
board_init();
+ fatfs_init();
NRF_SDH_BLE_OBSERVER(m_ble_observer, 3, ble_evt_handler, NULL);
- // ZERROR_CHECK(app_timer_create(&m_test_tx_timer, APP_TIMER_MODE_REPEATED, test_tx_timer_cb));
- // ZERROR_CHECK(app_timer_start(m_test_tx_timer, APP_TIMER_TICKS(100), NULL));
+ ZERROR_CHECK(app_timer_create(&m_test_tx_timer, APP_TIMER_MODE_REPEATED, test_tx_timer_cb));
+ ZERROR_CHECK(app_timer_start(m_test_tx_timer, APP_TIMER_TICKS(100), NULL));
- // fatfs_test_write();
// pwm_trigger();
- wd_init();
+ // wd_init();
zble_module_start_adv();
zsys_loop();
diff --git a/app/src/board.c b/app/src/board.c
index 57b550a..a0efeaf 100644
--- a/app/src/board.c
+++ b/app/src/board.c
@@ -7,6 +7,7 @@
#include "diskio_blkdev.h"
#include "ff.h"
#include "nrf_block_dev_sdc.h"
+#include "nrf_delay.h"
#include "nrf_drv_pwm.h"
#include "nrf_drv_wdt.h"
@@ -252,10 +253,16 @@ void board_i2c_write(uint8_t addr, uint8_t* data, uint8_t len) { nrf_drv_twi_tx(
#define SDC_SCK_PIN 29 ///< SDC serial clock (SCK) pin.
#define SDC_MOSI_PIN 30 ///< SDC serial data in (DI) pin.
#define SDC_MISO_PIN 31 ///< SDC serial data out (DO) pin.
-#define SDC_CS_PIN 28 ///< SDC chip select (CS) pin.
+#define SDC_CS_PIN 20 ///< SDC chip select (CS) pin.
NRF_BLOCK_DEV_SDC_DEFINE(m_block_dev_sdc, NRF_BLOCK_DEV_SDC_CONFIG(SDC_SECTOR_SIZE, APP_SDCARD_CONFIG(SDC_MOSI_PIN, SDC_MISO_PIN, SDC_SCK_PIN, SDC_CS_PIN)), NFR_BLOCK_DEV_INFO_CONFIG("Nordic", "SDC", "1.00"));
-void fatfs_init() {}
+void fatfs_init() {
+ // // Initialize FATFS disk I/O interface by providing the block device.
+ static diskio_blkdev_t drives[] = {DISKIO_BLOCKDEV_CONFIG(NRF_BLOCKDEV_BASE_ADDR(m_block_dev_sdc, block_dev), NULL)};
+
+ diskio_blockdev_register(drives, ARRAY_SIZE(drives));
+ fatfs_test_write();
+}
void fatfs_test_write() {
static FATFS fs;
static DIR dir;
@@ -266,19 +273,15 @@ void fatfs_test_write() {
FRESULT ff_result;
DSTATUS disk_state = STA_NOINIT;
- // Initialize FATFS disk I/O interface by providing the block device.
- static diskio_blkdev_t drives[] = {DISKIO_BLOCKDEV_CONFIG(NRF_BLOCKDEV_BASE_ADDR(m_block_dev_sdc, block_dev), NULL)};
-
- diskio_blockdev_register(drives, ARRAY_SIZE(drives));
-
- NRF_LOG_INFO("Initializing disk 0 (SDC)...");
for (uint32_t retries = 3; retries && disk_state; --retries) {
disk_state = disk_initialize(0);
}
if (disk_state) {
- NRF_LOG_INFO("Disk initialization failed.");
+ NRF_LOG_INFO("Disk initialization failed. %d", disk_state);
return;
}
+ return;
+ // NRF_LOG_INFO("Initializing disk 0 (SDC)...");
uint32_t blocks_per_mb = (1024uL * 1024uL) / m_block_dev_sdc.block_dev.p_ops->geometry(&m_block_dev_sdc.block_dev)->blk_size;
uint32_t capacity = m_block_dev_sdc.block_dev.p_ops->geometry(&m_block_dev_sdc.block_dev)->blk_count / blocks_per_mb;
@@ -335,10 +338,10 @@ void fatfs_test_write() {
nrf_drv_wdt_channel_id m_channel_id;
void wd_init() {
- //WDT_CONFIG_RELOAD_VALUE 修改这个数值修改喂狗周期,单位ms
- nrf_drv_wdt_config_t config = NRF_DRV_WDT_DEAFULT_CONFIG;
- config.reload_value = WDT_CONFIG_RELOAD_VALUE;
- ret_code_t err_code = nrf_drv_wdt_init(&config, NULL);
+ // WDT_CONFIG_RELOAD_VALUE 修改这个数值修改喂狗周期,单位ms
+ nrf_drv_wdt_config_t config = NRF_DRV_WDT_DEAFULT_CONFIG;
+ config.reload_value = WDT_CONFIG_RELOAD_VALUE;
+ ret_code_t err_code = nrf_drv_wdt_init(&config, NULL);
ZERROR_CHECK(err_code);
err_code = nrf_drv_wdt_channel_alloc(&m_channel_id);
ZERROR_CHECK(err_code);