本帖最后由 ddllxxrr 于 2015-3-26 21:52 编辑
这个例程是测试MATRIX即混合矩阵
本例程的第一个测试是运行在without default master
第二个测试是运行在with last access master
象前几个例程一样,首先打开:
而这两个定义是在这里:martix.h
/** \brief Matrix slave: default master type */
typedef enum {
MATRIX_DEFMSTR_NO_DEFAULT_MASTER = MATRIX_SCFG_DEFMSTR_TYPE(0),
MATRIX_DEFMSTR_LAST_DEFAULT_MASTER = MATRIX_SCFG_DEFMSTR_TYPE(1),
MATRIX_DEFMSTR_FIXED_DEFAULT_MASTER = MATRIX_SCFG_DEFMSTR_TYPE(2)
} defaut_master_t;
并且用了滴答时钟记数看看哪个用时多。
tatic uint32_t toggle_led_test(uint32_t ul_dly_ticks)
{
int32_t ul_cnt = 0;
uint32_t ul_cur_ticks;
ul_cur_ticks = g_ul_ms_ticks;
do {
ul_cnt++;
#if SAM4CM
ioport_toggle_pin_level(LED4_GPIO);
#else
ioport_toggle_pin_level(LED0_GPIO);
#endif
} while ((g_ul_ms_ticks - ul_cur_ticks) < ul_dly_ticks);
return ul_cnt;
}
最后在程序中转换主控制:
/* 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) && (!SAM4CM)
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) && (!SAM4CM)
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);
运行的结果如下:
|