Commit 2e924d75 authored by Peter Zumbruch's avatar Peter Zumbruch
Browse files

moved Apfel Api functionality from apfel to apiApfel

parent 9e698e31
......@@ -616,38 +616,10 @@ apiCommandResult apfelTriggerCommand(uint8_t nSubCommandsArguments)
}
void apfel_Inline()
{
apfelInit_Inline();
static const apfelAddress address={.port='A',.pinSetIndex=1,.sideSelection=0};
if (apfelOscilloscopeTestFrameMode)
{
apfelWritePort((1 << APFEL_PIN_DOUT1 | 1 << APFEL_PIN_CLK1), (apfelAddress*) &address);
apfelWritePort((1 << APFEL_PIN_DOUT1 | 0 << APFEL_PIN_CLK1), (apfelAddress*) &address);
apfelWritePort((1 << APFEL_PIN_DOUT1 | 1 << APFEL_PIN_CLK1), (apfelAddress*) &address);
apfelWritePort((0 << APFEL_PIN_DOUT1 | 0 << APFEL_PIN_CLK1), (apfelAddress*) &address);
}
apfelApi_Inline();
//apfelApi_Inline_p();
if (apfelOscilloscopeTestFrameMode)
{
apfelWritePort((1 << APFEL_PIN_DOUT1 | 1 << APFEL_PIN_CLK1), (apfelAddress*) &address);
apfelWritePort((1 << APFEL_PIN_DOUT1 | 0 << APFEL_PIN_CLK1), (apfelAddress*) &address);
apfelWritePort((1 << APFEL_PIN_DOUT1 | 1 << APFEL_PIN_CLK1), (apfelAddress*) &address);
apfelWritePort((1 << APFEL_PIN_DOUT1 | 0 << APFEL_PIN_CLK1), (apfelAddress*) &address);
apfelWritePort((1 << APFEL_PIN_DOUT1 | 1 << APFEL_PIN_CLK1), (apfelAddress*) &address);
apfelWritePort((0 << APFEL_PIN_DOUT1 | 0 << APFEL_PIN_CLK1), (apfelAddress*) &address);
}
}
uint16_t apfelPortAddressSetMask = 0;
#if 0
apfelPortAddressSet apfelPortAddressSets[APFEL_MAX_N_PORT_ADDRESS_SETS];
uint16_t apfelPortAddressSetMask = 0;
#endif
//----------------
......
......@@ -53,7 +53,6 @@ void apfelWriteClockSequence_Inline(apfelAddress *address, uint16_t nClk);
int8_t apfelWritePort(uint8_t val, apfelAddress *address);
void apfelEnable(bool enable);
void apfel_Inline(void);
apiCommandResult apfelTriggerCommand(uint8_t nSubCommandsArguments);
......
......@@ -40,40 +40,25 @@ static const char const string_bracket_7_bracket[] PROGMEM = "[7]";
//static char byte[3]= "00";
static const char apfelApiCommandKeyword00[] PROGMEM = "dac";
static const char apfelApiCommandKeyword01[] PROGMEM = "d";
static const char apfelApiCommandKeyword02[] PROGMEM = "testpulse";
static const char apfelApiCommandKeyword03[] PROGMEM = "t";
static const char apfelApiCommandKeyword04[] PROGMEM = "autocalib";
static const char apfelApiCommandKeyword05[] PROGMEM = "a";
static const char apfelApiCommandKeyword06[] PROGMEM = "ampl";
static const char apfelApiCommandKeyword07[] PROGMEM = "list";
static const char apfelApiCommandKeyword08[] PROGMEM = "l";
static const char apfelApiCommandKeyword09[] PROGMEM = "status";
static const char apfelApiCommandKeyword10[] PROGMEM = "s";
static const char apfelApiCommandKeyword11[] PROGMEM = "portAddressSetEnableMask";
static const char apfelApiCommandKeyword12[] PROGMEM = "pasem";
static const char apfelApiCommandKeyword13[] PROGMEM = "enablePortAddressSet";
static const char apfelApiCommandKeyword14[] PROGMEM = "epas";
static const char apfelApiCommandKeyword15[] PROGMEM = "disablePortAddressSet";
static const char apfelApiCommandKeyword16[] PROGMEM = "dpas";
static const char apfelApiCommandKeyword17[] PROGMEM = "addPortAddressSet";
static const char apfelApiCommandKeyword18[] PROGMEM = "apas";
static const char apfelApiCommandKeyword19[] PROGMEM = "removePortAddressSet";
static const char apfelApiCommandKeyword20[] PROGMEM = "rpas";
static const char apfelApiCommandKeyword21[] PROGMEM = "apfel_enable";
static const char apfelApiCommandKeyword22[] PROGMEM = "reset";
static const char apfelApiCommandKeyword01[] PROGMEM = "testpulse";
static const char apfelApiCommandKeyword02[] PROGMEM = "autocalib";
static const char apfelApiCommandKeyword03[] PROGMEM = "ampl";
static const char apfelApiCommandKeyword04[] PROGMEM = "list";
static const char apfelApiCommandKeyword05[] PROGMEM = "l";
static const char apfelApiCommandKeyword06[] PROGMEM = "status";
static const char apfelApiCommandKeyword07[] PROGMEM = "s";
static const char apfelApiCommandKeyword08[] PROGMEM = "apfel_enable";
static const char apfelApiCommandKeyword09[] PROGMEM = "reset";
const char* const apfelApiCommandKeywords[] PROGMEM = {
apfelApiCommandKeyword00, apfelApiCommandKeyword01, apfelApiCommandKeyword02, apfelApiCommandKeyword03, apfelApiCommandKeyword04,
apfelApiCommandKeyword05, apfelApiCommandKeyword06, apfelApiCommandKeyword07, apfelApiCommandKeyword08, apfelApiCommandKeyword09,
apfelApiCommandKeyword10, apfelApiCommandKeyword11, apfelApiCommandKeyword12, apfelApiCommandKeyword13, apfelApiCommandKeyword14,
apfelApiCommandKeyword15, apfelApiCommandKeyword16, apfelApiCommandKeyword17, apfelApiCommandKeyword18, apfelApiCommandKeyword19,
apfelApiCommandKeyword20, apfelApiCommandKeyword21, apfelApiCommandKeyword22
apfelApiCommandKeyword05, apfelApiCommandKeyword06, apfelApiCommandKeyword07, apfelApiCommandKeyword08, apfelApiCommandKeyword09
};
apfelApiConfig apfelApiConfiguration;
bool apfelApiInitialized = false;
bool apfelInitialized = false;
apfelApiConfig *ptr_apfelApiConfiguration = &apfelApiConfiguration;
extern bool apfelOscilloscopeTestFrameMode;
void apfelApiInit(void)
{
......@@ -83,7 +68,7 @@ void apfelApiInit(void)
}
void apfelApi_Inline(void)
void apfelApiVersion0(void)
{
uint32_t arg[8] =
{ -1, -1, -1, -1, -1, -1, -1, -1 };
......@@ -479,21 +464,53 @@ apiCommandResult apfelApiParseAddress(apfelAddress *address, uint8_t portArgumen
void apfelApi(struct uartStruct *ptr_uartStruct)
{
apfel_Inline();
return;
#if 0 //TODO
if (!apfelApiInitialized )
if (!apfelInitialized )
{
#warning apiInit to be implemented
// apfelApiInit();
apfelApiInitialized = true;
apfelInit_Inline();
apfelInitialized = true;
}
if (0 < ptr_uartStruct->number_of_arguments && isNumericArgument(setParameter[1],4))
{
if (! apfelOscilloscopeTestFrameMode)
{
apfelApiVersion0();
}
else
{
static const apfelAddress address={.port='A',.pinSetIndex=1,.sideSelection=0};
apfelWritePort((1 << APFEL_PIN_DOUT1 | 1 << APFEL_PIN_CLK1), (apfelAddress*) &address);
apfelWritePort((1 << APFEL_PIN_DOUT1 | 0 << APFEL_PIN_CLK1), (apfelAddress*) &address);
apfelWritePort((1 << APFEL_PIN_DOUT1 | 1 << APFEL_PIN_CLK1), (apfelAddress*) &address);
apfelWritePort((0 << APFEL_PIN_DOUT1 | 0 << APFEL_PIN_CLK1), (apfelAddress*) &address);
apfelApiVersion0();
apfelWritePort((1 << APFEL_PIN_DOUT1 | 1 << APFEL_PIN_CLK1), (apfelAddress*) &address);
apfelWritePort((1 << APFEL_PIN_DOUT1 | 0 << APFEL_PIN_CLK1), (apfelAddress*) &address);
apfelWritePort((1 << APFEL_PIN_DOUT1 | 1 << APFEL_PIN_CLK1), (apfelAddress*) &address);
apfelWritePort((1 << APFEL_PIN_DOUT1 | 0 << APFEL_PIN_CLK1), (apfelAddress*) &address);
apfelWritePort((1 << APFEL_PIN_DOUT1 | 1 << APFEL_PIN_CLK1), (apfelAddress*) &address);
apfelWritePort((0 << APFEL_PIN_DOUT1 | 0 << APFEL_PIN_CLK1), (apfelAddress*) &address);
}
}
else
{
#warning move to api and generalize it to be used via fcn pointer also by sub commands
apiCallCommands(1, ptr_uartStruct, apfelApiCommandKeywords, apfelApiCommandKeyNumber_MAXIMUM_NUMBER,
apfelApiSubCommands, apfelApiCommandKeyNumber_STATUS);
}
return;
}
void apiCallCommands(uint8_t parameterIndex, struct uartStruct *ptr_uartStruct, PGM_P const keywords[],
size_t keywordMaximumIndex, apiCommandResult (*apiCommands)(struct uartStruct*, int16_t, uint8_t), uint8_t defaultCommandIndex )
{
switch(ptr_uartStruct->number_of_arguments)
{
case 0:
// apfelApiSubCommands(ptr_uartStruct, apfelApiCommandKeyNumber_STATUS, 1);
apfelApiSubCommands(ptr_uartStruct, defaultCommandIndex, parameterIndex);
break;
default:
{
......@@ -501,10 +518,10 @@ void apfelApi(struct uartStruct *ptr_uartStruct)
{
int subCommandIndex = -1;
// find matching command keyword
subCommandIndex = apiFindCommandKeywordIndex(setParameter[1], apfelApiCommandKeywords, apfelApiCommandKeyNumber_MAXIMUM_NUMBER);
subCommandIndex = apiFindCommandKeywordIndex(setParameter[parameterIndex], keywords, keywordMaximumIndex);
if ( 0 <= subCommandIndex )
{
apfelApiSubCommands(ptr_uartStruct, subCommandIndex, 2);
(*apiCommands)(ptr_uartStruct, subCommandIndex, parameterIndex+1);
}
else
{
......@@ -518,11 +535,35 @@ void apfelApi(struct uartStruct *ptr_uartStruct)
break;
}
}
return;
#endif
// switch(ptr_uartStruct->number_of_arguments)
// {
// case 0:
// apfelApiSubCommands(ptr_uartStruct, apfelApiCommandKeyNumber_STATUS, 1);
// break;
// default:
// {
// if (ptr_uartStruct->number_of_arguments > 0)
// {
// int subCommandIndex = -1;
// // find matching command keyword
// subCommandIndex = apiFindCommandKeywordIndex(setParameter[1], apfelApiCommandKeywords, apfelApiCommandKeyNumber_MAXIMUM_NUMBER);
// if ( 0 <= subCommandIndex )
// {
// apfelApiSubCommands(ptr_uartStruct, subCommandIndex, 2);
// }
// else
// {
// CommunicationError_p(ERRA, SERIAL_ERROR_no_valid_command_name, true, NULL);
// }
// }
// else
// {
// CommunicationError_p(ERRG, GENERAL_ERROR_invalid_argument, true, NULL);
// }
// break;
// }
}
/*
* void apfelApiSubCommands(struct uartStruct *ptr_uartStruct, int16_t subCommandIndex)
*
......
......@@ -20,26 +20,13 @@ extern const char* const apfelApiCommandKeywords[] PROGMEM;
enum apfelApiCommandKeyNumber
{
apfelApiCommandKeyNumber_DAC = 0,
apfelApiCommandKeyNumber_D ,
apfelApiCommandKeyNumber_TESTPULSE ,
apfelApiCommandKeyNumber_T ,
apfelApiCommandKeyNumber_AUTOCALIB ,
apfelApiCommandKeyNumber_A ,
apfelApiCommandKeyNumber_AMPL ,
apfelApiCommandKeyNumber_LIST ,
apfelApiCommandKeyNumber_L ,
apfelApiCommandKeyNumber_STATUS ,
apfelApiCommandKeyNumber_S ,
apfelApiCommandKeyNumber_PORT_ADDRESS_SET_ENABLE_MASK,
apfelApiCommandKeyNumber_PASEM,
apfelApiCommandKeyNumber_ENABLE_PORT_ADDRESS_SET,
apfelApiCommandKeyNumber_EPAS,
apfelApiCommandKeyNumber_DISABLE_PORT_ADDRESS_SET,
apfelApiCommandKeyNumber_DPAS,
apfelApiCommandKeyNumber_ADD_PORT_ADDRESS_SET,
apfelApiCommandKeyNumber_APAS,
apfelApiCommandKeyNumber_REMOVE_PORT_ADDRESS_SET,
apfelApiCommandKeyNumber_RPAS,
apfelApiCommandKeyNumber_APFEL_ENABLE ,
apfelApiCommandKeyNumber_RESET ,
apfelApiCommandKeyNumber_MAXIMUM_NUMBER
......@@ -70,6 +57,8 @@ enum apfelApiCommandKeyNumber_Inline
apfelApiCommandKeyNumber_Trigger = APFEL_COMMAND_KEY_Trigger
};
void apiCallCommands(uint8_t parameterIndex, struct uartStruct *ptr_uartStruct, PGM_P const keywords[],
size_t keywordMaximumIndex, uint8_t (*apiCommands)(struct uartStruct*, int16_t, uint8_t), uint8_t defaultCommandIndex );
typedef struct apfelApiConfig
{
......@@ -80,7 +69,7 @@ typedef struct apfelApiConfig
extern apfelApiConfig apfelApiConfiguration;
extern apfelApiConfig* ptr_apfelApiConfiguration;
void apfelApi_Inline(void);
void apfelApiVersion0(void);
apiCommandResult apfelApiParseAddress(apfelAddress *address, uint8_t portArgumentIndex, uint8_t pinSetIndexArgumentIndex, uint8_t sideSelectionArgumentIndex, uint8_t chipIdArgumentIndex );
void apfelApi(struct uartStruct *ptr_uartStruct);
......@@ -96,13 +85,7 @@ apiCommandResult apfelApiSubCommandTestPulse (void);
apiCommandResult apfelApiSubCommandAutoCalib (void);
apiCommandResult apfelApiSubCommandAmplification (void);
apiCommandResult apfelApiSubCommandListIds (void);
apiCommandResult apfelApiSubCommandChipIdIgnoreMask (void);
apiCommandResult apfelApiSubCommandAddPortAddressSet (void);
apiCommandResult apfelApiSubCommandRemovePortAddressSet (void);
apiCommandResult apfelApiSubCommandApfelEnable (void);
apiCommandResult apfelApiSubCommandReset (void);
apiCommandResult apfelApiSubCommandPortAddressSetEnableMask(void);
apiCommandResult apfelApiSubCommandEnablePortAddressSet (void);
apiCommandResult apfelApiSubCommandDisablePortAddressSet (void);
#endif /* APFELAPI_H_ */
......@@ -8,6 +8,7 @@
* modified: Florian Feldbauer
* modified: Peter Zumbruch, Oct 2011
* modified: Peter Zumbruch, May 2013
* modified: Peter Zumbruch, Mar 2015
*/
#include <stdint.h>
......@@ -458,11 +459,11 @@ static const char commandShortDescription50[] PROGMEM = "returns device IDN";
static const uint8_t commandImplementation50 PROGMEM = TRUE;
// index: 51
static const char commandKeyword51[] PROGMEM = "APWI"; /* command (dummy name) */
static const char commandSyntax51[] PROGMEM = "<command> <portID> <posID> <chipID> [<Arguments>]";
static const char commandKeyword51[] PROGMEM = "CMD7"; /* command (dummy name) */
static const char commandSyntax51[] PROGMEM = "[???]";
static const char commandSyntaxAlternative51[] PROGMEM = "";
static const char commandShortDescription51[] PROGMEM = "APFEL ASIC command set";
static const uint8_t commandImplementation51 PROGMEM = TRUE;
static const char commandShortDescription51[] PROGMEM = "";
static const uint8_t commandImplementation51 PROGMEM = FALSE;
// index: 52
static const char commandKeyword52[] PROGMEM = "APFEL"; /* command (dummy name) */
......@@ -789,7 +790,6 @@ void Process_Uart_Event(void)
case commandKeyNumber_I2C:
case commandKeyNumber_DEBG:
case commandKeyNumber_SPI:
case commandKeyNumber_DAC:
case commandKeyNumber_APFEL:
Choose_Function(ptr_uartStruct);
break;
......@@ -1433,7 +1433,7 @@ void Choose_Function( struct uartStruct *ptr_uartStruct )
case commandKeyNumber_SPI: /* command (dummy name) */
spiApi(ptr_uartStruct);
break;
case commandKeyNumber_DAC: /* command (dummy name) */
case commandKeyNumber_CMD7: /* command (dummy name) */
break;
case commandKeyNumber_APFEL: /* command (dummy name) */
apfelApi(ptr_uartStruct);
......
......@@ -234,7 +234,7 @@ enum cmdKeyNumber
commandKeyNumber_WDOG,
commandKeyNumber_VERS,
commandKeyNumber_IDN,
commandKeyNumber_DAC,
commandKeyNumber_CMD7,
commandKeyNumber_APFEL,
commandKeyNumber_CMD8,
commandKeyNumber_MAXIMUM_NUMBER
......
......@@ -484,7 +484,7 @@ void help(struct uartStruct *ptr_uartStruct)
/* response */
helpShowCommandOrResponse_p (currentReceiveHeader, NULL, string_3questions);
break;
case commandKeyNumber_DAC:
case commandKeyNumber_CMD7:
break;
case commandKeyNumber_APFEL:
/* command */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment