kopia lustrzana https://github.com/DL7AD/pecanpico10
Quick fix for 446x.c temperature reading. Refactoring opportunity.
rodzic
99cd619f35
commit
7937fad841
|
|
@ -124,7 +124,7 @@ const conf_t conf_flash_default = {
|
||||||
},
|
},
|
||||||
.rx = {
|
.rx = {
|
||||||
.thread_conf = {
|
.thread_conf = {
|
||||||
.active = true
|
.active = false
|
||||||
},
|
},
|
||||||
.radio_conf = {
|
.radio_conf = {
|
||||||
.pwr = 0x7F,
|
.pwr = 0x7F,
|
||||||
|
|
|
||||||
|
|
@ -1453,20 +1453,23 @@ void Si446x_send2FSK(packet_t pp,
|
||||||
/* ========================================================================== Misc ========================================================================== */
|
/* ========================================================================== Misc ========================================================================== */
|
||||||
|
|
||||||
static int16_t Si446x_getTemperature(void) {
|
static int16_t Si446x_getTemperature(void) {
|
||||||
const uint8_t txData[2] = {0x14, 0x10};
|
Si446x_lockRadio();
|
||||||
uint8_t rxData[8];
|
const uint8_t txData[2] = {0x14, 0x10};
|
||||||
Si446x_read(txData, 2, rxData, 8);
|
uint8_t rxData[8];
|
||||||
uint16_t adc = rxData[7] | ((rxData[6] & 0x7) << 8);
|
Si446x_read(txData, 2, rxData, 8);
|
||||||
return (89900*adc)/4096 - 29300;
|
uint16_t adc = rxData[7] | ((rxData[6] & 0x7) << 8);
|
||||||
|
Si446x_unlockRadio();
|
||||||
|
return (89900*adc)/4096 - 29300;
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t Si446x_getLastTemperature(void) {
|
int16_t Si446x_getLastTemperature(void) {
|
||||||
if(lastTemp == 0x7FFF) { // Temperature was never measured => measure it now
|
if(lastTemp == 0x7FFF) { // Temperature was never measured => measure it now
|
||||||
Si446x_init();
|
Si446x_lockRadio();
|
||||||
Si446x_shutdown();
|
Si446x_init();
|
||||||
}
|
Si446x_shutdown();
|
||||||
|
Si446x_unlockRadio();
|
||||||
return lastTemp;
|
}
|
||||||
|
return lastTemp;
|
||||||
}
|
}
|
||||||
|
|
||||||
//#endif
|
//#endif
|
||||||
|
|
|
||||||
|
|
@ -107,6 +107,7 @@ bool pktServiceRelease() {
|
||||||
* @param[in] encoding radio link level encoding.
|
* @param[in] encoding radio link level encoding.
|
||||||
* @param[in] frequency operating frequency (in Hz).
|
* @param[in] frequency operating frequency (in Hz).
|
||||||
* @param[in] ch_step frequency step per channel (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.
|
* @return the reference to the packet handler object.
|
||||||
* @retval MSG_OK if the open request was processed.
|
* @retval MSG_OK if the open request was processed.
|
||||||
|
|
|
||||||
|
|
@ -95,8 +95,9 @@ bool transmitOnRadio(packet_t pp, uint32_t freq, uint16_t step, uint8_t chan,
|
||||||
extern packet_svc_t RPKTD1;
|
extern packet_svc_t RPKTD1;
|
||||||
packet_svc_t *handler = &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");
|
TRACE_ERROR("RAD > Packet services are not open for transmit");
|
||||||
|
ax25_delete(pp);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -115,12 +116,13 @@ bool transmitOnRadio(packet_t pp, uint32_t freq, uint16_t step, uint8_t chan,
|
||||||
rt.callback = NULL;
|
rt.callback = NULL;
|
||||||
|
|
||||||
/* Save the current data. */
|
/* Save the current data. */
|
||||||
handler->radio_tx_config = rt;
|
//handler->radio_tx_config = rt;
|
||||||
|
|
||||||
msg_t msg = pktSendRadioCommand(rt.handler, &rt);
|
msg_t msg = pktSendRadioCommand(handler, &rt);
|
||||||
if(msg != MSG_OK)
|
if(msg != MSG_OK) {
|
||||||
|
ax25_delete(pp);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
/* switch(mod)
|
/* switch(mod)
|
||||||
{
|
{
|
||||||
case MOD_2FSK:
|
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",
|
TRACE_ERROR("RAD > It is nonsense to transmit 0 bits, %d.%03d MHz, Pwr dBm, %s, %d byte",
|
||||||
freq/1000000, (freq%1000000)/1000, pwr,
|
freq/1000000, (freq%1000000)/1000, pwr,
|
||||||
getModulation(mod), len);
|
getModulation(mod), len);
|
||||||
|
ax25_delete(pp);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
Ładowanie…
Reference in New Issue