diff options
Diffstat (limited to 'fw/fe310/eos/soc/trap_entry.S')
-rw-r--r-- | fw/fe310/eos/soc/trap_entry.S | 45 |
1 files changed, 26 insertions, 19 deletions
diff --git a/fw/fe310/eos/soc/trap_entry.S b/fw/fe310/eos/soc/trap_entry.S index 1d3d1c2..98f9267 100644 --- a/fw/fe310/eos/soc/trap_entry.S +++ b/fw/fe310/eos/soc/trap_entry.S @@ -136,7 +136,7 @@ i2s_abuf_pop: 1: sh x18, I2S_ABUF_OFF_IDXR(x9) - # check for correct channel if mode is stereo + # check if buf data is for correct channel if mode is stereo lw x21, I2S_MODE(x27) bnez x21, 2f andi x22, x22, 1 @@ -209,11 +209,16 @@ i2s_sd_xchg: li x21, (1 << I2S_PIN_SR_CK) lw x22, GPIO_OUTPUT_VAL(x18) + # disable intpu, enable output for I2S_PIN_SD_OUT (pin is low) lw x9, GPIO_OUTPUT_EN(x18) or x9, x9, x20 sw x9, GPIO_OUTPUT_EN(x18) - not x20, x20 + lw x9, GPIO_INPUT_EN(x18) + and x9, x9, x20 + sw x9, GPIO_INPUT_EN(x18) + + # I2S_PIN_SR_CK bit low (was high) xor x22, x22, x21 li x23, 16 @@ -230,55 +235,57 @@ i2s_sd_xchg: and x22, x22, x20 or x22, x22, x9 -#if I2S_IDLE1_CYCLES - # idle - li x9, I2S_IDLE1_CYCLES -1: - addi x9, x9, -1 - bnez x9, 1b -#endif - # read bit lw x9, GPIO_INPUT_VAL(x18) and x9, x9, x19 srli x9, x9, I2S_PIN_SD_IN or x8, x8, x9 - # 74HC595 ck low (I2S_PIN_SR_CK high) + # I2S_PIN_SR_CK pin high (74HC595 ck low) xor x22, x22, x21 sw x22, GPIO_OUTPUT_VAL(x18) +#if I2S_IDLE1_CYCLES # idle - li x9, I2S_IDLE2_CYCLES + li x9, I2S_IDLE1_CYCLES 1: addi x9, x9, -1 bnez x9, 1b +#endif - # 74HC595 ck high (I2S_PIN_SR_CK low) + # I2S_PIN_SR_CK pin low (74HC595 ck high) xor x22, x22, x21 sw x22, GPIO_OUTPUT_VAL(x18) - addi x23, x23, -1 - bnez x23, 0b - +#if I2S_IDLE2_CYCLES # idle li x9, I2S_IDLE2_CYCLES 1: addi x9, x9, -1 bnez x9, 1b +#endif + + addi x23, x23, -1 + bnez x23, 0b - # 74HC595 ck low (I2S_PIN_SR_CK high) + # I2S_PIN_SD_OUT pin low (has pull-dn) + and x22, x22, x20 + # I2S_PIN_SR_CK pin high (74HC595 ck low) xor x22, x22, x21 sw x22, GPIO_OUTPUT_VAL(x18) + # disable output, enable input for I2S_PIN_SD_OUT lw x9, GPIO_OUTPUT_EN(x18) - and x9, x9, x20 + xor x9, x9, x20 sw x9, GPIO_OUTPUT_EN(x18) + lw x9, GPIO_INPUT_EN(x18) + xor x9, x9, x20 + sw x9, GPIO_INPUT_EN(x18) slli x8, x8, 16 srai x8, x8, 16 - # skip right channel + # skip right mic channel bnez x25, i2s_sd_complete i2s_encode: |