diff options
author | Sylvain Miermont <smiermont@semtech.com> | 2013-10-24 11:10:04 +0200 |
---|---|---|
committer | Sylvain Miermont <smiermont@semtech.com> | 2013-10-24 11:10:50 +0200 |
commit | b9710cd6fa8195e442f8bbce53364a125c9198ad (patch) | |
tree | d01d5345b7c85df6d003db1e17c82187c8b22d31 /libloragw/src/loragw_hal.c | |
parent | 4977430ef31fb52994fed42b9cb180930ed943d0 (diff) | |
download | lora_gateway-b9710cd6fa8195e442f8bbce53364a125c9198ad.tar.gz lora_gateway-b9710cd6fa8195e442f8bbce53364a125c9198ad.tar.bz2 lora_gateway-b9710cd6fa8195e442f8bbce53364a125c9198ad.zip |
v1.0.0v1.0.0
- switched FTDI as default SPI phy layer in library.cfg
- fixed a bug in TX power control; still only two TW power available, 14 and 24 dBm
- changed library directory name from loragw_hal to libloragw to follow usual conventions
Diffstat (limited to 'libloragw/src/loragw_hal.c')
-rw-r--r-- | libloragw/src/loragw_hal.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/libloragw/src/loragw_hal.c b/libloragw/src/loragw_hal.c index 930f13e..881abd4 100644 --- a/libloragw/src/loragw_hal.c +++ b/libloragw/src/loragw_hal.c @@ -886,6 +886,7 @@ int lgw_send(struct lgw_pkt_tx_s pkt_data) { uint16_t fsk_dr_div; /* divider to configure for target datarate */ int transfer_size = 0; /* data to transfer from host to TX databuffer */ int payload_offset = 0; /* start of the payload content in the databuffer */ + uint8_t power_nibble = 0; /* 4-bit value to set the firmware TX power */ /* check if the gateway is running */ if (lgw_is_started == false) { @@ -948,6 +949,14 @@ int lgw_send(struct lgw_pkt_tx_s pkt_data) { return LGW_HAL_ERROR; } + /* interpretation of TX power */ + if (pkt_data.rf_power < 24) { + power_nibble = 0x0; /* ~15.5 dBm, so 14 after cavity filter + cables */ + } else { + power_nibble = 0xF; /* maximum power ~25.5 dBm, 24 after filter */ + } + // TODO: implement LUT in the firmware and matched value in the HAL + /* reset TX command flags */ lgw_reg_w(LGW_TX_TRIG_IMMEDIATE, 0); lgw_reg_w(LGW_TX_TRIG_DELAYED, 0); @@ -973,8 +982,7 @@ int lgw_send(struct lgw_pkt_tx_s pkt_data) { /* parameters depending on modulation */ if (pkt_data.modulation == MOD_LORA) { /* metadata 7, modulation type, radio chain selection and TX power */ - buff[7] = (0x20 & (pkt_data.rf_chain << 5)) | (0x0F & pkt_data.rf_power); /* bit 4 is 0 -> Lora modulation */ - /* fine control over TX power not supported yet, any value other than 8 is 14 dBm */ + buff[7] = (0x20 & (pkt_data.rf_chain << 5)) | (0x0F & power_nibble); /* bit 4 is 0 -> Lora modulation */ buff[8] = 0; /* metadata 8, not used */ @@ -1033,8 +1041,7 @@ int lgw_send(struct lgw_pkt_tx_s pkt_data) { } else if (pkt_data.modulation == MOD_FSK) { /* metadata 7, modulation type, radio chain selection and TX power */ - buff[7] = (0x20 & (pkt_data.rf_chain << 5)) | 0x10 | (0x0F & pkt_data.rf_power); /* bit 4 is 1 -> FSK modulation */ - /* fine control over TX power not supported yet, any value other than 8 is 14 dBm */ + buff[7] = (0x20 & (pkt_data.rf_chain << 5)) | 0x10 | (0x0F & power_nibble); /* bit 4 is 1 -> FSK modulation */ buff[8] = 0; /* metadata 8, not used */ |