Skip to content
Snippets Groups Projects
Commit f181c361 authored by hsu10's avatar hsu10
Browse files

gpt version

parent b736c90b
Branches xu
No related tags found
No related merge requests found
......@@ -3,7 +3,7 @@
#define REGA 0x10000000
#define REGB 0x10000004
#define REGC 0x10000008
static void delay_cycles(int n_cycles) {
REG32(RV_TIMER_CTRL(0)) = (1<<RV_TIMER_CTRL_ACTIVE0_LSB);
......@@ -11,20 +11,20 @@ static void delay_cycles(int n_cycles) {
while(REG32(RV_TIMER_TIMER_V_LOWER0(0)) < n_cycles);
}
int main(void) {
// Implement tests here.
// Example:
void test_mode(int mode, int param, int delay) {
printf("Testing mode %d with parameter %d\n", mode, param);
REG32(REGA) = mode; // Set mode
REG32(REGB) = param; // Set parameter N
delay_cycles(delay);
printf("REGC state: 0x%08x\n", REG32(REGC)); // Read LED state
}
printf("REGA 0x%08x\n", REG32(REGA));
REG32(REGA) = 0x12345678;
printf("REGA 0x%08x\n", REG32(REGA));
delay_cycles(2);
int main(void) {
// Test different modes
test_mode(1, 10, 50); // Mode 1, Parameter N=10, Delay for 50 cycles
test_mode(2, 20, 100); // Mode 2, Parameter N=20, Delay for 100 cycles
test_mode(0, 15, 75); // Ping-Pong Mode, Parameter N=15, Delay for 75 cycles
test_mode(3, 5, 25); // Stop Mode, Parameter N=5, Delay for 25 cycles
REG32(REGB) = 0xFFFFFF01;
printf("REGB 0x%08x\n", REG32(REGB));
delay_cycles(10);
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment