|
|
@ -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); |
|
|
|