35extern MMC_HandleTypeDef
hmmc1;
37#define LEGACY_MAX_HZ 26000000UL
38#define AXI_SRAM_START 0x24000000UL
39#define AXI_SRAM_END 0x24050000UL
62 uintptr_t
a = (uintptr_t)
p;
73static uint32_t
divider_for(uint32_t kernel_hz, uint32_t max_hz) {
75 return (kernel_hz + 2U * max_hz - 1U) / (2U * max_hz);
83 uint32_t hz = div == 0U ? kernel : kernel / (2U * div);
91 while (HAL_MMC_GetCardState(&
hmmc1) != HAL_MMC_CARD_TRANSFER) {
103 (void)HAL_MMC_Abort(&
hmmc1);
124 if (
hmmc1.State == HAL_MMC_STATE_RESET) {
128 hmmc1.Init.ClockEdge = SDMMC_CLOCK_EDGE_RISING;
129 hmmc1.Init.ClockPowerSave = SDMMC_CLOCK_POWER_SAVE_DISABLE;
130 hmmc1.Init.BusWide = SDMMC_BUS_WIDE_4B;
131 hmmc1.Init.HardwareFlowControl = SDMMC_HARDWARE_FLOW_CONTROL_DISABLE;
136 }
else if (
hmmc1.State != HAL_MMC_STATE_READY) {
148 if (HAL_MMC_GetCardExtCSD(&
hmmc1, ext_csd, 100U) !=
HAL_OK) {
155 HAL_MMC_CardInfoTypeDef
info;
160 *block_count =
info.LogBlockNbr;
165 uint32_t
count, uint32_t budget_ms) {
183 uint32_t
count, uint32_t budget_ms) {
193 if (HAL_MMC_WriteBlocks_DMA(&
hmmc1, (uint8_t*)(uintptr_t)buffer, lba,
216 if (hmmc == &
hmmc1) {
227 if (hmmc == &
hmmc1) {
#define EMMC_RST_GPIO_Port
static board_sleep_info_t info
osStatus_t osSemaphoreRelease(osSemaphoreId_t semaphore_id)
Release a Semaphore token up to the initial maximum count.
osSemaphoreId_t osSemaphoreNew(uint32_t max_count, uint32_t initial_count, const osSemaphoreAttr_t *attr)
Create and Initialize a Semaphore object.
@ osOK
Operation completed successfully.
osStatus_t osSemaphoreAcquire(osSemaphoreId_t semaphore_id, uint32_t timeout)
Acquire a Semaphore token or timeout if no tokens are available.
uint32_t osKernelGetTickCount(void)
Get the RTOS kernel tick count.
#define osWaitForever
Wait forever timeout value.
osMutexId_t osMutexNew(const osMutexAttr_t *attr)
Create and Initialize a Mutex object.
osStatus_t osMutexAcquire(osMutexId_t mutex_id, uint32_t timeout)
Acquire a Mutex or timeout if it is locked.
osStatus_t osMutexRelease(osMutexId_t mutex_id)
Release a Mutex that was acquired by osMutexAcquire.
osStatus_t osDelay(uint32_t ticks)
Wait for Timeout (Time Delay).
uint32_t emmc_card_check(const emmc_card_info_t *info)
void emmc_card_parse(const uint32_t cid[4], const uint8_t ext_csd[512], emmc_card_info_t *out)
emmc_status_t emmc_log_service(emmc_log_t *log, uint32_t now_ms)
emmc_status_t emmc_log_init(emmc_log_t *log, const emmc_port_t *port, void *context, const emmc_log_config_t *config, emmc_log_chunk_t *chunks, uint8_t chunk_count, uint8_t *scratch)
uint8_t emmc_log_backlog(const emmc_log_t *log)
emmc_log_config_t emmc_log_default_config(void)
static emmc_status_t port_read(void *context, uint32_t lba, void *buffer, uint32_t count, uint32_t budget_ms)
static emmc_card_info_t card
const emmc_card_info_t * emmc_stm32_card(uint32_t *issues)
void HAL_MMC_TxCpltCallback(MMC_HandleTypeDef *hmmc)
static uint32_t card_issues
static emmc_status_t port_write(void *context, uint32_t lba, const void *buffer, uint32_t count, uint32_t budget_ms)
static emmc_status_t finish(uint32_t budget_ms)
void HAL_MMC_ErrorCallback(MMC_HandleTypeDef *hmmc)
static emmc_log_t flight_log
static volatile bool transfer_ok
void HAL_MMC_RxCpltCallback(MMC_HandleTypeDef *hmmc)
static osSemaphoreId_t transfer_done
void emmc_stm32_writer_task(void *argument)
emmc_status_t emmc_stm32_init(void)
static void port_lock(void *context)
static bool dcache_on(void)
static osMutexId_t queue_mutex
static void port_unlock(void *context)
static bool dma_reachable(const void *p, uint32_t bytes)
static const emmc_port_t port
static emmc_status_t port_start(void *context, uint32_t *block_count)
emmc_log_t * emmc_stm32_log(void)
static uint32_t divider_for(uint32_t kernel_hz, uint32_t max_hz)
static void clamp_clock(void)
static emmc_status_t wait_transfer_state(uint32_t deadline)
std::vector< daq::SensorDataChunkCollection > chunks
#define SCB_CCR_DC_Msk
SCB CCR: DC Mask.
#define SCB
SCB configuration struct.
__STATIC_FORCEINLINE void SCB_InvalidateDCache_by_Addr(volatile void *addr, int32_t dsize)
D-Cache Invalidate by address.
__STATIC_FORCEINLINE void SCB_CleanDCache_by_Addr(volatile void *addr, int32_t dsize)
D-Cache Clean by address.
#define SET_BIT(REG, BIT)
#define MODIFY_REG(REG, CLEARMASK, SETMASK)
void HAL_GPIO_WritePin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin, GPIO_PinState PinState)
#define SDMMC_CLKCR_HWFC_EN
HW Flow Control enable.
#define SDMMC_CLKCR_CLKDIV
Clock divide factor.
uint32_t HAL_RCCEx_GetPeriphCLKFreq(uint64_t PeriphClk)
#define RCC_PERIPHCLK_SDMMC
static const idle_config_t config
*brief create JSON pointer *sa reference_tokens const string_t & a
size_type count(const key_type &key) const
static uint8_t scratch[BS]