rainbow: update & bugfix
- renamed getGpio4 to getDataReadyIO - removed setGpio4 - fixed mapper thread issue (crash when reloading the ROM)
This commit is contained in:
parent
123b4d06c4
commit
68cdbf1d4a
|
@ -15,8 +15,7 @@ public:
|
|||
virtual uint8 tx() = 0;
|
||||
|
||||
// General purpose I/O pins
|
||||
virtual void setGpio4(bool v) = 0;
|
||||
virtual bool getGpio4() = 0;
|
||||
virtual bool getDataReadyIO() = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -131,6 +131,7 @@ static SFORMAT SStateRegs[] =
|
|||
// ESP interface
|
||||
|
||||
static EspFirmware *esp = NULL;
|
||||
static bool esp_running;
|
||||
static bool esp_enable;
|
||||
static bool esp_irq_enable;
|
||||
static bool esp_message_received;
|
||||
|
@ -153,10 +154,10 @@ static void Rainbow13EspMapIrq(int32) {
|
|||
|
||||
// Mapper
|
||||
|
||||
void esp_check_new_message(void) {
|
||||
while (esp != NULL) {
|
||||
void esp_check_new_message() {
|
||||
while (esp_running) {
|
||||
// get new message if needed
|
||||
if (esp_enable && esp->getGpio4() && !esp_message_received)
|
||||
if (esp_enable && esp->getDataReadyIO() && esp_message_received == false)
|
||||
{
|
||||
uint8 message_length = esp->tx();
|
||||
FPGA_WRAM[rx_address << 8] = message_length;
|
||||
|
@ -391,7 +392,7 @@ static DECLFR(Rainbow13Read) {
|
|||
case 0x4101:
|
||||
{
|
||||
uint8 message_received = esp_message_received ? 1 << 7 : 0;
|
||||
uint8 esp_rts_flag = esp->getGpio4() ? 0x40 : 0x00;
|
||||
uint8 esp_rts_flag = esp->getDataReadyIO() ? 0x40 : 0x00;
|
||||
return message_received | esp_rts_flag;
|
||||
}
|
||||
case 0x4102:
|
||||
|
@ -903,6 +904,7 @@ static void Rainbow13Power(void) {
|
|||
esp_enable = false;
|
||||
esp_irq_enable = false;
|
||||
esp_message_received = false;
|
||||
esp_running = true;
|
||||
esp_RX = std::thread (esp_check_new_message);
|
||||
}
|
||||
|
||||
|
@ -945,7 +947,8 @@ static void Rainbow13Close(void)
|
|||
if (esp)
|
||||
{
|
||||
esp_enable = false;
|
||||
esp_RX.detach();
|
||||
esp_running = false;
|
||||
esp_RX.join();
|
||||
delete esp;
|
||||
esp = NULL;
|
||||
}
|
||||
|
|
|
@ -211,10 +211,7 @@ uint8 BrokeStudioFirmware::tx() {
|
|||
return last_byte_read;
|
||||
}
|
||||
|
||||
void BrokeStudioFirmware::setGpio4(bool /*v*/) {
|
||||
}
|
||||
|
||||
bool BrokeStudioFirmware::getGpio4() {
|
||||
bool BrokeStudioFirmware::getDataReadyIO() {
|
||||
this->receiveDataFromServer();
|
||||
this->receivePingResult();
|
||||
return !(this->tx_buffer.empty() && this->tx_messages.empty());
|
||||
|
@ -1928,7 +1925,7 @@ std::pair<uint8, uint8> BrokeStudioFirmware::curle_to_net_error(CURLcode curle)
|
|||
|
||||
void BrokeStudioFirmware::downloadFile(std::string const& url, uint8 path, uint8 file) {
|
||||
UDBG("RAINBOW BrokeStudioFirmware download %s -> (%u,%u)\n", url.c_str(), (unsigned int)path, (unsigned int)file);
|
||||
//TODO asynchronous download using curl_multi_* (and maybe a thread, or regular ticks on rx/tx/getGpio4)
|
||||
//TODO asynchronous download using curl_multi_* (and maybe a thread, or regular ticks on rx/tx/getDataReadyIO)
|
||||
|
||||
// Directly fail if the curl handle was not properly initialized
|
||||
if (this->curl_handle == nullptr) {
|
||||
|
|
|
@ -46,8 +46,7 @@ public:
|
|||
void rx(uint8 v) override;
|
||||
uint8 tx() override;
|
||||
|
||||
virtual void setGpio4(bool v) override;
|
||||
virtual bool getGpio4() override;
|
||||
virtual bool getDataReadyIO() override;
|
||||
|
||||
private:
|
||||
// Defined message types from CPU to ESP
|
||||
|
|
Loading…
Reference in New Issue