10000 Merge pull request #165 from pycom/pygate_1308_timer_fix · pycom/pycom-micropython-sigfox@a97b4f8 · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Commit a97b4f8

Browse files
authored
Merge pull request #165 from pycom/pygate_1308_timer_fix
Fixed sx1308_timer_read_us to return correct time in us
2 parents 2279f99 + 2dc02fe commit a97b4f8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/sx1308/sx1308.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ bool sx1308_init(void) {
8787
machpin_register_irq_c_handler(SX1308.TxOn, (void *)SX1308_Tx_Off_Isr);
8888
pin_irq_enable(SX1308.TxOn);
8989

90-
timer_start_value = machtimer_get_timer_counter_value();
90+
timer_start_value = machtimer_get_timer_counter_value()/(CLK_FREQ / 1000000);
9191
SX1308.firsttx = true;
9292
SX1308.txongoing = 0;
9393
SX1308.offtmstp = 0;
@@ -235,7 +235,7 @@ uint8_t sx1308_spiReadBurst(uint8_t reg, uint8_t *data, int size) {
235235
}
236236

237237
uint32_t sx1308_timer_read_us(void) {
238-
return ((machtimer_get_timer_counter_value() - timer_start_value) & 0xFFFFFFFF);
238+
return ((machtimer_get_timer_counter_value()/(CLK_FREQ / 1000000) - timer_start_value) & 0xFFFFFFFF);
239239
}
240240

241241

0 commit comments

Comments
 (0)
0