Skip to content

Commit

Permalink
Merge pull request #140 from kipr/js-yield-b4-reg-write
Browse files Browse the repository at this point in the history
[JS] Catch up on pending register values before writing registers
  • Loading branch information
tcorbly authored Jul 3, 2021
2 parents 1b2502c + 44aebcd commit f31187a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/wallaby_p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ void Wallaby::writeRegister8b(unsigned char address, unsigned char value)
std::lock_guard<std::mutex> lock(transfer_mutex_);

#ifdef TARGET_EMSCRIPTEN
emscripten_sleep(0);
unsigned char addresses[] = {address};
unsigned char values[] = {value};
updateRegisters(addresses, values, 1);
Expand Down Expand Up @@ -298,6 +299,7 @@ void Wallaby::writeRegister16b(unsigned char address, unsigned short value)
std::lock_guard<std::mutex> lock(transfer_mutex_);

#ifdef TARGET_EMSCRIPTEN
emscripten_sleep(0);
unsigned char addresses[] = {address, static_cast<unsigned char>(address + 1)};
unsigned char values[] = {value1, value2};
updateRegisters(addresses, values, 2);
Expand Down Expand Up @@ -363,6 +365,7 @@ void Wallaby::writeRegister32b(unsigned char address, unsigned int value)
std::lock_guard<std::mutex> lock(transfer_mutex_);

#ifdef TARGET_EMSCRIPTEN
emscripten_sleep(0);
unsigned char addresses[] = {address, static_cast<unsigned char>(address + 1), static_cast<unsigned char>(address + 2), static_cast<unsigned char>(address + 3)};
unsigned char values[] = {value1, value2, value3, value4};
updateRegisters(addresses, values, 4);
Expand Down

0 comments on commit f31187a

Please sign in to comment.