summaryrefslogtreecommitdiff
path: root/code/fe310/eos/trap_entry.S
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2018-03-17 01:56:21 +0100
committerUros Majstorovic <majstor@majstor.org>2018-03-17 01:56:21 +0100
commit723b3db6942c8b3f51a819870df6e523008c2ed0 (patch)
tree6053da05f47b4031745e7e69af051a4b658861d1 /code/fe310/eos/trap_entry.S
parentb623f680f6a7aa53de6a1d949d857b37f391c80d (diff)
pwm scaling for i2s sck line added
Diffstat (limited to 'code/fe310/eos/trap_entry.S')
-rw-r--r--code/fe310/eos/trap_entry.S6
1 files changed, 4 insertions, 2 deletions
diff --git a/code/fe310/eos/trap_entry.S b/code/fe310/eos/trap_entry.S
index 0efac2c..fef7d27 100644
--- a/code/fe310/eos/trap_entry.S
+++ b/code/fe310/eos/trap_entry.S
@@ -32,7 +32,7 @@
#define INT_PWM1_BASE 44
#define INT_PWM2_BASE 48
-#define I2S_PWM_CTRL_ADDR_CK PWM1_CTRL_ADDR
+#define I2S_PWM_CTRL_ADDR_CK PWM0_CTRL_ADDR
#define I2S_PWM_CTRL_ADDR_WS PWM2_CTRL_ADDR
#include "i2s_def.h"
@@ -71,17 +71,19 @@ handler_sd:
li x18, I2S_PWM_CTRL_ADDR_CK
lw x8, PWM_COUNT(x18)
lw x9, PWM_CMP2(x18)
+ srli x9, x9, I2S_PWM_SCALE_CK
blt x8, x9, handler_sd_exit_
# read mic value -> x8
li x18, GPIO_CTRL_ADDR
lw x8, GPIO_INPUT_VAL(x18)
- # set bit as ws pwm counter/ck period - sd volume -> x9
+ # set bit as ws pwm counter/(ck period + 1) - sd volume -> x9
li x18, I2S_PWM_CTRL_ADDR_WS
lw x9, PWM_COUNT(x18)
la x18, _eos_i2s_ck_period
lw x19, 0(x18)
+ addi x19, x19, 1
divu x9, x9, x19
la x18, _eos_i2s_mic_volume
lw x19, 0(x18)