Skip to content

Commit

Permalink
#19
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Jun 9, 2021
1 parent 45007de commit 183a748
Show file tree
Hide file tree
Showing 11 changed files with 227 additions and 51 deletions.
44 changes: 44 additions & 0 deletions docs/examples/arduino-mega-uart-dlog/arduino-mega-uart-dlog.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
void setup() {
// setup serial
Serial1.begin(115200, SERIAL_8E2);

// setup LED
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW);

// wait 1sec
delay(1000);

// init dlog
Serial1.print("SENSe:DLOG:PERiod 0.001\n");
Serial1.print("SENSe:DLOG:TIME 60\n");
Serial1.print("SENS:DLOG:FUNC:VOLT ON, CH1\n");
Serial1.print("SENS:DLOG:FUNC:CURR ON, CH1\n");
Serial1.print("INITiate:DLOG '/Recordings/arduino-mega-uart-dlog.dlog'\n");

// wait 1 sec
delay(1000);

// add "start blink" bookmark
Serial1.print("SENS:DLOG:TRAC:BOOK 'start blink'\n");

// blink 5 times
for (int i = 0; i < 5; i++) {
digitalWrite(LED_BUILTIN, HIGH);
delay(500);
digitalWrite(LED_BUILTIN, LOW);
delay(500);
}

// add "stop blink" bookmark
Serial1.print("SENS:DLOG:TRAC:BOOK 'stop blink'\n");

// wait 1 sec
delay(1000);

// abort dlog
Serial1.print("ABORT:DLOG\n");
}

void loop() {
}
3 changes: 3 additions & 0 deletions src/eez/firmware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <eez/mp.h>
#include <eez/sound.h>
#include <eez/memory.h>
#include <eez/uart.h>
#include <eez/usb.h>
#include <eez/modules/aux_ps/fan.h>

Expand Down Expand Up @@ -501,6 +502,8 @@ void shutdown() {
ethernet::update();
#endif

uart::disable();

#if !defined(__EMSCRIPTEN__)
// shutdown SCPI thread
using namespace eez::scpi;
Expand Down
8 changes: 4 additions & 4 deletions src/eez/modules/dib-smx46/dib-smx46.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ static const uint32_t MIN_TO_MS = 60L * 1000L;

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

static const int NUM_REQUEST_RETRIES = 10;
static const int MAX_DMA_TRANSFER_ERRORS = 10;
static const int NUM_REQUEST_RETRIES = 25;
static const int MAX_DMA_TRANSFER_ERRORS = 25;
static const uint32_t REFRESH_TIME_MS = 250;
static const uint32_t TIMEOUT_TIME_MS = 350;
static const uint32_t TIMEOUT_UNTIL_OUT_OF_SYNC_MS = 1000;
static const uint32_t TIMEOUT_TIME_MS = 500;
static const uint32_t TIMEOUT_UNTIL_OUT_OF_SYNC_MS = 3000;

enum Command {
COMMAND_NONE = 0x113B3759,
Expand Down
11 changes: 8 additions & 3 deletions src/eez/modules/psu/io_pins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,10 +398,13 @@ void onTrigger() {
}

void refresh() {
// refresh output pins
if (g_ioPins[0].function != FUNCTION_UART) {
uart::refresh();
}

for (int pin = 0; pin < NUM_IO_PINS; ++pin) {
if (pin < 2) {
initInputPin(pin);
initInputPin(pin);
} else {
initOutputPin(pin);

Expand All @@ -422,7 +425,9 @@ void refresh() {
}
}

uart::refresh();
if (g_ioPins[0].function == FUNCTION_UART) {
uart::refresh();
}
}

bool getIsInhibitedByUser() {
Expand Down
5 changes: 0 additions & 5 deletions src/eez/modules/psu/psu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1225,11 +1225,6 @@ bool powerUp() {
// turn on Power On (PON) bit of ESE register
reg_set_esr_bits(ESR_PON);

#if defined(EEZ_PLATFORM_STM32)
HAL_NVIC_EnableIRQ(EXTI9_5_IRQn);
HAL_NVIC_EnableIRQ(EXTI15_10_IRQn);
#endif

InfoTrace("Power up (v%s)\n", MCU_FIRMWARE);

// play power up tune on success
Expand Down
21 changes: 16 additions & 5 deletions src/eez/modules/psu/scpi/syst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2386,17 +2386,28 @@ scpi_result_t scpi_cmd_systemCommunicateUartTransmit(scpi_t *context) {
return SCPI_RES_ERR;
}

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

int err;

if (!uart::transmit((uint8_t *)uartStr, (uint16_t)uartStrLen, 100, &err)) {
SCPI_ErrorPush(context, err);
return SCPI_RES_ERR;
}

if (!uart::transmit((uint8_t *)"\n", 1, 100, &err)) {
SCPI_ErrorPush(context, err);
return SCPI_RES_ERR;
}

return SCPI_RES_OK;
}

scpi_result_t scpi_cmd_systemCommunicateUartReceiveQ(scpi_t *context) {
char text[100];
char text[uart::CONF_UART_INPUT_BUFFER_SIZE + 1];
uint16_t n;
int err;
if (!uart::receiveFromBuffer((uint8_t *)text, sizeof(text) - 1, n, &err)) {
if (!uart::receive((uint8_t *)text, sizeof(text) - 1, n, &err)) {
SCPI_ErrorPush(context, err);
return SCPI_RES_ERR;
}
Expand All @@ -2421,7 +2432,7 @@ scpi_result_t scpi_cmd_systemCommunicateUartMode(scpi_t *context) {
}

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

return SCPI_RES_OK;
}
Expand Down
Loading

0 comments on commit 183a748

Please sign in to comment.