From feea644ff274193f4cbdbd3858de7a91ff85818d Mon Sep 17 00:00:00 2001 From: ninglichen Date: Tue, 31 Dec 2019 17:45:22 +0800 Subject: [PATCH] add HS0636 beep Signed-off-by: ninglichen --- Targets/LS2K/ls2k/start.S | 54 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/Targets/LS2K/ls2k/start.S b/Targets/LS2K/ls2k/start.S index 6b1dd5f7..b8d0d1f4 100644 --- a/Targets/LS2K/ls2k/start.S +++ b/Targets/LS2K/ls2k/start.S @@ -591,7 +591,11 @@ cp0_main: bal tlb_init nop +#ifdef HS0636 + bal HS0636_beep_on +#else bal beep_on +#endif nop li a0, 0x8000 1: @@ -2073,9 +2077,57 @@ LEAF(tgt_getchar) END(tgt_getchar) #ifndef BEEP_GPIO -#define BEEP_GPIO 35 +#define BEEP_GPIO 39 #endif +LEAF(HS0636_beep_on) +//enable output + li t1, 0xbfe10500 + BEEP_GPIO*4/32 + + li v1, (1<<(BEEP_GPIO&31)) + lw t0, 0(t1) + or t0, v1 + xor t0, v1 + sw t0, 0(t1) + + li t1, 0xbfe10510 + BEEP_GPIO*4/32 + li a1, 0x80 +222: + li v1, (1<<(BEEP_GPIO&31)) + lw t0, 0(t1) + or t0, v1 + xor t0, v1 + sw t0, 0(t1) + + li a0, 0xd +1: + addiu a0, -1 + nop + bnez a0, 1b + nop + + li v1, (1<<(BEEP_GPIO&31)) + lw t0, 0(t1) + or t0, v1 + sw t0, 0(t1) + + + li a0, 0xd +1: + addiu a0, -1 + nop + bnez a0, 1b + nop + + addiu a1, -1 + nop + bnez a1, 222b + nop + + jr ra + nop +END(HS0636_beep_on) + LEAF(beep_on) /* enable gpio35 output */ li t1, 0xbfe10500 + BEEP_GPIO*4/32