Play with FDMA.

This commit is contained in:
imi415 2022-08-11 23:54:50 +08:00
parent 1047755f8f
commit 3d407c43f2
Signed by: imi415
GPG Key ID: 17F01E106F9F5E0A
2 changed files with 54 additions and 38 deletions

View File

@ -131,11 +131,27 @@ typedef struct {
uint8_t UNUSED9[2]; /* Offset: 0x20022 */
} CSR_TypeDef;
/* drivers/stm/stx7105.c */
typedef struct {
__IO uint32_t SLIM_ID; /* Offset: 0x0000, SLIM CPU ID register */
__IO uint32_t SLIM_VER; /* Offset: 0x0004, SLIM CPU version register */
__IO uint32_t SLIM_EN; /* Offset: 0x0008, SLIM CPU enable control register */
__IO uint32_t SLIM_CLK_GATE; /* Offset: 0x000C, SLIM CPU clock gate register */
__IO uint32_t SLIM_ID; /* Offset: 0x0000, SLIM CPU ID register */
__IO uint32_t SLIM_VER; /* Offset: 0x0004, SLIM CPU version register */
__IO uint32_t SLIM_EN; /* Offset: 0x0008, SLIM CPU enable control register */
__IO uint32_t SLIM_CLK_GATE; /* Offset: 0x000C, SLIM CPU clock gate register */
uint32_t UNUSED0[8188]; /* Offset: 0x0010 */
__IO uint8_t SLIM_DMEM[8192]; /* Offset: 0x8000, SLIM CPU data memory */
uint32_t UNUSED1[2018]; /* Offset: 0xA000 */
__IO uint32_t PERIPH_SYNC; /* Offset: 0xBF88, Peripheral sync register */
uint32_t UNUSED2[13]; /* Offset: 0xBF8C */
__IO uint32_t PERIPH_CMD_STA; /* Offset: 0xBFC0, */
__IO uint32_t PERIPH_CMD_SET; /* Offset: 0xBFC4, */
__IO uint32_t PERIPH_CMD_CLR; /* Offset: 0xBFC8, */
__IO uint32_t PERIPH_CMD_MASK; /* Offset: 0xBFCC, */
__IO uint32_t PERIPH_INT_STA; /* Offset: 0xBFD0, */
__IO uint32_t PERIPH_INT_SET; /* Offset: 0xBFD4, */
__IO uint32_t PERIPH_INT_CLR; /* Offset: 0xBFD8, */
__IO uint32_t PERIPH_INT_MASK; /* Offset: 0xBFDC, */
uint32_t UNUSED3[8]; /* Offset: 0xBFE0 */
__IO uint8_t SLIM_IMEM[16384]; /* Offset: 0xC000, SLIM CPU instruction memory */
} FDMA_TypeDef;
#define PIO0_BASE (0xFD020000U)
@ -150,6 +166,7 @@ typedef struct {
#define ASC2_BASE (0xFD032000U)
#define ASC3_BASE (0xFD033000U)
#define FDMA0_BASE (0xFE220000U)
#define FDMA1_BASE (0xFE410000U)
#define CSR_BASE (0xFF000000U)
#define INTC_BASE (0xFFD00000U)
#define TMU_BASE (0xFFD80000U)
@ -167,6 +184,7 @@ typedef struct {
#define ASC3 ((ASC_TypeDef *)ASC3_BASE)
#define CSR ((CSR_TypeDef *)CSR_BASE)
#define FDMA0 ((FDMA_TypeDef *)FDMA0_BASE)
#define FDMA1 ((FDMA_TypeDef *)FDMA1_BASE)
#define INTC ((INTC_TypeDef *)INTC_BASE)
#define TMU ((TMU_TypeDef *)TMU_BASE)

View File

@ -33,52 +33,50 @@ void uart_init(void) {
CONSOLE_ASC->CTRL = 0x1589UL; /* 8N1, RX enable, FIFO enable, Baud mode 1 */
}
static void memory_test(void) {
for (uint32_t i = MEMTEST_START; i < MEMTEST_END; i += 4) {
*(uint32_t *)i = i;
if (i % 0x10000 == 0U) {
printf("Write to 0x%08lx...\r\n", i);
}
}
for (uint32_t i = MEMTEST_START; i < MEMTEST_END; i += 4) {
if (*(uint32_t *)i != i) {
printf("Read back error at 0x%08lx\r\n", i);
return;
}
if (i % 0x10000 == 0U) {
printf("Read from 0x%08lx...\r\n", i);
}
}
}
int main(void) {
init_led(LED_RED_GPIO, LED_RED_PIN, 0U);
init_led(LED_BLUE_GPIO, LED_BLUE_PIN, 0U);
setbuf(stdout,NULL);
setbuf(stderr,NULL);
setbuf(stdout, NULL);
setbuf(stderr, NULL);
uart_init();
printf("Hello world\r\n");
printf("Size of int: %d\r\n", sizeof(int));
printf("Size of short: %d\r\n", sizeof(short));
printf("Size of char: %d\r\n", sizeof(char));
printf("Size of long: %d\r\n", sizeof(long));
printf("Size of pointer: %d\r\n", sizeof(uint8_t *));
printf("Size of uint8_t: %d\r\n", sizeof(uint8_t));
printf("Size of uint16_t: %d\r\n", sizeof(uint16_t));
printf("Size of uint32_t: %d\r\n", sizeof(uint32_t));
printf("FDMA0 SLIM ID: 0x%08lx\r\n", FDMA0->SLIM_ID);
printf("FDMA0 SLIM Version: 0x%08lx\r\n", FDMA0->SLIM_VER);
printf("Dumping FDMA0 SLIM DMEM@%p: \r\n", FDMA0->SLIM_DMEM);
for (uint32_t i = 0; i < 2048; i++) {
if (i % 8 == 0) {
printf("0x%04lx: ", i * 4);
}
printf("0x%08lx ", ((uint32_t *)FDMA0->SLIM_DMEM)[i]);
if (i % 8 == 7) {
printf("\r\n");
}
}
printf("Dumping FDMA0 SLIM IMEM @%p: \r\n", FDMA0->SLIM_IMEM);
for (uint32_t i = 0; i < 4096; i++) {
if (i % 8 == 0) {
printf("0x%04lx: ", i * 4);
}
printf("0x%08lx ", ((uint32_t *)FDMA0->SLIM_IMEM)[i]);
if (i % 8 == 7) {
printf("\r\n");
}
}
delay_ms(5000);
memory_test();
for (;;) {
set_led(LED_BLUE_GPIO, LED_BLUE_PIN, 1U);
delay_ms(500);