Quick fix for 446x.c temperature reading. Refactoring opportunity.

pull/4/head
CInsights 2018-03-09 11:15:50 +11:00
rodzic 99cd619f35
commit 7937fad841
4 zmienionych plików z 24 dodań i 17 usunięć

Wyświetl plik

@ -124,7 +124,7 @@ const conf_t conf_flash_default = {
},
.rx = {
.thread_conf = {
.active = true
.active = false
},
.radio_conf = {
.pwr = 0x7F,

Wyświetl plik

@ -1453,20 +1453,23 @@ void Si446x_send2FSK(packet_t pp,
/* ========================================================================== Misc ========================================================================== */
static int16_t Si446x_getTemperature(void) {
const uint8_t txData[2] = {0x14, 0x10};
uint8_t rxData[8];
Si446x_read(txData, 2, rxData, 8);
uint16_t adc = rxData[7] | ((rxData[6] & 0x7) << 8);
return (89900*adc)/4096 - 29300;
Si446x_lockRadio();
const uint8_t txData[2] = {0x14, 0x10};
uint8_t rxData[8];
Si446x_read(txData, 2, rxData, 8);
uint16_t adc = rxData[7] | ((rxData[6] & 0x7) << 8);
Si446x_unlockRadio();
return (89900*adc)/4096 - 29300;
}
int16_t Si446x_getLastTemperature(void) {
if(lastTemp == 0x7FFF) { // Temperature was never measured => measure it now
Si446x_init();
Si446x_shutdown();
}
return lastTemp;
if(lastTemp == 0x7FFF) { // Temperature was never measured => measure it now
Si446x_lockRadio();
Si446x_init();
Si446x_shutdown();
Si446x_unlockRadio();
}
return lastTemp;
}
//#endif

Wyświetl plik

@ -107,6 +107,7 @@ bool pktServiceRelease() {
* @param[in] encoding radio link level encoding.
* @param[in] frequency operating frequency (in Hz).
* @param[in] ch_step frequency step per channel (in Hz).
* @param[in] ph variable to receive the reference to the packet handler.
*
* @return the reference to the packet handler object.
* @retval MSG_OK if the open request was processed.

Wyświetl plik

@ -95,8 +95,9 @@ bool transmitOnRadio(packet_t pp, uint32_t freq, uint16_t step, uint8_t chan,
extern packet_svc_t RPKTD1;
packet_svc_t *handler = &RPKTD1;
if(!(handler->state == PACKET_OPEN || handler->state == PACKET_RUN)) {
if(handler->state == PACKET_IDLE || handler->state == PACKET_CLOSE) {
TRACE_ERROR("RAD > Packet services are not open for transmit");
ax25_delete(pp);
return false;
}
@ -115,12 +116,13 @@ bool transmitOnRadio(packet_t pp, uint32_t freq, uint16_t step, uint8_t chan,
rt.callback = NULL;
/* Save the current data. */
handler->radio_tx_config = rt;
//handler->radio_tx_config = rt;
msg_t msg = pktSendRadioCommand(rt.handler, &rt);
if(msg != MSG_OK)
msg_t msg = pktSendRadioCommand(handler, &rt);
if(msg != MSG_OK) {
ax25_delete(pp);
return false;
}
/* switch(mod)
{
case MOD_2FSK:
@ -136,6 +138,7 @@ bool transmitOnRadio(packet_t pp, uint32_t freq, uint16_t step, uint8_t chan,
TRACE_ERROR("RAD > It is nonsense to transmit 0 bits, %d.%03d MHz, Pwr dBm, %s, %d byte",
freq/1000000, (freq%1000000)/1000, pwr,
getModulation(mod), len);
ax25_delete(pp);
}
return true;