Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions boards/obelix_dvt/defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ CONFIG_RNG_SF32LB=y
CONFIG_CPUMODE=y
CONFIG_CPUMODE_SF32LB=y

CONFIG_DMA=y
CONFIG_DMA_SF32LB=y

CONFIG_DYNAMIC_BACKLIGHT=y
CONFIG_ACCEL_SENSITIVITY=y
CONFIG_APP_SCALING=y
Expand Down
3 changes: 3 additions & 0 deletions boards/obelix_pvt/defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ CONFIG_RNG_SF32LB=y
CONFIG_CPUMODE=y
CONFIG_CPUMODE_SF32LB=y

CONFIG_DMA=y
CONFIG_DMA_SF32LB=y

CONFIG_DYNAMIC_BACKLIGHT=y
CONFIG_ACCEL_SENSITIVITY=y
CONFIG_APP_SCALING=y
Expand Down
1 change: 1 addition & 0 deletions src/fw/drivers/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ rsource "ambient/Kconfig"
rsource "backlight/Kconfig"
rsource "battery/Kconfig"
rsource "cpumode/Kconfig"
rsource "dma/Kconfig"
rsource "display/Kconfig"
rsource "exti/Kconfig"
rsource "flash/Kconfig"
Expand Down
21 changes: 21 additions & 0 deletions src/fw/drivers/dma/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# SPDX-FileCopyrightText: 2026 Core Devices LLC
# SPDX-License-Identifier: Apache-2.0

menuconfig DMA
bool "DMA"
help
DMA Drivers

if DMA

config DMA_NRF5
bool "Nordic nRF5 DMA Controller"
help
Support for the Nordic nRF5 DMA controller.

config DMA_SF32LB
bool "SiFli SF32LB DMA Controller"
help
Support for the SiFli SF32LB DMA controller.

endif # DMA
75 changes: 75 additions & 0 deletions src/fw/drivers/dma/sf32lb.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/* SPDX-FileCopyrightText: 2026 Core Devices LLC */
/* SPDX-License-Identifier: Apache-2.0 */

#include <stdint.h>
#include <stdbool.h>

#include "board/board.h"

#include <bf0_hal.h>

#include "sf32lb.h"

#define DMA_CHANNEL_NUM 8U

struct DMARequest {
DMA_HandleTypeDef *handle;
};

static DMADirectRequestHandler handlers[DMA_CHANNEL_NUM];
static DMACircularRequestHandler circular_handlers[DMA_CHANNEL_NUM];

static void dma_cplt_callback(DMA_HandleTypeDef *hdma)
{
DMARequest *this = (DMARequest *)hdma->Parent; //container_of?

if (handlers[hdma->ChannelIndex] != NULL)
handlers[hdma->ChannelIndex](this, NULL);
}

void dma_request_init(DMARequest *this)
{
HAL_DMA_Init(this->handle);
}

void dma_request_start_direct(DMARequest *this, void *dst, const void *src, uint32_t length,
DMADirectRequestHandler handler, void *context)
{
HAL_DMA_RegisterCallback(this->handle, HAL_DMA_XFER_CPLT_CB_ID, dma_cplt_callback);
handlers[this->handle->ChannelIndex] = handler;
HAL_DMA_Start_IT(this->handle, (uint32_t)src, (uint32_t)dst, length);
}

void dma_request_start_circular(DMARequest *this, void *dst, const void *src, uint32_t length,
DMACircularRequestHandler handler, void *context)
{
HAL_DMA_RegisterCallback(this->handle, HAL_DMA_XFER_CPLT_CB_ID, dma_cplt_callback);
circular_handlers[this->handle->ChannelIndex] = handler;
HAL_DMA_Start_IT(this->handle, (uint32_t)src, (uint32_t)dst, length);
}

void dma_request_stop(DMARequest *this)
{
HAL_DMA_Abort(this->handle);
}

bool dma_request_in_progress(DMARequest *this)
{
return (HAL_DMA_GetState(this->handle) == HAL_DMA_STATE_BUSY);
}

uint32_t dma_request_get_current_data_counter(DMARequest *this)
{
return 0;
// return HAL_DMA_GetCurrentDataCounter(this->handle);
}

bool dma_request_get_and_clear_transfer_error(DMARequest *this)
{
return false;
}

void dma_request_set_memory_increment_disabled(DMARequest *this, bool disabled)
{

}
6 changes: 6 additions & 0 deletions src/fw/drivers/dma/sf32lb.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* SPDX-FileCopyrightText: 2026 Core Devices LLC */
/* SPDX-License-Identifier: Apache-2.0 */




19 changes: 19 additions & 0 deletions src/fw/drivers/dma/wscript_build
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# SPDX-FileCopyrightText: 2026 Core Devices LLC
# SPDX-License-Identifier: Apache-2.0

use = ['freertos', 'fw_includes']

if bld.env.CONFIG_DMA_NRF5:
use.append('hal_nordic')
sources.append('nrf5.c')
elif bld.env.CONFIG_DMA_SF32LB:
use.append('hal_sifli')
sources.append('sf32lb.c')

bld.objects(
name='driver_dma',
source=sources,
use=use,
)

bld.env.DRIVERS.append('driver_dma')
56 changes: 56 additions & 0 deletions src/fw/drivers/stubs/dma.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/* SPDX-FileCopyrightText: 2026 Core Devices LLC */
/* SPDX-License-Identifier: Apache-2.0 */

#include <stdint.h>
#include <stdbool.h>

#include "drivers/dma.h"

T_STATIC DMADirectRequestHandler handlers[DMA_CHANNEL_NUM];

static void dma_cplt_callback(DMA_HandleTypeDef *hdma)
{

}

void dma_request_init(DMARequest *this)
{

}

void dma_request_start_direct(DMARequest *this, void *dst, const void *src, uint32_t length,
DMADirectRequestHandler handler, void *context)
{

}

void dma_request_start_circular(DMARequest *this, void *dst, const void *src, uint32_t length,
DMACircularRequestHandler handler, void *context)
{

}

void dma_request_stop(DMARequest *this)
{

}

bool dma_request_in_progress(DMARequest *this)
{
return true;
}

uint32_t dma_request_get_current_data_counter(DMARequest *this)
{
return 0;
}

bool dma_request_get_and_clear_transfer_error(DMARequest *this);
{
return true;
}

void dma_request_set_memory_increment_disabled(DMARequest *this, bool disabled)
{

}
3 changes: 3 additions & 0 deletions src/fw/drivers/wscript_build
Original file line number Diff line number Diff line change
Expand Up @@ -381,4 +381,7 @@ bld(
use=bld.env.DRIVERS,
)

if bld.env.CONFIG_DMA:
bld.recurse('dma')

# vim:filetype=python
Loading