The command control interpreter seemes to be working now.
This commit is contained in:
parent
d6983cce0a
commit
e2aa053314
8 changed files with 182 additions and 138 deletions
1
firmware/Arduino.mk
Symbolic link
1
firmware/Arduino.mk
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
/usr/share/arduino/Arduino.mk
|
6
firmware/Makefile
Normal file
6
firmware/Makefile
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
# Arduino Make file. Refer to https://github.com/sudar/Arduino-Makefile
|
||||||
|
|
||||||
|
BOARD_TAG = nano328
|
||||||
|
#MCU = atmega328
|
||||||
|
|
||||||
|
include Arduino.mk
|
|
@ -1,65 +0,0 @@
|
||||||
/*
|
|
||||||
* Author: klaute -Kai Lauterbach - @kailauterbach - me@klaute.de
|
|
||||||
* Date: 09/2016
|
|
||||||
* License: GPLv3
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __COMMAND_CONFIG_H__
|
|
||||||
#define __COMMAND_CONFIG_H__
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include <avr/wdt.h>
|
|
||||||
|
|
||||||
#include "globals.h"
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
void cc_setStartFreq(void);
|
|
||||||
void cc_setEndFreq(void);
|
|
||||||
void cc_setIntervall(void);
|
|
||||||
void cc_setDriveStrength(void);
|
|
||||||
void cc_startMeasurement(void);
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
//#define CC_CMD_GET_CONFIG 0x0A
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
//#define CC_CMD_GET_CONFIG_FUNC &cc_getConfig
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
//#define CC_CMD_GET_CONFIG_DATA_TO_READ 0
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
#define CC_READ_DATA_MAX 64
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
uint8_t cc_commands[] = {
|
|
||||||
// CC_CMD_GET_CONFIG,
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
void (*cc_cmd_functions[])() = {
|
|
||||||
// CC_CMD_GET_CONFIG_FUNC,
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t cc_cmd_data_to_read[] = {
|
|
||||||
// CC_CMD_GET_CONFIG_DATA_TO_READ,
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
uint8_t cc_read_data[CC_READ_DATA_MAX];
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -1,39 +0,0 @@
|
||||||
/*
|
|
||||||
* Author: klaute -Kai Lauterbach - @kailauterbach - me@klaute.de
|
|
||||||
* Date: 09/2016
|
|
||||||
* License: GPLv3
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __COMMAND_CTRL_H__
|
|
||||||
#define __COMMAND_CTRL_H__
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
#define CC_STATE_READ_SOM1 20
|
|
||||||
#define CC_STATE_READ_SOM2 30
|
|
||||||
#define CC_STATE_READ_CMD 40
|
|
||||||
#define CC_STATE_READ_DATA 50
|
|
||||||
#define CC_STATE_READ_EOM1 60
|
|
||||||
#define CC_STATE_READ_EOM2 70
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
#define CC_CMD_NO_CMD 0
|
|
||||||
|
|
||||||
#define MSG_INCOMPLETE 10
|
|
||||||
#define MSG_COMPLETE 20
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
extern void USB_serialStreamWrite(char*);
|
|
||||||
|
|
||||||
void cc_init(void);
|
|
||||||
void cc_abort(void);
|
|
||||||
void cc_processData(uint8_t);
|
|
||||||
void cc_clearReadDataBuffer(void);
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,18 +1,65 @@
|
||||||
/*
|
/*
|
||||||
* Author: klaute -Kai Lauterbach - @kailauterbach - me@klaute.de
|
* Author: klaute -Kai Lauterbach - @kailauterbach - me@klaute.de
|
||||||
* Date: 08/2016
|
* Date: 09/2016
|
||||||
* License: GPLv3
|
* License: GPLv3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
#include "command_ctrl.h"
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "command_config.h"
|
#include <avr/wdt.h>
|
||||||
|
|
||||||
// include user specific command control configuration and function definition
|
/*****************************************************************************/
|
||||||
#include "command_config.h"
|
|
||||||
#include "command_functions.c"
|
void cc_init(void);
|
||||||
|
void cc_abort(void);
|
||||||
|
void cc_processData(uint8_t);
|
||||||
|
void cc_clearReadDataBuffer(void);
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
void cc_setStartFreq(void);
|
||||||
|
void cc_setEndFreq(void);
|
||||||
|
void cc_setIntervall(void);
|
||||||
|
void cc_setDriveStrength(void);
|
||||||
|
void cc_startMeasurement(void);
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
#include "globals.h"
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
uint8_t cc_commands[] = {
|
||||||
|
CC_CMD_SET_START_FREQ,
|
||||||
|
CC_CMD_SET_END_FREQ,
|
||||||
|
CC_CMD_SET_INTERVALL,
|
||||||
|
CC_CMD_SET_DRIVE_STRENGTH,
|
||||||
|
CC_CMD_START_MEASUREMENT,
|
||||||
|
};
|
||||||
|
|
||||||
|
void (*cc_cmd_functions[])() = {
|
||||||
|
CC_CMD_SET_START_FREQ_FUNC,
|
||||||
|
CC_CMD_SET_END_FREQ_FUNC,
|
||||||
|
CC_CMD_SET_INTERVALL_FUNC,
|
||||||
|
CC_CMD_SET_DRIVE_STRENGTH_FUNC,
|
||||||
|
CC_CMD_START_MEASUREMENT_FUNC,
|
||||||
|
};
|
||||||
|
|
||||||
|
uint8_t cc_cmd_data_to_read[] = {
|
||||||
|
CC_CMD_SET_START_FREQ_DATA_TO_READ,
|
||||||
|
CC_CMD_SET_END_FREQ_DATA_TO_READ,
|
||||||
|
CC_CMD_SET_INTERVALL_DATA_TO_READ,
|
||||||
|
CC_CMD_SET_DRIVE_STRENGTH_DATA_TO_READ,
|
||||||
|
CC_CMD_START_MEASUREMENT_DATA_TO_READ,
|
||||||
|
};
|
||||||
|
|
||||||
|
uint8_t cc_read_data[CC_READ_DATA_MAX];
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
@ -26,6 +73,53 @@ uint8_t cc_cmd_data_read_cnt = 0;
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
void cc_setStartFreq()
|
||||||
|
{
|
||||||
|
char* tmp = " ";
|
||||||
|
sprintf(tmp, "%c%c%c%c%c", MSG_SOM1, MSG_SOM2,
|
||||||
|
MSG_TYPE_ANSWER_NOK,
|
||||||
|
MSG_EOM1, MSG_EOM2);
|
||||||
|
Serial.write(tmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cc_setEndFreq()
|
||||||
|
{
|
||||||
|
char* tmp = " ";
|
||||||
|
sprintf(tmp, "%c%c%c%c%c", MSG_SOM1, MSG_SOM2,
|
||||||
|
MSG_TYPE_ANSWER_NOK,
|
||||||
|
MSG_EOM1, MSG_EOM2);
|
||||||
|
Serial.write(tmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cc_setIntervall()
|
||||||
|
{
|
||||||
|
char* tmp = " ";
|
||||||
|
sprintf(tmp, "%c%c%c%c%c", MSG_SOM1, MSG_SOM2,
|
||||||
|
MSG_TYPE_ANSWER_NOK,
|
||||||
|
MSG_EOM1, MSG_EOM2);
|
||||||
|
Serial.write(tmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cc_setDriveStrength()
|
||||||
|
{
|
||||||
|
char* tmp = " ";
|
||||||
|
sprintf(tmp, "%c%c%c%c%c", MSG_SOM1, MSG_SOM2,
|
||||||
|
MSG_TYPE_ANSWER_NOK,
|
||||||
|
MSG_EOM1, MSG_EOM2);
|
||||||
|
Serial.write(tmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cc_startMeasurement()
|
||||||
|
{
|
||||||
|
char* tmp = " ";
|
||||||
|
sprintf(tmp, "%c%c%c%c%c", MSG_SOM1, MSG_SOM2,
|
||||||
|
123,
|
||||||
|
MSG_EOM1, MSG_EOM2);
|
||||||
|
Serial.write(tmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
void cc_init()
|
void cc_init()
|
||||||
{
|
{
|
||||||
cc_state = CC_STATE_READ_SOM1;
|
cc_state = CC_STATE_READ_SOM1;
|
||||||
|
@ -43,7 +137,7 @@ void cc_abort()
|
||||||
sprintf(tmp, "%c%c%c%c%c", MSG_SOM1, MSG_SOM2,
|
sprintf(tmp, "%c%c%c%c%c", MSG_SOM1, MSG_SOM2,
|
||||||
MSG_TYPE_ANSWER_NOK,
|
MSG_TYPE_ANSWER_NOK,
|
||||||
MSG_EOM1, MSG_EOM2);
|
MSG_EOM1, MSG_EOM2);
|
||||||
USB_serialStreamWrite(tmp);
|
Serial.write(tmp);
|
||||||
cc_init();
|
cc_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,6 +145,8 @@ void cc_abort()
|
||||||
|
|
||||||
void cc_processData(uint8_t c)
|
void cc_processData(uint8_t c)
|
||||||
{
|
{
|
||||||
|
uint8_t i = 0;
|
||||||
|
|
||||||
switch (cc_state)
|
switch (cc_state)
|
||||||
{
|
{
|
||||||
//*********************************//
|
//*********************************//
|
||||||
|
@ -71,7 +167,7 @@ void cc_processData(uint8_t c)
|
||||||
|
|
||||||
//*********************************//
|
//*********************************//
|
||||||
case CC_STATE_READ_CMD:;
|
case CC_STATE_READ_CMD:;
|
||||||
for (uint8_t i = 0; i < sizeof(cc_commands)/sizeof(uint8_t); i++)
|
for (i = 0; i < sizeof(cc_commands)/sizeof(uint8_t); i++)
|
||||||
{
|
{
|
||||||
if (cc_commands[i] == c)
|
if (cc_commands[i] == c)
|
||||||
{
|
{
|
||||||
|
@ -137,10 +233,12 @@ void cc_processData(uint8_t c)
|
||||||
|
|
||||||
void cc_clearReadDataBuffer()
|
void cc_clearReadDataBuffer()
|
||||||
{
|
{
|
||||||
for (uint8_t i = 0; i < CC_READ_DATA_MAX; i++)
|
uint8_t i = 0;
|
||||||
|
for (i = 0; i < CC_READ_DATA_MAX; i++)
|
||||||
{
|
{
|
||||||
cc_read_data[i] = 0x00;
|
cc_read_data[i] = 0x00;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
/*
|
|
||||||
* Author: klaute -Kai Lauterbach - @kailauterbach - me@klaute.de
|
|
||||||
* Date: 09/2016
|
|
||||||
* License: GPLv3
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
|
@ -4,10 +4,6 @@
|
||||||
#include <si5351.h>
|
#include <si5351.h>
|
||||||
#include "Wire.h"
|
#include "Wire.h"
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
#include "command_ctrl.h"
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
}
|
}
|
||||||
|
@ -16,8 +12,13 @@ Si5351 si5351;
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
// Start serial and initialize the Si5351
|
// Init the serial connection
|
||||||
Serial.begin(57600);
|
Serial.begin(57600);
|
||||||
|
|
||||||
|
// initialize the command control module
|
||||||
|
cc_init();
|
||||||
|
|
||||||
|
// init the Si5351
|
||||||
si5351.init(SI5351_CRYSTAL_LOAD_8PF, 0);
|
si5351.init(SI5351_CRYSTAL_LOAD_8PF, 0);
|
||||||
|
|
||||||
// Set CLK0 to output 14 MHz with a fixed PLL frequency
|
// Set CLK0 to output 14 MHz with a fixed PLL frequency
|
||||||
|
@ -35,6 +36,8 @@ void loop()
|
||||||
{
|
{
|
||||||
// Read the Status Register and print it every 10 seconds
|
// Read the Status Register and print it every 10 seconds
|
||||||
si5351.update_status();
|
si5351.update_status();
|
||||||
|
|
||||||
|
/*
|
||||||
Serial.print("SYS_INIT: ");
|
Serial.print("SYS_INIT: ");
|
||||||
Serial.print(si5351.dev_status.SYS_INIT);
|
Serial.print(si5351.dev_status.SYS_INIT);
|
||||||
Serial.print(" LOL_A: ");
|
Serial.print(" LOL_A: ");
|
||||||
|
@ -45,6 +48,14 @@ void loop()
|
||||||
Serial.print(si5351.dev_status.LOS);
|
Serial.print(si5351.dev_status.LOS);
|
||||||
Serial.print(" REVID: ");
|
Serial.print(" REVID: ");
|
||||||
Serial.println(si5351.dev_status.REVID);
|
Serial.println(si5351.dev_status.REVID);
|
||||||
|
*/
|
||||||
|
|
||||||
delay(10000);
|
if (Serial.available() > 0)
|
||||||
|
{
|
||||||
|
uint8_t c = Serial.read() & 0xff;
|
||||||
|
cc_processData(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delay(100);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,3 +12,47 @@
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
#define CC_STATE_READ_SOM1 20
|
||||||
|
#define CC_STATE_READ_SOM2 30
|
||||||
|
#define CC_STATE_READ_CMD 40
|
||||||
|
#define CC_STATE_READ_DATA 50
|
||||||
|
#define CC_STATE_READ_EOM1 60
|
||||||
|
#define CC_STATE_READ_EOM2 70
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
#define CC_CMD_NO_CMD 0
|
||||||
|
|
||||||
|
#define MSG_INCOMPLETE 10
|
||||||
|
#define MSG_COMPLETE 20
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
#define CC_CMD_SET_START_FREQ 0x01
|
||||||
|
#define CC_CMD_SET_END_FREQ 0x02
|
||||||
|
#define CC_CMD_SET_INTERVALL 0x03
|
||||||
|
#define CC_CMD_SET_DRIVE_STRENGTH 0x04
|
||||||
|
#define CC_CMD_START_MEASUREMENT 0x05
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
#define CC_CMD_SET_START_FREQ_FUNC &cc_setStartFreq
|
||||||
|
#define CC_CMD_SET_END_FREQ_FUNC &cc_setEndFreq
|
||||||
|
#define CC_CMD_SET_INTERVALL_FUNC &cc_setIntervall
|
||||||
|
#define CC_CMD_SET_DRIVE_STRENGTH_FUNC &cc_setDriveStrength
|
||||||
|
#define CC_CMD_START_MEASUREMENT_FUNC &cc_startMeasurement
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
#define CC_CMD_SET_START_FREQ_DATA_TO_READ 4 // up to 32 bit = 4 byte => 2 ** 32 = >500000000Hz
|
||||||
|
#define CC_CMD_SET_END_FREQ_DATA_TO_READ 4 // up to 32 bit = 4 byte => 2 ** 32 = >500000000Hz
|
||||||
|
#define CC_CMD_SET_INTERVALL_DATA_TO_READ 3 // up to 24 bit = 3 byte => 2 ** 24 = >1000000Hz
|
||||||
|
#define CC_CMD_SET_DRIVE_STRENGTH_DATA_TO_READ 1
|
||||||
|
#define CC_CMD_START_MEASUREMENT_DATA_TO_READ 0
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
#define CC_READ_DATA_MAX 64
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue