/** * \brief Test running speed between different slave configurations. * * \param test Current test case. */ static void run_hmatrix_test_slave(const struct test_case *test) { enum hmatrix_master_id ul_master_id; enum hmatrix_slave_id ul_slave_id; uint32_t ul_cnt1, ul_cnt2, ul_cnt3; struct hmatrix_master_ch_conf master_config; struct hmatrix_slave_ch_conf slave_config; /* Enable the HMATRIX access. */ hmatrix_enable(); hmatrix_master_ch_get_config_defaults(&master_config); hmatrix_slave_ch_get_config_defaults(&slave_config); /* Config all master with default setting */ for (ul_master_id = HMATRIX_MASTER_ID_CPU_IDCORE; ul_master_id < HMATRIX_MASTER_ID_NUM; ul_master_id++) { hmatrix_master_ch_set_config(ul_master_id, &master_config); } /* First, test with Round-Robin arbitration without default master */ slave_config.def_master_type = HMATRIX_DEFAULT_MASTER_NONE; for (ul_slave_id = HMATRIX_SLAVE_ID_FLASH; ul_slave_id < HMATRIX_SLAVE_ID_NUM; ul_slave_id++) { hmatrix_slave_ch_set_config(ul_slave_id, &slave_config); } ul_cnt1 = toggle_led_test(1000); /* Compare 1: test with Round-Robin arbitration with last access master */ slave_config.def_master_type = HMATRIX_DEFAULT_MASTER_PREVIOUS; for (ul_slave_id = HMATRIX_SLAVE_ID_FLASH; ul_slave_id < HMATRIX_SLAVE_ID_NUM; ul_slave_id++) { hmatrix_slave_ch_set_config(ul_slave_id, &slave_config); } ul_cnt2 = toggle_led_test(1000); test_assert_true(test, (ul_cnt1 < ul_cnt2), "running speed test failed!"); /* Compare 2: test with Round-Robin arbitration with fixed master */ slave_config.def_master_type = HMATRIX_DEFAULT_MASTER_FIXED; slave_config.fixed_def_master_number = HMATRIX_MASTER_ID_CPU_IDCORE; hmatrix_slave_ch_set_config(HMATRIX_SLAVE_ID_FLASH, &slave_config); slave_config.fixed_def_master_number = HMATRIX_MASTER_ID_CPU_SYS; for (ul_slave_id = HMATRIX_SLAVE_ID_PBA; ul_slave_id < HMATRIX_SLAVE_ID_NUM; ul_slave_id++) { hmatrix_slave_ch_set_config(ul_slave_id, &slave_config); } ul_cnt3 = toggle_led_test(1000); test_assert_true(test, (ul_cnt1 < ul_cnt3), "running speed test failed!"); /* Disable the HMATRIX access. */ hmatrix_disable(); }
/** * \brief Application entry point. * * \return Unused (ANSI-C compatibility). */ int main(void) { enum hmatrix_slave_id ul_slave_id; int32_t ul_cnt; struct hmatrix_slave_ch_conf config; /* Initialize the system */ sysclk_init(); board_init(); /* Configure console UART */ configure_console(); /* Output example information */ puts(STRING_HEADER); /* Configure systick for 1 ms */ puts("Configure system tick to get 1ms tick period.\r"); if (SysTick_Config(sysclk_get_cpu_hz() / 1000)) { puts("-F- Systick configuration error\r"); while (1) { } } /* Enable the HMATRIX access. */ hmatrix_enable(); hmatrix_slave_ch_get_config_defaults(&config); /* First, test with Round-Robin arbitration without default master */ puts("-- Test1: configure Round-Robin arbitration without default master. --\r"); config.def_master_type = HMATRIX_DEFAULT_MASTER_NONE; for (ul_slave_id = HMATRIX_SLAVE_ID_FLASH; ul_slave_id < HMATRIX_SLAVE_ID_NUM; ul_slave_id++) { hmatrix_slave_ch_set_config(ul_slave_id, &config); } ul_cnt = toggle_led_test(1000); printf(" Led toggled %ld times in one second\n\r", (long)ul_cnt); /* Second, test with Round-Robin arbitration with last access master */ puts("-- Test2: configure Round-Robin arbitration with last access master. --\r"); config.def_master_type = HMATRIX_DEFAULT_MASTER_PREVIOUS; for (ul_slave_id = HMATRIX_SLAVE_ID_FLASH; ul_slave_id < HMATRIX_SLAVE_ID_NUM; ul_slave_id++) { hmatrix_slave_ch_set_config(ul_slave_id, &config); } ul_cnt = toggle_led_test(1000); printf(" Led toggled %ld times in one second\n\r", (long)ul_cnt); /* Endless loop */ while (1) { } }
/** * \brief Application entry point. * * \return Unused (ANSI-C compatibility). */ int main(void) { uint32_t ul_slave_id, ul_cnt; /* Initialize the system */ sysclk_init(); board_init(); /* Configure console UART */ configure_console(); /* Output example information */ puts(STRING_HEADER); /* Configure systick for 1 ms */ puts("Configure system tick to get 1ms tick period.\r"); if (SysTick_Config(sysclk_get_cpu_hz() / 1000)) { puts("-F- Systick configuration error\r"); while (1) { } } /* First, test with Round-Robin arbitration without default master */ puts("-- Test1: configure Round-Robin arbitration without default master. --\r"); for (ul_slave_id = 0; ul_slave_id < MATRIX_SLAVE_NUM; ul_slave_id++) { #if (!SAM4E) && (!SAM4C) && (!SAM4CP) matrix_set_slave_arbitration_type(ul_slave_id, MATRIX_ARBT_ROUND_ROBIN); #endif matrix_set_slave_default_master_type(ul_slave_id, MATRIX_DEFMSTR_NO_DEFAULT_MASTER); } ul_cnt = toggle_led_test(1000); printf("Led toggled %ld times in one second\n\r", (long)ul_cnt); /* Second, test with Round-Robin arbitration with last access master */ puts("-- Test2: configure Round-Robin arbitration with last access master. --\r"); for (ul_slave_id = 0; ul_slave_id < MATRIX_SLAVE_NUM; ul_slave_id++) { #if (!SAM4E) && (!SAM4C) && (!SAM4CP) matrix_set_slave_arbitration_type(ul_slave_id, MATRIX_ARBT_ROUND_ROBIN); #endif matrix_set_slave_default_master_type(ul_slave_id, MATRIX_DEFMSTR_LAST_DEFAULT_MASTER); } ul_cnt = toggle_led_test(1000); printf("Led toggled %ld times in one second\n\r", (long)ul_cnt); /* Endless loop */ while (1) { } }
/** * \brief Test running speed between different arbitration configurations. * * \param test Current test case. */ static void run_hmatrix_test_arbitration(const struct test_case *test) { enum hmatrix_master_id ul_master_id; enum hmatrix_slave_id ul_slave_id; uint32_t ul_cnt1, ul_cnt2; struct hmatrix_master_ch_conf master_config; struct hmatrix_slave_ch_conf slave_config; hmatrix_prs priority_setting; /* Enable the HMATRIX access. */ hmatrix_enable(); hmatrix_master_ch_get_config_defaults(&master_config); hmatrix_slave_ch_get_config_defaults(&slave_config); /* Config all master with default setting */ for (ul_master_id = HMATRIX_MASTER_ID_CPU_IDCORE; ul_master_id < HMATRIX_MASTER_ID_NUM; ul_master_id++) { hmatrix_master_ch_set_config(ul_master_id, &master_config); } /* Compare 1: First, test with Round-Robin arbitration */ for (ul_slave_id = HMATRIX_SLAVE_ID_FLASH; ul_slave_id < HMATRIX_SLAVE_ID_NUM; ul_slave_id++) { hmatrix_slave_ch_set_config(ul_slave_id, &slave_config); } ul_cnt1 = toggle_led_test(1000); /* Compare 1: Second, test with fixed arbitration */ slave_config.arbitration_type = HMATRIX_ARBITRATION_FIXED_PRIORITY; priority_setting.HMATRIXB_PRAS = 0x03; priority_setting.HMATRIXB_PRBS = 0x00; hmatrix_set_slave_priority(HMATRIX_SLAVE_ID_FLASH, &priority_setting); hmatrix_slave_ch_set_config(HMATRIX_SLAVE_ID_FLASH, &slave_config); priority_setting.HMATRIXB_PRAS = 0x30; priority_setting.HMATRIXB_PRBS = 0x00; for (ul_slave_id = HMATRIX_SLAVE_ID_PBA; ul_slave_id < HMATRIX_SLAVE_ID_NUM; ul_slave_id++) { hmatrix_set_slave_priority(ul_slave_id, &priority_setting); hmatrix_slave_ch_set_config(ul_slave_id, &slave_config); } ul_cnt2 = toggle_led_test(1000); test_assert_true(test, (ul_cnt1 < ul_cnt2), "running speed test failed!"); /* Disable the HMATRIX access. */ hmatrix_disable(); }
/** * \brief Test running speed between different master configurations. * * \param test Current test case. */ static void run_hmatrix_test_master(const struct test_case *test) { enum hmatrix_master_id ul_master_id; enum hmatrix_slave_id ul_slave_id; uint32_t ul_cnt1, ul_cnt2; struct hmatrix_master_ch_conf master_config; struct hmatrix_slave_ch_conf slave_config; /* Enable the HMATRIX access. */ hmatrix_enable(); hmatrix_master_ch_get_config_defaults(&master_config); hmatrix_slave_ch_get_config_defaults(&slave_config); /* Config all slave with default setting */ for (ul_slave_id = HMATRIX_SLAVE_ID_FLASH; ul_slave_id < HMATRIX_SLAVE_ID_NUM; ul_slave_id++) { hmatrix_slave_ch_set_config(ul_slave_id, &slave_config); } /* Compare 1: First, test with single access master */ master_config.burst_type = HMATRIX_BURST_SINGLE_ACCESS; for (ul_master_id = HMATRIX_MASTER_ID_CPU_IDCORE; ul_master_id < HMATRIX_MASTER_ID_NUM; ul_master_id++) { hmatrix_master_ch_set_config(ul_master_id, &master_config); } ul_cnt1 = toggle_led_test(1000); /* Compare 1: Second, test with 16 beat burst access master */ master_config.burst_type = HMATRIX_BURST_SIXTEEN_BEAT; for (ul_master_id = HMATRIX_MASTER_ID_CPU_IDCORE; ul_master_id < HMATRIX_MASTER_ID_NUM; ul_master_id++) { hmatrix_master_ch_set_config(ul_master_id, &master_config); } ul_cnt2 = toggle_led_test(1000); test_assert_true(test, (ul_cnt1 < ul_cnt2), "running speed test failed!"); /* Disable the HMATRIX access. */ hmatrix_disable(); }