Skip to content

Commit

Permalink
fw: allocate hspi dma buffers in RAMX via the linker instead of hard …
Browse files Browse the repository at this point in the history
…coded macros

Signed-off-by: Yann Sionneau <yann@sionneau.net>
  • Loading branch information
fallen committed Mar 23, 2024
1 parent bb46b60 commit f4a0b8e
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions software/boards/hydrausb3/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@
/* HSPI Data width : 8 bits */
#define HSPI_DATA_WIDTH 0

#define RX_DMA_Addr0 0x20020000
#define RX_DMA_LENGTH 4096
#define RX_DMA_Addr1 RX_DMA_Addr0 + RX_DMA_LENGTH
#define HSPI_RX_DMA_LENGTH 4096

__attribute__((aligned(16))) uint8_t HSPI_RX_Addr0[HSPI_RX_DMA_LENGTH] __attribute__((section(".DMADATA")));
__attribute__((aligned(16))) uint8_t HSPI_RX_Addr1[HSPI_RX_DMA_LENGTH] __attribute__((section(".DMADATA")));

/* Shared variables */
volatile int HSPI_TX_End_Flag; // Send completion flag
Expand Down Expand Up @@ -87,8 +88,8 @@ int main(void) {
char ident_str[256];
int i = 0;
char c;
uint32_t *dma_rx = (uint32_t *)RX_DMA_Addr0;
uint8_t *hspi_rxed_bytes = (uint8_t *)RX_DMA_Addr0;
uint32_t *dma_rx = (uint32_t *)HSPI_RX_Addr0;
uint8_t *hspi_rxed_bytes = (uint8_t *)HSPI_RX_Addr0;

bsp_gpio_init();
bsp_init(FREQ_SYS);
Expand Down Expand Up @@ -118,10 +119,11 @@ int main(void) {
printf("FPGA SoC ident: %s\n\r", ident_str);

printf("Preparing HSPI RX interface...\n\r");
memset(dma_rx, '\0', RX_DMA_LENGTH*2);
memset(HSPI_RX_Addr0, '\0', HSPI_RX_DMA_LENGTH);
memset(HSPI_RX_Addr1, '\0', HSPI_RX_DMA_LENGTH);
HSPI_RX_End_Flag = 0; // Receive completion flag
HSPI_RX_End_Err = 0; // 0=No Error else >0 Error code
HSPI_DoubleDMA_Init(HSPI_DEVICE, HSPI_DATA_WIDTH, RX_DMA_Addr0, RX_DMA_Addr1, 0);
HSPI_DoubleDMA_Init(HSPI_DEVICE, HSPI_DATA_WIDTH, (unsigned long int)HSPI_RX_Addr0, (unsigned long int)HSPI_RX_Addr1, 0);

printf("Starting a capture...\n\r");
uartbone_write(&ctx, CSR_LA_TRIGGER_MEM_MASK_ADDR, 0);
Expand Down Expand Up @@ -205,8 +207,8 @@ int main(void) {

void HSPI_IRQHandler_ReInitRX(void)
{
R32_HSPI_RX_ADDR0 = RX_DMA_Addr0;
R32_HSPI_RX_ADDR1 = RX_DMA_Addr1;
R32_HSPI_RX_ADDR0 = (unsigned long int)HSPI_RX_Addr0;
R32_HSPI_RX_ADDR1 = (unsigned long int)HSPI_RX_Addr1;
}

__attribute__((interrupt("WCH-Interrupt-fast"))) void HSPI_IRQHandler(void)
Expand Down

0 comments on commit f4a0b8e

Please sign in to comment.