Skip to content

Commit

Permalink
#19
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Mar 10, 2021
1 parent 77205c5 commit 96bd802
Show file tree
Hide file tree
Showing 15 changed files with 410 additions and 63 deletions.
69 changes: 69 additions & 0 deletions modular-psu-firmware.eez-project
Original file line number Diff line number Diff line change
Expand Up @@ -69644,6 +69644,59 @@
]
}
},
{
"name": "SYSTem:COMMunicate:UART:RECeive?",
"helpLink": "EEZ BB3 SCPI reference 5.17 - SYSTem.html#syst_comm_usb_mode",
"parameters": [],
"response": {
"type": [
{
"type": "nr3"
},
{
"type": "quoted-string"
}
]
}
},
{
"name": "SYSTem:COMMunicate:UART:MODE",
"helpLink": "EEZ BB3 SCPI reference 5.17 - SYSTem.html#syst_comm_usb_mode",
"parameters": [
{
"name": "mode",
"type": [
{
"type": "discrete",
"enumeration": "UartMode"
}
]
}
],
"response": {
"type": [
{
"type": "nr3"
},
{
"type": "quoted-string"
}
]
}
},
{
"name": "SYSTem:COMMunicate:UART:MODE?",
"helpLink": "EEZ BB3 SCPI reference 5.17 - SYSTem.html#syst_comm_usb_mode",
"parameters": [],
"response": {
"type": [
{
"type": "discrete",
"enumeration": "UartMode"
}
]
}
},
{
"name": "SYSTem:CPU:FIRMware?",
"helpLink": "EEZ BB3 SCPI reference 5.17 - SYSTem.html#syst_cpu_firm",
Expand Down Expand Up @@ -72861,6 +72914,9 @@
{
"name": "TOUT",
"value": ""
},
{
"name": "UART"
}
]
},
Expand Down Expand Up @@ -73064,6 +73120,19 @@
"value": "3"
}
]
},
{
"name": "UartMode",
"members": [
{
"name": "PASS",
"value": "0"
},
{
"name": "SCPI",
"value": "1"
}
]
}
]
},
Expand Down
3 changes: 0 additions & 3 deletions src/eez/modules/bp3c/flash_slave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ void uploadHexFile() {
for (int ntry = 1; !eraseAll(g_slotIndex); ntry++) {
DebugTrace("Failed to erase all!\n");
if (ntry == 5) {
//goto Exit;
break;
}
osDelay(10);
Expand All @@ -220,8 +219,6 @@ void uploadHexFile() {
totalSize = file.size();
#endif

//eofReached = true;

while (!eofReached && readHexRecord(bufferedFile, hexRecord)) {
size_t currentPosition = file.tell();

Expand Down
4 changes: 4 additions & 0 deletions src/eez/modules/psu/persist_conf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1314,6 +1314,10 @@ void clearMcuRevision() {
g_devConf.mcuRevision = 0;
}

void setUartMode(uint8_t uartMode) {
g_devConf.uartMode = uartMode;
}

////////////////////////////////////////////////////////////////////////////////

ModuleConfiguration g_moduleConf[NUM_SLOTS];
Expand Down
4 changes: 3 additions & 1 deletion src/eez/modules/psu/persist_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ struct DeviceConfiguration {

// block 4
uint8_t startOfBlock4; // was serialBaud
uint8_t reserved3; // was serialParity
uint8_t uartMode;

uint32_t ethernetIpAddress;
uint32_t ethernetDns;
Expand Down Expand Up @@ -354,6 +354,8 @@ void setPowerLineFrequency(int powerLineFrequency);
void setMcuRevision(int mcuRevision);
void clearMcuRevision();

void setUartMode(uint8_t uartMode);

////////////////////////////////////////////////////////////////////////////////

struct ModuleConfiguration {
Expand Down
40 changes: 39 additions & 1 deletion src/eez/modules/psu/scpi/syst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2385,11 +2385,49 @@ scpi_result_t scpi_cmd_systemCommunicateUartTransmit(scpi_t *context) {
}

uart::transmit((uint8_t *)uartStr, (uint16_t)uartStrLen, 100);
uart::transmit((uint8_t *)"\r\n", 2, 100);
uart::transmit((uint8_t *)"\n", 1, 100);

return SCPI_RES_OK;
}

scpi_result_t scpi_cmd_systemCommunicateUartReceiveQ(scpi_t *context) {
char text[100];
uint16_t n;
int err;
if (!uart::receiveFromBuffer((uint8_t *)text, sizeof(text) - 1, n, &err)) {
SCPI_ErrorPush(context, err);
return SCPI_RES_ERR;
}

text[n] = 0;

SCPI_ResultText(context, text);
return SCPI_RES_OK;
}

static scpi_choice_def_t g_uartModeChoice[] = {
{ "BUFFer", uart::UART_MODE_BUFFER },
{ "SCPI", uart::UART_MODE_SCPI },
SCPI_CHOICE_LIST_END
};

scpi_result_t scpi_cmd_systemCommunicateUartMode(scpi_t *context) {
int32_t uartMode;
if (!SCPI_ParamChoice(context, g_uartModeChoice, &uartMode, true)) {
return SCPI_RES_ERR;
}

persist_conf::setUartMode((uint8_t)uartMode);
uart::resetInputBuffer();

return SCPI_RES_OK;
}

scpi_result_t scpi_cmd_systemCommunicateUartModeQ(scpi_t *context) {
resultChoiceName(context, g_uartModeChoice, persist_conf::devConf.uartMode);
return SCPI_RES_OK;
}

} // namespace scpi
} // namespace psu
} // namespace eez
3 changes: 3 additions & 0 deletions src/eez/scpi/commands_simulator.h
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,9 @@
SCPI_COMMAND("SYSTem:COMMunicate:USB:MODE", scpi_cmd_systemCommunicateUsbMode) \
SCPI_COMMAND("SYSTem:COMMunicate:USB:MODE?", scpi_cmd_systemCommunicateUsbModeQ) \
SCPI_COMMAND("SYSTem:COMMunicate:UART:TRANsmit", scpi_cmd_systemCommunicateUartTransmit) \
SCPI_COMMAND("SYSTem:COMMunicate:UART:RECeive?", scpi_cmd_systemCommunicateUartReceiveQ) \
SCPI_COMMAND("SYSTem:COMMunicate:UART:MODE", scpi_cmd_systemCommunicateUartMode) \
SCPI_COMMAND("SYSTem:COMMunicate:UART:MODE?", scpi_cmd_systemCommunicateUartModeQ) \
SCPI_COMMAND("SYSTem:CPU:FIRMware?", scpi_cmd_systemCpuFirmwareQ) \
SCPI_COMMAND("SYSTem:CPU:INFOrmation:ONTime:LAST?", scpi_cmd_systemCpuInformationOntimeLastQ) \
SCPI_COMMAND("SYSTem:CPU:INFOrmation:ONTime:TOTal?", scpi_cmd_systemCpuInformationOntimeTotalQ) \
Expand Down
3 changes: 3 additions & 0 deletions src/eez/scpi/commands_stm32.h
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,9 @@
SCPI_COMMAND("SYSTem:COMMunicate:USB:MODE", scpi_cmd_systemCommunicateUsbMode) \
SCPI_COMMAND("SYSTem:COMMunicate:USB:MODE?", scpi_cmd_systemCommunicateUsbModeQ) \
SCPI_COMMAND("SYSTem:COMMunicate:UART:TRANsmit", scpi_cmd_systemCommunicateUartTransmit) \
SCPI_COMMAND("SYSTem:COMMunicate:UART:RECeive?", scpi_cmd_systemCommunicateUartReceiveQ) \
SCPI_COMMAND("SYSTem:COMMunicate:UART:MODE", scpi_cmd_systemCommunicateUartMode) \
SCPI_COMMAND("SYSTem:COMMunicate:UART:MODE?", scpi_cmd_systemCommunicateUartModeQ) \
SCPI_COMMAND("SYSTem:CPU:FIRMware?", scpi_cmd_systemCpuFirmwareQ) \
SCPI_COMMAND("SYSTem:CPU:INFOrmation:ONTime:LAST?", scpi_cmd_systemCpuInformationOntimeLastQ) \
SCPI_COMMAND("SYSTem:CPU:INFOrmation:ONTime:TOTal?", scpi_cmd_systemCpuInformationOntimeTotalQ) \
Expand Down
Loading

0 comments on commit 96bd802

Please sign in to comment.