You've already forked ESP32-DAPLink
mirror of
https://github.com/m5stack/ESP32-DAPLink.git
synced 2026-05-20 11:37:17 -07:00
39 lines
1.0 KiB
C++
39 lines
1.0 KiB
C++
/*
|
|
* Copyright (c) 2023-2023, lihongquan
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*
|
|
* Change Logs:
|
|
* Date Author Notes
|
|
* 2023-9-8 lihongquan add license declaration
|
|
*/
|
|
#pragma once
|
|
|
|
#include "target_flash.h"
|
|
|
|
class FlashAccessor : public TargetFlash
|
|
{
|
|
private:
|
|
static constexpr uint32_t _page_size = 1024;
|
|
FlashIface::state_t _flash_state;
|
|
bool _current_sector_valid;
|
|
uint32_t _last_packet_addr = 0;
|
|
uint32_t _current_write_block_addr;
|
|
uint32_t _current_write_block_size;
|
|
uint32_t _current_sector_addr;
|
|
uint32_t _current_sector_size;
|
|
bool _page_buf_empty;
|
|
uint8_t _page_buffer[_page_size];
|
|
|
|
FlashAccessor();
|
|
FlashIface::err_t flush_current_block(uint32_t addr);
|
|
FlashIface::err_t setup_next_sector(uint32_t addr);
|
|
|
|
public:
|
|
~FlashAccessor() = default;
|
|
static FlashAccessor &get_instance();
|
|
FlashIface::err_t init(const target_cfg_t &cfg);
|
|
FlashIface::err_t write(uint32_t addr, const uint8_t *data, uint32_t size);
|
|
FlashIface::err_t uninit();
|
|
};
|