Integrate CAN controller and implement switches interrupt

This commit is contained in:
2022-12-07 22:35:29 +01:00
parent 2e03702047
commit 7af2c51d61
17 changed files with 346 additions and 22 deletions

71
programs/can_test.prog_ Normal file
View File

@@ -0,0 +1,71 @@
reset:
br always >main
nop
hardfault:
reti
nop
memfault:
reti
nop
timer_interrupt:
reti
nop
can_interrupt:
br >can_interrupt
nop
.align
led_addr: .word 0x000F0000
timer_counter_addr: .word 0x000F0008
timer_status_addr: .word 0x000F000C
dmem_start_addr: .word 0x00000400
dmem_end_addr: .word 0x000004FC
priority_mask: .word 0xFFFFFF03
timer_target_value: .word 127 // for simulation
// timer_target_value: .word 0xF10000 // for real board
can_base_addr: .word 0x000F0100
can_control_ptr: .word =can_base_addr
can_command_ptr: .word =can_base_addr + 1
can_acceptance_code_ptr: .word =can_base_addr + 4
can_acceptance_mask_ptr: .word =can_base_addr + 5
can_acceptance_bus_timing0_ptr: .word =can_base_addr + 6
can_acceptance_bus_timing1_ptr: .word =can_base_addr + 7
can_output_control_ptr: .word =can_base_addr + 8
can_identifier0_ptr: .word =can_base_addr + 10
can_identifier1_ptr: .word =can_base_addr + 11
can_data0_ptr: .word =can_base_addr + 12
can_data1_ptr: .word =can_base_addr + 13
main:
// Initialize stack pointer to the end of the data memory
ldr r12, >dmem_end_addr
// Set runtime priority
ldr r0, >priority_mask
and r14, r0, r14
// Set LED to pattern
clr r2
addi r2, 0x7A
st08 r0, r2
// Initialize CAN
ldr r0, >can_acceptance_code_ptr
loop:
br >loop
nop
can_interrupt:
reti
nop

View File

@@ -0,0 +1,65 @@
reset:
br always >main
nop
hardfault:
reti
nop
memfault:
reti
nop
switches_interrupt:
br >switches_interrupt_handler
nop
can_interrupt:
br >can_interrupt_handler
nop
.align
led_addr: .word 0x000F0000
timer_counter_addr: .word 0x000F0008
timer_status_addr: .word 0x000F000C
dmem_start_addr: .word 0x00000400
dmem_end_addr: .word 0x000004FC
priority_mask: .word 0xFFFFFF03
// timer_target_value: .word 127 // for simulation
timer_target_value: .word 0xF10000 // for real board
main:
// Initialize stack pointer to the end of the data memory
ldr r12, >dmem_end_addr
// Set runtime priority
ldr r0, >priority_mask
and r14, r0, r14
ldr r0,>led_addr // LED addr
ldr r1,>timer_status_addr // Timer addr
ldr r3,>timer_counter_addr // Timer addr
// Set LED to pattern
clr r2
addi r2, 0x7A
st08 r0, r2
// Enable the timer...
ldr r2, >timer_target_value
st32 r3, r2
clr r2
addi r2, 0x1 // enable bit set
st32 r1, r2
loop:
br >loop
nop
timer_interrupt_handler:
// Set LED to pattern
clr r2
addi r2, 0x0C
st08 r0, r2

View File

@@ -12,11 +12,11 @@ nop
scrolling_addr: .word 0x000F00A0
scrolling_count_addr: .word 0x000F00A4
scrolling_cnt_value: .word 0x20FC000 // for real board
// scrolling_cnt_value: .word 0x500 // for simulation
// scrolling_cnt_value: .word 0x20FC000 // for real board
scrolling_cnt_value: .word 0x500 // for simulation
w_cnt_top: .word 0x3FC000 // for real board
// w_cnt_top: .word 0x100 //for simulation
// w_cnt_top: .word 0x3FC000 // for real board
w_cnt_top: .word 0x100 //for simulation
pattern_ptr: .word =pattern1