CFS: Change "variable style" by "pointer style" (#523)

This commit is contained in:
Stephan 2023-02-27 19:04:18 +01:00 committed by GitHub
commit dc27027d67
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 14 deletions

View file

@ -93,10 +93,10 @@ int main() {
" simple data conversion functions using four memory-mapped registers.\n\n");
neorv32_uart0_printf("Default CFS memory-mapped registers:\n"
" * NEORV32_CFS.REG[0] (r/w): convert binary to gray code\n"
" * NEORV32_CFS.REG[1] (r/w): convert gray to binary code\n"
" * NEORV32_CFS.REG[2] (r/w): bit reversal\n"
" * NEORV32_CFS.REG[3] (r/w): byte swap\n"
" * NEORV32_CFS->REG[0] (r/w): convert binary to gray code\n"
" * NEORV32_CFS->REG[1] (r/w): convert gray to binary code\n"
" * NEORV32_CFS->REG[2] (r/w): bit reversal\n"
" * NEORV32_CFS->REG[3] (r/w): byte swap\n"
"The remaining 60 CFS registers are unused and will return 0 when read.\n");
@ -104,29 +104,29 @@ int main() {
neorv32_uart0_printf("\n--- CFS 'binary to gray' function ---\n");
for (i=0; i<TESTCASES; i++) {
tmp = xorshift32(); // get random test data
NEORV32_CFS.REG[0] = tmp; // write to CFS memory-mapped register 0
neorv32_uart0_printf("%u: IN = 0x%x, OUT = 0x%x\n", i, tmp, NEORV32_CFS.REG[0]); // read from CFS memory-mapped register 0
NEORV32_CFS->REG[0] = tmp; // write to CFS memory-mapped register 0
neorv32_uart0_printf("%u: IN = 0x%x, OUT = 0x%x\n", i, tmp, NEORV32_CFS->REG[0]); // read from CFS memory-mapped register 0
}
neorv32_uart0_printf("\n--- CFS 'gray to binary' function ---\n");
for (i=0; i<TESTCASES; i++) {
tmp = xorshift32(); // get random test data
NEORV32_CFS.REG[1] = tmp; // write to CFS memory-mapped register 1
neorv32_uart0_printf("%u: IN = 0x%x, OUT = 0x%x\n", i, tmp, NEORV32_CFS.REG[1]); // read from CFS memory-mapped register 1
NEORV32_CFS->REG[1] = tmp; // write to CFS memory-mapped register 1
neorv32_uart0_printf("%u: IN = 0x%x, OUT = 0x%x\n", i, tmp, NEORV32_CFS->REG[1]); // read from CFS memory-mapped register 1
}
neorv32_uart0_printf("\n--- CFS 'bit reversal' function ---\n");
for (i=0; i<TESTCASES; i++) {
tmp = xorshift32(); // get random test data
NEORV32_CFS.REG[2] = tmp; // write to CFS memory-mapped register 2
neorv32_uart0_printf("%u: IN = 0x%x, OUT = 0x%x\n", i, tmp, NEORV32_CFS.REG[2]); // read from CFS memory-mapped register 2
NEORV32_CFS->REG[2] = tmp; // write to CFS memory-mapped register 2
neorv32_uart0_printf("%u: IN = 0x%x, OUT = 0x%x\n", i, tmp, NEORV32_CFS->REG[2]); // read from CFS memory-mapped register 2
}
neorv32_uart0_printf("\n--- CFS 'byte swap' function ---\n");
for (i=0; i<TESTCASES; i++) {
tmp = xorshift32(); // get random test data
NEORV32_CFS.REG[3] = tmp; // write to CFS memory-mapped register 3
neorv32_uart0_printf("%u: IN = 0x%x, OUT = 0x%x\n", i, tmp, NEORV32_CFS.REG[3]); // read from CFS memory-mapped register 3
NEORV32_CFS->REG[3] = tmp; // write to CFS memory-mapped register 3
neorv32_uart0_printf("%u: IN = 0x%x, OUT = 0x%x\n", i, tmp, NEORV32_CFS->REG[3]); // read from CFS memory-mapped register 3
}

View file

@ -726,7 +726,7 @@ typedef struct __attribute__((packed,aligned(4))) {
**************************************************************************/
/**@{*/
/** CFS module prototype */
typedef struct __attribute__((packed,aligned(4))) {
typedef volatile struct __attribute__((packed,aligned(4))) {
uint32_t REG[64]; /**< offset 4*0..4*63: CFS register 0..63, user-defined */
} neorv32_cfs_t;
@ -734,7 +734,7 @@ typedef struct __attribute__((packed,aligned(4))) {
#define NEORV32_CFS_BASE (0xFFFFFE00U)
/** CFS module hardware access (#neorv32_cfs_t) */
#define NEORV32_CFS (*((volatile neorv32_cfs_t*) (NEORV32_CFS_BASE)))
#define NEORV32_CFS ((neorv32_cfs_t*) (NEORV32_CFS_BASE))
/**@}*/