Send 16/32 bit functions and read 16/32 bit from buffer functions added - to reduce complexity.
This commit is contained in:
parent
d12c75fa00
commit
37aef95e34
1 changed files with 28 additions and 35 deletions
|
@ -255,14 +255,9 @@ void cc_startMeasurement()
|
||||||
// MSG_TYPE_MEAS_FREQ_INFO
|
// MSG_TYPE_MEAS_FREQ_INFO
|
||||||
sendSOM();
|
sendSOM();
|
||||||
Serial.write(MSG_TYPE_MEAS_FREQ_INFO);
|
Serial.write(MSG_TYPE_MEAS_FREQ_INFO);
|
||||||
Serial.write((uint8_t)((freq & 0xff000000) >> 24));
|
send32BitValue(freq);
|
||||||
Serial.write((uint8_t)((freq & 0x00ff0000) >> 16));
|
send16BitValue(a0_sum);
|
||||||
Serial.write((uint8_t)((freq & 0x0000ff00) >> 8));
|
send16BitValue(a1_sum);
|
||||||
Serial.write((uint8_t) (freq & 0x000000ff));
|
|
||||||
Serial.write((uint8_t)((a0_sum & 0xff00) >> 8));
|
|
||||||
Serial.write((uint8_t) (a0_sum & 0x00ff));
|
|
||||||
Serial.write((uint8_t)((a1_sum & 0xff00) >> 8));
|
|
||||||
Serial.write((uint8_t) (a1_sum & 0x00ff));
|
|
||||||
sendEOM();
|
sendEOM();
|
||||||
|
|
||||||
si5351.output_enable(SI5351_CLK0, 0); // disable clock output 0
|
si5351.output_enable(SI5351_CLK0, 0); // disable clock output 0
|
||||||
|
@ -285,20 +280,10 @@ void cc_getConfig()
|
||||||
{
|
{
|
||||||
sendSOM();
|
sendSOM();
|
||||||
Serial.write(MSG_TYPE_CONFIG);
|
Serial.write(MSG_TYPE_CONFIG);
|
||||||
Serial.write((uint8_t)((start_freq & 0xff000000) >> 24));
|
send32BitValue(start_freq);
|
||||||
Serial.write((uint8_t)((start_freq & 0x00ff0000) >> 16));
|
send32BitValue(end_freq);
|
||||||
Serial.write((uint8_t)((start_freq & 0x0000ff00) >> 8));
|
send32BitValue(step_freq);
|
||||||
Serial.write((uint8_t) (start_freq & 0x000000ff));
|
send16BitValue(intervall);
|
||||||
Serial.write((uint8_t)((end_freq & 0xff000000) >> 24));
|
|
||||||
Serial.write((uint8_t)((end_freq & 0x00ff0000) >> 16));
|
|
||||||
Serial.write((uint8_t)((end_freq & 0x0000ff00) >> 8));
|
|
||||||
Serial.write((uint8_t) (end_freq & 0x000000ff));
|
|
||||||
Serial.write((uint8_t)((step_freq & 0xff000000) >> 24));
|
|
||||||
Serial.write((uint8_t)((step_freq & 0x00ff0000) >> 16));
|
|
||||||
Serial.write((uint8_t)((step_freq & 0x0000ff00) >> 8));
|
|
||||||
Serial.write((uint8_t) (step_freq & 0x000000ff));
|
|
||||||
Serial.write((uint8_t)((intervall & 0xff00) >> 8));
|
|
||||||
Serial.write((uint8_t) (intervall & 0x00ff));
|
|
||||||
Serial.write((uint8_t) drive_str);
|
Serial.write((uint8_t) drive_str);
|
||||||
sendEOM();
|
sendEOM();
|
||||||
}
|
}
|
||||||
|
@ -372,10 +357,7 @@ void cc_saveDefaults(void)
|
||||||
|
|
||||||
void cc_setClkCorrection(void)
|
void cc_setClkCorrection(void)
|
||||||
{
|
{
|
||||||
uint32_t tmp_corr = (uint32_t)cc_read_data[0] << 24;
|
uint32_t tmp_corr = read32BitDataFromBuffer(0);
|
||||||
tmp_corr += (uint32_t)cc_read_data[1] << 16;
|
|
||||||
tmp_corr += (uint32_t)cc_read_data[2] << 8;
|
|
||||||
tmp_corr += (uint32_t)cc_read_data[3];
|
|
||||||
|
|
||||||
si5351.set_correction(tmp_corr);
|
si5351.set_correction(tmp_corr);
|
||||||
|
|
||||||
|
@ -389,10 +371,7 @@ void cc_getClkCorrection(void)
|
||||||
uint32_t tmp_corr = si5351.get_correction();
|
uint32_t tmp_corr = si5351.get_correction();
|
||||||
|
|
||||||
sendSOM();
|
sendSOM();
|
||||||
Serial.write((uint8_t)((tmp_corr & 0xff000000) >> 24));
|
send32BitValue(tmp_corr);
|
||||||
Serial.write((uint8_t)((tmp_corr & 0x00ff0000) >> 16));
|
|
||||||
Serial.write((uint8_t)((tmp_corr & 0x0000ff00) >> 8));
|
|
||||||
Serial.write((uint8_t) (tmp_corr & 0x000000ff));
|
|
||||||
sendEOM();
|
sendEOM();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -411,11 +390,9 @@ void cc_init()
|
||||||
void cc_abort()
|
void cc_abort()
|
||||||
{
|
{
|
||||||
// send abort message, then init
|
// send abort message, then init
|
||||||
char* tmp = " ";
|
sendSOM();
|
||||||
sprintf(tmp, "%c%c%c%c%c", MSG_SOM1, MSG_SOM2,
|
Serial.write(MSG_TYPE_ANSWER_NOK);
|
||||||
MSG_TYPE_ANSWER_NOK,
|
sendEOM();
|
||||||
MSG_EOM1, MSG_EOM2);
|
|
||||||
Serial.write(tmp);
|
|
||||||
|
|
||||||
cc_init();
|
cc_init();
|
||||||
}
|
}
|
||||||
|
@ -535,3 +512,19 @@ void sendEOM()
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
void send32BitValue(uint32_t value)
|
||||||
|
{
|
||||||
|
Serial.write((uint8_t)((value & 0xff000000) >> 24));
|
||||||
|
Serial.write((uint8_t)((value & 0x00ff0000) >> 16));
|
||||||
|
Serial.write((uint8_t)((value & 0x0000ff00) >> 8));
|
||||||
|
Serial.write((uint8_t) (value & 0x000000ff));
|
||||||
|
}
|
||||||
|
|
||||||
|
void send16BitValue(uint16_t value)
|
||||||
|
{
|
||||||
|
Serial.write((uint8_t)((value & 0xff00) >> 8));
|
||||||
|
Serial.write((uint8_t) (value & 0x00ff));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue