Browse Source

fatfs spi 上有信号 但驱动失败

3lead_uart_test_ok_version
zhaohe 1 year ago
parent
commit
b951942070
  1. 4
      .vscode/settings.json
  2. 51
      app/app.uvoptx
  3. 17
      app/main.c
  4. 29
      app/src/board.c

4
.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"
}
}

51
app/app.uvoptx

@ -148,7 +148,56 @@
<Name>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))</Name>
</SetRegEntry>
</TargetDriverDllRegistry>
<Breakpoint/>
<Breakpoint>
<Bp>
<Number>0</Number>
<Type>0</Type>
<LineNumber>84</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>191842</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename>main.c</Filename>
<ExecCommand></ExecCommand>
<Expression>\\nrf52833_xxaa\main.c\84</Expression>
</Bp>
<Bp>
<Number>1</Number>
<Type>0</Type>
<LineNumber>275</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>173498</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename>.\src\board.c</Filename>
<ExecCommand></ExecCommand>
<Expression>\\nrf52833_xxaa\src/board.c\275</Expression>
</Bp>
<Bp>
<Number>2</Number>
<Type>0</Type>
<LineNumber>279</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>173540</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename>.\src\board.c</Filename>
<ExecCommand></ExecCommand>
<Expression>\\nrf52833_xxaa\src/board.c\279</Expression>
</Bp>
</Breakpoint>
<Tracepoint>
<THDelay>0</THDelay>
</Tracepoint>

17
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();

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

Loading…
Cancel
Save